return mfree(p);
}
-static int path_get_mount_info_at(
+int path_get_mount_info_at(
int dir_fd,
const char *path,
char **ret_fstype,
- char **ret_options) {
+ char **ret_options,
+ char **ret_source) {
_cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
_cleanup_(mnt_free_iterp) struct libmnt_iter *iter = NULL;
if (mnt_fs_get_id(fs) != mnt_id)
continue;
- _cleanup_free_ char *fstype = NULL, *options = NULL;
+ _cleanup_free_ char *fstype = NULL, *options = NULL, *source = NULL;
if (ret_fstype) {
fstype = strdup(strempty(mnt_fs_get_fstype(fs)));
return log_oom_debug();
}
+ if (ret_source) {
+ source = strdup(strempty(mnt_fs_get_source(fs)));
+ if (!source)
+ return log_oom_debug();
+ }
+
if (ret_fstype)
*ret_fstype = TAKE_PTR(fstype);
if (ret_options)
*ret_options = TAKE_PTR(options);
+ if (ret_source)
+ *ret_source = TAKE_PTR(source);
return 0;
}
return r;
_cleanup_free_ char *fstype = NULL, *options = NULL;
- r = path_get_mount_info_at(fd, /* path = */ NULL, &fstype, &options);
+ r = path_get_mount_info_at(fd, /* path = */ NULL, &fstype, &options, /* source = */ NULL);
if (r < 0)
return r;
int make_fsmount(int error_log_level, const char *what, const char *type, unsigned long flags, const char *options, int userns_fd);
+int path_get_mount_info_at(int dir_fd, const char *path, char **ret_fstype, char **ret_options, char **ret_source);
+static inline int path_get_mount_info(const char *path, char **ret_fstype, char **ret_options, char **ret_source) {
+ return path_get_mount_info_at(AT_FDCWD, path, ret_fstype, ret_options, ret_source);
+}
+
int path_is_network_fs_harder_at(int dir_fd, const char *path);
static inline int path_is_network_fs_harder(const char *path) {
return path_is_network_fs_harder_at(AT_FDCWD, path);