DataMuseum.dk

Presents historical artifacts from the history of:

Commodore CBM-900

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Commodore CBM-900

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦059beb1d6⟧

    Length: 2022 (0x7e6)
    Notes: UNIX file
    Names: »umount.c«

Derivation

└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
    └─⟦f4b8d8c84⟧ UNIX V7 Filesystem
        └─ ⟦this⟧ »cmd/umount.c« 

Hex Dump

0x000…020 2f 2a 0a 20 2a 20 55 6e 6d 6f 75 6e 74 20 61 20 66 69 6c 65 73 79 73 74 65 6d 0a 20 2a 2f 0a 0a   ┆/*  * Unmount a filesystem  */  ┆
0x020…040 63 68 61 72 20 68 65 6c 70 6d 65 73 73 61 67 65 5b 5d 20 3d 20 22 5c 0a 5c 0a 75 6d 6f 75 6e 74   ┆char helpmessage[] = "\ \ umount┆
0x040…060 20 2d 2d 20 75 6e 6d 6f 75 6e 74 20 66 69 6c 65 20 73 79 73 74 65 6d 5c 6e 5c 0a 55 73 61 67 65   ┆ -- unmount file system\n\ Usage┆
0x060…080 3a 09 2f 65 74 63 2f 75 6d 6f 75 6e 74 20 73 70 65 63 69 61 6c 5c 6e 5c 0a 54 68 65 20 62 6c 6f   ┆: /etc/umount special\n\ The blo┆
0x080…0a0 63 6b 20 73 70 65 63 69 61 6c 20 66 69 6c 65 20 27 73 70 65 63 69 61 6c 27 20 70 72 65 76 69 6f   ┆ck special file 'special' previo┆
0x0a0…0c0 75 73 6c 79 20 6d 6f 75 6e 74 65 64 20 62 79 20 27 2f 65 74 63 2f 6d 6f 75 6e 74 27 5c 6e 5c 0a   ┆usly mounted by '/etc/mount'\n\ ┆
0x0c0…0e0 6f 6e 20 27 64 69 72 65 63 74 6f 72 79 27 20 69 73 20 75 6e 6d 6f 75 6e 74 65 64 20 61 6e 64 20   ┆on 'directory' is unmounted and ┆
0x0e0…100 74 68 65 20 70 72 65 76 69 6f 75 73 20 63 6f 6e 74 65 6e 74 73 20 6f 66 20 27 64 69 72 65 63 74   ┆the previous contents of 'direct┆
0x100…120 6f 72 79 27 5c 6e 5c 0a 61 72 65 20 6f 6e 63 65 20 61 67 61 69 6e 20 61 63 63 65 73 73 69 62 6c   ┆ory'\n\ are once again accessibl┆
0x120…140 65 2e 5c 6e 5c 0a 41 20 66 69 6c 65 20 73 79 73 74 65 6d 20 63 61 6e 20 6f 6e 6c 79 20 62 65 20   ┆e.\n\ A file system can only be ┆
0x140…160 75 6e 6d 6f 75 6e 74 65 64 20 69 66 20 61 6c 6c 20 69 74 73 20 66 69 6c 65 73 20 61 72 65 20 63   ┆unmounted if all its files are c┆
0x160…180 6c 6f 73 65 64 2e 5c 6e 5c 0a 5c 0a 22 3b 0a 0a 23 69 6e 63 6c 75 64 65 20 3c 73 74 64 69 6f 2e   ┆losed.\n\ \ ";  #include <stdio.┆
0x180…1a0 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 6d 74 61 62 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 6d   ┆h> #include <mtab.h> #include <m┆
0x1a0…1c0 6e 74 74 61 62 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 65 72 72 6e 6f 2e 68 3e 0a 0a 63 68 61   ┆nttab.h> #include <errno.h>  cha┆
0x1c0…1e0 72 09 6d 74 61 62 66 5b 5d 20 3d 20 22 2f 65 74 63 2f 6d 74 61 62 22 3b 0a 63 68 61 72 09 6d 6e   ┆r mtabf[] = "/etc/mtab"; char mn┆
0x1e0…200 74 74 61 62 66 5b 5d 20 3d 20 22 2f 65 74 63 2f 6d 6e 74 74 61 62 22 3b 0a 0a 73 74 72 75 63 74   ┆ttabf[] = "/etc/mnttab";  struct┆
0x200…220 00 00 e9 0d 0e 00 f3 a9 08 9c 84 07 d6 54 f3 a9 08 9c fd a1 ed 51 e9 1c 07 06 00 00 04 28 00 00   ┆             T       Q       (  ┆
0x220…240 03 18 00 00 07 84 00 00 17 e4 00 00 17 dd 00 00 17 dc 00 00 17 e2 00 00 17 e1 00 00 17 e0 00 00   ┆                                ┆
0x240…260 17 df 00 00 17 e8 00 00 17 e6 00 00 17 e3 00 00 17 de 00 00 17 cf 00 00 17 d4 00 00 17 d1 00 00   ┆                                ┆
0x260…280 17 d0 00 00 17 d3 00 00 17 d2 00 00 17 db 00 00 17 d6 00 00 17 da 00 00 17 d8 00 00 17 d7 00 00   ┆                                ┆
0x280…2a0 17 d9 00 00 17 d5 d6 04 f7 a9 f3 a9 08 9c aa 92 ed 51 f7 a9 e1 1c ea 11 00 5f da 54 0c 00 fd a1   ┆                 Q       _ T    ┆
0x2a0…2c0 da 54 e9 1c 03 0a e1 1c 07 06 ed 51 16 00 e9 0d 00 00 ed 51 16 00 86 94 70 ab e1 93 d7 61 d1 43   ┆ T         Q       Q    p    a C┆
0x2c0…2e0 10 00 e0 91 e9 0d f9 a9 d1 61 ea 91 00 5f e8 91 ec 93 d1 6f 10 00 cc 83 01 61 86 94 90 a9 c0 a9   ┆         a   _     o     a      ┆
0x2e0…300 81 0c cc 83 01 e8 f5 a9 08 94 ea 91 00 5f e9 0d 2f 00 da 54 16 00 e0 91 e0 51 d0 54 16 00 e0 91   ┆             _  /  T     Q T    ┆
0x300…320 e0 51 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ┆ Q                              ┆
0x320…340 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00   ┆                                ┆
       […0x6…]
0x400…420 65 6f 66 28 7a 6d 6e 74 74 61 62 29 2c 31 2c 66 70 29 20 21 3d 20 31 29 0a 09 09 09 09 09 6d 65   ┆eof(zmnttab),1,fp) != 1)      me┆
0x420…440 72 72 6f 72 28 6d 6e 74 74 61 62 66 29 3b 0a 09 09 09 09 62 72 65 61 6b 3b 0a 09 09 09 7d 0a 09   ┆rror(mnttabf);     break;    }  ┆
0x440…460 7d 0a 09 69 66 20 28 28 66 70 20 3d 20 66 6f 70 65 6e 28 6d 74 61 62 66 2c 20 22 72 2b 77 22 29   ┆}  if ((fp = fopen(mtabf, "r+w")┆
0x460…480 29 20 21 3d 20 4e 55 4c 4c 29 20 7b 0a 09 09 6d 63 6f 70 79 28 61 72 67 76 5b 31 5d 2c 20 73 70   ┆) != NULL) {   mcopy(argv[1], sp┆
0x480…4a0 65 63 69 61 6c 29 3b 0a 09 09 77 68 69 6c 65 20 28 66 72 65 61 64 28 26 6d 74 61 62 2c 20 73 69   ┆ecial);   while (fread(&mtab, si┆
0x4a0…4c0 7a 65 6f 66 28 6d 74 61 62 29 2c 20 31 2c 20 66 70 29 20 3d 3d 20 31 29 0a 09 09 09 69 66 20 28   ┆zeof(mtab), 1, fp) == 1)    if (┆
0x4c0…4e0 6d 74 61 62 2e 6d 74 5f 6e 61 6d 65 5b 30 5d 20 21 3d 20 27 5c 30 27 0a 09 09 09 20 20 26 26 20   ┆mtab.mt_name[0] != '\0'      && ┆
0x4e0…500 20 73 74 72 6e 63 6d 70 28 6d 74 61 62 2e 6d 74 5f 73 70 65 63 69 61 6c 2c 20 73 70 65 63 69 61   ┆ strncmp(mtab.mt_special, specia┆
0x500…520 6c 2c 20 4d 4e 41 4d 53 49 5a 29 3d 3d 30 29 20 7b 0a 09 09 09 09 66 73 65 65 6b 28 66 70 2c 20   ┆l, MNAMSIZ)==0) {     fseek(fp, ┆
0x520…540 28 6c 6f 6e 67 29 28 2d 73 69 7a 65 6f 66 28 6d 74 61 62 29 29 2c 20 31 29 3b 0a 09 09 09 09 69   ┆(long)(-sizeof(mtab)), 1);     i┆
0x540…560 66 20 28 66 77 72 69 74 65 28 26 7a 6d 74 61 62 2c 20 73 69 7a 65 6f 66 28 7a 6d 74 61 62 29 2c   ┆f (fwrite(&zmtab, sizeof(zmtab),┆
0x560…580 20 31 2c 20 66 70 29 20 21 3d 20 31 29 0a 09 09 09 09 09 6d 65 72 72 6f 72 28 6d 74 61 62 66 29   ┆ 1, fp) != 1)      merror(mtabf)┆
0x580…5a0 3b 0a 09 09 09 09 62 72 65 61 6b 3b 0a 09 09 09 7d 0a 09 7d 0a 09 72 65 74 75 72 6e 20 28 30 29   ┆;     break;    }  }  return (0)┆
0x5a0…5c0 3b 0a 7d 0a 0a 75 73 61 67 65 28 29 0a 7b 0a 09 66 70 72 69 6e 74 66 28 73 74 64 65 72 72 2c 20   ┆; }  usage() {  fprintf(stderr, ┆
0x5c0…5e0 68 65 6c 70 6d 65 73 73 61 67 65 29 3b 0a 09 65 78 69 74 20 28 31 29 3b 0a 7d 0a 0a 6d 65 72 72   ┆helpmessage);  exit (1); }  merr┆
0x5e0…600 6f 72 28 66 29 0a 63 68 61 72 20 2a 66 3b 0a 7b 0a 09 72 65 67 69 73 74 65 72 20 69 6e 74 20 65   ┆or(f) char *f; {  register int e┆
0x600…620 72 72 3b 0a 09 65 78 74 65 72 6e 20 69 6e 74 20 65 72 72 6e 6f 3b 0a 0a 09 65 72 72 20 3d 20 65   ┆rr;  extern int errno;   err = e┆
0x620…640 72 72 6e 6f 3b 0a 09 66 70 72 69 6e 74 66 28 73 74 64 65 72 72 2c 20 22 75 6d 6f 75 6e 74 3a 20   ┆rrno;  fprintf(stderr, "umount: ┆
0x640…660 25 72 22 2c 20 26 66 29 3b 0a 09 69 66 20 28 65 72 72 20 3e 20 30 20 26 26 20 65 72 72 20 3c 20   ┆%r", &f);  if (err > 0 && err < ┆
0x660…680 73 79 73 5f 6e 65 72 72 29 0a 09 09 66 70 72 69 6e 74 66 28 73 74 64 65 72 72 2c 20 22 3a 20 25   ┆sys_nerr)   fprintf(stderr, ": %┆
0x680…6a0 73 5c 6e 22 2c 20 73 79 73 5f 65 72 72 6c 69 73 74 5b 65 72 72 5d 29 3b 0a 09 65 6c 73 65 0a 09   ┆s\n", sys_errlist[err]);  else  ┆
0x6a0…6c0 09 66 70 72 69 6e 74 66 28 73 74 64 65 72 72 2c 20 22 3a 20 75 6e 72 65 63 6f 67 6e 69 7a 65 64   ┆ fprintf(stderr, ": unrecognized┆
0x6c0…6e0 20 65 72 72 6f 72 3a 20 25 64 5c 6e 22 2c 20 65 72 72 29 3b 0a 09 65 78 69 74 28 31 29 3b 0a 7d   ┆ error: %d\n", err);  exit(1); }┆
0x6e0…700 0a 0a 2f 2a 0a 20 2a 20 43 6f 70 79 20 73 70 65 63 69 61 6c 20 70 61 74 68 6e 61 6d 65 20 28 73   ┆  /*  * Copy special pathname (s┆
0x700…720 74 72 69 70 70 65 64 20 6f 66 0a 20 2a 20 6c 65 61 64 69 6e 67 20 64 69 72 65 63 74 6f 72 69 65   ┆tripped of  * leading directorie┆
0x720…740 73 29 20 69 6e 74 6f 20 61 20 66 69 78 65 64 0a 20 2a 20 73 69 7a 65 20 62 75 66 66 65 72 2e 0a   ┆s) into a fixed  * size buffer. ┆
0x740…760 20 2a 2f 0a 6d 63 6f 70 79 28 6d 73 2c 20 62 75 66 29 0a 63 68 61 72 20 2a 6d 73 2c 20 2a 62 75   ┆ */ mcopy(ms, buf) char *ms, *bu┆
0x760…780 66 3b 0a 7b 0a 09 72 65 67 69 73 74 65 72 20 63 68 61 72 20 2a 70 31 2c 20 2a 70 32 3b 0a 0a 09   ┆f; {  register char *p1, *p2;   ┆
0x780…7a0 66 6f 72 20 28 70 31 3d 70 32 3d 6d 73 3b 20 2a 70 31 20 21 3d 20 27 5c 30 27 3b 20 29 0a 09 09   ┆for (p1=p2=ms; *p1 != '\0'; )   ┆
0x7a0…7c0 69 66 20 28 2a 70 31 2b 2b 20 3d 3d 20 27 2f 27 29 0a 09 09 09 70 32 20 3d 20 70 31 3b 0a 09 70   ┆if (*p1++ == '/')    p2 = p1;  p┆
0x7c0…7e0 31 20 3d 20 62 75 66 3b 0a 09 77 68 69 6c 65 20 28 2a 70 31 2b 2b 20 3d 20 2a 70 32 2b 2b 29 0a   ┆1 = buf;  while (*p1++ = *p2++) ┆
0x7e0…7e6 09 09 3b 0a 7d 0a   ┆  ; } ┆