I'm not able to access my OpenWRT router at the moment (no external ports are open), so I didn't try to create an nfs mount stanza in /etc/config/fstab
- I imagine given your response that you can't make it work?
Looking at the code for /sbin/block
that does the actual mounts, it simply invokes the appropriate mount.xxx
external executable to do the mount, so given that the stanza is constructed correctly, there doesn't appear to be any reason on the face of it that it would not work...?
static int exec_mount(const char *source, const char *target,
const char *fstype, const char *options)
{
pid_t pid;
struct stat s;
FILE *mount_fd;
int err, status, pfds[2];
char errmsg[128], cmd[sizeof("/sbin/mount.XXXXXXXXXXXXXXXX\0")];
snprintf(cmd, sizeof(cmd), "/sbin/mount.%s", fstype);
if (stat(cmd, &s) < 0 || !S_ISREG(s.st_mode) || !(s.st_mode & S_IXUSR)) {
ULOG_ERR("No \"mount.%s\" utility available\n", fstype);
return -1;
}
if (pipe(pfds) < 0)
return -1;
fcntl(pfds[0], F_SETFD, fcntl(pfds[0], F_GETFD) | FD_CLOEXEC);
fcntl(pfds[1], F_SETFD, fcntl(pfds[1], F_GETFD) | FD_CLOEXEC);
pid = vfork();
switch (pid) {
case -1:
close(pfds[0]);
close(pfds[1]);
return -1;
case 0:
to_devnull(STDIN_FILENO);
to_devnull(STDOUT_FILENO);
dup2(pfds[1], STDERR_FILENO);
close(pfds[0]);
close(pfds[1]);
if (options && *options)
execl(cmd, cmd, "-o", options, source, target, NULL);
else
execl(cmd, cmd, source, target, NULL);
return -1;
default:
close(pfds[1]);
mount_fd = fdopen(pfds[0], "r");
while (fgets(errmsg, sizeof(errmsg), mount_fd))
ULOG_ERR("mount.%s: %s", fstype, errmsg);
fclose(mount_fd);
err = waitpid(pid, &status, 0);
if (err != -1) {
if (status != 0) {
ULOG_ERR("mount.%s: failed with status %d\n", fstype, status);
errno = EINVAL;
err = -1;
} else {
errno = 0;
err = 0;
}
}
break;
}
return err;
}