Annotation of lucent/sys/src/9/boot/cache.c, revision 1.1.1.1

1.1       root        1: #include <u.h>
                      2: #include <libc.h>
                      3: #include <../boot/boot.h>
                      4: 
                      5: int
                      6: cache(int fd)
                      7: {
                      8:        int i, p[2];
                      9:        char d[DIRLEN];
                     10:        char partition[2*NAMELEN];
                     11:        char bd[NAMELEN];
                     12: 
                     13:        if(stat("/cfs", d) < 0)
                     14:                return fd;
                     15: 
                     16:        readfile("#e/bootdisk", bd, sizeof(bd));
                     17:        if(*bd){
                     18:                /* damned artificial intelligence */
                     19:                i = strlen(bd);
                     20:                if(strcmp("disk", &bd[i-4]) == 0)
                     21:                        bd[i-4] = 0;
                     22:                else if(strcmp("fs", &bd[i-2]) == 0)
                     23:                        bd[i-2] = 0;
                     24:                sprint(partition, "%scache", bd);
                     25:                if(stat(partition, d) < 0)
                     26:                        *bd = 0;
                     27:        }
                     28:        if(*bd == 0){
                     29:                sprint(partition, "%scache", bootdisk);
                     30:                if(stat(partition, d) < 0)
                     31:                        return fd;
                     32:        }
                     33:        print("cfs...");
                     34:        if(pipe(p)<0)
                     35:                fatal("pipe");
                     36:        switch(fork()){
                     37:        case -1:
                     38:                fatal("fork");
                     39:        case 0:
                     40:                close(p[1]);
                     41:                dup(fd, 0);
                     42:                close(fd);
                     43:                dup(p[0], 1);
                     44:                close(p[0]);
                     45:                if(fflag)
                     46:                        execl("/cfs", "bootcfs", "-rs", "-f", partition, 0);
                     47:                else
                     48:                        execl("/cfs", "bootcfs", "-s", "-f", partition, 0);
                     49:                break;
                     50:        default:
                     51:                close(p[0]);
                     52:                close(fd);
                     53:                fd = p[1];
                     54:                break;
                     55:        }
                     56:        return fd;
                     57: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.