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

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/hal/hald/solaris/devinfo_storage.c
          +++ new/usr/src/cmd/hal/hald/solaris/devinfo_storage.c
   1    1  /***************************************************************************
   2    2   *
   3    3   * devinfo_storage.c : storage devices
   4    4   *
   5    5   * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
   6    6   * Copyright 2013 Garrett D'Amore <garrett@damore.org>
        7 + * Copyright 2014 Andrew Stormont.
   7    8   *
   8    9   * Licensed under the Academic Free License version 2.1
   9   10   *
  10   11   **************************************************************************/
  11   12  
  12   13  #ifdef HAVE_CONFIG_H
  13   14  #  include <config.h>
  14   15  #endif
  15   16  
  16   17  #include <stdio.h>
↓ open down ↓ 15 lines elided ↑ open up ↑
  32   33  #include "../util.h"
  33   34  #include "../hald_runner.h"
  34   35  #include "hotplug.h"
  35   36  #include "devinfo.h"
  36   37  #include "devinfo_misc.h"
  37   38  #include "devinfo_storage.h"
  38   39  #include "osspec_solaris.h"
  39   40  
  40   41  #ifdef sparc
  41   42  #define WHOLE_DISK      "s2"
       43 +#define DOS_SEPERATOR   ":"
       44 +#define DOS_FORMAT      "s2:%d"
       45 +#define DOS_TEMPLATE    ":NN"
  42   46  #else
  43   47  #define WHOLE_DISK      "p0"
       48 +#define DOS_SEPERATOR   "p"
       49 +#define DOS_FORMAT      "p%d"
       50 +#define DOS_TEMPLATE    "pNN"
  44   51  #endif
  45   52  
  46   53  /* some devices,especially CDROMs, may take a while to be probed (values in ms) */
  47   54  #define DEVINFO_PROBE_STORAGE_TIMEOUT   60000
  48   55  #define DEVINFO_PROBE_VOLUME_TIMEOUT    60000
  49   56  
  50   57  typedef struct devinfo_storage_minor {
  51   58          char    *devpath;
  52   59          char    *devlink;
  53   60          char    *slice;
↓ open down ↓ 641 lines elided ↑ open up ↑
 695  702          free (raw);
 696  703          hal_device_property_set_bool (d, "block.is_volume", FALSE);
 697  704  
 698  705          devinfo_add_enqueue (d, minor_path, &devinfo_storage_handler);
 699  706  
 700  707          /* add volumes: one on main device and a few pcfs candidates */
 701  708          m = devinfo_storage_new_minor(minor_path, WHOLE_DISK, devlink, dev, -1);
 702  709          devinfo_volume_add (d, node, m);
 703  710          devinfo_storage_free_minor (m);
 704  711  
 705      -        doslink = (char *)calloc (1, strlen (devlink) + sizeof (":NNN") + 1);
      712 +        doslink = (char *)calloc (1, strlen (devlink) + sizeof (DOS_TEMPLATE) + 1);
 706  713          if (doslink != NULL) {
 707  714                  for (i = 1; i < 16; i++) {
 708      -                        snprintf(dospath, sizeof (dospath), WHOLE_DISK":%d", i);
 709      -                        sprintf(doslink, "%s:%d", devlink, i);
      715 +                        snprintf(dospath, sizeof (dospath), DOS_FORMAT, i);
      716 +                        sprintf(doslink, "%s"DOS_SEPERATOR"%d", devlink, i);
 710  717                          m = devinfo_storage_new_minor(minor_path, dospath, doslink, dev, i);
 711  718                          devinfo_volume_add (d, node, m);
 712  719                          devinfo_storage_free_minor (m);
 713  720                  }
 714  721                  free (doslink);
 715  722          }
 716  723  }
 717  724  
 718  725  void
 719  726  devinfo_lofi_remove_minor(char *parent_devfs_path, char *name)
