diff options
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 170 |
1 files changed, 49 insertions, 121 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index b3ae77cccbb6..0b806c5e32eb 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -44,7 +44,7 @@ extern int get_max_files(void); | |||
44 | struct inodes_stat_t { | 44 | struct inodes_stat_t { |
45 | int nr_inodes; | 45 | int nr_inodes; |
46 | int nr_unused; | 46 | int nr_unused; |
47 | int dummy[5]; | 47 | int dummy[5]; /* padding for sysctl ABI compatibility */ |
48 | }; | 48 | }; |
49 | extern struct inodes_stat_t inodes_stat; | 49 | extern struct inodes_stat_t inodes_stat; |
50 | 50 | ||
@@ -283,11 +283,14 @@ extern int dir_notify_enable; | |||
283 | #include <linux/init.h> | 283 | #include <linux/init.h> |
284 | #include <linux/pid.h> | 284 | #include <linux/pid.h> |
285 | #include <linux/mutex.h> | 285 | #include <linux/mutex.h> |
286 | #include <linux/sysctl.h> | ||
287 | #include <linux/capability.h> | ||
286 | 288 | ||
287 | #include <asm/atomic.h> | 289 | #include <asm/atomic.h> |
288 | #include <asm/semaphore.h> | 290 | #include <asm/semaphore.h> |
289 | #include <asm/byteorder.h> | 291 | #include <asm/byteorder.h> |
290 | 292 | ||
293 | struct export_operations; | ||
291 | struct hd_geometry; | 294 | struct hd_geometry; |
292 | struct iovec; | 295 | struct iovec; |
293 | struct nameidata; | 296 | struct nameidata; |
@@ -820,6 +823,10 @@ struct file_lock { | |||
820 | union { | 823 | union { |
821 | struct nfs_lock_info nfs_fl; | 824 | struct nfs_lock_info nfs_fl; |
822 | struct nfs4_lock_info nfs4_fl; | 825 | struct nfs4_lock_info nfs4_fl; |
826 | struct { | ||
827 | struct list_head link; /* link in AFS vnode's pending_locks list */ | ||
828 | int state; /* state of grant or error if -ve */ | ||
829 | } afs; | ||
823 | } fl_u; | 830 | } fl_u; |
824 | }; | 831 | }; |
825 | 832 | ||
@@ -984,6 +991,9 @@ enum { | |||
984 | #define put_fs_excl() atomic_dec(¤t->fs_excl) | 991 | #define put_fs_excl() atomic_dec(¤t->fs_excl) |
985 | #define has_fs_excl() atomic_read(¤t->fs_excl) | 992 | #define has_fs_excl() atomic_read(¤t->fs_excl) |
986 | 993 | ||
994 | #define is_owner_or_cap(inode) \ | ||
995 | ((current->fsuid == (inode)->i_uid) || capable(CAP_FOWNER)) | ||
996 | |||
987 | /* not quite ready to be deprecated, but... */ | 997 | /* not quite ready to be deprecated, but... */ |
988 | extern void lock_super(struct super_block *); | 998 | extern void lock_super(struct super_block *); |
989 | extern void unlock_super(struct super_block *); | 999 | extern void unlock_super(struct super_block *); |
@@ -1054,7 +1064,7 @@ struct block_device_operations { | |||
1054 | }; | 1064 | }; |
1055 | 1065 | ||
1056 | /* | 1066 | /* |
1057 | * "descriptor" for what we're up to with a read for sendfile(). | 1067 | * "descriptor" for what we're up to with a read. |
1058 | * This allows us to use the same read code yet | 1068 | * This allows us to use the same read code yet |
1059 | * have multiple different users of the data that | 1069 | * have multiple different users of the data that |
1060 | * we read from a file. | 1070 | * we read from a file. |
@@ -1105,7 +1115,6 @@ struct file_operations { | |||
1105 | int (*aio_fsync) (struct kiocb *, int datasync); | 1115 | int (*aio_fsync) (struct kiocb *, int datasync); |
1106 | int (*fasync) (int, struct file *, int); | 1116 | int (*fasync) (int, struct file *, int); |
1107 | int (*lock) (struct file *, int, struct file_lock *); | 1117 | int (*lock) (struct file *, int, struct file_lock *); |
1108 | ssize_t (*sendfile) (struct file *, loff_t *, size_t, read_actor_t, void *); | ||
1109 | ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); | 1118 | ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); |
1110 | unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); | 1119 | unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); |
1111 | int (*check_flags)(int); | 1120 | int (*check_flags)(int); |
@@ -1138,6 +1147,8 @@ struct inode_operations { | |||
1138 | ssize_t (*listxattr) (struct dentry *, char *, size_t); | 1147 | ssize_t (*listxattr) (struct dentry *, char *, size_t); |
1139 | int (*removexattr) (struct dentry *, const char *); | 1148 | int (*removexattr) (struct dentry *, const char *); |
1140 | void (*truncate_range)(struct inode *, loff_t, loff_t); | 1149 | void (*truncate_range)(struct inode *, loff_t, loff_t); |
1150 | long (*fallocate)(struct inode *inode, int mode, loff_t offset, | ||
1151 | loff_t len); | ||
1141 | }; | 1152 | }; |
1142 | 1153 | ||
1143 | struct seq_file; | 1154 | struct seq_file; |
@@ -1211,6 +1222,14 @@ static inline void mark_inode_dirty_sync(struct inode *inode) | |||
1211 | __mark_inode_dirty(inode, I_DIRTY_SYNC); | 1222 | __mark_inode_dirty(inode, I_DIRTY_SYNC); |
1212 | } | 1223 | } |
1213 | 1224 | ||
1225 | /** | ||
1226 | * inc_nlink - directly increment an inode's link count | ||
1227 | * @inode: inode | ||
1228 | * | ||
1229 | * This is a low-level filesystem helper to replace any | ||
1230 | * direct filesystem manipulation of i_nlink. Currently, | ||
1231 | * it is only here for parity with dec_nlink(). | ||
1232 | */ | ||
1214 | static inline void inc_nlink(struct inode *inode) | 1233 | static inline void inc_nlink(struct inode *inode) |
1215 | { | 1234 | { |
1216 | inode->i_nlink++; | 1235 | inode->i_nlink++; |
@@ -1222,11 +1241,30 @@ static inline void inode_inc_link_count(struct inode *inode) | |||
1222 | mark_inode_dirty(inode); | 1241 | mark_inode_dirty(inode); |
1223 | } | 1242 | } |
1224 | 1243 | ||
1244 | /** | ||
1245 | * drop_nlink - directly drop an inode's link count | ||
1246 | * @inode: inode | ||
1247 | * | ||
1248 | * This is a low-level filesystem helper to replace any | ||
1249 | * direct filesystem manipulation of i_nlink. In cases | ||
1250 | * where we are attempting to track writes to the | ||
1251 | * filesystem, a decrement to zero means an imminent | ||
1252 | * write when the file is truncated and actually unlinked | ||
1253 | * on the filesystem. | ||
1254 | */ | ||
1225 | static inline void drop_nlink(struct inode *inode) | 1255 | static inline void drop_nlink(struct inode *inode) |
1226 | { | 1256 | { |
1227 | inode->i_nlink--; | 1257 | inode->i_nlink--; |
1228 | } | 1258 | } |
1229 | 1259 | ||
1260 | /** | ||
1261 | * clear_nlink - directly zero an inode's link count | ||
1262 | * @inode: inode | ||
1263 | * | ||
1264 | * This is a low-level filesystem helper to replace any | ||
1265 | * direct filesystem manipulation of i_nlink. See | ||
1266 | * drop_nlink() for why we care about i_nlink hitting zero. | ||
1267 | */ | ||
1230 | static inline void clear_nlink(struct inode *inode) | 1268 | static inline void clear_nlink(struct inode *inode) |
1231 | { | 1269 | { |
1232 | inode->i_nlink = 0; | 1270 | inode->i_nlink = 0; |
@@ -1247,119 +1285,6 @@ static inline void file_accessed(struct file *file) | |||
1247 | 1285 | ||
1248 | int sync_inode(struct inode *inode, struct writeback_control *wbc); | 1286 | int sync_inode(struct inode *inode, struct writeback_control *wbc); |
1249 | 1287 | ||
1250 | /** | ||
1251 | * struct export_operations - for nfsd to communicate with file systems | ||
1252 | * @decode_fh: decode a file handle fragment and return a &struct dentry | ||
1253 | * @encode_fh: encode a file handle fragment from a dentry | ||
1254 | * @get_name: find the name for a given inode in a given directory | ||
1255 | * @get_parent: find the parent of a given directory | ||
1256 | * @get_dentry: find a dentry for the inode given a file handle sub-fragment | ||
1257 | * @find_exported_dentry: | ||
1258 | * set by the exporting module to a standard helper function. | ||
1259 | * | ||
1260 | * Description: | ||
1261 | * The export_operations structure provides a means for nfsd to communicate | ||
1262 | * with a particular exported file system - particularly enabling nfsd and | ||
1263 | * the filesystem to co-operate when dealing with file handles. | ||
1264 | * | ||
1265 | * export_operations contains two basic operation for dealing with file | ||
1266 | * handles, decode_fh() and encode_fh(), and allows for some other | ||
1267 | * operations to be defined which standard helper routines use to get | ||
1268 | * specific information from the filesystem. | ||
1269 | * | ||
1270 | * nfsd encodes information use to determine which filesystem a filehandle | ||
1271 | * applies to in the initial part of the file handle. The remainder, termed | ||
1272 | * a file handle fragment, is controlled completely by the filesystem. The | ||
1273 | * standard helper routines assume that this fragment will contain one or | ||
1274 | * two sub-fragments, one which identifies the file, and one which may be | ||
1275 | * used to identify the (a) directory containing the file. | ||
1276 | * | ||
1277 | * In some situations, nfsd needs to get a dentry which is connected into a | ||
1278 | * specific part of the file tree. To allow for this, it passes the | ||
1279 | * function acceptable() together with a @context which can be used to see | ||
1280 | * if the dentry is acceptable. As there can be multiple dentrys for a | ||
1281 | * given file, the filesystem should check each one for acceptability before | ||
1282 | * looking for the next. As soon as an acceptable one is found, it should | ||
1283 | * be returned. | ||
1284 | * | ||
1285 | * decode_fh: | ||
1286 | * @decode_fh is given a &struct super_block (@sb), a file handle fragment | ||
1287 | * (@fh, @fh_len) and an acceptability testing function (@acceptable, | ||
1288 | * @context). It should return a &struct dentry which refers to the same | ||
1289 | * file that the file handle fragment refers to, and which passes the | ||
1290 | * acceptability test. If it cannot, it should return a %NULL pointer if | ||
1291 | * the file was found but no acceptable &dentries were available, or a | ||
1292 | * %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or | ||
1293 | * %ENOMEM). | ||
1294 | * | ||
1295 | * encode_fh: | ||
1296 | * @encode_fh should store in the file handle fragment @fh (using at most | ||
1297 | * @max_len bytes) information that can be used by @decode_fh to recover the | ||
1298 | * file refered to by the &struct dentry @de. If the @connectable flag is | ||
1299 | * set, the encode_fh() should store sufficient information so that a good | ||
1300 | * attempt can be made to find not only the file but also it's place in the | ||
1301 | * filesystem. This typically means storing a reference to de->d_parent in | ||
1302 | * the filehandle fragment. encode_fh() should return the number of bytes | ||
1303 | * stored or a negative error code such as %-ENOSPC | ||
1304 | * | ||
1305 | * get_name: | ||
1306 | * @get_name should find a name for the given @child in the given @parent | ||
1307 | * directory. The name should be stored in the @name (with the | ||
1308 | * understanding that it is already pointing to a a %NAME_MAX+1 sized | ||
1309 | * buffer. get_name() should return %0 on success, a negative error code | ||
1310 | * or error. @get_name will be called without @parent->i_mutex held. | ||
1311 | * | ||
1312 | * get_parent: | ||
1313 | * @get_parent should find the parent directory for the given @child which | ||
1314 | * is also a directory. In the event that it cannot be found, or storage | ||
1315 | * space cannot be allocated, a %ERR_PTR should be returned. | ||
1316 | * | ||
1317 | * get_dentry: | ||
1318 | * Given a &super_block (@sb) and a pointer to a file-system specific inode | ||
1319 | * identifier, possibly an inode number, (@inump) get_dentry() should find | ||
1320 | * the identified inode and return a dentry for that inode. Any suitable | ||
1321 | * dentry can be returned including, if necessary, a new dentry created with | ||
1322 | * d_alloc_root. The caller can then find any other extant dentrys by | ||
1323 | * following the d_alias links. If a new dentry was created using | ||
1324 | * d_alloc_root, DCACHE_NFSD_DISCONNECTED should be set, and the dentry | ||
1325 | * should be d_rehash()ed. | ||
1326 | * | ||
1327 | * If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code | ||
1328 | * can be returned. The @inump will be whatever was passed to | ||
1329 | * nfsd_find_fh_dentry() in either the @obj or @parent parameters. | ||
1330 | * | ||
1331 | * Locking rules: | ||
1332 | * get_parent is called with child->d_inode->i_mutex down | ||
1333 | * get_name is not (which is possibly inconsistent) | ||
1334 | */ | ||
1335 | |||
1336 | struct export_operations { | ||
1337 | struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, int fh_len, int fh_type, | ||
1338 | int (*acceptable)(void *context, struct dentry *de), | ||
1339 | void *context); | ||
1340 | int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len, | ||
1341 | int connectable); | ||
1342 | |||
1343 | /* the following are only called from the filesystem itself */ | ||
1344 | int (*get_name)(struct dentry *parent, char *name, | ||
1345 | struct dentry *child); | ||
1346 | struct dentry * (*get_parent)(struct dentry *child); | ||
1347 | struct dentry * (*get_dentry)(struct super_block *sb, void *inump); | ||
1348 | |||
1349 | /* This is set by the exporting module to a standard helper */ | ||
1350 | struct dentry * (*find_exported_dentry)( | ||
1351 | struct super_block *sb, void *obj, void *parent, | ||
1352 | int (*acceptable)(void *context, struct dentry *de), | ||
1353 | void *context); | ||
1354 | |||
1355 | |||
1356 | }; | ||
1357 | |||
1358 | extern struct dentry * | ||
1359 | find_exported_dentry(struct super_block *sb, void *obj, void *parent, | ||
1360 | int (*acceptable)(void *context, struct dentry *de), | ||
1361 | void *context); | ||
1362 | |||
1363 | struct file_system_type { | 1288 | struct file_system_type { |
1364 | const char *name; | 1289 | const char *name; |
1365 | int fs_flags; | 1290 | int fs_flags; |
@@ -1496,7 +1421,7 @@ extern void putname(const char *name); | |||
1496 | 1421 | ||
1497 | #ifdef CONFIG_BLOCK | 1422 | #ifdef CONFIG_BLOCK |
1498 | extern int register_blkdev(unsigned int, const char *); | 1423 | extern int register_blkdev(unsigned int, const char *); |
1499 | extern int unregister_blkdev(unsigned int, const char *); | 1424 | extern void unregister_blkdev(unsigned int, const char *); |
1500 | extern struct block_device *bdget(dev_t); | 1425 | extern struct block_device *bdget(dev_t); |
1501 | extern void bd_set_size(struct block_device *, loff_t size); | 1426 | extern void bd_set_size(struct block_device *, loff_t size); |
1502 | extern void bd_forget(struct inode *inode); | 1427 | extern void bd_forget(struct inode *inode); |
@@ -1584,6 +1509,9 @@ extern int __invalidate_device(struct block_device *); | |||
1584 | extern int invalidate_partition(struct gendisk *, int); | 1509 | extern int invalidate_partition(struct gendisk *, int); |
1585 | #endif | 1510 | #endif |
1586 | extern int invalidate_inodes(struct super_block *); | 1511 | extern int invalidate_inodes(struct super_block *); |
1512 | unsigned long __invalidate_mapping_pages(struct address_space *mapping, | ||
1513 | pgoff_t start, pgoff_t end, | ||
1514 | bool be_atomic); | ||
1587 | unsigned long invalidate_mapping_pages(struct address_space *mapping, | 1515 | unsigned long invalidate_mapping_pages(struct address_space *mapping, |
1588 | pgoff_t start, pgoff_t end); | 1516 | pgoff_t start, pgoff_t end); |
1589 | 1517 | ||
@@ -1735,7 +1663,6 @@ extern ssize_t generic_file_buffered_write(struct kiocb *, const struct iovec *, | |||
1735 | unsigned long, loff_t, loff_t *, size_t, ssize_t); | 1663 | unsigned long, loff_t, loff_t *, size_t, ssize_t); |
1736 | extern ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos); | 1664 | extern ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos); |
1737 | extern ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos); | 1665 | extern ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos); |
1738 | extern ssize_t generic_file_sendfile(struct file *, loff_t *, size_t, read_actor_t, void *); | ||
1739 | extern void do_generic_mapping_read(struct address_space *mapping, | 1666 | extern void do_generic_mapping_read(struct address_space *mapping, |
1740 | struct file_ra_state *, struct file *, | 1667 | struct file_ra_state *, struct file *, |
1741 | loff_t *, read_descriptor_t *, read_actor_t); | 1668 | loff_t *, read_descriptor_t *, read_actor_t); |
@@ -1765,9 +1692,6 @@ extern int nonseekable_open(struct inode * inode, struct file * filp); | |||
1765 | #ifdef CONFIG_FS_XIP | 1692 | #ifdef CONFIG_FS_XIP |
1766 | extern ssize_t xip_file_read(struct file *filp, char __user *buf, size_t len, | 1693 | extern ssize_t xip_file_read(struct file *filp, char __user *buf, size_t len, |
1767 | loff_t *ppos); | 1694 | loff_t *ppos); |
1768 | extern ssize_t xip_file_sendfile(struct file *in_file, loff_t *ppos, | ||
1769 | size_t count, read_actor_t actor, | ||
1770 | void *target); | ||
1771 | extern int xip_file_mmap(struct file * file, struct vm_area_struct * vma); | 1695 | extern int xip_file_mmap(struct file * file, struct vm_area_struct * vma); |
1772 | extern ssize_t xip_file_write(struct file *filp, const char __user *buf, | 1696 | extern ssize_t xip_file_write(struct file *filp, const char __user *buf, |
1773 | size_t len, loff_t *ppos); | 1697 | size_t len, loff_t *ppos); |
@@ -2021,5 +1945,9 @@ static inline void free_secdata(void *secdata) | |||
2021 | { } | 1945 | { } |
2022 | #endif /* CONFIG_SECURITY */ | 1946 | #endif /* CONFIG_SECURITY */ |
2023 | 1947 | ||
1948 | int proc_nr_files(ctl_table *table, int write, struct file *filp, | ||
1949 | void __user *buffer, size_t *lenp, loff_t *ppos); | ||
1950 | |||
1951 | |||
2024 | #endif /* __KERNEL__ */ | 1952 | #endif /* __KERNEL__ */ |
2025 | #endif /* _LINUX_FS_H */ | 1953 | #endif /* _LINUX_FS_H */ |