Print this page
4846 HAL partition names don't match real partition names

@@ -2,10 +2,11 @@
  *
  * devinfo_storage.c : storage devices
  *
  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2013 Garrett D'Amore <garrett@damore.org>
+ * Copyright 2014 Andrew Stormont.
  *
  * Licensed under the Academic Free License version 2.1
  *
  **************************************************************************/
 

@@ -37,12 +38,18 @@
 #include "devinfo_storage.h"
 #include "osspec_solaris.h"
 
 #ifdef sparc
 #define WHOLE_DISK      "s2"
+#define DOS_SEPERATOR   ":"
+#define DOS_FORMAT      "s2:%d"
+#define DOS_TEMPLATE    ":NN"
 #else
 #define WHOLE_DISK      "p0"
+#define DOS_SEPERATOR   "p"
+#define DOS_FORMAT      "p%d"
+#define DOS_TEMPLATE    "pNN"
 #endif
 
 /* some devices,especially CDROMs, may take a while to be probed (values in ms) */
 #define DEVINFO_PROBE_STORAGE_TIMEOUT   60000
 #define DEVINFO_PROBE_VOLUME_TIMEOUT    60000

@@ -700,15 +707,15 @@
         /* add volumes: one on main device and a few pcfs candidates */
         m = devinfo_storage_new_minor(minor_path, WHOLE_DISK, devlink, dev, -1);
         devinfo_volume_add (d, node, m);
         devinfo_storage_free_minor (m);
 
-        doslink = (char *)calloc (1, strlen (devlink) + sizeof (":NNN") + 1);
+        doslink = (char *)calloc (1, strlen (devlink) + sizeof (DOS_TEMPLATE) + 1);
         if (doslink != NULL) {
                 for (i = 1; i < 16; i++) {
-                        snprintf(dospath, sizeof (dospath), WHOLE_DISK":%d", i);
-                        sprintf(doslink, "%s:%d", devlink, i);
+                        snprintf(dospath, sizeof (dospath), DOS_FORMAT, i);
+                        sprintf(doslink, "%s"DOS_SEPERATOR"%d", devlink, i);
                         m = devinfo_storage_new_minor(minor_path, dospath, doslink, dev, i);
                         devinfo_volume_add (d, node, m);
                         devinfo_storage_free_minor (m);
                 }
                 free (doslink);

@@ -857,18 +864,10 @@
                         free (devlink);
                         di_devfs_path_free (minor_path);
                         continue;
                 }
 
-                /* ignore p1..N - we'll use p0:N instead */
-                if ((strlen (slice) > 1) && (slice[0] == 'p') && isdigit(slice[1]) &&
-                    ((atol(&slice[1])) > 0)) {
-                        free (devlink);
-                        di_devfs_path_free (minor_path);
-                        continue;
-                }
-
                 m = devinfo_storage_new_minor(minor_path, slice, devlink, dev, -1);
                 if (m == NULL) {
                         free (devlink);
                         di_devfs_path_free (minor_path);
                         continue;

@@ -913,15 +912,15 @@
                 devinfo_add_enqueue (parent, maindev_path, &devinfo_storage_handler);
         }
 
         /* add virtual dos volumes to enable pcfs probing */
         if (!is_cdrom) {
-                doslink_len = strlen (maindev->devlink) + sizeof (":NNN") + 1;
+                doslink_len = strlen (maindev->devlink) + sizeof (DOS_TEMPLATE) + 1;
                 if ((doslink = (char *)calloc (1, doslink_len)) != NULL) {
                         for (i = 1; i < 16; i++) {
-                                snprintf(dospath, sizeof (dospath), "%s:%d", maindev->slice, i);
-                                snprintf(doslink, doslink_len, "%s:%d", maindev->devlink, i);
+                                snprintf(dospath, sizeof (dospath), "%s"DOS_SEPERATOR"%d", maindev->slice, i);
+                                snprintf(doslink, doslink_len, "%s"DOS_SEPERATOR"%d", maindev->devlink, i);
                                 m = devinfo_storage_new_minor(maindev_path, dospath, doslink, maindev->dev, i);
                                 g_queue_push_tail (mq, m);
                         }
                         free (doslink);
                 }

@@ -1401,30 +1400,30 @@
 static gboolean
 is_dos_path(char *path, int *partnum)
 {
         char *p;
 
-        if ((p = strrchr (path, ':')) == NULL) {
+        if ((p = strrchr (path, DOS_SEPERATOR)) == NULL) {
                 return (FALSE);
         }
         return ((*partnum = atoi(p + 1)) != 0);
 }
 
 static gboolean
 dos_to_dev(char *path, char **devpath, int *partnum)
 {
         char *p;
 
-        if ((p = strrchr (path, ':')) == NULL) {
+        if ((p = strrchr (path, DOS_SEPERATOR)) == NULL) {
                 return (FALSE);
         }
         if ((*partnum = atoi(p + 1)) == 0) {
                 return (FALSE);
         }
         p[0] = '\0';
         *devpath = strdup(path);
-        p[0] = ':';
+        p[0] = DOS_SEPERATOR;
         return (*devpath != NULL);
 }
 
 static void
 devinfo_storage_cleanup_mountpoint_cb (HalDevice *d, guint32 exit_type,