Commit aeb5d727062a0238a2f96c9c380fbd2be4640c6f

Authored by Al Viro
1 parent 2515ddc6db

[PATCH] introduce fmode_t, do annotations

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 41 changed files with 96 additions and 98 deletions Side-by-side Diff

... ... @@ -173,7 +173,7 @@
173 173  
174 174 static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
175 175 struct sg_io_v4 *hdr, struct bsg_device *bd,
176   - int has_write_perm)
  176 + fmode_t has_write_perm)
177 177 {
178 178 if (hdr->request_len > BLK_MAX_CDB) {
179 179 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
... ... @@ -242,7 +242,7 @@
242 242 * map sg_io_v4 to a request.
243 243 */
244 244 static struct request *
245   -bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, int has_write_perm)
  245 +bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm)
246 246 {
247 247 struct request_queue *q = bd->queue;
248 248 struct request *rq, *next_rq = NULL;
... ... @@ -601,7 +601,8 @@
601 601 }
602 602  
603 603 static int __bsg_write(struct bsg_device *bd, const char __user *buf,
604   - size_t count, ssize_t *bytes_written, int has_write_perm)
  604 + size_t count, ssize_t *bytes_written,
  605 + fmode_t has_write_perm)
605 606 {
606 607 struct bsg_command *bc;
607 608 struct request *rq;
... ... @@ -27,7 +27,7 @@
27 27 #include <linux/cdrom.h>
28 28  
29 29 int blk_verify_command(struct blk_cmd_filter *filter,
30   - unsigned char *cmd, int has_write_perm)
  30 + unsigned char *cmd, fmode_t has_write_perm)
