<varlistentry>
<term>
+ <option>--eject</option>
+ <arg choice="plain"><replaceable>device_file</replaceable></arg>
+ <arg><option>--eject-options</option><arg choice="plain"><replaceable>options</replaceable></arg></arg>
+ </term>
+ <listitem>
+ <para>
+ Ejects media from the device represented
+ by <replaceable>device_file</replaceable> using a
+ comma-separated list
+ of <replaceable>options</replaceable>.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term>
<option>--ata-smart-refresh</option>
<arg choice="plain"><replaceable>device_file</replaceable></arg>
<arg><option>--ata-smart-wakeup</option></arg>
COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur))
elif [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--detach" ] ; then
COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur))
+ elif [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--eject" ] ; then
+ COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur))
elif [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--ata-smart-refresh" ] ; then
COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur))
elif [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--ata-smart-simulate" ] ; then
elif [ "${COMP_WORDS[$(($COMP_CWORD - 1))]}" = "--poll-for-media" ] ; then
COMPREPLY=($(compgen -W "$(udisks --enumerate-device-files)" -- $cur))
else
- COMPREPLY=($(IFS=: compgen -W "--dump:--inhibit-polling:--inhibit-all-polling:--enumerate:--enumerate-device-files:--monitor:--monitor-detail:--show-info:--help:--mount:--mount-fstype:--mount-options:--unmount:--unmount-options:--detach:--detach-options:--ata-smart-refresh:--ata-smart-wakeup:--ata-smart-simulate:--set-spindown:--set-spindown-all:--spindown-timeout:--poll-for-media" -- $cur))
+ COMPREPLY=($(IFS=: compgen -W "--dump:--inhibit-polling:--inhibit-all-polling:--enumerate:--enumerate-device-files:--monitor:--monitor-detail:--show-info:--help:--mount:--mount-fstype:--mount-options:--unmount:--unmount-options:--detach:--detach-options:--eject:--eject-options:--ata-smart-refresh:--ata-smart-wakeup:--ata-smart-simulate:--set-spindown:--set-spindown-all:--spindown-timeout:--poll-for-media" -- $cur))
fi
}
static char *opt_unmount_options = NULL;
static char *opt_detach = NULL;
static char *opt_detach_options = NULL;
+static char *opt_eject = NULL;
+static char *opt_eject_options = NULL;
static char *opt_ata_smart_refresh = NULL;
static gboolean opt_ata_smart_wakeup = FALSE;
static char *opt_ata_smart_simulate = NULL;
}
static void
+do_eject (const char *object_path,
+ const char *options)
+{
+ DBusGProxy *proxy;
+ GError *error;
+ char **eject_options;
+
+ eject_options = NULL;
+ if (options != NULL)
+ eject_options = g_strsplit (options, ",", 0);
+
+ proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.UDisks", object_path, "org.freedesktop.UDisks.Device");
+
+ error = NULL;
+ if (!org_freedesktop_UDisks_Device_drive_eject (proxy, (const char **) options, &error))
+ {
+ g_print ("Eject failed: %s\n", error->message);
+ g_error_free (error);
+ }
+
+ g_strfreev (eject_options);
+}
+
+static void
device_added_signal_handler (DBusGProxy *proxy,
const char *object_path,
gpointer user_data)
{ "detach", 0, 0, G_OPTION_ARG_STRING, &opt_detach, "Detach the given device", NULL },
{ "detach-options", 0, 0, G_OPTION_ARG_STRING, &opt_detach_options, "Detach options separated by comma",
NULL },
+ { "eject", 0, 0, G_OPTION_ARG_STRING, &opt_eject, "Eject the given device", NULL },
+ { "eject-options", 0, 0, G_OPTION_ARG_STRING, &opt_eject_options, "Eject options separated by comma", NULL },
{ "ata-smart-refresh", 0, 0, G_OPTION_ARG_STRING, &opt_ata_smart_refresh, "Refresh ATA SMART data", NULL },
{ "ata-smart-wakeup", 0, 0, G_OPTION_ARG_NONE, &opt_ata_smart_wakeup,
"Wake up the disk if it is not awake", NULL },
goto out;
do_detach (device_file, opt_detach_options);
}
+ else if (opt_eject != NULL)
+ {
+ device_file = device_file_to_object_path (opt_eject);
+ if (device_file == NULL)
+ goto out;
+ do_eject (device_file, opt_eject_options);
+ }
else if (opt_ata_smart_refresh != NULL)
{
device_file = device_file_to_object_path (opt_ata_smart_refresh);