↓ open down ↓ 132 lines elided ↑ open up ↑
 852  859                          continue;
 853  860                  }
 854  861  
 855  862                  slice = devinfo_volume_get_slice_name (devlink);
 856  863                  if (strlen (slice) < 2) {
 857  864                          free (devlink);
 858  865                          di_devfs_path_free (minor_path);
 859  866                          continue;
 860  867                  }
 861  868  
 862      -                /* ignore p1..N - we'll use p0:N instead */
 863      -                if ((strlen (slice) > 1) && (slice[0] == 'p') && isdigit(slice[1]) &&
 864      -                    ((atol(&slice[1])) > 0)) {
 865      -                        free (devlink);
 866      -                        di_devfs_path_free (minor_path);
 867      -                        continue;
 868      -                }
 869      -
 870  869                  m = devinfo_storage_new_minor(minor_path, slice, devlink, dev, -1);
 871  870                  if (m == NULL) {
 872  871                          free (devlink);
 873  872                          di_devfs_path_free (minor_path);
 874  873                          continue;
 875  874                  }
 876  875  
 877  876                  /* main device is either s2/p0 or d0, the latter taking precedence */
 878  877                  if ((strcmp (slice, "d0") == 0) ||
 879  878                      (((strcmp (slice, whole_disk) == 0) && (maindev == NULL)))) {
↓ open down ↓ 28 lines elided ↑ open up ↑
 908  907                  raw = dsk_to_rdsk (maindev->devlink);
 909  908                  hal_device_property_set_string (parent, "block.solaris.raw_device", raw);
 910  909                  free (raw);
 911  910                  hal_device_property_set_bool (parent, "block.is_volume", FALSE);
 912  911                  hal_device_property_set_string (parent, "solaris.devfs_path", maindev_path);
 913  912                  devinfo_add_enqueue (parent, maindev_path, &devinfo_storage_handler);
 914  913          }
 915  914  
 916  915          /* add virtual dos volumes to enable pcfs probing */
 917  916          if (!is_cdrom) {
 918      -                doslink_len = strlen (maindev->devlink) + sizeof (":NNN") + 1;
      917 +                doslink_len = strlen (maindev->devlink) + sizeof (DOS_TEMPLATE) + 1;
 919  918                  if ((doslink = (char *)calloc (1, doslink_len)) != NULL) {
 920  919                          for (i = 1; i < 16; i++) {
 921      -                                snprintf(dospath, sizeof (dospath), "%s:%d", maindev->slice, i);
 922      -                                snprintf(doslink, doslink_len, "%s:%d", maindev->devlink, i);
      920 +                                snprintf(dospath, sizeof (dospath), "%s"DOS_SEPERATOR"%d", maindev->slice, i);
      921 +                                snprintf(doslink, doslink_len, "%s"DOS_SEPERATOR"%d", maindev->devlink, i);
 923  922                                  m = devinfo_storage_new_minor(maindev_path, dospath, doslink, maindev->dev, i);
 924  923                                  g_queue_push_tail (mq, m);
 925  924                          }
 926  925                          free (doslink);
 927  926                  }
 928  927          }
 929  928  
 930  929          maindev_is_d0 = (strcmp (maindev->slice, "d0") == 0);
 931  930  
 932  931          /* enqueue all volumes */
↓ open down ↓ 463 lines elided ↑ open up ↑
1396 1395          } else {
1397 1396                  return ("");
1398 1397          }
1399 1398  }
1400 1399  
1401 1400  static gboolean
1402 1401  is_dos_path(char *path, int *partnum)
1403 1402  {
1404 1403          char *p;
1405 1404  
1406      -        if ((p = strrchr (path, ':')) == NULL) {
     1405 +        if ((p = strrchr (path, DOS_SEPERATOR)) == NULL) {
1407 1406                  return (FALSE);
1408 1407          }
1409 1408          return ((*partnum = atoi(p + 1)) != 0);
1410 1409  }
1411 1410  
1412 1411  static gboolean
1413 1412  dos_to_dev(char *path, char **devpath, int *partnum)
1414 1413  {
1415 1414          char *p;
1416 1415  
1417      -        if ((p = strrchr (path, ':')) == NULL) {
     1416 +        if ((p = strrchr (path, DOS_SEPERATOR)) == NULL) {
1418 1417                  return (FALSE);
1419 1418          }
1420 1419          if ((*partnum = atoi(p + 1)) == 0) {
1421 1420                  return (FALSE);
1422 1421          }
1423 1422          p[0] = '\0';
1424 1423          *devpath = strdup(path);
1425      -        p[0] = ':';
     1424 +        p[0] = DOS_SEPERATOR;
1426 1425          return (*devpath != NULL);
1427 1426  }
1428 1427  
1429 1428  static void
1430 1429  devinfo_storage_cleanup_mountpoint_cb (HalDevice *d, guint32 exit_type, 
1431 1430                         gint return_code, gchar **error,
1432 1431                         gpointer data1, gpointer data2)
1433 1432  {
1434 1433          char *mount_point = (char *) data1;
1435 1434  
↓ open down ↓ 296 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX