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