Let's introduce simple function to hide 'struct stat' if unnecessary.
Signed-off-by: Karel Zak <kzak@redhat.com>
struct libmnt_optlist *ol;
struct libmnt_opt *opt;
const char *mstr = NULL;
- struct stat st;
assert(cxt);
assert(cxt->map_userspace);
if (!opt)
return 0;
- if (mnt_stat_mountpoint(tgt, &st) == 0)
+ if (mnt_is_path(tgt))
return 0;
mstr = mnt_opt_get_value(opt);
extern void mnt_free_filesystems(char **filesystems);
extern char *mnt_get_kernel_cmdline_option(const char *name);
+
extern int mnt_stat_mountpoint(const char *target, struct stat *st);
extern int mnt_lstat_mountpoint(const char *target, struct stat *st);
+extern int mnt_is_path(const char *target);
extern int mnt_tmptgt_unshare(int *old_ns_fd);
extern int mnt_tmptgt_cleanup(int old_ns_fd);
int direction)
{
char *mnt;
- struct stat st;
if (!tb || !path || !*path)
return NULL;
DBG(TAB, ul_debugobj(tb, "lookup MOUNTPOINT: '%s'", path));
- if (mnt_stat_mountpoint(path, &st))
+ if (!mnt_is_path(path))
return NULL;
mnt = strdup(path);
#endif
}
+/* Don't use access() or stat() here, we need a way how to check the path
+ * without trigger an automount or hangs on NFS, etc. */
+int mnt_is_path(const char *target)
+{
+ struct stat st;
+
+ return mnt_stat_mountpoint(target, &st) == 0;
+}
/*
* Note that the @target has to be an absolute path (so at least "/"). The