add recover/norecover options, obsolete force option, recover from unclean journal by default

master
szaka 2009-02-10 13:00:04 +00:00
parent 84ef1c5f9d
commit 5157bd2fd3
5 changed files with 47 additions and 51 deletions

View File

@ -4,7 +4,7 @@
* Copyright (c) 2000-2004 Anton Altaparmakov
* Copyright (c) 2004-2005 Richard Russon
* Copyright (c) 2005-2006 Yura Pakhuchiy
* Copyright (c) 2005-2008 Szabolcs Szakacsits
* Copyright (c) 2005-2009 Szabolcs Szakacsits
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@ -52,8 +52,8 @@
#define MS_EXCLUSIVE 0x08000000
#ifndef MS_FORCE
#define MS_FORCE 0x10000000
#ifndef MS_RECOVER
#define MS_RECOVER 0x10000000
#endif
#define MS_IGNORE_HIBERFILE 0x20000000

View File

@ -3,7 +3,7 @@
*
* Copyright (c) 2002-2005 Anton Altaparmakov
* Copyright (c) 2005 Yura Pakhuchiy
* Copyright (c) 2005-2006 Szabolcs Szakacsits
* Copyright (c) 2005-2009 Szabolcs Szakacsits
*
* This program/include file is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published
@ -676,8 +676,8 @@ BOOL ntfs_is_logfile_clean(ntfs_attr *log_na, RESTART_PAGE_HEADER *rp)
*/
if (ra->client_in_use_list != LOGFILE_NO_CLIENT &&
!(ra->flags & RESTART_VOLUME_IS_CLEAN)) {
ntfs_log_error("$LogFile indicates unclean shutdown (%d, %d)\n",
le16_to_cpu(ra->client_in_use_list),
ntfs_log_error("The disk contains an unclean file system (%d, "
"%d).\n", le16_to_cpu(ra->client_in_use_list),
le16_to_cpu(ra->flags));
return FALSE;
}

View File

@ -94,14 +94,8 @@ static const char *hibernated_volume_msg =
"\n";
static const char *unclean_journal_msg =
"Mount is denied because NTFS is marked to be in use. Choose one action:\n"
"\n"
"Choice 1: If you have Windows then disconnect the external devices by\n"
" clicking on the 'Safely Remove Hardware' icon in the Windows\n"
" taskbar then shutdown Windows cleanly.\n"
"\n"
"Choice 2: If you don't have Windows then you can use the 'force' option for\n"
" your own responsibility. For example type on the command line:\n";
"Write access is denied because the disk wasn't safely powered\n"
"off and the 'norecover' mount option was specified.\n";
static const char *opened_volume_msg =
"Mount is denied because the NTFS volume is already exclusively opened.\n"
@ -119,14 +113,6 @@ static const char *access_denied_msg =
"and the mounting user ID. More explanation is provided at\n"
"http://ntfs-3g.org/support.html#unprivileged\n";
static const char *forced_mount_msg =
"\n"
" mount -t ntfs-3g -o force %s %s\n"
"\n"
" Or add the option to the relevant row in the /etc/fstab file:\n"
"\n"
" %s %s ntfs-3g force 0 0\n";
/**
* ntfs_volume_alloc - Create an NTFS volume object and initialise it
*
@ -1115,9 +1101,10 @@ ntfs_volume *ntfs_device_mount(struct ntfs_device *dev, unsigned long flags)
ntfs_volume_check_hiberfile(vol, 1) < 0)
goto error_exit;
if (ntfs_volume_check_logfile(vol) < 0) {
if (!(flags & MS_FORCE))
if (!(flags & MS_RECOVER))
goto error_exit;
ntfs_log_info("WARNING: Forced mount, reset $LogFile.\n");
ntfs_log_info("The file system wasn't safely "
"closed on Windows. Fixing.\n");
if (ntfs_logfile_reset(vol))
goto error_exit;
}
@ -1548,8 +1535,6 @@ void ntfs_mount_error(const char *volume, const char *mntpoint, int err)
break;
case NTFS_VOLUME_UNCLEAN_UNMOUNT:
ntfs_log_error("%s", unclean_journal_msg);
ntfs_log_error(forced_mount_msg, volume, mntpoint,
volume, mntpoint);
break;
case NTFS_VOLUME_LOCKED:
ntfs_log_error("%s", opened_volume_msg);

View File

@ -104,13 +104,7 @@ present. The value is given in octal. The default value is 0 which
means full access to everybody.
.TP
.B ro
Mount filesystem read\-only. Useful if Windows is hibernated or the
NTFS journal file is unclean.
.TP
.B force
Force the mounting even if the NTFS logfile is unclean. The logfile
will be unconditionally cleared. Use this option with caution and for
your own responsibility.
Mount filesystem read\-only. Useful if Windows is hibernated.
.TP
.B remove_hiberfile
Unlike in case of read-only mount, the read-write mount is denied if
@ -120,6 +114,11 @@ hibernation file. Please note, this means that the saved Windows
session will be completely lost. Use this option for your own
responsibility.
.TP
.B recover, norecover
Recover and repair a corrupted or inconsistent
NTFS volume if it's possible. The default behaviour is
.B recover.
.TP
.B atime, noatime, relatime
The
.B atime
@ -178,9 +177,15 @@ file:stream). If it's set to \fBxattr\fR, then the named data streams are
mapped to xattrs and user can manipulate them using \fB{get,set}fattr\fR
utilities. The default is \fBnone\fR.
.TP
.B force
This mount option is not used anymore. It was superseded by the
.B recover
and
.B norecover
options.
.TP
.B debug
Makes ntfs-3g to not detach from terminal and print a lot of debug output from
libntfs-3g and FUSE.
Makes ntfs-3g to not detach from terminal and print a lot of driver debug output.
.TP
.B no_detach
Same as above but with less debug output.

View File

@ -129,7 +129,7 @@ typedef struct {
BOOL ro;
BOOL show_sys_files;
BOOL silent;
BOOL force;
BOOL recover;
BOOL hiberfile;
BOOL debug;
BOOL no_detach;
@ -153,16 +153,18 @@ static const char *usage_msg =
"\n"
"%s %s %s %d - Third Generation NTFS Driver\n"
"\n"
"Copyright (C) 2006-2008 Szabolcs Szakacsits\n"
"Copyright (C) 2005-2007 Yura Pakhuchiy\n"
"Copyright (C) 2006-2009 Szabolcs Szakacsits\n"
"Copyright (C) 2007-2009 Jean-Pierre Andre\n"
"Copyright (C) 2009 Erik Larsson\n"
"\n"
"Usage: %s [-o option[,...]] <device|image_file> <mount_point>\n"
"\n"
"Options: ro (read-only mount), force, remove_hiberfile, uid=,\n"
" gid=, umask=, fmask=, dmask=, streams_interface=.\n"
" Please see the details in the manual.\n"
"Options: ro (read-only mount), remove_hiberfile, uid=, gid=,\n"
" umask=, fmask=, dmask=, streams_interface=.\n"
" Please see the details in the manual (type: man ntfs-3g).\n"
"\n"
"Examples: ntfs-3g -o force /dev/sda1 /mnt/windows\n"
"Example: ntfs-3g /dev/sda1 /mnt/windows\n"
"\n"
"%s";
@ -1698,9 +1700,12 @@ static int ntfs_fuse_init(void)
return -1;
*ctx = (ntfs_fuse_context_t) {
.uid = getuid(),
.gid = getgid(),
.uid = getuid(),
.gid = getgid(),
.streams = NF_STREAMS_INTERFACE_NONE,
.atime = ATIME_RELATIVE,
.silent = TRUE,
.recover = TRUE
};
return 0;
}
@ -1713,8 +1718,8 @@ static int ntfs_open(const char *device)
flags |= MS_EXCLUSIVE;
if (ctx->ro)
flags |= MS_RDONLY;
if (ctx->force)
flags |= MS_FORCE;
if (ctx->recover)
flags |= MS_RECOVER;
if (ctx->hiberfile)
flags |= MS_IGNORE_HIBERFILE;
@ -1814,9 +1819,6 @@ static char *parse_mount_options(const char *orig_opts)
return NULL;
}
ctx->silent = TRUE;
ctx->atime = ATIME_RELATIVE;
s = options;
while (s && *s && (val = strsep(&s, ","))) {
opt = strsep(&val, "=");
@ -1892,10 +1894,14 @@ static char *parse_mount_options(const char *orig_opts)
if (bogus_option_value(val, "silent"))
goto err_exit;
ctx->silent = TRUE;
} else if (!strcmp(opt, "force")) {
if (bogus_option_value(val, "force"))
} else if (!strcmp(opt, "recover")) {
if (bogus_option_value(val, "recover"))
goto err_exit;
ctx->force = TRUE;
ctx->recover = TRUE;
} else if (!strcmp(opt, "norecover")) {
if (bogus_option_value(val, "norecover"))
goto err_exit;
ctx->recover = FALSE;
} else if (!strcmp(opt, "remove_hiberfile")) {
if (bogus_option_value(val, "remove_hiberfile"))
goto err_exit;