|
Packit |
8480eb |
/*
|
|
Packit |
8480eb |
* mount_afs.c
|
|
Packit |
8480eb |
*
|
|
Packit |
8480eb |
* Module for Linux automountd to "mount" AFS filesystems. We don't bother
|
|
Packit |
8480eb |
* with any of the things "attach" would do (making sure there are tokens,
|
|
Packit |
8480eb |
* subscribing to ops messages if Zephyr is installed), but it works for me.
|
|
Packit |
8480eb |
*
|
|
Packit |
8480eb |
*/
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#include <stdio.h>
|
|
Packit |
8480eb |
#include <malloc.h>
|
|
Packit |
8480eb |
#include <string.h>
|
|
Packit |
8480eb |
#include <sys/param.h>
|
|
Packit |
8480eb |
#include <sys/types.h>
|
|
Packit |
8480eb |
#include <sys/stat.h>
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#define MODULE_MOUNT
|
|
Packit |
8480eb |
#include "automount.h"
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
#define MODPREFIX "mount(afs): "
|
|
Packit |
8480eb |
int mount_version = AUTOFS_MOUNT_VERSION; /* Required by protocol */
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
int mount_init(void **context)
|
|
Packit |
8480eb |
{
|
|
Packit |
8480eb |
return 0;
|
|
Packit |
8480eb |
}
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
int mount_reinit(void **context)
|
|
Packit |
8480eb |
{
|
|
Packit |
8480eb |
return 0;
|
|
Packit |
8480eb |
}
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
int mount_mount(struct autofs_point *ap, const char *root, const char *name, int name_len,
|
|
Packit |
8480eb |
const char *what, const char *fstype, const char *options, void *context)
|
|
Packit |
8480eb |
{
|
|
Packit |
8480eb |
/* PATH_MAX is allegedly longest path allowed */
|
|
Packit |
8480eb |
char dest[PATH_MAX + 1];
|
|
Packit |
8480eb |
size_t r_len = strlen(root);
|
|
Packit |
8480eb |
size_t d_len = r_len + name_len + 2;
|
|
Packit Service |
1592bd |
void (*mountlog)(unsigned int, const char*, ...) = &log_debug;
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
if (ap->flags & MOUNT_FLAG_REMOUNT)
|
|
Packit |
8480eb |
return 0;
|
|
Packit |
8480eb |
|
|
Packit Service |
1592bd |
if (defaults_get_mount_verbose())
|
|
Packit Service |
1592bd |
mountlog = &log_info;
|
|
Packit Service |
1592bd |
|
|
Packit |
8480eb |
if (d_len > PATH_MAX)
|
|
Packit |
8480eb |
return 1;
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
/* Convert the name to a mount point. */
|
|
Packit |
8480eb |
strcpy(dest, root);
|
|
Packit |
8480eb |
strcat(dest, "/");
|
|
Packit |
8480eb |
strcat(dest, name);
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
/* remove trailing slash (http://bugs.debian.org/141775) */
|
|
Packit |
8480eb |
if (dest[strlen(dest)-1] == '/')
|
|
Packit |
8480eb |
dest[strlen(dest)-1] = '\0';
|
|
Packit |
8480eb |
|
|
Packit Service |
1592bd |
mountlog(ap->logopt, MODPREFIX "mounting AFS %s -> %s", dest, what);
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
return symlink(what, dest); /* Try it. If it fails, return the error. */
|
|
Packit |
8480eb |
}
|
|
Packit |
8480eb |
|
|
Packit |
8480eb |
int mount_done(void *context)
|
|
Packit |
8480eb |
{
|
|
Packit |
8480eb |
return 0;
|
|
Packit |
8480eb |
}
|