fs-util: rename xopenat() -> xopanat_full()
This commit is contained in:
+15
-15
@@ -374,11 +374,11 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int
|
||||
return r;
|
||||
|
||||
if (FLAGS_SET(flags, CHASE_MKDIR_0755) && !isempty(todo)) {
|
||||
child = xopenat(fd,
|
||||
first,
|
||||
O_DIRECTORY|O_CREAT|O_EXCL|O_NOFOLLOW|O_CLOEXEC,
|
||||
/* xopen_flags = */ 0,
|
||||
0755);
|
||||
child = xopenat_full(fd,
|
||||
first,
|
||||
O_DIRECTORY|O_CREAT|O_EXCL|O_NOFOLLOW|O_CLOEXEC,
|
||||
/* xopen_flags = */ 0,
|
||||
0755);
|
||||
if (child < 0)
|
||||
return child;
|
||||
} else if (FLAGS_SET(flags, CHASE_PARENT) && isempty(todo)) {
|
||||
@@ -760,10 +760,10 @@ int chase_and_open(const char *path, const char *root, ChaseFlags chase_flags, i
|
||||
if (empty_or_root(root) && !ret_path &&
|
||||
(chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_PROHIBIT_SYMLINKS|CHASE_PARENT|CHASE_MKDIR_0755)) == 0)
|
||||
/* Shortcut this call if none of the special features of this call are requested */
|
||||
return xopenat(AT_FDCWD, path,
|
||||
open_flags | (FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? O_NOFOLLOW : 0),
|
||||
/* xopen_flags = */ 0,
|
||||
mode);
|
||||
return xopenat_full(AT_FDCWD, path,
|
||||
open_flags | (FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? O_NOFOLLOW : 0),
|
||||
/* xopen_flags = */ 0,
|
||||
mode);
|
||||
|
||||
r = chase(path, root, CHASE_PARENT|chase_flags, &p, &path_fd);
|
||||
if (r < 0)
|
||||
@@ -777,7 +777,7 @@ int chase_and_open(const char *path, const char *root, ChaseFlags chase_flags, i
|
||||
return r;
|
||||
}
|
||||
|
||||
r = xopenat(path_fd, strempty(fname), open_flags|O_NOFOLLOW, /* xopen_flags = */ 0, mode);
|
||||
r = xopenat_full(path_fd, strempty(fname), open_flags|O_NOFOLLOW, /* xopen_flags = */ 0, mode);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@@ -964,10 +964,10 @@ int chase_and_openat(int dir_fd, const char *path, ChaseFlags chase_flags, int o
|
||||
if (dir_fd == AT_FDCWD && !ret_path &&
|
||||
(chase_flags & (CHASE_NO_AUTOFS|CHASE_SAFE|CHASE_PROHIBIT_SYMLINKS|CHASE_PARENT|CHASE_MKDIR_0755)) == 0)
|
||||
/* Shortcut this call if none of the special features of this call are requested */
|
||||
return xopenat(dir_fd, path,
|
||||
open_flags | (FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? O_NOFOLLOW : 0),
|
||||
/* xopen_flags = */ 0,
|
||||
mode);
|
||||
return xopenat_full(dir_fd, path,
|
||||
open_flags | (FLAGS_SET(chase_flags, CHASE_NOFOLLOW) ? O_NOFOLLOW : 0),
|
||||
/* xopen_flags = */ 0,
|
||||
mode);
|
||||
|
||||
r = chaseat(dir_fd, path, chase_flags|CHASE_PARENT, &p, &path_fd);
|
||||
if (r < 0)
|
||||
@@ -979,7 +979,7 @@ int chase_and_openat(int dir_fd, const char *path, ChaseFlags chase_flags, int o
|
||||
return r;
|
||||
}
|
||||
|
||||
r = xopenat(path_fd, strempty(fname), open_flags|O_NOFOLLOW, /* xopen_flags = */ 0, mode);
|
||||
r = xopenat_full(path_fd, strempty(fname), open_flags|O_NOFOLLOW, /* xopen_flags = */ 0, mode);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ int chattr_full(
|
||||
|
||||
assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
|
||||
|
||||
fd = xopenat(dir_fd, path, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, /* xopen_flags = */ 0, /* mode = */ 0);
|
||||
fd = xopenat(dir_fd, path, O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
|
||||
+4
-4
@@ -1054,7 +1054,7 @@ int open_mkdir_at(int dirfd, const char *path, int flags, mode_t mode) {
|
||||
path = fname;
|
||||
}
|
||||
|
||||
fd = xopenat(dirfd, path, flags|O_CREAT|O_DIRECTORY|O_NOFOLLOW, /* xopen_flags = */ 0, mode);
|
||||
fd = xopenat_full(dirfd, path, flags|O_CREAT|O_DIRECTORY|O_NOFOLLOW, /* xopen_flags = */ 0, mode);
|
||||
if (IN_SET(fd, -ELOOP, -ENOTDIR))
|
||||
return -EEXIST;
|
||||
if (fd < 0)
|
||||
@@ -1110,7 +1110,7 @@ int openat_report_new(int dirfd, const char *pathname, int flags, mode_t mode, b
|
||||
}
|
||||
}
|
||||
|
||||
int xopenat(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_flags, mode_t mode) {
|
||||
int xopenat_full(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_flags, mode_t mode) {
|
||||
_cleanup_close_ int fd = -EBADF;
|
||||
bool made = false;
|
||||
int r;
|
||||
@@ -1191,7 +1191,7 @@ int xopenat(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_flags
|
||||
return TAKE_FD(fd);
|
||||
}
|
||||
|
||||
int xopenat_lock(
|
||||
int xopenat_lock_full(
|
||||
int dir_fd,
|
||||
const char *path,
|
||||
int open_flags,
|
||||
@@ -1214,7 +1214,7 @@ int xopenat_lock(
|
||||
for (;;) {
|
||||
struct stat st;
|
||||
|
||||
fd = xopenat(dir_fd, path, open_flags, xopen_flags, mode);
|
||||
fd = xopenat_full(dir_fd, path, open_flags, xopen_flags, mode);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
|
||||
+8
-2
@@ -137,6 +137,12 @@ typedef enum XOpenFlags {
|
||||
XO_SUBVOLUME = 1 << 1,
|
||||
} XOpenFlags;
|
||||
|
||||
int xopenat(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_flags, mode_t mode);
|
||||
int xopenat_full(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_flags, mode_t mode);
|
||||
static inline int xopenat(int dir_fd, const char *path, int open_flags) {
|
||||
return xopenat_full(dir_fd, path, open_flags, 0, 0);
|
||||
}
|
||||
|
||||
int xopenat_lock(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_flags, mode_t mode, LockType locktype, int operation);
|
||||
int xopenat_lock_full(int dir_fd, const char *path, int open_flags, XOpenFlags xopen_flags, mode_t mode, LockType locktype, int operation);
|
||||
static inline int xopenat_lock(int dir_fd, const char *path, int open_flags, LockType locktype, int operation) {
|
||||
return xopenat_lock_full(dir_fd, path, open_flags, 0, 0, locktype, operation);
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ int make_lock_file_at(int dir_fd, const char *p, int operation, LockFile *ret) {
|
||||
if (!t)
|
||||
return -ENOMEM;
|
||||
|
||||
fd = xopenat_lock(dfd,
|
||||
p,
|
||||
O_CREAT|O_RDWR|O_NOFOLLOW|O_CLOEXEC|O_NOCTTY,
|
||||
/* xopen_flags = */ 0,
|
||||
0600,
|
||||
LOCK_UNPOSIX,
|
||||
operation);
|
||||
fd = xopenat_lock_full(dfd,
|
||||
p,
|
||||
O_CREAT|O_RDWR|O_NOFOLLOW|O_CLOEXEC|O_NOCTTY,
|
||||
/* xopen_flags = */ 0,
|
||||
0600,
|
||||
LOCK_UNPOSIX,
|
||||
operation);
|
||||
if (fd < 0)
|
||||
return fd == -EAGAIN ? -EBUSY : fd;
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ int readdir_all_at(int fd, const char *path, RecurseDirFlags flags, DirectoryEnt
|
||||
|
||||
assert(fd >= 0 || fd == AT_FDCWD);
|
||||
|
||||
dir_fd = xopenat(fd, path, O_DIRECTORY|O_CLOEXEC, /* xopen_flags= */ 0, /* mode= */ 0);
|
||||
dir_fd = xopenat(fd, path, O_DIRECTORY|O_CLOEXEC);
|
||||
if (dir_fd < 0)
|
||||
return dir_fd;
|
||||
|
||||
|
||||
@@ -468,7 +468,7 @@ int xstatfsat(int dir_fd, const char *path, struct statfs *ret) {
|
||||
assert(dir_fd >= 0 || dir_fd == AT_FDCWD);
|
||||
assert(ret);
|
||||
|
||||
fd = xopenat(dir_fd, path, O_PATH|O_CLOEXEC|O_NOCTTY, /* xopen_flags = */ 0, /* mode = */ 0);
|
||||
fd = xopenat(dir_fd, path, O_PATH|O_CLOEXEC|O_NOCTTY);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user