aboutsummaryrefslogtreecommitdiffstats
path: root/modules/mount_afs.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/mount_afs.c')
-rw-r--r--modules/mount_afs.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/modules/mount_afs.c b/modules/mount_afs.c
new file mode 100644
index 0000000..71de705
--- /dev/null
+++ b/modules/mount_afs.c
@@ -0,0 +1,55 @@
+#ident "$Id$"
+/*
+ * mount_afs.c
+ *
+ * Module for Linux automountd to "mount" AFS filesystems. We don't bother
+ * with any of the things "attach" would do (making sure there are tokens,
+ * subscribing to ops messages if Zephyr is installed), but it works for me.
+ *
+ */
+
+#include <stdio.h>
+#include <malloc.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#define MODULE_MOUNT
+#include "automount.h"
+
+#define MODPREFIX "mount(afs): "
+int mount_version = AUTOFS_MOUNT_VERSION; /* Required by protocol */
+
+int mount_init(void **context)
+{
+ return 0;
+}
+
+int mount_mount(const char *root, const char *name, int name_len,
+ const char *what, const char *fstype, const char *options,
+ void *context)
+{
+ char dest[PATH_MAX * 2];
+
+ strcpy(dest, root); /* Convert the name to a mount point. */
+ strncat(dest, "/", sizeof(dest));
+ strncat(dest, name, sizeof(dest));
+
+ /* This was here just so I could figure out how this worked.
+ syslog(LOG_DEBUG, MODPREFIX "mount_mount called with root=\"%s\", "
+ "name=\"%s\", namelen=\"%d, what=\"%s\", fstype=\"%s\", options=\"%s\"",+ root, name, name_len, what, fstype, options); */
+
+ syslog(LOG_DEBUG, MODPREFIX "mounting AFS %s -> %s", dest, what);
+
+ return symlink(what, dest); /* Try it. If it fails, return the error. */
+}
+
+int mount_done(void *context)
+{
+ return 0;
+}