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.h58
1 files changed, 26 insertions, 32 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a6a625be13fc..5b248d61430c 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -63,18 +63,23 @@ 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#define FMODE_READ ((__force fmode_t)1)
67#define FMODE_WRITE 2 67#define FMODE_WRITE ((__force fmode_t)2)
68 68
69/* Internal kernel extensions */ 69/* Internal kernel extensions */
70#define FMODE_LSEEK 4 70#define FMODE_LSEEK ((__force fmode_t)4)
71#define FMODE_PREAD 8 71#define FMODE_PREAD ((__force fmode_t)8)
72#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */ 72#define FMODE_PWRITE FMODE_PREAD /* These go hand in hand */
73 73
74/* File is being opened for execution. Primary users of this flag are 74/* File is being opened for execution. Primary users of this flag are
75 distributed filesystems that can use it to achieve correct ETXTBUSY 75 distributed filesystems that can use it to achieve correct ETXTBUSY
76 behavior for cross-node execution/opening_for_writing of files */ 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
79#define FMODE_NDELAY ((__force fmode_t)32)
80#define FMODE_EXCL ((__force fmode_t)64)
81#define FMODE_WRITE_IOCTL ((__force fmode_t)128)
82#define FMODE_NDELAY_NOW ((__force fmode_t)256)
78 83
79#define RW_MASK 1 84#define RW_MASK 1
80#define RWA_MASK 2 85#define RWA_MASK 2
@@ -136,7 +141,7 @@ extern int dir_notify_enable;
136/* 141/*
137 * Superblock flags that can be altered by MS_REMOUNT 142 * Superblock flags that can be altered by MS_REMOUNT
138 */ 143 */
139#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK) 144#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION)
140 145
141/* 146/*
142 * Old magic mount flag and mask 147 * Old magic mount flag and mask
@@ -825,7 +830,7 @@ struct file {
825 const struct file_operations *f_op; 830 const struct file_operations *f_op;
826 atomic_long_t f_count; 831 atomic_long_t f_count;
827 unsigned int f_flags; 832 unsigned int f_flags;
828 mode_t f_mode; 833 fmode_t f_mode;
829 loff_t f_pos; 834 loff_t f_pos;
830 struct fown_struct f_owner; 835 struct fown_struct f_owner;
831 unsigned int f_uid, f_gid; 836 unsigned int f_uid, f_gid;
@@ -1037,7 +1042,6 @@ extern int vfs_setlease(struct file *, long, struct file_lock **);
1037extern int lease_modify(struct file_lock **, int); 1042extern int lease_modify(struct file_lock **, int);
1038extern int lock_may_read(struct inode *, loff_t start, unsigned long count); 1043extern 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); 1044extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
1040extern struct seq_operations locks_seq_operations;
1041#else /* !CONFIG_FILE_LOCKING */ 1045#else /* !CONFIG_FILE_LOCKING */
1042#define fcntl_getlk(a, b) ({ -EINVAL; }) 1046#define fcntl_getlk(a, b) ({ -EINVAL; })
1043#define fcntl_setlk(a, b, c, d) ({ -EACCES; }) 1047#define fcntl_setlk(a, b, c, d) ({ -EACCES; })
@@ -1152,6 +1156,7 @@ struct super_block {
1152 char s_id[32]; /* Informational name */ 1156 char s_id[32]; /* Informational name */
1153 1157
1154 void *s_fs_info; /* Filesystem private info */ 1158 void *s_fs_info; /* Filesystem private info */
1159 fmode_t s_mode;
1155 1160
1156 /* 1161 /*
1157 * The next field is for VFS *only*. No filesystems have any business 1162 * The next field is for VFS *only*. No filesystems have any business
@@ -1266,20 +1271,7 @@ int generic_osync_inode(struct inode *, struct address_space *, int);
1266 * to have different dirent layouts depending on the binary type. 1271 * to have different dirent layouts depending on the binary type.
1267 */ 1272 */
1268typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned); 1273typedef int (*filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
1269 1274struct 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 1275
1284/* These macros are for out of kernel modules to test that 1276/* These macros are for out of kernel modules to test that
1285 * the kernel supports the unlocked_ioctl and compat_ioctl 1277 * the kernel supports the unlocked_ioctl and compat_ioctl
@@ -1593,7 +1585,6 @@ extern int get_sb_pseudo(struct file_system_type *, char *,
1593 struct vfsmount *mnt); 1585 struct vfsmount *mnt);
1594extern int simple_set_mnt(struct vfsmount *mnt, struct super_block *sb); 1586extern int simple_set_mnt(struct vfsmount *mnt, struct super_block *sb);
1595int __put_super_and_need_restart(struct super_block *sb); 1587int __put_super_and_need_restart(struct super_block *sb);
1596void unnamed_dev_init(void);
1597 1588
1598/* Alas, no aliases. Too much hassle with bringing module.h everywhere */ 1589/* Alas, no aliases. Too much hassle with bringing module.h everywhere */
1599#define fops_get(fops) \ 1590#define fops_get(fops) \
@@ -1714,7 +1705,7 @@ extern struct block_device *bdget(dev_t);
1714extern void bd_set_size(struct block_device *, loff_t size); 1705extern void bd_set_size(struct block_device *, loff_t size);
1715extern void bd_forget(struct inode *inode); 1706extern void bd_forget(struct inode *inode);
1716extern void bdput(struct block_device *); 1707extern void bdput(struct block_device *);
1717extern struct block_device *open_by_devnum(dev_t, unsigned); 1708extern struct block_device *open_by_devnum(dev_t, fmode_t);
1718#else 1709#else
1719static inline void bd_forget(struct inode *inode) {} 1710static inline void bd_forget(struct inode *inode) {}
1720#endif 1711#endif
@@ -1724,13 +1715,10 @@ extern const struct file_operations bad_sock_fops;
1724extern const struct file_operations def_fifo_fops; 1715extern const struct file_operations def_fifo_fops;
1725#ifdef CONFIG_BLOCK 1716#ifdef CONFIG_BLOCK
1726extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long); 1717extern int ioctl_by_bdev(struct block_device *, unsigned, unsigned long);
1727extern int blkdev_ioctl(struct inode *, struct file *, unsigned, unsigned long); 1718extern 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); 1719extern long compat_blkdev_ioctl(struct file *, unsigned, unsigned long);
1732extern int blkdev_get(struct block_device *, mode_t, unsigned); 1720extern int blkdev_get(struct block_device *, fmode_t);
1733extern int blkdev_put(struct block_device *); 1721extern int blkdev_put(struct block_device *, fmode_t);
1734extern int bd_claim(struct block_device *, void *); 1722extern int bd_claim(struct block_device *, void *);
1735extern void bd_release(struct block_device *); 1723extern void bd_release(struct block_device *);
1736#ifdef CONFIG_SYSFS 1724#ifdef CONFIG_SYSFS
@@ -1761,9 +1749,10 @@ extern void chrdev_show(struct seq_file *,off_t);
1761extern const char *__bdevname(dev_t, char *buffer); 1749extern const char *__bdevname(dev_t, char *buffer);
1762extern const char *bdevname(struct block_device *bdev, char *buffer); 1750extern const char *bdevname(struct block_device *bdev, char *buffer);
1763extern struct block_device *lookup_bdev(const char *); 1751extern struct block_device *lookup_bdev(const char *);
1764extern struct block_device *open_bdev_excl(const char *, int, void *); 1752extern struct block_device *open_bdev_exclusive(const char *, fmode_t, void *);
1765extern void close_bdev_excl(struct block_device *); 1753extern void close_bdev_exclusive(struct block_device *, fmode_t);
1766extern void blkdev_show(struct seq_file *,off_t); 1754extern void blkdev_show(struct seq_file *,off_t);
1755
1767#else 1756#else
1768#define BLKDEV_MAJOR_HASH_SIZE 0 1757#define BLKDEV_MAJOR_HASH_SIZE 0
1769#endif 1758#endif
@@ -1852,6 +1841,11 @@ extern int inode_permission(struct inode *, int);
1852extern int generic_permission(struct inode *, int, 1841extern int generic_permission(struct inode *, int,
1853 int (*check_acl)(struct inode *, int)); 1842 int (*check_acl)(struct inode *, int));
1854 1843
1844static inline bool execute_ok(struct inode *inode)
1845{
1846 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
1847}
1848
1855extern int get_write_access(struct inode *); 1849extern int get_write_access(struct inode *);
1856extern int deny_write_access(struct file *); 1850extern int deny_write_access(struct file *);
1857static inline void put_write_access(struct inode * inode) 1851static inline void put_write_access(struct inode * inode)