blob: 843994d043019632f46d7783962f52d467c07da7 [file] [log] [blame]
Support the MS_NOSYMFOLLOW mount flag. Added to Chrome OS in 5.4 and sent
upstream as:
https://lore.kernel.org/linux-fsdevel/20200304173446.122990-1-zwisler@google.com/
See b/152074038 for background.
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c
index 088d1328e..5cce46556 100644
--- a/libmount/src/context_mount.c
+++ b/libmount/src/context_mount.c
@@ -422,6 +422,8 @@ static int generate_helper_optstr(struct libmnt_context *cxt, char **optstr)
mnt_optstr_append_option(optstr, "suid", NULL);
if (!(cxt->mountflags & MS_NODEV))
mnt_optstr_append_option(optstr, "dev", NULL);
+ if (!(cxt->mountflags & MS_NOSYMFOLLOW))
+ mnt_optstr_append_option(optstr, "symfollow", NULL);
}
diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in
index 321c0540b..e6710ae01 100644
--- a/libmount/src/libmount.h.in
+++ b/libmount/src/libmount.h.in
@@ -941,6 +941,9 @@ extern int mnt_context_set_syscall_status(struct libmnt_context *cxt, int status
#ifndef MS_DIRSYNC
#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
#endif
+#ifndef MS_NOSYMFOLLOW
+#define MS_NOSYMFOLLOW 256 /* Don't follow symlinks */
+#endif
#ifndef MS_NOATIME
#define MS_NOATIME 0x400 /* 1024: Do not update access times. */
#endif
diff --git a/libmount/src/optmap.c b/libmount/src/optmap.c
index abd81bc8e..731771327 100644
--- a/libmount/src/optmap.c
+++ b/libmount/src/optmap.c
@@ -131,6 +131,10 @@ static const struct libmnt_optmap linux_flags_map[] =
{ "rslave", MS_SLAVE | MS_REC, MNT_NOHLPS | MNT_NOMTAB },
{ "shared", MS_SHARED, MNT_NOHLPS | MNT_NOMTAB }, /* Shared */
{ "rshared", MS_SHARED | MS_REC, MNT_NOHLPS | MNT_NOMTAB },
+#endif
+#ifdef MS_NOSYMFOLLOW
+ { "symfollow", MS_NOSYMFOLLOW, MNT_INVERT }, /* Don't follow symlinks */
+ { "nosymfollow", MS_NOSYMFOLLOW },
#endif
{ NULL, 0, 0 }
};