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         }
 166         return 1;
 167 }
 168 
 169 
 170 /* Read the super block of an MS-DOS FS. */
 171 
 172 struct super_block *fat_read_super(struct super_block *sb,void *data, int silent)
     /* [previous][next][first][last][top][bottom][index][help] */
 173 {
 174         struct buffer_head *bh;
 175         struct msdos_boot_sector *b;
 176         int data_sectors,logical_sector_size,sector_mult,fat_clusters=0;
 177         int debug,error,fat,quiet;
 178         char check,conversion,dotsOK,sys_immutable,showexec;
 179         uid_t uid;
 180         gid_t gid;
 181         int umask;
 182         int blksize = 512;
 183 
 184         MOD_INC_USE_COUNT;
 185         if (hardsect_size[MAJOR(sb->s_dev)] != NULL){
 186                 blksize = hardsect_size[MAJOR(sb->s_dev)][MINOR(sb->s_dev)];
 187                 if (blksize != 512){
 188                         printk ("MSDOS: Hardware sector size is %d\n",blksize);
 189                 }
 190         }
 191         if (!parse_options((char *) data,&check,&conversion,&uid,&gid,&umask,
 192             &debug,&fat,&quiet,&blksize,&dotsOK,&sys_immutable,&showexec)
 193                 || (blksize != 512 && blksize != 1024)) {
 194                 sb->s_dev = 0;
 195                 MOD_DEC_USE_COUNT;
 196                 return NULL;
 197         }
 198         cache_init();
 199         lock_super(sb);
 200         /* The first read is always 1024 bytes */
 201         sb->s_blocksize = 1024;
 202         set_blocksize(sb->s_dev, 1024);
 203         bh = bread(sb->s_dev, 0, 1024);
 204         unlock_super(sb);
 205         if (bh == NULL || !fat_is_uptodate(sb,bh)) {
 206                 brelse (bh);
 207                 sb->s_dev = 0;
 208                 printk("FAT bread failed\n");
 209                 MOD_DEC_USE_COUNT;
 210                 return NULL;
 211         }
 212         b = (struct msdos_boot_sector *) bh->b_data;
 213         set_blocksize(sb->s_dev, blksize);
 214 /*
 215  * The DOS3 partition size limit is *not* 32M as many people think.  
 216  * Instead, it is 64K sectors (with the usual sector size being
 217  * 512 bytes, leading to a 32M limit).
 218  * 
 219  * DOS 3 partition managers got around this problem by faking a 
 220  * larger sector size, ie treating multiple physical sectors as 
 221  * a single logical sector.
 222  * 
 223  * We can accommodate this scheme by adjusting our cluster size,
 224  * fat_start, and data_start by an appropriate value.
 225  *
 226  * (by Drew Eckhardt)
 227  */
 228 
 229 #define ROUND_TO_MULTIPLE(n,m) ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0)
 230     /* don't divide by zero */
 231 
 232         logical_sector_size = CF_LE_W(*(unsigned short *) &b->sector_size);
 233         sector_mult = logical_sector_size >> SECTOR_BITS;
 234         MSDOS_SB(sb)->cluster_size = b->cluster_size*sector_mult;
 235         MSDOS_SB(sb)->fats = b->fats;
 236         MSDOS_SB(sb)->fat_start = CF_LE_W(b->reserved)*sector_mult;
 237         MSDOS_SB(sb)->fat_length = CF_LE_W(b->fat_length)*sector_mult;
 238         MSDOS_SB(sb)->dir_start = (CF_LE_W(b->reserved)+b->fats*CF_LE_W(
 239             b->fat_length))*sector_mult;
 240         MSDOS_SB(sb)->dir_entries = CF_LE_W(*((unsigned short *) &b->dir_entries
 241             ));
 242         MSDOS_SB(sb)->data_start = MSDOS_SB(sb)->dir_start+ROUND_TO_MULTIPLE((
 243             MSDOS_SB(sb)->dir_entries << MSDOS_DIR_BITS) >> SECTOR_BITS,
 244             sector_mult);
 245         data_sectors = (CF_LE_W(*((unsigned short *) &b->sectors)) ?
 246             CF_LE_W(*((unsigned short *) &b->sectors)) :
 247             CF_LE_L(b->total_sect))*sector_mult-MSDOS_SB(sb)->data_start;
 248         error = !b->cluster_size || !sector_mult;
 249         if (!error) {
 250                 MSDOS_SB(sb)->clusters = b->cluster_size ? data_sectors/
 251                     b->cluster_size/sector_mult : 0;
 252                 MSDOS_SB(sb)->fat_bits = fat ? fat : MSDOS_SB(sb)->clusters >
 253                     MSDOS_FAT12 ? 16 : 12;
 254                 fat_clusters = MSDOS_SB(sb)->fat_length*SECTOR_SIZE*8/
 255                     MSDOS_SB(sb)->fat_bits;
 256                 error = !MSDOS_SB(sb)->fats || (MSDOS_SB(sb)->dir_entries &
 257                     (MSDOS_DPS-1)) || MSDOS_SB(sb)->clusters+2 > fat_clusters+
 258                     MSDOS_MAX_EXTRA || (logical_sector_size & (SECTOR_SIZE-1))
 259                     || !b->secs_track || !b->heads;
 260         }
 261         brelse(bh);
 262         /*
 263                 This must be done after the brelse because the bh is a dummy
 264                 allocated by fat_bread (see buffer.c)
 265         */
 266         sb->s_blocksize = blksize;      /* Using this small block size solve the */
 267                                 /* the misfit with buffer cache and cluster */
 268                                 /* because cluster (DOS) are often aligned */
 269                                 /* on odd sector */
 270         sb->s_blocksize_bits = blksize == 512 ? 9 : 10;
 271         if (error || debug) {
 272                 /* The MSDOS_CAN_BMAP is obsolete, but left just to remember */
 273                 printk("[MS-DOS FS Rel. 12,FAT %d,check=%c,conv=%c,"
 274                     "uid=%d,gid=%d,umask=%03o%s]\n",MSDOS_SB(sb)->fat_bits,check,
 275                     conversion,uid,gid,umask,MSDOS_CAN_BMAP(MSDOS_SB(sb)) ?
 276                     ",bmap" : "");
 277                 printk("[me=0x%x,cs=%d,#f=%d,fs=%d,fl=%d,ds=%d,de=%d,data=%d,"
 278                     "se=%d,ts=%ld,ls=%d]\n",b->media,MSDOS_SB(sb)->cluster_size,
 279                     MSDOS_SB(sb)->fats,MSDOS_SB(sb)->fat_start,MSDOS_SB(sb)->
 280                     fat_length,MSDOS_SB(sb)->dir_start,MSDOS_SB(sb)->dir_entries,
 281                     MSDOS_SB(sb)->data_start,CF_LE_W(*(unsigned short *) &b->
 282                     sectors),(unsigned long)b->total_sect,logical_sector_size);
 283                 printk ("Transaction block size = %d\n",blksize);
 284         }
 285         if (MSDOS_SB(sb)->clusters+2 > fat_clusters)
 286                 MSDOS_SB(sb)->clusters = fat_clusters-2;
 287         if (error) {
 288                 if (!silent)
 289                         printk("VFS: Can't find a valid MSDOS filesystem on dev "
 290                                "%s.\n", kdevname(sb->s_dev));
 291                 sb->s_dev = 0;
 292                 MOD_DEC_USE_COUNT;
 293                 return NULL;
 294         }
 295         sb->s_magic = MSDOS_SUPER_MAGIC;
 296         MSDOS_SB(sb)->name_check = check;
 297         MSDOS_SB(sb)->conversion = conversion;
 298         /* set up enough so that it can read an inode */
 299         MSDOS_SB(sb)->fs_uid = uid;
 300         MSDOS_SB(sb)->fs_gid = gid;
 301         MSDOS_SB(sb)->fs_umask = umask;
 302         MSDOS_SB(sb)->quiet = quiet;
 303         MSDOS_SB(sb)->dotsOK = dotsOK;
 304         MSDOS_SB(sb)->showexec = showexec;
 305         MSDOS_SB(sb)->sys_immutable = sys_immutable;
 306         MSDOS_SB(sb)->vfat = 0;   /* vfat_read_super sets this */
 307         MSDOS_SB(sb)->umsdos = 0; /* umsdos_read_super will set this */
 308         MSDOS_SB(sb)->free_clusters = -1; /* don't know yet */
 309         MSDOS_SB(sb)->fat_wait = NULL;
 310         MSDOS_SB(sb)->fat_lock = 0;
 311         MSDOS_SB(sb)->prev_free = 0;
 312         if (!(sb->s_mounted = iget(sb,MSDOS_ROOT_INO))) {
 313                 sb->s_dev = 0;
 314                 printk("get root inode failed\n");
 315                 MOD_DEC_USE_COUNT;
 316                 return NULL;
 317         }
 318         return sb;
 319 }
 320 
 321 
 322 void fat_statfs(struct super_block *sb,struct statfs *buf, int bufsiz)
     /* [previous][next][first][last][top][bottom][index][help] */
 323 {
 324         int free,nr;
 325         struct statfs tmp;
 326 
 327         lock_fat(sb);
 328         if (MSDOS_SB(sb)->free_clusters != -1)
 329                 free = MSDOS_SB(sb)->free_clusters;
 330         else {
 331                 free = 0;
 332                 for (nr = 2; nr < MSDOS_SB(sb)->clusters+2; nr++)
 333                         if (!fat_access(sb,nr,-1)) free++;
 334                 MSDOS_SB(sb)->free_clusters = free;
 335         }
 336         unlock_fat(sb);
 337         tmp.f_type = sb->s_magic;
 338         tmp.f_bsize = MSDOS_SB(sb)->cluster_size*SECTOR_SIZE;
 339         tmp.f_blocks = MSDOS_SB(sb)->clusters;
 340         tmp.f_bfree = free;
 341         tmp.f_bavail = free;
 342         tmp.f_files = 0;
 343         tmp.f_ffree = 0;
 344         tmp.f_namelen = 12;
 345         memcpy_tofs(buf, &tmp, bufsiz);
 346 }
 347 
 348 
 349 int fat_bmap(struct inode *inode,int block)
     /* [previous][next][first][last][top][bottom][index][help] */
 350 {
 351         struct msdos_sb_info *sb;
 352         int cluster,offset;
 353 
 354         sb = MSDOS_SB(inode->i_sb);
 355         if (inode->i_ino == MSDOS_ROOT_INO) {
 356                 return sb->dir_start + block;
 357         }
 358         cluster = block/sb->cluster_size;
 359         offset = block % sb->cluster_size;
 360         if (!(cluster = get_cluster(inode,cluster))) return 0;
 361         return (cluster-2)*sb->cluster_size+sb->data_start+offset;
 362 }
 363 
 364 static int is_exec(char *extension)
     /* [previous][next][first][last][top][bottom][index][help] */
 365 {
 366         char *exe_extensions = "EXECOMBAT", *walk;
 367 
 368         for (walk = exe_extensions; *walk; walk += 3)
 369                 if (!strncmp(extension, walk, 3))
 370                         return 1;
 371         return 0;
 372 }
 373 
 374 void fat_read_inode(struct inode *inode, struct inode_operations *fs_dir_inode_ops)
     /* [previous][next][first][last][top][bottom][index][help] */
 375 {
 376         struct super_block *sb = inode->i_sb;
 377         struct buffer_head *bh;
 378         struct msdos_dir_entry *raw_entry;
 379         int nr;
 380 
 381 /* printk("read inode %d\n",inode->i_ino); */
 382         MSDOS_I(inode)->i_busy = 0;
 383         MSDOS_I(inode)->i_depend = MSDOS_I(inode)->i_old = NULL;
 384         MSDOS_I(inode)->i_binary = 1;
 385         inode->i_uid = MSDOS_SB(inode->i_sb)->fs_uid;
 386         inode->i_gid = MSDOS_SB(inode->i_sb)->fs_gid;
 387         inode->i_version = ++event;
 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] */