From 699abc838104ff18e0883d42cfdac60a7c9f03ab Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 21 Apr 2011 14:53:23 +0200 Subject: libmount: add support for x-* mount comments The current way how add any comment or extra information to /etc/fstab is to use comment="" mount option. This is not too elegant and readable if you want to add more than one comment. It seems better to add any generic prefix that will be used for all 3rd-party userspace mount options. Expected syntax is: x--[=] For example: x-systemd-bar=managed All x-* options (as well as comment=) are ignored by libmount and not stored to the mtab file. Requested-by: Lennart Poettering Signed-off-by: Karel Zak --- shlibs/mount/src/optmap.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'shlibs/mount/src/optmap.c') diff --git a/shlibs/mount/src/optmap.c b/shlibs/mount/src/optmap.c index acd76173f..7db6d0314 100644 --- a/shlibs/mount/src/optmap.c +++ b/shlibs/mount/src/optmap.c @@ -133,7 +133,7 @@ static const struct libmnt_optmap userspace_opts_map[] = { "auto", MNT_MS_NOAUTO, MNT_INVERT | MNT_NOMTAB }, /* Can be mounted using -a */ { "noauto", MNT_MS_NOAUTO, MNT_NOMTAB }, /* Can only be mounted explicitly */ - { "user[=]", MNT_MS_USER }, /* Allow ordinary user to mount (mtab) */ + { "user[=]", MNT_MS_USER }, /* Allow ordinary user to mount (mtab) */ { "nouser", MNT_MS_USER, MNT_INVERT | MNT_NOMTAB }, /* Forbid ordinary user to mount */ { "users", MNT_MS_USERS, MNT_NOMTAB }, /* Allow ordinary users to mount */ @@ -147,9 +147,10 @@ static const struct libmnt_optmap userspace_opts_map[] = { "_netdev", MNT_MS_NETDEV }, /* Device requires network */ - { "comment=", MNT_MS_COMMENT, MNT_NOMTAB }, /* fstab comment only */ + { "comment=", MNT_MS_COMMENT, MNT_NOMTAB }, /* fstab comment only */ + { "x-", MNT_MS_XCOMMENT, MNT_NOMTAB | MNT_PREFIX }, /* x- options */ - { "loop[=]", MNT_MS_LOOP }, /* use the loop device */ + { "loop[=]", MNT_MS_LOOP }, /* use the loop device */ { "nofail", MNT_MS_NOFAIL, MNT_NOMTAB }, /* Do not fail if ENOENT on dev */ @@ -210,6 +211,14 @@ const struct libmnt_optmap *mnt_optmap_get_entry( const char *p; for (ent = map; ent && ent->name; ent++) { + if (ent->mask & MNT_PREFIX) { + if (startswith(name, ent->name)) { + if (mapent) + *mapent = ent; + return map; + } + continue; + } if (strncmp(ent->name, name, namelen)) continue; p = ent->name + namelen; -- cgit v1.2.3-55-g7522