bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GNU cpio suggestion


From: H.J.Thomassen
Subject: GNU cpio suggestion
Date: Mon, 17 Dec 2001 11:27:11 +0100
User-agent: Mutt/1.2.5i

Re: suggestion for GNU-cpio extension (plus reference implementation)

We use cpio for our backup purposes. The backup is started automatically
in the middle of the night. To chase away all users we do a reboot first,
and one of the rc-scripts then checks whether a backup must be done.
So: cpio runs from an rc-script, and thus without a controlling tty.

Recently we bought a tape-changing device, and now we want to use
the multi-volume facility of cpio (loosely speaking: the -M flag).
But this does not work, because -M uses "/dev/tty" and, as said above,
we do not have a controlling tty when running from an rc-script.
This is apart from the fact that, being a small company, we do not
have a human operator to change tapes in the middle of the night.
That's why we bought the automatic changer-device in the first place.
This device has separate (shell level) commands to control the medium
change (basically these are variations to the classic "mt" command).
We use the mtx-package (http://sourceforge.net/projects/mtx/) for this.

The tar command has a facility to start a script when a medium change
is needed. We wanted the same facility for cpio. It turned out to be
extremely easy to implement: about 20 lines of C code to be added to the
get_next_reel() routine of the util.c file, and no other change elsewhere.

Attached to this mail is the source text of my modified get_next_reel()
routine from util.c. The whole routine is about 120 text lines long
(20 of which are new code) so I figured that that would not be a burden
to your mailbox. I started from a source that I downloaded from the
GNU-website recently (cpio-2.4.2). I adhered to the existing style
of indenting and the positioning of curly brackets.

As for the command interface: to minimise the changes I have chosen
the following mechanism: if the -M string starts with the characters :!
then the rest of the string is the name of a script to execute.
This script will be called with the reel number as a parameter. I use the
system(3) routine, so the cpio program continues when the script finishes.

My rationale for the choice of this :! notation is as follows.
First I looked whether I could copy the tar-way of doing this. But tar
uses the -F flag, which (already) has an entirely different meaning in cpio.
My choice of :! as a trigger in the -M message was then inspired by the
shell-escape notation in vi. It would be closer to the UNIX-tradition to
start with a single ! only, but I am afraid that many people stuff their
existing messages with exclamationmarks, so a starting ! would give more
risk to break existing scripts. E.g. Spanish speaking people are used to
an inverted exclamation mark *at the beginning* of a text, and might
approximate that in an ASCII-only environment with a normal exclamationmark.
To keep things simple, my :! message does not support %d (but support for
%d is unharmed if -M is used in the traditional way).

I hope that this is of use to all users of cpio,
Sincerely
-- 
Hendrik-Jan Thomassen
<address@hidden> http://www.ATComputing.nl/images/pasfotos/hjt.jpg
AT Computing    P.O. Box 1428   6501 BK Nijmegen    The Netherlands
Office tel.+31-24-3527252 (fax +31-24-3527292)
Home   tel.+31-24-3446250 (fax +31-24-3441298)

Attachment: getnextreel
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]