copy: add copy_access() helper for copying access mode

This commit is contained in:
Lennart Poettering 2020-07-28 23:38:23 +02:00
parent 5c05f06264
commit bacf21e9e9
2 changed files with 16 additions and 0 deletions

View File

@ -969,6 +969,21 @@ int copy_times(int fdf, int fdt, CopyFlags flags) {
return 0;
}
int copy_access(int fdf, int fdt) {
struct stat st;
assert(fdf >= 0);
assert(fdt >= 0);
if (fstat(fdf, &st) < 0)
return -errno;
if (fchmod(fdt, st.st_mode & 07777) < 0)
return -errno;
return 0;
}
int copy_xattr(int fdf, int fdt) {
_cleanup_free_ char *names = NULL;
int ret = 0, r;

View File

@ -61,4 +61,5 @@ static inline int copy_bytes(int fdf, int fdt, uint64_t max_bytes, CopyFlags cop
}
int copy_times(int fdf, int fdt, CopyFlags flags);
int copy_access(int fdf, int fdt);
int copy_xattr(int fdf, int fdt);