18c2aff776a775d34a4c9893a4c72e0434d68e36artem/***************************************************************************
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * CVSID: $Id$
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * hal-storage-unmount.c : Unmount wrapper
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * Copyright (C) 2006 David Zeuthen, <david@fubar.dk>
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * This program is free software; you can redistribute it and/or modify
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * it under the terms of the GNU General Public License as published by
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * the Free Software Foundation; either version 2 of the License, or
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * (at your option) any later version.
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * This program is distributed in the hope that it will be useful,
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * but WITHOUT ANY WARRANTY; without even the implied warranty of
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * GNU General Public License for more details.
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * You should have received a copy of the GNU General Public License
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * along with this program; if not, write to the Free Software
18c2aff776a775d34a4c9893a4c72e0434d68e36artem * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18c2aff776a775d34a4c9893a4c72e0434d68e36artem **************************************************************************/
18c2aff776a775d34a4c9893a4c72e0434d68e36artem fprintf (stderr, "This program should only be started by hald.\n");
18c2aff776a775d34a4c9893a4c72e0434d68e36arteminvalid_unmount_option (const char *option, const char *uid)
18c2aff776a775d34a4c9893a4c72e0434d68e36artem fprintf (stderr, "org.freedesktop.Hal.Device.Volume.InvalidUnmountOption\n");
18c2aff776a775d34a4c9893a4c72e0434d68e36artem fprintf (stderr, "The option '%s' is not allowed for uid=%s\n", option, uid);
18c2aff776a775d34a4c9893a4c72e0434d68e36artem unknown_error ("Cannot obtain lock on /media/.hal-mtab");
18c2aff776a775d34a4c9893a4c72e0434d68e36artem invoked_by_uid = getenv ("HAL_METHOD_INVOKED_BY_UID");
18c2aff776a775d34a4c9893a4c72e0434d68e36artem invoked_by_syscon_name = getenv ("HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME");
18c2aff776a775d34a4c9893a4c72e0434d68e36artem if ((hal_ctx = libhal_ctx_init_direct (&error)) == NULL) {
18c2aff776a775d34a4c9893a4c72e0434d68e36artem /* read from stdin */
18c2aff776a775d34a4c9893a4c72e0434d68e36artem if (strlen (fgets (unmount_options, sizeof (unmount_options), stdin)) > 0)
18c2aff776a775d34a4c9893a4c72e0434d68e36artem unmount_options [strlen (unmount_options) - 1] = '\0';
18c2aff776a775d34a4c9893a4c72e0434d68e36artem /* validate that input from stdin is UTF-8 */
18c2aff776a775d34a4c9893a4c72e0434d68e36artem unknown_error ("Error validating unmount_options as UTF-8");
18c2aff776a775d34a4c9893a4c72e0434d68e36artem /* delete any trailing whitespace options from splitting the string */
18c2aff776a775d34a4c9893a4c72e0434d68e36artem given_options = g_strsplit (unmount_options, "\t", 0);
18c2aff776a775d34a4c9893a4c72e0434d68e36artem for (i = g_strv_length (given_options) - 1; i >= 0; --i) {
18c2aff776a775d34a4c9893a4c72e0434d68e36artem /* check unmount options */