Bug 20832 - cp --preserve mode argument is insufficiently granular
Summary: cp --preserve mode argument is insufficiently granular
Status: RESOLVED INVALID
Alias: None
Product: IO/Storage
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 enhancement
Assignee: io_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-21 14:06 UTC by Mark
Modified: 2012-08-14 11:18 UTC (History)
2 users (show)

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Mark 2010-10-21 14:06:17 UTC
This is the first bug I have submitted, so apologies if I get anything wrong here.

Overview
I have two filesystems. One filesystem is mounted with the "acl" option and one is not. I want to be able copy files containing ACLs from the filesystem that supports ACLs over to the filesystem that doesn't. I want to preserve the file ownership and permissions, but I want to NOT preserve the ACLs. At the moment there the cp command can sort of achieve this, but it returns an error.

STEPS TO REPRODUCE
# touch test
# setfacl -m u:1234:rw- test
# # Assuming that /tmp is not mounted with option "acl"
# cp -p test /tmp
cp: preserving permissions for `/tmp/test': Operation not supported
# cp --preserve=mode test /tmp
cp: preserving permissions for `/tmp/test': Operation not supported
# # (Only by excluding mode will the operation return success)
#  cp --preserve=ownership,timestamps test /tmp

DESIRED BEHAVIOUR
I think it would be highly desirable for cp to offer more granularity on what is preserved by the copy. I would suggest adding:
- acl
- x_attr

Note that rsync does a good job by providing the following options:
 -H, --hard-links            preserve hard links
 -p, --perms                 preserve permissions
 -E, --executability         preserve executability
     --chmod=CHMOD           affect file and/or directory permissions
 -A, --acls                  preserve ACLs (implies -p)
 -X, --xattrs                preserve extended attributes
 -o, --owner                 preserve owner (super-user only)
 -g, --group                 preserve group
     --devices               preserve device files (super-user only)
     --specials              preserve special files
 -D                          same as --devices --specials
 -t, --times                 preserve modification times

If only cp could be brought up to the same standard.

It is also perhaps worth mentioning that it seems bizarre (and very confusing) that in order to preserve the file mode (e.g. 0644) you need to specify preserve=ownership, not preserve=mode, and in order to preserve the file owner (e.g. mark) you need to specify preserve=mode!!

BUILD & PLATFORM
I'm pretty sure this issue applied to all flavours of Linux, but I am testing on a derivative of Debian Sarge running on a Sparc processor 
# uname -a
Linux tera 2.6.17.8ReadyNAS #1 Tue Jun 9 13:59:28 PDT 2009 padre unknown

Note You need to log in before you can comment on or make changes to this bug.