]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/path: use flags for fstatat()
authorKarel Zak <kzak@redhat.com>
Wed, 8 Sep 2021 11:16:29 +0000 (13:16 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 6 Oct 2021 09:01:54 +0000 (11:01 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/path.h
lib/path.c
lib/procfs.c
libmount/src/context_veritydev.c
misc-utils/lsblk-properties.c
misc-utils/lsfd.c

index e720893399eff71a9494b136f5e6f8849a2aca99..3ce70c40b2ad18213c5fbce4e5fe36ad286d702c 100644 (file)
@@ -48,7 +48,7 @@ int ul_path_is_accessible(struct path_cxt *pc);
 char *ul_path_get_abspath(struct path_cxt *pc, char *buf, size_t bufsz, const char *path, ...)
                                __attribute__ ((__format__ (__printf__, 4, 5)));
 
-int ul_path_stat(struct path_cxt *pc, struct stat *sb, const char *path);
+int ul_path_stat(struct path_cxt *pc, struct stat *sb, int flags, const char *path);
 int ul_path_access(struct path_cxt *pc, int mode, const char *path);
 int ul_path_accessf(struct path_cxt *pc, int mode, const char *path, ...)
                                __attribute__ ((__format__ (__printf__, 3, 4)));
index f0b010e67e509aeda94214c7554903c58da72ee1..cf3a33e046f88f7c84ed4eec347c0ad34310c71b 100644 (file)
@@ -339,7 +339,7 @@ int ul_path_accessf(struct path_cxt *pc, int mode, const char *path, ...)
        return !p ? -errno : ul_path_access(pc, mode, p);
 }
 
-int ul_path_stat(struct path_cxt *pc, struct stat *sb, const char *path)
+int ul_path_stat(struct path_cxt *pc, struct stat *sb, int flags, const char *path)
 {
        int rc;
 
@@ -353,7 +353,8 @@ int ul_path_stat(struct path_cxt *pc, struct stat *sb, const char *path)
                if (path) {
                        if  (*path == '/')
                                path++;
-                       rc = fstatat(dir, path, sb, 0);
+                       rc = fstatat(dir, path, sb, flags);
+
                } else
                        rc = fstat(dir, sb);    /* dir itself */
 
index ec55fb4803485b3f0e6d5b821ad98c1cdd0b576a..8173d6274c5f120150f37cf54f5b4cd99e966592 100644 (file)
@@ -167,7 +167,7 @@ int procfs_process_get_uid(struct path_cxt *pc, uid_t *uid)
        struct stat sb;
        int rc;
 
-       if ((rc = ul_path_stat(pc, &sb, NULL)) == 0)
+       if ((rc = ul_path_stat(pc, &sb, 0, NULL)) == 0)
                *uid = sb.st_uid;
        return rc;
 }
index 298a0299885b1c3131cf99feb902eb8bbc599598..a8cb1f6938b78ce565c8ae6852c014f53c68a10e 100644 (file)
@@ -223,7 +223,7 @@ int mnt_context_setup_veritydev(struct libmnt_context *cxt)
                root_hash_sig_file = strndup(val, len);
                rc = root_hash_sig_file ? 0 : -ENOMEM;
                if (rc == 0)
-                       rc = ul_path_stat(NULL, &hash_sig_st, root_hash_sig_file);
+                       rc = ul_path_stat(NULL, &hash_sig_st, 0, root_hash_sig_file);
                if (rc == 0)
                        rc = !S_ISREG(hash_sig_st.st_mode) || !hash_sig_st.st_size ? -EINVAL : 0;
                if (rc == 0) {
index bc6079371b9653f0eadaf37d9404f5929ec023af..ada9b03b703f227301bed33c920789f6bd0d5cb7 100644 (file)
@@ -191,7 +191,7 @@ static struct lsblk_devprop *get_properties_by_file(struct lsblk_device *ld)
                return NULL;
        if (ul_path_set_prefix(pc, lsblk->sysroot) != 0)
                goto done;
-       if (ul_path_stat(pc, &sb, ld->filename) != 0 || !S_ISREG(sb.st_mode))
+       if (ul_path_stat(pc, &sb, 0, ld->filename) != 0 || !S_ISREG(sb.st_mode))
                goto done;
 
        fp = ul_path_fopen(pc, "r", ld->filename);
index 4f65e38c493c8ae2d4f287c5b22790b1ac0bea9f..0665f05c5de8fba2a8d8b054a397b3959d2d7bf9 100644 (file)
@@ -561,7 +561,7 @@ static struct file *collect_outofbox_file(struct path_cxt *pc,
        struct stat sb;
        struct file *f;
 
-       if (ul_path_stat(pc, &sb, name) < 0)
+       if (ul_path_stat(pc, &sb, 0, name) < 0)
                return NULL;
        if (ul_path_readlink(pc, sym, sizeof(sym), name) < 0)
                return NULL;