]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/shared/libmount-util.h
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
6 /* This needs to be after sys/mount.h */
11 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct libmnt_table
*, mnt_free_table
, NULL
);
12 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct libmnt_iter
*, mnt_free_iter
, NULL
);
14 static inline int libmount_parse(
17 struct libmnt_table
**ret_table
,
18 struct libmnt_iter
**ret_iter
) {
20 _cleanup_(mnt_free_tablep
) struct libmnt_table
*table
= NULL
;
21 _cleanup_(mnt_free_iterp
) struct libmnt_iter
*iter
= NULL
;
24 /* Older libmount seems to require this. */
25 assert(!source
|| path
);
27 table
= mnt_new_table();
28 iter
= mnt_new_iter(MNT_ITER_FORWARD
);
32 /* If source or path are specified, we use on the functions which ignore utab.
33 * Only if both are empty, we use mnt_table_parse_mtab(). */
36 r
= mnt_table_parse_stream(table
, source
, path
);
38 r
= mnt_table_parse_file(table
, path
);
40 r
= mnt_table_parse_mtab(table
, NULL
);
44 *ret_table
= TAKE_PTR(table
);
45 *ret_iter
= TAKE_PTR(iter
);