NetBSD Problem Report #47770

From www@NetBSD.org  Fri Apr 26 18:28:49 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 6034D63ECDD
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 26 Apr 2013 18:28:49 +0000 (UTC)
Message-Id: <20130426182848.4457563ECDD@www.NetBSD.org>
Date: Fri, 26 Apr 2013 18:28:48 +0000 (UTC)
From: lists@eitanadler.com
Reply-To: lists@eitanadler.com
To: gnats-bugs@NetBSD.org
Subject: add x flag to rm to avoid cross mount points
X-Send-Pr-Version: www-1.0

>Number:         47770
>Category:       bin
>Synopsis:       add x flag to rm to avoid cross mount points
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 26 18:30:00 +0000 2013
>Closed-Date:    Sun Apr 28 16:24:36 +0000 2013
>Last-Modified:  Sun Apr 28 16:24:36 +0000 2013
>Originator:     Eitan Adler
>Release:        HEAD
>Organization:
>Environment:
>Description:
Add an x option to avoid crossing filesystem boundaries when removing files.
>How-To-Repeat:

>Fix:
The diff, available as an attachment by request.

Index: rm.c
===================================================================
RCS file: /cvsroot/src/bin/rm/rm.c,v
retrieving revision 1.52
diff -u -r1.52 rm.c
--- rm.c	13 Jun 2012 07:35:37 -0000	1.52
+++ rm.c	26 Apr 2013 18:27:00 -0000
@@ -61,6 +61,7 @@
 #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 @@
 	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 @@
 		case 'v':
 			vflag = 1;
 			break;
+		case 'x':
+			xflag = 1;
+			break;
 		case 'W':
 			Wflag = 1;
 			break;
@@ -175,6 +179,8 @@
 		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 @@
 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 */
Index: rm.1
===================================================================
RCS file: /cvsroot/src/bin/rm/rm.1,v
retrieving revision 1.25
diff -u -r1.25 rm.1
--- rm.1	13 Oct 2012 14:18:16 -0000	1.25
+++ rm.1	26 Apr 2013 18:27:00 -0000
@@ -110,6 +110,8 @@
 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

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/47770 CVS commit: src/bin/rm
Date: Fri, 26 Apr 2013 14:43:23 -0400

 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.

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 28 Apr 2013 16:24:36 +0000
State-Changed-Why:
Christos committed it, thanks!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.