X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=kernel%2Fvserver%2Fhelper.c;h=5963b1812443a3a6e4b181433f40400e03f99e47;hb=af20d436230b2df6d73a406b6f1b31ae000775cb;hp=c5472369a16fada180173214c590066cd6605d55;hpb=6a77f38946aaee1cd85eeec6cf4229b204c15071;p=linux-2.6.git diff --git a/kernel/vserver/helper.c b/kernel/vserver/helper.c index c5472369a..5963b1812 100644 --- a/kernel/vserver/helper.c +++ b/kernel/vserver/helper.c @@ -23,6 +23,21 @@ char vshelper_path[255] = "/sbin/vshelper"; +int do_vshelper(char *name, char *argv[], char *envp[], int sync) +{ + int ret; + + if ((ret = call_usermodehelper(name, argv, envp, sync))) { + printk( KERN_WARNING + "%s: (%s %s) returned with %d\n", + name, argv[1], argv[2], ret); + } + vxdprintk(VXD_CBIT(switch, 1), + "%s: (%s %s) returned with %d", + name, argv[1], argv[2], ret); + return ret; +} + /* * vshelper path is set via /proc/sys * invoked by vserver sys_reboot(), with @@ -67,31 +82,33 @@ long vs_reboot(unsigned int cmd, void * arg) case LINUX_REBOOT_CMD_SW_SUSPEND: argv[1] = "swsusp"; break; - - default: - argv[1] = "restart2"; - break; } - /* maybe we should wait ? */ - if (call_usermodehelper(*argv, argv, envp, 1)) { - printk( KERN_WARNING - "vs_reboot(): failed to exec (%s %s %s)\n", - vshelper_path, argv[1], argv[2]); + if (do_vshelper(vshelper_path, argv, envp, 1)) return -EPERM; - } return 0; } -long vs_context_state(unsigned int cmd) -{ - char id_buf[8], cmd_buf[32]; - char *argv[] = {vshelper_path, NULL, id_buf, NULL, 0}; +/* + * invoked by vserver sys_reboot(), with + * the following arguments + * + * argv [0] = vshelper_path; + * argv [1] = action: "startup", "shutdown" + * argv [2] = context identifier + * + * envp [*] = type-specific parameters + */ + +long vs_context_state(struct vx_info *vxi, unsigned int cmd) +{ + char id_buf[8], cmd_buf[16]; + char *argv[] = {vshelper_path, NULL, id_buf, 0}; char *envp[] = {"HOME=/", "TERM=linux", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", cmd_buf, 0}; - snprintf(id_buf, sizeof(id_buf)-1, "%d", vx_current_xid()); + snprintf(id_buf, sizeof(id_buf)-1, "%d", vxi->vx_id); snprintf(cmd_buf, sizeof(cmd_buf)-1, "VS_CMD=%08x", cmd); switch (cmd) { @@ -105,12 +122,7 @@ long vs_context_state(unsigned int cmd) return 0; } - if (call_usermodehelper(*argv, argv, envp, 1)) { - printk( KERN_WARNING - "vs_context_state(): failed to exec (%s %s %s %s)\n", - vshelper_path, argv[1], argv[2], argv[3]); - return 0; - } + do_vshelper(vshelper_path, argv, envp, 1); return 0; }