[maemo-commits] [maemo-commits] r17961 - in projects/haf/trunk/ke-recv: debian mmc-utils src
From: subversion at stage.maemo.org subversion at stage.maemo.orgDate: Wed Apr 1 18:43:15 EEST 2009
- Previous message: [maemo-commits] r17960 - projects/haf/trunk/glib
- Next message: [maemo-commits] r17962 - projects/haf/tags/ke-recv
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Author: kihamala Date: 2009-04-01 18:43:06 +0300 (Wed, 01 Apr 2009) New Revision: 17961 Added: projects/haf/trunk/ke-recv/mmc-utils/mmc-unmount.c Modified: projects/haf/trunk/ke-recv/debian/changelog projects/haf/trunk/ke-recv/debian/control projects/haf/trunk/ke-recv/mmc-utils/Makefile.am projects/haf/trunk/ke-recv/src/osso-mmc-mount.sh projects/haf/trunk/ke-recv/src/osso-mmc-umount.sh Log: releasing Modified: projects/haf/trunk/ke-recv/debian/changelog =================================================================== --- projects/haf/trunk/ke-recv/debian/changelog 2009-04-01 14:37:48 UTC (rev 17960) +++ projects/haf/trunk/ke-recv/debian/changelog 2009-04-01 15:43:06 UTC (rev 17961) @@ -1,11 +1,19 @@ -ke-recv (3.11-1~unreleased) unstable; urgency=low +ke-recv (3.11-1) unstable; urgency=low * Fix partitioning script for 3 partitions * Added check for the success of "rmmod g_nokia". * Added check for FAT magic number before trying to mount as FAT. * Fixes: NB#108219 - osso-mmc-mount.sh should use -n (no interaction) + * Added mmc-unmount utility for unmounting with GIO. Patch from Carlos + Garnacho. + * Fixes: NB#105328 - Internal memory card is not mounted to PC in USB Mass + storage mode + * Using the new '-I' command line option for dosfsck to ignore 'minor' + corruptions. + * Fixes: NB#108624 - External memory card is detected as read-only always + when it's corrupted. - -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> Thu, 26 Mar 2009 14:16:46 +0200 + -- Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> Wed, 01 Apr 2009 18:35:12 +0300 ke-recv (3.10-1) unstable; urgency=low Modified: projects/haf/trunk/ke-recv/debian/control =================================================================== --- projects/haf/trunk/ke-recv/debian/control 2009-04-01 14:37:48 UTC (rev 17960) +++ projects/haf/trunk/ke-recv/debian/control 2009-04-01 15:43:06 UTC (rev 17961) @@ -7,7 +7,7 @@ Package: ke-recv Architecture: any -Depends: ${shlibs:Depends}, ke-recv-l10n-mr | ke-recv-l10n-mr0, gconf2, osso-af-startup (>= 1.22), hal, dosfstools (>= 3.0.1-1maemo2), mtools +Depends: ${shlibs:Depends}, ke-recv-l10n-mr | ke-recv-l10n-mr0, gconf2, osso-af-startup (>= 1.22), hal, dosfstools (> 3.0.1-1maemo2), mtools Description: Program for automatical mounting and unmounting of memory cards. Program for receiving HW events from the HAL, managing mounting, renaming, formatting, and partitioning of memory cards, etc. Modified: projects/haf/trunk/ke-recv/mmc-utils/Makefile.am =================================================================== --- projects/haf/trunk/ke-recv/mmc-utils/Makefile.am 2009-04-01 14:37:48 UTC (rev 17960) +++ projects/haf/trunk/ke-recv/mmc-utils/Makefile.am 2009-04-01 15:43:06 UTC (rev 17961) @@ -1,6 +1,9 @@ -bin_PROGRAMS = mmc-pre-unmount +bin_PROGRAMS = \ + mmc-pre-unmount \ + mmc-unmount + INCLUDES = \ - `pkg-config --cflags gnome-vfs-2.0` \ + `pkg-config --cflags gnome-vfs-2.0 gio-2.0` \ -I . \ -DUSE_EXT_DBUS_DAEMON=1 @@ -13,3 +16,11 @@ mmc_pre_unmount_LDFLAGS = \ -lgnomevfs-2 +mmc_unmount_INCLUDES = \ + `pkg-config --cflags gio-2.0` + +mmc_unmount_SOURCES = \ + mmc-unmount.c + +mmc_unmount_LDFLAGS = \ + `pkg-config --libs gio-2.0` Added: projects/haf/trunk/ke-recv/mmc-utils/mmc-unmount.c =================================================================== --- projects/haf/trunk/ke-recv/mmc-utils/mmc-unmount.c 2009-04-01 14:37:48 UTC (rev 17960) +++ projects/haf/trunk/ke-recv/mmc-utils/mmc-unmount.c 2009-04-01 15:43:06 UTC (rev 17961) @@ -0,0 +1,184 @@ +#include <gio/gio.h> + +#define EXIT_FAILURE 1 + +static gboolean verbose = 1; +static gboolean success; +static gchar **path; +static GMainLoop *main_loop; + +static GOptionEntry entries[] = { + { "verbose", 'v', 0, + G_OPTION_ARG_NONE, &verbose, + "Whether to enable verbosity", + NULL }, + { G_OPTION_REMAINING, 0, 0, + G_OPTION_ARG_FILENAME_ARRAY, &path, + "Device/mountdir path", + NULL }, + + { NULL } +}; + +static void +log_message (const gchar *str, + ...) +{ + va_list args; + + if (G_LIKELY (!verbose)) + return; + + va_start (args, str); + g_logv ("ke-recv", G_LOG_LEVEL_MESSAGE, str, args); + va_end (args); +} + +static gboolean +check_device_path (GMount *mount, + GFile *file) +{ + GVolume *volume; + gchar *device_path; + GFile *device_file; + gboolean equal; + + volume = g_mount_get_volume (mount); + + if (!volume) + return FALSE; + + device_path = g_volume_get_identifier (volume, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE); + device_file = g_file_new_for_path (device_path); + + equal = g_file_equal (file, device_file); + + g_object_unref (device_file); + g_free (device_path); + + return equal; +} + +static GMount * +find_mount (GFile *file) +{ + GVolumeMonitor *monitor; + GMount *mount = NULL; + GList *mounts, *m; + + monitor = g_volume_monitor_get (); + mounts = g_volume_monitor_get_mounts (monitor); + + for (m = mounts; m; m = m->next) + { + GFile *root; + + root = g_mount_get_root (G_MOUNT (m->data)); + + /* Check mount dir/device path */ + if (g_file_equal (root, file) || + check_device_path (G_MOUNT (m->data), file)) + { + log_message ("Found mount for given path"); + g_object_unref (root); + mount = g_object_ref (m->data); + break; + } + + g_object_unref (root); + } + + g_list_foreach (mounts, (GFunc) g_object_unref, NULL); + g_list_free (mounts); + + return mount; +} + +static void +do_unmount_cb (GObject *object, + GAsyncResult *result, + gpointer user_data) +{ + GMount *mount; + GError *error = NULL; + + mount = G_MOUNT (object); + + if (!g_mount_unmount_finish (mount, result, &error)) + { + log_message ("Could not perform unmount, %s", + (error) ? error->message : "No error given"); + success = FALSE; + } + else + { + log_message ("Unmount succeeded"); + success = TRUE; + } + + g_main_loop_quit (main_loop); +} + +static void +do_unmount (GMount *mount) +{ + g_mount_unmount (mount, + G_MOUNT_UNMOUNT_NONE, + NULL, + do_unmount_cb, + NULL); +} + +int +main (int argc, char *argv[]) +{ + GOptionContext *context; + GFile *file; + GMount *mount; + + g_type_init (); + + context = g_option_context_new ("- Unmount a memcard"); + g_option_context_add_main_entries (context, entries, NULL); + g_option_context_parse (context, &argc, &argv, NULL); + + if (!path || !path[0]) + { + gchar *help_str; + + g_printerr ("No mount or device path were passed\n\n"); + + help_str = g_option_context_get_help (context, TRUE, NULL); + g_option_context_free (context); + g_printerr ("%s", help_str); + g_free (help_str); + + return EXIT_FAILURE; + } + + file = g_file_new_for_commandline_arg (path[0]); + log_message ("About to unmount %s", path[0]); + + mount = find_mount (file); + g_object_unref (file); + + if (!mount) + { + log_message ("Could not find mount"); + return EXIT_FAILURE; + } + + do_unmount (mount); + g_object_unref (mount); + + main_loop = g_main_loop_new (NULL, FALSE); + g_main_loop_run (main_loop); + g_main_loop_unref (main_loop); + + /* At this point success is updated with the operation result */ + + if (!success) + return EXIT_FAILURE; + + return 0; +} Modified: projects/haf/trunk/ke-recv/src/osso-mmc-mount.sh =================================================================== --- projects/haf/trunk/ke-recv/src/osso-mmc-mount.sh 2009-04-01 14:37:48 UTC (rev 17960) +++ projects/haf/trunk/ke-recv/src/osso-mmc-mount.sh 2009-04-01 15:43:06 UTC (rev 17961) @@ -49,7 +49,7 @@ fi # time limited check -/sbin/dosfsck -n -T 10 $PDEV +/sbin/dosfsck -I -n -T 10 $PDEV if [ $? != 0 ]; then logger "$0: $PDEV is corrupt, trying to mount it read-only" mmc-mount $PDEV $MP ro Modified: projects/haf/trunk/ke-recv/src/osso-mmc-umount.sh =================================================================== --- projects/haf/trunk/ke-recv/src/osso-mmc-umount.sh 2009-04-01 14:37:48 UTC (rev 17960) +++ projects/haf/trunk/ke-recv/src/osso-mmc-umount.sh 2009-04-01 15:43:06 UTC (rev 17961) @@ -1,9 +1,9 @@ #!/bin/sh # This file is part of ke-recv # -# Copyright (C) 2005-2007 Nokia Corporation. All rights reserved. +# Copyright (C) 2005-2009 Nokia Corporation. All rights reserved. # -# Contact: Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> +# Author: Kimmo Hämäläinen <kimmo.hamalainen at nokia.com> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -28,7 +28,12 @@ grep "$MP " /proc/mounts > /dev/null if [ $? = 0 ]; then - umount $MP 2> /dev/null + # first try in gvfs way + mmc-unmount $MP 2> /dev/null + if [ $? != 0 ]; then + # try if old-fashioned way works + umount $MP 2> /dev/null + fi RC=$? else # it is not mounted
- Previous message: [maemo-commits] r17960 - projects/haf/trunk/glib
- Next message: [maemo-commits] r17962 - projects/haf/tags/ke-recv
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]