lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20070511155612.1d4575ea.randy.dunlap@oracle.com>
Date:	Fri, 11 May 2007 15:56:12 -0700
From:	Randy Dunlap <randy.dunlap@...cle.com>
To:	Jeremy Fitzhardinge <jeremy@...p.org>
Cc:	Andi Kleen <ak@...e.de>, Andrew Morton <akpm@...ux-foundation.org>,
	lkml <linux-kernel@...r.kernel.org>,
	Chris Wright <chrisw@...s-sol.org>,
	Len Brown <lenb@...nel.org>, Al Viro <viro@...iv.linux.org.uk>,
	Arnd Bergmann <arnd@...db.de>,
	"David S. Miller" <davem@...emloft.net>
Subject: Re: [patch 6/7] Add common orderly_poweroff()

On Thu, 10 May 2007 16:57:14 -0700 Jeremy Fitzhardinge wrote:

> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -2208,3 +2208,61 @@ asmlinkage long sys_getcpu(unsigned __us
> +
> +/**
> + * Trigger an orderly system poweroff

    * orderly_poweroff - Trigger an orderly system poweroff

> + * @force: force poweroff if command execution fails
> + *
> + * This may be called from any context to trigger a system shutdown.
> + * If the orderly shutdown fails, it will force an immediate shutdown.
> + */
> +int orderly_poweroff(bool force)
> +{
> +	int argc;
> +	char **argv = argv_split(GFP_ATOMIC, poweroff_cmd, &argc);
> +	static char *envp[] = {
> +		"HOME=/",
> +		"PATH=/sbin:/bin:/usr/sbin:/usr/bin",
> +		NULL
> +	};
> +	int ret = -ENOMEM;
> +	struct subprocess_info *info;
> +
> +	if (argv == NULL) {
> +		printk(KERN_WARNING "%s failed to allocate memory for \"%s\"\n",
> +		       __func__, poweroff_cmd);
> +		goto out;
> +	}
> +
> +	info = call_usermodehelper_setup(argv[0], argv, envp);
> +	if (info == NULL) {
> +		argv_free(argv);
> +		goto out;
> +	}
> +
> +	call_usermodehelper_setcleanup(info, argv_cleanup);
> +
> +	ret = call_usermodehelper_exec(info, -1);
> +
> +  out:
> +	if (ret && force) {
> +		printk(KERN_WARNING "Failed to start orderly shutdown: "
> +		       "forcing the issue\n");
> +
> +		/* I guess this should try to kick off some daemon to
> +		   sync and poweroff asap.  Or not even bother syncing
> +		   if we're doing an emergency shutdown? */
> +		emergency_sync();
> +		kernel_power_off();
> +	}
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL_GPL(orderly_poweroff);


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