RT-AC56 3.0.0.4.374.37 core
[tomato.git] / release / src-rt-6.x.4708 / toolchains / hndtools-arm-linux-2.6.36-uclibc-4.5.3 / arm-brcm-linux-uclibcgnueabi / sysroot / usr / include / linux / fs.h
blob87af22b8a8de85d97bec9dc2da50232f41183b0c
1 #ifndef _LINUX_FS_H
2 #define _LINUX_FS_H
4 /*
5 * This file has definitions for some important file table
6 * structures etc.
7 */
9 #include <linux/limits.h>
10 #include <linux/ioctl.h>
11 #include <linux/blk_types.h>
14 * It's silly to have NR_OPEN bigger than NR_FILE, but you can change
15 * the file limit at runtime and only root can increase the per-process
16 * nr_file rlimit, so it's safe to set up a ridiculously high absolute
17 * upper limit on files-per-process.
19 * Some programs (notably those using select()) may have to be
20 * recompiled to take full advantage of the new limits..
23 /* Fixed constants first: */
24 #undef NR_OPEN
25 #define INR_OPEN 1024 /* Initial setting for nfile rlimits */
27 #define BLOCK_SIZE_BITS 10
28 #define BLOCK_SIZE (1<<BLOCK_SIZE_BITS)
30 #define SEEK_SET 0 /* seek relative to beginning of file */
31 #define SEEK_CUR 1 /* seek relative to current file position */
32 #define SEEK_END 2 /* seek relative to end of file */
33 #define SEEK_MAX SEEK_END
35 /* And dynamically-tunable limits and defaults: */
36 struct files_stat_struct {
37 int nr_files; /* read only */
38 int nr_free_files; /* read only */
39 int max_files; /* tunable */
42 struct inodes_stat_t {
43 int nr_inodes;
44 int nr_unused;
45 int dummy[5]; /* padding for sysctl ABI compatibility */
49 #define NR_FILE 8192 /* this can well be larger on a larger system */
51 #define MAY_EXEC 1
52 #define MAY_WRITE 2
53 #define MAY_READ 4
54 #define MAY_APPEND 8
55 #define MAY_ACCESS 16
56 #define MAY_OPEN 32
57 #define MAY_CHDIR 64
60 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond
61 * to O_WRONLY and O_RDWR via the strange trick in __dentry_open()
64 /* file is open for reading */
65 #define FMODE_READ ((fmode_t)0x1)
66 /* file is open for writing */
67 #define FMODE_WRITE ((fmode_t)0x2)
68 /* file is seekable */
69 #define FMODE_LSEEK ((fmode_t)0x4)
70 /* file can be accessed using pread */
71 #define FMODE_PREAD ((fmode_t)0x8)
72 /* file can be accessed using pwrite */
73 #define FMODE_PWRITE ((fmode_t)0x10)
74 /* File is opened for execution with sys_execve / sys_uselib */
75 #define FMODE_EXEC ((fmode_t)0x20)
76 /* File is opened with O_NDELAY (only set for block devices) */
77 #define FMODE_NDELAY ((fmode_t)0x40)
78 /* File is opened with O_EXCL (only set for block devices) */
79 #define FMODE_EXCL ((fmode_t)0x80)
80 /* File is opened using open(.., 3, ..) and is writeable only for ioctls
81 (specialy hack for floppy.c) */
82 #define FMODE_WRITE_IOCTL ((fmode_t)0x100)
85 * Don't update ctime and mtime.
87 * Currently a special hack for the XFS open_by_handle ioctl, but we'll
88 * hopefully graduate it to a proper O_CMTIME flag supported by open(2) soon.
90 #define FMODE_NOCMTIME ((fmode_t)0x800)
92 /* Expect random access pattern */
93 #define FMODE_RANDOM ((fmode_t)0x1000)
95 /* File was opened by fanotify and shouldn't generate fanotify events */
96 #define FMODE_NONOTIFY ((fmode_t)0x1000000)
99 * The below are the various read and write types that we support. Some of
100 * them include behavioral modifiers that send information down to the
101 * block layer and IO scheduler. Terminology:
103 * The block layer uses device plugging to defer IO a little bit, in
104 * the hope that we will see more IO very shortly. This increases
105 * coalescing of adjacent IO and thus reduces the number of IOs we
106 * have to send to the device. It also allows for better queuing,
107 * if the IO isn't mergeable. If the caller is going to be waiting
108 * for the IO, then he must ensure that the device is unplugged so
109 * that the IO is dispatched to the driver.
111 * All IO is handled async in Linux. This is fine for background
112 * writes, but for reads or writes that someone waits for completion
113 * on, we want to notify the block layer and IO scheduler so that they
114 * know about it. That allows them to make better scheduling
115 * decisions. So when the below references 'sync' and 'async', it
116 * is referencing this priority hint.
118 * With that in mind, the available types are:
120 * READ A normal read operation. Device will be plugged.
121 * READ_SYNC A synchronous read. Device is not plugged, caller can
122 * immediately wait on this read without caring about
123 * unplugging.
124 * READA Used for read-ahead operations. Lower priority, and the
125 * block layer could (in theory) choose to ignore this
126 * request if it runs into resource problems.
127 * WRITE A normal async write. Device will be plugged.
128 * WRITE_SYNC_PLUG Synchronous write. Identical to WRITE, but passes down
129 * the hint that someone will be waiting on this IO
130 * shortly. The device must still be unplugged explicitly,
131 * WRITE_SYNC_PLUG does not do this as we could be
132 * submitting more writes before we actually wait on any
133 * of them.
134 * WRITE_SYNC Like WRITE_SYNC_PLUG, but also unplugs the device
135 * immediately after submission. The write equivalent
136 * of READ_SYNC.
137 * WRITE_ODIRECT_PLUG Special case write for O_DIRECT only.
138 * WRITE_BARRIER Like WRITE_SYNC, but tells the block layer that all
139 * previously submitted writes must be safely on storage
140 * before this one is started. Also guarantees that when
141 * this write is complete, it itself is also safely on
142 * storage. Prevents reordering of writes on both sides
143 * of this IO.
146 #define RW_MASK REQ_WRITE
147 #define RWA_MASK REQ_RAHEAD
149 #define READ 0
150 #define WRITE RW_MASK
151 #define READA RWA_MASK
153 #define READ_SYNC (READ | REQ_SYNC | REQ_UNPLUG)
154 #define READ_META (READ | REQ_META)
155 #define WRITE_SYNC_PLUG (WRITE | REQ_SYNC | REQ_NOIDLE)
156 #define WRITE_SYNC (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_UNPLUG)
157 #define WRITE_ODIRECT_PLUG (WRITE | REQ_SYNC)
158 #define WRITE_META (WRITE | REQ_META)
159 #define WRITE_BARRIER (WRITE | REQ_SYNC | REQ_NOIDLE | REQ_UNPLUG | \
160 REQ_HARDBARRIER)
163 * These aren't really reads or writes, they pass down information about
164 * parts of device that are now unused by the file system.
166 #define DISCARD_NOBARRIER (WRITE | REQ_DISCARD)
167 #define DISCARD_BARRIER (WRITE | REQ_DISCARD | REQ_HARDBARRIER)
168 #define DISCARD_SECURE (DISCARD_NOBARRIER | REQ_SECURE)
170 #define SEL_IN 1
171 #define SEL_OUT 2
172 #define SEL_EX 4
174 /* public flags for file_system_type */
175 #define FS_REQUIRES_DEV 1
176 #define FS_BINARY_MOUNTDATA 2
177 #define FS_HAS_SUBTYPE 4
178 #define FS_REVAL_DOT 16384 /* Check the paths ".", ".." for staleness */
179 #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move()
180 * during rename() internally.
184 * These are the fs-independent mount-flags: up to 32 flags are supported
186 #define MS_RDONLY 1 /* Mount read-only */
187 #define MS_NOSUID 2 /* Ignore suid and sgid bits */
188 #define MS_NODEV 4 /* Disallow access to device special files */
189 #define MS_NOEXEC 8 /* Disallow program execution */
190 #define MS_SYNCHRONOUS 16 /* Writes are synced at once */
191 #define MS_REMOUNT 32 /* Alter flags of a mounted FS */
192 #define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
193 #define MS_DIRSYNC 128 /* Directory modifications are synchronous */
194 #define MS_NOATIME 1024 /* Do not update access times. */
195 #define MS_NODIRATIME 2048 /* Do not update directory access times */
196 #define MS_BIND 4096
197 #define MS_MOVE 8192
198 #define MS_REC 16384
199 #define MS_VERBOSE 32768 /* War is peace. Verbosity is silence.
200 MS_VERBOSE is deprecated. */
201 #define MS_SILENT 32768
202 #define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
203 #define MS_UNBINDABLE (1<<17) /* change to unbindable */
204 #define MS_PRIVATE (1<<18) /* change to private */
205 #define MS_SLAVE (1<<19) /* change to slave */
206 #define MS_SHARED (1<<20) /* change to shared */
207 #define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
208 #define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
209 #define MS_I_VERSION (1<<23) /* Update inode I_version field */
210 #define MS_STRICTATIME (1<<24) /* Always perform atime updates */
211 #define MS_BORN (1<<29)
212 #define MS_ACTIVE (1<<30)
213 #define MS_NOUSER (1<<31)
216 * Superblock flags that can be altered by MS_REMOUNT
218 #define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_I_VERSION)
221 * Old magic mount flag and mask
223 #define MS_MGC_VAL 0xC0ED0000
224 #define MS_MGC_MSK 0xffff0000
226 /* Inode flags - they have nothing to superblock flags now */
228 #define S_SYNC 1 /* Writes are synced at once */
229 #define S_NOATIME 2 /* Do not update access times */
230 #define S_APPEND 4 /* Append-only file */
231 #define S_IMMUTABLE 8 /* Immutable file */
232 #define S_DEAD 16 /* removed, but still open directory */
233 #define S_NOQUOTA 32 /* Inode is not counted to quota */
234 #define S_DIRSYNC 64 /* Directory modifications are synchronous */
235 #define S_NOCMTIME 128 /* Do not update file c/mtime */
236 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
237 #define S_PRIVATE 512 /* Inode is fs-internal */
240 * Note that nosuid etc flags are inode-specific: setting some file-system
241 * flags just means all the inodes inherit those flags by default. It might be
242 * possible to override it selectively if you really wanted to with some
243 * ioctl() that is not currently implemented.
245 * Exception: MS_RDONLY is always applied to the entire file system.
247 * Unfortunately, it is possible to change a filesystems flags with it mounted
248 * with files in use. This means that all of the inodes will not have their
249 * i_flags updated. Hence, i_flags no longer inherit the superblock mount
250 * flags, so these have to be checked separately. -- rmk@arm.uk.linux.org
252 #define __IS_FLG(inode,flg) ((inode)->i_sb->s_flags & (flg))
254 #define IS_RDONLY(inode) ((inode)->i_sb->s_flags & MS_RDONLY)
255 #define IS_SYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS) || \
256 ((inode)->i_flags & S_SYNC))
257 #define IS_DIRSYNC(inode) (__IS_FLG(inode, MS_SYNCHRONOUS|MS_DIRSYNC) || \
258 ((inode)->i_flags & (S_SYNC|S_DIRSYNC)))
259 #define IS_MANDLOCK(inode) __IS_FLG(inode, MS_MANDLOCK)
260 #define IS_NOATIME(inode) __IS_FLG(inode, MS_RDONLY|MS_NOATIME)
261 #define IS_I_VERSION(inode) __IS_FLG(inode, MS_I_VERSION)
263 #define IS_NOQUOTA(inode) ((inode)->i_flags & S_NOQUOTA)
264 #define IS_APPEND(inode) ((inode)->i_flags & S_APPEND)
265 #define IS_IMMUTABLE(inode) ((inode)->i_flags & S_IMMUTABLE)
266 #define IS_POSIXACL(inode) __IS_FLG(inode, MS_POSIXACL)
268 #define IS_DEADDIR(inode) ((inode)->i_flags & S_DEAD)
269 #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
270 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
271 #define IS_PRIVATE(inode) ((inode)->i_flags & S_PRIVATE)
273 /* the read-only stuff doesn't really belong here, but any other place is
274 probably as bad and I don't want to create yet another include file. */
276 #define BLKROSET _IO(0x12,93) /* set device read-only (0 = read-write) */
277 #define BLKROGET _IO(0x12,94) /* get read-only status (0 = read_write) */
278 #define BLKRRPART _IO(0x12,95) /* re-read partition table */
279 #define BLKGETSIZE _IO(0x12,96) /* return device size /512 (long *arg) */
280 #define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
281 #define BLKRASET _IO(0x12,98) /* set read ahead for block device */
282 #define BLKRAGET _IO(0x12,99) /* get current read ahead setting */
283 #define BLKFRASET _IO(0x12,100)/* set filesystem (mm/filemap.c) read-ahead */
284 #define BLKFRAGET _IO(0x12,101)/* get filesystem (mm/filemap.c) read-ahead */
285 #define BLKSECTSET _IO(0x12,102)/* set max sectors per request (ll_rw_blk.c) */
286 #define BLKSECTGET _IO(0x12,103)/* get max sectors per request (ll_rw_blk.c) */
287 #define BLKSSZGET _IO(0x12,104)/* get block device sector size */
288 #if 0
289 #define BLKPG _IO(0x12,105)/* See blkpg.h */
291 /* Some people are morons. Do not use sizeof! */
293 #define BLKELVGET _IOR(0x12,106,size_t)/* elevator get */
294 #define BLKELVSET _IOW(0x12,107,size_t)/* elevator set */
295 /* This was here just to show that the number is taken -
296 probably all these _IO(0x12,*) ioctls should be moved to blkpg.h. */
297 #endif
298 /* A jump here: 108-111 have been used for various private purposes. */
299 #define BLKBSZGET _IOR(0x12,112,size_t)
300 #define BLKBSZSET _IOW(0x12,113,size_t)
301 #define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size in bytes (u64 *arg) */
302 #define BLKTRACESETUP _IOWR(0x12,115,struct blk_user_trace_setup)
303 #define BLKTRACESTART _IO(0x12,116)
304 #define BLKTRACESTOP _IO(0x12,117)
305 #define BLKTRACETEARDOWN _IO(0x12,118)
306 #define BLKDISCARD _IO(0x12,119)
307 #define BLKIOMIN _IO(0x12,120)
308 #define BLKIOOPT _IO(0x12,121)
309 #define BLKALIGNOFF _IO(0x12,122)
310 #define BLKPBSZGET _IO(0x12,123)
311 #define BLKDISCARDZEROES _IO(0x12,124)
312 #define BLKSECDISCARD _IO(0x12,125)
314 #define BMAP_IOCTL 1 /* obsolete - kept for compatibility */
315 #define FIBMAP _IO(0x00,1) /* bmap access */
316 #define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
317 #define FIFREEZE _IOWR('X', 119, int) /* Freeze */
318 #define FITHAW _IOWR('X', 120, int) /* Thaw */
320 #define FS_IOC_GETFLAGS _IOR('f', 1, long)
321 #define FS_IOC_SETFLAGS _IOW('f', 2, long)
322 #define FS_IOC_GETVERSION _IOR('v', 1, long)
323 #define FS_IOC_SETVERSION _IOW('v', 2, long)
324 #define FS_IOC_FIEMAP _IOWR('f', 11, struct fiemap)
325 #define FS_IOC32_GETFLAGS _IOR('f', 1, int)
326 #define FS_IOC32_SETFLAGS _IOW('f', 2, int)
327 #define FS_IOC32_GETVERSION _IOR('v', 1, int)
328 #define FS_IOC32_SETVERSION _IOW('v', 2, int)
331 * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS)
333 #define FS_SECRM_FL 0x00000001 /* Secure deletion */
334 #define FS_UNRM_FL 0x00000002 /* Undelete */
335 #define FS_COMPR_FL 0x00000004 /* Compress file */
336 #define FS_SYNC_FL 0x00000008 /* Synchronous updates */
337 #define FS_IMMUTABLE_FL 0x00000010 /* Immutable file */
338 #define FS_APPEND_FL 0x00000020 /* writes to file may only append */
339 #define FS_NODUMP_FL 0x00000040 /* do not dump file */
340 #define FS_NOATIME_FL 0x00000080 /* do not update atime */
341 /* Reserved for compression usage... */
342 #define FS_DIRTY_FL 0x00000100
343 #define FS_COMPRBLK_FL 0x00000200 /* One or more compressed clusters */
344 #define FS_NOCOMP_FL 0x00000400 /* Don't compress */
345 #define FS_ECOMPR_FL 0x00000800 /* Compression error */
346 /* End compression flags --- maybe not all used */
347 #define FS_BTREE_FL 0x00001000 /* btree format dir */
348 #define FS_INDEX_FL 0x00001000 /* hash-indexed directory */
349 #define FS_IMAGIC_FL 0x00002000 /* AFS directory */
350 #define FS_JOURNAL_DATA_FL 0x00004000 /* Reserved for ext3 */
351 #define FS_NOTAIL_FL 0x00008000 /* file tail should not be merged */
352 #define FS_DIRSYNC_FL 0x00010000 /* dirsync behaviour (directories only) */
353 #define FS_TOPDIR_FL 0x00020000 /* Top of directory hierarchies*/
354 #define FS_EXTENT_FL 0x00080000 /* Extents */
355 #define FS_DIRECTIO_FL 0x00100000 /* Use direct i/o */
356 #define FS_RESERVED_FL 0x80000000 /* reserved for ext2 lib */
358 #define FS_FL_USER_VISIBLE 0x0003DFFF /* User visible flags */
359 #define FS_FL_USER_MODIFIABLE 0x000380FF /* User modifiable flags */
362 #define SYNC_FILE_RANGE_WAIT_BEFORE 1
363 #define SYNC_FILE_RANGE_WRITE 2
364 #define SYNC_FILE_RANGE_WAIT_AFTER 4
366 #endif /* _LINUX_FS_H */