xref: /minix3/minix/fs/procfs/const.h (revision f1abbce7257a5fbf50b3422d6dd5631fd0bf26a5)
1433d6423SLionel Sambuc #ifndef _PROCFS_CONST_H
2433d6423SLionel Sambuc #define _PROCFS_CONST_H
3433d6423SLionel Sambuc 
4*f1abbce7SDavid van Moolenbroek /*
5*f1abbce7SDavid van Moolenbroek  * The minimum number of inodes depends on a number of factors:
6433d6423SLionel Sambuc  * - Each statically created inode (e.g., /proc/hz) needs an inode.  As of
7433d6423SLionel Sambuc  *   writing, this requires about a dozen inodes.
8433d6423SLionel Sambuc  * - Deleted inodes that are still in use by VFS must be retained.  For deleted
9433d6423SLionel Sambuc  *   directories, all their containing directories up to the root must be
10*f1abbce7SDavid van Moolenbroek  *   retained as well (to allow the user to "cd .." out).  VTreeFS already
11*f1abbce7SDavid van Moolenbroek  *   takes care of this.  In the case of ProcFS, only PID-based directories can
12*f1abbce7SDavid van Moolenbroek  *   be deleted; no other directories are dynamically created.  These
13*f1abbce7SDavid van Moolenbroek  *   directories currently do not contain subdirectories, either.  Hence, for
14*f1abbce7SDavid van Moolenbroek  *   deleted open inodes, we need to reserve at most NR_VNODES inodes in the
15*f1abbce7SDavid van Moolenbroek  *   worst case.
16433d6423SLionel Sambuc  * - In order for getdents to be able to return all PID-based directories,
17433d6423SLionel Sambuc  *   inodes must not be recycled while generating the list of these PID-based
18433d6423SLionel Sambuc  *   directories.  In the worst case, this means (NR_TASKS + NR_PROCS) extra
19433d6423SLionel Sambuc  *   inodes.
20433d6423SLionel Sambuc  * The sum of these is the bare minimum for correct operation in all possible
21433d6423SLionel Sambuc  * circumstances.  In practice, not all open files will be deleted files in
22433d6423SLionel Sambuc  * ProcFS, and not all process slots will be in use either, so the average use
23433d6423SLionel Sambuc  * will be a lot less.  However, setting the value too low allows for a
24433d6423SLionel Sambuc  * potential denial-of-service attack by a non-root user.
25433d6423SLionel Sambuc  *
26433d6423SLionel Sambuc  * For the moment, we simply set this value to something reasonable.
27433d6423SLionel Sambuc  */
28433d6423SLionel Sambuc #define NR_INODES	((NR_TASKS + NR_PROCS) * 4)
29433d6423SLionel Sambuc 
30433d6423SLionel Sambuc /* Various file modes. */
31433d6423SLionel Sambuc #define REG_ALL_MODE	(S_IFREG | 0444)	/* world-readable regular */
32433d6423SLionel Sambuc #define DIR_ALL_MODE	(S_IFDIR | 0555)	/* world-accessible directory */
33433d6423SLionel Sambuc #define LNK_ALL_MODE	(S_IFLNK | 0777)	/* symbolic link */
34433d6423SLionel Sambuc 
355eefd0feSDavid van Moolenbroek /* Size of the I/O buffer. */
365eefd0feSDavid van Moolenbroek #define BUF_SIZE	4097			/* 4KB+1 (see buf.c) */
375eefd0feSDavid van Moolenbroek 
38433d6423SLionel Sambuc #endif /* _PROCFS_CONST_H */
39