fat: Save FAT root directory timestamps to volume label
Subsystems (3)
RFC PATCH 1/1 fat: Save FAT root directory timestamps to volume label
Standard FAT implementations cannot store any of the FAT root directory's timestamps. This commit adds the mount option 'rootts', which allows saving the FAT root directory timestamps as the timestamps of the FAT volume label directory entry. At least Mac OS X is known to support the same mechanism and interoperate with this commit.
When mounting, the following values can be specified for the 'rootts' mount option:
"rootts=ignore" ignores root directory timestamps. All timestamps are
reset to 0 (1/1/1970). This is the default.
"rootts=load" only tries to load the root directory's timestamps from
a volume label entry when mounting.
"rootts=preserve" tries to load and save the root directory's timestamps
if a volume label entry exists.
"rootts=save" tries to load and save the root directory's timestamps.
If the root directory was accessed but no volume label entry exists, the label "NO NAME" is created.
--- Documentation/filesystems/vfat.txt | 7 ++ fs/fat/dir.c | 44 ++++++++++++ fs/fat/fat.h | 27 +++++++ fs/fat/inode.c | 135 +++++++++++++++++++++++++----------- fs/fat/misc.c | 27 +++++++ 5 files changed, 198 insertions(+), 42 deletions(-)
Documentation/filesystems/vfat.txt +7 -0
@@ -137,6 +137,13 @@ errors=panic|continue|remount-ro without doing anything or remount the partition in read-only mode (default behavior). +root_ts=ignore|load|preserve|save + -- Specify whether to load/store the root dir timestamps as the + timestamp of the volume label entry: The default is to ignore, + 'preserve' stores the ts only if a volume label already exists, + and 'save' creates a volume label if the root ts has changed + but no volume label is present. + <bool>: 0,1,yes,no,true,false TODO
fs/fat/dir.c +44 -0
47 lines not on this page · raw message
fs/fat/fat.h +27 -0
@@ -21,6 +21,19 @@#define FAT_ERRORS_PANIC 2/* panic on error */ #define FAT_ERRORS_RO 3/* remount r/o on error */ +/* +* fat root directory timestamp backup +*/ +#define FAT_ROOT_TS_READ 0x01/* read root dir ts from volume label ts */ +#define FAT_ROOT_TS_WRITE 0x02/* write root dir ts to volume label ts */ +#define FAT_ROOT_TS_CREATE 0x04/* create volume label if there is none */ + +#define FAT_ROOT_TS_IGNORE 0 +#define FAT_ROOT_TS_LOAD FAT_ROOT_TS_READ +#define FAT_ROOT_TS_PRESERVE (FAT_ROOT_TS_READ | FAT_ROOT_TS_WRITE) +#define FAT_ROOT_TS_SAVE (FAT_ROOT_TS_READ | FAT_ROOT_TS_WRITE | \ + FAT_ROOT_TS_CREATE) +struct fat_mount_options {uid_t fs_uid;gid_t fs_gid;
@@ -32,6 +45,8 @@ struct fat_mount_options {unsigned char name_check;/* r = relaxed, n = normal, s = strict */ unsigned char errors;/* On error: continue, panic, remount-ro */ unsigned short allow_utime;/* permission for setting the [am]time */ +unsigned short root_ts;/* root dir timestamps: +ignore, load, preserve, save */ unsigned quiet:1, /* set = fake successful chmods and chowns */ showexec:1, /* set = only set x bit for com/exe/bat */ sys_immutable:1, /* set = system files are immutable */
@@ -50,6 +65,8 @@ struct fat_mount_options {#define FAT_HASH_BITS 8#define FAT_HASH_SIZE (1UL << FAT_HASH_BITS) +#define FAT_LABEL_NONAME "NO NAME " +/* * MS-DOS file system in-core superblock data */
@@ -247,6 +264,12 @@ extern int fat_add_entries(struct inode *dir, void *slots, int nr_slots, struct fat_slot_info *sinfo);extern int fat_remove_entries (struct inode *dir,struct fat_slot_info *sinfo); +extern int fat_get_label_entry (struct inode *root_inode, +struct buffer_head **bh, +struct msdos_dir_entry **de); +extern int fat_create_label_entry (struct inode *root_inode, +const unsigned char *name); +/* fat/fatent.c */ struct fat_entry {int entry;
@@ -329,6 +352,10 @@ extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts, __le16 __time, __le16 __date, u8 time_cs);extern void fat_time_unix2fat (struct msdos_sb_info *sbi,struct timespec *ts,__le16 *time,__le16 *date,u8 *time_cs); +extern void fat_time_de2inode (struct msdos_sb_info *sbi,struct inode *inode, +struct msdos_dir_entry *de); +extern void fat_time_inode2de (struct msdos_sb_info *sbi,struct inode *inode, +struct msdos_dir_entry *de);extern int fat_sync_bhs (struct buffer_head **bhs,int nr_bhs);int fat_cache_init (void );
fs/fat/inode.c +93 -42
188 lines not on this page · raw message
fs/fat/misc.c +27 -0
@@ -268,6 +268,33 @@ void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec *ts, }EXPORT_SYMBOL_GPL (fat_time_unix2fat); +void fat_time_de2inode (struct msdos_sb_info *sbi,struct inode *inode, +struct msdos_dir_entry *de) +{ +fat_time_fat2unix (sbi, &inode->i_mtime, de->time, de->date,0 ); +if (sbi->options.isvfat) { +fat_time_fat2unix (sbi, &inode->i_ctime, de->ctime, + de->cdate, de->ctime_cs); +fat_time_fat2unix (sbi, &inode->i_atime,0 , de->adate,0 ); + }else + inode->i_ctime = inode->i_atime = inode->i_mtime; +} +EXPORT_SYMBOL_GPL (fat_time_de2inode); + +void fat_time_inode2de (struct msdos_sb_info *sbi,struct inode *inode, +struct msdos_dir_entry *de) +{ +fat_time_unix2fat (sbi, &inode->i_mtime, &de->time, &de->date,NULL ); +if (sbi->options.isvfat) { +__le16 atime; +fat_time_unix2fat (sbi, &inode->i_ctime, &de->ctime, + &de->cdate, &de->ctime_cs); +fat_time_unix2fat (sbi, &inode->i_atime, &atime, + &de->adate,NULL ); + } +} +EXPORT_SYMBOL_GPL (fat_time_inode2de); +int fat_sync_bhs (struct buffer_head **bhs,int nr_bhs) {int i, err =0 ;
Signature · 1 line
1.5.4.3
RFC PATCH 1/1 fat: Save FAT root directory timestamps to volume label
Standard FAT implementations cannot store any of the FAT root directory's timestamps. This commit adds the mount option 'rootts', which allows saving the FAT root directory timestamps as the timestamps of the FAT volume label directory entry. At least Mac OS X is known to support the same mechanism and interoperate with this commit.
When mounting, the following values can be specified for the 'rootts' mount option:
"rootts=ignore" ignores root directory timestamps. All timestamps are
reset to 0 (1/1/1970). This is the default.
"rootts=load" only tries to load the root directory's timestamps from
a volume label entry when mounting.
"rootts=preserve" tries to load and save the root directory's timestamps
if a volume label entry exists.
"rootts=save" tries to load and save the root directory's timestamps.
If the root directory was accessed but no volume label entry exists, the label "NO NAME" is created.
--- Documentation/filesystems/vfat.txt | 10 +++ fs/fat/dir.c | 44 +++++++++++ fs/fat/fat.h | 27 +++++++ fs/fat/inode.c | 141 +++++++++++++++++++++++++----------- fs/fat/misc.c | 27 +++++++ 5 files changed, 207 insertions(+), 42 deletions(-)
Documentation/filesystems/vfat.txt +10 -0
@@ -137,6 +137,16 @@ errors=panic|continue|remount-ro without doing anything or remount the partition in read-only mode (default behavior). +rootts=ignore|load|preserve|save + -- Specify whether to load/store the root dir timestamps as the + timestamp of the volume label entry. + ignore: do not load or store root dir ts (default). + load: only try to load the root dir ts. + preserve: load the root dir ts, store them only if a volume + label already exists. + save: load and store the root dir ts, create a volume label + if the ts have changed but no label is present. + <bool>: 0,1,yes,no,true,false TODO
fs/fat/dir.c +44 -0
47 lines not on this page · raw message
fs/fat/fat.h +27 -0
@@ -21,6 +21,19 @@#define FAT_ERRORS_PANIC 2/* panic on error */ #define FAT_ERRORS_RO 3/* remount r/o on error */ +/* +* fat root directory timestamp backup +*/ +#define FAT_ROOT_TS_READ 0x01/* read root dir ts from volume label ts */ +#define FAT_ROOT_TS_WRITE 0x02/* write root dir ts to volume label ts */ +#define FAT_ROOT_TS_CREATE 0x04/* create volume label if there is none */ + +#define FAT_ROOT_TS_IGNORE 0 +#define FAT_ROOT_TS_LOAD FAT_ROOT_TS_READ +#define FAT_ROOT_TS_PRESERVE (FAT_ROOT_TS_READ | FAT_ROOT_TS_WRITE) +#define FAT_ROOT_TS_SAVE (FAT_ROOT_TS_READ | FAT_ROOT_TS_WRITE | \ + FAT_ROOT_TS_CREATE) +struct fat_mount_options {uid_t fs_uid;gid_t fs_gid;
@@ -32,6 +45,8 @@ struct fat_mount_options {unsigned char name_check;/* r = relaxed, n = normal, s = strict */ unsigned char errors;/* On error: continue, panic, remount-ro */ unsigned short allow_utime;/* permission for setting the [am]time */ +unsigned short root_ts;/* root dir timestamps: +ignore, load, preserve, save */ unsigned quiet:1, /* set = fake successful chmods and chowns */ showexec:1, /* set = only set x bit for com/exe/bat */ sys_immutable:1, /* set = system files are immutable */
@@ -50,6 +65,8 @@ struct fat_mount_options {#define FAT_HASH_BITS 8#define FAT_HASH_SIZE (1UL << FAT_HASH_BITS) +#define FAT_LABEL_NONAME "NO NAME " +/* * MS-DOS file system in-core superblock data */
@@ -247,6 +264,12 @@ extern int fat_add_entries(struct inode *dir, void *slots, int nr_slots, struct fat_slot_info *sinfo);extern int fat_remove_entries (struct inode *dir,struct fat_slot_info *sinfo); +extern int fat_get_label_entry (struct inode *root_inode, +struct buffer_head **bh, +struct msdos_dir_entry **de); +extern int fat_create_label_entry (struct inode *root_inode, +const unsigned char *name); +/* fat/fatent.c */ struct fat_entry {int entry;
@@ -329,6 +352,10 @@ extern void fat_time_fat2unix(struct msdos_sb_info *sbi, struct timespec *ts, __le16 __time, __le16 __date, u8 time_cs);extern void fat_time_unix2fat (struct msdos_sb_info *sbi,struct timespec *ts,__le16 *time,__le16 *date,u8 *time_cs); +extern void fat_time_de2inode (struct msdos_sb_info *sbi,struct inode *inode, +struct msdos_dir_entry *de); +extern void fat_time_inode2de (struct msdos_sb_info *sbi,struct inode *inode, +struct msdos_dir_entry *de);extern int fat_sync_bhs (struct buffer_head **bhs,int nr_bhs);int fat_cache_init (void );
fs/fat/inode.c +99 -42
194 lines not on this page · raw message
fs/fat/misc.c +27 -0
@@ -268,6 +268,33 @@ void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec *ts, }EXPORT_SYMBOL_GPL (fat_time_unix2fat); +void fat_time_de2inode (struct msdos_sb_info *sbi,struct inode *inode, +struct msdos_dir_entry *de) +{ +fat_time_fat2unix (sbi, &inode->i_mtime, de->time, de->date,0 ); +if (sbi->options.isvfat) { +fat_time_fat2unix (sbi, &inode->i_ctime, de->ctime, + de->cdate, de->ctime_cs); +fat_time_fat2unix (sbi, &inode->i_atime,0 , de->adate,0 ); + }else + inode->i_ctime = inode->i_atime = inode->i_mtime; +} +EXPORT_SYMBOL_GPL (fat_time_de2inode); + +void fat_time_inode2de (struct msdos_sb_info *sbi,struct inode *inode, +struct msdos_dir_entry *de) +{ +fat_time_unix2fat (sbi, &inode->i_mtime, &de->time, &de->date,NULL ); +if (sbi->options.isvfat) { +__le16 atime; +fat_time_unix2fat (sbi, &inode->i_ctime, &de->ctime, + &de->cdate, &de->ctime_cs); +fat_time_unix2fat (sbi, &inode->i_atime, &atime, + &de->adate,NULL ); + } +} +EXPORT_SYMBOL_GPL (fat_time_inode2de); +int fat_sync_bhs (struct buffer_head **bhs,int nr_bhs) {int i, err =0 ;
Signature · 1 line
1.5.4.3
OGAWA Hirofumi
maintainerQuoted 15 lines · Jorg Schummer
Standard FAT implementations cannot store any of the FAT root directory's timestamps. This commit adds the mount option 'rootts', which allows saving the FAT root directory timestamps as the timestamps of the FAT volume label directory entry. At least Mac OS X is known to support the same mechanism and interoperate with this commit.
When mounting, the following values can be specified for the 'rootts' mount option:
"rootts=ignore" ignores root directory timestamps. All timestamps are
reset to 0 (1/1/1970). This is the default."rootts=load" only tries to load the root directory's timestamps from
a volume label entry when mounting.
Quoted 6 lines
"rootts=preserve" tries to load and save the root directory's timestamps
if a volume label entry exists."rootts=save" tries to load and save the root directory's timestamps.
If the root directory was accessed but no volume label entry exists, the label "NO NAME" is created.
Looks like interesting hack. However, personally, I don't think I want this, but I guess it can be only me.
Well, so, what is this for? If rootdir doesn't have timestamp, some app is not working, or something?
Thanks.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
Quoted 7 lines · ext OGAWA Hirofumi
Quoted 5 lines · Jorg Schummer
Standard FAT implementations cannot store any of the FAT root directory's timestamps. This commit adds the mount option 'rootts', which allows saving the FAT root directory timestamps as the timestamps of the FAT volume label directory entry. At least Mac OS X is known to support the same mechanism and interoperate with this commit.
Hi,
I guess I should have explained a bit more:
Quoted 2 lines
Looks like interesting hack. However, personally, I don't think I want this, but I guess it can be only me.
If you don't want this functionality to be used, as pointed out before, "rootts=ignore" is the default.
If you don't want this patch.. There's probably good reasons not to take it, especially the amount-of-problem-solving-by-maintenance-cost ratio might be rather low.
Quoted 2 lines
Well, so, what is this for? If rootdir doesn't have timestamp, some app is not working, or something?
To be honest, the only app which I can think of here is some backup-script which I wrote many years ago and which has not been in use anymore for a long time. (Maybe rsync or similar could also fail under some circumstances? Not sure.)
So some backup / synchronisation apps might not work properly. But who's going to use FAT for sensitive, i.e. backup-worthy data anyway? The answer is: People who use the same volume in many different machines, some of which might be able to speak only FAT. Drawback: Just for these people this patch might not be useful since none of those FAT machines (except for the apple and possibly the penguin) support root dir timestamps anyway. So whatever timestamps are found at backup-time, they cannot be trusted, because the volume might have been in use by standard FAT implementations.
In summary: If you're not keen on integrating new features which would make Linux look good in the face of shiny Mac OS, there might not be much reason to take it in. Unless we get zillions of people replying now with what wonderful things it would enable them to do.. ;-)
Regards,
Jörg
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
OGAWA Hirofumi
maintainerQuoted 1 line · Jörg Schummer
Hi,
Hi,
Quoted 3 lines
If you don't want this patch.. There's probably good reasons not to take it, especially the amount-of-problem-solving-by-maintenance-cost ratio might be rather low.
Also, the option is easy to add, but really hard to delete by backward compatible reason. This is why I'm so careful to it.
BTW, the patch has several bugs. fat_get_label_entry() doesn't check IS_FREE(), is it right? fat_create_label_entry() doesn't initialize all timestamp in the case of msdos. spin_lock() usage is wrong. and more...
Quoted 18 lines
Quoted 2 lines
Well, so, what is this for? If rootdir doesn't have timestamp, some app is not working, or something?
To be honest, the only app which I can think of here is some backup-script which I wrote many years ago and which has not been in use anymore for a long time. (Maybe rsync or similar could also fail under some circumstances? Not sure.)
So some backup / synchronisation apps might not work properly. But who's going to use FAT for sensitive, i.e. backup-worthy data anyway? The answer is: People who use the same volume in many different machines, some of which might be able to speak only FAT. Drawback: Just for these people this patch might not be useful since none of those FAT machines (except for the apple and possibly the penguin) support root dir timestamps anyway. So whatever timestamps are found at backup-time, they cannot be trusted, because the volume might have been in use by standard FAT implementations.
Quoted 4 lines
In summary: If you're not keen on integrating new features which would make Linux look good in the face of shiny Mac OS, there might not be much reason to take it in. Unless we get zillions of people replying now with what wonderful things it would enable them to do.. ;-)
Yes, we would really want to know whether people want to use this. Is there any info from Mac OS people?
BTW, my thinking is, the option is why default is "rootts=ignore" if it's really good? Or 4 rootts=* options is really needed, and what is reason? Or if it's not good by some reasons, why is it added? ...
Thanks.
Signature · 5 lines
OGAWA Hirofumi <[email protected]> -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · ext OGAWA Hirofumi
Quoted 3 lines · Jörg Schummer
If you don't want this patch.. There's probably good reasons not to take it, especially the amount-of-problem-solving-by-maintenance-cost ratio might be rather low.
BTW, the patch has several bugs.
fat_get_label_entry()doesn't checkIS_FREE(), is it right?fat_create_label_entry()doesn't initialize all timestamp in the case of msdos.spin_lock()usage is wrong. and more...
You got good points there. I'll fix these on the chance that somebody decides to use it.
Quoted 10 lines
Quoted 4 lines
In summary: If you're not keen on integrating new features which would make Linux look good in the face of shiny Mac OS, there might not be much reason to take it in. Unless we get zillions of people replying now with what wonderful things it would enable them to do.. ;-)
Yes, we would really want to know whether people want to use this. Is there any info from Mac OS people?
BTW, my thinking is, the option is why default is "rootts=ignore" if it's really good?
That's because this feature does not seem to be part of most generally accepted FAT implementations. So I thought that the default should try to behave as people would expect FAT to behave: Forget about root dir timestamps.
On the other hand, except for 'save', none of the options makes 'real' fs changes, so maybe 'preserve' could be the default. (People who are used to the 'standard' behaviour should not be harmed by that - once the bugs are gone, that is..)
Quoted 2 lines
Or 4 rootts=* options is really needed, and what is reason?
I thought 'ignore' should be there in order to provide the 'standard'-FAT behaviour. And 'save' possibly creates a volume label, which might be not be wanted. But 'load' is not so necessary, indeed. The behaviour of Mac OS seems to be like 'preserve', btw.
Quoted 1 line
Or if it's not good by some reasons, why is it added? ...
The patch was created merely because one guy figured out that FAT can't save root dir timestamps by default and another guy knew that Mac OS X's FAT implementation can. So I thought, what the heck, let's enable linux to do the same thing.
Like mentioned before, this was not created because it would solve many people's problems. So I seriously do understand if you decide not to take it in. But still I would appreciate if you could take another look at my next - hopefully less buggy - version.
Thanks for your comments,
Jörg
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello again,
just in case you (or perhaps somebody else) have a minute to assist me..
Quoted 2 lines · ext OGAWA Hirofumi
BTW, the patch has several bugs.
fat_get_label_entry()doesn't checkIS_FREE(), is it right?
Not 100% sure if it's needed in a consistent fs, but I guess it shouldn't do any harm, so I added it.
Quoted 2 lines
fat_create_label_entry()doesn't initialize all
timestamp in the case of msdos.
Corrected.
Quoted 3 lines
spin_lock()usage is wrong.From the code, I'm not totally sure then what
inode_hash_lockis
supposed to protect in fat_write_inode. Probably it should prevent that the dir entry of an inode is being moved around to another i_pos while it's being changed?
But in the pre-patch version of fat_write_inode, shouldn't then mark_buffer_dirty(bh) be called when the lock is still held?
Sorry for the newbie-questions, thanks for any help.
Jörg
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
OGAWA Hirofumi
maintainerQuoted 11 lines · Jörg Schummer
Hello again,
just in case you (or perhaps somebody else) have a minute to assist me..
Quoted 2 lines · ext OGAWA Hirofumi
BTW, the patch has several bugs.
fat_get_label_entry()doesn't checkIS_FREE(), is it right?Not 100% sure if it's needed in a consistent fs, but I guess it shouldn't do any harm, so I added it.
If label was removed, what happen? I was assumed utility does
label_de->name[0] = DELETED_FLAG;
Quoted 9 lines
Quoted 3 lines
spin_lock()usage is wrong.From the code, I'm not totally sure then what
inode_hash_lockissupposed to protect in
fat_write_inode. Probably it should prevent that the dir entry of an inode is being moved around to anotheri_poswhile it's being changed?But in the pre-patch version of
fat_write_inode, shouldn't thenmark_buffer_dirty(bh)be called when the lock is still held?
I meant, read/write of storage might sleep, so it shouldn't hold spin_lock when does it.
If you set debug CONFIG_* of locking, I guess it will warn.
Thanks.
Signature · 5 lines
OGAWA Hirofumi <[email protected]> -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · ext OGAWA Hirofumi
Jörg Schummer <[email protected]> writes:
BTW, the patch has several bugs.
fat_get_label_entry()doesn't checkIS_FREE(), is it right?fat_create_label_entry()doesn't initialize all timestamp in the case of msdos.spin_lock()usage is wrong. and more...
After reviewing the patch again, I did notice some additional problems (I suppose that was the "and more..."). If and when I have time again, I might take a closer look at it again.
Thanks for your help until now!
Jörg
OGAWA Hirofumi
maintainerQuoted 7 lines · Jörg Schummer
Quoted 5 lines · ext OGAWA Hirofumi
Jörg Schummer <[email protected]> writes:
BTW, the patch has several bugs.
fat_get_label_entry()doesn't checkIS_FREE(), is it right?fat_create_label_entry()doesn't initialize all timestamp in the case of msdos.spin_lock()usage is wrong. and more...
Quoted 5 lines
After reviewing the patch again, I did notice some additional problems (I suppose that was the "and more..."). If and when I have time again, I might take a closer look at it again.
Thanks for your help until now!
No problem at all. Thanks for your work.
Signature · 5 lines
OGAWA Hirofumi <[email protected]> -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 1/1 fat: Save FAT root directory timestamps to volume label
Quoted 9 lines · ext OGAWA Hirofumi
Quoted 7 lines · Jörg Schummer
Quoted 5 lines · ext OGAWA Hirofumi
Jörg Schummer <[email protected]> writes:
BTW, the patch has several bugs.
fat_get_label_entry()doesn't checkIS_FREE(), is it right?fat_create_label_entry()doesn't initialize all timestamp in the case of msdos.spin_lock()usage is wrong. and more...
Quoted 5 lines
Quoted 5 lines
After reviewing the patch again, I did notice some additional problems (I suppose that was the "and more..."). If and when I have time again, I might take a closer look at it again.
Thanks for your help until now!
Hello,
on the off-chance that somebody would like to use this mechanism, I did a 3rd take of the patch. I tried to fix the problems of the previous patch and additionally added the functionality to correct the root dir timestamp's mtime and atime somewhat based on contained directory entries' ctime.
Any comments are welcome, but especially I'd like to ask if it is safe / good / doable to call
remove_inode_hash(inode); fat_attach(inode, i_pos); insert_inode_hash(inode);
inside fat_write_inode .
Thanks for any feedback!
Jörg
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
RFC PATCH 1/1 fat: Save FAT root directory timestamps to volume label
Standard FAT implementations cannot store any of the FAT root directory's timestamps. This commit adds the mount option 'rootts', which allows saving the FAT root directory timestamps as the timestamps of the FAT volume label directory entry. At least Mac OS X is known to support the same mechanism and interoperate with this commit.
When mounting, the following values can be specified for the 'rootts' mount option:
"rootts=ignore" ignores root directory timestamps. All timestamps are
reset to 0 (1/1/1970). This has been the FAT behaviour prior to this patch.
"rootts=preserve" tries to load and save the root directory's timestamps
if a volume label entry exists. The mtime and atime are corrected based on root directory entries' ctime. This is the default.
"rootts=save" tries to load and save the root directory's timestamps.
The mtime and atime are corrected based on root directory entries' ctime. If the root directory was accessed but no volume label entry exists, the label "NO NAME" is created.
--- Documentation/filesystems/vfat.txt | 9 ++ fs/fat/dir.c | 75 ++++++++++++++ fs/fat/fat.h | 19 ++++ fs/fat/inode.c | 192 +++++++++++++++++++++++++----------- 4 files changed, 239 insertions(+), 56 deletions(-)
Documentation/filesystems/vfat.txt +9 -0
@@ -137,6 +137,15 @@ errors=panic|continue|remount-ro without doing anything or remount the partition in read-only mode (default behavior). +rootts=ignore|preserve|save + -- Specify whether to load/store the root dir timestamps as the + timestamp of the volume label entry. + ignore: do not load or store root dir ts. + preserve: load the root dir ts, store them only if a volume + label already exists. This is the default. + save: load and store the root dir ts, create a volume label + if the ts have changed but no label is present. + <bool>: 0,1,yes,no,true,false TODO
fs/fat/dir.c +75 -0
78 lines not on this page · raw message
fs/fat/fat.h +19 -0
@@ -21,6 +21,14 @@#define FAT_ERRORS_PANIC 2/* panic on error */ #define FAT_ERRORS_RO 3/* remount r/o on error */ +/* +* fat root directory timestamp backup +*/ +#define FAT_ROOT_TS_IGNORE 1/* do not read or write root dir ts */ +#define FAT_ROOT_TS_PRESERVE 2/* read and write root dir ts as volume label +timestamp */ +#define FAT_ROOT_TS_SAVE 3/* create volume label if there is none */ +struct fat_mount_options {uid_t fs_uid;gid_t fs_gid;
@@ -32,6 +40,8 @@ struct fat_mount_options {unsigned char name_check;/* r = relaxed, n = normal, s = strict */ unsigned char errors;/* On error: continue, panic, remount-ro */ unsigned short allow_utime;/* permission for setting the [am]time */ +unsigned short root_ts;/* root dir timestamps: +ignore, preserve, save */ unsigned quiet:1, /* set = fake successful chmods and chowns */ showexec:1, /* set = only set x bit for com/exe/bat */ sys_immutable:1, /* set = system files are immutable */
@@ -50,6 +60,8 @@ struct fat_mount_options {#define FAT_HASH_BITS 8#define FAT_HASH_SIZE (1UL << FAT_HASH_BITS) +#define FAT_LABEL_NONAME "NO NAME " +/* * MS-DOS file system in-core superblock data */
@@ -247,6 +259,13 @@ extern int fat_add_entries(struct inode *dir, void *slots, int nr_slots, struct fat_slot_info *sinfo);extern int fat_remove_entries (struct inode *dir,struct fat_slot_info *sinfo); +extern int fat_get_label_entry (struct inode *root_inode, +struct buffer_head **bh, +struct msdos_dir_entry **de,loff_t *i_pos); +extern int fat_add_label_entry (struct inode *root_inode, +const unsigned char *name); +extern void fat_correct_root_ts (struct inode *root_inode); +/* fat/fatent.c */ struct fat_entry {int entry;
fs/fat/inode.c +136 -56
273 lines not on this page · raw message
Signature · 1 line
1.5.4.3
Quoted 18 lines · Jorg Schummer
Standard FAT implementations cannot store any of the FAT root directory's timestamps. This commit adds the mount option 'rootts', which allows saving the FAT root directory timestamps as the timestamps of the FAT volume label directory entry. At least Mac OS X is known to support the same mechanism and interoperate with this commit.
When mounting, the following values can be specified for the 'rootts' mount option:
"rootts=ignore" ignores root directory timestamps. All timestamps are
reset to 0 (1/1/1970). This has been the FAT behaviour prior to this patch."rootts=preserve" tries to load and save the root directory's timestamps
if a volume label entry exists. The mtime and atime are corrected based on root directory entries' ctime. This is the default.
Quoted 5 lines
"rootts=save" tries to load and save the root directory's timestamps.
The mtime and atime are corrected based on root directory entries' ctime. If the root directory was accessed but no volume label entry exists, the label "NO NAME" is created.
Does Mac OS X do the same "NO NAME" thing?
-- Jamie
Quoted 19 lines · ext Jamie Lokier
Quoted 18 lines · Jorg Schummer
Standard FAT implementations cannot store any of the FAT root directory's timestamps. This commit adds the mount option 'rootts', which allows saving the FAT root directory timestamps as the timestamps of the FAT volume label directory entry. At least Mac OS X is known to support the same mechanism and interoperate with this commit.
When mounting, the following values can be specified for the 'rootts' mount option:
"rootts=ignore" ignores root directory timestamps. All timestamps are
reset to 0 (1/1/1970). This has been the FAT behaviour prior to this patch."rootts=preserve" tries to load and save the root directory's timestamps
if a volume label entry exists. The mtime and atime are corrected based on root directory entries' ctime. This is the default.
Quoted 7 lines
Quoted 5 lines
"rootts=save" tries to load and save the root directory's timestamps.
The mtime and atime are corrected based on root directory entries' ctime. If the root directory was accessed but no volume label entry exists, the label "NO NAME" is created.Does Mac OS X do the same "NO NAME" thing?
AFAIK: No. It only supports the general mechanism of storing / loading the root dir timestamps to / from the volume label entry.
But feel free to re-check that one.
Jörg
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 18 lines · On Tue, 2009-09-08 at 16:34 +0200, Schummer Jorg.2 (EXT-TietoEnator/Helsinki)…
Standard FAT implementations cannot store any of the FAT root directory's timestamps. This commit adds the mount option 'rootts', which allows saving the FAT root directory timestamps as the timestamps of the FAT volume label directory entry. At least Mac OS X is known to support the same mechanism and interoperate with this commit.
When mounting, the following values can be specified for the 'rootts' mount option:
"rootts=ignore" ignores root directory timestamps. All timestamps are
reset to 0 (1/1/1970). This has been the FAT behaviour prior to this patch."rootts=preserve" tries to load and save the root directory's timestamps
if a volume label entry exists. The mtime and atime are corrected based on root directory entries' ctime. This is the default.
Quoted 5 lines
"rootts=save" tries to load and save the root directory's timestamps.
The mtime and atime are corrected based on root directory entries' ctime. If the root directory was accessed but no volume label entry exists, the label "NO NAME" is created.
Hello again,
in case anyone would like to send some feedback or comments about the patch, please use this email address from now on: [email protected] .
Thanks,
Jörg
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
OGAWA Hirofumi
maintainerQuoted 18 lines · Jorg Schummer
Standard FAT implementations cannot store any of the FAT root directory's timestamps. This commit adds the mount option 'rootts', which allows saving the FAT root directory timestamps as the timestamps of the FAT volume label directory entry. At least Mac OS X is known to support the same mechanism and interoperate with this commit.
When mounting, the following values can be specified for the 'rootts' mount option:
"rootts=ignore" ignores root directory timestamps. All timestamps are
reset to 0 (1/1/1970). This has been the FAT behaviour prior to this patch."rootts=preserve" tries to load and save the root directory's timestamps
if a volume label entry exists. The mtime and atime are corrected based on root directory entries' ctime. This is the default.
Quoted 5 lines
"rootts=save" tries to load and save the root directory's timestamps.
The mtime and atime are corrected based on root directory entries' ctime. If the root directory was accessed but no volume label entry exists, the label "NO NAME" is created.
Um..., I'm still not sure though. rootts=save may not be needed for this, because it seems a bit complex, and it can do on userland...
And some quick review of implement..
Quoted 17 lines
fs/fat/inode.c +17
-0+if (inode->i_ino ==MSDOS_ROOT_INO ) { +if (sbi->options.root_ts ==FAT_ROOT_TS_IGNORE ) +return 0 ; + +/* Write the timestamps of a FAT file system's root directory +* as the timestamps of the file system's label dir entry. */ + +if (!MSDOS_I (inode)->i_pos) { +struct buffer_head *bh; +struct msdos_dir_entry *de; +loff_t i_pos; + +if (sbi->options.root_ts !=FAT_ROOT_TS_SAVE ) +/* No label present, but we should not +create one. Thus not complaining. */ +return 0 ; +
fs/fat/inode.c static int fat_write_inode(struct inode *inode, int wait) · line 655
Quoted 10 lines
fs/fat/inode.c +10
-0+printk (KERN_INFO "FAT: creating volume label " +"on %s to save root dir timestamps\n" , + sb->s_id); + + err =fat_add_label_entry (inode,NULL ); +if (err) +return err; + err =fat_get_label_entry (inode, &bh, &de, &i_pos); +if (err) +return err;
In this path, we don't have inode->i_mutex, so to look directry up is wrong. I think adding label may move to userland.
I guess we should do all of preparation in fill_super().
fs/fat/inode.c static int fat_write_inode(struct inode *inode, int wait) · line 660
Quoted 4 lines
fs/fat/inode.c +4
-0+remove_inode_hash (inode); +fat_attach (inode, i_pos); +insert_inode_hash (inode); +brelse (bh);
Root inode should never change the position, so this shouldn't be needed.
Thanks.
Signature · 1 line
OGAWA Hirofumi <[email protected]>
Hello and thanks for your comments!
Quoted 11 lines · OGAWA Hirofumi
Quoted 9 lines · Jorg Schummer
Standard FAT implementations cannot store any of the FAT root directory's timestamps. This commit adds the mount option 'rootts', which allows saving the FAT root directory timestamps as the timestamps of the FAT volume label directory entry. At least Mac OS X is known to support the same mechanism and interoperate with this commit.
When mounting, the following values can be specified for the 'rootts' mount option:
...
Quoted 9 lines
Quoted 6 lines
"rootts=save" tries to load and save the root directory's timestamps.
The mtime and atime are corrected based on root directory entries' ctime. If the root directory was accessed but no volume label entry exists, the label "NO NAME" is created.Um..., I'm still not sure though. rootts=save may not be needed for this, because it seems a bit complex, and it can do on userland...
It's true, that is quite of a hack after all. I just thought I'll try to add the non-plus-ultra-feature on top of what Mac OS can do already.
But you're right, I'll get rid of the label creation. (And I think I should get rid of the time stamp correction as well. If there is no timestamp to be loaded, then 1970/1/1 should suffice. In case anyone thinks that the timestamp 'correction' is anyhow useful, let me know...)
Quoted 9 lines
And some quick review of implement..
fs/fat/inode.c static int fat_write_inode(struct inode *inode, int wait) · line 628
Quoted 1 line
fs/fat/inode.c +1
-0+if (inode->i_ino ==MSDOS_ROOT_INO ) {In this path, we don't have
inode->i_mutex, so to look directry up is wrong. I think adding label may move to userland.I guess we should do all of preparation in
fill_super().
True. This code is only needed for the time stamp creation, so it'll go in any case.
Quoted 8 lines
fs/fat/inode.c static int fat_write_inode(struct inode *inode, int wait) · line 660
Quoted 5 lines
fs/fat/inode.c +4
-0+remove_inode_hash (inode); +fat_attach (inode, i_pos); +insert_inode_hash (inode); +brelse (bh);Root inode should never change the position, so this shouldn't be needed.
Like above, this will be removed.
If 'preserve' (i.e. saving and loading the timestamp only IF a label is present) is the default, I'll remove the 'rootts=preserve' option. However, should there still be an option to switch this feature off completely ('rootts=ignore')?
Thanks very much for your comments, the next version will come soon!
Jörg
OGAWA Hirofumi
maintainerQuoted 4 lines · [email protected] writes:
If 'preserve' (i.e. saving and loading the timestamp only IF a label is present) is the default, I'll remove the 'rootts=preserve' option. However, should there still be an option to switch this feature off completely ('rootts=ignore')?
I think it should be boolean (I.e. "rootts" as "rootts=preserve", and no option as "rootts=ignore").
Thanks.
Signature · 1 line
OGAWA Hirofumi <[email protected]>