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.h442
1 files changed, 55 insertions, 387 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 65fbf571023f..001c7cff2d48 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1,121 +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
14/*
15 * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
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
45/* And dynamically-tunable limits and defaults: */
46struct files_stat_struct {
47 unsigned long nr_files; /* read only */
48 unsigned long nr_free_files; /* read only */
49 unsigned long max_files; /* tunable */
50};
51
52struct inodes_stat_t {
53 int nr_inodes;
54 int nr_unused;
55 int dummy[5]; /* padding for sysctl ABI compatibility */
56};
57
58
59#define NR_FILE 8192 /* this can well be larger on a larger system */
60
61#define MAY_EXEC 0x00000001
62#define MAY_WRITE 0x00000002
63#define MAY_READ 0x00000004
64#define MAY_APPEND 0x00000008
65#define MAY_ACCESS 0x00000010
66#define MAY_OPEN 0x00000020
67#define MAY_CHDIR 0x00000040
68/* called from RCU mode, don't block */
69#define MAY_NOT_BLOCK 0x00000080
70
71/*
72 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond
73 * to O_WRONLY and O_RDWR via the strange trick in __dentry_open()
74 */
75
76/* file is open for reading */
77#define FMODE_READ ((__force fmode_t)0x1)
78/* file is open for writing */
79#define FMODE_WRITE ((__force fmode_t)0x2)
80/* file is seekable */
81#define FMODE_LSEEK ((__force fmode_t)0x4)
82/* file can be accessed using pread */
83#define FMODE_PREAD ((__force fmode_t)0x8)
84/* file can be accessed using pwrite */
85#define FMODE_PWRITE ((__force fmode_t)0x10)
86/* File is opened for execution with sys_execve / sys_uselib */
87#define FMODE_EXEC ((__force fmode_t)0x20)
88/* File is opened with O_NDELAY (only set for block devices) */
89#define FMODE_NDELAY ((__force fmode_t)0x40)
90/* File is opened with O_EXCL (only set for block devices) */
91#define FMODE_EXCL ((__force fmode_t)0x80)
92/* File is opened using open(.., 3, ..) and is writeable only for ioctls
93 (specialy hack for floppy.c) */
94#define FMODE_WRITE_IOCTL ((__force fmode_t)0x100)
95/* 32bit hashes as llseek() offset (for directories) */
96#define FMODE_32BITHASH ((__force fmode_t)0x200)
97/* 64bit hashes as llseek() offset (for directories) */
98#define FMODE_64BITHASH ((__force fmode_t)0x400)
99 30
100/* 31#include <asm/byteorder.h>
101 * Don't update ctime and mtime. 32#include <uapi/linux/fs.h>
102 *
103 * Currently a special hack for the XFS open_by_handle ioctl, but we'll
104 * hopefully graduate it to a proper O_CMTIME flag supported by open(2) soon.
105 */
106#define FMODE_NOCMTIME ((__force fmode_t)0x800)
107 33
108/* Expect random access pattern */ 34struct export_operations;
109#define FMODE_RANDOM ((__force fmode_t)0x1000) 35struct hd_geometry;
36struct iovec;
37struct nameidata;
38struct kiocb;
39struct kobject;
40struct pipe_inode_info;
41struct poll_table_struct;
42struct kstatfs;
43struct vm_area_struct;
44struct vfsmount;
45struct cred;
46struct swap_info_struct;
110 47
111/* File is huge (eg. /dev/kmem): treat loff_t as unsigned */ 48extern void __init inode_init(void);
112#define FMODE_UNSIGNED_OFFSET ((__force fmode_t)0x2000) 49extern void __init inode_init_early(void);
50extern void __init files_init(unsigned long);
113 51
114/* File is opened with O_PATH; almost nothing can be done with it */ 52extern struct files_stat_struct files_stat;
115#define FMODE_PATH ((__force fmode_t)0x4000) 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;
116 59
117/* File was opened by fanotify and shouldn't generate fanotify events */ 60struct buffer_head;
118#define FMODE_NONOTIFY ((__force fmode_t)0x1000000) 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);
119 66
120/* 67/*
121 * The below are the various read and write types that we support. Some of 68 * The below are the various read and write types that we support. Some of
@@ -175,284 +122,6 @@ struct inodes_stat_t {
175#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA) 122#define WRITE_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FUA)
176#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA) 123#define WRITE_FLUSH_FUA (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_FLUSH | REQ_FUA)
177 124
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#define BLKZEROOUT _IO(0x12,127)
339
340#define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
341#define FIBMAP _IO(0x00,1) /* bmap access */
342#define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
343#define FIFREEZE _IOWR('X', 119, int) /* Freeze */
344#define FITHAW _IOWR('X', 120, int) /* Thaw */
345#define FITRIM _IOWR('X', 121, struct fstrim_range) /* Trim */
346
347#define FS_IOC_GETFLAGS _IOR('f', 1, long)
348#define FS_IOC_SETFLAGS _IOW('f', 2, long)
349#define FS_IOC_GETVERSION _IOR('v', 1, long)
350#define FS_IOC_SETVERSION _IOW('v', 2, long)
351#define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
352#define FS_IOC32_GETFLAGS _IOR('f', 1, int)
353#define FS_IOC32_SETFLAGS _IOW('f', 2, int)
354#define FS_IOC32_GETVERSION _IOR('v', 1, int)
355#define FS_IOC32_SETVERSION _IOW('v', 2, int)
356
357/*
358 * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
359 */
360#define FS_SECRM_FL 0x00000001 /* Secure deletion */
361#define FS_UNRM_FL 0x00000002 /* Undelete */
362#define FS_COMPR_FL 0x00000004 /* Compress file */
363#define FS_SYNC_FL 0x00000008 /* Synchronous updates */
364#define FS_IMMUTABLE_FL 0x00000010 /* Immutable file */
365#define FS_APPEND_FL 0x00000020 /* writes to file may only append */
366#define FS_NODUMP_FL 0x00000040 /* do not dump file */
367#define FS_NOATIME_FL 0x00000080 /* do not update atime */
368/* Reserved for compression usage... */
369#define FS_DIRTY_FL 0x00000100
370#define FS_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
371#define FS_NOCOMP_FL 0x00000400 /* Don't compress */
372#define FS_ECOMPR_FL 0x00000800 /* Compression error */
373/* End compression flags --- maybe not all used */
374#define FS_BTREE_FL 0x00001000 /* btree format dir */
375#define FS_INDEX_FL 0x00001000 /* hash-indexed directory */
376#define FS_IMAGIC_FL 0x00002000 /* AFS directory */
377#define FS_JOURNAL_DATA_FL 0x00004000 /* Reserved for ext3 */
378#define FS_NOTAIL_FL 0x00008000 /* file tail should not be merged */
379#define FS_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
380#define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
381#define FS_EXTENT_FL 0x00080000 /* Extents */
382#define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
383#define FS_NOCOW_FL 0x00800000 /* Do not cow file */
384#define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
385
386#define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
387#define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
388
389
390#define SYNC_FILE_RANGE_WAIT_BEFORE 1
391#define SYNC_FILE_RANGE_WRITE 2
392#define SYNC_FILE_RANGE_WAIT_AFTER 4
393
394#ifdef __KERNEL__
395
396#include <linux/linkage.h>
397#include <linux/wait.h>
398#include <linux/kdev_t.h>
399#include <linux/dcache.h>
400#include <linux/path.h>
401#include <linux/stat.h>
402#include <linux/cache.h>
403#include <linux/list.h>
404#include <linux/radix-tree.h>
405#include <linux/rbtree.h>
406#include <linux/init.h>
407#include <linux/pid.h>
408#include <linux/bug.h>
409#include <linux/mutex.h>
410#include <linux/capability.h>
411#include <linux/semaphore.h>
412#include <linux/fiemap.h>
413#include <linux/rculist_bl.h>
414#include <linux/atomic.h>
415#include <linux/shrinker.h>
416#include <linux/migrate_mode.h>
417#include <linux/uidgid.h>
418#include <linux/lockdep.h>
419#include <linux/percpu-rwsem.h>
420
421#include <asm/byteorder.h>
422
423struct export_operations;
424struct hd_geometry;
425struct iovec;
426struct nameidata;
427struct kiocb;
428struct kobject;
429struct pipe_inode_info;
430struct poll_table_struct;
431struct kstatfs;
432struct vm_area_struct;
433struct vfsmount;
434struct cred;
435struct swap_info_struct;
436
437extern void __init inode_init(void);
438extern void __init inode_init_early(void);
439extern void __init files_init(unsigned long);
440
441extern struct files_stat_struct files_stat;
442extern unsigned long get_max_files(void);
443extern int sysctl_nr_open;
444extern struct inodes_stat_t inodes_stat;
445extern int leases_enable, lease_break_time;
446extern int sysctl_protected_symlinks;
447extern int sysctl_protected_hardlinks;
448
449struct buffer_head;
450typedef int (get_block_t)(struct inode *inode, sector_t iblock,
451 struct buffer_head *bh_result, int create);
452typedef void (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
453 ssize_t bytes, void *private, int ret,
454 bool is_async);
455
456/* 125/*
457 * Attribute flags. These should be or-ed together to figure out what 126 * Attribute flags. These should be or-ed together to figure out what
458 * has been changed! 127 * has been changed!
@@ -2877,5 +2546,4 @@ static inline void inode_has_no_xattr(struct inode *inode)
2877 inode->i_flags |= S_NOSEC; 2546 inode->i_flags |= S_NOSEC;
2878} 2547}
2879 2548
2880#endif /* __KERNEL__ */
2881#endif /* _LINUX_FS_H */ 2549#endif /* _LINUX_FS_H */