root/fs/fat/inode.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. fat_put_inode
  2. fat_put_super
  3. parse_options
  4. fat_read_super
  5. fat_statfs
  6. fat_bmap
  7. is_exec
  8. fat_read_inode
  9. fat_write_inode
  10. fat_notify_change
  11. init_module
  12. cleanup_module

   1 /*
   2  *  linux/fs/fat/inode.c
   3  *
   4  *  Written 1992,1993 by Werner Almesberger
   5  *  VFAT extensions by Gordon Chaffee, merged with msdos fs by Henrik Storner
   6  */
   7 
   8 #define __NO_VERSION__
   9 #include <linux/module.h>
  10 
  11 #include <linux/msdos_fs.h>
  12 #include <linux/kernel.h>
  13 #include <linux/sched.h>
  14 #include <linux/errno.h>
  15 #include <linux/string.h>
  16 #include <linux/major.h>
  17 #include <linux/blkdev.h>
  18 #include <linux/fs.h>
  19 #include <linux/stat.h>
  20 #include <linux/locks.h>
  21 
  22 #include "msbuffer.h"
  23 #include "tables.h"
  24 
  25 #include <asm/segment.h>
  26 
  27 
  28 
  29 void fat_put_inode(struct inode *inode)
     /* [previous][next][first][last][top][bottom][index][help] */
  30 {
  31         struct inode *depend;
  32         struct super_block *sb;
  33 
  34         if (inode->i_nlink) {
  35                 if (MSDOS_I(inode)->i_busy) fat_cache_inval_inode(inode);
  36                 return;
  37         }
  38         inode->i_size = 0;
  39         fat_truncate(inode);
  40         depend = MSDOS_I(inode)->i_depend;
  41         sb = inode->i_sb;
  42         clear_inode(inode);
  43         if (depend) {
  44                 if (MSDOS_I(depend)->i_old != inode) {
  45                         printk("Invalid link (0x%p): expected 0x%p, got 0x%p\n",
  46                             depend, inode, MSDOS_I(depend)->i_old);
  47                         fat_fs_panic(sb,"...");
  48                         return;
  49                 }
  50                 MSDOS_I(depend)->i_old = NULL;
  51                 iput(depend);
  52         }
  53 }
  54 
  55 
  56 void fat_put_super(struct super_block *sb)
     /* [previous][next][first][last][top][bottom][index][help] */
  57 {
  58         fat_cache_inval_dev(sb->s_dev);
  59         set_blocksize (sb->s_dev,BLOCK_SIZE);
  60         lock_super(sb);
  61         sb->s_dev = 0;
  62         unlock_super(sb);
  63         MOD_DEC_USE_COUNT;
  64         return;
  65 }
  66 
  67 
  68 static int parse_options(char *options,char *check,char *conversion,uid_t *uid,
     /* [previous][next][first][last][top][bottom][index][help] */
  69     gid_t *gid,int *umask,int *debug,int *fat,int *quiet,
  70         int *blksize, char *dotsOK, char *sys_immutable, char *showexec)
  71 {
  72         char *this_char,*value;
  73 
  74         *check = 'n';
  75         *conversion = 'b';
  76         *dotsOK = 0;
  77         *showexec = 0;
  78         *uid = current->uid;
  79         *gid = current->gid;
  80         *umask = current->fs->umask;
  81         *debug = *fat = *quiet = *sys_immutable = 0;
  82         if (!options) return 1;
  83         for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) {
  84                 if ((value = strchr(this_char,'=')) != NULL)
  85                         *value++ = 0;
  86                 if (!strcmp(this_char,"check") && value) {
  87                         if (value[0] && !value[1] && strchr("rns",*value))
  88                                 *check = *value;
  89                         else if (!strcmp(value,"relaxed")) *check = 'r';
  90                         else if (!strcmp(value,"normal")) *check = 'n';
  91                         else if (!strcmp(value,"strict")) *check = 's';
  92                         else return 0;
  93                 }
  94                 else if (!strcmp(this_char,"conv") && value) {
  95                         if (value[0] && !value[1] && strchr("bta",*value))
  96                                 *conversion = *value;
  97                         else if (!strcmp(value,"binary")) *conversion = 'b';
  98                         else if (!strcmp(value,"text")) *conversion = 't';
  99                         else if (!strcmp(value,"auto")) *conversion = 'a';
 100                         else return 0;
 101                 }
 102                 else if (!strcmp(this_char,"dots")) {
 103                   *dotsOK = 1;
 104                 }
 105                 else if (!strcmp(this_char,"nodots")) {
 106                   *dotsOK = 0;
 107                 }
 108                 else if (!strcmp(this_char,"showexec")) {
 109                   *showexec = 1;
 110                 }
 111                 else if (!strcmp(this_char,"dotsOK") && value) {
 112                         if (!strcmp(value,"yes")) *dotsOK = 1;
 113                         else if (!strcmp(value,"no")) *dotsOK = 0;
 114                         else return 0;
 115                 }
 116                 else if (!strcmp(this_char,"uid")) {
 117                         if (!value || !*value)
 118                                 return 0;
 119                         *uid = simple_strtoul(value,&value,0);
 120                         if (*value)
 121                                 return 0;
 122                 }
 123                 else if (!strcmp(this_char,"gid")) {
 124                         if (!value || !*value)
 125                                 return 0;
 126                         *gid = simple_strtoul(value,&value,0);
 127                         if (*value)
 128                                 return 0;
 129                 }
 130                 else if (!strcmp(this_char,"umask")) {
 131                         if (!value || !*value)
 132                                 return 0;
 133                         *umask = simple_strtoul(value,&value,8);
 134                         if (*value)
 135                                 return 0;
 136                 }
 137                 else if (!strcmp(this_char,"debug")) {
 138                         if (value) return 0;
 139                         *debug = 1;
 140                 }
 141                 else if (!strcmp(this_char,"fat")) {
 142                         if (!value || !*value)
 143                                 return 0;
 144                         *fat = simple_strtoul(value,&value,0);
 145                         if (*value || (*fat != 12 && *fat != 16))
 146                                 return 0;
 147                 }
 148                 else if (!strcmp(this_char,"quiet")) {
 149                         if (value) return 0;
 150                         *quiet = 1;
 151                 }
 152                 else if (!strcmp(this_char,"blocksize")) {
 153                         *blksize = simple_strtoul(value,&value,0);
 154                         if (*value)
 155                                 return 0;
 156                         if (*blksize != 512 && *blksize != 1024){
 157                                 printk ("MSDOS FS: Invalid blocksize (512 or 1024)\n");
 158                         }
 159                 }
 160                 else if (!strcmp(this_char,"sys_immutable")) {
 161                         if (value)
 162                                 return 0;
 163                         *sys_immutable = 1;
 164                 }
 165                 else return 1;
 166         }
 167         return 1;
 168 }
 169 
 170 
 171 /* Read the super block of an MS-DOS FS. */
 172 
 173 struct super_block *fat_read_super(struct super_block *sb,void *data, int silent)
     /* [previous][next][first][last][top][bottom][index][help] */
 174 {
 175         struct buffer_head *bh;
 176         struct msdos_boot_sector *b;
 177         int data_sectors,logical_sector_size,sector_mult,fat_clusters=0;
 178         int debug,error,fat,quiet;
 179         char check,conversion,dotsOK,sys_immutable,showexec;
 180         uid_t uid;
 181         gid_t gid;
 182         int umask;
 183         int blksize = 512;
 184 
 185         MOD_INC_USE_COUNT;
 186         if (hardsect_size[MAJOR(sb->s_dev)] != NULL){
 187                 blksize = hardsect_size[MAJOR(sb->s_dev)][MINOR(sb->s_dev)];
 188                 if (blksize != 512){
 189                         printk ("MSDOS: Hardware sector size is %d\n",blksize);
 190                 }
 191         }
 192         if (!parse_options((char *) data,&check,&conversion,&uid,&gid,&umask,
 193             &debug,&fat,&quiet,&blksize,&dotsOK,&sys_immutable,&showexec)
 194                 || (blksize != 512 && blksize != 1024)) {
 195                 sb->s_dev = 0;
 196                 MOD_DEC_USE_COUNT;
 197                 return NULL;
 198         }
 199         cache_init();
 200         lock_super(sb);
 201         /* The first read is always 1024 bytes */
 202         sb->s_blocksize = 1024;
 203         set_blocksize(sb->s_dev, 1024);
 204         bh = bread(sb->s_dev, 0, 1024);
 205         unlock_super(sb);
 206         if (bh == NULL || !fat_is_uptodate(sb,bh)) {
 207                 brelse (bh);
 208                 sb->s_dev = 0;
 209                 printk("FAT bread failed\n");
 210                 MOD_DEC_USE_COUNT;
 211                 return NULL;
 212         }
 213         b = (struct msdos_boot_sector *) bh->b_data;
 214         set_blocksize(sb->s_dev, blksize);
 215 /*
 216  * The DOS3 partition size limit is *not* 32M as many people think.  
 217  * Instead, it is 64K sectors (with the usual sector size being
 218  * 512 bytes, leading to a 32M limit).
 219  * 
 220  * DOS 3 partition managers got around this problem by faking a 
 221  * larger sector size, ie treating multiple physical sectors as 
 222  * a single logical sector.
 223  * 
 224  * We can accommodate this scheme by adjusting our cluster size,
 225  * fat_start, and data_start by an appropriate value.
 226  *
 227  * (by Drew Eckhardt)
 228  */
 229 
 230 #define ROUND_TO_MULTIPLE(n,m) ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0)
 231     /* don't divide by zero */
 232 
 233         logical_sector_size = CF_LE_W(*(unsigned short *) &b->sector_size);
 234         sector_mult = logical_sector_size >> SECTOR_BITS;
 235         MSDOS_SB(sb)->cluster_size = b->cluster_size*sector_mult;
 236         MSDOS_SB(sb)->fats = b->fats;
 237         MSDOS_SB(sb)->fat_start = CF_LE_W(b->reserved)*sector_mult;
 238         MSDOS_SB(sb)->fat_length = CF_LE_W(b->fat_length)*sector_mult;
 239         MSDOS_SB(sb)->dir_start = (CF_LE_W(b->reserved)+b->fats*CF_LE_W(
 240             b->fat_length))*sector_mult;
 241         MSDOS_SB(sb)->dir_entries = CF_LE_W(*((unsigned short *) &b->dir_entries
 242             ));
 243         MSDOS_SB(sb)->data_start = MSDOS_SB(sb)->dir_start+ROUND_TO_MULTIPLE((
 244             MSDOS_SB(sb)->dir_entries << MSDOS_DIR_BITS) >> SECTOR_BITS,
 245             sector_mult);
 246         data_sectors = (CF_LE_W(*((unsigned short *) &b->sectors)) ?
 247             CF_LE_W(*((unsigned short *) &b->sectors)) :
 248             CF_LE_L(b->total_sect))*sector_mult-MSDOS_SB(sb)->data_start;
 249         error = !b->cluster_size || !sector_mult;
 250         if (!error) {
 251                 MSDOS_SB(sb)->clusters = b->cluster_size ? data_sectors/
 252                     b->cluster_size/sector_mult : 0;
 253                 MSDOS_SB(sb)->fat_bits = fat ? fat : MSDOS_SB(sb)->clusters >
 254                     MSDOS_FAT12 ? 16 : 12;
 255                 fat_clusters = MSDOS_SB(sb)->fat_length*SECTOR_SIZE*8/
 256                     MSDOS_SB(sb)->fat_bits;
 257                 error = !MSDOS_SB(sb)->fats || (MSDOS_SB(sb)->dir_entries &
 258                     (MSDOS_DPS-1)) || MSDOS_SB(sb)->clusters+2 > fat_clusters+
 259                     MSDOS_MAX_EXTRA || (logical_sector_size & (SECTOR_SIZE-1))
 260                     || !b->secs_track || !b->heads;
 261         }
 262         brelse(bh);
 263         /*
 264                 This must be done after the brelse because the bh is a dummy
 265                 allocated by fat_bread (see buffer.c)
 266         */
 267         sb->s_blocksize = blksize;      /* Using this small block size solve the */
 268                                 /* the misfit with buffer cache and cluster */
 269                                 /* because cluster (DOS) are often aligned */
 270                                 /* on odd sector */
 271         sb->s_blocksize_bits = blksize == 512 ? 9 : 10;
 272         if (error || debug) {
 273                 /* The MSDOS_CAN_BMAP is obsolete, but left just to remember */
 274                 printk("[MS-DOS FS Rel. 12,FAT %d,check=%c,conv=%c,"
 275                     "uid=%d,gid=%d,umask=%03o%s]\n",MSDOS_SB(sb)->fat_bits,check,
 276                     conversion,uid,gid,umask,MSDOS_CAN_BMAP(MSDOS_SB(sb)) ?
 277                     ",bmap" : "");
 278                 printk("[me=0x%x,cs=%d,#f=%d,fs=%d,fl=%d,ds=%d,de=%d,data=%d,"
 279                     "se=%d,ts=%ld,ls=%d]\n",b->media,MSDOS_SB(sb)->cluster_size,
 280                     MSDOS_SB(sb)->fats,MSDOS_SB(sb)->fat_start,MSDOS_SB(sb)->
 281                     fat_length,MSDOS_SB(sb)->dir_start,MSDOS_SB(sb)->dir_entries,
 282                     MSDOS_SB(sb)->data_start,CF_LE_W(*(unsigned short *) &b->
 283                     sectors),(unsigned long)b->total_sect,logical_sector_size);
 284                 printk ("Transaction block size = %d\n",blksize);
 285         }
 286         if (MSDOS_SB(sb)->clusters+2 > fat_clusters)
 287                 MSDOS_SB(sb)->clusters = fat_clusters-2;
 288         if (error) {
 289                 if (!silent)
 290                         printk("VFS: Can't find a valid MSDOS filesystem on dev "
 291                                "%s.\n", kdevname(sb->s_dev));
 292                 sb->s_dev = 0;
 293                 MOD_DEC_USE_COUNT;
 294                 return NULL;
 295         }
 296         sb->s_magic = MSDOS_SUPER_MAGIC;
 297         MSDOS_SB(sb)->name_check = check;
 298         MSDOS_SB(sb)->conversion = conversion;
 299         /* set up enough so that it can read an inode */
 300         MSDOS_SB(sb)->fs_uid = uid;
 301         MSDOS_SB(sb)->fs_gid = gid;
 302         MSDOS_SB(sb)->fs_umask = umask;
 303         MSDOS_SB(sb)->quiet = quiet;
 304         MSDOS_SB(sb)->dotsOK = dotsOK;
 305         MSDOS_SB(sb)->showexec = showexec;
 306         MSDOS_SB(sb)->sys_immutable = sys_immutable;
 307         MSDOS_SB(sb)->vfat = 0;   /* vfat_read_super sets this */
 308         MSDOS_SB(sb)->umsdos = 0; /* umsdos_read_super will set this */
 309         MSDOS_SB(sb)->free_clusters = -1; /* don't know yet */
 310         MSDOS_SB(sb)->fat_wait = NULL;
 311         MSDOS_SB(sb)->fat_lock = 0;
 312         MSDOS_SB(sb)->prev_free = 0;
 313         if (!(sb->s_mounted = iget(sb,MSDOS_ROOT_INO))) {
 314                 sb->s_dev = 0;
 315                 printk("get root inode failed\n");
 316                 MOD_DEC_USE_COUNT;
 317                 return NULL;
 318         }
 319         return sb;
 320 }
 321 
 322 
 323 void fat_statfs(struct super_block *sb,struct statfs *buf, int bufsiz)
     /* [previous][next][first][last][top][bottom][index][help] */
 324 {
 325         int free,nr;
 326         struct statfs tmp;
 327 
 328         lock_fat(sb);
 329         if (MSDOS_SB(sb)->free_clusters != -1)
 330                 free = MSDOS_SB(sb)->free_clusters;
 331         else {
 332                 free = 0;
 333                 for (nr = 2; nr < MSDOS_SB(sb)->clusters+2; nr++)
 334                         if (!fat_access(sb,nr,-1)) free++;
 335                 MSDOS_SB(sb)->free_clusters = free;
 336         }
 337         unlock_fat(sb);
 338         tmp.f_type = sb->s_magic;
 339         tmp.f_bsize = MSDOS_SB(sb)->cluster_size*SECTOR_SIZE;
 340         tmp.f_blocks = MSDOS_SB(sb)->clusters;
 341         tmp.f_bfree = free;
 342         tmp.f_bavail = free;
 343         tmp.f_files = 0;
 344         tmp.f_ffree = 0;
 345         tmp.f_namelen = 12;
 346         memcpy_tofs(buf, &tmp, bufsiz);
 347 }
 348 
 349 
 350 int fat_bmap(struct inode *inode,int block)
     /* [previous][next][first][last][top][bottom][index][help] */
 351 {
 352         struct msdos_sb_info *sb;
 353         int cluster,offset;
 354 
 355         sb = MSDOS_SB(inode->i_sb);
 356         if (inode->i_ino == MSDOS_ROOT_INO) {
 357                 return sb->dir_start + block;
 358         }
 359         cluster = block/sb->cluster_size;
 360         offset = block % sb->cluster_size;
 361         if (!(cluster = get_cluster(inode,cluster))) return 0;
 362         return (cluster-2)*sb->cluster_size+sb->data_start+offset;
 363 }
 364 
 365 static int is_exec(char *extension)
     /* [previous][next][first][last][top][bottom][index][help] */
 366 {
 367         char *exe_extensions = "EXECOMBAT", *walk;
 368 
 369         for (walk = exe_extensions; *walk; walk += 3)
 370                 if (!strncmp(extension, walk, 3))
 371                         return 1;
 372         return 0;
 373 }
 374 
 375 void fat_read_inode(struct inode *inode, struct inode_operations *fs_dir_inode_ops)
     /* [previous][next][first][last][top][bottom][index][help] */
 376 {
 377         struct super_block *sb = inode->i_sb;
 378         struct buffer_head *bh;
 379         struct msdos_dir_entry *raw_entry;
 380         int nr;
 381 
 382 /* printk("read inode %d\n",inode->i_ino); */
 383         MSDOS_I(inode)->i_busy = 0;
 384         MSDOS_I(inode)->i_depend = MSDOS_I(inode)->i_old = NULL;
 385         MSDOS_I(inode)->i_binary = 1;
 386         inode->i_uid = MSDOS_SB(inode->i_sb)->fs_uid;
 387         inode->i_gid = MSDOS_SB(inode->i_sb)->fs_gid;
 388         if (inode->i_ino == MSDOS_ROOT_INO) {
 389                 inode->i_mode = (S_IRWXUGO & ~MSDOS_SB(inode->i_sb)->fs_umask) |
 390                     S_IFDIR;
 391                 inode->i_op = fs_dir_inode_ops;
 392                 inode->i_nlink = fat_subdirs(inode)+2;
 393                     /* subdirs (neither . nor ..) plus . and "self" */
 394                 inode->i_size = MSDOS_SB(inode->i_sb)->dir_entries*
 395                     sizeof(struct msdos_dir_entry);
 396                 inode->i_blksize = MSDOS_SB(inode->i_sb)->cluster_size*
 397                     SECTOR_SIZE;
 398                 inode->i_blocks = (inode->i_size+inode->i_blksize-1)/
 399                     inode->i_blksize*MSDOS_SB(inode->i_sb)->cluster_size;
 400                 MSDOS_I(inode)->i_start = 0;
 401                 MSDOS_I(inode)->i_attrs = 0;
 402                 inode->i_mtime = inode->i_atime = inode->i_ctime = 0;
 403                 return;
 404         }
 405         if (!(bh = bread(inode->i_dev,inode->i_ino >> MSDOS_DPB_BITS,
 406             SECTOR_SIZE))) {
 407                 printk("dev = %s, ino = %ld\n",
 408                        kdevname(inode->i_dev), inode->i_ino);
 409                 panic("fat_read_inode: unable to read i-node block");
 410         }
 411         raw_entry = &((struct msdos_dir_entry *) (bh->b_data))
 412             [inode->i_ino & (MSDOS_DPB-1)];
 413         if ((raw_entry->attr & ATTR_DIR) && !IS_FREE(raw_entry->name)) {
 414                 inode->i_mode = MSDOS_MKMODE(raw_entry->attr,S_IRWXUGO &
 415                     ~MSDOS_SB(inode->i_sb)->fs_umask) | S_IFDIR;
 416                 inode->i_op = fs_dir_inode_ops;
 417 
 418                 MSDOS_I(inode)->i_start = CF_LE_W(raw_entry->start);
 419                 inode->i_nlink = fat_subdirs(inode);
 420                     /* includes .., compensating for "self" */
 421 #ifdef DEBUG
 422                 if (!inode->i_nlink) {
 423                         printk("directory %d: i_nlink == 0\n",inode->i_ino);
 424                         inode->i_nlink = 1;
 425                 }
 426 #endif
 427                 inode->i_size = 0;
 428                 if ((nr = CF_LE_W(raw_entry->start)) != 0)
 429                         while (nr != -1) {
 430                                 inode->i_size += SECTOR_SIZE*MSDOS_SB(inode->
 431                                     i_sb)->cluster_size;
 432                                 if (!(nr = fat_access(inode->i_sb,nr,-1))) {
 433                                         printk("Directory %ld: bad FAT\n",
 434                                             inode->i_ino);
 435                                         break;
 436                                 }
 437                         }
 438         } else { /* not a directory */
 439                 inode->i_mode = MSDOS_MKMODE(raw_entry->attr,
 440                     ((IS_NOEXEC(inode) || (MSDOS_SB(inode->i_sb)->showexec &&
 441                                                 !is_exec(raw_entry->ext)))
 442                         ? S_IRUGO|S_IWUGO : S_IRWXUGO)
 443                     & ~MSDOS_SB(inode->i_sb)->fs_umask) | S_IFREG;
 444                 inode->i_op = (sb->s_blocksize == 1024)
 445                         ? &fat_file_inode_operations_1024
 446                         : &fat_file_inode_operations;
 447                 MSDOS_I(inode)->i_start = CF_LE_W(raw_entry->start);
 448                 inode->i_nlink = 1;
 449                 inode->i_size = CF_LE_L(raw_entry->size);
 450         }
 451         if(raw_entry->attr & ATTR_SYS)
 452                 if (MSDOS_SB(inode->i_sb)->sys_immutable)
 453                         inode->i_flags |= S_IMMUTABLE;
 454         MSDOS_I(inode)->i_binary = is_binary(MSDOS_SB(inode->i_sb)->conversion,
 455             raw_entry->ext);
 456         MSDOS_I(inode)->i_attrs = raw_entry->attr & ATTR_UNUSED;
 457         /* this is as close to the truth as we can get ... */
 458         inode->i_blksize = MSDOS_SB(inode->i_sb)->cluster_size*SECTOR_SIZE;
 459         inode->i_blocks = (inode->i_size+inode->i_blksize-1)/
 460             inode->i_blksize*MSDOS_SB(inode->i_sb)->cluster_size;
 461         inode->i_mtime = inode->i_atime =
 462             date_dos2unix(CF_LE_W(raw_entry->time),CF_LE_W(raw_entry->date));
 463         inode->i_ctime =
 464                 MSDOS_SB(inode->i_sb)->vfat
 465                 ? date_dos2unix(CF_LE_W(raw_entry->ctime),CF_LE_W(raw_entry->cdate))
 466                 : inode->i_mtime;
 467         brelse(bh);
 468 }
 469 
 470 
 471 void fat_write_inode(struct inode *inode)
     /* [previous][next][first][last][top][bottom][index][help] */
 472 {
 473         struct super_block *sb = inode->i_sb;
 474         struct buffer_head *bh;
 475         struct msdos_dir_entry *raw_entry;
 476 
 477         inode->i_dirt = 0;
 478         if (inode->i_ino == MSDOS_ROOT_INO || !inode->i_nlink) return;
 479         if (!(bh = bread(inode->i_dev,inode->i_ino >> MSDOS_DPB_BITS,
 480             SECTOR_SIZE))) {
 481                 printk("dev = %s, ino = %ld\n",
 482                        kdevname(inode->i_dev), inode->i_ino);
 483                 panic("msdos_write_inode: unable to read i-node block");
 484         }
 485         raw_entry = &((struct msdos_dir_entry *) (bh->b_data))
 486             [inode->i_ino & (MSDOS_DPB-1)];
 487         if (S_ISDIR(inode->i_mode)) {
 488                 raw_entry->attr = ATTR_DIR;
 489                 raw_entry->size = 0;
 490         }
 491         else {
 492                 raw_entry->attr = ATTR_NONE;
 493                 raw_entry->size = CT_LE_L(inode->i_size);
 494         }
 495         raw_entry->attr |= MSDOS_MKATTR(inode->i_mode) |
 496             MSDOS_I(inode)->i_attrs;
 497         raw_entry->start = CT_LE_L(MSDOS_I(inode)->i_start);
 498         fat_date_unix2dos(inode->i_mtime,&raw_entry->time,&raw_entry->date);
 499         raw_entry->time = CT_LE_W(raw_entry->time);
 500         raw_entry->date = CT_LE_W(raw_entry->date);
 501         if (MSDOS_SB(sb)->vfat) {
 502                 fat_date_unix2dos(inode->i_ctime,&raw_entry->ctime,&raw_entry->cdate);
 503                 raw_entry->ctime = CT_LE_W(raw_entry->ctime);
 504                 raw_entry->cdate = CT_LE_W(raw_entry->cdate);
 505         }
 506         mark_buffer_dirty(bh, 1);
 507         brelse(bh);
 508 }
 509 
 510 
 511 int fat_notify_change(struct inode * inode,struct iattr * attr)
     /* [previous][next][first][last][top][bottom][index][help] */
 512 {
 513         int error;
 514 
 515         error = inode_change_ok(inode, attr);
 516         if (error)
 517                 return error;
 518 
 519         if (((attr->ia_valid & ATTR_UID) && 
 520              (attr->ia_uid != MSDOS_SB(inode->i_sb)->fs_uid)) ||
 521             ((attr->ia_valid & ATTR_GID) && 
 522              (attr->ia_gid != MSDOS_SB(inode->i_sb)->fs_gid)) ||
 523             ((attr->ia_valid & ATTR_MODE) &&
 524              (attr->ia_mode & ~MSDOS_VALID_MODE)))
 525                 error = -EPERM;
 526 
 527         if (error)
 528                 return MSDOS_SB(inode->i_sb)->quiet ? 0 : error;
 529 
 530         inode_setattr(inode, attr);
 531 
 532         if (IS_NOEXEC(inode) && !S_ISDIR(inode->i_mode))
 533                 inode->i_mode &= S_IFMT | S_IRUGO | S_IWUGO;
 534         else
 535                 inode->i_mode |= S_IXUGO;
 536 
 537         inode->i_mode = ((inode->i_mode & S_IFMT) | ((((inode->i_mode & S_IRWXU
 538             & ~MSDOS_SB(inode->i_sb)->fs_umask) | S_IRUSR) >> 6)*S_IXUGO)) &
 539             ~MSDOS_SB(inode->i_sb)->fs_umask;
 540         return 0;
 541 }
 542 
 543 
 544 #ifdef MODULE
 545 int init_module(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 546 {
 547         return init_fat_fs();
 548 }
 549 
 550 
 551 void cleanup_module(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 552 {
 553         /* Nothing to be done, really! */
 554         return;
 555 }
 556 #endif
 557 

/* [previous][next][first][last][top][bottom][index][help] */