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. fat_read_inode
  8. fat_write_inode
  9. fat_notify_change
  10. init_module
  11. cleanup_module

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

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