2
* utils.h - Part of the Linux-NTFS project.
4
* Copyright (c) 2002-2003 Richard Russon
5
* Copyright (c) 2004 Anton Altaparmakov
7
* A set of shared functions for ntfs utilities
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.
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.
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
25
#ifndef _NTFS_UTILS_H_
26
#define _NTFS_UTILS_H_
38
extern const char *ntfs_bugs;
39
extern const char *ntfs_home;
40
extern const char *ntfs_gpl;
45
#if !defined(REG_NOERROR) || (REG_NOERROR != 0)
46
# define REG_NOERROR 0
49
#define DEC_PRINTF(NAME) \
50
int NAME (const char *format, ...) \
51
__attribute__ ((format (printf, 1, 2)));
53
#define GEN_PRINTF(NAME, STREAM, CONTROL, TRIGGER) \
54
__attribute__ ((format (printf, 1, 2))) \
55
int NAME (const char *format, ...) \
57
int ret, olderr = errno, *control = (CONTROL); \
63
((*control && !(TRIGGER)) || (!*control && (TRIGGER)))) \
66
va_start (args, format); \
67
ret = vfprintf ((STREAM), format, args); \
75
int ntfs_printf (struct _IO_FILE *stream, int *control, BOOL trigger,
76
const char *format, ...) __attribute__ ((format (printf, 4, 5)));
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);
91
time_t ntfs2utc (s64 ntfs_time);
92
s64 utc2ntfs (time_t utc_time);
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);
99
* if *not in use* then the other flags are ignored?
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
112
* struct mft_search_ctx
114
struct mft_search_ctx {
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);
126
#endif /* _NTFS_UTILS_H_ */