aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fs.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h80
1 files changed, 34 insertions, 46 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a6a625be13fc..4a853ef6fd35 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -63,18 +63,24 @@ extern int dir_notify_enable;
63#define MAY_ACCESS 16 63#define MAY_ACCESS 16
64#define MAY_OPEN 32 64#define MAY_OPEN 32
65 65
66#define FMODE_READ 1 66/* file is open for reading */
67#define FMODE_WRITE 2 67#define FMODE_READ ((__force fmode_t)1)
68 68/* file is open for writing */
69/* Internal kernel extensions */ 69#define FMODE_WRITE ((__force fmode_t)2)
70#define FMODE_LSEEK 4 70/* file is seekable */
71#define FMODE_PREAD 8 71#define FMODE_LSEEK ((__force fmode_t)4)
72#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */ 72/* file can be accessed using pread/pwrite */
73 73#define FMODE_PREAD ((__force fmode_t)8)
74/* File is being opened for execution. Primary users of this flag are 74#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */
75 distributed filesystems that can use it to achieve correct ETXTBUSY 75/* File is opened for execution with sys_execve / sys_uselib */
76 behavior for cross-node execution/opening_for_writing of files */ 76#define FMODE_EXEC ((__force fmode_t)16)
77#define FMODE_EXEC 16 77/* File is opened with O_NDELAY (only set for block devices) */
78#define FMODE_NDELAY ((__force fmode_t)32)
79/* File is opened with O_EXCL (only set for block devices) */
80#define FMODE_EXCL ((__force fmode_t)64)
81/* File is opened using open(.., 3, ..) and is writeable only for ioctls
82 (specialy hack for floppy.c) */
83#define FMODE_WRITE_IOCTL ((__force fmode_t)128)
78 84
79#define RW_MASK 1 85#define RW_MASK 1
80#define RWA_MASK 2 86#define RWA_MASK 2
@@ -136,7 +142,7 @@ extern int dir_notify_enable;
136/* 142/*
137 * Superblock flags that can be altered by MS_REMOUNT 143 * Superblock flags that can be altered by MS_REMOUNT
138 */ 144 */
139#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK) 145#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION)
140 146
141/* 147/*
142 * Old magic mount flag and mask 148 * Old magic mount flag and mask
@@ -484,13 +490,6 @@ struct address_space_operations {
484 int (*readpages)(struct file *filp, struct address_space *mapping, 490 int (*readpages)(struct file *filp, struct address_space *mapping,
485 struct list_head *pages, unsigned nr_pages); 491 struct list_head *pages, unsigned nr_pages);
486 492
487 /*
488 * ext3 requires that a successful prepare_write() call be followed
489 * by a commit_write() call - they must be balanced
490 */
491 int (*prepare_write)(struct file *, struct page *, unsigned, unsigned);
492 int (*commit_write)(struct file *, struct page *, unsigned, unsigned);
493
494 int (*write_begin)(struct file *, struct address_space *mapping, 493 int (*write_begin)(struct file *, struct address_space *mapping,
495 loff_t pos, unsigned len, unsigned flags, 494 loff_t pos, unsigned len, unsigned flags,
496 struct page **pagep, void **fsdata); 495 struct page **pagep, void **fsdata);
@@ -825,7 +824,7 @@ struct file {
825 const struct file_operations *f_op; 824 const struct file_operations *f_op;
826 atomic_long_t f_count; 825 atomic_long_t f_count;
827 unsigned int f_flags; 826 unsigned int f_flags;
828 mode_t f_mode; 827 fmode_t f_mode;
829 loff_t f_pos; 828 loff_t f_pos;
830 struct fown_struct f_owner; 829 struct fown_struct f_owner;
831 unsigned int f_uid, f_gid; 830 unsigned int f_uid, f_gid;
@@ -1037,7 +1036,6 @@ extern int vfs_setlease(struct file *, long, struct file_lock **);
1037extern int lease_modify(struct file_lock **, int); 1036extern int lease_modify(struct file_lock **, int);
1038extern int lock_may_read(struct inode *, loff_t start, unsigned long count); 1037extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
1039extern int lock_may_write(struct inode *, loff_t start, unsigned long count); 1038extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
1040extern struct seq_operations locks_seq_operations;
1041#else /* !CONFIG_FILE_LOCKING */ 1039#else /* !CONFIG_FILE_LOCKING */
1042#define fcntl_getlk(a, b) ({ -EINVAL; }) 1040#define fcntl_getlk(a, b) ({ -EINVAL; })
1043#define fcntl_setlk(a, b, c, d) ({ -EACCES; }) 1041#define fcntl_setlk(a, b, c, d) ({ -EACCES; })
@@ -1152,6 +1150,7 @@ struct super_block {
1152 char s_id[32]; /* Informational name */ 1150 char s_id[32]; /* Informational name */
1153 1151
1154 void *s_fs_info; /* Filesystem private info */ 1152 void *s_fs_info; /* Filesystem private info */
1153 fmode_t s_mode;
1155 1154
1156 /* 1155 /*
1157 * The next field is for VFS *only*. No filesystems have any business 1156 * The next field is for VFS *only*. No filesystems have any business
@@ -1266,20 +1265,7 @@ int generic_osync_inode(struct inode *, struct address_space *, int);
1266 * to have different dirent layouts depending on the binary type. 1265 * to have different dirent layouts depending on the binary type.
1267 */ 1266 */
1268typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned); 1267typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
1269 1268struct block_device_operations;
1270struct block_device_operations {
1271 int (*open) (struct inode *, struct file *);
1272 int (*release) (struct inode *, struct file *);
1273 int (*ioctl) (struct inode *, struct file *, unsigned, unsigned long);
1274 long (*unlocked_ioctl) (struct file *, unsigned, unsigned long);
1275 long (*compat_ioctl) (struct file *, unsigned, unsigned long);
1276 int (*direct_access) (struct block_device *, sector_t,
1277 void **, unsigned long *);
1278 int (*media_changed) (struct gendisk *);
1279 int (*revalidate_disk) (struct gendisk *);
1280 int (*getgeo)(struct block_device *, struct hd_geometry *);
1281 struct module *owner;
1282};
1283 1269
1284/* These macros are for out of kernel modules to test that 1270/* These macros are for out of kernel modules to test that
1285 * the kernel supports the unlocked_ioctl and compat_ioctl 1271 * the kernel supports the unlocked_ioctl and compat_ioctl
@@ -1593,7 +1579,6 @@ extern int get_sb_pseudo(struct file_system_type *, char *,
1593 struct vfsmount *mnt); 1579 struct vfsmount *mnt);
1594extern int simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); 1580extern int simple_set_mnt(struct vfsmount *mnt, struct super_block *sb);
1595int __put_super_and_need_restart(struct super_block *sb); 1581int __put_super_and_need_restart(struct super_block *sb);
1596void unnamed_dev_init(void);
1597 1582
1598/* Alas, no aliases. Too much hassle with bringing module.h everywhere */ 1583/* Alas, no aliases. Too much hassle with bringing module.h everywhere */
1599#define fops_get(fops) \ 1584#define fops_get(fops) \
@@ -1714,7 +1699,7 @@ extern struct block_device *bdget(dev_t);
1714extern void bd_set_size(struct block_device *, loff_t size); 1699extern void bd_set_size(struct block_device *, loff_t size);
1715extern void bd_forget(struct inode *inode); 1700extern void bd_forget(struct inode *inode);
1716extern void bdput(struct block_device *); 1701extern void bdput(struct block_device *);
1717extern struct block_device *open_by_devnum(dev_t, unsigned); 1702extern struct block_device *open_by_devnum(dev_t, fmode_t);
1718#else 1703#else
1719static inline void bd_forget(struct inode *inode) {} 1704static inline void bd_forget(struct inode *inode) {}
1720#endif 1705#endif
@@ -1724,13 +1709,10 @@ extern const struct file_operations bad_sock_fops;
1724extern const struct file_operations def_fifo_fops; 1709extern const struct file_operations def_fifo_fops;
1725#ifdef CONFIG_BLOCK 1710#ifdef CONFIG_BLOCK
1726extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); 1711extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
1727extern int blkdev_ioctl(struct inode *, struct file *, unsigned, unsigned long); 1712extern int blkdev_ioctl(struct block_device *, fmode_t, unsigned, unsigned long);
1728extern int blkdev_driver_ioctl(struct inode *inode, struct file *file,
1729 struct gendisk *disk, unsigned cmd,
1730 unsigned long arg);
1731extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long); 1713extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
1732extern int blkdev_get(struct block_device *, mode_t, unsigned); 1714extern int blkdev_get(struct block_device *, fmode_t);
1733extern int blkdev_put(struct block_device *); 1715extern int blkdev_put(struct block_device *, fmode_t);
1734extern int bd_claim(struct block_device *, void *); 1716extern int bd_claim(struct block_device *, void *);
1735extern void bd_release(struct block_device *); 1717extern void bd_release(struct block_device *);
1736#ifdef CONFIG_SYSFS 1718#ifdef CONFIG_SYSFS
@@ -1761,9 +1743,10 @@ extern void chrdev_show(struct seq_file *,off_t);
1761extern const char *__bdevname(dev_t, char *buffer); 1743extern const char *__bdevname(dev_t, char *buffer);
1762extern const char *bdevname(struct block_device *bdev, char *buffer); 1744extern const char *bdevname(struct block_device *bdev, char *buffer);
1763extern struct block_device *lookup_bdev(const char *); 1745extern struct block_device *lookup_bdev(const char *);
1764extern struct block_device *open_bdev_excl(const char *, int, void *); 1746extern struct block_device *open_bdev_exclusive(const char *, fmode_t, void *);
1765extern void close_bdev_excl(struct block_device *); 1747extern void close_bdev_exclusive(struct block_device *, fmode_t);
1766extern void blkdev_show(struct seq_file *,off_t); 1748extern void blkdev_show(struct seq_file *,off_t);
1749
1767#else 1750#else
1768#define BLKDEV_MAJOR_HASH_SIZE 0 1751#define BLKDEV_MAJOR_HASH_SIZE 0
1769#endif 1752#endif
@@ -1852,6 +1835,11 @@ extern int inode_permission(struct inode *, int);
1852extern int generic_permission(struct inode *, int, 1835extern int generic_permission(struct inode *, int,
1853 int (*check_acl)(struct inode *, int)); 1836 int (*check_acl)(struct inode *, int));
1854 1837
1838static inline bool execute_ok(struct inode *inode)
1839{
1840 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
1841}
1842
1855extern int get_write_access(struct inode *); 1843extern int get_write_access(struct inode *);
1856extern int deny_write_access(struct file *); 1844extern int deny_write_access(struct file *);
1857static inline void put_write_access(struct inode * inode) 1845static inline void put_write_access(struct inode * inode)