CVS commit: src/bin/rm
Module Name:src Committed By: sevan Date: Fri Aug 12 02:26:42 UTC 2016 Modified Files: src/bin/rm: rm.1 Log Message: Document the version rm first appeared. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/bin/rm/rm.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/rm
Module Name:src Committed By: sevan Date: Fri Aug 12 02:26:42 UTC 2016 Modified Files: src/bin/rm: rm.1 Log Message: Document the version rm first appeared. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/bin/rm/rm.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/rm/rm.1 diff -u src/bin/rm/rm.1:1.27 src/bin/rm/rm.1:1.28 --- src/bin/rm/rm.1:1.27 Fri Apr 26 19:34:34 2013 +++ src/bin/rm/rm.1 Fri Aug 12 02:26:42 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: rm.1,v 1.27 2013/04/26 19:34:34 wiz Exp $ +.\" $NetBSD: rm.1,v 1.28 2016/08/12 02:26:42 sevan Exp $ .\" .\" Copyright (c) 1990, 1993, 1994, 2003 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)rm.1 8.5 (Berkeley) 12/5/94 .\" -.Dd April 26, 2013 +.Dd August 12, 2016 .Dt RM 1 .Os .Sh NAME @@ -190,6 +190,11 @@ magnetic disk. .Em Because these requirements are not met, the .Fl P .Em option does not conform to the standard . +.Sh HISTORY +An +.Nm +utility appeared in +.At v1 . .Sh BUGS The .Fl P
CVS commit: src/bin/rm
Module Name:src Committed By: christos Date: Fri Apr 26 18:43:23 UTC 2013 Modified Files: src/bin/rm: rm.1 rm.c Log Message: PR/47770: Eitan Adler: add x flag to rm to avoid cross mount points To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/bin/rm/rm.1 cvs rdiff -u -r1.52 -r1.53 src/bin/rm/rm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/rm/rm.1 diff -u src/bin/rm/rm.1:1.25 src/bin/rm/rm.1:1.26 --- src/bin/rm/rm.1:1.25 Sat Oct 13 10:18:16 2012 +++ src/bin/rm/rm.1 Fri Apr 26 14:43:22 2013 @@ -1,4 +1,4 @@ -.\ $NetBSD: rm.1,v 1.25 2012/10/13 14:18:16 njoly Exp $ +.\ $NetBSD: rm.1,v 1.26 2013/04/26 18:43:22 christos Exp $ .\ .\ Copyright (c) 1990, 1993, 1994, 2003 .\ The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\ .\ @(#)rm.1 8.5 (Berkeley) 12/5/94 .\ -.Dd August 25, 2006 +.Dd April 26, 2013 .Dt RM 1 .Os .Sh NAME @@ -41,7 +41,7 @@ .Sh SYNOPSIS .Nm .Op Fl f | Fl i -.Op Fl dPRrvW +.Op Fl dPRrvWx .Ar .Sh DESCRIPTION The @@ -110,6 +110,8 @@ to be verbose, showing files as they are Attempts to undelete the named files. Currently, this option can only be used to recover files covered by whiteouts. +.It Fl x +When removing a hierarchy, do not cross mount points. .El .Pp The @@ -189,7 +191,9 @@ utility is expected to be compatible. The .Fl v -option is an extension. +and +.Fl x +options are extensions. .Pp The .Fl P Index: src/bin/rm/rm.c diff -u src/bin/rm/rm.c:1.52 src/bin/rm/rm.c:1.53 --- src/bin/rm/rm.c:1.52 Wed Jun 13 03:35:37 2012 +++ src/bin/rm/rm.c Fri Apr 26 14:43:22 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: rm.c,v 1.52 2012/06/13 07:35:37 dholland Exp $ */ +/* $NetBSD: rm.c,v 1.53 2013/04/26 18:43:22 christos Exp $ */ /*- * Copyright (c) 1990, 1993, 1994, 2003 @@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = @(#)rm.c 8.8 (Berkeley) 4/27/95; #else -__RCSID($NetBSD: rm.c,v 1.52 2012/06/13 07:35:37 dholland Exp $); +__RCSID($NetBSD: rm.c,v 1.53 2013/04/26 18:43:22 christos Exp $); #endif #endif /* not lint */ @@ -61,6 +61,7 @@ __RCSID($NetBSD: rm.c,v 1.52 2012/06/13 #include unistd.h static int dflag, eval, fflag, iflag, Pflag, stdin_ok, vflag, Wflag; +static int xflag; static sig_atomic_t pinfo; static int check(char *, char *, struct stat *); @@ -94,8 +95,8 @@ main(int argc, char *argv[]) setprogname(argv[0]); (void)setlocale(LC_ALL, ); - Pflag = rflag = 0; - while ((ch = getopt(argc, argv, dfiPRrvW)) != -1) + Pflag = rflag = xflag = 0; + while ((ch = getopt(argc, argv, dfiPRrvWx)) != -1) switch (ch) { case 'd': dflag = 1; @@ -118,6 +119,9 @@ main(int argc, char *argv[]) case 'v': vflag = 1; break; + case 'x': + xflag = 1; + break; case 'W': Wflag = 1; break; @@ -175,6 +179,8 @@ rm_tree(char **argv) flags |= FTS_NOSTAT; if (Wflag) flags |= FTS_WHITEOUT; + if (xflag) + flags |= FTS_XDEV; if ((fts = fts_open(argv, flags, NULL)) == NULL) err(1, fts_open failed); while ((p = fts_read(fts)) != NULL) { @@ -591,7 +597,7 @@ static void usage(void) { - (void)fprintf(stderr, usage: %s [-f|-i] [-dPRrvW] file ...\n, + (void)fprintf(stderr, usage: %s [-f|-i] [-dPRrvWx] file ...\n, getprogname()); exit(1); /* NOTREACHED */
CVS commit: src/bin/rm
Module Name:src Committed By: wiz Date: Fri Apr 26 19:34:34 UTC 2013 Modified Files: src/bin/rm: rm.1 Log Message: Sort sections. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/bin/rm/rm.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/rm/rm.1 diff -u src/bin/rm/rm.1:1.26 src/bin/rm/rm.1:1.27 --- src/bin/rm/rm.1:1.26 Fri Apr 26 18:43:22 2013 +++ src/bin/rm/rm.1 Fri Apr 26 19:34:34 2013 @@ -1,4 +1,4 @@ -.\ $NetBSD: rm.1,v 1.26 2013/04/26 18:43:22 christos Exp $ +.\ $NetBSD: rm.1,v 1.27 2013/04/26 19:34:34 wiz Exp $ .\ .\ Copyright (c) 1990, 1993, 1994, 2003 .\ The Regents of the University of California. All rights reserved. @@ -146,31 +146,6 @@ can be accomplished as follows: or .Pp .Ic rm ./-file -.Sh SEE ALSO -.Xr rmdir 1 , -.Xr undelete 2 , -.Xr unlink 2 , -.Xr fts 3 , -.Xr getopt 3 , -.Xr symlink 7 -.Sh BUGS -The -.Fl P -option assumes that the underlying file system is a fixed-block file -system. -FFS is a fixed-block file system, LFS is not. -In addition, only regular files are overwritten, other types of files -are not. -Recent research indicates that as many as 35 overwrite passes with -carefully chosen data patterns may be necessary to actually prevent -recovery of data from a magnetic disk. -Thus the -.Fl P -option is likely both insufficient for its design purpose and far -too costly for default operation. -However, it will at least prevent the recovery of data from FFS -volumes with -.Xr fsdb 8 . .Sh COMPATIBILITY The .Nm @@ -183,6 +158,13 @@ Also, historical .Bx implementations prompted on the standard output, not the standard error output. +.Sh SEE ALSO +.Xr rmdir 1 , +.Xr undelete 2 , +.Xr unlink 2 , +.Xr fts 3 , +.Xr getopt 3 , +.Xr symlink 7 .Sh STANDARDS The .Nm @@ -208,3 +190,21 @@ magnetic disk. .Em Because these requirements are not met, the .Fl P .Em option does not conform to the standard . +.Sh BUGS +The +.Fl P +option assumes that the underlying file system is a fixed-block file +system. +FFS is a fixed-block file system, LFS is not. +In addition, only regular files are overwritten, other types of files +are not. +Recent research indicates that as many as 35 overwrite passes with +carefully chosen data patterns may be necessary to actually prevent +recovery of data from a magnetic disk. +Thus the +.Fl P +option is likely both insufficient for its design purpose and far +too costly for default operation. +However, it will at least prevent the recovery of data from FFS +volumes with +.Xr fsdb 8 .
CVS commit: src/bin/rm
Module Name:src Committed By: christos Date: Fri Apr 26 18:43:23 UTC 2013 Modified Files: src/bin/rm: rm.1 rm.c Log Message: PR/47770: Eitan Adler: add x flag to rm to avoid cross mount points To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/bin/rm/rm.1 cvs rdiff -u -r1.52 -r1.53 src/bin/rm/rm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/rm
Module Name:src Committed By: wiz Date: Fri Apr 26 19:34:34 UTC 2013 Modified Files: src/bin/rm: rm.1 Log Message: Sort sections. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/bin/rm/rm.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/rm
Module Name:src Committed By: dholland Date: Wed Jun 13 07:35:37 UTC 2012 Modified Files: src/bin/rm: rm.c Log Message: Rectify race condition in rm -P processing by checking that the file we opened is the one we expected to get. Also use O_NOFOLLOW to help avoid even opening devices, which sometimes produce side effects. Reported by Radoslaw A. Zarzynski. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/bin/rm/rm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/rm/rm.c diff -u src/bin/rm/rm.c:1.51 src/bin/rm/rm.c:1.52 --- src/bin/rm/rm.c:1.51 Sat Jan 21 16:38:41 2012 +++ src/bin/rm/rm.c Wed Jun 13 07:35:37 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: rm.c,v 1.51 2012/01/21 16:38:41 christos Exp $ */ +/* $NetBSD: rm.c,v 1.52 2012/06/13 07:35:37 dholland Exp $ */ /*- * Copyright (c) 1990, 1993, 1994, 2003 @@ -39,7 +39,7 @@ __COPYRIGHT(@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = @(#)rm.c 8.8 (Berkeley) 4/27/95; #else -__RCSID($NetBSD: rm.c,v 1.51 2012/01/21 16:38:41 christos Exp $); +__RCSID($NetBSD: rm.c,v 1.52 2012/06/13 07:35:37 dholland Exp $); #endif #endif /* not lint */ @@ -380,7 +380,7 @@ rm_file(char **argv) static int rm_overwrite(char *file, struct stat *sbp) { - struct stat sb; + struct stat sb, sb2; int fd, randint; char randchar; @@ -394,8 +394,18 @@ rm_overwrite(char *file, struct stat *sb return 0; /* flags to try to defeat hidden caching by forcing seeks */ - if ((fd = open(file, O_RDWR|O_SYNC|O_RSYNC, 0)) == -1) + if ((fd = open(file, O_RDWR|O_SYNC|O_RSYNC|O_NOFOLLOW, 0)) == -1) + goto err; + + if (fstat(fd, sb2)) { goto err; + } + + if (sb2.st_dev != sbp-st_dev || sb2.st_ino != sbp-st_ino || + !S_ISREG(sb2.st_mode)) { + errno = EPERM; + goto err; + } #define RAND_BYTES 1 #define THIS_BYTE 0
CVS commit: src/bin/rm
Module Name:src Committed By: dholland Date: Wed Jun 13 07:35:37 UTC 2012 Modified Files: src/bin/rm: rm.c Log Message: Rectify race condition in rm -P processing by checking that the file we opened is the one we expected to get. Also use O_NOFOLLOW to help avoid even opening devices, which sometimes produce side effects. Reported by Radoslaw A. Zarzynski. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/bin/rm/rm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/rm
Module Name:src Committed By: christos Date: Sat Jan 21 16:38:41 UTC 2012 Modified Files: src/bin/rm: rm.c Log Message: Siginfo support from Daniel Loffgren To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/bin/rm/rm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/rm
Module Name:src Committed By: joerg Date: Mon Aug 29 14:48:46 UTC 2011 Modified Files: src/bin/rm: rm.c Log Message: static + __dead To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/bin/rm/rm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/rm/rm.c diff -u src/bin/rm/rm.c:1.49 src/bin/rm/rm.c:1.50 --- src/bin/rm/rm.c:1.49 Sat Feb 14 08:05:04 2009 +++ src/bin/rm/rm.c Mon Aug 29 14:48:46 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: rm.c,v 1.49 2009/02/14 08:05:04 lukem Exp $ */ +/* $NetBSD: rm.c,v 1.50 2011/08/29 14:48:46 joerg Exp $ */ /*- * Copyright (c) 1990, 1993, 1994, 2003 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = @(#)rm.c 8.8 (Berkeley) 4/27/95; #else -__RCSID($NetBSD: rm.c,v 1.49 2009/02/14 08:05:04 lukem Exp $); +__RCSID($NetBSD: rm.c,v 1.50 2011/08/29 14:48:46 joerg Exp $); #endif #endif /* not lint */ @@ -59,15 +59,14 @@ #include string.h #include unistd.h -int dflag, eval, fflag, iflag, Pflag, stdin_ok, vflag, Wflag; +static int dflag, eval, fflag, iflag, Pflag, stdin_ok, vflag, Wflag; -int check(char *, char *, struct stat *); -void checkdot(char **); -void rm_file(char **); -int rm_overwrite(char *, struct stat *); -void rm_tree(char **); -void usage(void); -int main(int, char *[]); +static int check(char *, char *, struct stat *); +static void checkdot(char **); +static void rm_file(char **); +static int rm_overwrite(char *, struct stat *); +static void rm_tree(char **); +__dead static void usage(void); /* * For the sake of the `-f' flag, check whether an error number indicates the @@ -147,7 +146,7 @@ /* NOTREACHED */ } -void +static void rm_tree(char **argv) { FTS *fts; @@ -261,7 +260,7 @@ fts_close(fts); } -void +static void rm_file(char **argv) { struct stat sb; @@ -371,7 +370,7 @@ * rm_overwrite will return 0 on success. */ -int +static int rm_overwrite(char *file, struct stat *sbp) { struct stat sb; @@ -492,7 +491,7 @@ return 1; } -int +static int check(char *path, char *name, struct stat *sp) { int ch, first; @@ -540,7 +539,7 @@ * trailing slashes have been removed, we'll remove them here. */ #define ISDOT(a) ((a)[0] == '.' (!(a)[1] || ((a)[1] == '.' !(a)[2]))) -void +static void checkdot(char **argv) { char *p, **save, **t; @@ -571,7 +570,7 @@ } } -void +static void usage(void) {
CVS commit: src/bin/rm
Module Name:src Committed By: joerg Date: Mon Aug 29 14:48:46 UTC 2011 Modified Files: src/bin/rm: rm.c Log Message: static + __dead To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/bin/rm/rm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.