diff options
| author | Karel Zak <kzak@redhat.com> | 2024-06-13 10:30:24 +0200 |
|---|---|---|
| committer | Karel Zak <kzak@redhat.com> | 2025-01-08 13:57:42 +0100 |
| commit | ba353afbeba6bcb7a07c447ee6832aa51eaf70ad (patch) | |
| tree | d98bca0ca62f44a7738563d38845acac7ec346a1 /libmount/src/fs.c | |
| parent | fa34e4166b6a33a43df7bd96b40079f92bb6f72c (diff) | |
| download | util-linux-ba353afbeba6bcb7a07c447ee6832aa51eaf70ad.tar.gz | |
libmount: remember parsed propagation
This change allows propagation flags to be retained from another
source, such as statmount().
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/fs.c')
| -rw-r--r-- | libmount/src/fs.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/libmount/src/fs.c b/libmount/src/fs.c index 26f2c69e90..5b3a5511f4 100644 --- a/libmount/src/fs.c +++ b/libmount/src/fs.c @@ -100,6 +100,7 @@ void mnt_reset_fs(struct libmnt_fs *fs) fs->optlist = NULL; fs->opts_age = 0; + fs->propagation = 0; memset(fs, 0, sizeof(*fs)); INIT_LIST_HEAD(&fs->ents); @@ -657,21 +658,21 @@ int mnt_fs_get_propagation(struct libmnt_fs *fs, unsigned long *flags) if (!fs || !flags) return -EINVAL; - *flags = 0; - - if (!fs->opt_fields) - return 0; - - /* - * The optional fields format is incompatible with mount options - * ... we have to parse the field here. - */ - *flags |= strstr(fs->opt_fields, "shared:") ? MS_SHARED : MS_PRIVATE; + if (!fs->propagation && fs->opt_fields) { + /* + * The optional fields format is incompatible with mount options + * ... we have to parse the field here. + */ + fs->propagation |= strstr(fs->opt_fields, "shared:") ? + MS_SHARED : MS_PRIVATE; + + if (strstr(fs->opt_fields, "master:")) + fs->propagation |= MS_SLAVE; + if (strstr(fs->opt_fields, "unbindable")) + fs->propagation |= MS_UNBINDABLE; + } - if (strstr(fs->opt_fields, "master:")) - *flags |= MS_SLAVE; - if (strstr(fs->opt_fields, "unbindable")) - *flags |= MS_UNBINDABLE; + *flags = fs->propagation; return 0; } |
