Updated FAT attributes patch
PATCH 1/1 Updated FAT attributes patch
This updates the FAT attributes as well as (hopefully) corrects the handling of VFAT ctime. The FAT attributes are implemented as a 32-bit ioctl, per the previous discussions.
-hpa
Index: linux-2.5/fs/fat/dir.c
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/fs/fat/dir.c,v retrieving revision 1.32
fs/fat/dir.c +1 -1
@@ -639,7 +639,7 @@ both =1 ;break ;default : -return -EINVAL ; +return fat_generic_ioctl (inode, filp, cmd, arg); } d1 = (struct dirent __user *)arg;
Index: linux-2.5/fs/fat/file.c
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/fs/fat/file.c,v retrieving revision 1.28
fs/fat/file.c +1 -0
@@ -32,6 +32,7 @@ .read = generic_file_read, .write = fat_file_write, .mmap = generic_file_mmap, + .ioctl = fat_generic_ioctl, .fsync = file_fsync, .readv = generic_file_readv, .writev = generic_file_writev,
Index: linux-2.5/fs/fat/inode.c
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/fs/fat/inode.c,v retrieving revision 1.113
fs/fat/inode.c +114 -9
144 lines not on this page · raw message
Index: linux-2.5/fs/vfat/namei.c
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/fs/vfat/namei.c,v retrieving revision 1.57
fs/vfat/namei.c +1 -1
@@ -649,7 +649,7 @@ de->lcase = lcase; de->adate = de->cdate = de->date =0 ; de->ctime = de->time =0 ; - de->ctime_ms =0 ; + de->ctime_cs =0 ; de->start =0 ; de->starthi =0 ; de->size =0 ;
Index: linux-2.5/include/linux/msdos_fs.h
===================================================================
RCS file: /home/hpa/kernel/bkcvs/linux-2.5/include/linux/msdos_fs.h,v retrieving revision 1.45
include/linux/msdos_fs.h +14 -3
@@ -50,8 +50,6 @@#define MSDOS_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXU | S_IRWXG | S_IRWXO)/* Convert attribute bits and a mask to the UNIX mode. */ #define MSDOS_MKMODE (a, m) (m & (a & ATTR_RO ? S_IRUGO|S_IXUGO : S_IRWXUGO)) -/* Convert the UNIX mode to MS-DOS attribute bits. */ -#define MSDOS_MKATTR (m) ((m & S_IWUGO) ? ATTR_NONE : ATTR_RO)#define MSDOS_NAME 11/* maximum name length */ #define MSDOS_LONGNAME 256/* maximum name length */
@@ -102,6 +100,9 @@*/ #define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2])#define VFAT_IOCTL_READDIR_SHORT _IOR('r', 2, struct dirent [2]) +/* <linux/videotext.h> has used 0x72 ('r') in collision, so skip a few */ +#define FAT_IOCTL_GET_ATTRIBUTES _IOR('r', 0x10, __u32) +#define FAT_IOCTL_SET_ATTRIBUTES _IOW('r', 0x11, __u32)/* * vfat shortname flags
@@ -152,7 +153,7 @@__u8 name[8 ],ext[3 ];/* name and extension */ __u8 attr;/* attribute bits */ __u8 lcase;/* Case for base and extension */ -__u8 ctime_ms;/* Creation time, milliseconds */ +__u8 ctime_cs;/* Creation time, centiseconds (0-199) */ __le16 ctime;/* Creation time */ __le16 cdate;/* Creation date */ __le16 adate;/* Last access date */
@@ -273,6 +274,14 @@ return container_of(inode, struct msdos_inode_info, vfs_inode); } +/* Return the FAT attribute byte for this inode */ +static inline u8 msdos_attr (struct inode *inode) +{ +return ((inode->i_mode &S_IWUGO ) ?ATTR_NONE :ATTR_RO ) | + (S_ISDIR (inode->i_mode) ?ATTR_DIR :ATTR_NONE ) | +MSDOS_I (inode)->i_attrs; +} +static inline sector_t fat_clus_to_blknr (struct msdos_sb_info *sbi,int clus) {return ((sector_t )clus -FAT_START_ENT ) * sbi->sec_per_clus
@@ -341,6 +350,8 @@ struct msdos_dir_entry *de, loff_t i_pos, int *res);int fat_fill_super (struct super_block *sb,void *data,int silent,struct inode_operations *fs_dir_inode_ops,int isvfat); +extern int fat_generic_ioctl (struct inode * inode,struct file * filp, +unsigned int cmd,unsigned long arg);/* fat/misc.c */ extern void fat_fs_panic (struct super_block *s,const char *fmt, ...);
OGAWA Hirofumi
maintainerQuoted 3 lines · H. Peter Anvin
This updates the FAT attributes as well as (hopefully) corrects the handling of VFAT ctime. The FAT attributes are implemented as a 32-bit ioctl, per the previous discussions.
[...]
fs/fat/inode.c line 1435
Quoted 12 lines
fs/fat/inode.c +12
-0+/* This MUST be done before doing anything irreversible... */ +if ( (err =notify_change (filp->f_dentry, &ia)) ) + goto up; + +if (sbi->options.sys_immutable) { +if ( attr &ATTR_SYS ) + inode->i_flags |=S_IMMUTABLE ; +else + inode->i_flags &=S_IMMUTABLE ; + } + +MSDOS_I (inode)->i_attrs = attr &ATTR_UNUSED ;
Looks good to me. However, we would need to add the mark_inode_ditry() after seting iattr. Because another write_inode() path can clear the dirty flag before setting ->i_attr.
I'll apply the patch and add it.
Thanks.
Signature · 1 line
OGAWA Hirofumi <[email protected]>