version : fuzzer_build ? '>= 0' : '>= 2.30',
disabler : true,
required : get_option('libmount'))
+libmount_cflags = libmount.partial_dependency(includes: true, compile_args: true)
libfdisk = dependency('fdisk',
version : '>= 2.32',
dependencies : [libaudit_cflags,
libdl,
libm,
- libmount,
+ libmount_cflags,
librt,
libseccomp_cflags,
libselinux,
libcore,
libshared
],
- 'dependencies' : libmount,
+ 'dependencies' : libmount_cflags,
},
fuzz_template + {
'sources' : files('fuzz-manager-serialize.c'),
struct libmnt_fs *fs;
const char *device, *path, *options, *fstype;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r == 1)
break;
if (r < 0)
return log_error_errno(r, "Failed to get next entry from /proc/self/mountinfo: %m");
- device = mnt_fs_get_source(fs);
- path = mnt_fs_get_target(fs);
- options = mnt_fs_get_options(fs);
- fstype = mnt_fs_get_fstype(fs);
+ device = sym_mnt_fs_get_source(fs);
+ path = sym_mnt_fs_get_target(fs);
+ options = sym_mnt_fs_get_options(fs);
+ fstype = sym_mnt_fs_get_fstype(fs);
if (!device || !path)
continue;
m->mount_event_source = sd_event_source_disable_unref(m->mount_event_source);
- mnt_unref_monitor(m->mount_monitor);
- m->mount_monitor = NULL;
+ if (m->mount_monitor) {
+ sym_mnt_unref_monitor(m->mount_monitor);
+ m->mount_monitor = NULL;
+ }
}
static void mount_handoff_timestamp(
assert(m);
- mnt_init_debug(0);
+ r = dlopen_libmount();
+ if (r < 0) {
+ log_error_errno(r, "Cannot enumerate mounts, as libmount is not available: %m");
+ goto fail;
+ }
+
+ sym_mnt_init_debug(0);
if (!m->mount_monitor) {
usec_t mount_rate_limit_interval = 1 * USEC_PER_SEC;
unsigned mount_rate_limit_burst = 5;
int fd;
- m->mount_monitor = mnt_new_monitor();
+ m->mount_monitor = sym_mnt_new_monitor();
if (!m->mount_monitor) {
log_oom();
goto fail;
}
- r = mnt_monitor_enable_kernel(m->mount_monitor, 1);
+ r = sym_mnt_monitor_enable_kernel(m->mount_monitor, 1);
if (r < 0) {
log_error_errno(r, "Failed to enable watching of kernel mount events: %m");
goto fail;
}
- r = mnt_monitor_enable_userspace(m->mount_monitor, 1, NULL);
+ r = sym_mnt_monitor_enable_userspace(m->mount_monitor, 1, NULL);
if (r < 0) {
log_error_errno(r, "Failed to enable watching of userspace mount events: %m");
goto fail;
}
/* mnt_unref_monitor() will close the fd */
- fd = r = mnt_monitor_get_fd(m->mount_monitor);
+ fd = r = sym_mnt_monitor_get_fd(m->mount_monitor);
if (r < 0) {
log_error_errno(r, "Failed to acquire watch file descriptor: %m");
goto fail;
assert(m);
+ if (!m->mount_monitor)
+ return false;
+
/* Drain all events and verify that the event is valid.
*
* Note that libmount also monitors /run/mount mkdir if the directory does not exist yet. The mkdir
*
* error: r < 0; valid: r == 0, false positive: r == 1 */
do {
- r = mnt_monitor_next_change(m->mount_monitor, NULL, NULL);
+ r = sym_mnt_monitor_next_change(m->mount_monitor, NULL, NULL);
if (r < 0)
return log_error_errno(r, "Failed to drain libmount events: %m");
if (r == 0)
_cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
int r;
- table = mnt_new_table();
+ r = dlopen_libmount();
+ if (r < 0)
+ return r;
+
+ table = sym_mnt_new_table();
if (!table)
return -ENOMEM;
- r = mnt_table_parse_mtab(table, /* filename= */ NULL);
+ r = sym_mnt_table_parse_mtab(table, /* filename= */ NULL);
if (r < 0)
return r;
- struct libmnt_fs *fs = mnt_table_find_devno(table, devno, MNT_ITER_FORWARD);
+ struct libmnt_fs *fs = sym_mnt_table_find_devno(table, devno, MNT_ITER_FORWARD);
if (!fs)
return -ENODEV;
- r = mnt_fs_get_option(fs, "noswap", /* value= */ NULL, /* valuesz= */ NULL);
+ r = sym_mnt_fs_get_option(fs, "noswap", /* value= */ NULL, /* valuesz= */ NULL);
if (r < 0)
return r;
'public' : true,
'sources' : files('creds.c'),
'dependencies' : [
- libmount,
+ libmount_cflags,
libopenssl,
threads,
],
for (;;) {
struct libmnt_fs *fs;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r != 0)
return NULL;
- if (path_equal(mnt_fs_get_source(fs), device)) {
- const char *target = mnt_fs_get_target(fs);
+ if (path_equal(sym_mnt_fs_get_source(fs), device)) {
+ const char *target = sym_mnt_fs_get_target(fs);
if (target)
return strdup(target);
}
'sources' : systemd_cryptsetup_sources,
'dependencies' : [
libcryptsetup,
- libmount,
+ libmount_cflags,
libopenssl,
libp11kit_cflags,
],
for (;;) {
struct libmnt_fs *fs;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r < 0)
return log_error_errno(r, "Failed to get next entry from '%s': %m", fstab);
if (r > 0) /* EOF */
return ret;
- r = parse_fstab_one(fstab,
- mnt_fs_get_source(fs), mnt_fs_get_target(fs),
- mnt_fs_get_fstype(fs), mnt_fs_get_options(fs), mnt_fs_get_passno(fs),
- prefix_sysroot,
- /* accept_root = */ false,
- /* use_swap_enabled = */ true);
+ r = parse_fstab_one(
+ fstab,
+ sym_mnt_fs_get_source(fs),
+ sym_mnt_fs_get_target(fs),
+ sym_mnt_fs_get_fstype(fs),
+ sym_mnt_fs_get_options(fs),
+ sym_mnt_fs_get_passno(fs),
+ prefix_sysroot,
+ /* accept_root = */ false,
+ /* use_swap_enabled = */ true);
if (arg_sysroot_check && r > 0)
return true; /* We found a mount or swap that would be started… */
RET_GATHER(ret, r);
for (;;) {
struct libmnt_fs *fs;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r < 0)
return log_error_errno(r, "Failed to get next fstab entry from credential '%s': %m", cred);
if (r > 0) /* EOF */
return ret;
- RET_GATHER(ret, parse_fstab_one("/run/credentials",
- mnt_fs_get_source(fs), mnt_fs_get_target(fs),
- mnt_fs_get_fstype(fs), mnt_fs_get_options(fs), mnt_fs_get_passno(fs),
- prefix_sysroot,
- /* accept_root = */ true,
- /* use_swap_enabled = */ true));
+ RET_GATHER(ret, parse_fstab_one(
+ "/run/credentials",
+ sym_mnt_fs_get_source(fs),
+ sym_mnt_fs_get_target(fs),
+ sym_mnt_fs_get_fstype(fs),
+ sym_mnt_fs_get_options(fs),
+ sym_mnt_fs_get_passno(fs),
+ prefix_sysroot,
+ /* accept_root = */ true,
+ /* use_swap_enabled = */ true));
}
}
generator_template + {
'name' : 'systemd-fstab-generator',
'sources' : files('fstab-generator.c'),
- 'dependencies' : libmount,
+ 'dependencies' : libmount_cflags,
},
]
'name' : 'systemd-mount',
'public' : true,
'sources' : files('mount-tool.c'),
- 'dependencies' : libmount,
+ 'dependencies' : libmount_cflags,
},
]
struct libmnt_fs *fs;
const char *source, *target;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r == 1)
break;
if (r < 0)
return log_error_errno(r, "Failed to get next entry from /proc/self/mountinfo: %m");
- source = mnt_fs_get_source(fs);
- target = mnt_fs_get_target(fs);
+ source = sym_mnt_fs_get_source(fs);
+ target = sym_mnt_fs_get_target(fs);
if (!source || !target)
continue;
libexec_template + {
'name' : 'systemd-remount-fs',
'sources' : files('remount-fs.c'),
- 'dependencies' : libmount,
+ 'dependencies' : libmount_cflags,
},
]
for (;;) {
struct libmnt_fs *fs;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r < 0)
return log_error_errno(r, "Failed to get next entry from fstab: %m");
if (r > 0) /* EOF */
break;
- const char *target = mnt_fs_get_target(fs);
+ const char *target = sym_mnt_fs_get_target(fs);
if (!target)
continue;
for (;;) {
struct libmnt_fs *fs;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r < 0)
return r;
if (r > 0) /* EOF */
return false;
- if (streq_ptr(mnt_fs_get_fstype(fs), fstype))
+ if (streq_ptr(sym_mnt_fs_get_fstype(fs), fstype))
return true;
}
}
struct libmnt_fs *fs;
const char *path;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r < 0)
return r;
if (r > 0) /* EOF */
return false;
- path = mnt_fs_get_target(fs);
+ path = sym_mnt_fs_get_target(fs);
if (!path)
continue;
for (;;) {
struct libmnt_fs *fs;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r < 0)
return r;
if (r > 0) /* EOF */
return false;
- if (where && !path_equal(mnt_fs_get_target(fs), where))
+ if (where && !path_equal(sym_mnt_fs_get_target(fs), where))
continue;
if (!path)
return true;
- r = fstab_is_same_node(mnt_fs_get_source(fs), path);
+ r = fstab_is_same_node(sym_mnt_fs_get_source(fs), path);
if (r > 0 || (r < 0 && !ERRNO_IS_DEVICE_ABSENT(r)))
return r;
}
#include "libmount-util.h"
#include "log.h"
+static void *libmount_dl = NULL;
+
+DLSYM_PROTOTYPE(mnt_free_iter) = NULL;
+DLSYM_PROTOTYPE(mnt_free_table) = NULL;
+DLSYM_PROTOTYPE(mnt_fs_get_fs_options) = NULL;
+DLSYM_PROTOTYPE(mnt_fs_get_fstype) = NULL;
+DLSYM_PROTOTYPE(mnt_fs_get_id) = NULL;
+DLSYM_PROTOTYPE(mnt_fs_get_option) = NULL;
+DLSYM_PROTOTYPE(mnt_fs_get_options) = NULL;
+DLSYM_PROTOTYPE(mnt_fs_get_passno) = NULL;
+DLSYM_PROTOTYPE(mnt_fs_get_propagation) = NULL;
+DLSYM_PROTOTYPE(mnt_fs_get_source) = NULL;
+DLSYM_PROTOTYPE(mnt_fs_get_target) = NULL;
+DLSYM_PROTOTYPE(mnt_fs_get_vfs_options) = NULL;
+DLSYM_PROTOTYPE(mnt_get_builtin_optmap) = NULL;
+DLSYM_PROTOTYPE(mnt_init_debug) = NULL;
+DLSYM_PROTOTYPE(mnt_monitor_enable_kernel) = NULL;
+DLSYM_PROTOTYPE(mnt_monitor_enable_userspace) = NULL;
+DLSYM_PROTOTYPE(mnt_monitor_get_fd) = NULL;
+DLSYM_PROTOTYPE(mnt_monitor_next_change) = NULL;
+DLSYM_PROTOTYPE(mnt_new_iter) = NULL;
+DLSYM_PROTOTYPE(mnt_new_monitor) = NULL;
+DLSYM_PROTOTYPE(mnt_new_table) = NULL;
+DLSYM_PROTOTYPE(mnt_optstr_get_flags) = NULL;
+DLSYM_PROTOTYPE(mnt_table_find_devno) = NULL;
+DLSYM_PROTOTYPE(mnt_table_find_target) = NULL;
+DLSYM_PROTOTYPE(mnt_table_next_child_fs) = NULL;
+DLSYM_PROTOTYPE(mnt_table_next_fs) = NULL;
+DLSYM_PROTOTYPE(mnt_table_parse_file) = NULL;
+DLSYM_PROTOTYPE(mnt_table_parse_mtab) = NULL;
+DLSYM_PROTOTYPE(mnt_table_parse_stream) = NULL;
+DLSYM_PROTOTYPE(mnt_table_parse_swaps) = NULL;
+DLSYM_PROTOTYPE(mnt_unref_monitor) = NULL;
+
+int dlopen_libmount(void) {
+ ELF_NOTE_DLOPEN("mount",
+ "Support for mount enumeration",
+ ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED,
+ "libmount.so.1");
+
+ return dlopen_many_sym_or_warn(
+ &libmount_dl,
+ "libmount.so.1",
+ LOG_DEBUG,
+ DLSYM_ARG(mnt_free_iter),
+ DLSYM_ARG(mnt_free_table),
+ DLSYM_ARG(mnt_fs_get_fs_options),
+ DLSYM_ARG(mnt_fs_get_fstype),
+ DLSYM_ARG(mnt_fs_get_id),
+ DLSYM_ARG(mnt_fs_get_option),
+ DLSYM_ARG(mnt_fs_get_options),
+ DLSYM_ARG(mnt_fs_get_passno),
+ DLSYM_ARG(mnt_fs_get_propagation),
+ DLSYM_ARG(mnt_fs_get_source),
+ DLSYM_ARG(mnt_fs_get_target),
+ DLSYM_ARG(mnt_fs_get_vfs_options),
+ DLSYM_ARG(mnt_get_builtin_optmap),
+ DLSYM_ARG(mnt_init_debug),
+ DLSYM_ARG(mnt_monitor_enable_kernel),
+ DLSYM_ARG(mnt_monitor_enable_userspace),
+ DLSYM_ARG(mnt_monitor_get_fd),
+ DLSYM_ARG(mnt_monitor_next_change),
+ DLSYM_ARG(mnt_new_iter),
+ DLSYM_ARG(mnt_new_monitor),
+ DLSYM_ARG(mnt_new_table),
+ DLSYM_ARG(mnt_optstr_get_flags),
+ DLSYM_ARG(mnt_table_find_devno),
+ DLSYM_ARG(mnt_table_find_target),
+ DLSYM_ARG(mnt_table_next_child_fs),
+ DLSYM_ARG(mnt_table_next_fs),
+ DLSYM_ARG(mnt_table_parse_file),
+ DLSYM_ARG(mnt_table_parse_mtab),
+ DLSYM_ARG(mnt_table_parse_stream),
+ DLSYM_ARG(mnt_table_parse_swaps),
+ DLSYM_ARG(mnt_unref_monitor));
+}
+
int libmount_parse_full(
const char *path,
FILE *source,
/* Older libmount seems to require this. */
assert(!source || path);
- table = mnt_new_table();
- iter = mnt_new_iter(MNT_ITER_FORWARD);
+ r = dlopen_libmount();
+ if (r < 0)
+ return r;
+
+ table = sym_mnt_new_table();
+ iter = sym_mnt_new_iter(MNT_ITER_FORWARD);
if (!table || !iter)
return -ENOMEM;
* Only if both are empty, we use mnt_table_parse_mtab(). */
if (source)
- r = mnt_table_parse_stream(table, source, path);
+ r = sym_mnt_table_parse_stream(table, source, path);
else if (path)
- r = mnt_table_parse_file(table, path);
+ r = sym_mnt_table_parse_file(table, path);
else
- r = mnt_table_parse_mtab(table, NULL);
+ r = sym_mnt_table_parse_mtab(table, NULL);
if (r < 0)
return r;
struct libmnt_fs *fs) {
int r;
+ assert(table);
+
_cleanup_(mnt_free_iterp) struct libmnt_iter *iter_children = NULL;
- iter_children = mnt_new_iter(MNT_ITER_FORWARD);
+ iter_children = sym_mnt_new_iter(MNT_ITER_FORWARD);
if (!iter_children)
return log_oom();
/* We care only whether it exists, it is unused */
_unused_ struct libmnt_fs *child;
- r = mnt_table_next_child_fs(table, iter_children, fs, &child);
+ r = sym_mnt_table_next_child_fs(table, iter_children, fs, &child);
if (r < 0)
return r;
/* This needs to be after sys/mount.h */
#include <libmount.h> /* IWYU pragma: export */
+#include "dlfcn-util.h"
#include "forward.h"
-DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct libmnt_table*, mnt_free_table, NULL);
-DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct libmnt_iter*, mnt_free_iter, NULL);
+extern DLSYM_PROTOTYPE(mnt_free_iter);
+extern DLSYM_PROTOTYPE(mnt_free_table);
+extern DLSYM_PROTOTYPE(mnt_fs_get_fs_options);
+extern DLSYM_PROTOTYPE(mnt_fs_get_fstype);
+extern DLSYM_PROTOTYPE(mnt_fs_get_id);
+extern DLSYM_PROTOTYPE(mnt_fs_get_option);
+extern DLSYM_PROTOTYPE(mnt_fs_get_options);
+extern DLSYM_PROTOTYPE(mnt_fs_get_passno);
+extern DLSYM_PROTOTYPE(mnt_fs_get_propagation);
+extern DLSYM_PROTOTYPE(mnt_fs_get_source);
+extern DLSYM_PROTOTYPE(mnt_fs_get_target);
+extern DLSYM_PROTOTYPE(mnt_fs_get_vfs_options);
+extern DLSYM_PROTOTYPE(mnt_get_builtin_optmap);
+extern DLSYM_PROTOTYPE(mnt_init_debug);
+extern DLSYM_PROTOTYPE(mnt_monitor_enable_kernel);
+extern DLSYM_PROTOTYPE(mnt_monitor_enable_userspace);
+extern DLSYM_PROTOTYPE(mnt_monitor_get_fd);
+extern DLSYM_PROTOTYPE(mnt_monitor_next_change);
+extern DLSYM_PROTOTYPE(mnt_new_iter);
+extern DLSYM_PROTOTYPE(mnt_new_monitor);
+extern DLSYM_PROTOTYPE(mnt_new_table);
+extern DLSYM_PROTOTYPE(mnt_optstr_get_flags);
+extern DLSYM_PROTOTYPE(mnt_table_find_devno);
+extern DLSYM_PROTOTYPE(mnt_table_find_target);
+extern DLSYM_PROTOTYPE(mnt_table_next_child_fs);
+extern DLSYM_PROTOTYPE(mnt_table_next_fs);
+extern DLSYM_PROTOTYPE(mnt_table_parse_file);
+extern DLSYM_PROTOTYPE(mnt_table_parse_mtab);
+extern DLSYM_PROTOTYPE(mnt_table_parse_stream);
+extern DLSYM_PROTOTYPE(mnt_table_parse_swaps);
+extern DLSYM_PROTOTYPE(mnt_unref_monitor);
+
+int dlopen_libmount(void);
+
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct libmnt_table*, sym_mnt_free_table, mnt_free_tablep, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct libmnt_iter*, sym_mnt_free_iter, mnt_free_iterp, NULL);
int libmount_parse_full(
const char *path,
libgcrypt_cflags,
libkmod_cflags,
liblz4_cflags,
- libmount,
+ libmount_cflags,
libopenssl,
libp11kit_cflags,
libpam_cflags,
struct libmnt_fs *fs;
const char *path;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r == 1)
break;
if (r < 0)
return log_debug_errno(r, "Failed to get next entry from /proc/self/mountinfo: %m");
- path = mnt_fs_get_target(fs);
+ path = sym_mnt_fs_get_target(fs);
if (!path)
continue;
unsigned long flags = 0;
struct libmnt_fs *fs;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r == 1) /* EOF */
break;
if (r < 0)
return log_debug_errno(r, "Failed to get next entry from /proc/self/mountinfo: %m");
- path = mnt_fs_get_target(fs);
+ path = sym_mnt_fs_get_target(fs);
if (!path)
continue;
if (!path_startswith(path, prefix))
continue;
- type = mnt_fs_get_fstype(fs);
+ type = sym_mnt_fs_get_fstype(fs);
if (!type)
continue;
continue;
}
- opts = mnt_fs_get_vfs_options(fs);
+ opts = sym_mnt_fs_get_vfs_options(fs);
if (opts) {
- r = mnt_optstr_get_flags(opts, &flags, mnt_get_builtin_optmap(MNT_LINUX_MAP));
+ r = sym_mnt_optstr_get_flags(opts, &flags, sym_mnt_get_builtin_optmap(MNT_LINUX_MAP));
if (r < 0)
log_debug_errno(r, "Could not get flags for '%s', ignoring: %m", path);
}
rewind(proc_self_mountinfo);
- table = mnt_new_table();
+ r = dlopen_libmount();
+ if (r < 0)
+ return r;
+
+ table = sym_mnt_new_table();
if (!table)
return -ENOMEM;
- r = mnt_table_parse_stream(table, proc_self_mountinfo, "/proc/self/mountinfo");
+ r = sym_mnt_table_parse_stream(table, proc_self_mountinfo, "/proc/self/mountinfo");
if (r < 0)
return r;
- fs = mnt_table_find_target(table, path, MNT_ITER_FORWARD);
+ fs = sym_mnt_table_find_target(table, path, MNT_ITER_FORWARD);
if (!fs) {
r = access_nofollow(path, F_OK); /* Hmm, it's not in the mount table, but does it exist at all? */
if (r < 0)
return -EINVAL; /* Not a mount point we recognize */
}
- opts = mnt_fs_get_vfs_options(fs);
+ opts = sym_mnt_fs_get_vfs_options(fs);
if (opts) {
- r = mnt_optstr_get_flags(opts, &flags, mnt_get_builtin_optmap(MNT_LINUX_MAP));
+ r = sym_mnt_optstr_get_flags(opts, &flags, sym_mnt_get_builtin_optmap(MNT_LINUX_MAP));
if (r < 0)
log_debug_errno(r, "Could not get flags for '%s', ignoring: %m", path);
}
assert(ret_mount_flags);
assert(ret_remaining_options);
- map = mnt_get_builtin_optmap(MNT_LINUX_MAP);
+ r = dlopen_libmount();
+ if (r < 0)
+ return r;
+
+ map = sym_mnt_get_builtin_optmap(MNT_LINUX_MAP);
if (!map)
return -EINVAL;
const char *path;
int id1, id2;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r == 1)
break; /* EOF */
if (r < 0)
return log_debug_errno(r, "Failed to get next entry from /proc/self/mountinfo: %m");
- path = mnt_fs_get_target(fs);
+ path = sym_mnt_fs_get_target(fs);
if (!path)
continue;
if (isempty(path_startswith(path, prefix)))
continue;
- id1 = mnt_fs_get_id(fs);
+ id1 = sym_mnt_fs_get_id(fs);
r = path_get_mnt_id(path, &id2);
if (r < 0) {
log_debug_errno(r, "Failed to get mount ID of '%s', ignoring: %m", path);
for (;;) {
struct libmnt_fs *fs;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r == 1)
break; /* EOF */
if (r < 0)
return log_debug_errno(r, "Failed to get next entry from /proc/self/mountinfo: %m");
- if (mnt_fs_get_id(fs) != mnt_id)
+ if (sym_mnt_fs_get_id(fs) != mnt_id)
continue;
_cleanup_free_ char *fstype = NULL, *options = NULL, *source = NULL;
if (ret_fstype) {
- fstype = strdup(strempty(mnt_fs_get_fstype(fs)));
+ fstype = strdup(strempty(sym_mnt_fs_get_fstype(fs)));
if (!fstype)
return log_oom_debug();
}
if (ret_options) {
- options = strdup(strempty(mnt_fs_get_options(fs)));
+ options = strdup(strempty(sym_mnt_fs_get_options(fs)));
if (!options)
return log_oom_debug();
}
if (ret_source) {
- source = strdup(strempty(mnt_fs_get_source(fs)));
+ source = strdup(strempty(sym_mnt_fs_get_source(fs)));
if (!source)
return log_oom_debug();
}
assert(head);
- t = mnt_new_table();
- i = mnt_new_iter(MNT_ITER_FORWARD);
+ r = dlopen_libmount();
+ if (r < 0)
+ return log_error_errno(r, "Cannot enumerate swap partitions, no libmount support.");
+
+ t = sym_mnt_new_table();
+ i = sym_mnt_new_iter(MNT_ITER_FORWARD);
if (!t || !i)
return log_oom();
- r = mnt_table_parse_swaps(t, swaps);
+ r = sym_mnt_table_parse_swaps(t, swaps);
if (r == -ENOENT) /* no /proc/swaps is fine */
return 0;
if (r < 0)
_cleanup_free_ SwapDevice *swap = NULL;
const char *source;
- r = mnt_table_next_fs(t, i, &fs);
+ r = sym_mnt_table_next_fs(t, i, &fs);
if (r == 1) /* EOF */
break;
if (r < 0)
return log_error_errno(r, "Failed to get next entry from %s: %m", swaps ?: "/proc/swaps");
- source = mnt_fs_get_source(fs);
+ source = sym_mnt_fs_get_source(fs);
if (!source)
continue;
'name' : 'systemd-shutdown',
'sources' : systemd_shutdown_sources + systemd_shutdown_extract_sources,
'extract' : systemd_shutdown_extract_sources,
- 'dependencies' : libmount,
+ 'dependencies' : libmount_cflags,
},
libexec_template + {
'name' : 'systemd-shutdown.standalone',
libshared_static,
libsystemd_static,
],
- 'dependencies' : libmount,
+ 'dependencies' : libmount_cflags,
},
test_template + {
'sources' : files('test-umount.c'),
'objects' : ['systemd-shutdown'],
- 'dependencies' : libmount,
+ 'dependencies' : libmount_cflags,
},
]
bool try_remount_ro, is_api_vfs, is_network;
_cleanup_free_ MountPoint *m = NULL;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r == 1) /* EOF */
break;
if (r < 0)
return log_error_errno(r, "Failed to get next entry from /proc/self/mountinfo: %m");
- path = mnt_fs_get_target(fs);
+ path = sym_mnt_fs_get_target(fs);
if (!path)
continue;
- fstype = mnt_fs_get_fstype(fs);
+ fstype = sym_mnt_fs_get_fstype(fs);
/* Combine the generic VFS options with the FS-specific options. Duplicates are not a problem
* here, because the only options that should come up twice are typically ro/rw, which are
*
* Even if there are duplicates later in mount_option_mangle() they shouldn't hurt anyways as
* they override each other. */
- if (!strextend_with_separator(&options, ",", mnt_fs_get_vfs_options(fs)))
+ if (!strextend_with_separator(&options, ",", sym_mnt_fs_get_vfs_options(fs)))
return log_oom();
- if (!strextend_with_separator(&options, ",", mnt_fs_get_fs_options(fs)))
+ if (!strextend_with_separator(&options, ",", sym_mnt_fs_get_fs_options(fs)))
return log_oom();
/* Ignore mount points we can't unmount because they are API or because we are keeping them
* were when the filesystem was mounted, except for the desired changes. So we
* reconstruct both here and adjust them for the later remount call too. */
- r = mnt_fs_get_propagation(fs, &remount_flags);
+ r = sym_mnt_fs_get_propagation(fs, &remount_flags);
if (r < 0) {
log_warning_errno(r, "mnt_fs_get_propagation() failed for %s, ignoring: %m", path);
continue;
############################################################
common_test_dependencies = [
- libmount,
+ libmount_cflags,
librt,
libseccomp_cflags,
libselinux,
'dependencies' : [
libblkid_cflags,
libkmod_cflags,
+ libmount_cflags,
libp11kit_cflags,
libseccomp_cflags,
],
test_template + {
'sources' : files('test-libmount.c'),
'dependencies' : [
- libmount,
+ libmount_cflags,
threads,
],
},
},
test_template + {
'sources' : files('test-mount-util.c'),
- 'dependencies' : libmount,
+ 'dependencies' : libmount_cflags,
},
test_template + {
'sources' : files('test-netlink-manual.c'),
#include "libarchive-util.h"
#include "libaudit-util.h"
#include "libfido2-util.h"
+#include "libmount-util.h"
#include "main-func.h"
#include "module-util.h"
#include "pam-util.h"
ASSERT_DLOPEN(dlopen_libacl, HAVE_ACL);
ASSERT_DLOPEN(dlopen_libblkid, HAVE_BLKID);
ASSERT_DLOPEN(dlopen_libseccomp, HAVE_SECCOMP);
+ ASSERT_DLOPEN(dlopen_libmount, true);
return 0;
}
/* We allow this call and the checks below to fail in some cases. See the case definitions below. */
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r != 0 && may_fail) {
log_error_errno(r, "mnt_table_next_fs failed: %m");
return;
assert_se(x = cescape(string));
- assert_se(source = mnt_fs_get_source(fs));
- assert_se(target = mnt_fs_get_target(fs));
+ assert_se(source = sym_mnt_fs_get_source(fs));
+ assert_se(target = sym_mnt_fs_get_target(fs));
assert_se(cs = cescape(source));
assert_se(ct = cescape(target));
assert_se(may_fail || streq(source, expected_source));
assert_se(may_fail || streq(target, expected_target));
- assert_se(mnt_table_next_fs(table, iter, &fs) == 1);
+ assert_se(sym_mnt_table_next_fs(table, iter, &fs) == 1);
}
TEST(libmount_unescaping) {
for (;;) {
struct libmnt_fs *fs;
- r = mnt_table_next_fs(table, iter, &fs);
+ r = sym_mnt_table_next_fs(table, iter, &fs);
if (r == 1)
break;
if (r < 0) {
_exit(EXIT_FAILURE);
}
- log_debug("left after complete umount: %s", mnt_fs_get_target(fs));
+ log_debug("left after complete umount: %s", sym_mnt_fs_get_target(fs));
}
_exit(EXIT_SUCCESS);