16 /* Special akaros edition. */
17 /* akaros does not (yet) pass as much info as plan 9 does,
18 * and it still has stuff I'm not happy about like an inode number.
22 __ino64_t d_ino; /* inod
24 __off64_t d_off; /* offs
25 et to the next dirent */
26 unsigned short d_reclen; /* length of th
29 char d_name[MAX_FILENAME_SZ + 1]; /* filename */
30 } __attribute__ ((aligned(8)));
34 unsigned int convM2kdirent(uint8_t * buf, unsigned int nbuf, struct kdirent *kd,
41 printd("%s >>>>>>>>>nbuf %d STATFIXLEN %d\n", __func__, nbuf, STATFIXLEN);
42 if (nbuf < STATFIXLEN)
48 p += BIT16SZ; /* ignore size */
49 kd->d_type = GBIT16(p);
57 kd->d_ino = GBIT64(p);
59 junk /* mode */ = GBIT32(p);
61 junk /*d->atime */ = GBIT32(p);
63 junk /*d->mtime */ = GBIT32(p);
65 junk /*d->length */ = GBIT64(p);
68 /* for now, uids in akaros are ints. Does not
69 * matter; kdirents are limited in what they tell you.
70 * get the name, ignore the rest. Maybe we can
73 for (i = 0; i < 4; i++) {
74 if (p + BIT16SZ > ebuf)
88 printd("memmove %p %p %d\n", kd->d_name, p, ns);
89 memmove(kd->d_name, p, ns);
95 printd("%s returns %d %s\n", __func__, p - buf, kd->d_name);
99 static int mode_9ns_to_posix(int mode_9ns)
103 if (mode_9ns & DMDIR)
104 mode_posix |= __S_IFDIR;
105 else if (mode_9ns & DMSYMLINK)
106 mode_posix |= __S_IFLNK;
108 mode_posix |= __S_IFREG;
109 if (mode_9ns & DMREADABLE)
110 mode_posix |= __S_READABLE;
111 if (mode_9ns & DMWRITABLE)
112 mode_posix |= __S_WRITABLE;
113 mode_posix |= mode_9ns & 0777;
117 unsigned int convM2kstat(uint8_t * buf, unsigned int nbuf, struct kstat *ks)
124 if (nbuf < STATFIXLEN)
130 p += BIT16SZ; /* ignore size */
131 junk /*kd->d_type */ = GBIT16(p);
133 ks->st_rdev = ks->st_dev = GBIT32(p);
135 junk /*qid.type */ = GBIT8(p);
137 junk /*qid.vers */ = GBIT32(p);
139 ks->st_ino = GBIT64(p);
141 ks->st_mode = mode_9ns_to_posix(GBIT32(p));
143 ks->st_atim.tv_sec = GBIT32(p);
145 ks->st_mtim.tv_sec = GBIT32(p);
147 ks->st_size = GBIT64(p);
149 ks->st_blksize = 512;
150 ks->st_blocks = ROUNDUP(ks->st_size, ks->st_blksize) / ks->st_blksize;
152 ks->st_nlink = 2; // links make no sense any more.
153 ks->st_uid = ks->st_gid = 0;