home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume22 / mntdisk / part02 < prev    next >
Text File  |  1991-08-21  |  36KB  |  1,437 lines

  1. Newsgroups: comp.sources.misc
  2. From: Mike J. Fuller <mikef@kristen.lerc.nasa.gov>
  3. Subject:  v22i032:  mntdisk - Allow general users to mount disks, Part02/03
  4. Message-ID: <1991Aug21.162823.11581@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 56265c52a32f19aee4e8156bcc471174
  6. Date: Wed, 21 Aug 1991 16:28:23 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Mike J. Fuller <mikef@kristen.lerc.nasa.gov>
  10. Posting-number: Volume 22, Issue 32
  11. Archive-name: mntdisk/part02
  12. Environment: SunOS
  13.  
  14. #!/bin/sh
  15. # this is mntdisk.shar.part.02 (part 2 of a multipart archive)
  16. # do not concatenate these parts, unpack them in order with /bin/sh
  17. # file mntdisk.c continued
  18. #
  19. if test ! -r _shar_seq_.tmp; then
  20.     echo 'Please unpack part 1 first!'
  21.     exit 1
  22. fi
  23. (read Scheck
  24.  if test "$Scheck" != 2; then
  25.     echo Please unpack part "$Scheck" next!
  26.     exit 1
  27.  else
  28.     exit 0
  29.  fi
  30. ) < _shar_seq_.tmp || exit 1
  31. if test ! -f _shar_wnt_.tmp; then
  32.     echo 'x - still skipping mntdisk.c'
  33. else
  34. echo 'x - continuing file mntdisk.c'
  35. sed 's/^X//' << 'SHAR_EOF' >> 'mntdisk.c' &&
  36. X
  37. /* Written by Mike J. Fuller (mikef@sarah.lerc.nasa.gov) 
  38. X   for NASA Lewis Research Center */
  39. X
  40. #ifndef lint
  41. X    static char ID[] = "@(#)mntdisk.c 1.00 91/07/02";
  42. #endif
  43. X
  44. #include "mntdisk.h"
  45. #include <sys/mount.h>
  46. X
  47. #ifdef __STDC__
  48. X    extern int run(char *command);
  49. X    extern char *mounted(char *device);
  50. X    extern char *username(int uid);
  51. X    extern int dounmount(char *device, char *mountpoint);
  52. #ifdef EXPORT
  53. X    extern int doexport(char *mountpoint, int ro, int unexport);
  54. #endif
  55. X    extern int domount(char *device, char *mountpoint, char *mtype,
  56. X               char *moptstr, int mopts);
  57. X    extern int no_fs(char *device);
  58. X    extern int can_overwrite(char *device);
  59. X    extern int mountpoint_ok(char *mp, char *nmp);
  60. X    extern void setmodes(char *device, mode_t mode);
  61. X    extern int makeowner(char *device);
  62. X    extern int spinup(char *device);
  63. #if TIMEOUT > 0
  64. X    extern void spindown(char *device, int time);
  65. #endif
  66. X    extern int lock(char *device);
  67. X    extern int unlock(char *device);
  68. X    extern int fsck(char *device);
  69. X    extern int ufschecks(char *device, int mode, int skip);
  70. X    extern int device_ok(char *device, char *ndevice);
  71. X    extern void exit(int);
  72. X    extern void closelog(void);
  73. #else
  74. X    extern int run();
  75. X    extern char *mounted();
  76. X    extern char *username();
  77. X    extern int dounmount();
  78. #ifdef EXPORT
  79. X    extern int doexport();
  80. #endif
  81. X    extern int domount();
  82. X    extern int no_fs();
  83. X    extern int can_overwrite();
  84. X    extern int mountpoint_ok();
  85. X    extern void setmodes();
  86. X    extern int makeowner();
  87. X    extern int spinup();
  88. #if TIMEOUT > 0
  89. X    extern void spindown();
  90. #endif
  91. X    extern int lock();
  92. X    extern int unlock();
  93. X    extern int fsck();
  94. X    extern int ufschecks();
  95. X    extern int device_ok();
  96. X    extern void exit();
  97. X    extern void closelog();
  98. #endif
  99. X
  100. /*****************************************************************************/
  101. X
  102. static int mode;
  103. int mask, uid, quiet = 0;
  104. char *prog;
  105. X
  106. /*****************************************************************************/
  107. X
  108. #ifdef __STDC__
  109. static int
  110. X    unmountdisk(char *device, int ejectflag)
  111. #else
  112. X    static int unmountdisk(device, ejectflag)
  113. X    char *device;
  114. X    int ejectflag;
  115. #endif
  116. {
  117. X    char bdevice[MAXPATHLEN], *mountpoint;
  118. X
  119. X    (void) sprintf(bdevice, "/dev/%s", device);
  120. X
  121. X    if((mountpoint = mounted(bdevice)) == (char *) 0) {
  122. X    (void) fprintf(stderr, "%s: Error: device '%s' not mounted.\n", prog,
  123. X        bdevice);
  124. X    return(1);
  125. X    }
  126. X
  127. #ifdef EXPORT
  128. X    switch(mode) {
  129. X    case FLOPPY:
  130. X    case EOD:
  131. X    case CD:
  132. /* XXX - should check return code, but it may fail the second time if the
  133. X   unmount fails the first time. */
  134. X    (void) doexport(mountpoint, 0, 1);
  135. X    case DOSFLOPPY:
  136. X    break;
  137. X    }
  138. #endif
  139. X    if(dounmount(bdevice, mountpoint))
  140. X    return(1);
  141. X
  142. X    if(! quiet)
  143. X    (void) printf("%s: '%s' unmounted from '%s'.\n", prog, bdevice,
  144. X              mountpoint);
  145. #ifdef SYSLOG
  146. X    syslog(LOG_INFO,
  147. X       "%s unmounted '%s' from '%s'.", username(uid), device, mountpoint);
  148. #endif
  149. X
  150. X    switch(mode) {
  151. X    case DOSFLOPPY:
  152. X    case FLOPPY:
  153. X    setmodes(device, FLOPMODE);
  154. X    break;
  155. X    case EOD:
  156. X    setmodes(device, EODMODE);
  157. X    case CD:
  158. X    break;
  159. X    }
  160. X
  161. #if TIMEOUT > 0
  162. X    if(! ejectflag && (mode == EOD))
  163. X    spindown(device, TIMEOUT);
  164. #endif
  165. X    return(0);
  166. }
  167. X
  168. /*****************************************************************************/
  169. X
  170. #ifdef __STDC__
  171. static int
  172. X    ejectdisk(char *device)
  173. #else
  174. static int ejectdisk(device)
  175. X    char *device;
  176. #endif
  177. {
  178. X    char bdevice[MAXPATHLEN], disk[MAXPATHLEN], buf[MAXPATHLEN], *c;
  179. X
  180. X    (void) sprintf(bdevice, "/dev/%s", device);
  181. X    (void) strcpy(disk, device);
  182. X    disk[strlen(disk) - 1] = '\0';
  183. X
  184. X    if((c = mounted(bdevice)) != (char *) 0) {
  185. X    (void) fprintf(stderr,
  186. X               "%s: Error: '%s' is currently mounted on '%s'.\n",
  187. X               prog, bdevice, c);
  188. X    return(1);
  189. X    }
  190. X
  191. X    if(mode == EOD)
  192. X    (void) sprintf(buf, EODEJECT, disk);
  193. X    else
  194. X    (void) sprintf(buf, "/usr/bin/eject /dev/r%s", device);
  195. X    if(run(buf))
  196. X    return(1);
  197. X
  198. X    if(! quiet)
  199. X    (void) printf("%s: '%s' ejected.\n", prog, disk);
  200. #ifdef SYSLOG
  201. X    syslog(LOG_INFO, "%s ejected '%s'.", username(uid), device);
  202. #endif
  203. X    return(0);
  204. }
  205. X
  206. /*****************************************************************************/
  207. X
  208. #ifdef __STDC__
  209. static int
  210. X    spindisk(char *device)
  211. #else
  212. static int spindisk(device)
  213. X    char *device;
  214. #endif
  215. {
  216. X    char bdevice[MAXPATHLEN], disk[MAXPATHLEN], buf[MAXPATHLEN], *c;
  217. X
  218. X    (void) sprintf(bdevice, "/dev/%s", device);
  219. X    (void) strcpy(disk, device);
  220. X    disk[strlen(disk) - 1] = '\0';
  221. X
  222. X    if((c = mounted(bdevice)) != (char *) 0) {
  223. X    (void) fprintf(stderr,
  224. X               "%s: Error: '%s' is currently mounted on '%s'.\n",
  225. X               prog, bdevice, c);
  226. X    return(1);
  227. X    }
  228. X
  229. X    if(run(sprintf(buf, EODSTOP, disk)))
  230. X    return(1);
  231. X
  232. X    if(! quiet)
  233. X    (void) printf("%s: '%s' spun down.\n", prog, disk);
  234. #ifdef SYSLOG
  235. X    syslog(LOG_INFO, "%s spun down '%s'.", username(uid), device);
  236. #endif
  237. X    return(0);
  238. }
  239. X
  240. /*****************************************************************************/
  241. X
  242. #ifdef __STDC__
  243. static int
  244. X    formatdisk(char *device, int hdflag, int batch)
  245. #else
  246. static int formatdisk(device, hdflag, batch)
  247. X    char *device;
  248. X    int hdflag, batch;
  249. #endif
  250. {
  251. X    char bdevice[MAXPATHLEN], rdevice[MAXPATHLEN], buf[MAXPATHLEN], *c;
  252. X    char eoddevice[MAXPATHLEN];
  253. X    int rc;
  254. X
  255. X    (void) sprintf(bdevice, "/dev/%s", device);
  256. X    (void) sprintf(rdevice, "/dev/r%s", device);
  257. X
  258. X    if((c = mounted(bdevice)) != (char *) 0) {
  259. X    (void) fprintf(stderr,
  260. X               "%s: Error: '%s' is currently mounted on '%s'.\n",
  261. X               prog, bdevice, c);
  262. X    return(1);
  263. X    }
  264. X
  265. X    if((mode == EOD) && spinup(device)) {
  266. X    (void) fprintf(stderr, "%s: Error: cannot spin up drive '%s'.\n",
  267. X        prog, rdevice);
  268. X    return(1);
  269. X    }
  270. X
  271. #ifdef DEBUG
  272. X    if(! can_overwrite(rdevice)) {
  273. #else
  274. X    if(uid && ! can_overwrite(rdevice)) {
  275. #endif
  276. #if TIMEOUT > 0
  277. X        if(mode == EOD)
  278. X        spindown(device, TIMEOUT);
  279. #endif
  280. X        return(1);
  281. X    }
  282. X
  283. X    if(! batch) {
  284. X        (void) printf("%s: Warning: formatting will destroy ", prog);
  285. X        (void) printf("any data on '%s'.\n", rdevice);
  286. X        (void) printf("Press return to continue or ^C to abort...");
  287. X        (void) gets(buf);
  288. X    }
  289. X
  290. X    switch(mode) {
  291. X    case EOD:
  292. X        (void) strcpy(eoddevice, device);
  293. X        eoddevice[strlen(eoddevice) - 1] = '\0';
  294. X        (void) sprintf(buf, EODFORMAT, eoddevice);
  295. X        break;
  296. X    case FLOPPY:
  297. X        if(hdflag)
  298. X        (void) sprintf(buf, "/usr/bin/fdformat -f %s", rdevice);
  299. X        else
  300. X        (void) sprintf(buf, "/usr/bin/fdformat -fl %s", rdevice);
  301. X        break;
  302. X    case DOSFLOPPY:
  303. X        if(hdflag)
  304. X        (void) sprintf(buf, "/usr/bin/fdformat -fd %s", rdevice);
  305. X        else
  306. X        (void) sprintf(buf, "/usr/bin/fdformat -fdl %s", rdevice);
  307. X        break;
  308. X    }
  309. X    rc = run(buf);
  310. X
  311. /* XXX - this stuff used to be needed back when eodutil didn't label the
  312. X   disk after formatting.  I left it here just in case it is ever needed
  313. X   again.
  314. X       if(! (rc = run(buf)) && (mode == EOD)) {
  315. X       FILE *fp;
  316. X       char fn[MAXPATHLEN];
  317. X
  318. X       if((fp = fopen(sprintf(fn, "/tmp/%s.%d", prog, getpid()), "w")) ==
  319. X       (FILE *) 0) {
  320. X       (void) fprintf(stderr,
  321. X       "%s: Error: cannot create input file for format.\n", prog);
  322. X       return(1);
  323. X    }
  324. X
  325. X    (void) fputs("label", fp);
  326. X    (void) fputs("quit", fp);
  327. X    fclose(fp);
  328. #ifdef DEBUG
  329. X    rc = run(sprintf(buf, "/usr/etc/format -t 'Artecon EOD ISO' -f %s %s",
  330. X             fn, eoddevice));
  331. #else
  332. X    rc = run(sprintf(buf,
  333. X             "/usr/etc/format -s -t 'Artecon EOD ISO' -f %s %s",
  334. X             fn, eoddevice));
  335. #endif
  336. X    unlink(fn);
  337. X    }
  338. X    */
  339. X
  340. #ifdef SYSLOG
  341. X    if(! rc)
  342. X    syslog(LOG_INFO, "%s formatted '%s'.", username(uid), device);
  343. #endif
  344. #if TIMEOUT > 0
  345. X    if(mode == EOD)
  346. X    spindown(device, TIMEOUT);
  347. #endif
  348. X    return(rc);
  349. }
  350. X
  351. /*****************************************************************************/
  352. X
  353. #ifdef __STDC__
  354. static int
  355. initdisk(char *device, int batch)
  356. #else
  357. static int initdisk(device, batch)
  358. X    char *device;
  359. X    int batch;
  360. #endif
  361. {
  362. X    char bdevice[MAXPATHLEN], rdevice[MAXPATHLEN], buf[MAXPATHLEN], *c;
  363. X    int rc;
  364. X
  365. X    (void) sprintf(bdevice, "/dev/%s", device);
  366. X    (void) sprintf(rdevice, "/dev/r%s", device);
  367. X
  368. X    if((c = mounted(bdevice)) != (char *) 0) {
  369. X    (void) fprintf(stderr,
  370. X               "%s: Error: '%s' is currently mounted on '%s'.\n",
  371. X               prog, bdevice, c);
  372. X    return(1);
  373. X    }
  374. X
  375. X    if((mode == EOD) && spinup(device)) {
  376. X    (void) fprintf(stderr, "%s: Error: cannot spin up drive '%s'.\n",
  377. X               prog, rdevice);
  378. X    return(1);
  379. X    }
  380. X
  381. #ifdef DEBUG
  382. X    if(! can_overwrite(rdevice)) {
  383. #else
  384. X    if(uid && ! can_overwrite(rdevice)) {
  385. #endif
  386. #if TIMEOUT > 0
  387. X    if(mode == EOD)
  388. X        spindown(device, TIMEOUT);
  389. #endif
  390. X    return(1);
  391. X    }
  392. X
  393. X    if(! batch) {
  394. X    (void) printf("%s: Warning: initializing will destroy ", prog);
  395. X    (void) printf("any data on '%s'.\n", rdevice);
  396. X    (void) printf("Press return to continue or ^C to abort...");
  397. X    (void) gets(buf);
  398. X    }
  399. X
  400. X    (void) sprintf(buf, "/usr/etc/newfs %s %s", (mode == EOD) ? EODPARAMS :
  401. X        FLOPPARAMS, rdevice);
  402. X    if(run(buf)) {
  403. #if TIMEOUT > 0
  404. X    if(mode == EOD)
  405. X        spindown(device, TIMEOUT);
  406. #endif
  407. X    return(1);
  408. X    }
  409. X
  410. X    rc = makeowner(rdevice);
  411. #ifdef SYSLOG
  412. X    if(! rc)
  413. X    syslog(LOG_INFO, "%s initialized '%s'.", username(uid), device);
  414. #endif
  415. #if TIMEOUT > 0
  416. X    if(mode == EOD)
  417. X       spindown(device, TIMEOUT);
  418. #endif
  419. X    return(rc);
  420. }
  421. X
  422. /*****************************************************************************/
  423. X
  424. #ifdef __STDC__
  425. static int
  426. checkdisk(char *device)
  427. #else
  428. static int checkdisk(device)
  429. char *device;
  430. #endif
  431. {
  432. X    char bdevice[MAXPATHLEN], rdevice[MAXPATHLEN], *c;
  433. X    int rc;
  434. X
  435. X    (void) sprintf(bdevice, "/dev/%s", device);
  436. X    (void) sprintf(rdevice, "/dev/r%s", device);
  437. X
  438. X    if((c = mounted(bdevice)) != (char *) 0) {
  439. X    (void) fprintf(stderr,
  440. X               "%s: Error: '%s' is currently mounted on '%s'.\n",
  441. X               prog, bdevice, c);
  442. X    return(1);
  443. X    }
  444. X
  445. X    if((mode == EOD) && spinup(device)) {
  446. X    (void) fprintf(stderr, "%s: Error: cannot spin up drive '%s'.\n",
  447. X        prog, rdevice);
  448. X    return(1);
  449. X    }
  450. X
  451. X    if(no_fs(rdevice)) {
  452. X    (void) fprintf(stderr, "%s: Error: '%s' has no filesystem.\n",
  453. X               prog, rdevice);
  454. #if TIMEOUT > 0
  455. X    if(mode == EOD)
  456. X        spindown(device, TIMEOUT);
  457. #endif
  458. X    return(1);
  459. X    }
  460. X
  461. X    rc = fsck(rdevice);
  462. #ifdef SYSLOG
  463. X    if(! rc)
  464. X    syslog(LOG_INFO, "%s checked '%s'.", username(uid), device);
  465. #endif
  466. #if TIMEOUT > 0
  467. X    if(mode == EOD)
  468. X    spindown(device, TIMEOUT);
  469. #endif
  470. X    return(rc);
  471. }
  472. X
  473. /*****************************************************************************/
  474. X
  475. #ifdef __STDC__
  476. static int
  477. mountdisk(char *device, char *mountpoint, int ro)
  478. #else
  479. static int
  480. mountdisk(device, mountpoint, ro)
  481. X    char *device, *mountpoint;
  482. X    int ro;
  483. #endif
  484. {
  485. X    char buf[MAXPATHLEN], bdevice[MAXPATHLEN], rdevice[MAXPATHLEN], *c, *mtype;
  486. X    int mopts = M_NEWTYPE | M_NOSUB;
  487. X    char moptstr[BUFSIZ];
  488. X    extern char *realpath();
  489. X
  490. X    moptstr[0] = '\0';
  491. X    if((mountpoint = realpath(mountpoint, buf)) == (char *) 0) {
  492. X    perror(buf);
  493. #if TIMEOUT > 0
  494. X    if(mode == EOD)
  495. X        spindown(device, TIMEOUT);
  496. #endif
  497. X    return(1);
  498. X    }
  499. X
  500. X    (void) sprintf(bdevice, "/dev/%s", device);
  501. X    (void) sprintf(rdevice, "/dev/r%s", device);
  502. X
  503. X    if((c = mounted(bdevice)) != (char *) 0) {
  504. X    (void) fprintf(stderr,
  505. X               "%s: Error: '%s' is currently mounted on '%s'.\n",
  506. X               prog, bdevice, c);
  507. X    return(1);
  508. X    }
  509. X
  510. X    if(((mode == EOD) || (mode == FLOPPY)) && ufschecks(device, mode, ro)) {
  511. #if TIMEOUT > 0
  512. X    if(mode == EOD)
  513. X        spindown(device, TIMEOUT);
  514. #endif
  515. X    return(1);
  516. X    }
  517. X
  518. X    if(ro) {
  519. X    mopts |= M_RDONLY;
  520. X    (void) strcat(moptstr, "ro");
  521. X    }
  522. X    else
  523. X    (void) strcat(moptstr, "rw");
  524. X
  525. X    switch(mode) {
  526. X    case FLOPPY:
  527. X    case EOD:
  528. X    mopts |= M_NOSUID;
  529. X    (void) strcat(moptstr, ",nosuid");
  530. X    mtype = "4.2";
  531. X    break;
  532. X    case CD:
  533. X    switch(no_fs(rdevice)) {
  534. X    case -1:
  535. X        return(1);
  536. X    case 0:
  537. X        mtype = "4.2";
  538. X        break;
  539. X    case 1:
  540. X        mtype = "hsfs";
  541. X        break;
  542. X        }
  543. X    break;
  544. X    case DOSFLOPPY:
  545. X    mtype = "pcfs";
  546. X    break;
  547. X    }
  548. X
  549. X    if(domount(bdevice, mountpoint, mtype, moptstr, mopts)) {
  550. #if TIMEOUT > 0
  551. X    if(mode == EOD)
  552. X        spindown(device, TIMEOUT);
  553. #endif
  554. X    return(1);
  555. X    }
  556. X
  557. X    if(! quiet)
  558. X    (void) printf("%s: '%s' mounted on '%s'.\n", prog, device, mountpoint);
  559. #ifdef SYSLOG
  560. X    syslog(LOG_INFO, "%s mounted '%s' on '%s'.", username(uid), device,
  561. X       mountpoint);
  562. #endif
  563. X
  564. X    switch(mode) {
  565. X    case FLOPPY:
  566. X    case EOD:
  567. X    setmodes(device, MODE);
  568. X    case CD:
  569. #ifdef EXPORT
  570. X    if(doexport(mountpoint, ro, 0))
  571. X        return(1);
  572. #endif
  573. X    break;
  574. X    case DOSFLOPPY:
  575. X    setmodes(device, MODE);
  576. X    break;
  577. X    }
  578. X
  579. X    return(0);
  580. }
  581. X
  582. /*****************************************************************************/
  583. X
  584. #ifdef __STDC__
  585. static void
  586. usage(char *device, char *mountpoint)
  587. #else
  588. static void usage(device, mountpoint)
  589. X    char *device, *mountpoint;
  590. #endif
  591. {
  592. X    switch(mode) {
  593. X    case EOD:
  594. X    (void) fprintf(stderr,
  595. X               "Usage: %s {cefimrsu}[bdlq] [disk] [dir]\n", prog);
  596. X    break;
  597. X    case FLOPPY:
  598. X    (void) fprintf(stderr,
  599. X               "Usage: %s {cefhimru}[bdlq] [disk] [dir]\n", prog);
  600. X    break;
  601. X    case CD:
  602. X    (void) fprintf(stderr,
  603. X               "Usage: %s {emu}[dlq] [disk] [dir]\n", prog);
  604. X    break;
  605. X    case DOSFLOPPY:
  606. X    (void) fprintf(stderr,
  607. X               "Usage: %s {efhmru}[bdlq] [disk] [dir]\n", prog);
  608. X    break;
  609. X    }
  610. X
  611. X    if((mode == EOD) || (mode == FLOPPY))
  612. X    (void) fputs("Where:\tc = Check a disk\n", stderr);
  613. X    (void) fputs("\te = Eject a disk\n", stderr);
  614. X    if(mode != CD)
  615. X    (void) fputs("\tf = Format a disk\n", stderr);
  616. X    if((mode == FLOPPY) || (mode == DOSFLOPPY))
  617. X    (void)
  618. X        fputs("\th = Format a high density disk (default = low density)\n",
  619. X          stderr);
  620. X    if((mode == EOD) || (mode == FLOPPY))
  621. X    (void) fputs("\ti = Initialize a disk\n", stderr);
  622. X    (void) fputs("\tm = Mount a disk\n", stderr);
  623. X    if(mode != CD)
  624. X    (void) fputs("\tr = Mount a disk read-only (default = read-write)\n",
  625. X             stderr);
  626. X    if(mode == EOD)
  627. X    (void) fputs("\ts = Spin down a disk\n", stderr);
  628. X    (void) fputs("\tu = Unmount a disk\n", stderr);
  629. X    if(mode != CD)
  630. X    (void) fputs("\tb = Batch mode (default = interactive)\n", stderr);
  631. X    (void) fprintf(stderr, "\td = disk (default = '%s')\n", device);
  632. X    (void) fputs("\tl = Lock disk\n", stderr);
  633. X    (void) fputs("\tq = Quiet (default = verbose)\n", stderr);
  634. X    (void) fprintf(stderr,
  635. X           "      dir = directory to mount disk on (default = %s)\n",
  636. X           mountpoint);
  637. X
  638. X    exit(1);
  639. }
  640. X
  641. /*****************************************************************************/
  642. X
  643. static char *cleanupdevice;
  644. X
  645. /*****************************************************************************/
  646. X
  647. static void cleanup(sig, code, scp, addr)
  648. X    int sig, code;
  649. X    struct sigcontext *scp;
  650. X    char *addr;
  651. {
  652. #if TIMEOUT > 0
  653. X    if(mode == EOD)
  654. X    spindown(cleanupdevice, TIMEOUT);
  655. #endif
  656. X    (void) unlock(cleanupdevice);
  657. #ifdef SYSLOG
  658. X    closelog();
  659. #endif
  660. X    exit(sig);
  661. }
  662. X
  663. /*****************************************************************************/
  664. X
  665. int main(argc, argv)
  666. X    int argc;
  667. X    char *argv[];
  668. {
  669. X    int ejectflag = 0, roflag = 0, formatflag = 0, initflag = 0, lockflag = 0;
  670. X    int mountflag = 0, unmountflag = 0, checkflag = 0, spinflag = 0;
  671. X    int hdflag = 0, batchflag = 0;
  672. X    char *c, *d, *device, *mountpoint;
  673. X
  674. X    prog = ((c = strrchr(argv[0], '/')) == (char *) 0) ? argv[0] : (c + 1);
  675. X    uid = getuid();
  676. X    mask = umask(0);
  677. X
  678. X    if(geteuid()) {
  679. X    (void) fprintf(stderr,
  680. X        "%s: Error: must be running as root or set-uid root.\n", prog);
  681. X    exit(1);
  682. X    }
  683. X
  684. #ifdef ENABLE_EOD
  685. X    if(! strcmp(prog, "eodmount")) {
  686. X    mode = EOD;
  687. X    device = EODDEVICE;
  688. X    mountpoint = EODMNT;
  689. X    }
  690. X    else
  691. #endif
  692. #ifdef ENABLE_FLOPPY
  693. X    if(! strcmp(prog, "fdmount")) {
  694. X    mode = FLOPPY;
  695. X    device = FDDEVICE;
  696. X    mountpoint = FLOPMNT;
  697. X    }
  698. X    else
  699. #endif
  700. #ifdef ENABLE_DOSFLOPPY
  701. X    if(! strcmp(prog, "dosmount")) {
  702. X    mode = DOSFLOPPY;
  703. X    device = FDDEVICE;
  704. X    mountpoint = DOSMNT;
  705. X    }
  706. X    else
  707. #endif
  708. #ifdef ENABLE_CD
  709. X    if(! strcmp(prog, "cdmount")) {
  710. X    mode = CD;
  711. X    device = CDDEVICE;
  712. X    mountpoint = CDMNT;
  713. X    }
  714. X    else
  715. #endif
  716. X    {
  717. #ifdef DEBUG
  718. X        mode = FLOPPY;
  719. X        device = FDDEVICE;
  720. X        mountpoint = FLOPMNT;
  721. #else
  722. X        (void) fprintf(stderr,    "%s: Error: argv[0].\n", prog);
  723. X        exit(1);
  724. #endif
  725. X    }
  726. X
  727. X    if(argc == 1)
  728. X    usage(device, mountpoint);
  729. X    argv++;
  730. X    for(c = *argv++; *c != '\0'; c++)
  731. X    if(mode == CD)
  732. X        switch (*c) {
  733. X        case 'e':
  734. X        ++ejectflag;
  735. X        break;
  736. X        case 'm':
  737. X        case 'r':
  738. X        ++mountflag;
  739. X        ++roflag;
  740. X        break;
  741. X        case 'u':
  742. X        ++unmountflag;
  743. X        break;
  744. X        case 'd':
  745. X        if(*argv == (char *) 0) {
  746. X            (void) fprintf(stderr, "Error: a disk must be specified ");
  747. X            (void) fprintf(stderr, "with the 'd' option.\n");
  748. X            usage(device, mountpoint);
  749. X        }
  750. X        d = *argv++;
  751. X        if(! device_ok(device, d)) {
  752. X            (void) fprintf(stderr, "Error: invalid disk '%s'.\n", d);
  753. X            usage(device, mountpoint);
  754. X        }
  755. X        device = d;
  756. X        break;
  757. X        case 'l':
  758. X        ++lockflag;
  759. X        break;
  760. X        case 'q':
  761. X        ++quiet;
  762. X        break;
  763. X        case '-':
  764. X        break;
  765. X        default:
  766. X        (void) fprintf(stderr, "Error: unknown option '%c'.\n", *c);
  767. X        usage(device, mountpoint);
  768. X        break;
  769. X        }
  770. X    else
  771. X        switch (*c) {
  772. X        case 'c':
  773. X        ++checkflag;
  774. X        break;
  775. X        case 'e':
  776. X        ++ejectflag;
  777. X        break;
  778. X        case 'f':
  779. X        ++formatflag;
  780. X        break;
  781. X        case 'h':
  782. X        if((mode != FLOPPY) && (mode != DOSFLOPPY)) {
  783. X            (void) fprintf(stderr, "Error: unknown option '%c'.\n", *c);
  784. X            usage(device, mountpoint);
  785. X        }
  786. X        ++hdflag;
  787. X        ++formatflag;
  788. X        break;
  789. X        case 'i':
  790. X        ++initflag;
  791. X        break;
  792. X        case 'm':
  793. X        ++mountflag;
  794. X        break;
  795. X        case 's':
  796. X        if(mode != EOD) {
  797. X            (void) fprintf(stderr, "Error: unknown option '%c'.\n", *c);
  798. X            usage(device, mountpoint);
  799. X        }
  800. X        ++spinflag;
  801. X        break;
  802. X        case 'u':
  803. X        ++unmountflag;
  804. X        break;
  805. X        case 'b':
  806. X        ++batchflag;
  807. X        break;
  808. X        case 'd':
  809. X        if(*argv == (char *) 0) {
  810. X            (void) fprintf(stderr, "Error: a disk must be specified ");
  811. X            (void) fprintf(stderr, "with the 'd' option.\n");
  812. X            usage(device, mountpoint);
  813. X        }
  814. X        d = *argv++;
  815. X        if(! device_ok(device, d)) {
  816. X            (void) fprintf(stderr, "Error: invalid disk '%s'.\n", d);
  817. X            usage(device, mountpoint);
  818. X        }
  819. X        device = d;
  820. X        break;
  821. X        case 'l':
  822. X        ++lockflag;
  823. X        break;
  824. X        case 'q':
  825. X        ++quiet;
  826. X        break;
  827. X        case 'r':
  828. X        ++mountflag;
  829. X        ++roflag;
  830. X        break;
  831. X        case '-':
  832. X        break;
  833. X        default:
  834. X        (void) fprintf(stderr, "Error: unknown option '%c'.\n", *c);
  835. X        usage(device, mountpoint);
  836. X        break;
  837. X        }
  838. X
  839. X
  840. X    if(*argv != (char *) 0)
  841. X    d = *argv++;
  842. X    else
  843. X    d = mountpoint;
  844. X    if(mountflag && ! mountpoint_ok(mountpoint, d))
  845. X    usage(device, mountpoint);
  846. X    mountpoint = d;
  847. X
  848. X    if((*argv != (char *) 0) ||
  849. X       ! (checkflag || ejectflag || formatflag || initflag || mountflag ||
  850. X      spinflag || unmountflag) ||
  851. X       (spinflag && mountflag) || (spinflag && ejectflag))
  852. X    usage(device, mountpoint);
  853. X
  854. X    cleanupdevice = device;
  855. X    (void) signal(SIGHUP, cleanup);
  856. X    (void) signal(SIGINT, cleanup);
  857. #ifndef DEBUG
  858. X    (void) signal(SIGABRT, cleanup);
  859. #endif
  860. X
  861. X    if(lock(device))
  862. X    exit(1);
  863. #ifdef SYSLOG
  864. X    openlog(prog, LOG_NOWAIT, SYSLOG);
  865. #endif
  866. X    if((unmountflag && unmountdisk(device, ejectflag)) ||
  867. X       (formatflag && formatdisk(device, hdflag, batchflag)) ||
  868. X       (initflag && initdisk(device, batchflag || formatflag)) ||
  869. X       (checkflag && checkdisk(device)) ||
  870. X       (spinflag && spindisk(device)) ||
  871. X       (ejectflag && ejectdisk(device)) ||
  872. X       (mountflag && mountdisk(device, mountpoint, roflag))) {
  873. X    (void) unlock(device);
  874. #ifdef SYSLOG
  875. X    closelog();
  876. #endif
  877. X    exit(1);
  878. X    }
  879. X    if(! (mountflag && lockflag)) {
  880. #ifdef SYSLOG
  881. X    closelog();
  882. #endif
  883. X    (void) unlock(device);
  884. X    }
  885. X
  886. X    return(0);
  887. }
  888. SHAR_EOF
  889. echo 'File mntdisk.c is complete' &&
  890. chmod 0644 mntdisk.c ||
  891. echo 'restore of mntdisk.c failed'
  892. Wc_c="`wc -c < 'mntdisk.c'`"
  893. test 19477 -eq "$Wc_c" ||
  894.     echo 'mntdisk.c: original size 19477, current size' "$Wc_c"
  895. rm -f _shar_wnt_.tmp
  896. fi
  897. # ============= mntdisk.h ==============
  898. if test -f 'mntdisk.h' -a X"$1" != X"-c"; then
  899.     echo 'x - skipping mntdisk.h (File already exists)'
  900.     rm -f _shar_wnt_.tmp
  901. else
  902. > _shar_wnt_.tmp
  903. echo 'x - extracting mntdisk.h (Text)'
  904. sed 's/^X//' << 'SHAR_EOF' > 'mntdisk.h' &&
  905. /* mntdisk.h -- compile time options for MNTDISK */
  906. X
  907. /* Mode for disk device special files when disk is mounted. */
  908. #define MODE 0440
  909. X
  910. /* Syslog(3) facility to log user actions under.
  911. X   May be commented out to save some code if you're not going to use it. */
  912. #define SYSLOG LOG_LOCAL1
  913. X
  914. /* Don't check for device special files and skip the default fsck(8) for
  915. X   users in group wheel.
  916. X   May be commented out if you don't trust people in group wheel :-) */
  917. #define WHEEL
  918. X
  919. /* Options to be passed to exportfs(8) when the disk is mounted.
  920. X   May be commented out if you don't want to export mounted disks. */
  921. #define EXPORT "access=your_netgroup"
  922. X
  923. /* Enable FDMOUNT. */
  924. /* Comment out if you don't want users to be able to mount UFS floppies. */
  925. #define ENABLE_FLOPPY
  926. X
  927. /* Enable CDMOUNT. */
  928. /* Comment out if you don't want users to be able to mount CD-ROMs. */
  929. #define ENABLE_CD
  930. X
  931. /* Enable EODMOUNT. */
  932. /* Comment out if you don't want users to be able to mount EODs. */
  933. /* #define ENABLE_EOD */
  934. X
  935. /* Enable DOSMOUNT. */
  936. /* Comment out if you don't want users to be able to mount DOS floppies. */
  937. #define ENABLE_DOSFLOPPY
  938. X
  939. /* The rest of these PROBABLY don't need to be changed.
  940. X   If you have preferences, then they should be self-explanatory :-) */
  941. #define FDDEVICE "fd0c"
  942. #define FLOPPARAMS "-b 4096 -f 512 -m 5 -o space -C 7"
  943. #define FLOPMODE 0666
  944. #define FLOPMNT "/floppy"
  945. #define DOSMNT "/pcfs"
  946. X
  947. #define CDDEVICE "sr0"
  948. #define CDMNT "/cdrom"
  949. X
  950. #define EODDEVICE "eod0c"
  951. #define EODEJECT "/usr/local/etc/eodutil.new %s eject"
  952. #define EODFORMAT "/usr/local/etc/eodutil.new %s format"
  953. #define EODSTART "/usr/local/etc/eodutil.old %s start"
  954. #define EODSTOP "/usr/local/etc/eodutil.old %s stop"
  955. #define EODPARAMS "-c 128 -i 16384 -m 5 -o space -r 2400 -C 7"
  956. #define EODMODE 0660
  957. #define EODMNT "/eod"
  958. #define TIMEOUT 0
  959. X
  960. /* Nothing after here should need to be changed. */
  961. #define EOD 1
  962. #define FLOPPY 2
  963. #define CD 3
  964. #define DOSFLOPPY 4
  965. X
  966. #include <sys/param.h>
  967. #include <stdio.h>
  968. #include <string.h>
  969. #include <fcntl.h>
  970. #include <dirent.h>
  971. #include <syslog.h>
  972. SHAR_EOF
  973. chmod 0644 mntdisk.h ||
  974. echo 'restore of mntdisk.h failed'
  975. Wc_c="`wc -c < 'mntdisk.h'`"
  976. test 2056 -eq "$Wc_c" ||
  977.     echo 'mntdisk.h: original size 2056, current size' "$Wc_c"
  978. rm -f _shar_wnt_.tmp
  979. fi
  980. # ============= mntdisk.man ==============
  981. if test -f 'mntdisk.man' -a X"$1" != X"-c"; then
  982.     echo 'x - skipping mntdisk.man (File already exists)'
  983.     rm -f _shar_wnt_.tmp
  984. else
  985. > _shar_wnt_.tmp
  986. echo 'x - extracting mntdisk.man (Text)'
  987. sed 's/^X//' << 'SHAR_EOF' > 'mntdisk.man' &&
  988. .\" @(#)mntdisk.l 1.00 91/06/06
  989. .TH MNTDISK L "6 June 1991"
  990. .SH NAME
  991. mntdisk \- allow a user to manipulate a disk
  992. .SH SYNOPSIS
  993. .B fdmount
  994. {
  995. .B cefhimru
  996. }[
  997. .B bdlq
  998. ] [
  999. .I disk
  1000. ] [
  1001. .I dir
  1002. ]
  1003. .LP
  1004. .B dosmount
  1005. {
  1006. .B efhmru
  1007. }[
  1008. .B bdlq
  1009. ] [
  1010. .I disk
  1011. ] [
  1012. .I dir
  1013. ]
  1014. .LP
  1015. .B eodmount
  1016. {
  1017. .B cefimrsu
  1018. }[
  1019. .B bdlq
  1020. ] [
  1021. .I disk
  1022. ] [
  1023. .I dir
  1024. ]
  1025. .LP
  1026. .B cdmount
  1027. {
  1028. .B emu
  1029. }[
  1030. .B dlq
  1031. ] [
  1032. .I disk
  1033. ] [
  1034. .I dir
  1035. ]
  1036. .SH DESCRIPTION
  1037. All four incarnations of
  1038. .B mntdisk
  1039. allow users to perform basic operations on some type of removable
  1040. disk media in a reasonably secure manner.
  1041. .SH FUNCTIONS
  1042. .TP
  1043. .B c
  1044. Check a
  1045. .IR disk .
  1046. This function merely runs
  1047. .B fsck(8)
  1048. to check the consistency of the filesystem on the
  1049. .IR disk .
  1050. Therefore, it is available only under
  1051. .B fdmount
  1052. and
  1053. .BR eodmount .
  1054. .TP
  1055. .B e
  1056. Eject a
  1057. .IR disk .
  1058. This function causes the
  1059. .I disk
  1060. to be ejected from the drive.  It is available under all four
  1061. incarnation of
  1062. .BR mntdisk ,
  1063. although it may seem superfluous for eraseable-optical disk drives and
  1064. cd-rom disk drives.
  1065. .TP
  1066. .B f
  1067. Format a
  1068. .IR disk .
  1069. Under
  1070. .B fdmount
  1071. and
  1072. .B eodmount
  1073. it does a low-level format on a
  1074. .IR disk ,
  1075. while under
  1076. .B dosmount
  1077. it does a low-level format
  1078. .B and
  1079. puts a DOS filesystem on the
  1080. .IR disk .
  1081. Therefore, under
  1082. .B fdmount
  1083. and
  1084. .BR eodmount ,
  1085. a disk needs to be formatted and initialized (see the
  1086. .B i
  1087. option) before it can be used, whereas under
  1088. .B dosmount
  1089. a disk only needs to be formatted before it can be used.
  1090. .TP
  1091. .B h
  1092. Format a high density
  1093. .IR disk .
  1094. This option is available only under
  1095. .B dosmount
  1096. and
  1097. .BR fdmount ,
  1098. and behaves the same as the
  1099. .B f
  1100. option (above), except it formats a high density (1.44M) disk whereas
  1101. the
  1102. .B f
  1103. option formats a low density (720K) disk.
  1104. .TP
  1105. .B i
  1106. Initialize a
  1107. .IR disk .
  1108. This option is available under
  1109. .B fdmount
  1110. and
  1111. .BR eodmount .
  1112. It places a UNIX filesystem on the
  1113. .IR disk ,
  1114. identical in structure to the UNIX filesystem which you are accustomed
  1115. to.  Note that although this option is normally used in conjunction
  1116. with the
  1117. .B f
  1118. option (above), once the disk has been formatted, it can be
  1119. initialized repeatedly without being reformatted if you wish to
  1120. discard all the information on the disk quickly.
  1121. .TP
  1122. .B m
  1123. Mount a
  1124. .IR disk
  1125. on directory
  1126. .IR dir .
  1127. This causes the filesystem on the
  1128. .I disk
  1129. to be placed in the overall file system hierarchy at the pathname
  1130. location
  1131. .IR dir ,
  1132. which must already exist.  If
  1133. .I dir
  1134. was not empty, its original contents will remain covered until the
  1135. .I disk
  1136. is unmounted.  If no
  1137. .I dir
  1138. is given, the
  1139. .I disk
  1140. will be mounted on a default directory as specified below.
  1141. .TP
  1142. .B r
  1143. Mount a
  1144. .I disk
  1145. read-only.  This option is the same as the
  1146. .B m
  1147. option (above), except that the
  1148. .I disk
  1149. cannot be written to. This may speed file access on slow disks since
  1150. the access times on files won't be updated.  For obvious reasons, this
  1151. is the same as the
  1152. .B m
  1153. option (above) for CD ROMs.
  1154. .TP
  1155. .B s
  1156. Spin down a
  1157. .I disk.
  1158. This option is only available under
  1159. .BR eodmount ,
  1160. since only optical drives can be spun down manually.  This causes the
  1161. .I disk
  1162. to stop spinning until it is mounted or otherwise accessed again.
  1163. This option is good for saving wear and tear on the disk drive if you
  1164. wish to leave a disk in the drive for later use.  Note that the
  1165. .I disk
  1166. cannot be spun down if it is currently mounted or otherwise busy.
  1167. .TP
  1168. .B u
  1169. Unmount a
  1170. .IR disk .
  1171. This option causes the
  1172. .I disk
  1173. to be removed from the filesystem hierarchy.
  1174. .SH OPTIONS
  1175. .TP
  1176. .B b
  1177. Batch mode.
  1178. In this mode, user input is never asked for and an affirmative answer
  1179. is assumed to all questions which would normally be asked.  Note that
  1180. this option may be dangerous and is best used only by users who are
  1181. familiar with all the questions which may be asked.
  1182. .TP
  1183. .B d
  1184. .IR Disk .
  1185. This option specifies an alternate disk device.  Note that, for
  1186. obvious security reasons, '/dev/' is assumed to be prepended to the
  1187. device name and only variations on the default device can be used.
  1188. .TP
  1189. .B l
  1190. Lock
  1191. .IR disk .
  1192. Normally a
  1193. .I disk
  1194. that has been mounted by one user may be unmounted by any other user.
  1195. Of course, if the
  1196. .I disk
  1197. is currently busy, no one can unmount it.  Therefore, this should not
  1198. be a problem unless you are really paranoid.  When this option is
  1199. specified, only the user who originally mounted the
  1200. .I disk
  1201. can unmount it.  Use this option with care because if you mount a
  1202. disk, forget about it, and go home, you will leave the drive useless for
  1203. others.
  1204. .TP
  1205. .B q
  1206. Quiet.  In this mode, informational output is suppressed.  Error
  1207. messages, however, will still be printed when necessary.
  1208. .SH EXAMPLES
  1209. .LP
  1210. To check and mount an erasable-optical disk on the default directory,
  1211. one might use:
  1212. .IP
  1213. .B sarah% eodmount cm
  1214. .LP
  1215. To format, initialize, and mount a floppy disk on ~/tmp, one might
  1216. use:
  1217. .IP
  1218. .B holodeck% fdmount fim ~/tmp
  1219. .LP
  1220. To mount and lock a read-only DOS floppy disk on the default
  1221. directory, one might use:
  1222. .IP
  1223. .B panic% dosmount rl
  1224. .LP
  1225. To unmount and eject a CD-ROM, one might use:
  1226. .IP
  1227. .B dredd% cdmount ue
  1228. .SH FILES
  1229. .PD 0
  1230. .TP 20
  1231. .B /pcfs
  1232. default directory upon which to mount DOS disks
  1233. .TP
  1234. .B /cdrom
  1235. default directory upon which to mount CD ROM disk
  1236. .TP
  1237. .B /eod
  1238. default directory upon which to mount erasable-optical disks
  1239. .TP
  1240. .B /floppy
  1241. default directory upon which to mount floppy disks
  1242. .PD
  1243. .SH SEE ALSO
  1244. .BR fsck (8),
  1245. .BR mount (8),
  1246. .BR umount (8).
  1247. .SH DIAGNOSTICS
  1248. .BI "mntdisk: " filename ": device busy"
  1249. .br
  1250. There is a process running with files open on the
  1251. .IR disk ,
  1252. most likely your current shell.
  1253. .LP
  1254. Most other error messages should be fairly self explanatory, although
  1255. some of the less common error messages may seem somewhat cryptic to
  1256. the inexperienced user.
  1257. .SH AUTHOR
  1258. Mike J. Fuller
  1259. .br
  1260. NASA Lewis Research Center
  1261. .br
  1262. mikef@sarah.lerc.nasa.gov
  1263. .PD
  1264. .SH BUGS
  1265. Mounting a disk with the right magic but a garbage filesystem will
  1266. surely crash the system.  Of course, if you are truly malicious and
  1267. only want to crash the system, the power switch is located on the back
  1268. of the computer by the power cord.  It is faster and doesn't leave a
  1269. log of who did it.
  1270. .LP
  1271. .B cdmount
  1272. doesn't check for device special files on 4.2 filesystem CD ROMs.  I
  1273. would check for it, but that slows down the mounting process and I
  1274. won't lose sleep over someone going to the trouble to have a custom CD
  1275. ROM with device special files made.
  1276. .LP
  1277. I have seen instances where trying access the floppy drive when there
  1278. is no disk in it will crash the system, but have been unable to
  1279. reproduce it.  However, this is an operating system bug and something
  1280. I can't check for, so if you only want to crash the system, see above.
  1281. .LP
  1282. The difference between formatting and initializing a disk is confusing
  1283. for many users and is only compounded by the difference for
  1284. .BR dosmount .
  1285. However, if you have ever waited for an erasable-optical disk to
  1286. format and initialize, as opposed to just initialize, you would want
  1287. the options separate, too.
  1288. .LP
  1289. Exporting of disks is a compile time option.  Thus, there is no way
  1290. for a user to control the exporting of his disk.
  1291. .LP
  1292. Because a filesystem must be unexported before it is unmounted, if the
  1293. unmount fails because a filesystem is busy, the unexport will fail on
  1294. subsequent attempts to unmount the filesystem because it was already
  1295. done on the first attempt.
  1296. SHAR_EOF
  1297. chmod 0644 mntdisk.man ||
  1298. echo 'restore of mntdisk.man failed'
  1299. Wc_c="`wc -c < 'mntdisk.man'`"
  1300. test 7206 -eq "$Wc_c" ||
  1301.     echo 'mntdisk.man: original size 7206, current size' "$Wc_c"
  1302. rm -f _shar_wnt_.tmp
  1303. fi
  1304. # ============= mntdisk.ps ==============
  1305. if test -f 'mntdisk.ps' -a X"$1" != X"-c"; then
  1306.     echo 'x - skipping mntdisk.ps (File already exists)'
  1307.     rm -f _shar_wnt_.tmp
  1308. else
  1309. > _shar_wnt_.tmp
  1310. echo 'x - extracting mntdisk.ps (Text)'
  1311. sed 's/^X//' << 'SHAR_EOF' > 'mntdisk.ps' &&
  1312. %!PS-Adobe-1.0
  1313. %%Creator: sarah:mikef (Mike J. Fuller,105-204,8163,867-7164)
  1314. %%Title: stdin
  1315. %%CreationDate: Fri Jun  7 13:20:31 1991
  1316. %%DocumentFonts: Times-Roman Times-Italic Times-Bold Symbol Times-Roman DIThacks
  1317. %%Pages: (atend)
  1318. %%EndComments
  1319. % Start of pscat.pro -- prolog for troff translator
  1320. % Copyright (c) 1985,1987 Adobe Systems Incorporated. All Rights Reserved. 
  1321. % GOVERNMENT END USERS: See Notice file in TranScript library directory
  1322. % -- probably /usr/lib/ps/Notice
  1323. % RCS: $Header: pscat.pro,v 2.2 87/11/17 16:40:32 byron Rel $
  1324. save /pscatsave exch def
  1325. /$pscat 50 dict def
  1326. $pscat begin
  1327. /fm [1 0 0 1 0 0] def
  1328. /xo 0 def /yo 0 def
  1329. /M /moveto load def
  1330. /R /show load def
  1331. /S {exch currentpoint exch pop moveto show}def
  1332. /T {exch currentpoint pop exch moveto show}def
  1333. /U {3 1 roll moveto show}def
  1334. /siz 0 def
  1335. /font 0 def
  1336. /Z {/siz exch def SF}def
  1337. /F {/font exch def SF}def
  1338. /SF{font 0 ne
  1339. X    {catfonts font 1 sub get fm 0 siz put fm 3 siz neg put 
  1340. X     fm makefont setfont}if}def
  1341. /BP{save/catsv exch def 0 792 translate 72 432 div dup neg scale 
  1342. X  xo yo translate 0 0 moveto}def
  1343. /BPL{save/catsv exch def 72 8.25 mul 792 translate -90 rotate
  1344. X  72 432 div dup neg scale xo yo translate 0 0 moveto}def
  1345. /EP{catsv restore showpage}def
  1346. X
  1347. /SetStTime{statusdict /manualfeedtimeout 120 put} def
  1348. /SetStatus{statusdict /manualfeed true put
  1349. X   statusdict /product get (LaserWriter) eq 
  1350. X   {version (23.0) eq  % Don't redefine EP if printer is not "Classic LW"
  1351. X     {/EP {catsv restore
  1352. X     {statusdict /printerstatus get exec 16#22000000 and 0 eq{exit}if}loop
  1353. X     showpage}def}if }if}def
  1354. % definitions for PPROC callback functions
  1355. % each PPROC is called with the following number on the stack:
  1356. % pointsize charcode railmag pswidth pschar x y wid
  1357. /$pprocs 50 dict def
  1358. /fractm [.65 0 0 .6 0 0] def
  1359. % fractions
  1360. /PS1{gsave $pprocs begin
  1361. X    /wid exch def pop pop pop pop pop /ch exch def /size exch def
  1362. X    /pair $pprocs ch get def /cf currentfont def
  1363. X    cf fractm makefont setfont
  1364. X    0 .3 size mul 6 mul 2 copy neg rmoveto pair 0 get show rmoveto
  1365. X    currentfont cf setfont (\244) show setfont
  1366. X    pair 1 get show grestore wid .06 div 0 rmoveto end}def
  1367. $pprocs begin
  1368. 8#34 [(1)(4)] def
  1369. 8#36 [(1)(2)] def
  1370. 8#46 [(3)(4)] def
  1371. end
  1372. % DIThacks fonts for some special chars
  1373. 50 dict dup begin
  1374. /FontType 3 def
  1375. /FontName /DIThacks def
  1376. /FontMatrix [.001 0.0 0.0 .001 0.0 0.0] def
  1377. /FontBBox [-220 -280 900 900] def% a lie but ...
  1378. /Encoding 256 array def
  1379. 0 1 255{Encoding exch /.notdef put}for
  1380. Encoding
  1381. X dup 8#040/space put %space
  1382. X dup 8#110/rc put %right ceil
  1383. X dup 8#111/lt put %left  top curl
  1384. X dup 8#112/bv put %bold vert
  1385. X dup 8#113/lk put %left  mid curl
  1386. X dup 8#114/lb put %left  bot curl
  1387. X dup 8#115/rt put %right top curl
  1388. X dup 8#116/rk put %right mid curl
  1389. X dup 8#117/rb put %right bot curl
  1390. X dup 8#120/rf put %right floor
  1391. X dup 8#121/lf put %left  floor
  1392. X dup 8#122/lc put %left  ceil
  1393. X dup 8#140/sq put %square
  1394. X dup 8#141/bx put %box
  1395. X dup 8#142/ci put %circle
  1396. X dup 8#143/br put %box rule
  1397. X dup 8#144/rn put %root extender
  1398. X dup 8#145/vr put %vertical rule
  1399. X dup 8#146/ob put %outline bullet
  1400. X dup 8#147/bu put %bullet
  1401. X dup 8#150/ru put %rule
  1402. X dup 8#151/ul put %underline
  1403. X pop
  1404. /DITfd 100 dict def
  1405. /BuildChar{0 begin
  1406. X /cc exch def /fd exch def
  1407. X /charname fd /Encoding get cc get def
  1408. X /charwid fd /Metrics get charname get def
  1409. X /charproc fd /CharProcs get charname get def
  1410. X charwid 0 fd /FontBBox get aload pop setcachedevice
  1411. X 40 setlinewidth
  1412. X newpath 0 0 moveto gsave charproc grestore
  1413. X end}def
  1414. /BuildChar load 0 DITfd put
  1415. %/UniqueID 5 def
  1416. /CharProcs 50 dict def
  1417. CharProcs begin
  1418. /space{}def
  1419. /.notdef{}def
  1420. /ru{500 0 rls}def
  1421. /rn{0 750 moveto 500 0 rls}def
  1422. /vr{20 800 moveto 0 -770 rls}def
  1423. SHAR_EOF
  1424. true || echo 'restore of mntdisk.ps failed'
  1425. fi
  1426. echo 'End of  part 2'
  1427. echo 'File mntdisk.ps is continued in part 3'
  1428. echo 3 > _shar_seq_.tmp
  1429. exit 0
  1430.  
  1431. exit 0 # Just in case...
  1432. -- 
  1433. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1434. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1435. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1436. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1437.