21 typedef struct Miscfile Miscfile
;
34 if(strcmp(path
, "/dev/null")==0){
36 } else if(strcmp(path
, "/dev/zero")==0){
38 } else if(strcmp(path
, "/dev/full")==0){
40 } else if(strcmp(path
, "/dev/random")==0){
42 } else if(strcmp(path
, "/dev/urandom")==0){
50 openmisc(char *path
, int mode
, int, Ufile
**pf
)
55 if((m
= path2m(path
)) < 0)
57 f
= kmallocz(sizeof(*f
), 1);
60 f
->path
= kstrdup(path
);
75 readmisc(Ufile
*f
, void *buf
, int len
, vlong
)
77 switch(((Miscfile
*)f
)->m
){
97 writemisc(Ufile
*f
, void *, int len
, vlong
)
99 switch(((Miscfile
*)f
)->m
){
113 statmisc(char *path
, int, Ustat
*s
)
118 s
->mode
= 0666 | S_IFCHR
;
119 s
->uid
= current
->uid
;
120 s
->gid
= current
->gid
;
122 s
->ino
= hashpath(path
);
125 s
->atime
= s
->mtime
= s
->ctime
= boottime
/1000000000LL;
130 fstatmisc(Ufile
*f
, Ustat
*s
)
132 return fsstat(f
->path
, 0, s
);
135 static Udev miscdev
=
145 void miscdevinit(void)
147 devtab
[MISCDEV
] = &miscdev
;
149 fsmount(&miscdev
, "/dev/null");
150 fsmount(&miscdev
, "/dev/zero");
151 fsmount(&miscdev
, "/dev/full");
152 fsmount(&miscdev
, "/dev/random");
153 fsmount(&miscdev
, "/dev/urandom");