fs-util: add new futimens_opath() helper
futimens() that works for O_PATH fds.
This commit is contained in:
parent
9271daeed7
commit
f25bff5eaf
|
@ -312,6 +312,25 @@ int fchmod_opath(int fd, mode_t m) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int futimens_opath(int fd, const struct timespec ts[2]) {
|
||||||
|
char procfs_path[STRLEN("/proc/self/fd/") + DECIMAL_STR_MAX(int)];
|
||||||
|
|
||||||
|
/* Similar to fchmod_path() but for futimens() */
|
||||||
|
|
||||||
|
xsprintf(procfs_path, "/proc/self/fd/%i", fd);
|
||||||
|
if (utimensat(AT_FDCWD, procfs_path, ts, 0) < 0) {
|
||||||
|
if (errno != ENOENT)
|
||||||
|
return -errno;
|
||||||
|
|
||||||
|
if (proc_mounted() == 0)
|
||||||
|
return -ENOSYS; /* if we have no /proc/, the concept is not implementable */
|
||||||
|
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int stat_warn_permissions(const char *path, const struct stat *st) {
|
int stat_warn_permissions(const char *path, const struct stat *st) {
|
||||||
assert(path);
|
assert(path);
|
||||||
assert(st);
|
assert(st);
|
||||||
|
|
|
@ -38,6 +38,8 @@ int fchmod_and_chown(int fd, mode_t mode, uid_t uid, gid_t gid);
|
||||||
int fchmod_umask(int fd, mode_t mode);
|
int fchmod_umask(int fd, mode_t mode);
|
||||||
int fchmod_opath(int fd, mode_t m);
|
int fchmod_opath(int fd, mode_t m);
|
||||||
|
|
||||||
|
int futimens_opath(int fd, const struct timespec ts[2]);
|
||||||
|
|
||||||
int fd_warn_permissions(const char *path, int fd);
|
int fd_warn_permissions(const char *path, int fd);
|
||||||
int stat_warn_permissions(const char *path, const struct stat *st);
|
int stat_warn_permissions(const char *path, const struct stat *st);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue