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

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/hal/utils/fsutils.c
          +++ new/usr/src/cmd/hal/utils/fsutils.c
   1    1  /*
   2    2   *
   3    3   * fsutils.c : filesystem utilities
   4    4   *
   5    5   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
   6    6   * Use is subject to license terms.
   7    7   *
        8 + * Copyright 2014 Andrew Stormont.
        9 + *
   8   10   * Licensed under the Academic Free License version 2.1
   9   11   *
  10   12   */
  11   13  
  12   14  #ifdef HAVE_CONFIG_H
  13   15  #include <config.h>
  14   16  #endif
  15   17  
  16   18  #include <stdio.h>
  17   19  #include <sys/types.h>
↓ open down ↓ 8 lines elided ↑ open up ↑
  26   28  #include <sys/dkio.h>
  27   29  #include <libintl.h>
  28   30  #include <sys/dktp/fdisk.h>
  29   31  #include <sys/fs/pc_label.h>
  30   32  
  31   33  #include <libhal.h>
  32   34  #include "fsutils.h"
  33   35  
  34   36  /*
  35   37   * Separates dos notation device spec into device and drive number
       38 + *     pN partition names are rewritten to point to p0
       39 + *     :N partition names are dropped
  36   40   */
  37   41  boolean_t
  38   42  dos_to_dev(char *path, char **devpath, int *num)
  39   43  {
  40      -        char *p;
       44 +        int i;
       45 +        char *buf;
       46 +        boolean_t found = B_FALSE;
  41   47  
  42      -        if ((p = strrchr(path, ':')) == NULL) {
  43      -                return (B_FALSE);
       48 +        for (i = strlen(path); i > 0; i--) {
       49 +                if (path[i] == 'p' || path[i] == ':') {
       50 +                        found = B_TRUE;
       51 +                        break;
       52 +                }
  44   53          }
  45      -        if ((*num = atoi(p + 1)) == 0) {
       54 +
       55 +        if (found == B_FALSE || (*num = atoi(path + i + 1)) == 0 ||
       56 +            (buf = strdup(path)) == NULL) {
  46   57                  return (B_FALSE);
  47   58          }
  48      -        p[0] = '\0';
  49      -        *devpath = strdup(path);
  50      -        p[0] = ':';
  51      -        return (*devpath != NULL);
       59 +
       60 +        (void) strcpy(buf + i, path[i] == 'p' ? "p0" : "");
       61 +        *devpath = buf;
       62 +        return (B_TRUE);
  52   63  }
  53   64  
  54   65  char *
  55   66  get_slice_name(char *devlink)
  56   67  {
  57   68          char    *part, *slice, *disk;
  58   69          char    *s = NULL;
  59   70          char    *p;
  60   71  
  61   72          if ((p = strstr(devlink, "/lofi/")) != 0) {
↓ open down ↓ 187 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX