mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-29 13:03:37 +01:00
added -u, --unmount option to force unmounting the disk after end of operations
This commit is contained in:
parent
85314f8310
commit
6103d852d5
2 changed files with 12 additions and 2 deletions
|
@ -42,6 +42,8 @@ static const char *help_string =
|
||||||
" missing, a generic filename will be created.\n"
|
" missing, a generic filename will be created.\n"
|
||||||
" -q, --quiet Activate quiet mode, i.e. minimum verbosity and very\n"
|
" -q, --quiet Activate quiet mode, i.e. minimum verbosity and very\n"
|
||||||
" limited decorations (no extra messages).\n"
|
" limited decorations (no extra messages).\n"
|
||||||
|
" -u, --unmount Force unmount disk at the end of operations, even if\n"
|
||||||
|
" not mounted here\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Device filters:\n"
|
"Device filters:\n"
|
||||||
" A device filter is a comma-separated list of properties that a device has\n"
|
" A device filter is a comma-separated list of properties that a device has\n"
|
||||||
|
@ -64,6 +66,7 @@ static const char *help_string =
|
||||||
bool silentmode = false;
|
bool silentmode = false;
|
||||||
bool loginfile = false;
|
bool loginfile = false;
|
||||||
char *userlogfilename = NULL;
|
char *userlogfilename = NULL;
|
||||||
|
bool forceunmount = false;
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
@ -86,10 +89,11 @@ int main(int argc, char **argv)
|
||||||
{ "libusb-log", required_argument, NULL, LIBUSB_LOG },
|
{ "libusb-log", required_argument, NULL, LIBUSB_LOG },
|
||||||
{ "quiet", no_argument, NULL, 'q' },
|
{ "quiet", no_argument, NULL, 'q' },
|
||||||
{ "fxlink-log", optional_argument, NULL, LOG_IN_FILE },
|
{ "fxlink-log", optional_argument, NULL, LOG_IN_FILE },
|
||||||
|
{ "unmount", no_argument, NULL, 'u' },
|
||||||
};
|
};
|
||||||
|
|
||||||
while(option >= 0 && option != '?')
|
while(option >= 0 && option != '?')
|
||||||
switch((option = getopt_long(argc, argv, "hlbsiqf:w::", longs, NULL)))
|
switch((option = getopt_long(argc, argv, "hlbsiquf:w::", longs, NULL)))
|
||||||
{
|
{
|
||||||
case 'h':
|
case 'h':
|
||||||
fprintf(stderr, help_string, argv[0]);
|
fprintf(stderr, help_string, argv[0]);
|
||||||
|
@ -118,6 +122,10 @@ int main(int argc, char **argv)
|
||||||
printf("Enabling quiet mode (i.e. minimum verbosity)\n");
|
printf("Enabling quiet mode (i.e. minimum verbosity)\n");
|
||||||
silentmode = true;
|
silentmode = true;
|
||||||
break;
|
break;
|
||||||
|
case 'u':
|
||||||
|
printf("Force unmount the disk at the end.\n");
|
||||||
|
forceunmount = true;
|
||||||
|
break;
|
||||||
case LOG_IN_FILE:
|
case LOG_IN_FILE:
|
||||||
printf("Enabling Log in File Mode\n");
|
printf("Enabling Log in File Mode\n");
|
||||||
loginfile = true;
|
loginfile = true;
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
// UDisks2 utility functions
|
// UDisks2 utility functions
|
||||||
//---
|
//---
|
||||||
|
|
||||||
|
extern bool forceunmount;
|
||||||
|
|
||||||
int ud2_start(UDisksClient **udc_ptr, UDisksManager **udm_ptr)
|
int ud2_start(UDisksClient **udc_ptr, UDisksManager **udm_ptr)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
@ -358,7 +360,7 @@ int main_send(filter_t *filter, delay_t *delay, char **files)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unmount the filesystem and eject the device if we mounted it */
|
/* Unmount the filesystem and eject the device if we mounted it */
|
||||||
if(mounted_here) {
|
if(mounted_here || forceunmount) {
|
||||||
GVariant *args = g_variant_new("a{sv}", NULL);
|
GVariant *args = g_variant_new("a{sv}", NULL);
|
||||||
udisks_filesystem_call_unmount_sync(fs, args, NULL, &error);
|
udisks_filesystem_call_unmount_sync(fs, args, NULL, &error);
|
||||||
if(error) err("while unmounting %s: %s", dev, error->message);
|
if(error) err("while unmounting %s: %s", dev, error->message);
|
||||||
|
|
Loading…
Reference in a new issue