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.h492
1 files changed, 154 insertions, 338 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index aa110476a95b..b33cfc97b9ca 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1,62 +1,68 @@
1#ifndef _LINUX_FS_H 1#ifndef _LINUX_FS_H
2#define _LINUX_FS_H 2#define _LINUX_FS_H
3 3
4/*
5 * This file has definitions for some important file table
6 * structures etc.
7 */
8 4
9#include <linux/limits.h> 5#include <linux/linkage.h>
10#include <linux/ioctl.h> 6#include <linux/wait.h>
7#include <linux/kdev_t.h>
8#include <linux/dcache.h>
9#include <linux/path.h>
10#include <linux/stat.h>
11#include <linux/cache.h>
12#include <linux/list.h>
13#include <linux/radix-tree.h>
14#include <linux/rbtree.h>
15#include <linux/init.h>
16#include <linux/pid.h>
17#include <linux/bug.h>
18#include <linux/mutex.h>
19#include <linux/capability.h>
20#include <linux/semaphore.h>
21#include <linux/fiemap.h>
22#include <linux/rculist_bl.h>
23#include <linux/atomic.h>
24#include <linux/shrinker.h>
25#include <linux/migrate_mode.h>
26#include <linux/uidgid.h>
27#include <linux/lockdep.h>
28#include <linux/percpu-rwsem.h>
11#include <linux/blk_types.h> 29#include <linux/blk_types.h>
12#include <linux/types.h>
13 30
14/* 31#include <asm/byteorder.h>
15 * It's silly to have NR_OPEN bigger than NR_FILE, but you can change 32#include <uapi/linux/fs.h>
16 * the file limit at runtime and only root can increase the per-process
17 * nr_file rlimit, so it's safe to set up a ridiculously high absolute
18 * upper limit on files-per-process.
19 *
20 * Some programs (notably those using select()) may have to be
21 * recompiled to take full advantage of the new limits..
22 */
23
24/* Fixed constants first: */
25#undef NR_OPEN
26#define INR_OPEN_CUR 1024 /* Initial setting for nfile rlimits */
27#define INR_OPEN_MAX 4096 /* Hard limit for nfile rlimits */
28
29#define BLOCK_SIZE_BITS 10
30#define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
31
32#define SEEK_SET 0 /* seek relative to beginning of file */
33#define SEEK_CUR 1 /* seek relative to current file position */
34#define SEEK_END 2 /* seek relative to end of file */
35#define SEEK_DATA 3 /* seek to the next data */
36#define SEEK_HOLE 4 /* seek to the next hole */
37#define SEEK_MAX SEEK_HOLE
38
39struct fstrim_range {
40 __u64 start;
41 __u64 len;
42 __u64 minlen;
43};
44 33
45/* And dynamically-tunable limits and defaults: */ 34struct export_operations;
46struct files_stat_struct { 35struct hd_geometry;
47 unsigned long nr_files; /* read only */ 36struct iovec;
48 unsigned long nr_free_files; /* read only */ 37struct nameidata;
49 unsigned long max_files; /* tunable */ 38struct kiocb;
50}; 39struct kobject;
40struct pipe_inode_info;
41struct poll_table_struct;
42struct kstatfs;
43struct vm_area_struct;
44struct vfsmount;
45struct cred;
46struct swap_info_struct;
51 47
52struct inodes_stat_t { 48extern void __init inode_init(void);
53 int nr_inodes; 49extern void __init inode_init_early(void);
54 int nr_unused; 50extern void __init files_init(unsigned long);
55 int dummy[5]; /* padding for sysctl ABI compatibility */
56};
57 51
52extern struct files_stat_struct files_stat;
53extern unsigned long get_max_files(void);
54extern int sysctl_nr_open;
55extern struct inodes_stat_t inodes_stat;
56extern int leases_enable, lease_break_time;
57extern int sysctl_protected_symlinks;
58extern int sysctl_protected_hardlinks;
58 59
59#define NR_FILE 8192 /* this can well be larger on a larger system */ 60struct buffer_head;
61typedef int (get_block_t)(struct inode *inode, sector_t iblock,
62 struct buffer_head *bh_result, int create);
63typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
64 ssize_t bytes, void *private, int ret,
65 bool is_async);
60 66
61#define MAY_EXEC 0x00000001 67#define MAY_EXEC 0x00000001
62#define MAY_WRITE 0x00000002 68#define MAY_WRITE 0x00000002
@@ -118,6 +124,14 @@ struct inodes_stat_t {
118#define FMODE_NONOTIFY ((__force fmode_t)0x1000000) 124#define FMODE_NONOTIFY ((__force fmode_t)0x1000000)
119 125
120/* 126/*
127 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector
128 * that indicates that they should check the contents of the iovec are
129 * valid, but not check the memory that the iovec elements
130 * points too.
131 */
132#define CHECK_IOVEC_ONLY -1
133
134/*
121 * The below are the various read and write types that we support. Some of 135 * The below are the various read and write types that we support. Some of
122 * them include behavioral modifiers that send information down to the 136 * them include behavioral modifiers that send information down to the
123 * block layer and IO scheduler. Terminology: 137 * block layer and IO scheduler. Terminology:
@@ -175,282 +189,6 @@ struct inodes_stat_t {
175#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA) 189#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA)
176#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA) 190#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA)
177 191
178
179/*
180 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector
181 * that indicates that they should check the contents of the iovec are
182 * valid, but not check the memory that the iovec elements
183 * points too.
184 */
185#define CHECK_IOVEC_ONLY -1
186
187#define SEL_IN 1
188#define SEL_OUT 2
189#define SEL_EX 4
190
191/* public flags for file_system_type */
192#define FS_REQUIRES_DEV 1
193#define FS_BINARY_MOUNTDATA 2
194#define FS_HAS_SUBTYPE 4
195#define FS_REVAL_DOT 16384 /* Check the paths ".", ".." for staleness */
196#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move()
197 * during rename() internally.
198 */
199
200/*
201 * These are the fs-independent mount-flags: up to 32 flags are supported
202 */
203#define MS_RDONLY 1 /* Mount read-only */
204#define MS_NOSUID 2 /* Ignore suid and sgid bits */
205#define MS_NODEV 4 /* Disallow access to device special files */
206#define MS_NOEXEC 8 /* Disallow program execution */
207#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
208#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
209#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
210#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
211#define MS_NOATIME 1024 /* Do not update access times. */
212#define MS_NODIRATIME 2048 /* Do not update directory access times */
213#define MS_BIND 4096
214#define MS_MOVE 8192
215#define MS_REC 16384
216#define MS_VERBOSE 32768 /* War is peace. Verbosity is silence.
217 MS_VERBOSE is deprecated. */
218#define MS_SILENT 32768
219#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
220#define MS_UNBINDABLE (1<<17) /* change to unbindable */
221#define MS_PRIVATE (1<<18) /* change to private */
222#define MS_SLAVE (1<<19) /* change to slave */
223#define MS_SHARED (1<<20) /* change to shared */
224#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
225#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
226#define MS_I_VERSION (1<<23) /* Update inode I_version field */
227#define MS_STRICTATIME (1<<24) /* Always perform atime updates */
228#define MS_NOSEC (1<<28)
229#define MS_BORN (1<<29)
230#define MS_ACTIVE (1<<30)
231#define MS_NOUSER (1<<31)
232
233/*
234 * Superblock flags that can be altered by MS_REMOUNT
235 */
236#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION)
237
238/*
239 * Old magic mount flag and mask
240 */
241#define MS_MGC_VAL 0xC0ED0000
242#define MS_MGC_MSK 0xffff0000
243
244/* Inode flags - they have nothing to superblock flags now */
245
246#define S_SYNC 1 /* Writes are synced at once */
247#define S_NOATIME 2 /* Do not update access times */
248#define S_APPEND 4 /* Append-only file */
249#define S_IMMUTABLE 8 /* Immutable file */
250#define S_DEAD 16 /* removed, but still open directory */
251#define S_NOQUOTA 32 /* Inode is not counted to quota */
252#define S_DIRSYNC 64 /* Directory modifications are synchronous */
253#define S_NOCMTIME 128 /* Do not update file c/mtime */
254#define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
255#define S_PRIVATE 512 /* Inode is fs-internal */
256#define S_IMA 1024 /* Inode has an associated IMA struct */
257#define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
258#define S_NOSEC 4096 /* no suid or xattr security attributes */
259
260/*
261 * Note that nosuid etc flags are inode-specific: setting some file-system
262 * flags just means all the inodes inherit those flags by default. It might be
263 * possible to override it selectively if you really wanted to with some
264 * ioctl() that is not currently implemented.
265 *
266 * Exception: MS_RDONLY is always applied to the entire file system.
267 *
268 * Unfortunately, it is possible to change a filesystems flags with it mounted
269 * with files in use. This means that all of the inodes will not have their
270 * i_flags updated. Hence, i_flags no longer inherit the superblock mount
271 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
272 */
273#define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
274
275#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
276#define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
277 ((inode)->i_flags & S_SYNC))
278#define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
279 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
280#define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
281#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
282#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
283
284#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
285#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
286#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
287#define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
288
289#define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
290#define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
291#define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
292#define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
293#define IS_IMA(inode) ((inode)->i_flags & S_IMA)
294#define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
295#define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
296
297/* the read-only stuff doesn't really belong here, but any other place is
298 probably as bad and I don't want to create yet another include file. */
299
300#define BLKROSET _IO(0x12,93) /* set device read-only (0 = read-write) */
301#define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
302#define BLKRRPART _IO(0x12,95) /* re-read partition table */
303#define BLKGETSIZE _IO(0x12,96) /* return device size /512 (long *arg) */
304#define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
305#define BLKRASET _IO(0x12,98) /* set read ahead for block device */
306#define BLKRAGET _IO(0x12,99) /* get current read ahead setting */
307#define BLKFRASET _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
308#define BLKFRAGET _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
309#define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
310#define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
311#define BLKSSZGET _IO(0x12,104)/* get block device sector size */
312#if 0
313#define BLKPG _IO(0x12,105)/* See blkpg.h */
314
315/* Some people are morons. Do not use sizeof! */
316
317#define BLKELVGET _IOR(0x12,106,size_t)/* elevator get */
318#define BLKELVSET _IOW(0x12,107,size_t)/* elevator set */
319/* This was here just to show that the number is taken -
320 probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
321#endif
322/* A jump here: 108-111 have been used for various private purposes. */
323#define BLKBSZGET _IOR(0x12,112,size_t)
324#define BLKBSZSET _IOW(0x12,113,size_t)
325#define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size in bytes (u64 *arg) */
326#define BLKTRACESETUP _IOWR(0x12,115,struct blk_user_trace_setup)
327#define BLKTRACESTART _IO(0x12,116)
328#define BLKTRACESTOP _IO(0x12,117)
329#define BLKTRACETEARDOWN _IO(0x12,118)
330#define BLKDISCARD _IO(0x12,119)
331#define BLKIOMIN _IO(0x12,120)
332#define BLKIOOPT _IO(0x12,121)
333#define BLKALIGNOFF _IO(0x12,122)
334#define BLKPBSZGET _IO(0x12,123)
335#define BLKDISCARDZEROES _IO(0x12,124)
336#define BLKSECDISCARD _IO(0x12,125)
337#define BLKROTATIONAL _IO(0x12,126)
338
339#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
340#define FIBMAP _IO(0x00,1) /* bmap access */
341#define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
342#define FIFREEZE _IOWR('X', 119, int) /* Freeze */
343#define FITHAW _IOWR('X', 120, int) /* Thaw */
344#define FITRIM _IOWR('X', 121, struct fstrim_range) /* Trim */
345
346#define FS_IOC_GETFLAGS _IOR('f', 1, long)
347#define FS_IOC_SETFLAGS _IOW('f', 2, long)
348#define FS_IOC_GETVERSION _IOR('v', 1, long)
349#define FS_IOC_SETVERSION _IOW('v', 2, long)
350#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
351#define FS_IOC32_GETFLAGS _IOR('f', 1, int)
352#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
353#define FS_IOC32_GETVERSION _IOR('v', 1, int)
354#define FS_IOC32_SETVERSION _IOW('v', 2, int)
355
356/*
357 * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
358 */
359#define FS_SECRM_FL 0x00000001 /* Secure deletion */
360#define FS_UNRM_FL 0x00000002 /* Undelete */
361#define FS_COMPR_FL 0x00000004 /* Compress file */
362#define FS_SYNC_FL 0x00000008 /* Synchronous updates */
363#define FS_IMMUTABLE_FL 0x00000010 /* Immutable file */
364#define FS_APPEND_FL 0x00000020 /* writes to file may only append */
365#define FS_NODUMP_FL 0x00000040 /* do not dump file */
366#define FS_NOATIME_FL 0x00000080 /* do not update atime */
367/* Reserved for compression usage... */
368#define FS_DIRTY_FL 0x00000100
369#define FS_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
370#define FS_NOCOMP_FL 0x00000400 /* Don't compress */
371#define FS_ECOMPR_FL 0x00000800 /* Compression error */
372/* End compression flags --- maybe not all used */
373#define FS_BTREE_FL 0x00001000 /* btree format dir */
374#define FS_INDEX_FL 0x00001000 /* hash-indexed directory */
375#define FS_IMAGIC_FL 0x00002000 /* AFS directory */
376#define FS_JOURNAL_DATA_FL 0x00004000 /* Reserved for ext3 */
377#define FS_NOTAIL_FL 0x00008000 /* file tail should not be merged */
378#define FS_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
379#define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
380#define FS_EXTENT_FL 0x00080000 /* Extents */
381#define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
382#define FS_NOCOW_FL 0x00800000 /* Do not cow file */
383#define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
384
385#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
386#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
387
388
389#define SYNC_FILE_RANGE_WAIT_BEFORE 1
390#define SYNC_FILE_RANGE_WRITE 2
391#define SYNC_FILE_RANGE_WAIT_AFTER 4
392
393#ifdef __KERNEL__
394
395#include <linux/linkage.h>
396#include <linux/wait.h>
397#include <linux/kdev_t.h>
398#include <linux/dcache.h>
399#include <linux/path.h>
400#include <linux/stat.h>
401#include <linux/cache.h>
402#include <linux/list.h>
403#include <linux/radix-tree.h>
404#include <linux/prio_tree.h>
405#include <linux/init.h>
406#include <linux/pid.h>
407#include <linux/bug.h>
408#include <linux/mutex.h>
409#include <linux/capability.h>
410#include <linux/semaphore.h>
411#include <linux/fiemap.h>
412#include <linux/rculist_bl.h>
413#include <linux/atomic.h>
414#include <linux/shrinker.h>
415#include <linux/migrate_mode.h>
416#include <linux/uidgid.h>
417#include <linux/lockdep.h>
418
419#include <asm/byteorder.h>
420
421struct export_operations;
422struct hd_geometry;
423struct iovec;
424struct nameidata;
425struct kiocb;
426struct kobject;
427struct pipe_inode_info;
428struct poll_table_struct;
429struct kstatfs;
430struct vm_area_struct;
431struct vfsmount;
432struct cred;
433struct swap_info_struct;
434
435extern void __init inode_init(void);
436extern void __init inode_init_early(void);
437extern void __init files_init(unsigned long);
438
439extern struct files_stat_struct files_stat;
440extern unsigned long get_max_files(void);
441extern int sysctl_nr_open;
442extern struct inodes_stat_t inodes_stat;
443extern int leases_enable, lease_break_time;
444extern int sysctl_protected_symlinks;
445extern int sysctl_protected_hardlinks;
446
447struct buffer_head;
448typedef int (get_block_t)(struct inode *inode, sector_t iblock,
449 struct buffer_head *bh_result, int create);
450typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
451 ssize_t bytes, void *private, int ret,
452 bool is_async);
453
454/* 192/*
455 * Attribute flags. These should be or-ed together to figure out what 193 * Attribute flags. These should be or-ed together to figure out what
456 * has been changed! 194 * has been changed!
@@ -669,7 +407,7 @@ struct address_space {
669 struct radix_tree_root page_tree; /* radix tree of all pages */ 407 struct radix_tree_root page_tree; /* radix tree of all pages */
670 spinlock_t tree_lock; /* and lock protecting it */ 408 spinlock_t tree_lock; /* and lock protecting it */
671 unsigned int i_mmap_writable;/* count VM_SHARED mappings */ 409 unsigned int i_mmap_writable;/* count VM_SHARED mappings */
672 struct prio_tree_root i_mmap; /* tree of private and shared mappings */ 410 struct rb_root i_mmap; /* tree of private and shared mappings */
673 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */ 411 struct list_head i_mmap_nonlinear;/*list VM_NONLINEAR mappings */
674 struct mutex i_mmap_mutex; /* protect tree, count, list */ 412 struct mutex i_mmap_mutex; /* protect tree, count, list */
675 /* Protected by tree_lock together with the radix tree */ 413 /* Protected by tree_lock together with the radix tree */
@@ -724,6 +462,8 @@ struct block_device {
724 int bd_fsfreeze_count; 462 int bd_fsfreeze_count;
725 /* Mutex for freeze */ 463 /* Mutex for freeze */
726 struct mutex bd_fsfreeze_mutex; 464 struct mutex bd_fsfreeze_mutex;
465 /* A semaphore that prevents I/O while block size is being changed */
466 struct percpu_rw_semaphore bd_block_size_semaphore;
727}; 467};
728 468
729/* 469/*
@@ -741,7 +481,7 @@ int mapping_tagged(struct address_space *mapping, int tag);
741 */ 481 */
742static inline int mapping_mapped(struct address_space *mapping) 482static inline int mapping_mapped(struct address_space *mapping)
743{ 483{
744 return !prio_tree_empty(&mapping->i_mmap) || 484 return !RB_EMPTY_ROOT(&mapping->i_mmap) ||
745 !list_empty(&mapping->i_mmap_nonlinear); 485 !list_empty(&mapping->i_mmap_nonlinear);
746} 486}
747 487
@@ -1074,7 +814,11 @@ struct file_handle {
1074 unsigned char f_handle[0]; 814 unsigned char f_handle[0];
1075}; 815};
1076 816
1077#define get_file(x) atomic_long_inc(&(x)->f_count) 817static inline struct file *get_file(struct file *f)
818{
819 atomic_long_inc(&f->f_count);
820 return f;
821}
1078#define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1) 822#define fput_atomic(x) atomic_long_add_unless(&(x)->f_count, -1, 1)
1079#define file_count(x) atomic_long_read(&(x)->f_count) 823#define file_count(x) atomic_long_read(&(x)->f_count)
1080 824
@@ -1126,9 +870,9 @@ static inline int file_check_writeable(struct file *filp)
1126/* Page cache limit. The filesystems should put that into their s_maxbytes 870/* Page cache limit. The filesystems should put that into their s_maxbytes
1127 limits, otherwise bad things can happen in VM. */ 871 limits, otherwise bad things can happen in VM. */
1128#if BITS_PER_LONG==32 872#if BITS_PER_LONG==32
1129#define MAX_LFS_FILESIZE (((u64)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1) 873#define MAX_LFS_FILESIZE (((loff_t)PAGE_CACHE_SIZE << (BITS_PER_LONG-1))-1)
1130#elif BITS_PER_LONG==64 874#elif BITS_PER_LONG==64
1131#define MAX_LFS_FILESIZE 0x7fffffffffffffffUL 875#define MAX_LFS_FILESIZE ((loff_t)0x7fffffffffffffffLL)
1132#endif 876#endif
1133 877
1134#define FL_POSIX 1 878#define FL_POSIX 1
@@ -1503,7 +1247,6 @@ struct super_block {
1503 unsigned long s_magic; 1247 unsigned long s_magic;
1504 struct dentry *s_root; 1248 struct dentry *s_root;
1505 struct rw_semaphore s_umount; 1249 struct rw_semaphore s_umount;
1506 struct mutex s_lock;
1507 int s_count; 1250 int s_count;
1508 atomic_t s_active; 1251 atomic_t s_active;
1509#ifdef CONFIG_SECURITY 1252#ifdef CONFIG_SECURITY
@@ -1881,6 +1624,60 @@ struct super_operations {
1881}; 1624};
1882 1625
1883/* 1626/*
1627 * Inode flags - they have no relation to superblock flags now
1628 */
1629#define S_SYNC 1 /* Writes are synced at once */
1630#define S_NOATIME 2 /* Do not update access times */
1631#define S_APPEND 4 /* Append-only file */
1632#define S_IMMUTABLE 8 /* Immutable file */
1633#define S_DEAD 16 /* removed, but still open directory */
1634#define S_NOQUOTA 32 /* Inode is not counted to quota */
1635#define S_DIRSYNC 64 /* Directory modifications are synchronous */
1636#define S_NOCMTIME 128 /* Do not update file c/mtime */
1637#define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
1638#define S_PRIVATE 512 /* Inode is fs-internal */
1639#define S_IMA 1024 /* Inode has an associated IMA struct */
1640#define S_AUTOMOUNT 2048 /* Automount/referral quasi-directory */
1641#define S_NOSEC 4096 /* no suid or xattr security attributes */
1642
1643/*
1644 * Note that nosuid etc flags are inode-specific: setting some file-system
1645 * flags just means all the inodes inherit those flags by default. It might be
1646 * possible to override it selectively if you really wanted to with some
1647 * ioctl() that is not currently implemented.
1648 *
1649 * Exception: MS_RDONLY is always applied to the entire file system.
1650 *
1651 * Unfortunately, it is possible to change a filesystems flags with it mounted
1652 * with files in use. This means that all of the inodes will not have their
1653 * i_flags updated. Hence, i_flags no longer inherit the superblock mount
1654 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
1655 */
1656#define __IS_FLG(inode, flg) ((inode)->i_sb->s_flags & (flg))
1657
1658#define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
1659#define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
1660 ((inode)->i_flags & S_SYNC))
1661#define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
1662 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
1663#define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
1664#define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
1665#define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
1666
1667#define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
1668#define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
1669#define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
1670#define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
1671
1672#define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
1673#define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
1674#define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
1675#define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
1676#define IS_IMA(inode) ((inode)->i_flags & S_IMA)
1677#define IS_AUTOMOUNT(inode) ((inode)->i_flags & S_AUTOMOUNT)
1678#define IS_NOSEC(inode) ((inode)->i_flags & S_NOSEC)
1679
1680/*
1884 * Inode state bits. Protected by inode->i_lock 1681 * Inode state bits. Protected by inode->i_lock
1885 * 1682 *
1886 * Three bits determine the dirty state of the inode, I_DIRTY_SYNC, 1683 * Three bits determine the dirty state of the inode, I_DIRTY_SYNC,
@@ -2012,6 +1809,11 @@ int sync_inode_metadata(struct inode *inode, int wait);
2012struct file_system_type { 1809struct file_system_type {
2013 const char *name; 1810 const char *name;
2014 int fs_flags; 1811 int fs_flags;
1812#define FS_REQUIRES_DEV 1
1813#define FS_BINARY_MOUNTDATA 2
1814#define FS_HAS_SUBTYPE 4
1815#define FS_REVAL_DOT 16384 /* Check the paths ".", ".." for staleness */
1816#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */
2015 struct dentry *(*mount) (struct file_system_type *, int, 1817 struct dentry *(*mount) (struct file_system_type *, int,
2016 const char *, void *); 1818 const char *, void *);
2017 void (*kill_sb) (struct super_block *); 1819 void (*kill_sb) (struct super_block *);
@@ -2072,7 +1874,7 @@ extern struct vfsmount *kern_mount_data(struct file_system_type *, void *data);
2072extern void kern_unmount(struct vfsmount *mnt); 1874extern void kern_unmount(struct vfsmount *mnt);
2073extern int may_umount_tree(struct vfsmount *); 1875extern int may_umount_tree(struct vfsmount *);
2074extern int may_umount(struct vfsmount *); 1876extern int may_umount(struct vfsmount *);
2075extern long do_mount(char *, char *, char *, unsigned long, void *); 1877extern long do_mount(const char *, const char *, const char *, unsigned long, void *);
2076extern struct vfsmount *collect_mounts(struct path *); 1878extern struct vfsmount *collect_mounts(struct path *);
2077extern void drop_collected_mounts(struct vfsmount *); 1879extern void drop_collected_mounts(struct vfsmount *);
2078extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *, 1880extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,
@@ -2189,6 +1991,13 @@ static inline int break_lease(struct inode *inode, unsigned int mode)
2189#endif /* CONFIG_FILE_LOCKING */ 1991#endif /* CONFIG_FILE_LOCKING */
2190 1992
2191/* fs/open.c */ 1993/* fs/open.c */
1994struct audit_names;
1995struct filename {
1996 const char *name; /* pointer to actual string */
1997 const __user char *uptr; /* original userland pointer */
1998 struct audit_names *aname;
1999 bool separate; /* should "name" be freed? */
2000};
2192 2001
2193extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs, 2002extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
2194 struct file *filp); 2003 struct file *filp);
@@ -2196,12 +2005,15 @@ extern int do_fallocate(struct file *file, int mode, loff_t offset,
2196 loff_t len); 2005 loff_t len);
2197extern long do_sys_open(int dfd, const char __user *filename, int flags, 2006extern long do_sys_open(int dfd, const char __user *filename, int flags,
2198 umode_t mode); 2007 umode_t mode);
2008extern struct file *file_open_name(struct filename *, int, umode_t);
2199extern struct file *filp_open(const char *, int, umode_t); 2009extern struct file *filp_open(const char *, int, umode_t);
2200extern struct file *file_open_root(struct dentry *, struct vfsmount *, 2010extern struct file *file_open_root(struct dentry *, struct vfsmount *,
2201 const char *, int); 2011 const char *, int);
2202extern struct file * dentry_open(const struct path *, int, const struct cred *); 2012extern struct file * dentry_open(const struct path *, int, const struct cred *);
2203extern int filp_close(struct file *, fl_owner_t id); 2013extern int filp_close(struct file *, fl_owner_t id);
2204extern char * getname(const char __user *); 2014
2015extern struct filename *getname(const char __user *);
2016
2205enum { 2017enum {
2206 FILE_CREATED = 1, 2018 FILE_CREATED = 1,
2207 FILE_OPENED = 2 2019 FILE_OPENED = 2
@@ -2221,13 +2033,14 @@ extern void __init vfs_caches_init(unsigned long);
2221 2033
2222extern struct kmem_cache *names_cachep; 2034extern struct kmem_cache *names_cachep;
2223 2035
2224#define __getname_gfp(gfp) kmem_cache_alloc(names_cachep, (gfp)) 2036extern void final_putname(struct filename *name);
2225#define __getname() __getname_gfp(GFP_KERNEL) 2037
2038#define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL)
2226#define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) 2039#define __putname(name) kmem_cache_free(names_cachep, (void *)(name))
2227#ifndef CONFIG_AUDITSYSCALL 2040#ifndef CONFIG_AUDITSYSCALL
2228#define putname(name) __putname(name) 2041#define putname(name) final_putname(name)
2229#else 2042#else
2230extern void putname(const char *name); 2043extern void putname(struct filename *name);
2231#endif 2044#endif
2232 2045
2233#ifdef CONFIG_BLOCK 2046#ifdef CONFIG_BLOCK
@@ -2548,6 +2361,8 @@ extern int sb_min_blocksize(struct super_block *, int);
2548 2361
2549extern int generic_file_mmap(struct file *, struct vm_area_struct *); 2362extern int generic_file_mmap(struct file *, struct vm_area_struct *);
2550extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); 2363extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
2364extern int generic_file_remap_pages(struct vm_area_struct *, unsigned long addr,
2365 unsigned long size, pgoff_t pgoff);
2551extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size); 2366extern int file_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size);
2552int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk); 2367int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk);
2553extern ssize_t generic_file_aio_read(struct kiocb *, const struct iovec *, unsigned long, loff_t); 2368extern ssize_t generic_file_aio_read(struct kiocb *, const struct iovec *, unsigned long, loff_t);
@@ -2564,6 +2379,8 @@ extern int generic_segment_checks(const struct iovec *iov,
2564 unsigned long *nr_segs, size_t *count, int access_flags); 2379 unsigned long *nr_segs, size_t *count, int access_flags);
2565 2380
2566/* fs/block_dev.c */ 2381/* fs/block_dev.c */
2382extern ssize_t blkdev_aio_read(struct kiocb *iocb, const struct iovec *iov,
2383 unsigned long nr_segs, loff_t pos);
2567extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov, 2384extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
2568 unsigned long nr_segs, loff_t pos); 2385 unsigned long nr_segs, loff_t pos);
2569extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end, 2386extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end,
@@ -2855,5 +2672,4 @@ static inline void inode_has_no_xattr(struct inode *inode)
2855 inode->i_flags |= S_NOSEC; 2672 inode->i_flags |= S_NOSEC;
2856} 2673}
2857 2674
2858#endif /* __KERNEL__ */
2859#endif /* _LINUX_FS_H */ 2675#endif /* _LINUX_FS_H */