rust-kernel
Rustbelt: a hobby x86_64 kernel written in Rust
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | //! /proc (stage 18): a window into the running process, made up on the fly.
//!
//! Linux's /proc has a directory for every process and lots of files. We
//! have just the corner that programs (and C libraries) lean on most:
//!
//! /proc/self/exe a symlink to the program that's running
//! /proc/self/cwd a symlink to the current directory (stage 19)
//! /proc/self/fd/ one symlink per open file descriptor:
//! /proc/self/fd/N to the file's path ("/tmp/notes.txt"), or a
//! name like "pipe:[4123]" or "socket:[1007]" for
//! things that have no path, or "/dev/pts/0"
//!
//! Nothing here is stored anywhere. Every lookup and every listing asks
//! the process that is *asking* (`current()`) for its fd table, so two
//! programs listing /proc/self/fd at once each see their own files. That
//! is the whole trick of "self".
//!
//! Following one of the fd links (open, stat) is special-cased in
//! syscall.rs, as on Linux: opening /proc/self/fd/N opens the file that's
//! behind fd N again (a pipe or terminal: the same open file, like dup),
//! even when the link's text isn't a real path ("pipe:[...]").
//!
//! Differences from Linux: /proc/self is a directory, not a symlink to
//! /proc/<pid>, and there are no /proc/<pid> directories yet.
use File;
use ;
use crateErrno;
use ;
/// f_type of a mounted /proc (PROC_SUPER_MAGIC in <linux/magic.h>).
pub const PROC_MAGIC: u64 = 0x9fa0;
;
/// The handful of things in our /proc.
/// The open files of the process asking, by fd number.
/// What /proc/self/fd/N says for this open file (readlink's answer).
/// Is `path` (absolute, normalized) /proc/self/fd/N? Then N.
|