move netifd_start_process dir_fd to the data structure
authorFelix Fietkau <nbd@openwrt.org>
Sat, 15 Oct 2011 15:42:25 +0000 (17:42 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Sat, 15 Oct 2011 15:42:25 +0000 (17:42 +0200)
main.c
netifd.h
proto-shell.c

diff --git a/main.c b/main.c
index abc220edd43cd1d2080197dc900425323148dc9c..04d5648264efd44fa535a48bb1fde96b2cb6de6d 100644 (file)
--- a/main.c
+++ b/main.c
@@ -26,7 +26,7 @@ netifd_process_cb(struct uloop_process *proc, int ret)
 }
 
 int
-netifd_start_process(const char **argv, char **env, int dir_fd, struct netifd_process *proc)
+netifd_start_process(const char **argv, char **env, struct netifd_process *proc)
 {
        int pid;
 
@@ -42,8 +42,8 @@ netifd_start_process(const char **argv, char **env, int dir_fd, struct netifd_pr
                                env++;
                        }
                }
-               if (dir_fd >= 0)
-                       fchdir(dir_fd);
+               if (proc->dir_fd >= 0)
+                       fchdir(proc->dir_fd);
                execvp(argv[0], (char **) argv);
                exit(127);
        }
index 5eeb5e25b291be5317151c496c78b2b62d96ede9..f86fb15e00cd7a1d94ae8f84bd79fc0bb73c6d6d 100644 (file)
--- a/netifd.h
+++ b/netifd.h
@@ -52,9 +52,10 @@ struct netifd_process {
        struct list_head list;
        struct uloop_process uloop;
        void (*cb)(struct netifd_process *, int ret);
+       int dir_fd;
 };
 
-int netifd_start_process(const char **argv, char **env, int dir_fd, struct netifd_process *proc);
+int netifd_start_process(const char **argv, char **env, struct netifd_process *proc);
 void netifd_kill_process(struct netifd_process *proc);
 
 struct device;
index 0e1412ba53bda1e40839eef264ce67261fe32842..d0028c4baa5bcec7e4f1f8790e50fa4ba8bff2c6 100644 (file)
@@ -86,7 +86,7 @@ proto_shell_handler(struct interface_proto_state *proto,
                argv[i++] = proto->iface->main_dev.dev->ifname;
        argv[i] = NULL;
 
-       ret = netifd_start_process(argv, NULL, proto_fd, proc);
+       ret = netifd_start_process(argv, NULL, proc);
        free(config);
 
        return ret;
@@ -401,7 +401,7 @@ proto_shell_run_command(struct proto_shell_state *state, struct blob_attr **tb)
        if (!fill_string_list(tb[NOTIFY_ENV], env, ARRAY_SIZE(env)))
                goto error;
 
-       netifd_start_process((const char **) argv, (char **) env, proto_fd, &state->proto_task);
+       netifd_start_process((const char **) argv, (char **) env, &state->proto_task);
 
        return 0;
 
@@ -469,8 +469,11 @@ proto_shell_attach(const struct proto_handler *h, struct interface *iface,
        state->proto.cb = proto_shell_handler;
        state->setup_timeout.cb = proto_shell_setup_timeout_cb;
        state->setup_task.cb = proto_shell_setup_cb;
+       state->setup_task.dir_fd = proto_fd;
        state->teardown_task.cb = proto_shell_teardown_cb;
+       state->teardown_task.dir_fd = proto_fd;
        state->proto_task.cb = proto_shell_task_cb;
+       state->proto_task.dir_fd = proto_fd;
        state->handler = container_of(h, struct proto_shell_handler, proto);
 
        return &state->proto;