The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/boot/bootcache.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #include <u.h>
    2 #include <libc.h>
    3 #include <../boot/boot.h>
    4 
    5 uchar statbuf[Statsz];
    6 
    7 int
    8 cache(int fd)
    9 {
   10         int argc, i, p[2];
   11         char *argv[5], bd[32], buf[256], partition[64], *pp;
   12 
   13         if(stat("/boot/cfs", statbuf, sizeof statbuf) < 0)
   14                 return fd;
   15 
   16         *partition = 0;
   17 
   18         bind("#S", "/dev", MAFTER);
   19         readfile("#e/cfs", buf, sizeof(buf));
   20         if(*buf){
   21                 argc = tokenize(buf, argv, 4);
   22                 for(i = 0; i < argc; i++){
   23                         if(strcmp(argv[i], "off") == 0)
   24                                 return fd;
   25                         else if(stat(argv[i], statbuf, sizeof statbuf) >= 0){
   26                                 strncpy(partition, argv[i], sizeof(partition)-1);
   27                                 partition[sizeof(partition)-1] = 0;
   28                         }
   29                 }
   30         }
   31 
   32         if(*partition == 0){
   33                 readfile("#e/bootdisk", bd, sizeof(bd));
   34                 if(*bd){
   35                         if(pp = strchr(bd, ':'))
   36                                 *pp = 0;
   37                         /* damned artificial intelligence */
   38                         i = strlen(bd);
   39                         if(strcmp("disk", &bd[i-4]) == 0)
   40                                 bd[i-4] = 0;
   41                         else if(strcmp("fs", &bd[i-2]) == 0)
   42                                 bd[i-2] = 0;
   43                         else if(strcmp("fossil", &bd[i-6]) == 0)
   44                                 bd[i-6] = 0;
   45                         sprint(partition, "%scache", bd);
   46                         if(stat(partition, statbuf, sizeof statbuf) < 0)
   47                                 *bd = 0;
   48                 }
   49                 if(*bd == 0){
   50                         sprint(partition, "%scache", bootdisk);
   51                         if(stat(partition, statbuf, sizeof statbuf) < 0)
   52                                 return fd;
   53                 }
   54         }
   55 
   56         print("cfs...");
   57         if(pipe(p)<0)
   58                 fatal("pipe");
   59         switch(fork()){
   60         case -1:
   61                 fatal("fork");
   62         case 0:
   63                 close(p[1]);
   64                 dup(fd, 0);
   65                 close(fd);
   66                 dup(p[0], 1);
   67                 close(p[0]);
   68                 if(fflag)
   69                         execl("/boot/cfs", "bootcfs", "-rs", "-f", partition, 0);
   70                 else
   71                         execl("/boot/cfs", "bootcfs", "-s", "-f", partition, 0);
   72                 break;
   73         default:
   74                 close(p[0]);
   75                 close(fd);
   76                 fd = p[1];
   77                 break;
   78         }
   79         return fd;
   80 }

Cache object: 144ca5d2adb0c4142307ee20d594ff9d


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.