/***************************************************************************
*
* hal-storage-eject.c : Eject method handler
*
* Copyright (C) 2006 David Zeuthen, <david@fubar.dk>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
**************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <unistd.h>
#include <libhal.h>
#include <libhal-storage.h>
#ifdef HAVE_POLKIT
#include <libpolkit.h>
#endif
#include "hal-storage-shared.h"
/* possible values: "Volume", "Storage" */
static void
usage (void)
{
exit (1);
}
void static
{
exit (1);
}
static void
{
exit (1);
}
int
{
char *udi;
char *device;
const char *drive_udi;
#ifdef HAVE_POLKIT
#endif
char *invoked_by_uid;
char *invoked_by_syscon_name;
char **volume_udis;
int num_volumes;
int i;
char **given_options;
const char *end;
usage ();
usage ();
dbus_error_init (&error);
printf ("Cannot connect to hald\n");
usage ();
}
dbus_error_init (&error);
if (system_bus == NULL) {
printf ("Cannot connect to the system bus\n");
usage ();
}
#ifdef HAVE_POLKIT
printf ("Cannot get libpolkit context\n");
unknown_eject_error ("Cannot get libpolkit context");
}
#endif
/* read from stdin */
/* validate that input from stdin is UTF-8 */
unknown_eject_error ("Error validating eject_options as UTF-8");
#ifdef DEBUG
#endif
/* delete any trailing whitespace options from splitting the string */
if (strlen (given_options[i]) > 0)
break;
given_options[i] = NULL;
}
/* check eject options */
for (i = 0; given_options[i] != NULL; i++) {
/* none supported right now */
}
/* should be either volume or storage */
} else {
devtype = "Storage";
}
unknown_eject_error ("Cannot get drive udi");
}
unknown_eject_error ("Cannot get drive from udi");
}
/* first, unmount all volumes */
if (volume_udis == NULL)
unknown_eject_error ("Cannot get all enclosed volumes");
for (i = 0; i < num_volumes; i++) {
char *volume_udi;
volume_udi = volume_udis[i];
#ifdef DEBUG
#endif
if (volume_to_unmount == NULL) {
unknown_eject_error ("Cannot get volume object");
}
#ifdef DEBUG
printf (" unmounting\n");
#endif
* will also want to lock the /media/.hal-mtab-lock file for peeking
*/
if (!lock_hal_mtab ()) {
unknown_eject_error ("Cannot obtain lock on /media/.hal-mtab");
}
#ifdef HAVE_POLKIT
#endif
unlock_hal_mtab ();
} else {
#ifdef DEBUG
printf (" not mounted\n");
#endif
}
}
/* now attempt the eject */
#ifdef HAVE_POLKIT
#endif
FALSE, system_bus);
return 0;
}