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 ↓ 57 lines elided ↑ open up ↑
  74   75  HalDevice *devinfo_volume_add(HalDevice *parent, di_node_t node, devinfo_storage_minor_t *m);
  75   76  static void devinfo_volume_preprobing_done(HalDevice *d, gpointer userdata1, gpointer userdata2);
  76   77  static void devinfo_volume_hotplug_begin_add (HalDevice *d, HalDevice *parent, DevinfoDevHandler *handler, void *end_token);
  77   78  static void devinfo_storage_hotplug_begin_add (HalDevice *d, HalDevice *parent, DevinfoDevHandler *handler, void *end_token);
  78   79  static void devinfo_storage_probing_done (HalDevice *d, guint32 exit_type, gint return_code, char **error, gpointer userdata1, gpointer userdata2);
  79   80  const gchar *devinfo_volume_get_prober (HalDevice *d, int *timeout);
  80   81  const gchar *devinfo_storage_get_prober (HalDevice *d, int *timeout);
  81   82  
  82   83  static char *devinfo_scsi_dtype2str(int dtype);
  83   84  static char *devinfo_volume_get_slice_name (char *devlink);
  84      -static gboolean dos_to_dev(char *path, char **devpath, int *partnum);
  85      -static gboolean is_dos_path(char *path, int *partnum);
       85 +static boolean_t is_dos_slice(const char *slice, int *partnum);
  86   86  
  87   87  static void devinfo_storage_set_nicknames (HalDevice *d);
  88   88  
  89   89  DevinfoDevHandler devinfo_ide_handler = {
  90   90          devinfo_ide_add,
  91   91          NULL,
  92   92          NULL,
  93   93          NULL,
  94   94          NULL,
  95   95          NULL
↓ open down ↓ 756 lines elided ↑ open up ↑
 852  852                          continue;
 853  853                  }
 854  854  
 855  855                  slice = devinfo_volume_get_slice_name (devlink);
 856  856                  if (strlen (slice) < 2) {
 857  857                          free (devlink);
 858  858                          di_devfs_path_free (minor_path);
 859  859                          continue;
 860  860                  }
 861  861  
 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  862                  m = devinfo_storage_new_minor(minor_path, slice, devlink, dev, -1);
 871  863                  if (m == NULL) {
 872  864                          free (devlink);
 873  865                          di_devfs_path_free (minor_path);
 874  866                          continue;
 875  867                  }
 876  868  
 877  869                  /* main device is either s2/p0 or d0, the latter taking precedence */
 878  870                  if ((strcmp (slice, "d0") == 0) ||
 879  871                      (((strcmp (slice, whole_disk) == 0) && (maindev == NULL)))) {
↓ open down ↓ 26 lines elided ↑ open up ↑
 906  898                  hal_device_property_set_int (parent, "block.minor", minor(maindev->dev));
 907  899                  hal_device_property_set_string (parent, "block.device", maindev->devlink);
 908  900                  raw = dsk_to_rdsk (maindev->devlink);
 909  901                  hal_device_property_set_string (parent, "block.solaris.raw_device", raw);
 910  902                  free (raw);
 911  903                  hal_device_property_set_bool (parent, "block.is_volume", FALSE);
 912  904                  hal_device_property_set_string (parent, "solaris.devfs_path", maindev_path);
 913  905                  devinfo_add_enqueue (parent, maindev_path, &devinfo_storage_handler);
 914  906          }
 915  907  
 916      -        /* add virtual dos volumes to enable pcfs probing */
 917      -        if (!is_cdrom) {
 918      -                doslink_len = strlen (maindev->devlink) + sizeof (":NNN") + 1;
 919      -                if ((doslink = (char *)calloc (1, doslink_len)) != NULL) {
 920      -                        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);
 923      -                                m = devinfo_storage_new_minor(maindev_path, dospath, doslink, maindev->dev, i);
 924      -                                g_queue_push_tail (mq, m);
 925      -                        }
 926      -                        free (doslink);
 927      -                }
 928      -        }
 929      -
 930  908          maindev_is_d0 = (strcmp (maindev->slice, "d0") == 0);
 931  909  
 932  910          /* enqueue all volumes */
 933  911          while (!g_queue_is_empty (mq)) {
 934  912                  m = g_queue_pop_head (mq);
 935  913  
 936  914                  /* if main device is d0, we'll throw away s2/p0 */
 937  915                  if (maindev_is_d0 && (strcmp (m->slice, whole_disk) == 0)) {
 938  916                          devinfo_storage_free_minor (m);
 939  917                          continue;
↓ open down ↓ 130 lines elided ↑ open up ↑
1070 1048          }
1071 1049          storage_d = hal_device_store_match_key_value_string (hald_get_gdl (), "info.udi", storage_udi);
1072 1050          if (storage_d == NULL) {
1073 1051                  HAL_INFO (("Storage device not found %s", hal_device_get_udi (d)));
1074 1052                  goto skip;
1075 1053          }
1076 1054  
1077 1055          whole_disk = hal_device_has_capability (storage_d,
1078 1056              "storage.cdrom") ? "s2" : WHOLE_DISK;
1079 1057  
1080      -        if (is_dos_path(block_device, &dos_num)) {
     1058 +        if (is_dos_slice(slice, &dos_num)) {
1081 1059                  /* don't probe more dos volumes than probe-storage found */
1082 1060                  if ((hal_device_property_get_bool (storage_d, "storage.no_partitions_hint") ||
1083 1061                      (dos_num > hal_device_property_get_int (storage_d, "storage.solaris.num_dos_partitions")))) {
1084 1062                              HAL_INFO (("%d > %d %s", dos_num, hal_device_property_get_int (storage_d,
1085 1063                                  "storage.solaris.num_dos_partitions"), hal_device_get_udi (storage_d)));
1086 1064                          goto skip;
1087 1065                  }
1088 1066          } else {
1089 1067                  /* if no VTOC slices found, don't probe slices except s2 */
1090 1068                  if ((slice[0] == 's') && (isdigit(slice[1])) && ((strcmp (slice, whole_disk)) != 0) &&
↓ open down ↓ 300 lines elided ↑ open up ↑
1391 1369          } else {
1392 1370                  s = disk;
1393 1371          }
1394 1372          if ((s != NULL) && isdigit(s[1])) {
1395 1373                  return (s);
1396 1374          } else {
1397 1375                  return ("");
1398 1376          }
1399 1377  }
1400 1378  
1401      -static gboolean
1402      -is_dos_path(char *path, int *partnum)
     1379 +static boolean_t
     1380 +is_dos_slice(const char *slice, int *partnum)
1403 1381  {
1404 1382          char *p;
1405 1383  
1406      -        if ((p = strrchr (path, ':')) == NULL) {
1407      -                return (FALSE);
     1384 +        if ((p = strrchr(slice, 'p')) == NULL &&
     1385 +            (p = strrchr(slice, ':')) == NULL) {
     1386 +                return (B_FALSE);
1408 1387          }
1409      -        return ((*partnum = atoi(p + 1)) != 0);
1410      -}
1411      -
1412      -static gboolean
1413      -dos_to_dev(char *path, char **devpath, int *partnum)
1414      -{
1415      -        char *p;
1416 1388  
1417      -        if ((p = strrchr (path, ':')) == NULL) {
1418      -                return (FALSE);
1419      -        }
1420      -        if ((*partnum = atoi(p + 1)) == 0) {
1421      -                return (FALSE);
1422      -        }
1423      -        p[0] = '\0';
1424      -        *devpath = strdup(path);
1425      -        p[0] = ':';
1426      -        return (*devpath != NULL);
     1389 +        return ((*partnum = atoi(p + 1)) != 0);
1427 1390  }
1428 1391  
1429 1392  static void
1430 1393  devinfo_storage_cleanup_mountpoint_cb (HalDevice *d, guint32 exit_type, 
1431 1394                         gint return_code, gchar **error,
1432 1395                         gpointer data1, gpointer data2)
1433 1396  {
1434 1397          char *mount_point = (char *) data1;
1435 1398  
1436 1399          HAL_INFO (("Cleaned up mount point '%s'", mount_point));
↓ open down ↓ 295 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX