|
|
1.1 ! root 1: #include <libc.h> ! 2: #include "worm.h" ! 3: ! 4: main(argc, argv) ! 5: char **argv; ! 6: { ! 7: Superblock s; ! 8: char *e, *vol_id = 0, *vol; ! 9: char *dev = "/dev/worm0"; ! 10: int c; ! 11: long nf = 0; ! 12: char wflag[512]; ! 13: char buf[512]; ! 14: int i; ! 15: extern char *optarg; ! 16: extern int optind; ! 17: extern long atol(); ! 18: ! 19: wflag[0] = 0; ! 20: while((c = getopt(argc, argv, "w:")) != -1) ! 21: switch(c) ! 22: { ! 23: case 'w': sprint(wflag, "-w%s", optarg); break; ! 24: case '?': usage(); ! 25: } ! 26: if(optind < argc){ ! 27: vol_id = argv[optind++]; ! 28: if(optind != argc) ! 29: usage(); ! 30: } ! 31: if(vol_id == 0){ ! 32: for(i = 0; ; i++){ ! 33: sprint(buf, "%d", i); ! 34: dev = mapdev(buf); ! 35: if((s.fd = open(dev, 0)) < 0){ ! 36: if(errno == ENOENT) ! 37: break; ! 38: if(errno == ENXIO) ! 39: continue; ! 40: perror(dev); ! 41: exit(2); ! 42: } ! 43: if(e = openinode(&s, SPIN_DOWN)){ ! 44: fprint(2, "%s: %s\n", dev, e); ! 45: exit(2); ! 46: } ! 47: print("%s: %s\n", dev, s.vol_id); ! 48: close(s.fd); ! 49: } ! 50: exit(0); ! 51: } ! 52: if(isjukebox()){ ! 53: jload(vol_id, wflag); ! 54: exit(0); ! 55: } ! 56: { ! 57: for(i = 0; ; i++){ ! 58: sprint(buf, "%d", i); ! 59: dev = mapdev(buf); ! 60: if((s.fd = open(dev, 0)) < 0){ ! 61: if(errno == ENOENT) ! 62: break; ! 63: if(errno == ENXIO) ! 64: continue; ! 65: perror(dev); ! 66: exit(2); ! 67: } ! 68: if(e = openinode(&s, SPIN_DOWN)){ ! 69: fprint(2, "%s: %s\n", dev, e); ! 70: exit(2); ! 71: } ! 72: if(strcmp(vol_id, s.vol_id) == 0){ ! 73: print("%s\n", buf); ! 74: exit(0); ! 75: } ! 76: close(s.fd); ! 77: } ! 78: } ! 79: fprint(2, "worm mount: couldn't find %s\n", vol_id); ! 80: exit(1); ! 81: } ! 82: ! 83: usage() ! 84: { ! 85: print("Usage: worm mount [-wsecs] [vol_id]\n"); ! 86: exit(2); ! 87: } ! 88: ! 89: /* ! 90: return zero if there isn't a jukebox ! 91: */ ! 92: isjukebox() ! 93: { ! 94: return(access("/dev/scsi", 6) == 0); ! 95: } ! 96: ! 97: /* ! 98: secs is the number of seconds to wait ! 99: */ ! 100: jload(vol, secs) ! 101: char *vol, *secs; ! 102: { ! 103: if(*secs) ! 104: execlp("/usr/lib/worm/jukebox", "jukebox", secs, "-Rm", vol, (char *)0); ! 105: else ! 106: execlp("/usr/lib/worm/jukebox", "jukebox", "-Rm", vol, (char *)0); ! 107: perror("execlp(/usr/lib/worm/jukebox)"); ! 108: exit(1); ! 109: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.