9os

Experimental kernel using plan9 ideas for embedded device
git clone git://git.simple-cc.org/9os
Log | Files | Refs | README | LICENSE

dirtop9.c (747B)


      1 #include <os9/os9.h>
      2 
      3 #include <libk.h>
      4 #include <serialize.h>
      5 
      6 int
      7 dirtop9(Dir *dp, unsigned char *buf, int n)
      8 {
      9 	int len;
     10 	unsigned char *p;
     11 
     12 	if (n < DIRLEN)
     13 		return 0;
     14 
     15 	p = buf + 2;
     16 	SHORT(dp->type, p);    /* type */
     17 	LONG(dp->dev, p);      /* dev */
     18 	CHAR(dp->qid.type, p); /* qid.type */
     19 	LONG(dp->qid.vers, p); /* qid.vers */
     20 	LLONG(dp->qid.path, p);/* qid.path */
     21 	LONG(0, p);            /* mode */
     22 	LONG(0, p);            /* atime */
     23 	LONG(0, p);            /* mtime */
     24 	LLONG(dp->length, p);  /* length */
     25 	STRING("root", p);     /* uid */
     26 	STRING("root", p);     /* gid */
     27 	STRING("root", p);     /* muid */
     28 	STRING(dp->name, p);   /* name */
     29 	len = p - buf;
     30 	SHORT(len, buf);       /* size */
     31 
     32 	assert(len < DIRLEN);
     33 
     34 	return len;
     35 }