From fbfbe3b48ea4b3d0ad238f8d8868c146316316b0 Mon Sep 17 00:00:00 2001 From: yura Date: Sat, 25 Nov 2006 21:44:35 +0000 Subject: [PATCH] force distro developers to fix their broken init scripts --- ntfsprogs/ntfsmount.c | 17 ++++++++++++++++- ntfsprogs/utils.c | 7 ++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ntfsprogs/ntfsmount.c b/ntfsprogs/ntfsmount.c index 75c5500e..67f89ccc 100644 --- a/ntfsprogs/ntfsmount.c +++ b/ntfsprogs/ntfsmount.c @@ -101,6 +101,7 @@ typedef struct { BOOL debug; BOOL noatime; BOOL no_detach; + BOOL leave_dirty; } ntfs_fuse_context_t; typedef enum { @@ -1359,6 +1360,10 @@ exit: static void ntfs_fuse_destroy(void *priv __attribute__((unused))) { if (ctx->vol) { + if (!ctx->leave_dirty && ntfs_volume_write_flags(ctx->vol, + ctx->vol->flags & ~VOLUME_IS_DIRTY)) + ntfs_log_error("Failed to clear volume dirty flag. " + "OK, leave it, chkdsk will handle.\n"); ntfs_log_info("Unmounting %s (%s)\n", opts.device, ctx->vol->vol_name); if (ntfs_umount(ctx->vol, FALSE)) @@ -1426,10 +1431,20 @@ static int ntfs_fuse_mount(const char *device) return -1; } ctx->vol = vol; + if (vol->flags & VOLUME_IS_DIRTY) + ctx->leave_dirty = TRUE; + else { + if (ntfs_volume_write_flags(vol, vol->flags | + VOLUME_IS_DIRTY)) { + ntfs_log_perror("Failed to set temporary dirty flag"); + ntfs_umount(vol, FALSE); + ctx->vol = NULL; + return -1; + } + } return 0; } - static void signal_handler(int arg __attribute__((unused))) { fuse_exit((fuse_get_context())->fuse); diff --git a/ntfsprogs/utils.c b/ntfsprogs/utils.c index 8ae69a7d..807d789e 100644 --- a/ntfsprogs/utils.c +++ b/ntfsprogs/utils.c @@ -114,7 +114,12 @@ static const char *opened_volume_msg = static const char *dirty_volume_msg = "Volume is scheduled for check.\n" -"Please boot into Windows TWICE, or use the 'force' option.\n"; +"Please boot into Windows TWICE, or use the 'force' option.\n" +"NOTE: If you had not scheduled check and last time accessed this volume\n" +"using ntfsmount and shutdown system properly, then init scripts in your\n" +"distribution are broken. Please report to your distribution developers\n" +"(NOT to us!) that init scripts kill ntfsmount or mount.ntfs-fuse during\n" +"shutdown instead of proper umount.\n"; /** * utils_set_locale