xref: /minix3/minix/fs/procfs/const.h (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc #ifndef _PROCFS_CONST_H
2*433d6423SLionel Sambuc #define _PROCFS_CONST_H
3*433d6423SLionel Sambuc 
4*433d6423SLionel Sambuc /* The minimum number of inodes depends on a number of factors:
5*433d6423SLionel Sambuc  * - Each statically created inode (e.g., /proc/hz) needs an inode. As of
6*433d6423SLionel Sambuc  *   writing, this requires about a dozen inodes.
7*433d6423SLionel Sambuc  * - Deleted inodes that are still in use by VFS must be retained. For deleted
8*433d6423SLionel Sambuc  *   directories, all their containing directories up to the root must be
9*433d6423SLionel Sambuc  *   retained as well (to allow the user to "cd .." out). VTreeFS already takes
10*433d6423SLionel Sambuc  *   care of this. In the case of ProcFS, only PID-based directories can be
11*433d6423SLionel Sambuc  *   deleted; no other directories are dynamically created. These directories
12*433d6423SLionel Sambuc  *   currently do not contain subdirectories, either. Hence, for deleted open
13*433d6423SLionel Sambuc  *   inodes, we need to reserve at most NR_VNODES inodes in the worst case.
14*433d6423SLionel Sambuc  * - In order for getdents to be able to return all PID-based directories,
15*433d6423SLionel Sambuc  *   inodes must not be recycled while generating the list of these PID-based
16*433d6423SLionel Sambuc  *   directories. In the worst case, this means (NR_TASKS + NR_PROCS) extra
17*433d6423SLionel Sambuc  *   inodes.
18*433d6423SLionel Sambuc  * The sum of these is the bare minimum for correct operation in all possible
19*433d6423SLionel Sambuc  * circumstances. In practice, not all open files will be deleted files in
20*433d6423SLionel Sambuc  * ProcFS, and not all process slots will be in use either, so the average use
21*433d6423SLionel Sambuc  * will be a lot less. However, setting the value too low allows for a
22*433d6423SLionel Sambuc  * potential denial-of-service attack by a non-root user.
23*433d6423SLionel Sambuc  *
24*433d6423SLionel Sambuc  * For the moment, we simply set this value to something reasonable.
25*433d6423SLionel Sambuc  */
26*433d6423SLionel Sambuc #define NR_INODES	((NR_TASKS + NR_PROCS) * 4)
27*433d6423SLionel Sambuc 
28*433d6423SLionel Sambuc /* Various file modes. */
29*433d6423SLionel Sambuc #define REG_ALL_MODE	(S_IFREG | 0444)	/* world-readable regular */
30*433d6423SLionel Sambuc #define DIR_ALL_MODE	(S_IFDIR | 0555)	/* world-accessible directory */
31*433d6423SLionel Sambuc #define LNK_ALL_MODE	(S_IFLNK | 0777)	/* symbolic link */
32*433d6423SLionel Sambuc 
33*433d6423SLionel Sambuc #endif /* _PROCFS_CONST_H */
34