|
|
4d476f |
autofs-5.0.7 - add symlink pseudo option
|
|
|
4d476f |
|
|
|
4d476f |
From: Ian Kent <raven@themaw.net>
|
|
|
4d476f |
|
|
|
4d476f |
Add a "symlink" pseudo option to tell the bind mount module to symlink
|
|
|
4d476f |
instead of bind when mounting mounts other than direct mounts and
|
|
|
4d476f |
non-root indirect mount offset mounts (aka. non-root multi-mount
|
|
|
4d476f |
entries).
|
|
|
4d476f |
---
|
|
|
4d476f |
CHANGELOG | 1 +
|
|
|
4d476f |
include/automount.h | 3 +++
|
|
|
4d476f |
lib/master_parse.y | 8 +++++++-
|
|
|
4d476f |
lib/master_tok.l | 1 +
|
|
|
4d476f |
man/auto.master.5.in | 8 ++++++++
|
|
|
4d476f |
modules/mount_autofs.c | 5 +++++
|
|
|
4d476f |
modules/mount_bind.c | 36 +++++++++++++++++++++++++++++++++++-
|
|
|
4d476f |
7 files changed, 60 insertions(+), 2 deletions(-)
|
|
|
4d476f |
|
|
|
4d476f |
diff --git a/CHANGELOG b/CHANGELOG
|
|
|
4d476f |
index c189483..247d334 100644
|
|
|
4d476f |
--- a/CHANGELOG
|
|
|
4d476f |
+++ b/CHANGELOG
|
|
|
4d476f |
@@ -32,6 +32,7 @@
|
|
|
4d476f |
- fix wildcard multi map regression.
|
|
|
4d476f |
- fix file descriptor leak when reloading the daemon.
|
|
|
4d476f |
- depricate nosymlink pseudo option.
|
|
|
4d476f |
+- add symlink pseudo option.
|
|
|
4d476f |
|
|
|
4d476f |
25/07/2012 autofs-5.0.7
|
|
|
4d476f |
=======================
|
|
|
4d476f |
diff --git a/include/automount.h b/include/automount.h
|
|
|
4d476f |
index 37541f5..e72fa0d 100644
|
|
|
4d476f |
--- a/include/automount.h
|
|
|
4d476f |
+++ b/include/automount.h
|
|
|
4d476f |
@@ -455,6 +455,9 @@ struct kernel_mod_version {
|
|
|
4d476f |
/* Don't use bind mounts even when system supports them */
|
|
|
4d476f |
#define MOUNT_FLAG_NOBIND 0x0020
|
|
|
4d476f |
|
|
|
4d476f |
+/* Use symlinks instead of bind mounting local mounts */
|
|
|
4d476f |
+#define MOUNT_FLAG_SYMLINK 0x0040
|
|
|
4d476f |
+
|
|
|
4d476f |
struct autofs_point {
|
|
|
4d476f |
pthread_t thid;
|
|
|
4d476f |
char *path; /* Mount point name */
|
|
|
4d476f |
diff --git a/lib/master_parse.y b/lib/master_parse.y
|
|
|
4d476f |
index f925b5a..11caf5b 100644
|
|
|
4d476f |
--- a/lib/master_parse.y
|
|
|
4d476f |
+++ b/lib/master_parse.y
|
|
|
4d476f |
@@ -57,6 +57,7 @@ static char *type;
|
|
|
4d476f |
static char *format;
|
|
|
4d476f |
static long timeout;
|
|
|
4d476f |
static long negative_timeout;
|
|
|
4d476f |
+static unsigned symlnk;
|
|
|
4d476f |
static unsigned nobind;
|
|
|
4d476f |
static unsigned ghost;
|
|
|
4d476f |
extern unsigned global_selection_options;
|
|
|
4d476f |
@@ -100,7 +101,7 @@ static int master_fprintf(FILE *, char *, ...);
|
|
|
4d476f |
%token COMMENT
|
|
|
4d476f |
%token MAP
|
|
|
4d476f |
%token OPT_TIMEOUT OPT_NTIMEOUT OPT_NOBIND OPT_NOGHOST OPT_GHOST OPT_VERBOSE
|
|
|
4d476f |
-%token OPT_DEBUG OPT_RANDOM OPT_USE_WEIGHT
|
|
|
4d476f |
+%token OPT_DEBUG OPT_RANDOM OPT_USE_WEIGHT OPT_SYMLINK
|
|
|
4d476f |
%token COLON COMMA NL DDASH
|
|
|
4d476f |
%type <strtype> map
|
|
|
4d476f |
%type <strtype> options
|
|
|
4d476f |
@@ -186,6 +187,7 @@ line:
|
|
|
4d476f |
| PATH OPT_USE_WEIGHT { master_notify($1); YYABORT; }
|
|
|
4d476f |
| PATH OPT_DEBUG { master_notify($1); YYABORT; }
|
|
|
4d476f |
| PATH OPT_TIMEOUT { master_notify($1); YYABORT; }
|
|
|
4d476f |
+ | PATH OPT_SYMLINK { master_notify($1); YYABORT; }
|
|
|
4d476f |
| PATH OPT_NOBIND { master_notify($1); YYABORT; }
|
|
|
4d476f |
| PATH OPT_GHOST { master_notify($1); YYABORT; }
|
|
|
4d476f |
| PATH OPT_NOGHOST { master_notify($1); YYABORT; }
|
|
|
4d476f |
@@ -557,6 +559,7 @@ option: daemon_option
|
|
|
4d476f |
|
|
|
4d476f |
daemon_option: OPT_TIMEOUT NUMBER { timeout = $2; }
|
|
|
4d476f |
| OPT_NTIMEOUT NUMBER { negative_timeout = $2; }
|
|
|
4d476f |
+ | OPT_SYMLINK { symlnk = 1; }
|
|
|
4d476f |
| OPT_NOBIND { nobind = 1; }
|
|
|
4d476f |
| OPT_NOGHOST { ghost = 0; }
|
|
|
4d476f |
| OPT_GHOST { ghost = 1; }
|
|
|
4d476f |
@@ -627,6 +630,7 @@ static void local_init_vars(void)
|
|
|
4d476f |
debug = 0;
|
|
|
4d476f |
timeout = -1;
|
|
|
4d476f |
negative_timeout = 0;
|
|
|
4d476f |
+ symlnk = 0;
|
|
|
4d476f |
nobind = 0;
|
|
|
4d476f |
ghost = defaults_get_browse_mode();
|
|
|
4d476f |
random_selection = global_selection_options & MOUNT_FLAG_RANDOM_SELECT;
|
|
|
4d476f |
@@ -811,6 +815,8 @@ int master_parse_entry(const char *buffer, unsigned int default_timeout, unsigne
|
|
|
4d476f |
entry->ap->flags |= MOUNT_FLAG_RANDOM_SELECT;
|
|
|
4d476f |
if (use_weight)
|
|
|
4d476f |
entry->ap->flags |= MOUNT_FLAG_USE_WEIGHT_ONLY;
|
|
|
4d476f |
+ if (symlnk)
|
|
|
4d476f |
+ entry->ap->flags |= MOUNT_FLAG_SYMLINK;
|
|
|
4d476f |
if (negative_timeout)
|
|
|
4d476f |
entry->ap->negative_timeout = negative_timeout;
|
|
|
4d476f |
|
|
|
4d476f |
diff --git a/lib/master_tok.l b/lib/master_tok.l
|
|
|
4d476f |
index 30abb15..f9b4e55 100644
|
|
|
4d476f |
--- a/lib/master_tok.l
|
|
|
4d476f |
+++ b/lib/master_tok.l
|
|
|
4d476f |
@@ -361,6 +361,7 @@ OPTNTOUT (-n{OPTWS}|-n{OPTWS}={OPTWS}|--negative-timeout{OPTWS}|--negative-timeo
|
|
|
4d476f |
return(NUMBER);
|
|
|
4d476f |
}
|
|
|
4d476f |
|
|
|
4d476f |
+ -?symlink { return(OPT_SYMLINK); }
|
|
|
4d476f |
-?nobind { return(OPT_NOBIND); }
|
|
|
4d476f |
-?nobrowse { return(OPT_NOGHOST); }
|
|
|
4d476f |
-g|--ghost|-?browse { return(OPT_GHOST); }
|
|
|
4d476f |
diff --git a/man/auto.master.5.in b/man/auto.master.5.in
|
|
|
4d476f |
index 8007542..bbea43a 100644
|
|
|
4d476f |
--- a/man/auto.master.5.in
|
|
|
4d476f |
+++ b/man/auto.master.5.in
|
|
|
4d476f |
@@ -159,6 +159,14 @@ on individual map entries of both types. Bind mounting of NFS file
|
|
|
4d476f |
systems can also be prevented for specific map entrys by adding the
|
|
|
4d476f |
"port=" mount option to the entries.
|
|
|
4d476f |
.TP
|
|
|
4d476f |
+.I "symlink"
|
|
|
4d476f |
+This option makes bind mounting use a symlink instead of an actual bind
|
|
|
4d476f |
+mount. It is an autofs specific option that is a pseudo mount option and
|
|
|
4d476f |
+so is given without a leading dash. It may be used with indirect map
|
|
|
4d476f |
+entries only, either in the master map (so it effects all map entries)
|
|
|
4d476f |
+or with individual map entries. The option is ignored for direct mounts
|
|
|
4d476f |
+and non-root offest mount entries.
|
|
|
4d476f |
+.TP
|
|
|
4d476f |
.I "\-r, \-\-random-multimount-selection"
|
|
|
4d476f |
Enables the use of ramdom selection when choosing a host from a
|
|
|
4d476f |
list of replicated servers. This option is applied to this mount
|
|
|
4d476f |
diff --git a/modules/mount_autofs.c b/modules/mount_autofs.c
|
|
|
4d476f |
index ef16020..8c1e600 100644
|
|
|
4d476f |
--- a/modules/mount_autofs.c
|
|
|
4d476f |
+++ b/modules/mount_autofs.c
|
|
|
4d476f |
@@ -51,6 +51,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
|
|
|
4d476f |
int argc, status;
|
|
|
4d476f |
int nobind = ap->flags & MOUNT_FLAG_NOBIND;
|
|
|
4d476f |
int ghost = ap->flags & MOUNT_FLAG_GHOST;
|
|
|
4d476f |
+ int symlnk = ap->flags & MOUNT_FLAG_SYMLINK;
|
|
|
4d476f |
time_t timeout = ap->entry->maps->exp_timeout;
|
|
|
4d476f |
unsigned logopt = ap->logopt;
|
|
|
4d476f |
struct map_type_info *info;
|
|
|
4d476f |
@@ -120,6 +121,8 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
|
|
|
4d476f |
nobind = 1;
|
|
|
4d476f |
else if (strncmp(cp, "browse", 6) == 0)
|
|
|
4d476f |
ghost = 1;
|
|
|
4d476f |
+ else if (strncmp(cp, "symlink", 7) == 0)
|
|
|
4d476f |
+ symlnk = 1;
|
|
|
4d476f |
else if (strncmp(cp, "timeout=", 8) == 0) {
|
|
|
4d476f |
char *val = strchr(cp, '=');
|
|
|
4d476f |
unsigned tout;
|
|
|
4d476f |
@@ -158,6 +161,8 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
|
|
|
4d476f |
}
|
|
|
4d476f |
nap = entry->ap;
|
|
|
4d476f |
nap->parent = ap;
|
|
|
4d476f |
+ if (symlnk)
|
|
|
4d476f |
+ nap->flags |= MOUNT_FLAG_SYMLINK;
|
|
|
4d476f |
|
|
|
4d476f |
argc = 1;
|
|
|
4d476f |
|
|
|
4d476f |
diff --git a/modules/mount_bind.c b/modules/mount_bind.c
|
|
|
4d476f |
index 9bce686..4975294 100644
|
|
|
4d476f |
--- a/modules/mount_bind.c
|
|
|
4d476f |
+++ b/modules/mount_bind.c
|
|
|
4d476f |
@@ -73,10 +73,44 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
|
|
|
4d476f |
char buf[MAX_ERR_BUF];
|
|
|
4d476f |
int err;
|
|
|
4d476f |
int i, len;
|
|
|
4d476f |
+ int symlnk = (*name != '/' && (ap->flags & MOUNT_FLAG_SYMLINK));
|
|
|
4d476f |
|
|
|
4d476f |
if (ap->flags & MOUNT_FLAG_REMOUNT)
|
|
|
4d476f |
return 0;
|
|
|
4d476f |
|
|
|
4d476f |
+ /* Extract "symlink" pseudo-option which forces local filesystems
|
|
|
4d476f |
+ * to be symlinked instead of bound.
|
|
|
4d476f |
+ */
|
|
|
4d476f |
+ if (*name != '/' && !symlnk && options) {
|
|
|
4d476f |
+ const char *comma;
|
|
|
4d476f |
+ int o_len = strlen(options) + 1;
|
|
|
4d476f |
+
|
|
|
4d476f |
+ for (comma = options; *comma != '\0';) {
|
|
|
4d476f |
+ const char *cp;
|
|
|
4d476f |
+ const char *end;
|
|
|
4d476f |
+
|
|
|
4d476f |
+ while (*comma == ',')
|
|
|
4d476f |
+ comma++;
|
|
|
4d476f |
+
|
|
|
4d476f |
+ /* Skip leading white space */
|
|
|
4d476f |
+ while (*comma == ' ' || *comma == '\t')
|
|
|
4d476f |
+ comma++;
|
|
|
4d476f |
+
|
|
|
4d476f |
+ cp = comma;
|
|
|
4d476f |
+ while (*comma != '\0' && *comma != ',')
|
|
|
4d476f |
+ comma++;
|
|
|
4d476f |
+
|
|
|
4d476f |
+ /* Skip trailing white space */
|
|
|
4d476f |
+ end = comma - 1;
|
|
|
4d476f |
+ while (*comma == ' ' || *comma == '\t')
|
|
|
4d476f |
+ end--;
|
|
|
4d476f |
+
|
|
|
4d476f |
+ o_len = end - cp + 1;
|
|
|
4d476f |
+ if (strncmp("symlink", cp, o_len) == 0)
|
|
|
4d476f |
+ symlnk = 1;
|
|
|
4d476f |
+ }
|
|
|
4d476f |
+ }
|
|
|
4d476f |
+
|
|
|
4d476f |
/* Root offset of multi-mount */
|
|
|
4d476f |
len = strlen(root);
|
|
|
4d476f |
if (root[len - 1] == '/') {
|
|
|
4d476f |
@@ -100,7 +134,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
|
|
|
4d476f |
if (options == NULL || *options == '\0')
|
|
|
4d476f |
options = "defaults";
|
|
|
4d476f |
|
|
|
4d476f |
- if (bind_works) {
|
|
|
4d476f |
+ if (!symlnk && bind_works) {
|
|
|
4d476f |
int status, existed = 1;
|
|
|
4d476f |
|
|
|
4d476f |
debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath);
|