home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume7 / multivol / part1 next >
Encoding:
Text File  |  1986-11-30  |  26.0 KB  |  885 lines

  1. Relay-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site mirror.UUCP
  2. Path: mirror!cca!decvax!genrad!panda!husc6!seismo!munnari!sources-request
  3. From: sources-request@munnari.UUCP
  4. Newsgroups: mod.sources
  5. Subject: v07i12: Multivol V1.00 - multivolume backup utility, part01/02
  6. Message-ID: <1230@munnari.OZ>
  7. Date: 29 Aug 86 15:26:37 GMT
  8. Date-Received: 2 Sep 86 20:55:26 GMT
  9. Sender: kre@munnari.OZ
  10. Lines: 872
  11. Approved: kre@munnari.oz
  12.  
  13. Submitted-by: Tony O'Hagan <tony%uqcspe.oz@seismo.css.gov>
  14. Mod.sources: Volume 17, Issue 12
  15. Archive-name: multivol
  16.  
  17.     [ This is a program that was announced in net.unix-wizards
  18.       some time ago (May perhaps).  It reads standard input
  19.       and splits the (assumed large) file across multiple
  20.       tape volumes.  It does some label checking on tapes.
  21.  
  22.       I have tested this to the extent of seeing that it compiles,
  23.       and runs its own test cases, on both 4.3beta and Sys V.
  24.       To compile this on Sys V you will need to add
  25.           -Dindex=strchr -DSYSV
  26.       on the DEFINE= line in Makefile.
  27.  
  28.       You should read the Makefile carefully, there are some system
  29.       dependant defines scattered through it.  Also read the READ_ME
  30.       carefully.
  31.  
  32.       One day I will get a better version of shar, till then... kre ]
  33.  
  34. echo x - "READ_ME" 2>&1
  35. sed "s/^X//" >"READ_ME" <<'!The!End!'
  36. X    Multivol V1.00 - multivolume backup utility
  37. X
  38. X========================================================================
  39. XTo install :-
  40. X    0) check Makefile
  41. X        - sorry you'll find a lot of testing junk - see below.
  42. X    1) make depend
  43. X        - to build dependencies in makefile 
  44. X        - check them at the end of the Makefile.
  45. X    2) make multivol
  46. X    3) Test writting to a file (i.e. not a device)
  47. X        3.0) make testdata - to build a test data program.
  48. X        3.1) make wfile - test writting to file
  49. X            The first time a file or device is written to
  50. X            multivol will report that it finds no header.
  51. X        3.2) make rfile - test reading the file.
  52. X        3.3) make rewfile - test writting and re-reading the file.
  53. X    4) Test writting to a device.
  54. X        4.0) Change TSTDEV in makefile to the device used for testing.
  55. X             or better - create the link /dev/multivol to the device.
  56. X             This is compiled into multivol as the default device.
  57. X        4.1 - 4.3) Simple tests are 'make w', 'make r', 'make ro'
  58. X        4.4) Have a look at Makefile to try some other tests (e.g wbig)
  59. X    End)
  60. X        E.0) Change DEFINE in Makefile to not include -DDEBUG
  61. X             This ensures tracing is removed from object code.
  62. X        E.1) Change CFLAGS in Makefile to include -O
  63. X            (if you have an optimising compiler)
  64. X        E.2) make clobber - to remove any object code.
  65. X        E.3) make multivol - to rebuild the thing without any tracing.
  66. X        E.4) If it still works (i.e. you can trust your optimiser)
  67. X             install it in you favourite bin directory and
  68. X             multivol.8 in /usr/man/man8 or wherever.
  69. X========================================================================
  70. X19-Jul-85  Tony O'Hagan
  71. X    Using /dev/rmt0, doesn't appear to read volume header unless
  72. X    the block size matches the written block size.  I/O failure.
  73. X========================================================================
  74. X 7-Aug-85  Tony O'Hagan
  75. X    Expected lint errors :-        (Perkin-Elmer V7 lint)
  76. X"rd.c", line 150: warning: possible pointer alignment problem
  77. X"rd.c", line 152: warning: possible pointer alignment problem
  78. X"wr.c", line 149: warning: possible pointer alignment problem
  79. X"vhdr.c", line 51: warning: possible pointer alignment problem
  80. X"vhdr.c", line 85: warning: blk_siz redefinition hides earlier one
  81. Xaskf returns value which is always ignored
  82. Xclose returns value which is always ignored
  83. Xfgets returns value which is always ignored
  84. Xmount_v returns value which is sometimes ignored
  85. Xrd_put_ returns value which is always ignored
  86. Xsprintf returns value which is always ignored
  87. Xsscanf returns value which is sometimes ignored
  88. Xstrncpy returns value which is always ignored
  89. Xwrite returns value which is sometimes ignored
  90. X========================================================================
  91. !The!End!
  92.  
  93. echo x - "multivol.8" 2>&1
  94. sed "s/^X//" >"multivol.8" <<'!The!End!'
  95. X.TH MULTIVOL 8 local
  96. X.SH NAME
  97. Xmultivol \- handle multivolume files
  98. X.SH SYNOPSIS
  99. X.B multivol
  100. X.B \-o
  101. X.RB [ \-vtw ]
  102. X.RB [ \-b
  103. X.IR blocksize ]
  104. X.RB [ \-n
  105. X.IR count ]
  106. X.RB [ \-l
  107. X.IR label ]
  108. X.RI [ device ]
  109. X.PP
  110. X.B multivol
  111. X.B \-i
  112. X.RB [ \-vtw ]
  113. X.RB [ \-b
  114. X.IR blocksize ]
  115. X.RB [ \-n
  116. X.IR count ]
  117. X.RB [ \-l
  118. X.IR label ]
  119. X.RI [ device ]
  120. X.PP
  121. X.B multivol
  122. X.B \-t
  123. X.RI [ device ]
  124. X.SH DESCRIPTION
  125. X.I Multivol
  126. Xallows for the convenient use of multiple volume files such as when
  127. Xbacking up output from 
  128. X.I cpio/tar
  129. Xover several floppy disks.
  130. X.PP
  131. XOption
  132. X.B \-o
  133. Xreads the standard input file, breaking it into volumes on the output device.
  134. XOption
  135. X.BR \-i
  136. Xreads volumes from the device, concatenates them
  137. Xand writes the result to standard output.
  138. X.PP
  139. XThe device to use is given by the
  140. X.I device
  141. Xargument, or
  142. X.I /dev/multivol
  143. Xif none is specified.
  144. XNormally this will be a character special file corresponding to a raw
  145. Xdisk or tape unit.
  146. XIt does not have to be a random access device:
  147. X.I multivol
  148. Xonly accesses it sequentially.
  149. XHowever,
  150. X.I multivol
  151. Xmay close and re-open a volume in order to rewind devices such as magnetic tape.
  152. X.PP
  153. XThe
  154. X.B \-b
  155. X.I blocksize
  156. Xargument specifies the physical block size to be used.
  157. XThis number may end with
  158. X.B k
  159. Xor
  160. X.B b
  161. Xto specify multiplication by
  162. X1024 or 512 respectively.
  163. XWith a floppy disk it can usefully be made the size of one
  164. Xtrack.
  165. XThe default physical block size is 512 bytes.
  166. XIf the device or its driver does not allow successful writing all the way to the
  167. Xend of a physical volume, such as with magnetic tape, the
  168. X.B \-n
  169. X.I count
  170. Xoptions should be used to specify the maximum number of physical blocks
  171. Xto be written on one volume.
  172. X.PP
  173. XThe
  174. X.B \-l
  175. X.I label
  176. Xoption allows the user to supply a short string to be written onto
  177. Xthe volume for identification.
  178. X.PP
  179. XBefore reading or writing a new volume,
  180. X.I multivol
  181. Xprompts on the controlling terminal for the user to insert the appropriate
  182. Xvolume into the physical device and waits for a new-line to be typed.
  183. XWith
  184. X.BR \-i ,
  185. Xif the volume inserted is not a
  186. X.I multivol
  187. Xvolume,
  188. Xis not the next volume in sequence,
  189. Xor does not have the same date stamp as the previous volume,
  190. X.I multivol
  191. Xverifies that you really want to read it.
  192. X.PP
  193. X.I Multivol
  194. Xwrites an \s-2ASCII\s0 header on each volume, 
  195. Xand checksum info in each block
  196. Xhence the actual amount of data stored on each volume will be slightly less
  197. Xthan its physical size.
  198. XThe
  199. X.B \-t
  200. Xoption prints some of this header information on standard error.
  201. XIt includes:
  202. X.IP \(bu
  203. Xthe date that the volume was written
  204. X.IP \(bu
  205. Xthe sequence number of the volume
  206. X.IP \(bu
  207. Xany
  208. X.I label
  209. Xstring supplied at the time the volume was written
  210. X.LP
  211. XIf you specify
  212. X.B \-w
  213. Xwith
  214. X.B \-i
  215. Xor
  216. X.B \-o
  217. X.I multivol
  218. Xassumes the
  219. X.B \-t
  220. Xoption also and
  221. Xasks you to verify that each volume really is the required one.
  222. X.PP
  223. XThe
  224. X.B \-v
  225. Xoption tells
  226. X.I multivol
  227. Xto write various other verbose information on standard error
  228. Xsuch as an indication of how many blocks it has read or written.
  229. X.SH EXAMPLES
  230. XTell me what you know about this volume:
  231. X.br
  232. X    multivol \-t
  233. X.LP
  234. XBackup a directory to the default device:
  235. X.br
  236. X    tar cf \- mydir | multivol \-o
  237. X.sp
  238. Xand retrieve it again:
  239. X.br
  240. X    cd mydir
  241. X.br
  242. X    multivol \-i | tar xf \-
  243. X.LP
  244. XBackup to tape all files changed since last time:
  245. X.br
  246. X    touch /etc/multivoldate1
  247. X.br
  248. X    find / \-newer /etc/multivoldate2 \-print | cpio \-ov |
  249. X.br
  250. X        multivol \-o \-l WEEKLY \-b 20k \-n 1000 /dev/rmt0
  251. X.br
  252. X    mv /etc/multivoldate1 /etc/multivoldate2
  253. X.sp
  254. XRetrieve a file from that backup:
  255. X.br
  256. X    cd /
  257. X.br
  258. X    multivol \-i /dev/rmt0 | cpio \-idmv usr/myname/myfile
  259. X.SH FILES
  260. X.ta \w'/dev/multivol     'u
  261. X.nf
  262. X/dev/tty    where prompts are written and responses read
  263. X.br
  264. X/dev/multivol    the default device
  265. X.SH SEE ALSO
  266. Xtar(1), cpio(1), dd(1), dump(8), ``your device''(4)
  267. X.SH DIAGNOSTICS
  268. X.PP
  269. XA message is written on standard error and
  270. X.I multivol
  271. Xterminates in the event of
  272. X.IP \(bu
  273. Xincorrect usage
  274. X.IP \(bu
  275. Xnot being able to open the device
  276. X.IP \(bu
  277. Xnot being able to open /dev/tty
  278. X.IP \(bu
  279. Xa device I/O error 
  280. X.SH BUGS
  281. XIn the event of an I/O error you may have to start again with the first volume
  282. Xdepending on the nature of the file and the program which produced it.  In
  283. Xmany cases it simply means the end of the volume has been reached, and no more
  284. Xcan be read/written.  If a block limit has been set
  285. X.I multivol
  286. Xwill indicate this condition.
  287. X.PP
  288. XWhen reading or writting,
  289. X.I multivol
  290. Xattempts to read the volumes header to display what is being written over,
  291. Xor to determine the block size recorded in the header.
  292. XSome raw devices will return an I/O error
  293. Xwhen the volume has not been written before, or has been previously written
  294. Xwith a different block size.
  295. XHence the volume header cannot be read until the original
  296. Xblock size is also specified.
  297. XThe first time a volume is written,
  298. X.I multivol
  299. Xmay signal an I/O error as it attempts to read the header, but will proceed 
  300. Xto allow the volume to be written.
  301. X.PP
  302. XVolume labels may not contain white space and are limited to 14 characters.
  303. X.PP
  304. XSome tape device drivers cannot handle a read/write request while the tape
  305. Xis rewinding, for such drivers the
  306. X.B \-w
  307. Xswitch is recommended in place of just
  308. X.B \-t
  309. X\.
  310. !The!End!
  311.  
  312. echo x - "maint.doc" 2>&1
  313. sed "s/^X//" >"maint.doc" <<'!The!End!'
  314. Xmultivol.doc V1.00 01-Jun-85 Tony O'Hagan
  315. X    Documentation on developement of multi-volume backup utility "multivol".
  316. X    Global flags
  317. X1. rd_flag  -i Read each volume -> stdout
  318. X2. wr_flag  -o Write each volume stdin ->
  319. X3. dsp_vol  -t Attempt to read & print each volume header -> stderr
  320. X4. dsp_blks -v Indicate number of blocks read/written -> stderr
  321. X5. vfy_vol  -w Allow user to verify each volume mounted -> stderr /dev/tty ->  
  322. X
  323. XWhen dsp_vol is set the following will be tested :-
  324. XWriting:-
  325. X    * Writing over a volume in the set being tested;
  326. XReading:-
  327. X    * Reading a volume with a time stamp different from first volume read;
  328. X    * Reading volumes out of sequence
  329. X    * Check that label corresponds (if specified)
  330. X
  331. XQueries:-
  332. X    a. What will happen if no blocks have ever been written to the volume
  333. X    and an attempt is made to read the volumes header ?
  334. X==============================================================================
  335. X    multivol V2.00 01-Jul-85 Tony O'Hagan & Tim Roper
  336. XBuffer data structure :-
  337. X
  338. X    First volume block        Other volume blocks
  339. X
  340. X .      ---------------  <- buf_ptr ->     ---------------
  341. X/|\    | block header    | (word aligned)|        |
  342. X |    |---------------|        |        |
  343. X |    |        |        |        |
  344. X |    | volume header    |        |---------------|       .
  345. X |    |        |        | block header    |      /|\
  346. X |     ---------------  <- dta_ptr ->     ---------------    |
  347. X |    |        | (word aligned)|        |    |
  348. X |    |        |             |        |    |
  349. Xblk_siz    |     data    |        |        |    |
  350. X |    |        |        |     data    |    blk_siz
  351. X |    |        |        |        |    |
  352. X\!/    |        |        |        |    |
  353. X     |---------------|               |        |    |
  354. X    |        |        |        |    |
  355. X    |        |        |        |      \!/
  356. X     ---------------         --------------- 
  357. X
  358. X    sizeof(vol_hdr) and sizeof(blk_hdr) must both be an integral number
  359. X    of word alignment units.
  360. X========================================================================
  361. X19-Jul-85  Tony O'Hagan
  362. X    Using /dev/rmt0, doesn't appear to read volume header unless
  363. X    the block size matches the written block size.  I/O failure.
  364. X========================================================================
  365. X 7-Aug-85  Tony O'Hagan
  366. X    Expected lint errors :-        (Perkin-Elmer V7 lint)
  367. X"rd.c", line 150: warning: possible pointer alignment problem
  368. X"rd.c", line 152: warning: possible pointer alignment problem
  369. X"wr.c", line 149: warning: possible pointer alignment problem
  370. X"vhdr.c", line 51: warning: possible pointer alignment problem
  371. X"vhdr.c", line 85: warning: blk_siz redefinition hides earlier one
  372. Xaskf returns value which is always ignored
  373. Xclose returns value which is always ignored
  374. Xfgets returns value which is always ignored
  375. Xmount_v returns value which is sometimes ignored
  376. Xrd_put_ returns value which is always ignored
  377. Xsprintf returns value which is always ignored
  378. Xsscanf returns value which is sometimes ignored
  379. Xstrncpy returns value which is always ignored
  380. Xwrite returns value which is sometimes ignored
  381. X========================================================================
  382. XTony O'Hagan        Australia: (07) 3774125  International: +61 7 3774125
  383. XUniversity of Queensland    CSNET:    tony@uqcspe.oz    ACSnet:    tony@uqcspe.oz
  384. XDept. of Computer Science    UUCP:    ...!seismo!munnari!uqcspe.oz!tony
  385. XSt. Lucia, Brisbane,         ARPA:    tony%uqcspe.oz@seismo.css.gov
  386. XAUSTRALIA  4067             JANET:    uqcspe.oz!tony@ukc
  387. !The!End!
  388.  
  389. echo x - "Makefile" 2>&1
  390. sed "s/^X//" >"Makefile" <<'!The!End!'
  391. XMAKEFILE = Makefile
  392. XTARGET    = multivol
  393. X
  394. X#    USER - user name used for sendfile requests
  395. X#    HOSTS - sendfile hosts
  396. XUSER    = tony
  397. XHOSTS    = pisa rune uq ppse madvax1
  398. X
  399. X#    installation library
  400. XINSTALL = /user0/tony/Bin
  401. X
  402. X#    MISC - misc. files to be listed and sent to other hosts
  403. XMISC    = multivol.8 testdata.c READ_ME maint.doc
  404. XHEADERS    = multivol.h options.h trace.h
  405. XSRC1    = multivol.c rd.c wr.c
  406. XSRC2    = vhdr.c mount.c bcopy.c ask.c error.c trace.c
  407. XSOURCES    = $(SRC1) $(SRC2)
  408. XOBJECTS    = multivol.o rd.o wr.o vhdr.o mount.o ask.o error.o trace.o
  409. XSHSRC    =
  410. X
  411. X#    used to compile in bcopy() if it is not defined on the system
  412. XLIBRARY    = multivol.a
  413. XLIBSRC    = bcopy.c
  414. XLIBOBJ    = bcopy.o
  415. X
  416. X#    **** shar switches ****
  417. XSHAR    = shar -c -b -v
  418. X
  419. X#    **** defaults for compiled code ****
  420. X#    DEFDEV - default device
  421. X#    DEFLIM - default block limit (-1 = no limit)
  422. X#    DEFBSIZ - default block size
  423. XDEFDEV    = /dev/multivol
  424. XDEFBSIZ    = 4096
  425. XDEFBLIM    = -1
  426. X
  427. X#    **** compiler, loader & lint switches ****
  428. X#    DEBUG     - compile in traceing code.
  429. X#    VOLNUM    - read/write to <device>.<vol-number> to test multiple volumes
  430. X#          with files pretending to be device volumes.
  431. X#    REWIND    - manually rewind tape after reading volume header
  432. XDEFINE    = -DDEBUG -Dvoid=int
  433. X#DEFINE    = -Dvoid=int
  434. XLINT    = -p $(DEFINE) 
  435. X#CFLAGS    = -O $(DEFINE)
  436. XCFLAGS    = $(DEFINE)
  437. XLDFLAGS    = -n
  438. X
  439. X#    **** Variables used for Testing ****
  440. X#    TSTFIL - Test file pretending to be a device - see wfile: and rfile:
  441. X#    TSTDEV - Test device
  442. XTSTFIL    = vol
  443. X#    test device
  444. X#TSTDEV    = $(TSTFIL)
  445. XTSTDEV    = $(DEFDEV)
  446. X#TSTDEV    = /dev/flop
  447. X#TSTDEV    = /dev/rx2
  448. X#TSTDEV    = /dev/rmt0
  449. X#TSTDEV    = /dev/fd70
  450. X
  451. X#    Testing utilities use these switches :-
  452. X#    These can be easily individually changed when invoking make
  453. X#    LABEL    - volume label
  454. X#    BLKSIZ    - Block size used in test runs
  455. X#    BLKLIM    - Limit of blocks per volume ( -1 = no limit )
  456. X#    OPT    - other multivol options
  457. XLABEL    = -l testdata_label
  458. XBLKSIZ    = -b $(DEFBSIZ)
  459. XBLKLIM    = -n 10
  460. X#OPT    = -vw
  461. XOPT    = -tD
  462. XRDOPTS    = -i $(OPT) $(BLKLIM) $(LABEL)
  463. XWROPTS    = -o $(OPT) $(BLKSIZ) $(BLKLIM) $(LABEL)
  464. X
  465. X#    OUTDTA    - temporary file for comparing with output from 'testdata'.
  466. X#    TSTSH    - temporary file for storing the last testdata command 
  467. XOUTDTA    = $(TARGET).out
  468. XTSTSH    = $(TARGET).sh
  469. X
  470. X$(TARGET):    $(OBJECTS) $(LIBRARY)
  471. X    $(CC) $(LDFLAGS) -o $(TARGET) $(OBJECTS) -lc $(LIBRARY)
  472. X# for uq PDP11. to use correct ctime() routines.
  473. X#    $(CC) $(LDFLAGS) -o $(TARGET) $(OBJECTS) -lstd -lc $(LIBRARY)
  474. X#    size $@
  475. X
  476. Xmultivol.o:        multivol.c
  477. X    $(CC) $(CFLAGS) -DDEFBSIZ=$(DEFBSIZ) -DDEFBLIM=$(DEFBLIM) \
  478. X            -DDEFDEV='"$(DEFDEV)"' -c multivol.c
  479. X
  480. X$(LIBRARY):    $(LIBOBJ)
  481. X    ar ru $(LIBRARY) $(LIBOBJ)
  482. X#    ranlib $(LIBRARY)
  483. X
  484. Xtestdata:    testdata.o
  485. X    $(CC) $(LDFLAGS) -o testdata testdata.o
  486. X
  487. X#    ******* Testing utilities for multivol *******
  488. Xodfile:
  489. X    od -c $(TSTFIL) | less
  490. X
  491. Xod:
  492. X    od -c $(TSTDEV) | less
  493. X
  494. X# Test displaying volume header of a file
  495. Xtfile:    $(TARGET) 
  496. X    ./$(TARGET) -t $(TSTFIL)
  497. X
  498. X# Test writing of files pretending to be devices - quick test
  499. Xwfile:    testdata $(TARGET) # write data out to file
  500. X    >$(TSTFIL)
  501. X    echo './testdata 1005 xyz 1022 abc' > $(TSTSH)
  502. X    sh $(TSTSH) | ./$(TARGET) $(WROPTS) $(TSTFIL)
  503. X
  504. X# Test reading files pretending to be devices
  505. X# Read file volume and compare output with the last input data written
  506. Xrfile:     $(TARGET)
  507. X    ./$(TARGET) $(RDOPTS) $(TSTFIL) > $(OUTDTA)
  508. X    sh $(TSTSH) | cmp - $(OUTDTA)
  509. X
  510. X# Test re-writing of files pretending to be devices
  511. Xrewfile:    testdata $(TARGET) wfile
  512. X    echo './testdata 4096 zyxwvutsrqponml' > $(TSTSH)
  513. X    sh $(TSTSH) |./$(TARGET) $(WROPTS) $(TSTFIL)
  514. X
  515. X# Test displaying volume header
  516. Xt:    $(TARGET) 
  517. X    ./$(TARGET) -t $(TSTDEV)
  518. X
  519. X# Read volume and compare output with the last input data written
  520. Xr:     $(TARGET)
  521. X    ./$(TARGET) $(RDOPTS) $(TSTDEV) > $(OUTDTA)
  522. X    sh $(TSTSH) | cmp - $(OUTDTA)
  523. X
  524. X# Read volume and count wo
  525. Xro:     $(TARGET)
  526. X    ./$(TARGET) $(RDOPTS) $(TSTDEV)
  527. X
  528. X# Test writing of volumes - quick test
  529. Xw:    testdata $(TARGET) # write data out to device
  530. X    echo './testdata 30 abcdefghi' > $(TSTSH) 
  531. X    sh $(TSTSH) | ./$(TARGET) $(WROPTS) $(TSTDEV)
  532. X
  533. X# Test writing off end of a volume (NCR floppy)
  534. Xwpisa:    testdata $(TARGET) # write data out to device
  535. X    echo './testdata 7680 abcdefghijklmno' > $(TSTSH) 
  536. X    sh $(TSTSH) | ./$(TARGET) $(WROPTS) $(TSTDEV)
  537. X
  538. X# Test writing off end of a volume (NCR floppy)
  539. Xwwords:    testdata $(TARGET) # write data out to device
  540. X    echo 'cat /usr/dict/words' > $(TSTSH) 
  541. X    sh $(TSTSH) | ./$(TARGET) $(WROPTS) $(TSTDEV)
  542. X
  543. X# Read volume and compare output with the last input data written
  544. Xrwords:     $(TARGET)
  545. X    ./$(TARGET) $(RDOPTS) $(TSTDEV) | diff - /usr/dict/words
  546. X
  547. X# Test writing off end of a volume (rune host, 1600 bpi tape)
  548. X#    100 blocks = 4088 * 100 - 68 = 102183 * 4  (4 chars = 'abc\n')
  549. Xwrune:    testdata $(TARGET) # write data out to device
  550. X    echo './testdata 102183 abc' > $(TSTSH) 
  551. X    sh $(TSTSH) | ./$(TARGET) $(WROPTS) -n -1 $(TSTDEV)
  552. X
  553. X# Test writing 2 volume set
  554. Xw2vol:    testdata $(TARGET) # write data out to device
  555. X    echo './testdata 7000 abcdefghi' > $(TSTSH) 
  556. X    sh $(TSTSH) | ./$(TARGET) $(WROPTS) $(TSTDEV)
  557. X
  558. X# Test writing 3 volume set
  559. Xw3vol:    testdata $(TARGET) # write data out to device
  560. X    echo './testdata 12000 abcdefghi' > $(TSTSH) 
  561. X    sh $(TSTSH) | ./$(TARGET) $(WROPTS) $(TSTDEV)
  562. X
  563. X# Test writing off end of a volume
  564. Xwbig:    testdata $(TARGET) # write data out to device
  565. X    echo './testdata 100000 abcdefghijklmno' > $(TSTSH) 
  566. X    sh $(TSTSH) | ./$(TARGET) $(WROPTS) $(TSTDEV)
  567. X
  568. X#    ******* General utilities *******
  569. X
  570. X#    Updates multivol files on other hosts
  571. Xuqcspe $(HOSTS):    $(SOURCES) $(LIBSRC) $(HEADERS) $(MISC) $(MAKEFILE)
  572. X    echo "`date` % $@ $?" >> $@
  573. X    sendfile $(USER)@$@ $@ $?
  574. X
  575. X#    Update all hosts
  576. Xhosts:    $(HOSTS)
  577. X
  578. X#    Retrieves sent files
  579. Xgetfile:
  580. X    getfile -DY
  581. X
  582. X# Sorry, $* doesn't work in our version of make.
  583. Xshar:    $(TARGET)1.shar $(TARGET)2.shar $(TARGET)3.shar $(TARGET)4.shar
  584. X
  585. X$(TARGET)1.shar: $(MISC)
  586. X    $(SHAR) $(MISC) > $@ 
  587. X
  588. X$(TARGET)2.shar: $(HEADERS) $(MAKEFILE) 
  589. X    $(SHAR) $(HEADERS) $(MAKEFILE) > $@ 
  590. X
  591. X$(TARGET)3.shar: $(SRC1)
  592. X    $(SHAR) $(SRC1) > $@
  593. X
  594. X$(TARGET)4.shar: $(SRC2)
  595. X    $(SHAR) $(SRC2) > $@
  596. X
  597. X#    List files updated since last listing
  598. Xlist:    $(SOURCES) $(LIBSRC) $(HEADERS) $(MISC) $(MAKEFILE)
  599. X    echo "`date` % $@ $?" >> $@
  600. X    list $? &
  601. X
  602. Xci:    $(SHSRC) $(SOURCES) $(HEADERS) $(MISC) $(MAKEFILE)
  603. X    ci -l -q $? </dev/null
  604. X    echo "`date` % $@ $?" >> $@
  605. X
  606. Xrun:    $(TARGET)
  607. X    ./$(TARGET)
  608. X
  609. Xvi:
  610. X    vi $(SOURCES) $(LIBSRC) $(HEADERS)
  611. X
  612. Xtags:    $(SOURCES) $(LIBSRC) $(HEADERS)
  613. X    ctags $(SOURCES) $(LIBSRC) $(HEADERS)
  614. X    
  615. Xtidy:
  616. X    rm -f $(OUTDTA) LOG core a.out junk* $(TSTFIL) $(TSTFIL).[0-9] $(TSTSH) 
  617. X
  618. Xclean:        tidy
  619. X    rm -f $(OBJECTS) $(LIBOBJ) $(LIBRARY) testdata testdata.o
  620. X
  621. Xclobber:    clean
  622. X    rm -f $(TARGET)
  623. X
  624. Xlint:
  625. X    lint $(LINT) -hbx -lc $(SOURCES) $(LIBSRC) 2>&1 | tee LOG
  626. X
  627. Xinstall:    $(TARGET)
  628. X    mv $(TARGET) $(INSTALL)
  629. X    chmod 711 $(INSTALL)/$(TARGET)
  630. X
  631. Xerr:
  632. X    error -v LOG
  633. X
  634. Xdepend:
  635. X    sed -n -e '1,/^### DO NOT DELETE THIS LINE./p' < $(MAKEFILE) > $(MAKEFILE).new
  636. X    -for i in $(YACCFILES) $(LEXFILES) $(SOURCES) $(LIBSRC) $(FFILES) ; do\
  637. X        base=`expr $$i ':' '\(.*\).[cylf]$$'`;\
  638. X        suffix=`expr $$i ':' '.*\.\([cylf]\)$$'`;\
  639. X        if /bin/test $$suffix = l ; then\
  640. X            lex $$i;\
  641. X            mv lex.yy.c $$base.c;\
  642. X            suffix=c;\
  643. X            echo "$$base.c:    $$base.l" >> $(MAKEFILE).new;\
  644. X        elif /bin/test $$suffix = y ; then\
  645. X            yacc $(YFLAGS) $$i;\
  646. X            mv y.tab.c $$base.c;\
  647. X            suffix=c;\
  648. X            echo "$$base.c:    $$base.y" >> $(MAKEFILE).new;\
  649. X            echo "y.tab.h:    $$base.y" >> $(MAKEFILE).new;\
  650. X        fi;\
  651. X        $(CC) $(CLOCALFLAGS) -I$(INCLUDE) -E $$base.$$suffix |\
  652. X        grep '^# [0-9][0-9]* ".*"$$' > /tmp/grep$$$$;\
  653. X        sed -e 's/.*"\(.*\)"$$/\1/' -e 's/^.\///' < /tmp/grep$$$$ |\
  654. X        sort -u |\
  655. X        awk\
  656. X            "BEGIN { line=\"$$base.o:    \"}\
  657. X            {\
  658. X                if(length(line \$$0)>63)\
  659. X                {\
  660. X                    print line,\"\\\\\";\
  661. X                    line=\"        \"\$$0\
  662. X                }\
  663. X                else\
  664. X                    line=line\" \"\$$0\
  665. X            }\
  666. X            END { print line}"\
  667. X        >> $(MAKEFILE).new;\
  668. X    done;\
  669. X    rm /tmp/grep$$$$
  670. X    mv $(MAKEFILE).new $(MAKEFILE)
  671. X### The following dependancies are/can be generated automatically
  672. X### by 'make depend'. Listen to this warning
  673. X###
  674. X### Do NOT put any of your own dependancies below this line,
  675. X### they will be removed
  676. X### DO NOT DELETE THIS LINE. USED FOR MAKE DEPEND
  677. Xmultivol.o:     /usr/include/assert.h /usr/include/ctype.h \
  678. X        /usr/include/signal.h /usr/include/stdio.h \
  679. X        /usr/include/sys/param.h /usr/include/sys/types.h multivol.c \
  680. X        multivol.h options.h trace.h
  681. Xrd.o:     /usr/include/assert.h /usr/include/stdio.h multivol.h rd.c \
  682. X        trace.h
  683. Xwr.o:     /usr/include/assert.h /usr/include/ctype.h \
  684. X        /usr/include/errno.h /usr/include/stdio.h \
  685. X        /usr/include/sys/types.h multivol.h trace.h wr.c
  686. Xvhdr.o:     /usr/include/assert.h /usr/include/stdio.h \
  687. X        /usr/include/sys/types.h multivol.h trace.h vhdr.c
  688. Xmount.o:     /usr/include/assert.h /usr/include/ctype.h \
  689. X        /usr/include/stdio.h mount.c multivol.h trace.h
  690. Xask.o:     /usr/include/stdio.h ask.c
  691. Xerror.o:     /usr/include/stdio.h error.c
  692. Xtrace.o:     trace.c
  693. Xbcopy.o:     bcopy.c
  694. !The!End!
  695.  
  696. echo x - "multivol.h" 2>&1
  697. sed "s/^X//" >"multivol.h" <<'!The!End!'
  698. X/* multivol  V1.00  5-Jun-85  Tony O'Hagan
  699. X * multivol (8) - handle multivolume files
  700. X * multivol.h 
  701. X */
  702. X#define PROGNAM    "multivol"
  703. X#define VERSION "1.00"
  704. X#include <assert.h>
  705. X#include "trace.h"
  706. X
  707. X#define export        /* used to import/export globals */
  708. X#define import    extern
  709. X
  710. X#define bool    short
  711. X#define FALSE    0
  712. X#define TRUE    1
  713. X
  714. X#define READ    0
  715. X#define WRITE    1
  716. X/*
  717. X * The size of block & volume headers must be a multiple of
  718. X * of 4 to keep the DMA controllers happy when asked to 
  719. X * read or write a buffer, and to keep this multiple 
  720. X * consistant for volumes being transfered between systems
  721. X * which round up the size of structures to a mulitple of 4.
  722. X */
  723. X#define wd_size    4
  724. X#define    wd_round(x) (( (x) + wd_size-1 ) & ~(wd_size-1))
  725. X#define BHDSIZ    wd_round(sizeof(blk_hdr))    /* Block header size */
  726. X#define VHDSIZ    wd_round(sizeof(vol_hdr))    /* Volume header size */
  727. X#define MINBLK    wd_round(BHDSIZ + VHDSIZ + 1)    /* Minmum block size */
  728. X
  729. X#define    NOLIMIT    -1        /* used when no limit on blocks per volume */
  730. X
  731. X#define BEGBLK    'B'        /* blk_hdr->bh_blk_typ values */
  732. X#define DTABLK    'D'
  733. X#define ENDBLK    'E'
  734. X
  735. X    /* Unpacked volume header */
  736. X#define NULVHD    ((up_vhdr *)NULL)
  737. Xtypedef struct {
  738. X    int    up_vol_num;
  739. X    long    up_siz_blk, up_lim_blk, up_timestamp;
  740. X    char    up_prog_name[15], up_version[5], up_label[15];
  741. X} up_vhdr ;
  742. X
  743. X    /* Volume header (all ascii) */
  744. Xtypedef struct {
  745. X    char    v_volnum[4],sp0;    /* "0001" */
  746. X      char    v_prog[14],sp1;        /* program name */
  747. X    char    v_version[5],sp2;    /* Vn.nn */
  748. X    char    v_label[14],sp3;    /* volume label */
  749. X    char    v_timestamp[10],sp4;    /* binary time stamp */
  750. X    char    v_siz_blk[6], sp5;    /* digits of physical block size */
  751. X    char    v_lim_blk[6];        /* maximum no. of blocks per volume */
  752. X    char    nullch;            /* Null ch placed by sprintf() */
  753. X} vol_hdr;
  754. X
  755. X    /* used to pack/unpack volume headers */
  756. X#define VHDFIELDS    7
  757. X#define VHDPACK        "%4d %-14s %-5s %-14s %10ld %6ld %6ld" 
  758. X#define VHDUNPACK    "%d %s %s %s %ld %ld %ld"
  759. X
  760. X    /* Block header */
  761. Xtypedef struct {
  762. X    char    bh_blktyp;    /* block type - indicates end of volume set */
  763. X    char    bh_chksum;    /* block check sum */
  764. X    char    bh_dtalen[6];    /* amount of data in the block */
  765. X} blk_hdr;
  766. !The!End!
  767.  
  768. echo x - "options.h" 2>&1
  769. sed "s/^X//" >"options.h" <<'!The!End!'
  770. X/*
  771. X *    Option processing.
  772. X *
  773. X *    Conforms to intro(1) in System V.
  774. X *
  775. X *    Typical layout:
  776. X *
  777. X *        OPTIONS ("-b -t c -f file -w N file ...")
  778. X *            FLAG    ('b', flag)
  779. X *            CHAR    ('t', tab_ch)
  780. X *            STRING    ('f', filename)
  781. X *                f = fopen(filename, "r");
  782. X *            NUMBER    ('w', width)
  783. X *        ENDOPTS
  784. X */
  785. Xchar    *O_name, *O_usage;
  786. X
  787. Xvoid
  788. Xusage()
  789. X{
  790. X    /*
  791. X     * Poor man's version of:
  792. X     *
  793. X     *    fprintf(stderr, "Usage: %s %s\n", O_name, O_usage);
  794. X     */
  795. X    write(2, "Usage: ", 7);
  796. X    write(2, O_name, strlen(O_name));
  797. X    write(2, " ", 1);
  798. X    write(2, O_usage, strlen(O_usage));
  799. X    write(2, "\n", 1);
  800. X    exit(1);
  801. X}
  802. X
  803. X/*
  804. X *    An argument "-" is interpreted as a program argument and stops
  805. X *    option processing.
  806. X *
  807. X *    An argument "--" stops option processing and is discarded.
  808. X *
  809. X *    An option which takes an argument uses either the rest of the
  810. X *    the current argument, or, if at the end of an argument, the
  811. X *    next argument.
  812. X */
  813. X#define OPTIONS(usage)                            \
  814. X    O_usage = usage;                        \
  815. X    O_name = argv[0];                        \
  816. X    while (*++argv && **argv == '-' && argv[0][1]) {        \
  817. X        register int O_cont = 1;                \
  818. X                                    \
  819. X        argc--;                            \
  820. X        if (argv[0][1] == '-' && argv[0][2] == '\0') {        \
  821. X            argv++;                        \
  822. X            break;                        \
  823. X        }                            \
  824. X        while (O_cont)                        \
  825. X            switch (*++*argv) {                \
  826. X            case '\0':                    \
  827. X                O_cont = 0;
  828. X
  829. X# define FLAG(c,flag)    break;                        \
  830. X            case c:                        \
  831. X                flag = 1;
  832. X
  833. X# define NUMBER(c,num)    break;                        \
  834. X            case c:                        \
  835. X                if (*++*argv == '\0') {            \
  836. X                    if (--argc == 0)        \
  837. X                        usage();        \
  838. X                    argv++;                \
  839. X                }                    \
  840. X                num = atol(*argv);            \
  841. X                O_cont = 0;
  842. X
  843. X# define STRING(c,str)    break;                        \
  844. X            case c:                        \
  845. X                if (*++*argv == '\0') {            \
  846. X                    if (--argc == 0)        \
  847. X                        usage();        \
  848. X                    argv++;                \
  849. X                }                    \
  850. X                str = *argv;                \
  851. X                O_cont = 0;
  852. X
  853. X# define CHAR(c,ch)    break;                        \
  854. X            case c:                        \
  855. X                if (*++*argv == '\0') {            \
  856. X                    if (--argc == 0)        \
  857. X                        usage();        \
  858. X                    argv++;                \
  859. X                }                    \
  860. X                ch = **argv;                \
  861. X                O_cont = 0;
  862. X
  863. X# define ENDOPTS    break;                        \
  864. X            default:                    \
  865. X                usage();                \
  866. X            }                        \
  867. X    }                                \
  868. X    *--argv = O_name;
  869. !The!End!
  870.  
  871. echo x - "trace.h" 2>&1
  872. sed "s/^X//" >"trace.h" <<'!The!End!'
  873. X/* use tracef() as tracef((tr, <format>, <format-args> ... )); */
  874. X#ifdef DEBUG
  875. X    extern int    tron;
  876. X    extern char    tr[];
  877. X#    define trace(step) strace(__FILE__, __LINE__, step)
  878. X#    define tracef(step) {sprintf step; trace(tr);}
  879. X#else
  880. X#    define trace(step)
  881. X#    define tracef(step)
  882. X#endif
  883. !The!End!
  884. exit
  885.