jik@athena.mit.edu (Jonathan I. Kamens) (12/06/90)
Below is official patch number 11 for undel2, in volume 22 of the comp.sources.unix archives. It was submitted to comp.sources.unix on October 15, but it hasn't been posted there yet, so I am making it available elsewhere. When the shar archive below is unpacked, it will produce the file delete.patch11, which should be applied in the undel source directory using "patch -p0". The following changes have been made for patch 11. Fred Hucht (fred@hal9000.uni-duisburg.de) gets credit for the changes which are marked by "(fred)", although if there's anything wrong with any of them, it's my fault. 1. One minor change to the Makefile's AFS support. If you don't use AFS, this shouldn't matter to you. 2. Delete will now recognize when it is linked to "rm", "rmdir" or "rd" (equivalent to "rmdir") and set command-line options accordingly. (fred) 3. If the above link emulation is in effect, the usage message printed by delete changes to reflect what it is being invoked as. 4. When determining how old a file is in lsdel and expunge, the ctime of the file is used, rather than the mtime. This way, time to expunge is measured from the time the file was "delete"d, rather than from the time it was last modified by the user. (fred) 5. One declaration of "char *realloc()" should have been "extern char *realloc()". (fred) 6. Lsdel had a bug in file counting similar to a bug which was fixed in expunge over a year ago; this bug might cause it to miss some files. (fred) 7. Some variants of malloc() et al return NULL if you realloc() to size 0, and delete et al will not cope well with that at all. Special casing of error-checking for 0-sized data fixes this. (fred) 8. A typo in the expunge man page -- "too" should have been "to". 9. The expunge and lsdel man pages are updated to reflect the choice of ctime over mtime. -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: delete.patch11 # Wrapped by jik@pit-manager on Wed Dec 5 16:04:47 1990 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'delete.patch11' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'delete.patch11'\" else echo shar: Extracting \"'delete.patch11'\" \(8024 characters\) sed "s/^X//" >'delete.patch11' <<'END_OF_FILE' X*** /tmp/delete/Makefile Mon Oct 15 22:35:41 1990 X--- Makefile Mon Oct 15 22:57:50 1990 X*************** X*** 22,28 **** X # These variables apply only if you want this program to recognize X # Andrew File System mount points. If you don't want to support AFS, X # then set all the variables starting with "AFS" to nothing. X! AFSBLD= bld X AFSINC= /afs/athena.mit.edu/astaff/project/afsdev/sandbox/$(AFSBLD)/dest/include X AFSLIB= /afs/athena.mit.edu/astaff/project/afsdev/sandbox/$(AFSBLD)/dest/lib X AFSINCS= -I$(AFSINC) X--- 22,28 ---- X # These variables apply only if you want this program to recognize X # Andrew File System mount points. If you don't want to support AFS, X # then set all the variables starting with "AFS" to nothing. X! AFSBLD= bld.3.0 X AFSINC= /afs/athena.mit.edu/astaff/project/afsdev/sandbox/$(AFSBLD)/dest/include X AFSLIB= /afs/athena.mit.edu/astaff/project/afsdev/sandbox/$(AFSBLD)/dest/lib X AFSINCS= -I$(AFSINC) X*** /tmp/delete/delete.c Mon Oct 15 22:35:42 1990 X--- delete.c Mon Oct 15 22:57:55 1990 X*************** X*** 73,79 **** X X X int force, interactive, recursive, noop, verbose, filesonly, directoriesonly; X! int emulate_rm; X extern int errno; X X main(argc, argv) X--- 73,79 ---- X X X int force, interactive, recursive, noop, verbose, filesonly, directoriesonly; X! int emulate_rm, linked_to_rm, linked_to_rmdir; X extern int errno; X X main(argc, argv) X*************** X*** 89,95 **** X initialize_del_error_table(); X X force = interactive = recursive = noop = verbose = filesonly = X! directoriesonly = emulate_rm = 0; X while ((arg = getopt(argc, argv, "efirnvFD")) != -1) { X switch (arg) { X case 'r': X--- 89,101 ---- X initialize_del_error_table(); X X force = interactive = recursive = noop = verbose = filesonly = X! directoriesonly = emulate_rm = linked_to_rm = linked_to_rmdir = 0; X! X! if (!strcmp(whoami, "rm")) X! emulate_rm++, filesonly++, linked_to_rm++; X! if (!strcmp(whoami, "rmdir") || !strcmp(whoami, "rd")) X! emulate_rm++, directoriesonly++, linked_to_rmdir++; X! X while ((arg = getopt(argc, argv, "efirnvFD")) != -1) { X switch (arg) { X case 'r': X*************** X*** 168,183 **** X { X printf("Usage: %s [ options ] filename ...\n", whoami); X printf("Options are:\n"); X! printf(" -r recursive\n"); X printf(" -i interactive\n"); X printf(" -f force\n"); X printf(" -n noop\n"); X printf(" -v verbose\n"); X! printf(" -F files only\n"); X! printf(" -D directories only\n"); X printf(" -- end options and start filenames\n"); X! printf("-r and -D are mutually exclusive\n"); X! printf("-F and -D are mutually exclusive\n"); X } X X X--- 174,195 ---- X { X printf("Usage: %s [ options ] filename ...\n", whoami); X printf("Options are:\n"); X! if (! linked_to_rmdir) X! printf(" -r recursive\n"); X printf(" -i interactive\n"); X printf(" -f force\n"); X printf(" -n noop\n"); X printf(" -v verbose\n"); X! if (! (linked_to_rmdir || linked_to_rm)) { X! printf(" -e emulate rm/rmdir\n"); X! printf(" -F files only\n"); X! printf(" -D directories only\n"); X! } X printf(" -- end options and start filenames\n"); X! if (! (linked_to_rmdir || linked_to_rm)) { X! printf("-r and -D are mutually exclusive\n"); X! printf("-F and -D are mutually exclusive\n"); X! } X } X X X*** /tmp/delete/util.c Mon Oct 15 22:35:46 1990 X--- util.c Mon Oct 15 22:58:22 1990 X*************** X*** 239,245 **** X filerec *file_ent; X time_t current_time, min_days; X { X! if ((current_time - file_ent->specs.st_mtime) / 86400 >= min_days) X return(1); X else X return(0); X--- 239,245 ---- X filerec *file_ent; X time_t current_time, min_days; X { X! if ((current_time - file_ent->specs.st_ctime) / 86400 >= min_days) X return(1); X else X return(0); X*** /tmp/delete/lsdel.c Mon Oct 15 22:35:48 1990 X--- lsdel.c Mon Oct 15 22:58:06 1990 X*************** X*** 41,47 **** X #include "delete_errs.h" X #include "errors.h" X X! char *realloc(); X extern time_t current_time; X extern int errno; X X--- 41,47 ---- X #include "delete_errs.h" X #include "errors.h" X X! extern char *realloc(); X extern time_t current_time; X extern int errno; X X*************** X*** 233,239 **** X char **files; X int num; X { X! int i; X filerec *leaf; X X for (i = 0; i < num; i++) { X--- 233,239 ---- X char **files; X int num; X { X! int i, skipped = 0; X filerec *leaf; X X for (i = 0; i < num; i++) { X*************** X*** 244,256 **** X free(files[i]); X if (! timed_out(leaf, current_time, timev)) { X free_leaf(leaf); X! num--; X continue; X } X block_total += leaf->specs.st_blocks; X } X free((char *) files); X! return(num); X } X X X--- 244,256 ---- X free(files[i]); X if (! timed_out(leaf, current_time, timev)) { X free_leaf(leaf); X! skipped++; X continue; X } X block_total += leaf->specs.st_blocks; X } X free((char *) files); X! return(num-skipped); X } X X X*************** X*** 343,349 **** X *number -= offset; X files = (char **) realloc((char *) files, X (unsigned) (sizeof(char *) * *number)); X! if (! files) { X set_error(errno); X error("realloc"); X return errno; X--- 343,349 ---- X *number -= offset; X files = (char **) realloc((char *) files, X (unsigned) (sizeof(char *) * *number)); X! if ((*number != 0) && (! files)) { X set_error(errno); X error("realloc"); X return errno; X*** /tmp/delete/stack.c Mon Oct 15 22:35:49 1990 X--- stack.c Mon Oct 15 22:58:16 1990 X*************** X*** 119,125 **** X if (newsize < size) { X size = newsize; X stack = (caddr_t) realloc((char *) stack, (unsigned) size); X! if (! stack) { X set_error(errno); X error("realloc"); X #ifdef STACK_DEBUG X--- 119,125 ---- X if (newsize < size) { X size = newsize; X stack = (caddr_t) realloc((char *) stack, (unsigned) size); X! if ((size != 0) && (! stack)) { X set_error(errno); X error("realloc"); X #ifdef STACK_DEBUG X*** /tmp/delete/man1/expunge.1 Mon Oct 15 22:33:01 1990 X--- man1/expunge.1 Mon Oct 15 22:56:30 1990 X*************** X*** 99,110 **** X option, this option prevents X .I expunge X from prompting for confirmation after listing all the files that are X! too be deleted. Furthermore, it prevents the printing of error X messages. X .TP X .B \-t\fIn\fR X Specifies the minimum age (in days) of files to be expunged, measured X! as the length of time since the last file modification. X .TP X .B \-n X No file expunges are performed. Instead, X--- 99,111 ---- X option, this option prevents X .I expunge X from prompting for confirmation after listing all the files that are X! to be deleted. Furthermore, it prevents the printing of error X messages. X .TP X .B \-t\fIn\fR X Specifies the minimum age (in days) of files to be expunged, measured X! as the length of time since the file was X! .IR delete d. X .TP X .B \-n X No file expunges are performed. Instead, X*** /tmp/delete/man1/lsdel.1 Mon Oct 15 22:33:02 1990 X--- man1/lsdel.1 Mon Oct 15 22:56:32 1990 X*************** X*** 55,62 **** X The X .BR \-t X option allows the user to specify a minimum age, in days, of files to X! list. Only files that have not been modified in \fIn\fR days or more X! will be listed. X .PP X The X .BR \-s X--- 55,63 ---- X The X .BR \-t X option allows the user to specify a minimum age, in days, of files to X! list. Only files that were X! .IR delete d X! \fIn\fR days or more ago will be listed. X .PP X The X .BR \-s X*** /tmp/,RCSt1005570 Mon Oct 15 23:27:06 1990 X--- PATCHLEVEL Mon Oct 15 23:03:35 1990 X*************** X*** 1 **** X! 10 X--- 1 ---- X! 11 END_OF_FILE if test 8024 -ne `wc -c <'delete.patch11'`; then echo shar: \"'delete.patch11'\" unpacked with wrong size! fi # end of 'delete.patch11' fi echo shar: End of shell archive. exit 0