diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-04-14 09:28:54 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-04-14 09:28:54 +0200 |
commit | 5a2f674a005a8f31648dfed1dde0b34ed02ee7dd (patch) | |
tree | dc67d32a0ecca793018a016c1790120d97b522d9 /src | |
parent | Merge pull request #27254 from poettering/cmsg-align-check (diff) | |
download | systemd-5a2f674a005a8f31648dfed1dde0b34ed02ee7dd.tar.xz systemd-5a2f674a005a8f31648dfed1dde0b34ed02ee7dd.zip |
chase: use FLAGS_SET() macro
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/chase.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/basic/chase.c b/src/basic/chase.c index e8d38279fd..f167a439ad 100644 --- a/src/basic/chase.c +++ b/src/basic/chase.c @@ -88,10 +88,10 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int assert(dir_fd >= 0 || dir_fd == AT_FDCWD); /* Either the file may be missing, or we return an fd to the final object, but both make no sense */ - if ((flags & CHASE_NONEXISTENT)) + if (FLAGS_SET(flags, CHASE_NONEXISTENT)) assert(!ret_fd); - if ((flags & CHASE_STEP)) + if (FLAGS_SET(flags, CHASE_STEP)) assert(!ret_fd); if (isempty(path)) @@ -176,7 +176,7 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int /* Shortcut the ret_fd case if the caller isn't interested in the actual path and has no root * set and doesn't care about any of the other special features we provide either. */ - r = openat(dir_fd, path, O_PATH|O_CLOEXEC|((flags & CHASE_NOFOLLOW) ? O_NOFOLLOW : 0)); + r = openat(dir_fd, path, O_PATH|O_CLOEXEC|(FLAGS_SET(flags, CHASE_NOFOLLOW) ? O_NOFOLLOW : 0)); if (r < 0) return -errno; @@ -221,7 +221,7 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int if (fstat(fd, &st) < 0) return -errno; - if (flags & CHASE_TRAIL_SLASH) + if (FLAGS_SET(flags, CHASE_TRAIL_SLASH)) append_trail_slash = ENDSWITH_SET(buffer, "/", "/."); for (todo = buffer;;) { @@ -283,10 +283,10 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int } else return r; - if (flags & CHASE_STEP) + if (FLAGS_SET(flags, CHASE_STEP)) goto chased_one; - if (flags & CHASE_SAFE && + if (FLAGS_SET(flags, CHASE_SAFE) && unsafe_transition(&st, &st_parent)) return log_unsafe_transition(fd, fd_parent, path, flags); @@ -317,7 +317,7 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int return -ENOMEM; break; - } else if (flags & CHASE_NONEXISTENT) { + } else if (FLAGS_SET(flags, CHASE_NONEXISTENT)) { if (!path_extend(&done, first, todo)) return -ENOMEM; @@ -330,18 +330,18 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int if (fstat(child, &st_child) < 0) return -errno; - if ((flags & CHASE_SAFE) && + if (FLAGS_SET(flags, CHASE_SAFE) && unsafe_transition(&st, &st_child)) return log_unsafe_transition(fd, child, path, flags); - if ((flags & CHASE_NO_AUTOFS) && + if (FLAGS_SET(flags, CHASE_NO_AUTOFS) && fd_is_fs_type(child, AUTOFS_SUPER_MAGIC) > 0) return log_autofs_mount_point(child, path, flags); - if (S_ISLNK(st_child.st_mode) && !((flags & CHASE_NOFOLLOW) && isempty(todo))) { + if (S_ISLNK(st_child.st_mode) && !(FLAGS_SET(flags, CHASE_NOFOLLOW) && isempty(todo))) { _cleanup_free_ char *destination = NULL; - if (flags & CHASE_PROHIBIT_SYMLINKS) + if (FLAGS_SET(flags, CHASE_PROHIBIT_SYMLINKS)) return log_prohibited_symlink(child, flags); /* This is a symlink, in this case read the destination. But let's make sure we @@ -368,7 +368,7 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int if (fstat(fd, &st) < 0) return -errno; - if (flags & CHASE_SAFE && + if (FLAGS_SET(flags, CHASE_SAFE) && unsafe_transition(&st_child, &st)) return log_unsafe_transition(child, fd, path, flags); @@ -385,7 +385,7 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int free_and_replace(buffer, destination); todo = buffer; - if (flags & CHASE_STEP) + if (FLAGS_SET(flags, CHASE_STEP)) goto chased_one; continue; @@ -403,7 +403,7 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int close_and_replace(fd, child); } - if (flags & CHASE_PARENT) { + if (FLAGS_SET(flags, CHASE_PARENT)) { r = stat_verify_directory(&st); if (r < 0) return r; @@ -438,7 +438,7 @@ int chaseat(int dir_fd, const char *path, ChaseFlags flags, char **ret_path, int *ret_fd = TAKE_FD(fd); } - if (flags & CHASE_STEP) + if (FLAGS_SET(flags, CHASE_STEP)) return 1; return exists; @@ -499,7 +499,7 @@ int chase(const char *path, const char *original_root, ChaseFlags flags, char ** assert(path_is_absolute(root)); assert(!empty_or_root(root)); - if (flags & CHASE_PREFIX_ROOT) { + if (FLAGS_SET(flags, CHASE_PREFIX_ROOT)) { absolute = path_join(root, path); if (!absolute) return -ENOMEM; @@ -516,7 +516,7 @@ int chase(const char *path, const char *original_root, ChaseFlags flags, char ** path = path_startswith(absolute, empty_to_root(root)); if (!path) - return log_full_errno(flags & CHASE_WARN ? LOG_WARNING : LOG_DEBUG, + return log_full_errno(FLAGS_SET(flags, CHASE_WARN) ? LOG_WARNING : LOG_DEBUG, SYNTHETIC_ERRNO(ECHRNG), "Specified path '%s' is outside of specified root directory '%s', refusing to resolve.", absolute, empty_to_root(root)); |