| plan 9 kernel history: overview | file list | diff list |
2000/0405/boot/bootcache.c (diff list | history)
| 2000/0405/sys/src/9/boot/bootcache.c:1,75 – 2001/0527/sys/src/9/boot/bootcache.c:1,77 (short | long | prev | next) | ||
| 2000/0405 | #include <u.h> #include <libc.h> #include <../boot/boot.h> | |
| 2001/0527 | uchar statbuf[STATMAX]; | |
| 2000/0405 | int cache(int fd) { int argc, i, p[2]; | |
| 2001/0527 | char *argv[5], bd[32], buf[256], partition[64], *pp; | |
| 2000/0405 |
| |
| 2001/0527 | if(stat("/cfs", statbuf, sizeof statbuf) < 0) | |
| 2000/0405 | return fd; *partition = 0; readfile("#e/cfs", buf, sizeof(buf)); if(*buf){ argc = getfields(buf, argv, 4, 1, " "); for(i = 0; i < argc; i++){ if(strcmp(argv[i], "off") == 0) return fd; | |
| 2001/0527 | else if(stat(argv[i], statbuf, sizeof statbuf) >= 0){ | |
| 2000/0405 | strncpy(partition, argv[i], sizeof(partition)-1); partition[sizeof(partition)-1] = 0; } } } if(*partition == 0){ readfile("#e/bootdisk", bd, sizeof(bd)); if(*bd){ if(pp = strchr(bd, ':')) *pp = 0; /* damned artificial intelligence */ i = strlen(bd); if(strcmp("disk", &bd[i-4]) == 0) bd[i-4] = 0; else if(strcmp("fs", &bd[i-2]) == 0) bd[i-2] = 0; sprint(partition, "%scache", bd); | |
| 2001/0527 | if(stat(partition, statbuf, sizeof statbuf) < 0) | |
| 2000/0405 | *bd = 0; } if(*bd == 0){ sprint(partition, "%scache", bootdisk); | |
| 2001/0527 | if(stat(partition, statbuf, sizeof statbuf) < 0) | |
| 2000/0405 | return fd; } } print("cfs..."); if(pipe(p)<0) fatal("pipe"); switch(fork()){ case -1: fatal("fork"); case 0: close(p[1]); dup(fd, 0); close(fd); dup(p[0], 1); close(p[0]); if(fflag) execl("/cfs", "bootcfs", "-rs", "-f", partition, 0); else execl("/cfs", "bootcfs", "-s", "-f", partition, 0); break; default: close(p[0]); close(fd); fd = p[1]; break; } return fd; } | |