automount: Pass automount pass as environment variable
This makes it possible to pass a command sequence to the automount command instead of only a script (a command sequence would get confused by the additional argument) Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
ff879a2d4c
commit
51c31ae1c5
13
fs/fs.c
13
fs/fs.c
|
@ -31,6 +31,8 @@
|
||||||
#include <init.h>
|
#include <init.h>
|
||||||
#include <module.h>
|
#include <module.h>
|
||||||
#include <libbb.h>
|
#include <libbb.h>
|
||||||
|
#include <magicvar.h>
|
||||||
|
#include <environment.h>
|
||||||
|
|
||||||
void *read_file(const char *filename, size_t *size)
|
void *read_file(const char *filename, size_t *size)
|
||||||
{
|
{
|
||||||
|
@ -289,7 +291,6 @@ static void automount_mount(const char *path, int instat)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
list_for_each_entry(am, &automount_list, list) {
|
list_for_each_entry(am, &automount_list, list) {
|
||||||
char *cmd;
|
|
||||||
int len_path = strlen(path);
|
int len_path = strlen(path);
|
||||||
int len_am_path = strlen(am->path);
|
int len_am_path = strlen(am->path);
|
||||||
|
|
||||||
|
@ -312,9 +313,10 @@ static void automount_mount(const char *path, int instat)
|
||||||
if (*(path + len_am_path) != 0 && *(path + len_am_path) != '/')
|
if (*(path + len_am_path) != 0 && *(path + len_am_path) != '/')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
cmd = asprintf("%s %s", am->cmd, am->path);
|
setenv("automount_path", am->path);
|
||||||
ret = run_command(cmd, 0);
|
export("automount_path");
|
||||||
free(cmd);
|
ret = run_command(am->cmd, 0);
|
||||||
|
setenv("automount_path", NULL);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
printf("running automount command '%s' failed\n",
|
printf("running automount command '%s' failed\n",
|
||||||
|
@ -325,6 +327,9 @@ static void automount_mount(const char *path, int instat)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BAREBOX_MAGICVAR(automount_path, "mountpath passed to automount scripts");
|
||||||
|
|
||||||
#else
|
#else
|
||||||
static void automount_mount(const char *path, int instat)
|
static void automount_mount(const char *path, int instat)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue