Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!gem.mps.ohio-state.edu!ginosko!rex!mgse!marks From: marks@mgse.UUCP (Mark Seiffert) Newsgroups: comp.os.minix Subject: Re: POSIX compatible tar(1) Summary: bug fixes Message-ID: <1002@mgse.UUCP> Date: 25 Sep 89 17:37:42 GMT References: <261@nikhefh.nikhef.nl> Reply-To: marks@mgse.UUCP (Mark Seiffert) Organization: mgse Lines: 173 In article <261@nikhefh.nikhef.nl> Schutte@nikhefh.nikhef.nl (Klamer Schutte) writes: >Here is a new version of tar(1). > I do not have minix yet, i have the book, but there seem to be a few utilites missing, not enough to bother typing it it, when i get a job again i hope to get minix (unless i can find someone to give me a copy in the meantime), what i can't understand yet is how you people plan on backing up your systems. Is there tape backup software for the PC or ST versions yet? What would be the best way to have this tar program prompt the user to switch disks (or tape) when it is full? Under Xenix tar the 'k' option followed by a numeric argument tells tar how big a volume is and the user is prompted for another volume when the current one is full. Is this POSIX compliant? how type code would be used in the headerblock, is that what CONTTYPE is for? Here is a shar file with a note of what i have done, and a diff of the changes i made. I think this will all be portable to Minix, please let me know if it is not. #! /bin/sh # This is a shell archive. Remove anything before this line, then feed it # into a shell via "sh file" or similar. To overwrite existing files, # type "sh file -c". # The tool that generated this appeared in the comp.sources.unix newsgroup; # send mail to comp-sources-unix@uunet.uu.net if you want that tool. # If this archive is complete, you will see the following message at the end: # "End of shell archive." # Contents: note.mgs tar.c.diff # Wrapped by root@mgse on Mon Sep 25 12:35:06 1989 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'note.mgs' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'note.mgs'\" else echo shar: Extracting \"'note.mgs'\" \(1480 characters\) sed "s/^X//" >'note.mgs' <<'END_OF_FILE' XThis is to document the changes i have made to the POSIX tar utility Xposted by n62@nikhefh.nikhef.nl (Klamer Schutte). Some stuff was added Xso it would compile under SCO Xenix 286 rel. 2.2.1, most notably was Xthe need to a mkfifo() function. I have noted three bugs so far, and Xfixed two. The tar.c.diff contains the patches i have made so far. I Xwould love to find out just what POSIX means as far as a tar utility Xis concerned. X X1) tar will back itself up, should check archive inode num(&dev) Xand then check the target inode number. We should issue a warning Xand ignore target. X X Made changes to main() to get the archive inode number and Xdevice with a stat() call. this is saved in the global variables Xar_inode and ar_dev. The type declarations for ar_inode and ar_dev Xare from the SCO Xenix stat.h man page, I am not sure that this is Xportable to Minix. Changes were made to add_file() to check the Xtarget files device and inode against the archive numbers. The Xarchive inode (ar_inode) is initialized to zero (0), since the root Xinode is 2 this should not cause a problem. I seem to remember Xsomething about inode 0 or 1 being for the superblock or boot block. XIf the archive file is stdout, ar_inode and ar_dev remain at zero. X X2) tar will not notice that a file has changed size while it Xwas being backed up. should issue warning. X X3) the 'f' option was not documented in usage[]. X X changed both usage[] defines. Why are there two (one is Xcommented out)? END_OF_FILE echo shar: NEWLINE appended to \"'note.mgs'\" if test 1481 -ne `wc -c <'note.mgs'`; then echo shar: \"'note.mgs'\" unpacked with wrong size! fi # end of 'note.mgs' fi if test -f 'tar.c.diff' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'tar.c.diff'\" else echo shar: Extracting \"'tar.c.diff'\" \(2537 characters\) sed "s/^X//" >'tar.c.diff' <<'END_OF_FILE' X14a15,21 X> /* X> 1) tar will back itself up, should check archive inode num(&dev) and X> then check the target inode number. In verbose mode, issue X> warning, in all cases ignore target. X> marks@mgse Mon Sep 25 10:38:58 CDT 1989 X> added global varaibles, made changes to main() and add_file(); X> maks@mgse Mon Sep 25 12:09:20 CDT 1989 X15a23,31 X> 2) tar will not notice that a file has changed size while it was being X> backed up. should issue warning. X> marks@mgse Mon Sep 25 10:38:58 CDT 1989 X> X> 3) the 'f' option was not documented in usage[]. X> marks@mgse Mon Sep 25 12:03:20 CDT 1989 X> changed both usage[] defines. Why are there two (one is commented out)? X> */ X> X29a46,51 X> #if defined(M_XENIX) /* is this Xenix? */ X> #ifdef HAVE_FIFO /* yes, should we include FIFO code? */ X> #define NEED_MKFIFO /* yes, we don't have mkfifo() */ X> #endif X> #endif /* marks@mgse Mon Sep 25 10:06:08 CDT 1989 */ X> X94,95c116,117 X< /* char usage[] = "Usage: tar [cxt] tarfile [files]."; */ X< char usage[] = "Usage: tar [cxt][vo][F] tarfile [files]."; X--- X> /* char usage[] = "Usage: tar [cxt][f] tarfile [files]."; */ X> char usage[] = "Usage: tar [cxt][vo][F][f] tarfile [files]."; X107a130,133 X> /* make sure we don't tar ourselves. marks@mgse Mon Sep 25 12:06:28 CDT 1989 */ X> ino_t ar_inode; /* archive inode number */ X> dev_t ar_dev; /* archive device number */ X> X126a153 X> struct stat st; X170a198,206 X> ar_inode = ar_dev = 0; /* init ar_inode & ar_dev */ X> X> if (tar_fd > 1 && stat(argv[2], &st) < 0) X> error("Can't stat ", argv[2]); /* will never be here, right? */ X> else { /* get archive inode & device */ X> ar_inode= st.st_ino; /* save files inode */ X> ar_dev = st.st_dev; /* save files device */ X> } /* marks@mgse Mon Sep 25 11:30:45 CDT 1989 */ X> X488a525,527 X> /* X> * add a file to the archive X> */ X496a536 X> char *getcwd(); /* marks@mgse Mon Sep 25 10:06:08 CDT 1989 */ X501a542,547 X> X> if (st.st_dev == ar_dev && st.st_ino == ar_inode) { X> string_print(NIL_PTR, "Cannot tar current archive file (%s)\n", file); X> return; X> } /* marks@mgse Mon Sep 25 12:06:28 CDT 1989 */ X> X597a644,646 X> /* X> * open file 'file' to be added to archive, return file descripto X> */ X819a869,876 X> #ifdef NEED_MKFIFO /* do we need a mkfifo() function? */ X> mkfifo(filename, perms) X> char *filename; /* name of fifo special file */ X> int perms; /* perms for file */ X> { X> return( mknod(filename, S_IFIFO | perms, 0) ); X> } X> #endif /* marks@mgse Mon Sep 25 10:06:08 CDT 1989 */ END_OF_FILE echo shar: NEWLINE appended to \"'tar.c.diff'\" if test 2538 -ne `wc -c <'tar.c.diff'`; then echo shar: \"'tar.c.diff'\" unpacked with wrong size! fi # end of 'tar.c.diff' fi echo shar: End of shell archive. exit 0 >Klamer Schutte mcvax!nikhefh!{n62,Schutte} {Schutte,n62}@nikhef.nl -- Mark Seiffert, Metairie, LA. uucp: rex!mgse!marks bitnet: marks%mgse@REX.CS.TULANE.EDU internet: marks%mgse@rex.cs.tulane.edu