| plan 9 kernel history: overview | file list | diff list |
1996/0123/port/devtinyfs.c (diff list | history)
| 1996/0122/sys/src/9/port/devtinyfs.c:13,20 – 1996/0123/sys/src/9/port/devtinyfs.c:13,23 (short | long | prev | next) | ||
| 1996/0116 | enum{ Qdir, | |
| 1996/0123 | Nfile= 32, | |
| 1996/0120 | Qmedium, | |
| 1996/0123 | Magic= 0xfeedbeef, Superlen= 64, | |
| 1996/0116 | }; | |
| 1996/0122 | typedef struct FS FS; | |
| 1996/0122/sys/src/9/port/devtinyfs.c:25,33 – 1996/0123/sys/src/9/port/devtinyfs.c:28,36 | ||
| 1996/0122 | int dev; FS *next; | |
| 1996/0116 | Chan *c; | |
| 1996/0122 |
| |
| 1996/0116 |
| |
| 1996/0122 |
| |
| 1996/0123 | uchar *fat; ulong nclust; ulong clustsize; | |
| 1996/0122 | }; struct { | |
| 1996/0122/sys/src/9/port/devtinyfs.c:39,52 – 1996/0123/sys/src/9/port/devtinyfs.c:42,47 | ||
| 1996/0116 | void tinyfsreset(void) { | |
| 1996/0120 |
| |
| 1996/0116 |
| |
| 1996/0120 |
| |
| 1996/0116 | } void | |
| 1996/0122/sys/src/9/port/devtinyfs.c:54,59 – 1996/0123/sys/src/9/port/devtinyfs.c:49,123 | ||
| 1996/0116 | { } | |
| 1996/0123 | #define GETS(x) ((x)[0]|((x)[1]<<8)) #define PUTS(x, v) {(x)[0] = (v);(x)[1] = ((v)>>8);} #define GETL(x) (GETS(x)|(GETS(x+2)<<16)) #define PUTL(x, v) {PUTS(x, v);PUTS(x+2, (v)>>16)}; /* * see if we have a reasonable fat/root directory */ static int fsinit(FS *fs) { uchar buf[DIRLEN]; Dir d; ulong x; n = devtab[fs->c->type].read(fs->c, buf, Superlen, 0); if(n != Superlen) error(Eio); x = GETL(buf); if(x != Magic) return -1; fs->clustsize = GETL(buf+4); fs->nclust = GETL(buf+8); x = fs->clustsize*fs->nclust; devtab[fs->c->type].stat(fs->c, buf); convM2D(buf, &d); if(d.length < 128) error("tinyfs medium too small"); if(d.length < x) return -1; fs->fat = smalloc(2*fs->nclust); n = devtab[fs->c->type].read(fs->c, buf, 2*fs->nclust, Superlen); fd(n != 2*fs->nclust) error(Eio); x = GETS(fs->fat); if(x == 0) return -1; return 0; } /* * set up the fat and then a root directory (starting at first cluster (1)) */ static void fssetup(FS *fs) { uchar buf[DIRLEN]; Dir d; devtab[fs->c->type].stat(fs->c, buf); convM2D(buf, &d); fs->clustsize = d.length>>16; if(fs->clustsize < 64) fs->clustsize = 64; fs->nclust = (d.length - 12)/fs->clustsize; fs->fat = smalloc(2*fs->nclust); n = devtab[fs->c->type].write(fs->c, buf, 2*fs->nclust, Superlen); if(n < 2*fs->nclust) error(Eio); n = devtab[fs->c->type].write(fs->c, buf, Superlen, 0); if(n < Superlen) error(Eio); } | |
| 1996/0116 | Chan * tinyfsattach(char *spec) { | |
| 1996/0122/sys/src/9/port/devtinyfs.c:61,66 – 1996/0123/sys/src/9/port/devtinyfs.c:125,135 | ||
| 1996/0122 | Chan *c, *cc; | |
| 1996/0120 | ||
| 1996/0122 | cc = namec((char*)arg[0], Aopen, arg[1], 0); | |
| 1996/0123 | if(waserror()){ close(cc); unlock(&fs); nexterror(); } | |
| 1996/0122 | qlock(&tinyfs); l = &tinyfs.l; for(fs = tinyfs.l; fs != 0; fs = fs->next){ | |
| 1996/0122/sys/src/9/port/devtinyfs.c:74,84 – 1996/0123/sys/src/9/port/devtinyfs.c:143,161 | ||
| 1996/0122 | close(cc); } else { fs = smalloc(sizeof(*fs)); | |
| 1996/0123 | if(waserror()){ free(fs); nexterror(); } if(fsinit(fs) < 0) fssetup(fs); poperror(); *l = fs; | |
| 1996/0122 | qunlock(&tinyfs); } | |
| 1996/0123 | poperror(); | |
| 1996/0122 | c = devattach('E', spec); c->aux = fs; | |
| 1996/0122/sys/src/9/port/devtinyfs.c:123,143 – 1996/0123/sys/src/9/port/devtinyfs.c:200,205 | ||
| 1996/0116 | qunlock(&tinyfs); nexterror(); } | |
| 1996/0120 | ||
| 1996/0116 |
| |