Changes by: aia21
Update of /cvs/linux-ntfs/ntfsprogs/ntfsprogs
In directory delta357:/tmp/cvs-serv3630/ntfsprogs
Modified Files:
ntfscat.c ntfscat.h ntfsclone.c ntfscp.c ntfsdump_logfile.c
ntfsfix.c ntfsinfo.c ntfsmount.c ntfsmove.c ntfsresize.c
ntfswipe.c utils.c
Log Message:
- Empty the journal at mount time. (Anton)
- Set the volume dirty bit at mount time (if it is not set already and
clear it again at umount time but only if it was not set to start
with. (Anton)
Index: ntfscat.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/ntfscat.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -p -r1.28 -r1.29
--- ntfscat.c 12 Nov 2006 22:46:50 -0000 1.28
+++ ntfscat.c 28 Nov 2006 10:09:57 -0000 1.29
@@ -86,7 +86,8 @@ static void usage(void)
" -q, --quiet Less output\n"
" -V, --version Version information\n"
" -v, --verbose More output\n\n",
- //" -r --raw Display the compressed or encrypted file",
+// Does not work for compressed files at present so leave undocumented...
+// " -r --raw Display the raw data (e.g. for compressed or encrypted file)",
EXEC_NAME);
ntfs_log_info("%s%s\n", ntfs_bugs, ntfs_home);
}
@@ -156,7 +157,7 @@ static int parse_attribute(const char *v
*/
static int parse_options(int argc, char **argv)
{
- static const char *sopt = "-a:fh?i:n:qVv";
+ static const char *sopt = "-a:fh?i:n:qVvr";
static const struct option lopt[] = {
{ "attribute", required_argument, NULL, 'a' },
{ "attribute-name", required_argument, NULL, 'n' },
@@ -166,6 +167,7 @@ static int parse_options(int argc, char
{ "quiet", no_argument, NULL, 'q' },
{ "version", no_argument, NULL, 'V' },
{ "verbose", no_argument, NULL, 'v' },
+ { "raw", no_argument, NULL, 'r' },
{ NULL, 0, NULL, 0 }
};
@@ -247,6 +249,9 @@ static int parse_options(int argc, char
opts.verbose++;
ntfs_log_set_levels(NTFS_LOG_LEVEL_VERBOSE);
break;
+ case 'r':
+ opts.raw = TRUE;
+ break;
default:
ntfs_log_error("Unknown option '%s'.\n", argv[optind-1]);
err++;
@@ -349,10 +354,11 @@ static int cat(ntfs_volume *vol, ntfs_in
offset = 0;
for (;;) {
- if (block_size > 0) {
+ if (!opts.raw && block_size > 0) {
// These types have fixup
bytes_read = ntfs_attr_mst_pread(attr, offset, 1, block_size, buffer);
- bytes_read *= block_size;
+ if (bytes_read > 0)
+ bytes_read *= block_size;
} else {
bytes_read = ntfs_attr_pread(attr, offset, bufsize, buffer);
}
Index: ntfscat.h
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/ntfscat.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -p -r1.6 -r1.7
--- ntfscat.h 23 Oct 2005 14:00:37 -0000 1.6
+++ ntfscat.h 28 Nov 2006 10:09:57 -0000 1.7
@@ -38,6 +38,7 @@ struct options {
int force; /* Override common sense */
int quiet; /* Less output */
int verbose; /* Extra output */
+ BOOL raw; /* Raw data output */
};
#endif /* _NTFSCAT_H_ */
Index: ntfsclone.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/ntfsclone.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -p -r1.94 -r1.95
--- ntfsclone.c 12 Nov 2006 22:46:50 -0000 1.94
+++ ntfsclone.c 28 Nov 2006 10:09:57 -0000 1.95
@@ -1388,7 +1388,7 @@ static void mount_volume(unsigned long n
exit(1);
}
- if (vol->flags & VOLUME_IS_DIRTY)
+ if (NVolWasDirty(vol))
if (opt.force-- <= 0)
err_exit(dirty_volume_msg, opt.volume);
@@ -1538,17 +1538,18 @@ static s64 open_image(void)
if (memcmp(image_hdr.magic, IMAGE_MAGIC, IMAGE_MAGIC_SIZE) != 0)
err_exit("Input file is not an image! (invalid magic)\n");
if (image_hdr.major_ver < NTFSCLONE_IMG_VER_MAJOR_ENDIANNESS_SAFE) {
- Printf("Old image format detected. Byteswapping on big "
- "endian architectures. If the image was "
- "created on a little endian architecture it "
- "will not work. Use a more recent version "
- "of ntfsclone to recreate the image.\n");
image_hdr.major_ver = NTFSCLONE_IMG_VER_MAJOR;
image_hdr.minor_ver = NTFSCLONE_IMG_VER_MINOR;
+#if (__BYTE_ORDER == __BIG_ENDIAN)
+ Printf("Old image format detected. If the image was created "
+ "on a little endian architecture it will not "
+ "work. Use a more recent version of "
+ "ntfsclone to recreate the image.\n");
image_hdr.cluster_size = cpu_to_le32(image_hdr.cluster_size);
image_hdr.device_size = cpu_to_sle64(image_hdr.device_size);
image_hdr.nr_clusters = cpu_to_sle64(image_hdr.nr_clusters);
image_hdr.inuse = cpu_to_sle64(image_hdr.inuse);
+#endif
image_hdr.offset_to_image_data =
const_cpu_to_le32((sizeof(image_hdr) + 7) & ~7);
image_is_host_endian = TRUE;
@@ -1764,6 +1765,7 @@ int main(int argc, char **argv)
device_size = open_volume();
ntfs_size = vol->nr_clusters * vol->cluster_size;
}
+ // FIXME: This needs to be the cluster size...
ntfs_size += 512; /* add backup boot sector */
if (opt.std_out) {
Index: ntfscp.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/ntfscp.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -p -r1.39 -r1.40
--- ntfscp.c 12 Nov 2006 22:46:50 -0000 1.39
+++ ntfscp.c 28 Nov 2006 10:09:57 -0000 1.40
@@ -352,7 +352,7 @@ int main(int argc, char *argv[])
return 1;
}
- if ((vol->flags & VOLUME_IS_DIRTY) && (!opts.force))
+ if (NVolWasDirty(vol) && !opts.force)
goto umount;
{
Index: ntfsdump_logfile.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/ntfsdump_logfile.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -p -r1.35 -r1.36
--- ntfsdump_logfile.c 12 Nov 2006 22:46:50 -0000 1.35
+++ ntfsdump_logfile.c 28 Nov 2006 10:09:57 -0000 1.36
@@ -197,7 +197,7 @@ static int logfile_open(BOOL is_volume,
ntfs_inode *ni;
ntfs_attr *na;
- vol = ntfs_mount(filename, NTFS_MNT_RDONLY);
+ vol = ntfs_mount(filename, NTFS_MNT_RDONLY | NTFS_MNT_FORENSIC);
if (!vol)
log_err_exit(NULL, "Failed to mount %s: %s\n",
filename, strerror(errno));
Index: ntfsfix.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/ntfsfix.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -p -r1.33 -r1.34
--- ntfsfix.c 5 Apr 2006 12:43:07 -0000 1.33
+++ ntfsfix.c 28 Nov 2006 10:09:57 -0000 1.34
@@ -82,8 +82,6 @@ switch if you want to be able to build t
static const char *EXEC_NAME = "ntfsfix";
static const char *OK = "OK\n";
static const char *FAILED = "FAILED\n";
-static BOOL vol_is_dirty = FALSE;
-static BOOL journal_is_empty = FALSE;
struct {
char *volume;
@@ -247,9 +245,8 @@ static int set_dirty_flag(ntfs_volume *v
{
u16 flags;
- if (vol_is_dirty == TRUE)
+ if (NVolWasDirty(vol))
return 0;
-
ntfs_log_info("Setting required flags on partition... ");
/*
* Set chkdsk flag, i.e. mark the partition dirty so chkdsk will run
@@ -264,37 +261,9 @@ static int set_dirty_flag(ntfs_volume *v
ntfs_log_error("Error setting volume flags.\n");
return -1;
}
+ vol->flags = flags;
ntfs_log_info(OK);
- vol_is_dirty = TRUE;
- return 0;
-}
-
-/**
- * set_dirty_flag_mount
- */
-static int set_dirty_flag_mount(ntfs_volume *vol)
-{
- u16 flags;
-
- if (vol_is_dirty == TRUE)
- return 0;
-
- ntfs_log_info("Setting required flags on partition... ");
- /*
- * Set chkdsk flag, i.e. mark the partition dirty so chkdsk will run
- * and fix it for us.
- */
- flags = vol->flags | VOLUME_IS_DIRTY;
- /* If NTFS volume version >= 2.0 then set mounted on NT4 flag. */
- if (vol->major_ver >= 2)
- flags |= VOLUME_MOUNTED_ON_NT4;
- if (ntfs_volume_write_flags(vol, flags)) {
- ntfs_log_info(FAILED);
- ntfs_log_error("Error setting volume flags.\n");
- return -1;
- }
- ntfs_log_info(OK);
- vol_is_dirty = TRUE;
+ NVolSetWasDirty(vol);
return 0;
}
@@ -303,9 +272,8 @@ static int set_dirty_flag_mount(ntfs_vol
*/
static int empty_journal(ntfs_volume *vol)
{
- if (journal_is_empty == TRUE)
+ if (NVolLogFileEmpty(vol))
return 0;
-
ntfs_log_info("Going to empty the journal ($LogFile)... ");
if (ntfs_logfile_reset(vol)) {
ntfs_log_info(FAILED);
@@ -313,7 +281,6 @@ static int empty_journal(ntfs_volume *vo
return -1;
}
ntfs_log_info(OK);
- journal_is_empty = TRUE;
return 0;
}
@@ -475,13 +442,13 @@ static int fix_mount(void)
ntfs_log_info("Attempting to correct errors... ");
- dev = ntfs_device_alloc(opt.volume, 0, &ntfs_device_default_io_ops, NULL);
+ dev = ntfs_device_alloc(opt.volume, 0, &ntfs_device_default_io_ops,
+ NULL);
if (!dev) {
ntfs_log_info(FAILED);
ntfs_log_perror("Failed to allocate device");
return -1;
}
-
vol = ntfs_volume_startup(dev, 0);
if (!vol) {
ntfs_log_info(FAILED);
@@ -490,17 +457,12 @@ static int fix_mount(void)
ntfs_device_free(dev);
return -1;
}
-
if (fix_mftmirr(vol) < 0)
goto error_exit;
-
- /* FIXME: Will this fail? Probably... */
if (set_dirty_flag(vol) < 0)
goto error_exit;
-
if (empty_journal(vol) < 0)
goto error_exit;
-
ret = 0;
error_exit:
/* ntfs_umount() will invoke ntfs_device_free() for us. */
@@ -550,7 +512,8 @@ int main(int argc, char **argv)
exit(1);
}
}
-
+ /* So the unmount does not clear it again. */
+ NVolSetWasDirty(vol);
/* Check NTFS version is ok for us (in $Volume) */
ntfs_log_info("NTFS volume version is %i.%i.\n", vol->major_ver,
vol->minor_ver);
@@ -558,22 +521,13 @@ int main(int argc, char **argv)
ntfs_log_error("Error: Unknown NTFS version.\n");
goto error_exit;
}
-
- if (set_dirty_flag_mount(vol) < 0)
- goto error_exit;
-
- if (empty_journal(vol) < 0)
- goto error_exit;
-
if (vol->major_ver >= 3) {
- /* FIXME: If on NTFS 3.0+, check for presence of the usn journal and
- disable it (if present) as Win2k might be unhappy otherwise and Bad
- Things(TM) could happen depending on what applications are actually
- using it for. */
+ /*
+ * FIXME: If on NTFS 3.0+, check for presence of the usn
+ * journal and stamp it if present.
+ */
}
-
- /* FIXME: Should we be marking the quota out of date, too? */
-
+ /* FIXME: We should be marking the quota out of date, too. */
/* That's all for now! */
ntfs_log_info("NTFS partition %s was processed successfully.\n",
vol->dev->d_name);
Index: ntfsinfo.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/ntfsinfo.c,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -p -r1.154 -r1.155
--- ntfsinfo.c 25 Nov 2006 18:38:47 -0000 1.154
+++ ntfsinfo.c 28 Nov 2006 10:09:57 -0000 1.155
@@ -1288,7 +1288,7 @@ static void ntfs_dump_attribute_header(A
// TODO: Switch this to properly aligned hex...
printf("\tRunlist:\tVCN\t\tLCN\t\tLength\n");
while (rlc->length) {
- printf("\t\t\t%lld\t\t%lld\t\t%lld\n",
+ printf("\t\t\t0x%llx\t\t0x%llx\t\t0x%llx\n",
rlc->vcn, rlc->lcn, rlc->length);
rlc++;
}
Index: ntfsmount.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/ntfsmount.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -p -r1.103 -r1.104
--- ntfsmount.c 25 Nov 2006 21:44:35 -0000 1.103
+++ ntfsmount.c 28 Nov 2006 10:09:57 -0000 1.104
@@ -101,7 +101,6 @@ typedef struct {
BOOL debug;
BOOL noatime;
BOOL no_detach;
- BOOL leave_dirty;
} ntfs_fuse_context_t;
typedef enum {
@@ -1360,10 +1359,6 @@ 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))
@@ -1431,17 +1426,6 @@ static int ntfs_fuse_mount(const char *d
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;
}
Index: ntfsmove.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/ntfsmove.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -p -r1.24 -r1.25
--- ntfsmove.c 12 Nov 2006 22:46:50 -0000 1.24
+++ ntfsmove.c 28 Nov 2006 10:09:57 -0000 1.25
@@ -891,10 +891,7 @@ int main(int argc, char *argv[])
count = move_file(vol, inode, opts.location, 0);
if ((count > 0) && (!opts.nodirty)) {
- if (ntfs_volume_write_flags(vol, vol->flags | VOLUME_IS_DIRTY) <
- 0) {
- ntfs_log_error("Couldn't mark volume dirty\n");
- }
+ NVolSetWasDirty(vol);
ntfs_log_info("Relocated %lld bytes\n", count);
}
if (count >= 0)
Index: ntfsresize.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/ntfsresize.c,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -p -r1.123 -r1.124
--- ntfsresize.c 12 Nov 2006 22:46:50 -0000 1.123
+++ ntfsresize.c 28 Nov 2006 10:09:57 -0000 1.124
@@ -2255,7 +2255,7 @@ static ntfs_volume *mount_volume(void)
exit(1);
}
- if (vol->flags & VOLUME_IS_DIRTY)
+ if (NVolWasDirty(vol))
if (opt.force-- <= 0)
err_exit("Volume is scheduled for check.\nRun chkdsk /f"
" and please try again, or see option -f.\n");
@@ -2279,32 +2279,16 @@ static ntfs_volume *mount_volume(void)
/**
* prepare_volume_fixup
*
- * Set the volume's dirty flag and wipe the filesystem journal. When Windows
- * boots it will automatically run chkdsk to check for any problems. If the
- * read-only command line option was given, this function will do nothing.
+ * Make sure the volume's dirty flag does not get cleared at umount time. When
+ * Windows boots it will automatically run chkdsk to check for any problems.
+ * If the read-only command line option was given, this function will do
+ * nothing.
*/
static void prepare_volume_fixup(ntfs_volume *vol)
{
- u16 flags;
-
- flags = vol->flags | VOLUME_IS_DIRTY;
- if (vol->major_ver >= 2)
- flags |= VOLUME_MOUNTED_ON_NT4;
-
printf("Schedule chkdsk for NTFS consistency check at Windows "
"boot time ...\n");
-
- if (ntfs_volume_write_flags(vol, flags))
- perr_exit("Failed to set $Volume dirty");
-
- if (vol->dev->d_ops->sync(vol->dev) == -1)
- perr_exit("Failed to sync device");
-
- printf("Resetting $LogFile ... (this might take a while)\n");
-
- if (ntfs_logfile_reset(vol))
- perr_exit("Failed to reset $LogFile");
-
+ NVolSetWasDirty(vol);
if (vol->dev->d_ops->sync(vol->dev) == -1)
perr_exit("Failed to sync device");
}
@@ -2470,7 +2454,6 @@ int main(int argc, char **argv)
proceed_question();
}
- /* FIXME: performance - relocate logfile here if it's needed */
prepare_volume_fixup(vol);
if (resize.relocations)
Index: ntfswipe.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/ntfswipe.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -p -r1.45 -r1.46
--- ntfswipe.c 12 Nov 2006 22:46:51 -0000 1.45
+++ ntfswipe.c 28 Nov 2006 10:09:57 -0000 1.46
@@ -1346,7 +1346,7 @@ int main(int argc, char *argv[])
if (!vol)
goto free;
- if ((vol->flags & VOLUME_IS_DIRTY) && (!opts.force))
+ if (NVolWasDirty(vol) && !opts.force)
goto umount;
if (opts.info) {
Index: utils.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/ntfsprogs/utils.c,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -p -r1.69 -r1.70
--- utils.c 25 Nov 2006 21:44:36 -0000 1.69
+++ utils.c 28 Nov 2006 10:09:57 -0000 1.70
@@ -229,7 +229,7 @@ ntfs_volume * utils_mount_volume(const c
return NULL;
}
- if (vol->flags & VOLUME_IS_DIRTY) {
+ if (NVolWasDirty(vol)) {
if (!force) {
ntfs_log_error("%s", dirty_volume_msg);
ntfs_umount(vol, FALSE);
|