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

user/1025: mv(1) sometimes does not preserve the file flags




>Number:         1025
>Category:       user
>Synopsis:       mv(1) sometimes does not preserve the file flags
>Confidential:   yes
>Severity:       non-critical
>Priority:       low
>Responsible:    bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 24 09:30:01 MST 1999
>Last-Modified:
>Originator:     Kamo Hiroyasu
>Organization:
Nara Women's University
>Release:        2.6
>Environment:
	System      : OpenBSD 2.6
	Architecture: OpenBSD.i386
	Machine     : i386
>Description:
	
	mv(1) does not preserve the file flags when moving a regular file
across file systems.
	This bug is identical to FreeBSD Problem Report bin/12375.
>How-To-Repeat:
	
	Move a regular file across file systems.

 touch foo
 chflags nodump /mnt1/foo
 mv /mnt1/foo /mnt2/foo
 ls -lo /mnt2/foo

where /mnt1 and /mnt2 are different file systems.

>Fix:
	
	Copy a few lines from cp(1) and paste them on mv(1).

--- bin/mv/mv.c.orig	Tue Jul 27 06:29:45 1999
+++ bin/mv/mv.c	Sat Dec 25 01:15:57 1999
@@ -324,6 +324,17 @@
 	}
 	if (fchmod(to_fd, sbp->st_mode))
 		warn("%s: set mode", to);
+	/*
+	 * XXX
+	 * NFS doesn't support chflags; ignore errors unless there's reason
+	 * to believe we're losing bits.  (Note, this still won't be right
+	 * if the server supports flags and we were trying to *remove* flags
+	 * on a file that we copied, i.e., that we didn't create.)
+	 */
+	errno = 0;
+	if (fchflags(to_fd, sbp->st_flags))
+		if (errno != EOPNOTSUPP || sbp->st_flags != 0)
+			warn("%s: set flags", to);
 
 	tval[0].tv_sec = sbp->st_atime;
 	tval[1].tv_sec = sbp->st_mtime;

>Audit-Trail:
>Unformatted: