]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fs-util: rename laccess to access_nofollow 34638/head
authorMike Yuan <me@yhndnzj.com>
Fri, 4 Oct 2024 23:30:43 +0000 (01:30 +0200)
committerMike Yuan <me@yhndnzj.com>
Fri, 4 Oct 2024 23:30:43 +0000 (01:30 +0200)
In order to distinguish it from libc function naming.

18 files changed:
src/basic/cgroup-util.c
src/basic/fs-util.h
src/basic/os-util.c
src/basic/path-lookup.c
src/core/exec-invoke.c
src/coredump/coredump.c
src/home/homework-luks.c
src/kernel-install/kernel-install.c
src/libsystemd/sd-daemon/sd-daemon.c
src/nspawn/nspawn.c
src/portable/portablectl.c
src/shared/condition.c
src/shared/journal-util.c
src/shared/mount-util.c
src/sysext/sysext.c
src/system-update-generator/system-update-generator.c
src/tmpfiles/tmpfiles.c
src/udev/udevadm-wait.c

index b3cd2c27a6fb3d86db76d84ce1f8db3cb3dc458a..223bcdfbcfa86e32bcae91251b79a4c26f17ab0f 100644 (file)
@@ -623,7 +623,7 @@ static int controller_is_v1_accessible(const char *root, const char *controller)
          * - we can modify the hierarchy. */
 
         cpath = strjoina("/sys/fs/cgroup/", dn, root, root ? "/cgroup.procs" : NULL);
-        return laccess(cpath, root ? W_OK : F_OK);
+        return access_nofollow(cpath, root ? W_OK : F_OK);
 }
 
 int cg_get_path_and_check(const char *controller, const char *path, const char *suffix, char **ret) {
index 2ec4b196f87c1facf89899ad962aefe8ce17090f..82e865180b9574f4021680ef5d02e47fb8401eab 100644 (file)
@@ -49,7 +49,7 @@ int futimens_opath(int fd, const struct timespec ts[2]);
 int fd_warn_permissions(const char *path, int fd);
 int stat_warn_permissions(const char *path, const struct stat *st);
 
-#define laccess(path, mode)                                             \
+#define access_nofollow(path, mode)                                             \
         RET_NERRNO(faccessat(AT_FDCWD, (path), (mode), AT_SYMLINK_NOFOLLOW))
 
 int touch_file(const char *path, bool parents, usec_t stamp, uid_t uid, gid_t gid, mode_t mode);
index 3f6a14f5d697e01144a7b582066e2de8dd3129f6..21b6f669e6a6bd2557b9de8afde998f0f81bf98a 100644 (file)
@@ -97,7 +97,7 @@ int path_is_extension_tree(ImageClass image_class, const char *path, const char
         /* Does the path exist at all? If not, generate an error immediately. This is useful so that a missing root dir
          * always results in -ENOENT, and we can properly distinguish the case where the whole root doesn't exist from
          * the case where just the os-release file is missing. */
-        r = laccess(path, F_OK);
+        r = access_nofollow(path, F_OK);
         if (r < 0)
                 return r;
 
index 0166fdcb9d0092a4d19cbb6e5d89e5f918517a53..234b1973948e2962708c00e56a1745870d60e11b 100644 (file)
@@ -918,7 +918,7 @@ int find_portable_profile(const char *name, const char *unit, char **ret_path) {
                 if (!joined)
                         return -ENOMEM;
 
-                r = laccess(joined, F_OK);
+                r = access_nofollow(joined, F_OK);
                 if (r >= 0) {
                         *ret_path = TAKE_PTR(joined);
                         return 0;
index 9c2b13275e7be78cf67cb8471825e801f1f0e833..becc2b92ef8d94fbfa661d08b61c21d27b25dbb3 100644 (file)
@@ -2345,7 +2345,7 @@ static int setup_exec_directory(
                         assert_cc(EXEC_DIRECTORY_STATE < EXEC_DIRECTORY_LOGS);
                         assert_cc(EXEC_DIRECTORY_LOGS < EXEC_DIRECTORY_CONFIGURATION);
 
-                        r = laccess(p, F_OK);
+                        r = access_nofollow(p, F_OK);
                         if (r == -ENOENT) {
                                 _cleanup_free_ char *q = NULL;
 
@@ -2363,7 +2363,7 @@ static int setup_exec_directory(
                                         goto fail;
                                 }
 
-                                r = laccess(q, F_OK);
+                                r = access_nofollow(q, F_OK);
                                 if (r >= 0) {
                                         /* It does exist! This hence looks like an update. Symlink the
                                          * configuration directory into the state directory. */
@@ -2429,7 +2429,7 @@ static int setup_exec_directory(
                                 goto fail;
 
                         if (is_dir(p, false) > 0 &&
-                            (laccess(pp, F_OK) == -ENOENT)) {
+                            (access_nofollow(pp, F_OK) == -ENOENT)) {
 
                                 /* Hmm, the private directory doesn't exist yet, but the normal one exists? If so, move
                                  * it over. Most likely the service has been upgraded from one that didn't use
index 0da4a531f7a297d78294dc4fc0f45b0f8bb12f2a..722b5b7529aba03a45df689bb321680dd4fee462 100644 (file)
@@ -1525,7 +1525,7 @@ static int forward_coredump_to_container(Context *context) {
 
                 pair[0] = safe_close(pair[0]);
 
-                r = laccess("/run/systemd/coredump", W_OK);
+                r = access_nofollow("/run/systemd/coredump", W_OK);
                 if (r < 0) {
                         log_debug_errno(r, "Cannot find coredump socket, exiting: %m");
                         _exit(EXIT_FAILURE);
index 8ab8dd8cbd0f430481d59f4f15ca9860cad5eaaa..7c3be8dd9a4e77d19cedc3318966782ac7cf6b8b 100644 (file)
@@ -1997,7 +1997,7 @@ static int wait_for_devlink(const char *path) {
                 _cleanup_free_ char *dn = NULL;
                 usec_t w;
 
-                r = laccess(path, F_OK);
+                r = access_nofollow(path, F_OK);
                 if (r >= 0)
                         return 0; /* Found it */
                 if (r != -ENOENT)
index bb646515d0387770a4d9e75eda60f79d9357c013..f4f30df07dd5505cb93a76fc4265f1051c020f43 100644 (file)
@@ -1110,7 +1110,7 @@ static int kernel_from_version(const char *version, char **ret_kernel) {
         if (!vmlinuz)
                 return log_oom();
 
-        r = laccess(vmlinuz, F_OK);
+        r = access_nofollow(vmlinuz, F_OK);
         if (r == -ENOENT)
                 return log_error_errno(r, "Kernel image not installed to '%s', requiring manual kernel image path specification.", vmlinuz);
         if (r < 0)
index 82e677b21509ed55eccc80ae0fbd1334f6355aba..b5469b5d98bfbf0079eab9b0e0422c3bb0611ce4 100644 (file)
@@ -743,7 +743,7 @@ _public_ int sd_booted(void) {
         /* We test whether the runtime unit file directory has been created. This takes place in mount-setup.c,
          * so is guaranteed to happen very early during boot. */
 
-        r = laccess("/run/systemd/system/", F_OK);
+        r = access_nofollow("/run/systemd/system/", F_OK);
         if (r >= 0)
                 return true;
         if (r == -ENOENT)
index fb1954320e0120b1c85cb812b72bf225afcad5d3..47eff33e461b726749ecbb0569bbfbce6b3235c5 100644 (file)
@@ -6154,7 +6154,7 @@ static int run(int argc, char *argv[]) {
                                 goto finish;
                         }
 
-                        if (laccess(p, F_OK) < 0) {
+                        if (access_nofollow(p, F_OK) < 0) {
                                 r = log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                                     "Directory %s doesn't look like it has an OS tree (/usr/ directory is missing). Refusing.", arg_directory);
                                 goto finish;
index e4eb437b2ec29957a713dcfc95806273fedbdd49..7f770f5f922b6713fd2af363e22744b8d74ede00 100644 (file)
@@ -69,7 +69,7 @@ static int determine_image(const char *image, bool permit_non_existing, char **r
         if (image_name_is_valid(image)) {
                 char *c;
 
-                if (!arg_quiet && laccess(image, F_OK) >= 0)
+                if (!arg_quiet && access_nofollow(image, F_OK) >= 0)
                         log_warning("Ambiguous invocation: current working directory contains file matching non-path argument '%s', ignoring. "
                                     "Prefix argument with './' to force reference to file in current working directory.", image);
 
index 401a1feb3cf1913c12554322b330b601e1d3ee68..9dfa1f8901ff2c796d09e8221c81afedbecac462 100644 (file)
@@ -169,7 +169,7 @@ static int condition_test_credential(Condition *c, char **env) {
                 if (!j)
                         return -ENOMEM;
 
-                r = laccess(j, F_OK);
+                r = access_nofollow(j, F_OK);
                 if (r >= 0)
                         return true; /* yay! */
                 if (r != -ENOENT)
index 11d5d68478a50044741cf127cffe45a52a557b14..85b369c36d627306fc5e2810fc813501c44584d2 100644 (file)
@@ -34,7 +34,7 @@ static int access_check_var_log_journal(sd_journal *j, bool want_other_users) {
         _cleanup_strv_free_ char **g = NULL;
         const char* dir;
 
-        if (laccess("/run/log/journal", F_OK) >= 0)
+        if (access_nofollow("/run/log/journal", F_OK) >= 0)
                 dir = "/run/log/journal";
         else
                 dir = "/var/log/journal";
index cf45791c12cc8754f3da49723a6667814de17e6a..1353395c8962b28da364e25dc092881876c05f33 100644 (file)
@@ -427,7 +427,7 @@ int bind_remount_one_with_mountinfo(
 
         fs = mnt_table_find_target(table, path, MNT_ITER_FORWARD);
         if (!fs) {
-                r = laccess(path, F_OK); /* Hmm, it's not in the mount table, but does it exist at all? */
+                r = access_nofollow(path, F_OK); /* Hmm, it's not in the mount table, but does it exist at all? */
                 if (r < 0)
                         return r;
 
@@ -879,7 +879,7 @@ static int mount_in_namespace_legacy(
         assert(!options || (flags & MOUNT_IN_NAMESPACE_IS_IMAGE));
 
         p = strjoina(propagate_path, "/");
-        r = laccess(p, F_OK);
+        r = access_nofollow(p, F_OK);
         if (r < 0)
                 return log_debug_errno(r == -ENOENT ? SYNTHETIC_ERRNO(EOPNOTSUPP) : r, "Target does not allow propagation of mount points");
 
index de52a14d0d3a58235da6c4d700e805f2af3e97b2..f6b38d66152f43902fc72162c60472d00f2f1316 100644 (file)
@@ -1760,7 +1760,7 @@ static int merge_subprocess(
                 if (!p)
                         return log_oom();
 
-                r = laccess(p, F_OK);
+                r = access_nofollow(p, F_OK);
                 if (r == -ENOENT) /* Hierarchy apparently was empty in all extensions, and wasn't mounted, ignoring. */
                         continue;
                 if (r < 0)
index d8845306747dc6315fc553c560634b89bd033235..8be8879decd6ce9329799450ef214742a8cda62e 100644 (file)
@@ -23,7 +23,7 @@ static int generate_symlink(void) {
         int r;
 
         FOREACH_STRING(p, "/system-update", "/etc/system-update") {
-                r = laccess(p, F_OK);
+                r = access_nofollow(p, F_OK);
                 if (r < 0) {
                         if (r != -ENOENT)
                                 log_warning_errno(r, "Failed to check if %s symlink exists, ignoring: %m", p);
index 825818fbaef010f1ac7ce4221721f496e8ae92a6..a7655aad1c7970adcd4ef17d2a38d1807445202e 100644 (file)
@@ -3900,7 +3900,7 @@ static int parse_line(
 
                 path_simplify(i.argument);
 
-                if (laccess(i.argument, F_OK) == -ENOENT) {
+                if (access_nofollow(i.argument, F_OK) == -ENOENT) {
                         /* Silently skip over lines where the source file is missing. */
                         log_syntax(NULL, LOG_DEBUG, fname, line, 0,
                                    "Copy source path '%s' does not exist, skipping line.", i.argument);
index 6ffc86bbf1efe91f3ccf5d5f73a7fb7071fca4ee..39e31ad2bfe145b9468ca0d4f85e7c085f21e039 100644 (file)
@@ -52,7 +52,7 @@ static int check_device(const char *path) {
         assert(path);
 
         if (arg_wait_until == WAIT_UNTIL_REMOVED) {
-                r = laccess(path, F_OK);
+                r = access_nofollow(path, F_OK);
                 if (r == -ENOENT)
                         return true;
                 if (r < 0)