lib/path: use flags for fstatat()

Signed-off-by: Karel Zak <kzak@redhat.com>
pull/1487/head
Karel Zak 1 year ago
parent 0e04a66789
commit db9ad223d6
  1. 2
      include/path.h
  2. 5
      lib/path.c
  3. 2
      lib/procfs.c
  4. 2
      libmount/src/context_veritydev.c
  5. 2
      misc-utils/lsblk-properties.c
  6. 2
      misc-utils/lsfd.c

@ -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)));

@ -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 */

@ -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;
}

@ -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) {

@ -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);

@ -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;

Loading…
Cancel
Save