#include <mntent.h>
#endif
-/*
- * Under Cygwin, DJGPP and FreeBSD we do not have MS_RDONLY,
- * so we define them ourselves.
- */
-#ifndef MS_RDONLY
-#define MS_RDONLY 1
-#endif
-
-#define MS_EXCLUSIVE 0x08000000
-
-#ifndef MS_RECOVER
-#define MS_RECOVER 0x10000000
-#endif
-
-#define MS_IGNORE_HIBERFILE 0x20000000
-#define MS_FORENSIC 0x04000000 /* No modification during mount */
-
/* Forward declaration */
typedef struct _ntfs_volume ntfs_volume;
/**
* enum ntfs_mount_flags -
*
+ * Flags for the ntfs_mount() function.
+ */
+enum {
+ NTFS_MNT_NONE = 0x00000000,
+ NTFS_MNT_RDONLY = 0x00000001,
+ NTFS_MNT_FORENSIC = 0x04000000, /* No modification during
+ * mount. */
+ NTFS_MNT_EXCLUSIVE = 0x08000000,
+ NTFS_MNT_RECOVER = 0x10000000,
+ NTFS_MNT_IGNORE_HIBERFILE = 0x20000000,
+};
+typedef unsigned long ntfs_mount_flags;
+
+/**
+ * enum ntfs_mounted_flags -
+ *
* Flags returned by the ntfs_check_if_mounted() function.
*/
typedef enum {
NTFS_MF_MOUNTED = 1, /* Device is mounted. */
NTFS_MF_ISROOT = 2, /* Device is mounted as system root. */
NTFS_MF_READONLY = 4, /* Device is mounted read-only. */
-} ntfs_mount_flags;
+} ntfs_mounted_flags;
extern int ntfs_check_if_mounted(const char *file, unsigned long *mnt_flags);
extern ntfs_volume *ntfs_volume_alloc(void);
extern ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev,
- unsigned long flags);
+ ntfs_mount_flags flags);
extern ntfs_volume *ntfs_device_mount(struct ntfs_device *dev,
- unsigned long flags);
+ ntfs_mount_flags flags);
-extern ntfs_volume *ntfs_mount(const char *name, unsigned long flags);
+extern ntfs_volume *ntfs_mount(const char *name, ntfs_mount_flags flags);
extern int ntfs_umount(ntfs_volume *vol, const BOOL force);
extern int ntfs_version_is_supported(ntfs_volume *vol);
* Return the allocated volume structure on success and NULL on error with
* errno set to the error code.
*/
-ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev, unsigned long flags)
+ntfs_volume *ntfs_volume_startup(struct ntfs_device *dev,
+ ntfs_mount_flags flags)
{
LCN mft_zone_size, mft_lcn;
s64 br;
#else
NVolClearCompression(vol);
#endif
- if (flags & MS_RDONLY)
+ if (flags & NTFS_MNT_RDONLY)
NVolSetReadOnly(vol);
/* ...->open needs bracketing to compile with glibc 2.7 */
* @flags is an optional second parameter. The same flags are used as for
* the mount system call (man 2 mount). Currently only the following flag
* is implemented:
- * MS_RDONLY - mount volume read-only
+ * NTFS_MNT_RDONLY - mount volume read-only
*
* The function opens the device @dev and verifies that it contains a valid
* bootsector. Then, it allocates an ntfs_volume structure and initializes
* Return the allocated volume structure on success and NULL on error with
* errno set to the error code.
*/
-ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long flags)
+ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, ntfs_mount_flags flags)
{
s64 l;
ntfs_volume *vol;
* Check for dirty logfile and hibernated Windows.
* We care only about read-write mounts.
*/
- if (!(flags & (MS_RDONLY | MS_FORENSIC))) {
- if (!(flags & MS_IGNORE_HIBERFILE) &&
+ if (!(flags & (NTFS_MNT_RDONLY | NTFS_MNT_FORENSIC))) {
+ if (!(flags & NTFS_MNT_IGNORE_HIBERFILE) &&
ntfs_volume_check_hiberfile(vol, 1) < 0)
goto error_exit;
if (ntfs_volume_check_logfile(vol) < 0) {
/* Always reject cached metadata for now */
- if (!(flags & MS_RECOVER) || (errno == EPERM))
+ if (!(flags & NTFS_MNT_RECOVER) || (errno == EPERM))
goto error_exit;
ntfs_log_info("The file system wasn't safely "
"closed on Windows. Fixing.\n");
* @flags is an optional second parameter. The same flags are used as for
* the mount system call (man 2 mount). Currently only the following flags
* is implemented:
- * MS_RDONLY - mount volume read-only
+ * NTFS_MNT_RDONLY - mount volume read-only
*
* The function opens the device or file @name and verifies that it contains a
* valid bootsector. Then, it allocates an ntfs_volume structure and initializes
* soon as the function returns.
*/
ntfs_volume *ntfs_mount(const char *name __attribute__((unused)),
- unsigned long flags __attribute__((unused)))
+ ntfs_mount_flags flags __attribute__((unused)))
{
#ifndef NO_NTFS_DEVICE_DEFAULT_IO_OPS
struct ntfs_device *dev;
utils_set_locale();
- vol = utils_mount_volume(opts.device, MS_RDONLY |
- (opts.force ? MS_RECOVER : 0));
+ vol = utils_mount_volume(opts.device, NTFS_MNT_RDONLY |
+ (opts.force ? NTFS_MNT_RECOVER : 0));
if (!vol) {
ntfs_log_perror("ERROR: couldn't mount volume");
return 1;
// at this point we know that the volume is valid enough for mounting.
/* Call ntfs_device_mount() to do the actual mount. */
- vol = ntfs_device_mount(dev, MS_RDONLY);
+ vol = ntfs_device_mount(dev, NTFS_MNT_RDONLY);
if (!vol) {
ntfs_device_free(dev);
return 2;
{
s64 device_size;
- mount_volume(MS_RDONLY);
+ mount_volume(NTFS_MNT_RDONLY);
device_size = ntfs_device_size_get(vol->dev, 1);
if (device_size <= 0)
FIXME: use mount flags to avoid potential side-effects in future */
opt.force++;
ntfs_umount(vol,FALSE);
- mount_volume(0 /*MS_NOATIME*/);
+ mount_volume(0 /*NTFS_MNT_NOATIME*/);
}
free(lcn_bitmap.bm);
utils_set_locale();
- vol = utils_mount_volume(opts.device, MS_RDONLY |
- (opts.force ? MS_RECOVER : 0));
+ vol = utils_mount_volume(opts.device, NTFS_MNT_RDONLY |
+ (opts.force ? NTFS_MNT_RECOVER : 0));
if (!vol)
return 1;
"You must 'umount' it first.\n", volume);
}
- vol = ntfs_mount(volume, MS_RDONLY);
+ vol = ntfs_mount(volume, NTFS_MNT_RDONLY);
if (vol == NULL) {
int err = errno;
}
if (opts.noaction)
- flags = MS_RDONLY;
+ flags = NTFS_MNT_RDONLY;
if (opts.force)
- flags |= MS_RECOVER;
+ flags |= NTFS_MNT_RECOVER;
vol = utils_mount_volume(opts.device, flags);
if (!vol) {
return 1;
}
/* Mount the ntfs volume. */
- vol = utils_mount_volume(opts.device, MS_RDONLY |
- (opts.force ? MS_RECOVER : 0));
+ vol = utils_mount_volume(opts.device, NTFS_MNT_RDONLY |
+ (opts.force ? NTFS_MNT_RECOVER : 0));
if (!vol) {
ntfs_log_error("Failed to mount ntfs volume. Aborting.\n");
ntfs_rsa_private_key_release(rsa_key);
/* Porting note: NTFS_MNT_FORENSIC is not needed when we mount
* the volume in read-only mode. No changes will be made to the
* logfile or anything else when we are in read only-mode. */
- vol = ntfs_mount(filename, MS_RDONLY);
+ vol = ntfs_mount(filename, NTFS_MNT_RDONLY);
if (!vol)
log_err_exit(NULL, "Failed to mount %s: %s\n",
filename, strerror(errno));
NVolSetShowSysFiles(vol);
NVolSetShowHidFiles(vol);
NVolClearHideDotFiles(vol);
- if (flags & MS_RDONLY)
+ if (flags & NTFS_MNT_RDONLY)
NVolSetReadOnly(vol);
/* ...->open needs bracketing to compile with glibc 2.7 */
ntfs_log_perror("Failed to allocate device");
return -1;
}
- flags = (opt.no_action ? MS_RDONLY : 0);
+ flags = (opt.no_action ? NTFS_MNT_RDONLY : 0);
vol = ntfs_volume_startup(dev, flags);
if (!vol) {
ntfs_log_info(FAILED);
ntfs_log_perror("Failed to determine whether %s is mounted",
opt.volume);
/* Attempt a full mount first. */
- flags = (opt.no_action ? MS_RDONLY : 0);
+ flags = (opt.no_action ? NTFS_MNT_RDONLY : 0);
ntfs_log_info("Mounting volume... ");
vol = ntfs_mount(opt.volume, flags);
if (vol) {
utils_set_locale();
- vol = utils_mount_volume(opts.device, MS_RDONLY |
- (opts.force ? MS_RECOVER : 0));
+ vol = utils_mount_volume(opts.device, NTFS_MNT_RDONLY |
+ (opts.force ? NTFS_MNT_RECOVER : 0));
if (!vol) {
printf("Failed to open '%s'.\n", opts.device);
exit(1);
opts.noaction++;
vol = utils_mount_volume(opts.device,
- (opts.noaction ? MS_RDONLY : 0) |
- (opts.force ? MS_RECOVER : 0));
+ (opts.noaction ? NTFS_MNT_RDONLY : 0) |
+ (opts.force ? NTFS_MNT_RECOVER : 0));
if (!vol)
return 1;
utils_set_locale();
- vol = utils_mount_volume(opts.device, MS_RDONLY |
- (opts.force ? MS_RECOVER : 0));
+ vol = utils_mount_volume(opts.device, NTFS_MNT_RDONLY |
+ (opts.force ? NTFS_MNT_RECOVER : 0));
if (!vol) {
// FIXME: Print error... (AIA)
return 2;
/* Mount the device. */
if (opts.no_action) {
ntfs_log_quiet("Running in READ-ONLY mode!\n");
- ul = MS_RDONLY;
+ ul = NTFS_MNT_RDONLY;
} else
ul = 0;
vol = ntfs_mount(dev_name, ul);
utils_set_locale();
if (opts.noaction)
- flags |= MS_RDONLY;
+ flags |= NTFS_MNT_RDONLY;
if (opts.force)
- flags |= MS_RECOVER;
+ flags |= NTFS_MNT_RECOVER;
vol = utils_mount_volume(opts.device, flags);
if (!vol) {
opt.infombonly++;
break;
case 'n':
- opt.ro_flag = MS_RDONLY;
+ opt.ro_flag = NTFS_MNT_RDONLY;
break;
case 'P':
opt.show_progress = 0;
err++;
}
if (opt.info || opt.infombonly) {
- opt.ro_flag = MS_RDONLY;
+ opt.ro_flag = NTFS_MNT_RDONLY;
}
if (opt.bytes
&& (opt.expand || opt.info || opt.infombonly)) {
ntfs_volume *myvol = NULL;
/*
- * Pass MS_FORENSIC so that the mount process does not modify the
+ * Pass NTFS_MNT_FORENSIC so that the mount process does not modify the
* volume at all. We will do the logfile emptying and dirty setting
* later if needed.
*/
- if (!(myvol = ntfs_mount(opt.volume, opt.ro_flag | MS_FORENSIC))) {
+ if (!(myvol = ntfs_mount(opt.volume, opt.ro_flag | NTFS_MNT_FORENSIC)))
+ {
int err = errno;
perr_printf("Opening '%s' as NTFS failed", opt.volume);
/* Mount the device. */
if (opts.no_action) {
ntfs_log_quiet("Running in READ-ONLY mode!\n");
- ul = MS_RDONLY;
+ ul = NTFS_MNT_RDONLY;
} else
ul = 0;
vol = ntfs_mount(dev_name, ul);
utils_set_locale();
- vol = utils_mount_volume(opts.device, MS_RDONLY |
- (opts.force ? MS_RECOVER : 0));
+ vol = utils_mount_volume(opts.device, NTFS_MNT_RDONLY |
+ (opts.force ? NTFS_MNT_RECOVER : 0));
if (!vol)
return 1;
print_summary();
if (opts.info || opts.noaction)
- flags = MS_RDONLY;
+ flags = NTFS_MNT_RDONLY;
if (opts.force)
- flags |= MS_RECOVER;
+ flags |= NTFS_MNT_RECOVER;
vol = utils_mount_volume(opts.device, flags);
if (!vol)
*
* libntfs-3g only has safety check number 2. The dirty flag is simply
* ignored because we are confident that we can handle a dirty volume.
- * So we treat MS_RECOVER like NTFS_MNT_FORCE, knowing that the first
- * check is always bypassed.
+ * So we treat NTFS_MNT_RECOVER like NTFS_MNT_FORCE, knowing that the
+ * first check is always bypassed.
*/
- if (!utils_valid_device(device, flags & MS_RECOVER))
+ if (!utils_valid_device(device, flags & NTFS_MNT_RECOVER))
return NULL;
vol = ntfs_mount(device, flags);
* before mount, so we can only warn if the VOLUME_IS_DIRTY flag is set
* in VOLUME_INFORMATION. */
if (vol->flags & VOLUME_IS_DIRTY) {
- if (!(flags & MS_RECOVER)) {
+ if (!(flags & NTFS_MNT_RECOVER)) {
ntfs_log_error("%s", dirty_volume_msg);
ntfs_umount(vol, FALSE);
return NULL;
ntfs_volume *vol;
if (!ctx->blkdev)
- flags |= MS_EXCLUSIVE;
+ flags |= NTFS_MNT_EXCLUSIVE;
if (ctx->ro)
- flags |= MS_RDONLY;
+ flags |= NTFS_MNT_RDONLY;
if (ctx->recover)
- flags |= MS_RECOVER;
+ flags |= NTFS_MNT_RECOVER;
if (ctx->hiberfile)
- flags |= MS_IGNORE_HIBERFILE;
+ flags |= NTFS_MNT_IGNORE_HIBERFILE;
ctx->vol = vol = ntfs_mount(device, flags);
if (!vol) {
unsigned long flags = 0;
if (!ctx->blkdev)
- flags |= MS_EXCLUSIVE;
+ flags |= NTFS_MNT_EXCLUSIVE;
if (ctx->ro)
- flags |= MS_RDONLY;
+ flags |= NTFS_MNT_RDONLY;
if (ctx->recover)
- flags |= MS_RECOVER;
+ flags |= NTFS_MNT_RECOVER;
if (ctx->hiberfile)
- flags |= MS_IGNORE_HIBERFILE;
+ flags |= NTFS_MNT_IGNORE_HIBERFILE;
ctx->vol = ntfs_mount(device, flags);
if (!ctx->vol) {
int ret = NTFS_VOLUME_OK;
if (opts.probetype == PROBE_READONLY)
- flags |= MS_RDONLY;
+ flags |= NTFS_MNT_RDONLY;
vol = ntfs_mount(device, flags);
if (!vol)
#endif /* STSC */
-#define MS_NONE 0 /* no flag for mounting the device */
-#define MS_RDONLY 1 /* flag for mounting the device read-only */
+#define NTFS_MNT_NONE 0 /* no flag for mounting the device */
+#define NTFS_MNT_RDONLY 1 /* flag for mounting the device read-only */
struct CALLBACK;
err = FALSE;
if (!getuid()) {
if (open_security_api()) {
- if (open_volume(volume,MS_NONE)) {
+ if (open_volume(volume,NTFS_MNT_NONE)) {
if (restore(fd)) err = TRUE;
close_volume(volume);
} else {
now = time((time_t*)NULL);
txtime = ctime(&now);
if (!getuid() && open_security_api()) {
- if (open_volume(volume,MS_RDONLY)) {
+ if (open_volume(volume,NTFS_MNT_RDONLY)) {
printf("#\n# Recursive ACL collection on %s#\n",txtime);
err = recurseshow(root);
count = 0;
int count;
if (!getuid() && open_security_api()) {
- if (open_volume(volume,MS_RDONLY)) {
+ if (open_volume(volume,NTFS_MNT_RDONLY)) {
if (opt_r) {
printf("\nRecursive file check\n");
err = recurseshow(root);
err = FALSE;
if (!getuid() && open_security_api()) {
- if (open_volume(volume,MS_RDONLY)) {
+ if (open_volume(volume,NTFS_MNT_RDONLY)) {
attrsz = 0;
securindex = ntfs_get_file_security(ntfs_context,name,
err = FALSE;
if (!getuid() && open_security_api()) {
- if (open_volume(volume,MS_RDONLY)) {
+ if (open_volume(volume,NTFS_MNT_RDONLY)) {
if (audit_sds(FALSE)) err = TRUE;
if (audit_sds(TRUE)) err = TRUE;
if (audit_sii()) err = TRUE;
pxdesc = encode_posix_acl(p);
if (pxdesc) {
if (!getuid() && open_security_api()) {
- if (open_volume(argv[xarg],MS_NONE)) {
+ if (open_volume(argv[xarg],NTFS_MNT_NONE)) {
if (opt_r) {
for (i=0; i<(MAXSECURID + (1 << SECBLKSZ) - 1)/(1 << SECBLKSZ); i++)
securdata[i] = (struct SECURITY_DATA*)NULL;
cmderr = TRUE;
} else
if (!getuid() && open_security_api()) {
- if (open_volume(argv[xarg],MS_NONE)) {
+ if (open_volume(argv[xarg],NTFS_MNT_NONE)) {
if (opt_r) {
for (i=0; i<(MAXSECURID + (1 << SECBLKSZ) - 1)/(1 << SECBLKSZ); i++)
securdata[i] = (struct SECURITY_DATA*)NULL;
typedef u32 DWORD; /* must be 32 bits whatever the platform */
typedef DWORD *LPDWORD;
-#define MS_NONE 0 /* no flag for mounting the device */
-#define MS_RDONLY 1 /* flag for mounting the device read-only */
+#define NTFS_MNT_NONE 0 /* no flag for mounting the device */
+#define NTFS_MNT_RDONLY 1 /* flag for mounting the device read-only */
#endif /* WIN32 */