This is unmountod.c in view mode; [Download] [Up]
/* unmountbackupod - unmount and eject an od */ #include <stdio.h> #define UNIT "0a" /* Default unit number */ #define DEVICE "od" /* Default (only available) device name */ #define DEVDIR "/dev" /* Default (only available) device directory */ #define UMOUNT "/usr/etc/umount" /* Command for unmounting filesystem */ #define EJECT "/usr/etc/disk -e" /* Command for ejecting disk */ #define MAX(x, y) \ (x > y ? x : y) main(int argc, char *argv[]) { char *unit, *cmdbuf, *PgmName; PgmName = basename(argv[0]); /* So messages look nice */ if (argc > 2) { /* Arguments provided? */ (void)fprintf(stderr, "%s: wrong number of arguments\n", PgmName); (void)fprintf(stderr, "Usage: %s [UNIT]\n", PgmName); (void)fprintf(stderr, "\tUNIT is the OD unit number (e.g., 0a) to be unmounted and ejected\n", DEVDIR); exit(1); } else if (argc == 2) { /* One argument provided */ unit = argv[1]; } else { /* No arguments provided; use defaults */ unit = UNIT; } cmdbuf = (char *)malloc(MAX(strlen(UMOUNT), strlen(EJECT) +1) + strlen(DEVDIR) + strlen(DEVICE) + strlen(unit) + 3); /* +3 in above for ' ' and '/' before unit name, and for '\0' to terminate * and the +1 is for the 'r' in /dev/rod0a */ (void)sprintf(cmdbuf, "%s %s/%s%s", UMOUNT, DEVDIR, DEVICE, unit); if (0 != system(cmdbuf)) { (void)fprintf(stderr, "%s: problems unmounting %s.\n", PgmName, unit); exit(1); } (void)sprintf(cmdbuf, "%s %s/r%s%s", EJECT, DEVDIR, DEVICE, unit); if (0 != system(cmdbuf)) { (void)fprintf(stderr, "%s: problems ejecting %s.\n", PgmName, unit); exit(1); } exit(0); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.