Skip to content

Commit 35df78c

Browse files
committed
fstab-util: add fstab_is_bind
1 parent d7d3625 commit 35df78c

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

src/core/mount.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,7 @@ static bool mount_is_loop(const MountParameters *p) {
123123

124124
static bool mount_is_bind(const MountParameters *p) {
125125
assert(p);
126-
127-
if (fstab_test_option(p->options, "bind\0" "rbind\0"))
128-
return true;
129-
130-
if (p->fstype && STR_IN_SET(p->fstype, "bind", "rbind"))
131-
return true;
132-
133-
return false;
126+
return fstab_is_bind(p->options, p->fstype);
134127
}
135128

136129
static bool mount_is_bound_to_device(Mount *m) {

src/shared/fstab-util.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ int fstab_has_fstype(const char *fstype) {
2020
_cleanup_endmntent_ FILE *f = NULL;
2121
struct mntent *m;
2222

23+
assert(fstype);
24+
2325
f = setmntent(fstab_path(), "re");
2426
if (!f)
2527
return errno == ENOENT ? false : -errno;
@@ -288,3 +290,14 @@ char *fstab_node_to_udev_node(const char *p) {
288290

289291
return strdup(p);
290292
}
293+
294+
bool fstab_is_bind(const char *options, const char *fstype) {
295+
296+
if (fstab_test_option(options, "bind\0" "rbind\0"))
297+
return true;
298+
299+
if (fstype && STR_IN_SET(fstype, "bind", "rbind"))
300+
return true;
301+
302+
return false;
303+
}

src/shared/fstab-util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,5 @@ char *fstab_node_to_udev_node(const char *p);
4040
static inline const char* fstab_path(void) {
4141
return secure_getenv("SYSTEMD_FSTAB") ?: "/etc/fstab";
4242
}
43+
44+
bool fstab_is_bind(const char *options, const char *fstype);

0 commit comments

Comments
 (0)