libmount = dependency('mount',
version : fuzzer_build ? '>= 0' : '>= 2.30',
- disabler : true,
required : get_option('libmount'))
+have = libmount.found()
+conf.set10('HAVE_LIBMOUNT', have)
libmount_cflags = libmount.partial_dependency(includes: true, compile_args: true)
libfdisk = dependency('fdisk',
# SPDX-License-Identifier: LGPL-2.1-or-later
+load_fragment_gperf_gperf = custom_target(
+ input : 'load-fragment-gperf.gperf.in',
+ output: 'load-fragment-gperf.gperf',
+ command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'])
+
+libcore_build_dir = meson.current_build_dir()
+core_includes = [includes, include_directories('.')]
+
+systemd_pc = custom_target(
+ input : 'systemd.pc.in',
+ output : 'systemd.pc',
+ command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
+ install : pkgconfigdatadir != 'no',
+ install_tag : 'devel',
+ install_dir : pkgconfigdatadir)
+
+if conf.get('HAVE_LIBMOUNT') != 1
+ libcore = disabler()
+
+ core_test_template = test_template + {
+ 'link_with' : [
+ libcore,
+ libshared,
+ ],
+ 'include_directories' : core_includes,
+ 'suite' : 'core',
+ }
+
+ subdir_done()
+endif
+
libcore_sources = files(
'audit-fd.c',
'automount.c',
sources += libcore_sources
-load_fragment_gperf_gperf = custom_target(
- input : 'load-fragment-gperf.gperf.in',
- output: 'load-fragment-gperf.gperf',
- command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'])
-
load_fragment_gperf_c = custom_target(
input : load_fragment_gperf_gperf,
output : 'load-fragment-gperf.c',
generated_sources += [load_fragment_gperf_c, load_fragment_gperf_nulstr_c, bpf_delegate_configs_inc]
libcore_sources += [load_fragment_gperf_c, load_fragment_gperf_nulstr_c, bpf_delegate_configs_inc]
-libcore_build_dir = meson.current_build_dir()
libcore_name = 'systemd-core-@0@'.format(shared_lib_tag)
libcore_static = static_library(
install : true,
install_dir : pkglibdir)
-core_includes = [includes, include_directories('.')]
-
systemd_sources = files(
'main.c',
'crash-handler.c',
install_dir : dir)
endforeach
-systemd_pc = custom_target(
- input : 'systemd.pc.in',
- output : 'systemd.pc',
- command : [jinja2_cmdline, '@INPUT@', '@OUTPUT@'],
- install : pkgconfigdatadir != 'no',
- install_tag : 'devel',
- install_dir : pkgconfigdatadir)
-
install_data('org.freedesktop.systemd1.conf',
install_dir : dbuspolicydir)
install_data('org.freedesktop.systemd1.service',
# SPDX-License-Identifier: LGPL-2.1-or-later
+if conf.get('HAVE_LIBMOUNT') != 1
+ subdir_done()
+endif
+
executables += [
executable_template + {
'name' : 'systemd-creds',
# SPDX-License-Identifier: LGPL-2.1-or-later
-if conf.get('HAVE_LIBCRYPTSETUP') != 1
+if conf.get('HAVE_LIBCRYPTSETUP') != 1 or conf.get('HAVE_LIBMOUNT') != 1
subdir_done()
endif
# SPDX-License-Identifier: LGPL-2.1-or-later
+if conf.get('HAVE_LIBMOUNT') != 1
+ subdir_done()
+endif
+
executables += [
generator_template + {
'name' : 'systemd-fstab-generator',
# SPDX-License-Identifier: LGPL-2.1-or-later
+if conf.get('HAVE_LIBMOUNT') != 1
+ subdir_done()
+endif
+
executables += [
executable_template + {
'name' : 'systemd-mount',
# SPDX-License-Identifier: LGPL-2.1-or-later
+if conf.get('HAVE_LIBMOUNT') != 1
+ subdir_done()
+endif
+
executables += [
libexec_template + {
'name' : 'systemd-remount-fs',
}
int fstab_has_fstype(const char *fstype) {
+#if HAVE_LIBMOUNT
_cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
_cleanup_(mnt_free_iterp) struct libmnt_iter *iter = NULL;
int r;
if (streq_ptr(sym_mnt_fs_get_fstype(fs), fstype))
return true;
}
+#else
+ return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "libmount support not compiled in");
+#endif
}
bool fstab_is_extrinsic(const char *mount, const char *opts) {
return false;
}
+#if HAVE_LIBMOUNT
static int fstab_is_same_node(const char *what_fstab, const char *path) {
_cleanup_free_ char *node = NULL;
return false;
}
+#endif
int fstab_has_mount_point_prefix_strv(char * const *prefixes) {
+#if HAVE_LIBMOUNT
_cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
_cleanup_(mnt_free_iterp) struct libmnt_iter *iter = NULL;
int r;
if (path_startswith_strv(path, prefixes))
return true;
}
+#else
+ return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "libmount support not compiled in");
+#endif
}
int fstab_is_mount_point_full(const char *where, const char *path) {
+#if HAVE_LIBMOUNT
_cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
_cleanup_(mnt_free_iterp) struct libmnt_iter *iter = NULL;
int r;
if (r > 0 || (r < 0 && !ERRNO_IS_DEVICE_ABSENT(r)))
return r;
}
+#else
+ return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "libmount support not compiled in");
+#endif
}
int fstab_filter_options(
/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#include "libmount-util.h"
+
+#if HAVE_LIBMOUNT
#include <stdio.h>
#include "fstab-util.h"
-#include "libmount-util.h"
#include "log.h"
static void *libmount_dl = NULL;
DLSYM_PROTOTYPE(mnt_table_parse_stream) = NULL;
DLSYM_PROTOTYPE(mnt_table_parse_swaps) = NULL;
DLSYM_PROTOTYPE(mnt_unref_monitor) = NULL;
+#endif
int dlopen_libmount(void) {
+#if HAVE_LIBMOUNT
ELF_NOTE_DLOPEN("mount",
"Support for mount enumeration",
ELF_NOTE_DLOPEN_PRIORITY_RECOMMENDED,
DLSYM_ARG(mnt_table_parse_stream),
DLSYM_ARG(mnt_table_parse_swaps),
DLSYM_ARG(mnt_unref_monitor));
+#else
+ return -EOPNOTSUPP;
+#endif
}
+#if HAVE_LIBMOUNT
int libmount_parse_full(
const char *path,
FILE *source,
return r == 1;
}
+#endif
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
+#include "shared-forward.h"
+
+#if HAVE_LIBMOUNT
+
/* This needs to be after sys/mount.h */
#include <libmount.h> /* IWYU pragma: export */
#include "dlfcn-util.h"
-#include "shared-forward.h"
extern DLSYM_PROTOTYPE(mnt_free_iter);
extern DLSYM_PROTOTYPE(mnt_free_table);
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);
FILE *source,
struct libmnt_table **ret_table,
struct libmnt_iter **ret_iter) {
-
return libmount_parse_full("/proc/self/mountinfo", source, MNT_ITER_FORWARD, ret_table, ret_iter);
}
static inline int libmount_parse_with_utab(
struct libmnt_table **ret_table,
struct libmnt_iter **ret_iter) {
-
return libmount_parse_full(NULL, NULL, MNT_ITER_FORWARD, ret_table, ret_iter);
}
int libmount_is_leaf(
struct libmnt_table *table,
struct libmnt_fs *fs);
+#endif
+
+int dlopen_libmount(void);
#include "user-util.h"
int umount_recursive_full(const char *prefix, int flags, char **keep) {
+#if HAVE_LIBMOUNT
_cleanup_fclose_ FILE *f = NULL;
int n = 0, r;
}
return n;
+#else
+ return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "libmount support not compiled in");
+#endif
}
#define MS_CONVERTIBLE_FLAGS (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_NOSYMFOLLOW|MS_RELATIME|MS_NOATIME|MS_STRICTATIME|MS_NODIRATIME)
char **deny_list,
FILE *proc_self_mountinfo) {
- _cleanup_fclose_ FILE *proc_self_mountinfo_opened = NULL;
- _cleanup_set_free_ Set *done = NULL;
- unsigned n_tries = 0;
- int r;
-
assert(prefix);
if ((flags_mask & ~MS_CONVERTIBLE_FLAGS) == 0 && strv_isempty(deny_list) && !skip_mount_set_attr) {
return 0; /* Nice, this worked! */
}
+#if HAVE_LIBMOUNT
+ _cleanup_fclose_ FILE *proc_self_mountinfo_opened = NULL;
+ _cleanup_set_free_ Set *done = NULL;
+ unsigned n_tries = 0;
+ int r;
+
if (!proc_self_mountinfo) {
r = fopen_unlocked("/proc/self/mountinfo", "re", &proc_self_mountinfo_opened);
if (r < 0)
log_trace("Remounted %s.", x);
}
}
+#else
+ return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "libmount support not compiled in");
+#endif
}
int bind_remount_one_with_mountinfo(
unsigned long flags_mask,
FILE *proc_self_mountinfo) {
- _cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
- unsigned long flags = 0;
- struct libmnt_fs *fs;
- const char *opts;
- int r;
-
assert(path);
assert(proc_self_mountinfo);
return 0; /* Nice, this worked! */
}
+#if HAVE_LIBMOUNT
+ _cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
+ unsigned long flags = 0;
+ struct libmnt_fs *fs;
+ const char *opts;
+ int r;
+
rewind(proc_self_mountinfo);
r = dlopen_libmount();
}
return 0;
+#else
+ return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "libmount support not compiled in");
+#endif
}
int bind_remount_one(const char *path, unsigned long new_flags, unsigned long flags_mask) {
unsigned long *ret_mount_flags,
char **ret_remaining_options) {
+ assert(ret_mount_flags);
+ assert(ret_remaining_options);
+
+ if (!options) {
+ *ret_mount_flags = mount_flags;
+ *ret_remaining_options = NULL;
+ return 0;
+ }
+
+#if HAVE_LIBMOUNT
const struct libmnt_optmap *map;
_cleanup_free_ char *ret = NULL;
int r;
* The validity of options stored in '*ret_remaining_options' is not checked.
* If 'options' is NULL, this just copies 'mount_flags' to *ret_mount_flags. */
- assert(ret_mount_flags);
- assert(ret_remaining_options);
-
r = dlopen_libmount();
if (r < 0)
return r;
*ret_remaining_options = TAKE_PTR(ret);
return 0;
+#else
+ return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "libmount support not compiled in");
+#endif
}
static int mount_in_namespace_legacy(
free(s);
}
+#if HAVE_LIBMOUNT
static int sub_mount_compare(const SubMount *a, const SubMount *b) {
assert(a);
assert(b);
m = i;
}
}
+#endif
int get_sub_mounts(const char *prefix, SubMount **ret_mounts, size_t *ret_n_mounts) {
-
+#if HAVE_LIBMOUNT
_cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
_cleanup_(mnt_free_iterp) struct libmnt_iter *iter = NULL;
SubMount *mounts = NULL;
*ret_mounts = TAKE_PTR(mounts);
*ret_n_mounts = n;
return 0;
+#else
+ return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "libmount support not compiled in");
+#endif
}
int bind_mount_submounts(
char **ret_options,
char **ret_source) {
+#if HAVE_LIBMOUNT
_cleanup_(mnt_free_tablep) struct libmnt_table *table = NULL;
_cleanup_(mnt_free_iterp) struct libmnt_iter *iter = NULL;
int r, mnt_id;
}
return log_debug_errno(SYNTHETIC_ERRNO(ESTALE), "Cannot find mount ID %i from /proc/self/mountinfo.", mnt_id);
+#else
+ return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "libmount support not compiled in");
+#endif
}
int path_is_network_fs_harder_at(int dir_fd, const char *path) {
# SPDX-License-Identifier: LGPL-2.1-or-later
+if conf.get('HAVE_LIBMOUNT') != 1
+ subdir_done()
+endif
+
systemd_shutdown_sources = files(
'detach-dm.c',
'detach-loopback.c',
},
test_template + {
'sources' : files('test-libmount.c'),
+ 'conditions' : ['HAVE_LIBMOUNT'],
'dependencies' : [
libmount_cflags,
threads,
},
test_template + {
'sources' : files('test-mount-util.c'),
+ 'conditions' : ['HAVE_LIBMOUNT'],
'dependencies' : libmount_cflags,
},
test_template + {
ASSERT_DLOPEN(dlopen_libblkid, HAVE_BLKID);
ASSERT_DLOPEN(dlopen_libfido2, HAVE_LIBFIDO2);
ASSERT_DLOPEN(dlopen_libkmod, HAVE_KMOD);
- ASSERT_DLOPEN(dlopen_libmount, true);
+ ASSERT_DLOPEN(dlopen_libmount, HAVE_LIBMOUNT);
ASSERT_DLOPEN(dlopen_libpam, HAVE_PAM);
ASSERT_DLOPEN(dlopen_libseccomp, HAVE_SECCOMP);
ASSERT_DLOPEN(dlopen_libselinux, HAVE_SELINUX);
############################################################
test_compare_versions_sh = files('test-compare-versions.sh')
-if want_tests != 'false'
+if want_tests != 'false' and executables_by_name.has_key('systemd-analyze')
exe = executables_by_name.get('systemd-analyze')
test('test-compare-versions',
test_compare_versions_sh,
############################################################
test_fstab_generator_sh = files('test-fstab-generator.sh')
-if want_tests != 'false'
+if want_tests != 'false' and executables_by_name.has_key('systemd-fstab-generator')
exe = executables_by_name.get('systemd-fstab-generator')
test('test-fstab-generator',
test_fstab_generator_sh,
print(item, file=sys.stderr)
sys.exit(77 if arguments.test else 1)
- if not os.path.exists(f'{arguments.build_dir}/systemd'):
- sys.exit(f"{arguments.build_dir}/systemd doesn't exist. Use --build-dir=.")
+ if not os.path.exists(f'{arguments.build_dir}'):
+ sys.exit(f"{arguments.build_dir} doesn't exist.")
missing_version = []
stats = {page.split('/')[-1] : process(page, missing_version) for page in arguments.pages}