From f7fe30a0aab006ec0e07e7267206fbb102562df7 Mon Sep 17 00:00:00 2001 From: cha0smaster Date: Mon, 14 Nov 2005 15:31:23 +0000 Subject: [PATCH] Automatically update access and change time in ntfs_attr_p{read,write} and ntfs_attr_truncate. --- ChangeLog | 2 ++ libntfs/attrib.c | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b398730..a687443a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -86,6 +86,8 @@ xx/xx/2005 - 1.12.2-WIP users to submit it, thus write speed to very fragmented files dramatically increased, while write speed to low fragmented files stayed at approximately same level. (Yura) + - Automatically update access and change time in ntfs_attr_p{read,write} + and ntfs_attr_truncate. (Yura) 10/10/2005 - 1.12.1 - Minor fix to location of mount.ntfs-fuse and mkfs.ntfs. diff --git a/libntfs/attrib.c b/libntfs/attrib.c index 5cf5a85d..5e5111d4 100644 --- a/libntfs/attrib.c +++ b/libntfs/attrib.c @@ -55,6 +55,7 @@ #include "compress.h" #include "bitmap.h" #include "logging.h" +#include "ntfstime.h" ntfschar AT_UNNAMED[] = { const_cpu_to_le16('\0') }; @@ -769,6 +770,12 @@ s64 ntfs_attr_pread(ntfs_attr *na, const s64 pos, s64 count, void *b) errno = EACCES; return -1; } + /* Update access time if accessing unnamed data attribute. */ + if (na->type == AT_DATA && na->name == AT_UNNAMED) { + na->ni->last_access_time = time(NULL); + NInoFileNameSetDirty(na->ni); + NInoSetDirty(na->ni); + } if (!count) return 0; /* Truncate reads beyond end of attribute. */ @@ -951,6 +958,13 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, const s64 pos, s64 count, const void *b) errno = EOPNOTSUPP; return -1; } + /* Update time if writing to unnamed data attribute. */ + if (na->type == AT_DATA && na->name == AT_UNNAMED) { + na->ni->last_data_change_time = time(NULL); + na->ni->last_mft_change_time = time(NULL); + NInoFileNameSetDirty(na->ni); + NInoSetDirty(na->ni); + } if (!count) return 0; /* If the write reaches beyond the end, extend the attribute. */ @@ -4915,9 +4929,10 @@ int ntfs_attr_truncate(ntfs_attr *na, const s64 newsize) ret = ntfs_non_resident_attr_shrink(na, newsize); } else ret = ntfs_resident_attr_resize(na, newsize); - /* Set FILE_NAME dirty flag, to update file length in the index. */ + /* Set FILE_NAME dirty flag, to update length and time in the index. */ if (na->type == AT_DATA && na->name == AT_UNNAMED) { - NInoFileNameSetDirty(na->ni); + na->ni->last_data_change_time = time(NULL); + na->ni->last_mft_change_time = time(NULL); na->ni->data_size = na->data_size; /* * If attribute sparse or compressed then allocated size in @@ -4928,6 +4943,7 @@ int ntfs_attr_truncate(ntfs_attr *na, const s64 newsize) na->ni->allocated_size = na->compressed_size; else na->ni->allocated_size = na->allocated_size; + NInoFileNameSetDirty(na->ni); } return ret; }