From d2fab4e71f76773cc29f9a87a4a4bff3afca1a19 Mon Sep 17 00:00:00 2001 From: szaka Date: Fri, 10 Aug 2007 15:01:21 +0000 Subject: [PATCH] fix: utimes() shouldn't update the parent dir mtime (Wayne Sherman, Szaka) --- include/ntfs-3g/inode.h | 6 ++++++ libntfs-3g/inode.c | 1 + src/ntfs-3g.c | 3 +++ 3 files changed, 10 insertions(+) diff --git a/include/ntfs-3g/inode.h b/include/ntfs-3g/inode.h index 3ff15f43..94c79f8e 100644 --- a/include/ntfs-3g/inode.h +++ b/include/ntfs-3g/inode.h @@ -49,6 +49,7 @@ typedef enum { NI_FileNameDirty, /* 1: FILE_NAME attributes need to be updated in the index. */ NI_NoMtimeUpdate, /* 1: Don't update modifiction time. */ + NI_NoParentMtimeUpdate, /* 1: Don't update parent dir's mtime. */ } ntfs_inode_state_bits; #define test_nino_flag(ni, flag) test_bit(NI_##flag, (ni)->state) @@ -102,6 +103,11 @@ typedef enum { #define NInoClearNoMtimeUpdate(ni) clear_nino_flag(ni, NoMtimeUpdate) #define NInoMtimeUpdate(ni) (!NInoNoMtimeUpdate(ni)) +#define NInoNoParentMtimeUpdate(ni) test_nino_flag(ni, NoMtimeUpdate) +#define NInoSetNoParentMtimeUpdate(ni) set_nino_flag(ni, NoMtimeUpdate) +#define NInoClearNoParentMtimeUpdate(ni) clear_nino_flag(ni, NoMtimeUpdate) +#define NInoParentMtimeUpdate(ni) (!NInoNoParentMtimeUpdate(ni)) + /** * struct _ntfs_inode - The NTFS in-memory inode structure. * diff --git a/libntfs-3g/inode.c b/libntfs-3g/inode.c index 446adda5..d00789d9 100644 --- a/libntfs-3g/inode.c +++ b/libntfs-3g/inode.c @@ -686,6 +686,7 @@ int ntfs_inode_sync(ntfs_inode *ni) /* Update FILE_NAME's in the index. */ if ((ni->mrec->flags & MFT_RECORD_IN_USE) && ni->nr_extents != -1 && NInoFileNameTestAndClearDirty(ni) && + NInoParentMtimeUpdate(ni) && ntfs_inode_sync_file_name(ni)) { if (!err || errno == EIO) { err = errno; diff --git a/src/ntfs-3g.c b/src/ntfs-3g.c index aa09d080..3cafffd2 100644 --- a/src/ntfs-3g.c +++ b/src/ntfs-3g.c @@ -1245,6 +1245,9 @@ static int ntfs_fuse_utime(const char *path, struct utimbuf *buf) ni = ntfs_pathname_to_inode(ctx->vol, NULL, path); if (!ni) return -errno; + + NInoSetNoParentMtimeUpdate(ni); + if (buf) { ni->last_access_time = buf->actime; ni->last_data_change_time = buf->modtime;