31 31 {
32 32 /* root can do any command. */
33 33 if (capable(CAP_SYS_RAWIO))
... ... @@ -384,7 +384,8 @@
384 384 struct gendisk *disk, struct scsi_ioctl_command __user *sic)
385 385 {
386 386 struct request *rq;
387   - int err, write_perm = 0;
  387 + int err;
  388 + fmode_t write_perm = 0;
388 389 unsigned int in_len, out_len, bytes, opcode, cmdlen;
389 390 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
390 391  
... ... @@ -428,7 +429,7 @@
428 429  
429 430 /* scsi_ioctl passes NULL */
430 431 if (file && (file->f_mode & FMODE_WRITE))
431   - write_perm = 1;
  432 + write_perm = FMODE_WRITE;
432 433  
433 434 err = blk_verify_command(&q->cmd_filter, rq->cmd, write_perm);
434 435 if (err)
drivers/block/amiflop.c
... ... @@ -1560,9 +1560,9 @@
1560 1560 if (fd_ref[drive] && old_dev != system)
1561 1561 return -EBUSY;
1562 1562  
1563   - if (filp && filp->f_mode & 3) {
  1563 + if (filp && filp->f_mode & (FMODE_READ|FMODE_WRITE)) {
1564 1564 check_disk_change(inode->i_bdev);
1565   - if (filp->f_mode & 2 ) {
  1565 + if (filp->f_mode & FMODE_WRITE ) {
1566 1566 int wrprot;
1567 1567  
1568 1568 get_fdc(drive);
drivers/block/ataflop.c
... ... @@ -1826,9 +1826,9 @@
1826 1826 if (filp->f_flags & O_NDELAY)
1827 1827 return 0;
1828 1828  
1829   - if (filp->f_mode & 3) {
  1829 + if (filp->f_mode & (FMODE_READ|FMODE_WRITE)) {
1830 1830 check_disk_change(inode->i_bdev);
1831   - if (filp->f_mode & 2) {
  1831 + if (filp->f_mode & FMODE_WRITE) {
1832 1832 if (p->wpstat) {
1833 1833 if (p->ref < 0)
1834 1834 p->ref = 0;
drivers/block/floppy.c
... ... @@ -3761,14 +3761,14 @@
3761 3761 UFDCS->rawcmd = 2;
3762 3762  
3763 3763 if (!(filp->f_flags & O_NDELAY)) {
3764   - if (filp->f_mode & 3) {
  3764 + if (filp->f_mode & (FMODE_READ|FMODE_WRITE)) {
3765 3765 UDRS->last_checked = 0;
3766 3766 check_disk_change(inode->i_bdev);
3767 3767 if (UTESTF(FD_DISK_CHANGED))
3768 3768 goto out;
3769 3769 }
3770 3770 res = -EROFS;
3771   - if ((filp->f_mode & 2) && !(UTESTF(FD_DISK_WRITABLE)))
  3771 + if ((filp->f_mode & FMODE_WRITE) && !(UTESTF(FD_DISK_WRITABLE)))
3772 3772 goto out;
3773 3773 }
3774 3774 mutex_unlock(&open_lock);
drivers/block/paride/pf.c
... ... @@ -305,7 +305,7 @@
305 305 if (pf->media_status == PF_NM)
306 306 return -ENODEV;
307 307  
308   - if ((pf->media_status == PF_RO) && (file->f_mode & 2))
  308 + if ((pf->media_status == PF_RO) && (file->f_mode & FMODE_WRITE))
309 309 return -EROFS;
310 310  
311 311 pf->access++;
drivers/block/paride/pt.c
... ... @@ -667,7 +667,7 @@
667 667 goto out;
668 668  
669 669 err = -EROFS;
670   - if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & 2))
  670 + if ((!(tape->flags & PT_WRITE_OK)) && (file->f_mode & FMODE_WRITE))
671 671 goto out;
672 672  
673 673 if (!(iminor(inode) & 128))
drivers/block/pktcdvd.c
... ... @@ -2320,7 +2320,7 @@
2320 2320 /*
2321 2321 * called at open time.
2322 2322 */
2323   -static int pkt_open_dev(struct pktcdvd_device *pd, int write)
  2323 +static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write)
2324 2324 {
2325 2325 int ret;
2326 2326 long lba;
drivers/block/swim3.c
... ... @@ -908,13 +908,13 @@
908 908 return -EBUSY;
909 909  
910 910 if (err == 0 && (filp->f_flags & O_NDELAY) == 0
911   - && (filp->f_mode & 3)) {
  911 + && (filp->f_mode & (FMODE_READ|FMODE_WRITE))) {
912 912 check_disk_change(inode->i_bdev);
913 913 if (fs->ejected)
914 914 err = -ENXIO;
915 915 }
916 916  
917   - if (err == 0 && (filp->f_mode & 2)) {
  917 + if (err == 0 && (filp->f_mode & FMODE_WRITE)) {
918 918 if (fs->write_prot < 0)
919 919 fs->write_prot = swim3_readbit(fs, WRITE_PROT);
920 920 if (fs->write_prot)
drivers/char/nvram.c
... ... @@ -338,7 +338,7 @@
338 338  
339 339 if ((nvram_open_cnt && (file->f_flags & O_EXCL)) ||
340 340 (nvram_open_mode & NVRAM_EXCL) ||
341   - ((file->f_mode & 2) && (nvram_open_mode & NVRAM_WRITE))) {
  341 + ((file->f_mode & FMODE_WRITE) && (nvram_open_mode & NVRAM_WRITE))) {
342 342 spin_unlock(&nvram_state_lock);
343 343 unlock_kernel();
344 344 return -EBUSY;
... ... @@ -346,7 +346,7 @@
346 346  
347 347 if (file->f_flags & O_EXCL)
348 348 nvram_open_mode |= NVRAM_EXCL;
349   - if (file->f_mode & 2)
  349 + if (file->f_mode & FMODE_WRITE)
350 350 nvram_open_mode |= NVRAM_WRITE;
351 351 nvram_open_cnt++;
352 352  
... ... @@ -366,7 +366,7 @@
366 366 /* if only one instance is open, clear the EXCL bit */
367 367 if (nvram_open_mode & NVRAM_EXCL)
368 368 nvram_open_mode &= ~NVRAM_EXCL;
369   - if (file->f_mode & 2)
  369 + if (file->f_mode & FMODE_WRITE)
370 370 nvram_open_mode &= ~NVRAM_WRITE;
371 371  
372 372 spin_unlock(&nvram_state_lock);
drivers/ide/ide-floppy_ioctl.c
... ... @@ -250,7 +250,7 @@
250 250 case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY:
251 251 return ide_floppy_get_format_capacities(drive, argp);
252 252 case IDEFLOPPY_IOCTL_FORMAT_START:
253   - if (!(file->f_mode & 2))
  253 + if (!(file->f_mode & FMODE_WRITE))
254 254 return -EPERM;
255 255 return ide_floppy_format_unit(drive, (int __user *)argp);
256 256 case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS:
drivers/ide/ide-gd.c
... ... @@ -202,7 +202,7 @@
202 202 goto out_put_idkp;
203 203 }
204 204  
205   - if ((drive->dev_flags & IDE_DFLAG_WP) && (filp->f_mode & 2)) {
  205 + if ((drive->dev_flags & IDE_DFLAG_WP) && (filp->f_mode & FMODE_WRITE)) {
206 206 ret = -EROFS;
207 207 goto out_put_idkp;
208 208 }
drivers/md/dm-ioctl.c
... ... @@ -988,9 +988,9 @@
988 988 return r;
989 989 }
990 990  
991   -static inline int get_mode(struct dm_ioctl *param)
  991 +static inline fmode_t get_mode(struct dm_ioctl *param)
992 992 {
993   - int mode = FMODE_READ | FMODE_WRITE;
  993 + fmode_t mode = FMODE_READ | FMODE_WRITE;
994 994  
995 995 if (param->flags & DM_READONLY_FLAG)
996 996 mode = FMODE_READ;
drivers/md/dm-table.c
... ... @@ -43,7 +43,7 @@
43 43 * device. This should be a combination of FMODE_READ
44 44 * and FMODE_WRITE.
45 45 */
46   - int mode;
  46 + fmode_t mode;
47 47  
48 48 /* a list of devices used by this table */
49 49 struct list_head devices;
... ... @@ -217,7 +217,7 @@
217 217 return 0;
218 218 }
219 219  
220   -int dm_table_create(struct dm_table **result, int mode,
  220 +int dm_table_create(struct dm_table **result, fmode_t mode,
221 221 unsigned num_targets, struct mapped_device *md)
222 222 {
223 223 struct dm_table *t = kzalloc(sizeof(*t), GFP_KERNEL);
... ... @@ -395,7 +395,7 @@
395 395 * careful to leave things as they were if we fail to reopen the
396 396 * device.
397 397 */
398   -static int upgrade_mode(struct dm_dev_internal *dd, int new_mode,
  398 +static int upgrade_mode(struct dm_dev_internal *dd, fmode_t new_mode,
399 399 struct mapped_device *md)
400 400 {
401 401 int r;
... ... @@ -421,7 +421,7 @@
421 421 */
422 422 static int __table_get_device(struct dm_table *t, struct dm_target *ti,
423 423 const char *path, sector_t start, sector_t len,
424   - int mode, struct dm_dev **result)
  424 + fmode_t mode, struct dm_dev **result)
425 425 {
426 426 int r;
427 427 dev_t uninitialized_var(dev);
... ... @@ -537,7 +537,7 @@
537 537 EXPORT_SYMBOL_GPL(dm_set_device_limits);
538 538  
539 539 int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
540   - sector_t len, int mode, struct dm_dev **result)
  540 + sector_t len, fmode_t mode, struct dm_dev **result)
541 541 {
542 542 int r = __table_get_device(ti->table, ti, path,
543 543 start, len, mode, result);
... ... @@ -887,7 +887,7 @@
887 887 return &t->devices;
888 888 }
889 889  
890   -int dm_table_get_mode(struct dm_table *t)
  890 +fmode_t dm_table_get_mode(struct dm_table *t)
891 891 {
892 892 return t->mode;
893 893 }
drivers/mtd/mtdchar.c
... ... @@ -96,7 +96,7 @@
96 96 return -ENODEV;
97 97  
98 98 /* You can't open the RO devices RW */
99   - if ((file->f_mode & 2) && (minor & 1))
  99 + if ((file->f_mode & FMODE_WRITE) && (minor & 1))
100 100 return -EACCES;
101 101  
102 102 lock_kernel();
... ... @@ -114,7 +114,7 @@
114 114 }
115 115  
116 116 /* You can't open it RW if it's not a writeable device */
117   - if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) {
  117 + if ((file->f_mode & FMODE_WRITE) && !(mtd->flags & MTD_WRITEABLE)) {
118 118 put_mtd_device(mtd);
119 119 ret = -EACCES;
120 120 goto out;
... ... @@ -144,7 +144,7 @@
144 144 DEBUG(MTD_DEBUG_LEVEL0, "MTD_close\n");
145 145  
146 146 /* Only sync if opened RW */
147   - if ((file->f_mode & 2) && mtd->sync)
  147 + if ((file->f_mode & FMODE_WRITE) && mtd->sync)
148 148 mtd->sync(mtd);
149 149  
150 150 put_mtd_device(mtd);
... ... @@ -443,7 +443,7 @@
443 443 {
444 444 struct erase_info *erase;
445 445  
446   - if(!(file->f_mode & 2))
  446 + if(!(file->f_mode & FMODE_WRITE))
447 447 return -EPERM;
448 448  
449 449 erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL);
... ... @@ -497,7 +497,7 @@
497 497 struct mtd_oob_buf __user *user_buf = argp;
498 498 uint32_t retlen;
499 499  
500   - if(!(file->f_mode & 2))
  500 + if(!(file->f_mode & FMODE_WRITE))
501 501 return -EPERM;
502 502  
503 503 if (copy_from_user(&buf, argp, sizeof(struct mtd_oob_buf)))
drivers/parisc/eisa_eeprom.c
... ... @@ -86,7 +86,7 @@
86 86 {
87 87 cycle_kernel_lock();
88 88  
89   - if (file->f_mode & 2)
  89 + if (file->f_mode & FMODE_WRITE)
90 90 return -EINVAL;
91 91  
92 92 return 0;
... ... @@ -840,7 +840,7 @@
840 840 * to be used for internal purposes. If you ever need it - reconsider
841 841 * your API.
842 842 */
843   -struct block_device *open_by_devnum(dev_t dev, unsigned mode)
  843 +struct block_device *open_by_devnum(dev_t dev, fmode_t mode)
844 844 {
845 845 struct block_device *bdev = bdget(dev);
846 846 int err = -ENOMEM;
... ... @@ -975,7 +975,7 @@
975 975 }
976 976 EXPORT_SYMBOL(bd_set_size);
977 977  
978   -static int __blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags,
  978 +static int __blkdev_get(struct block_device *bdev, fmode_t mode, unsigned flags,
979 979 int for_part);
980 980 static int __blkdev_put(struct block_device *bdev, int for_part);
981 981  
... ... @@ -1104,7 +1104,7 @@
1104 1104 return ret;
1105 1105 }
1106 1106  
1107   -static int __blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags,
  1107 +static int __blkdev_get(struct block_device *bdev, fmode_t mode, unsigned flags,
1108 1108 int for_part)
1109 1109 {
1110 1110 /*
... ... @@ -1123,7 +1123,7 @@
1123 1123 return do_open(bdev, &fake_file, for_part);
1124 1124 }
1125 1125  
1126   -int blkdev_get(struct block_device *bdev, mode_t mode, unsigned flags)
  1126 +int blkdev_get(struct block_device *bdev, fmode_t mode, unsigned flags)
1127 1127 {
1128 1128 return __blkdev_get(bdev, mode, flags, 0);
1129 1129 }
... ... @@ -1315,7 +1315,7 @@
1315 1315 struct block_device *open_bdev_excl(const char *path, int flags, void *holder)
1316 1316 {
1317 1317 struct block_device *bdev;
1318   - mode_t mode = FMODE_READ;
  1318 + fmode_t mode = FMODE_READ;
1319 1319 int error = 0;
1320 1320  
1321 1321 bdev = lookup_bdev(path);
... ... @@ -51,7 +51,7 @@
51 51 filp->f_mode &= (FMODE_READ | FMODE_WRITE);
52 52  
53 53 switch (filp->f_mode) {
54   - case 1:
  54 + case FMODE_READ:
55 55 /*
56 56 * O_RDONLY
57 57 * POSIX.1 says that O_NONBLOCK means return with the FIFO
... ... @@ -76,7 +76,7 @@
76 76 }
77 77 break;
78 78  
79   - case 2:
  79 + case FMODE_WRITE:
80 80 /*
81 81 * O_WRONLY
82 82 * POSIX.1 says that O_NONBLOCK means return -1 with
... ... @@ -98,7 +98,7 @@
98 98 }
99 99 break;
100 100  
101   - case 3:
  101 + case FMODE_READ | FMODE_WRITE:
102 102 /*
103 103 * O_RDWR
104 104 * POSIX.1 leaves this case "undefined" when O_NONBLOCK is set.
... ... @@ -161,7 +161,7 @@
161 161 * code should be moved into this function.
162 162 */
163 163 struct file *alloc_file(struct vfsmount *mnt, struct dentry *dentry,
164   - mode_t mode, const struct file_operations *fop)
  164 + fmode_t mode, const struct file_operations *fop)
165 165 {
166 166 struct file *file;
167 167 struct path;
... ... @@ -193,7 +193,7 @@
193 193 * of this should be moving to alloc_file().
194 194 */
195 195 int init_file(struct file *file, struct vfsmount *mnt, struct dentry *dentry,
196   - mode_t mode, const struct file_operations *fop)
  196 + fmode_t mode, const struct file_operations *fop)
197 197 {
198 198 int error = 0;
199 199 file->f_path.dentry = dentry;
fs/hostfs/hostfs_kern.c
... ... @@ -20,7 +20,7 @@
20 20 struct hostfs_inode_info {
21 21 char *host_filename;
22 22 int fd;
23   - int mode;
  23 + fmode_t mode;
24 24 struct inode vfs_inode;
25 25 };
26 26  
... ... @@ -373,7 +373,8 @@
373 373 int hostfs_file_open(struct inode *ino, struct file *file)
374 374 {
375 375 char *name;
376   - int mode = 0, r = 0, w = 0, fd;
  376 + fmode_t mode = 0;
  377 + int r = 0, w = 0, fd;
377 378  
378 379 mode = file->f_mode & (FMODE_READ | FMODE_WRITE);
379 380 if ((mode & HOSTFS_I(ino)->mode) == mode)
... ... @@ -1580,7 +1580,8 @@
1580 1580 cmd &= ~LOCK_NB;
1581 1581 unlock = (cmd == LOCK_UN);
1582 1582  
1583   - if (!unlock && !(cmd & LOCK_MAND) && !(filp->f_mode & 3))
  1583 + if (!unlock && !(cmd & LOCK_MAND) &&
  1584 + !(filp->f_mode & (FMODE_READ|FMODE_WRITE)))
1584 1585 goto out_putf;
1585 1586  
1586 1587 error = flock_make_lock(filp, &lock, cmd);
... ... @@ -798,7 +798,7 @@
798 798 int error;
799 799  
800 800 f->f_flags = flags;
801   - f->f_mode = ((flags+1) & O_ACCMODE) | FMODE_LSEEK |
  801 + f->f_mode = (__force fmode_t)((flags+1) & O_ACCMODE) | FMODE_LSEEK |
802 802 FMODE_PREAD | FMODE_PWRITE;
803 803 inode = dentry->d_inode;
804 804 if (f->f_mode & FMODE_WRITE) {
... ... @@ -1712,9 +1712,9 @@
1712 1712 file = fcheck_files(files, fd);
1713 1713 if (!file)
1714 1714 goto out_unlock;
1715   - if (file->f_mode & 1)
  1715 + if (file->f_mode & FMODE_READ)
1716 1716 inode->i_mode |= S_IRUSR | S_IXUSR;
1717   - if (file->f_mode & 2)
  1717 + if (file->f_mode & FMODE_WRITE)
1718 1718 inode->i_mode |= S_IWUSR | S_IXUSR;
1719 1719 spin_unlock(&files->file_lock);
1720 1720 put_files_struct(files);
fs/reiserfs/journal.c
... ... @@ -2593,7 +2593,7 @@
2593 2593 {
2594 2594 int result;
2595 2595 dev_t jdev;
2596   - int blkdev_mode = FMODE_READ | FMODE_WRITE;
  2596 + fmode_t blkdev_mode = FMODE_READ | FMODE_WRITE;
2597 2597 char b[BDEVNAME_SIZE];
2598 2598  
2599 2599 result = 0;
include/linux/blkdev.h
... ... @@ -910,7 +910,8 @@
910 910 * command filter functions
911 911 */
912 912 extern int blk_verify_command(struct blk_cmd_filter *filter,
913   - unsigned char *cmd, int has_write_perm);
  913 + unsigned char *cmd, fmode_t has_write_perm);
  914 +extern void blk_unregister_filter(struct gendisk *disk);
914 915 extern void blk_set_cmd_filter_defaults(struct blk_cmd_filter *filter);
915 916  
916 917 #define MAX_PHYS_SEGMENTS 128
include/linux/device-mapper.h
... ... @@ -85,7 +85,7 @@
85 85  
86 86 struct dm_dev {
87 87 struct block_device *bdev;
88   - int mode;
  88 + fmode_t mode;
89 89 char name[16];
90 90 };
91 91  
... ... @@ -95,7 +95,7 @@
95 95 * FIXME: too many arguments.
96 96 */
97 97 int dm_get_device(struct dm_target *ti, const char *path, sector_t start,
98   - sector_t len, int mode, struct dm_dev **result);
  98 + sector_t len, fmode_t mode, struct dm_dev **result);
99 99 void dm_put_device(struct dm_target *ti, struct dm_dev *d);
100 100  
101 101 /*
... ... @@ -223,7 +223,7 @@
223 223 /*
224 224 * First create an empty table.
225 225 */
226   -int dm_table_create(struct dm_table **result, int mode,
  226 +int dm_table_create(struct dm_table **result, fmode_t mode,
227 227 unsigned num_targets, struct mapped_device *md);
228 228  
229 229 /*
... ... @@ -254,7 +254,7 @@
254 254 */
255 255 sector_t dm_table_get_size(struct dm_table *t);
256 256 unsigned int dm_table_get_num_targets(struct dm_table *t);
257   -int dm_table_get_mode(struct dm_table *t);
  257 +fmode_t dm_table_get_mode(struct dm_table *t);
258 258 struct mapped_device *dm_table_get_md(struct dm_table *t);
259 259  
260 260 /*
include/linux/file.h
... ... @@ -19,10 +19,10 @@
19 19 struct vfsmount;
20 20 struct dentry;
21 21 extern int init_file(struct file *, struct vfsmount *mnt,
22   - struct dentry *dentry, mode_t mode,
  22 + struct dentry *dentry, fmode_t mode,
23 23 const struct file_operations *fop);
24 24 extern struct file *alloc_file(struct vfsmount *, struct dentry *dentry,
25   - mode_t mode, const struct file_operations *fop);
  25 + fmode_t mode, const struct file_operations *fop);
26 26  
27 27 static inline void fput_light(struct file *file, int fput_needed)
28 28 {
... ... @@ -63,18 +63,18 @@
63 63 #define MAY_ACCESS 16
64 64 #define MAY_OPEN 32
65 65  
66   -#define FMODE_READ 1
67   -#define FMODE_WRITE 2
  66 +#define FMODE_READ ((__force fmode_t)1)
  67 +#define FMODE_WRITE ((__force fmode_t)2)
68 68  
69 69 /* Internal kernel extensions */
70   -#define FMODE_LSEEK 4
71   -#define FMODE_PREAD 8
  70 +#define FMODE_LSEEK ((__force fmode_t)4)
  71 +#define FMODE_PREAD ((__force fmode_t)8)
72 72 #define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */
73 73  
74 74 /* File is being opened for execution. Primary users of this flag are
75 75 distributed filesystems that can use it to achieve correct ETXTBUSY
76 76 behavior for cross-node execution/opening_for_writing of files */
77   -#define FMODE_EXEC 16
  77 +#define FMODE_EXEC ((__force fmode_t)16)
78 78  
79 79 #define RW_MASK 1
80 80 #define RWA_MASK 2
... ... @@ -825,7 +825,7 @@
825 825 const struct file_operations *f_op;
826 826 atomic_long_t f_count;
827 827 unsigned int f_flags;
828   - mode_t f_mode;
  828 + fmode_t f_mode;
829 829 loff_t f_pos;
830 830 struct fown_struct f_owner;
831 831 unsigned int f_uid, f_gid;
... ... @@ -1714,7 +1714,7 @@
1714 1714 extern void bd_set_size(struct block_device *, loff_t size);
1715 1715 extern void bd_forget(struct inode *inode);
1716 1716 extern void bdput(struct block_device *);
1717   -extern struct block_device *open_by_devnum(dev_t, unsigned);
  1717 +extern struct block_device *open_by_devnum(dev_t, fmode_t);
1718 1718 #else
1719 1719 static inline void bd_forget(struct inode *inode) {}
1720 1720 #endif
... ... @@ -1729,7 +1729,7 @@
1729 1729 struct gendisk *disk, unsigned cmd,
1730 1730 unsigned long arg);
1731 1731 extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
1732   -extern int blkdev_get(struct block_device *, mode_t, unsigned);
  1732 +extern int blkdev_get(struct block_device *, fmode_t, unsigned);
1733 1733 extern int blkdev_put(struct block_device *);
1734 1734 extern int bd_claim(struct block_device *, void *);
1735 1735 extern void bd_release(struct block_device *);
include/linux/fsnotify.h
... ... @@ -188,7 +188,7 @@
188 188 struct dentry *dentry = file->f_path.dentry;
189 189 struct inode *inode = dentry->d_inode;
190 190 const char *name = dentry->d_name.name;
191   - mode_t mode = file->f_mode;
  191 + fmode_t mode = file->f_mode;
192 192 u32 mask = (mode & FMODE_WRITE) ? IN_CLOSE_WRITE : IN_CLOSE_NOWRITE;
193 193  
194 194 if (S_ISDIR(inode->i_mode))
include/linux/types.h
... ... @@ -190,6 +190,7 @@
190 190  
191 191 #ifdef __KERNEL__
192 192 typedef unsigned __bitwise__ gfp_t;
  193 +typedef unsigned __bitwise__ fmode_t;
193 194  
194 195 #ifdef CONFIG_PHYS_ADDR_T_64BIT
195 196 typedef u64 phys_addr_t;
... ... @@ -817,7 +817,7 @@
817 817 struct ipc_namespace *ns;
818 818 struct shm_file_data *sfd;
819 819 struct path path;
820   - mode_t f_mode;
  820 + fmode_t f_mode;
821 821  
822 822 err = -EINVAL;
823 823 if (shmid < 0)
sound/core/oss/pcm_oss.c
... ... @@ -2283,7 +2283,7 @@
2283 2283 int idx, err;
2284 2284 struct snd_pcm_oss_file *pcm_oss_file;
2285 2285 struct snd_pcm_substream *substream;
2286   - unsigned int f_mode = file->f_mode;
  2286 + fmode_t f_mode = file->f_mode;
2287 2287  
2288 2288 if (rpcm_oss_file)
2289 2289 *rpcm_oss_file = NULL;
sound/oss/au1550_ac97.c
... ... @@ -93,7 +93,7 @@
93 93 spinlock_t lock;
94 94 struct mutex open_mutex;
95 95 struct mutex sem;
96   - mode_t open_mode;
  96 + fmode_t open_mode;
97 97 wait_queue_head_t open_wait;
98 98  
99 99 struct dmabuf {
sound/oss/dmasound/dmasound.h
... ... @@ -129,7 +129,7 @@
129 129 int (*mixer_ioctl)(u_int, u_long); /* optional */
130 130 int (*write_sq_setup)(void); /* optional */
131 131 int (*read_sq_setup)(void); /* optional */
132   - int (*sq_open)(mode_t); /* optional */
  132 + int (*sq_open)(fmode_t); /* optional */
133 133 int (*state_info)(char *, size_t); /* optional */
134 134 void (*abort_read)(void); /* optional */
135 135 int min_dsp_speed;
... ... @@ -235,7 +235,7 @@
235 235 */
236 236 int active;
237 237 wait_queue_head_t action_queue, open_queue, sync_queue;
238   - int open_mode;
  238 + fmode_t open_mode;
239 239 int busy, syncing, xruns, died;
240 240 };
241 241  
sound/oss/dmasound/dmasound_atari.c
... ... @@ -143,7 +143,7 @@
143 143 static int TTMixerIoctl(u_int cmd, u_long arg);
144 144 static int FalconMixerIoctl(u_int cmd, u_long arg);
145 145 static int AtaWriteSqSetup(void);
146   -static int AtaSqOpen(mode_t mode);
  146 +static int AtaSqOpen(fmode_t mode);
147 147 static int TTStateInfo(char *buffer, size_t space);
148 148 static int FalconStateInfo(char *buffer, size_t space);
149 149  
... ... @@ -1461,7 +1461,7 @@
1461 1461 return 0 ;
1462 1462 }
1463 1463  
1464   -static int AtaSqOpen(mode_t mode)
  1464 +static int AtaSqOpen(fmode_t mode)
1465 1465 {
1466 1466 write_sq_ignore_int = 1;
1467 1467 return 0 ;
sound/oss/dmasound/dmasound_core.c
... ... @@ -212,7 +212,7 @@
212 212 #endif /* MODULE */
213 213  
214 214 /* control over who can modify resources shared between play/record */
215   -static mode_t shared_resource_owner;
  215 +static fmode_t shared_resource_owner;
216 216 static int shared_resources_initialised;
217 217  
218 218 /*
... ... @@ -668,7 +668,7 @@
668 668  
669 669 #if 0 /* blocking open() */
670 670 static inline void sq_wake_up(struct sound_queue *sq, struct file *file,
671   - mode_t mode)
  671 + fmode_t mode)
672 672 {
673 673 if (file->f_mode & mode) {
674 674 sq->busy = 0; /* CHECK: IS THIS OK??? */
... ... @@ -677,7 +677,7 @@
677 677 }
678 678 #endif
679 679  
680   -static int sq_open2(struct sound_queue *sq, struct file *file, mode_t mode,
  680 +static int sq_open2(struct sound_queue *sq, struct file *file, fmode_t mode,
681 681 int numbufs, int bufsize)
682 682 {
683 683 int rc = 0;
684 684  
... ... @@ -891,10 +891,10 @@
891 891 is the owner - if we have problems.
892 892 */
893 893  
894   -static int shared_resources_are_mine(mode_t md)
  894 +static int shared_resources_are_mine(fmode_t md)
895 895 {
896 896 if (shared_resource_owner)
897   - return (shared_resource_owner & md ) ;
  897 + return (shared_resource_owner & md) != 0;
898 898 else {
899 899 shared_resource_owner = md ;
900 900 return 1 ;
... ... @@ -211,7 +211,7 @@
211 211  
212 212 /* State variables */
213 213 enum { msndClassic, msndPinnacle } type;
214   - mode_t mode;
  214 + fmode_t mode;
215 215 unsigned long flags;
216 216 #define F_RESETTING 0
217 217 #define F_HAVEDIGITAL 1
sound/oss/sound_config.h
... ... @@ -110,23 +110,15 @@
110 110 #define OPEN_WRITE PCM_ENABLE_OUTPUT
111 111 #define OPEN_READWRITE (OPEN_READ|OPEN_WRITE)
112 112  
113   -#if OPEN_READ == FMODE_READ && OPEN_WRITE == FMODE_WRITE
114   -
115 113 static inline int translate_mode(struct file *file)
116 114 {
117   - return file->f_mode;
  115 + if (OPEN_READ == (__force int)FMODE_READ &&
  116 + OPEN_WRITE == (__force int)FMODE_WRITE)
  117 + return (__force int)(file->f_mode & (FMODE_READ | FMODE_WRITE));
  118 + else
  119 + return ((file->f_mode & FMODE_READ) ? OPEN_READ : 0) |
  120 + ((file->f_mode & FMODE_WRITE) ? OPEN_WRITE : 0);
118 121 }
119   -
120   -#else
121   -
122   -static inline int translate_mode(struct file *file)
123   -{
124   - return ((file->f_mode & FMODE_READ) ? OPEN_READ : 0) |
125   - ((file->f_mode & FMODE_WRITE) ? OPEN_WRITE : 0);
126   -}
127   -
128   -#endif
129   -
130 122  
131 123 #include "sound_calls.h"
132 124 #include "dev_table.h"
sound/oss/swarm_cs4297a.c
... ... @@ -295,7 +295,7 @@
295 295 struct mutex open_mutex;
296 296 struct mutex open_sem_adc;
297 297 struct mutex open_sem_dac;
298   - mode_t open_mode;
  298 + fmode_t open_mode;
299 299 wait_queue_head_t open_wait;
300 300 wait_queue_head_t open_wait_adc;
301 301 wait_queue_head_t open_wait_dac;
... ... @@ -1509,7 +1509,7 @@
1509 1509 struct mutex open_mutex;
1510 1510 struct mutex io_mutex;
1511 1511 struct mutex mix_mutex;
1512   - mode_t open_mode;
  1512 + fmode_t open_mode;
1513 1513 wait_queue_head_t open_wait;
1514 1514  
1515 1515 lithium_t lith;