Skip to content

preload: copy timestamps with cp -p #729

Open
@adammoody

Description

A cp with the -p option fails when accessing a file descriptor while trying to copy the file timestamps. Here is an strace output for cp -pr file.foo file.bar on NFS.

stat("file.bar", 0x7fffffffbed0)        = -1 ENOENT (No such file or directory)
lstat("file.foo", {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
stat("file.bar", 0x7fffffffbc30)        = -1 ENOENT (No such file or directory)
open("file.foo", O_RDONLY|O_NOFOLLOW)   = 3
fstat(3, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
open("file.bar", O_WRONLY|O_CREAT|O_EXCL, 0600) = 4
fstat(4, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
read(3, "", 65536)                      = 0
utimensat(4, NULL, [{tv_sec=1659649206, tv_nsec=800501000} /* 2022-08-04T14:40:06.800501000-0700 */, {tv_sec=1659649206, tv_nsec=800501000} /* 2022-08-04T14:40:06.800501000-0700 */], 0) = 0
fgetxattr(3, "system.posix_acl_access", 0x7fffffffb870, 132) = -1 EOPNOTSUPP (Operation not supported)
fsetxattr(4, "system.posix_acl_access", "\2\0\0\0\1\0\6\0\377\377\377\377\4\0\0\0\377\377\377\377 \0\0\0\377\377\377\377", 28, 0) = -1 EOPNOTSUPP (Operation not supported)
fchmod(4, 0100600)                      = 0
close(4)                                = 0
close(3)                                = 0
lseek(0, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
close(0)                                = 0
close(1)                                = 0
close(2)                                = 0

It looks to be due to a missing wrapper for utimensat.

We should also check fadvise64, fgetxattr, fgetxattr.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions