[maemo-commits] [maemo-commits] r16818 - projects/haf/trunk/ke-recv/src

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Mon Dec 1 11:17:47 EET 2008
Author: kihamala
Date: 2008-12-01 11:17:36 +0200 (Mon, 01 Dec 2008)
New Revision: 16818

Modified:
   projects/haf/trunk/ke-recv/src/events.c
   projects/haf/trunk/ke-recv/src/ke-recv.c
Log:
fix for E_RENAME handling


Modified: projects/haf/trunk/ke-recv/src/events.c
===================================================================
--- projects/haf/trunk/ke-recv/src/events.c	2008-12-01 09:03:17 UTC (rev 16817)
+++ projects/haf/trunk/ke-recv/src/events.c	2008-12-01 09:17:36 UTC (rev 16818)
@@ -603,17 +603,28 @@
         }
 }
 
-static void handle_e_rename(mmc_info_t *mmc, const char *udi)
+static void handle_e_rename(mmc_info_t *mmc)
 {
         const char* args[] = {MMC_RENAME_PROG, NULL, NULL, NULL};
         int ret;
-        char *dev;
+        volume_list_t *vol;
 
-        dev = get_prop_string(udi, "block.device");
-        if (dev == NULL) {
-                return;
+        vol = get_nth_volume(mmc, mmc->preferred_volume);
+
+        if (vol == NULL || vol->dev_name == NULL) {
+                ULOG_ERR_F("could not find partition number %d",
+                           mmc->preferred_volume);
+                if (mmc->preferred_volume != 1 && mmc->internal_card) {
+                        /* workaround for not yet partitioned systems */
+                        ULOG_DEBUG_F("%s: falling back to partition 1!");
+                        vol = get_nth_volume(mmc, 1);
+                        if (vol == NULL || vol->dev_name == NULL)
+                                return;
+                } else
+                        return;
         }
-        args[1] = dev;
+
+        args[1] = vol->dev_name;
         args[2] = mmc->desired_label;
 
         /* check validity of volume label */
@@ -621,11 +632,9 @@
         assert(ret < 1 && ret > -3);
         if (ret == -1) {
                 ULOG_ERR_F("too long name");
-                libhal_free_string(dev);
                 return;
         } else if (ret == -2) {
                 ULOG_ERR_F("invalid characters");
-                libhal_free_string(dev);
                 return;
         }
 
@@ -641,7 +650,6 @@
                         /* even if renaming failed it makes sense to
                          * try mounting the card */
                 }
-                libhal_free_string(dev);
 
                 update_mmc_label(mmc);
                 ULOG_DEBUG_F("successful renaming");
@@ -650,7 +658,6 @@
                         display_dialog(MSG_MEMORY_CARD_IS_CORRUPTED);
                 }
         } else {
-                libhal_free_string(dev);
                 ULOG_DEBUG_F("umount failed");
                 display_system_note(dgettext("osso-filemanager",
                                     "sfil_ni_mmc_rename_mmc_in_use"));
@@ -1125,7 +1132,7 @@
                         }
                         break;
                 case E_RENAME:
-                        handle_e_rename(mmc, arg);
+                        handle_e_rename(mmc);
                         break;
                 case E_FORMAT:
                         handle_e_format(mmc);

Modified: projects/haf/trunk/ke-recv/src/ke-recv.c
===================================================================
--- projects/haf/trunk/ke-recv/src/ke-recv.c	2008-12-01 09:03:17 UTC (rev 16817)
+++ projects/haf/trunk/ke-recv/src/ke-recv.c	2008-12-01 09:17:36 UTC (rev 16818)
@@ -365,19 +365,6 @@
 
         send_reply();
 
-        l = &mmc->volumes;
-        while (l != NULL) {
-                if (l->udi != NULL && l->volume_number == 1) {
-                        udi = l->udi;
-                        break;
-                }
-                l = l->next;
-        }
-        if (udi == NULL) {
-                ULOG_ERR_F("could not find udi for first partition");
-                goto rename_exit;
-        }
-
         if (label[0] == '\0') {
                 /* empty label */
                 strncpy(mmc->desired_label, "           ", 11);
@@ -387,7 +374,7 @@
         mmc->desired_label[11] = '\0';
         ULOG_DEBUG_F("got label: '%s'", mmc->desired_label);
         /* validity of the label is checked later */
-        handle_event(E_RENAME, mmc, udi);
+        handle_event(E_RENAME, mmc, NULL);
 
 rename_exit:
         /* invalidate */


More information about the maemo-commits mailing list