10 * functions (possibly) linked in, complete, from libc.
14 UTFmax = 4, /* maximum bytes per rune */
15 Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
16 Runeself = 0x80, /* rune and UTF sequences are the same (<) */
17 Runeerror = 0xFFFD, /* decoding error in UTF */
18 Runemax = 0x10FFFF, /* 21-bit rune */
19 Runemask = 0x1FFFFF, /* bits used by runes (see grep) */
20 NUMSIZE32 = 9, /* max size of formatted 32 bit number */
21 NUMSIZE64 = 20, /* max size of formatted 64 bit number */
27 extern int isNaN(double);
28 extern int isInf(double, int);
29 extern double floor(double);
30 extern double frexp(double, int*);
31 extern double pow10(int);
36 extern char* cleanname( char *unused_char_p_t);
37 //extern uint32_t getcallerpc(void*);
38 static inline uint32_t getcallerpc(void*v)
46 extern int getfields( char *unused_char_p_t, char **unused_char_pp_t, int unused_int, int, char*);
47 extern int tokenize( char *unused_char_p_t, char **unused_char_pp_t, int);
48 extern int dec64( uint8_t *unused_uint8_p_t, int unused_int, char *unused_char_p_t, int);
49 extern void qsort(void*, long, long, int (*)(void*, void*));
51 extern int toupper(int);
52 extern char* netmkaddr( char *unused_char_p_t, char*, char*);
53 extern int myetheraddr( uint8_t *unused_uint8_p_t, char *unused_char_p_t);
54 extern int parseether( uint8_t *unused_uint8_p_t, char *unused_char_p_t);
62 * Syscall data structures
64 #define MORDER 0x0003 /* mask for bits defining order of mounting */
65 #define MREPL 0x0000 /* mount replaces object */
66 #define MBEFORE 0x0001 /* mount goes before others in union directory */
67 #define MAFTER 0x0002 /* mount goes after others in union directory */
68 #define MCREATE 0x0004 /* permit creation in mounted directory */
69 #define MCACHE 0x0010 /* cache some data */
70 #define MMASK 0x0017 /* all bits on */
72 #define NCONT 0 /* continue after note */
73 #define NDFLT 1 /* terminate after note */
74 #define NSAVE 2 /* clear note but hold state */
75 #define NRSTR 3 /* restore saved state */
77 #define STATMAX 65535U /* max length of machine-independent stat structure */
78 #define ERRMAX 128 /* max length of error string */
79 #define KNAMELEN 28 /* max length of name held in kernel */
81 /* bits in Qid.type */
82 #define QTDIR 0x80 /* type bit for directories */
83 #define QTAPPEND 0x40 /* type bit for append only files */
84 #define QTEXCL 0x20 /* type bit for exclusive use files */
85 #define QTMOUNT 0x10 /* type bit for mounted channel */
86 #define QTAUTH 0x08 /* type bit for authentication file */
87 #define QTFILE 0x00 /* plain file */
89 /* bits in Dir.mode */
90 #define DMDIR 0x80000000 /* mode bit for directories */
91 #define DMAPPEND 0x40000000 /* mode bit for append only files */
92 #define DMEXCL 0x20000000 /* mode bit for exclusive use files */
93 #define DMMOUNT 0x10000000 /* mode bit for mounted channel */
94 #define DMREAD 0x4 /* mode bit for read permission */
95 #define DMWRITE 0x2 /* mode bit for write permission */
96 #define DMEXEC 0x1 /* mode bit for execute permission */
106 /* system-modified data */
107 uint16_t type; /* server type */
108 unsigned int dev; /* server subtype */
110 struct qid qid; /* unique id from server */
111 uint32_t mode; /* permissions */
112 uint32_t atime; /* last read time */
113 uint32_t mtime; /* last write time */
114 int64_t length; /* file length: see <u.h> */
115 char *name; /* last element of path */
116 char *uid; /* owner name */
117 char *gid; /* group name */
118 char *muid; /* last modifier name */
123 int pid; /* of loved one */
124 uint32_t time[3]; /* of loved one and descendants */
125 char msg[ERRMAX]; /* actually variable-size in user mode */
128 #define VERSION9P "9P2000"
140 uint32_t msize; /* Tversion, Rversion */
141 char *version; /* Tversion, Rversion */
144 uint16_t oldtag; /* Tflush */
147 char *ename; /* Rerror */
150 struct qid qid; /* Rattach, Ropen, Rcreate */
151 uint32_t iounit; /* Ropen, Rcreate */
154 struct qid aqid; /* Rauth */
157 uint32_t afid; /* Tauth, Tattach */
158 char *uname; /* Tauth, Tattach */
159 char *aname; /* Tauth, Tattach */
162 uint32_t perm; /* Tcreate */
163 char *name; /* Tcreate */
164 uint8_t mode; /* Tcreate, Topen */
167 uint32_t newfid; /* Twalk */
168 uint16_t nwname; /* Twalk */
169 char *wname[MAXWELEM]; /* Twalk */
172 uint16_t nwqid; /* Rwalk */
173 struct qid wqid[MAXWELEM]; /* Rwalk */
176 int64_t offset; /* Tread, Twrite */
177 uint32_t count; /* Tread, Twrite, Rread */
178 char *data; /* Twrite, Rread */
181 uint16_t nstat; /* Twstat, Rstat */
182 uint8_t *stat; /* Twstat, Rstat */
188 #define GBIT8(p) ((p)[0])
189 #define GBIT16(p) ((p)[0]|((p)[1]<<8))
190 #define GBIT32(p) ((uint32_t)((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24)))
191 #define GBIT64(p) ((uint32_t)((p)[0]|((p)[1]<<8)|((p)[2]<<16)|((p)[3]<<24)) |\
192 ((int64_t)((p)[4]|((p)[5]<<8)|((p)[6]<<16)|((p)[7]<<24)) << 32))
194 #define PBIT8(p,v) (p)[0]=(v)
195 #define PBIT16(p,v) (p)[0]=(v);(p)[1]=(v)>>8
196 #define PBIT32(p,v) (p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>16;(p)[3]=(v)>>24
197 #define PBIT64(p,v) (p)[0]=(v);(p)[1]=(v)>>8;(p)[2]=(v)>>16;(p)[3]=(v)>>24;\
198 (p)[4]=(v)>>32;(p)[5]=(v)>>40;(p)[6]=(v)>>48;(p)[7]=(v)>>56
204 #define QIDSZ (BIT8SZ+BIT32SZ+BIT64SZ)
206 /* STATFIXLEN includes leading 16-bit count */
207 /* The count, however, excludes itself; total size is BIT16SZ+count */
208 #define STATFIXLEN (BIT16SZ+QIDSZ+5*BIT16SZ+4*BIT32SZ+1*BIT64SZ) /* amount of fixed length data in a stat buffer */
210 #define NOTAG (uint16_t)~0U /* Dummy tag */
211 #define NOFID (uint32_t)~0U /* Dummy fid */
212 #define IOHDRSZ 24 /* ample room for Twrite/Rread header (iounit) */
222 Terror = 106, /* illegal */
247 unsigned int convM2S( uint8_t *unused_uint8_p_t, unsigned int unused_int, struct fcall*);
248 unsigned int convS2M(struct fcall*, uint8_t *unused_uint8_p_t, unsigned int);
249 unsigned int sizeS2M(struct fcall*);
251 unsigned int convM2kdirent(uint8_t * buf, unsigned int nbuf, struct kdirent *kd, char *strs);
252 unsigned int convM2kstat(uint8_t * buf, unsigned int nbuf, struct kstat *ks);
255 int statcheck(uint8_t *abuf, unsigned int nbuf);
256 unsigned int convM2D( uint8_t *unused_uint8_p_t, unsigned int unused_int, struct dir*, char *unused_char_p_t);
257 unsigned int convD2M(struct dir*, uint8_t *unused_uint8_p_t, unsigned int);
258 unsigned int sizeD2M(struct dir*);
260 int read9pmsg( int unused_int, void*, unsigned int);
274 int (*active)(void*);
275 int (*ck)(void*, int);
276 void (*f)(void*); /* called with VM acquire()'d */
305 * Access types in namec & channel flags
309 Aaccess, /* as in stat, wstat */
310 Abind, /* for left-hand-side of bind */
311 Atodir, /* as in chdir */
313 Amount, /* to be mounted or mounted upon */
314 Acreate, /* is to be created */
315 Aremove, /* will be removed by caller */
317 COPEN = 0x0001, /* for i/o */
318 CMSG = 0x0002, /* the message channel for a mount */
319 CCEXEC = 0x0008, /* close on exec */
320 CFREE = 0x0010, /* not in use */
321 CRCLOSE = 0x0020, /* remove on close */
322 CCACHE = 0x0080, /* client cache */
329 Bipck = (1<<2), /* ip checksum */
330 Budpck = (1<<3), /* udp checksum */
331 Btcpck = (1<<4), /* tcp checksum */
332 Bpktck = (1<<5), /* packet checksum */
339 uint8_t* rp; /* first unconsumed byte */
340 uint8_t* wp; /* first empty byte */
341 uint8_t* lim; /* 1 past the end of the buffer */
342 uint8_t* base; /* start of the buffer */
343 void (*free)(struct block*);
345 uint16_t checksum; /* IP checksum of complete packet (minus media header) */
347 #define BLEN(s) ((s)->wp - (s)->rp)
348 #define BALLOC(s) ((s)->lim - (s)->base)
354 struct chan* next; /* allocation */
356 int64_t offset; /* in file */
359 uint16_t mode; /* read/write */
362 int fid; /* for devmnt */
363 uint32_t iounit; /* chunk size for i/o; 0==default */
364 struct mhead* umh; /* mount point that derived Chan; used in unionread */
365 struct chan* umc; /* channel in union; held for union read */
366 qlock_t umqlock; /* serialize unionreads */
367 int uri; /* union read index */
368 int dri; /* devdirread index */
370 struct mntcache *mcp; /* Mount cache pointer */
371 struct mnt *mux; /* Mnt for clients using me for messages */
374 char tag[4]; /* for iproute */
376 struct chan* mchan; /* channel to mounted server */
377 struct qid mqid; /* qid of root of mount point */
384 int alen; /* allocated length */
385 int len; /* strlen(s) */
396 void (*shutdown)(void);
397 struct chan* (*attach)( char *muxattach);
398 struct walkqid* (*walk)(struct chan*, struct chan*, char **name, int);
399 int (*stat)(struct chan*, uint8_t *, int);
400 struct chan* (*open)(struct chan*, int);
401 void (*create)(struct chan*, char *, int , uint32_t);
402 void (*close)(struct chan*);
403 long (*read)(struct chan*, void*, long, int64_t);
404 struct block* (*bread)(struct chan*, long, uint32_t);
405 long (*write)(struct chan*, void*, long, int64_t);
406 long (*bwrite)(struct chan*, struct block*, uint32_t);
407 void (*remove)(struct chan*);
408 int (*wstat)(struct chan*, uint8_t *unused_uint8_p_t, int);
409 void (*power)(int); /* power mgt: power(1) → on, power (0) → off */
410 // int (*config)( int unused_int, char *unused_char_p_t, DevConf*);
432 NSCACHE = (1<<NSLOG),
435 struct mntwalk /* state for /proc/#/ns */
450 struct chan* to; /* channel replacing channel */
459 struct chan* from; /* channel mounted upon */
460 struct mount* mount; /* what's mounted upon it */
461 struct mhead* hash; /* Hash chain */
467 /* references are counted using c->ref; channels on this mount point incref(c->mchan) == Mnt.c */
468 struct chan *c; /* Channel to file service */
469 struct proc *rip; /* Reader in progress */
470 struct mntrpc *queue; /* Queue of pending requests on this channel */
471 uint32_t id; /* Multiplexer id for channel check */
472 struct mnt *list; /* Free list */
473 int flags; /* cache */
474 int msize; /* data + IOHDRSZ */
475 char *version; /* 9P version */
476 struct queue *q; /* input queue */
482 RENDHASH = 1<<RENDLOG, /* Hash to lookup rendezvous tags */
484 MNTHASH = 1<<MNTLOG, /* Hash to walk mount table */
485 DELTAFD= 20, /* allocation quantum for process file descriptors */
486 MAXNFD = 4000, /* max per process file descriptors */
487 MAXKEY = 8, /* keys for signed modules */
489 #define MOUNTH(p,qid) ((p)->mnthash[(qid).path&((1<<MNTLOG)-1)])
493 struct chan* authchan;
500 struct kref ref; /* also used as a lock when mounting */
502 qlock_t debug; /* single access via devproc.c */
503 struct rwlock ns; /* Namespace n read/one write lock */
505 struct mhead* mnthash[MNTHASH];
518 int nfd; /* number of fd slots */
519 int maxfd; /* highest fd in use */
520 int minfd; /* lower bound on free fd */
537 struct evalue *entries;
538 uint32_t path; /* qid.path of next Evalue to be allocated */
539 uint32_t vers; /* of Egrp */
550 void (*pkfree)(void*);
560 struct signerkey *keys[MAXKEY];
564 * fasttick timer interrupts
568 Trelative, /* timer programmed in ns from now */
569 Tabsolute, /* timer programmed in ns since epoch */
570 Tperiodic, /* periodic timer, period in ns */
576 NUMSIZE = 12, /* size of formatted number */
578 READSTR = 1000, /* temporary buffer size for device reads */
581 extern struct dev* devtab[];
591 int index; /* used by client to switch on result */
592 char *cmd; /* command name */
593 int narg; /* expected #args; 0 ==> variadic */
596 /* queue state bits, Qmsg, Qcoalesce, and Qkick can be set in qopen */
600 Qstarve = (1<<0), /* consumer starved */
601 Qmsg = (1<<1), /* message stream */
602 Qclosed = (1<<2), /* queue has been closed/hungup */
603 Qflow = (1<<3), /* producer flow controlled */
604 Qcoalesce = (1<<4), /* coallesce packets on read */
605 Qkick = (1<<5), /* always call the kick routine after qwrite */
611 typedef int Devgen(struct chan*, char *unused_char_p_t, struct dirtab*, int unused_int, int,
614 /* inferno portfns.h. Not all these are needed. */
616 #define FPinit() fpinit() /* remove this if math lib is linked */
617 void FPrestore(void*);
619 struct cname* addelem(struct cname*, char *unused_char_p_t);
620 void addprog(struct proc*);
621 void addrootfile( char *unused_char_p_t, uint8_t *unused_uint8_p_t, uint32_t);
622 struct block* adjustblock(struct block*, int);
623 struct block* allocb(int);
626 void _assert( char *unused_char_p_t);
627 struct block* bl2mem( uint8_t *unused_uint8_p_t, struct block*, int);
628 int blocklen(struct block*);
629 char* channame(struct chan*);
630 void cclose(struct chan*);
631 void chandevinit(void);
632 void chandevreset(void);
633 void chandevshutdown(void);
634 struct dir* chandirstat(struct chan*);
635 void chanfree(struct chan*);
636 void chanrec(struct mnt*);
637 void checkalarms(void);
638 void checkb(struct block*, char *unused_char_p_t);
640 struct chan* cclone(struct chan*);
641 void cclose(struct chan*);
642 void closeegrp(struct egrp*);
643 void closefgrp(struct fgrp*);
644 void closemount(struct mount*);
645 void closepgrp(struct pgrp*);
646 void closesigs(struct skeyset*);
647 void cmderror(struct cmdbuf*, char *unused_char_p_t);
648 struct mhead *newmhead(struct chan *from);
649 int cmount(struct chan*, struct chan*, int unused_int, char *unused_char_p_t);
650 void cnameclose(struct cname*);
651 struct block* concatblock(struct block*);
653 void copen(struct chan*);
654 struct block* copyblock(struct block*, int);
655 int cread(struct chan*, uint8_t *unused_uint8_p_t, int unused_int, int64_t);
656 struct chan* cunique(struct chan*);
657 struct chan* createdir(struct chan*, struct mhead*);
658 void cunmount(struct chan*, struct chan*);
659 void cupdate(struct chan*, uint8_t *unused_uint8_p_t, int unused_int, int64_t);
660 void cursorenable(void);
661 void cursordisable(void);
664 void cwrite(struct chan*, uint8_t *unused_uint8_p_t, int unused_int, int64_t);
665 struct chan* devattach( int unused_int, char *unused_char_p_t);
666 struct block* devbread(struct chan*, long, uint32_t);
667 long devbwrite(struct chan*, struct block*, uint32_t);
668 struct chan* devclone(struct chan*);
669 void devcreate(struct chan*, char *unused_char_p_t, int unused_int, uint32_t);
670 void devdir(struct chan*, struct qid, char *unused_char_p_t, int64_t, char*, long,
672 long devdirread(struct chan*, char *unused_char_p_t, long,
673 struct dirtab*, int unused_int, Devgen*);
676 int devno( int unused_int, int);
678 struct dev* devbyname( char *unused_char_p_t);
679 struct chan* devopen(struct chan*, int unused_int,
680 struct dirtab*, int unused_int2, Devgen*);
681 void devpermcheck( char *unused_char_p_t, uint32_t, int);
682 void devremove(struct chan*);
684 void devshutdown(void);
685 int devstat(struct chan*, uint8_t *unused_uint8_p_t, int unused_int,
686 struct dirtab*, int unused_int2, Devgen*);
687 struct walkqid* devwalk(struct chan*,
688 struct chan*, char **unused_char_pp_t, int unused_int,
689 struct dirtab*, int unused_intw, Devgen*);
690 int devwstat(struct chan*, uint8_t *unused_uint8_p_t, int);
692 void disfault(void*, char *unused_char_p_t);
693 int domount(struct chan**, struct mhead**);
694 void drawactive(int);
696 void dumpstack(void);
697 struct fgrp* dupfgrp(struct fgrp*);
698 void egrpcpy(struct egrp*, struct egrp*);
699 int emptystr( char *unused_char_p_t);
700 int eqchan(struct chan*, struct chan*, int);
701 int eqqid(struct qid, struct qid);
703 void errstr( char *unused_char_p_t, int);
708 int export( int unused_int, char *unused_char_p_t, int);
709 uint64_t fastticks(uint64_t*);
710 uint64_t fastticks2ns(uint64_t);
711 void fdclose(struct fgrp*, int);
712 struct chan* fdtochan(struct fgrp*, int unused_int, int, int, int);
713 int findmount(struct chan**,
714 struct mhead**, int unused_int, int, struct qid);
716 void freeb(struct block*);
717 void freeblist(struct block*);
718 void freeskey(struct signerkey*);
719 void getcolor(uint32_t, uint32_t*, uint32_t*, uint32_t*);
720 uint32_t getmalloctag(void*);
721 uint32_t getrealloctag(void*);
722 void hnputl(void*, uint32_t);
723 void hnputs(void*, uint16_t);
724 struct block* iallocb(int);
725 void iallocsummary(void);
726 void ilock(spinlock_t*);
727 int iprint( char *unused_char_p_t, ...);
728 void isdir(struct chan*);
730 void iunlock(spinlock_t*);
731 void ixsummary(void);
733 int kbdcr2nl(struct queue*, int);
734 int kbdputc(struct queue*, int);
736 void kproc( char *unused_char_p_t, void(*)(void*), void*, int);
737 int fgrpclose(struct fgrp*, int);
738 void kprocchild(struct proc*, void (*)(void*), void*);
739 void (*kproftick)(uint32_t);
740 void ksetenv( char *unused_char_p_t, char*, int);
741 //void kstrncpy( char *unused_char_p_t, char*, int unused_int, sizeof(char*, char*));
742 void kstrdup( char **unused_char_pp_t, char *unused_char_p_t);
744 struct cmdtab* lookupcmd(struct cmdbuf*, struct cmdtab*, int);
745 struct block* mem2bl( uint8_t *unused_uint8_p_t, int);
746 int memusehigh(void);
747 void microdelay(int);
748 uint64_t mk64fract(uint64_t, uint64_t);
749 void mkqid(struct qid*, int64_t, uint32_t, int);
751 struct chan* mntauth(struct chan*, char *unused_char_p_t);
752 long mntversion(struct chan*, char *unused_char_p_t, int unused_int, int);
753 void mountfree(struct mount*);
754 void mousetrack( int unused_int, int, int, int);
755 uint64_t ms2fastticks(uint32_t);
756 void mul64fract(uint64_t*, uint64_t, uint64_t);
757 void muxclose(struct mnt*);
758 struct chan* namec( char *unused_char_p_t, int unused_int, int, uint32_t);
759 struct chan* newchan(void);
760 struct egrp* newegrp(void);
761 struct fgrp* newfgrp(void);
762 struct mount* newmount(struct mhead*, struct chan*, int unused_int, char *unused_char_p_t);
763 struct pgrp* newpgrp(void);
764 struct proc* newproc(void);
765 char* nextelem( char *unused_char_p_t, char*);
767 struct cname* newcname( char *unused_char_p_t);
768 void notkilled(void);
770 uint64_t ns2fastticks(uint64_t);
771 int okaddr(uint32_t, uint32_t, int);
772 int openmode(uint32_t);
773 struct block* packblock(struct block*);
774 struct block* padblock(struct block*, int);
776 struct cmdbuf* parsecmd( char *unused_char_p_t, int);
778 void pgrpcpy(struct pgrp*, struct pgrp*);
780 int progfdprint(struct chan*, int unused_int, int, char *unused_char_p_t, int i);
781 int pullblock(struct block**, int);
782 struct block* pullupblock(struct block*, int);
783 struct block* pullupqueue(struct queue*, int);
784 void putmhead(struct mhead*);
785 void putstrn( char *unused_char_p_t, int);
786 void qaddlist(struct queue*, struct block*);
787 struct block* qbread(struct queue*, int);
788 long qbwrite(struct queue*, struct block*);
789 struct queue* qbypass(void (*)(void*, struct block*), void*);
790 int qcanread(struct queue*);
791 void qclose(struct queue*);
792 int qconsume(struct queue*, void*, int);
793 struct block* qcopy(struct queue*, int unused_int, uint32_t);
794 int qdiscard(struct queue*, int);
795 void qflush(struct queue*);
796 void qfree(struct queue*);
797 int qfull(struct queue*);
798 struct block* qget(struct queue*);
799 void qhangup(struct queue*, char *unused_char_p_t);
800 int qisclosed(struct queue*);
801 int qiwrite(struct queue*, void*, int);
802 int qlen(struct queue*);
803 void qnoblock(struct queue*, int);
804 struct queue* qopen( int unused_int, int, void (*)(void*), void*);
805 int qpass(struct queue*, struct block*);
806 int qpassnolim(struct queue*, struct block*);
807 int qproduce(struct queue*, void*, int);
808 void qputback(struct queue*, struct block*);
809 long qread(struct queue*, void*, int);
810 struct block* qremove(struct queue*);
811 void qreopen(struct queue*);
812 void qsetlimit(struct queue*, int);
813 int qwindow(struct queue*);
814 int qwrite(struct queue*, void*, int);
815 void randominit(void);
816 uint32_t randomread(void*, uint32_t);
817 void* realloc(void*, uint32_t);
818 int readmem(unsigned long offset, char *buf, unsigned long n,
819 void *mem, size_t mem_len);
820 int readnum(unsigned long off, char *buf, unsigned long n, unsigned long val,
822 int readstr(unsigned long offset, char *buf, unsigned long n, char *str);
823 int readnum_int64_t(uint32_t, char *unused_char_p_t, uint32_t, int64_t, int);
824 void ready(struct proc*);
825 void renameproguser( char *unused_char_p_t, char*);
826 void renameuser( char *unused_char_p_t, char*);
827 void resrcwait( char *unused_char_p_t);
828 struct proc* runproc(void);
830 void (*serwrite)( char *unused_char_p_t, int);
831 int setcolor(uint32_t, uint32_t, uint32_t, uint32_t);
833 void setmalloctag(void*, uint32_t);
835 void setrealloctag(void*, uint32_t);
836 char* skipslash( char *unused_char_p_t);
837 void* smalloc(uint32_t);
842 void swiproc(struct proc*, int);
843 uint32_t _tas(uint32_t*);
844 uint32_t tk2ms(uint32_t);
845 #define TK2MS(x) ((x)*(1000/HZ))
846 uint64_t tod2fastticks(int64_t);
847 int64_t todget(int64_t*);
849 void todsetfreq(int64_t);
851 void todset(int64_t, int64_t, int);
853 struct block* trimblock(struct block*, int unused_int, int);
856 void uartputs( char *unused_char_p_t, int);
857 long unionread(struct chan*, void*, long);
858 void unlock(spinlock_t*);
860 uint32_t userpc(void);
861 void validname( char *unused_char_p_t, int);
862 void validstat( uint8_t *unused_uint8_p_t, int);
863 void validwstatname( char *unused_char_p_t);
864 int walk(struct chan**, char **unused_char_pp_t, int unused_int, int, int*);
865 void werrstr( char *unused_char_p_t, ...);
866 void* xalloc(uint32_t);
867 void* xallocz(uint32_t, int);
869 void xhole(uint32_t, uint32_t);
871 int xmerge(void*, void*);
872 void* xspanalloc(uint32_t, int unused_int, uint32_t);
875 void validaddr(void*, uint32_t, int);
876 void* vmemchr(void*, int unused_int, int);
877 void hnputv(void*, int64_t);
878 void hnputl(void*, uint32_t);
879 void hnputs(void*, uint16_t);
880 int64_t nhgetv(void*);
881 uint32_t nhgetl(void*);
882 uint16_t nhgets(void*);
884 /* error messages, from inferno emu error.h */
885 extern char Enoerror[]; /* no error */
886 extern char Emount[]; /* inconsistent mount */
887 extern char Eunmount[]; /* not mounted */
888 extern char Eunion[]; /* not in union */
889 extern char Emountrpc[]; /* mount rpc error */
890 extern char Eshutdown[]; /* mounted device shut down */
891 extern char Eowner[]; /* not owner */
892 extern char Eunknown[]; /* unknown user or group id */
893 extern char Enocreate[]; /* mounted directory forbids creation */
894 extern char Enonexist[]; /* file does not exist */
895 extern char Eexist[]; /* file already exists */
896 extern char Ebadsharp[]; /* unknown device in # filename */
897 extern char Enotdir[]; /* not a directory */
898 extern char Eisdir[]; /* file is a directory */
899 extern char Ebadchar[]; /* bad character in file name */
900 extern char Efilename[]; /* file name syntax */
901 extern char Eperm[]; /* permission denied */
902 extern char Ebadusefd[]; /* inappropriate use of fd */
903 extern char Ebadarg[]; /* bad arg in system call */
904 extern char Einuse[]; /* device or object already in use */
905 extern char Eio[]; /* i/o error */
906 extern char Etoobig[]; /* read or write too large */
907 extern char Etoosmall[]; /* read or write too small */
908 extern char Enetaddr[]; /* bad network address */
909 extern char Emsgsize[]; /* message is too big for protocol */
910 extern char Enetbusy[]; /* network device is busy or allocated */
911 extern char Enoproto[]; /* network protocol not supported */
912 extern char Enoport[]; /* network port not available */
913 extern char Enoifc[]; /* bad interface or no free interface slots */
914 extern char Enolisten[]; /* not announced */
915 extern char Ehungup[]; /* i/o on hungup channel */
916 extern char Ebadctl[]; /* bad process or channel control request */
917 extern char Enodev[]; /* no free devices */
918 extern char Enoenv[]; /* no free environment resources */
919 extern char Ethread[]; /* thread exited */
920 extern char Enochild[]; /* no living children */
921 extern char Eioload[]; /* i/o error in demand load */
922 extern char Enovmem[]; /* out of memory: virtual memory */
923 extern char Ebadld[]; /* illegal line discipline */
924 extern char Ebadfd[]; /* fd out of range or not open */
925 extern char Eisstream[]; /* seek on a stream */
926 extern char Ebadexec[]; /* exec header invalid */
927 extern char Etimedout[]; /* connection timed out */
928 extern char Econrefused[]; /* connection refused */
929 extern char Econinuse[]; /* connection in use */
930 extern char Enetunreach[]; /* network unreachable */
931 extern char Eintr[]; /* interrupted */
932 extern char Enomem[]; /* out of memory: kernel */
933 extern char Esfnotcached[]; /* subfont not cached */
934 extern char Esoverlap[]; /* segments overlap */
935 extern char Emouseset[]; /* mouse type already set */
936 extern char Eshort[]; /* i/o count too small */
937 extern char Enobitstore[]; /* out of screen memory */
938 extern char Egreg[]; /* jim'll fix it */
939 extern char Ebadspec[]; /* bad attach specifier */
940 extern char Estopped[]; /* thread must be stopped */
941 extern char Enoattach[]; /* mount/attach disallowed */
942 extern char Eshortstat[]; /* stat buffer too small */
943 extern char Enegoff[]; /* negative i/o offset */
944 extern char Ebadstat[]; /* malformed stat buffer */
945 extern char Ecmdargs[]; /* wrong #args in control message */
946 extern char Enofd[]; /* no free file descriptors */
947 extern char Enoctl[]; /* unknown control request */
951 int errpush(struct errbuf *errstack, int stacksize, int *curindex,
952 struct errbuf **prev_errbuf);
953 void errpop(struct errbuf *errstack, int stacksize, int *curindex,
954 struct errbuf *prev_errbuf);
956 char *get_cur_genbuf(void);
959 #define NOW tsc2msec(read_tsc())
960 #define seconds() tsc2sec(read_tsc())
961 #define milliseconds() tsc2msec(read_tsc())
963 /* kern/src/ns/parse.c */
964 struct cmdbuf *parsecmd(char *p, int n);
965 void cmderror(struct cmdbuf *cb, char *s);
966 struct cmdtab *lookupcmd(struct cmdbuf *cb, struct cmdtab *ctab, int nctab);
968 /* kern/src/ns/sysfile.c */
969 int newfd(struct chan *c);
970 struct chan *fdtochan(struct fgrp *f, int fd, int mode, int chkmnt, int iref);
971 long kchanio(void *vc, void *buf, int n, int mode);
972 int openmode(uint32_t o);
973 void fdclose(struct fgrp *f, int fd);
974 int syschdir(char *path);
975 int grpclose(struct fgrp *f, int fd);
976 int sysclose(int fd);
977 int syscreate(char *path, int mode, uint32_t perm);
978 int sysdup(int old, int new);
979 int sysfstat(int fd, uint8_t *buf, int n);
980 char *sysfd2path(int fd);
981 int sysfauth(int fd, char *aname);
982 int sysfversion(int fd, unsigned int msize, char *vers, unsigned int arglen);
983 int syspipe(int fd[2]);
984 int sysfwstat(int fd, uint8_t *buf, int n);
985 long bindmount(struct chan *c, char *old, int flag, char *spec);
986 int sysbind(char *new, char *old, int flags);
987 int sysmount(int fd, int afd, char *old, int flags, char *spec);
988 int sysunmount(char *old, char *new);
989 int sysopen(char *path, int mode);
990 long unionread(struct chan *c, void *va, long n);
991 long sysread(int fd, void *va, long n);
992 long syspread(int fd, void *va, long n, int64_t off);
993 int sysremove(char *path);
994 int64_t sysseek(int fd, int64_t off, int whence);
995 void validstat(uint8_t *s, int n);
996 int sysstat(char *path, uint8_t *buf, int n);
997 long syswrite(int fd, void *va, long n);
998 long syspwrite(int fd, void *va, long n, int64_t off);
999 int syswstat(char *path, uint8_t *buf, int n);
1000 struct dir *chandirstat(struct chan *c);
1001 struct dir *sysdirstat(char *name);
1002 struct dir *sysdirfstat(int fd);
1003 int sysdirwstat(char *name, struct dir *dir);
1004 int sysdirfwstat(int fd, struct dir *dir);
1005 long sysdirread(int fd, struct kdirent **d);
1006 int sysiounit(int fd);
1007 void close_9ns_files(struct proc *p, bool only_cloexec);
1008 void print_chaninfo(struct chan *ch);
1009 void print_9ns_files(struct proc *p);
1010 int plan9setup(struct proc *new_proc, struct proc *parent);
1013 static inline int abs(int a)
1022 /* special sections */
1023 #define __devtab __attribute__((__section__(".devtab")))
1024 #define __devlink __attribute__((__section__(".devlink")))
1025 #define __etherlink __attribute__((__section__(".etherlink")))
1026 #define __media __attribute__((__section__(".media")))
1028 #endif /* ROS_KERN_NS_H */