Print this page
4846 HAL partition names don't match real partition names
@@ -3,10 +3,12 @@
* fsutils.c : filesystem utilities
*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
+ * Copyright 2014 Andrew Stormont.
+ *
* Licensed under the Academic Free License version 2.1
*
*/
#ifdef HAVE_CONFIG_H
@@ -31,26 +33,35 @@
#include <libhal.h>
#include "fsutils.h"
/*
* Separates dos notation device spec into device and drive number
+ * pN partition names are rewritten to point to p0
+ * :N partition names are dropped
*/
boolean_t
dos_to_dev(char *path, char **devpath, int *num)
{
- char *p;
+ int i;
+ char *buf;
+ boolean_t found = B_FALSE;
- if ((p = strrchr(path, ':')) == NULL) {
- return (B_FALSE);
+ for (i = strlen(path); i > 0; i--) {
+ if (path[i] == 'p' || path[i] == ':') {
+ found = B_TRUE;
+ break;
}
- if ((*num = atoi(p + 1)) == 0) {
+ }
+
+ if (found == B_FALSE || (*num = atoi(path + i + 1)) == 0 ||
+ (buf = strdup(path)) == NULL) {
return (B_FALSE);
}
- p[0] = '\0';
- *devpath = strdup(path);
- p[0] = ':';
- return (*devpath != NULL);
+
+ (void) strcpy(buf + i, path[i] == 'p' ? "p0" : "");
+ *devpath = buf;
+ return (B_TRUE);
}
char *
get_slice_name(char *devlink)
{