~ubuntu-branches/ubuntu/warty/linux-ntfs/warty

« back to all changes in this revision

Viewing changes to ntfsprogs/utils.h

  • Committer: Bazaar Package Importer
  • Author(s): David Martínez Moreno
  • Date: 2004-03-12 00:03:30 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040312000330-xv94ve7yg6bwplwu
Tags: 1.9.0-1
* New upstream release:
  - Merged Debian diff with upstream.
  - Fixed mkntfs for large volumes.
  - Add relocation support to ntfsresize. This modifies the command line
    options a little as well as the returned output so applications using
    ntfsresize might need modifications before they will work with the
    updated ntfsresize.
  - Revamped the build system completely.
  - Provide always own byteswap constant versions in order to avoid the mess
    that some architectures define only some of them (read m68k, ppc,
    mips...).
  - Made the warnings on 64 bit architectures go away.
  - Fixed lots of typos in the documentation.
  - Lots of fixes in general.
* Resolved several FTBFS (Fail To Build From Source) bugs (closes: #226989,
  #234104). With this, all the architectures go in sync again.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * utils.h - Part of the Linux-NTFS project.
 
3
 *
 
4
 * Copyright (c) 2002-2003 Richard Russon
 
5
 * Copyright (c) 2004 Anton Altaparmakov
 
6
 *
 
7
 * A set of shared functions for ntfs utilities
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or modify
 
10
 * it under the terms of the GNU General Public License as published by
 
11
 * the Free Software Foundation; either version 2 of the License, or
 
12
 * (at your option) any later version.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this program (in the main directory of the Linux-NTFS
 
21
 * distribution in the file COPYING); if not, write to the Free Software
 
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
23
 */
 
24
 
 
25
#ifndef _NTFS_UTILS_H_
 
26
#define _NTFS_UTILS_H_
 
27
 
 
28
#include "config.h"
 
29
 
 
30
#include "types.h"
 
31
#include "layout.h"
 
32
#include "volume.h"
 
33
 
 
34
#include <errno.h>
 
35
#include <stdarg.h>
 
36
#include <regex.h>
 
37
 
 
38
extern const char *ntfs_bugs;
 
39
extern const char *ntfs_home;
 
40
extern const char *ntfs_gpl;
 
41
 
 
42
#define PATH_SEP        '/'
 
43
#define MAX_PATH        1024
 
44
 
 
45
#if !defined(REG_NOERROR) || (REG_NOERROR != 0)
 
46
#       define REG_NOERROR 0
 
47
#endif
 
48
 
 
49
#define DEC_PRINTF(NAME)                                                        \
 
50
        int NAME (const char *format, ...)                                      \
 
51
        __attribute__ ((format (printf, 1, 2)));
 
52
 
 
53
#define GEN_PRINTF(NAME, STREAM, CONTROL, TRIGGER)                              \
 
54
        __attribute__ ((format (printf, 1, 2)))                                 \
 
55
        int NAME (const char *format, ...)                                      \
 
56
        {                                                                       \
 
57
                int ret, olderr = errno, *control = (CONTROL);                  \
 
58
                va_list args;                                                   \
 
59
                                                                                \
 
60
                if (!(STREAM))                                                  \
 
61
                        return -1;                                              \
 
62
                if (control &&                                                  \
 
63
                   ((*control && !(TRIGGER)) || (!*control && (TRIGGER))))      \
 
64
                        return -1;                                              \
 
65
                                                                                \
 
66
                va_start (args, format);                                        \
 
67
                ret = vfprintf ((STREAM), format, args);                        \
 
68
                va_end (args);                                                  \
 
69
                errno = olderr;                                                 \
 
70
                return ret;                                                     \
 
71
        }
 
72
 
 
73
struct _IO_FILE;
 
74
 
 
75
int ntfs_printf (struct _IO_FILE *stream, int *control, BOOL trigger,
 
76
                const char *format, ...) __attribute__ ((format (printf, 4, 5)));
 
77
 
 
78
int utils_valid_device (const char *name, int force);
 
79
int utils_set_locale (void);
 
80
ntfs_volume * utils_mount_volume (const char *device, unsigned long flags, BOOL force);
 
81
int utils_parse_size (const char *value, s64 *size, BOOL scale);
 
82
int utils_parse_range (const char *string, s64 *start, s64 *finish, BOOL scale);
 
83
int utils_inode_get_name (ntfs_inode *inode, char *buffer, int bufsize);
 
84
int utils_attr_get_name (ntfs_volume *vol, ATTR_RECORD *attr, char *buffer, int bufsize);
 
85
int utils_cluster_in_use (ntfs_volume *vol, long long lcn);
 
86
int utils_mftrec_in_use (ntfs_volume *vol, MFT_REF mref);
 
87
int utils_is_metadata (ntfs_inode *inode);
 
88
ntfs_inode * utils_pathname_to_inode (ntfs_volume *vol, ntfs_inode *parent, const char *pathname);
 
89
void utils_dump_mem (u8 *buf, int start, int length, int ascii);
 
90
 
 
91
time_t ntfs2utc (s64 ntfs_time);
 
92
s64 utc2ntfs (time_t utc_time);
 
93
 
 
94
ATTR_RECORD * find_attribute (const ATTR_TYPES type, ntfs_attr_search_ctx *ctx);
 
95
ATTR_RECORD * find_first_attribute (const ATTR_TYPES type, MFT_RECORD *mft);
 
96
 
 
97
/**
 
98
 * defines...
 
99
 * if *not in use* then the other flags are ignored?
 
100
 */
 
101
#define FEMR_IN_USE             1 << 0
 
102
#define FEMR_NOT_IN_USE         1 << 1
 
103
#define FEMR_FILE               1 << 2          // $DATA
 
104
#define FEMR_DIR                1 << 3          // $INDEX_ROOT, "$I30"
 
105
#define FEMR_METADATA           1 << 4
 
106
#define FEMR_NOT_METADATA       1 << 5
 
107
#define FEMR_BASE_RECORD        1 << 6
 
108
#define FEMR_NOT_BASE_RECORD    1 << 7
 
109
#define FEMR_ALL_RECORDS        0xFF
 
110
 
 
111
/**
 
112
 * struct mft_search_ctx
 
113
 */
 
114
struct mft_search_ctx {
 
115
        int flags_search;
 
116
        int flags_match;
 
117
        ntfs_inode *inode;
 
118
        u64 mft_num;
 
119
        ntfs_volume *vol;
 
120
};
 
121
 
 
122
struct mft_search_ctx * mft_get_search_ctx (ntfs_volume *vol);
 
123
void mft_put_search_ctx (struct mft_search_ctx *ctx);
 
124
int mft_next_record (struct mft_search_ctx *ctx);
 
125
 
 
126
#endif /* _NTFS_UTILS_H_ */