xref: /illumos-gate/usr/src/cmd/hal/utils/fsutils.c (revision 342440ec)
1*342440ecSPrasad Singamsetty /*
218c2aff7Sartem  *
318c2aff7Sartem  * fsutils.c : filesystem utilities
418c2aff7Sartem  *
5422ee277Sartem  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
618c2aff7Sartem  * Use is subject to license terms.
718c2aff7Sartem  *
818c2aff7Sartem  * Licensed under the Academic Free License version 2.1
918c2aff7Sartem  *
10*342440ecSPrasad Singamsetty  */
1118c2aff7Sartem 
1218c2aff7Sartem #ifdef HAVE_CONFIG_H
13*342440ecSPrasad Singamsetty #include <config.h>
1418c2aff7Sartem #endif
1518c2aff7Sartem 
1618c2aff7Sartem #include <stdio.h>
1718c2aff7Sartem #include <sys/types.h>
1818c2aff7Sartem #include <sys/scsi/impl/uscsi.h>
1918c2aff7Sartem #include <string.h>
2018c2aff7Sartem #include <strings.h>
2118c2aff7Sartem #include <ctype.h>
2218c2aff7Sartem #include <unistd.h>
2318c2aff7Sartem #include <stdlib.h>
2418c2aff7Sartem #include <errno.h>
2518c2aff7Sartem #include <fcntl.h>
2618c2aff7Sartem #include <sys/dkio.h>
2718c2aff7Sartem #include <libintl.h>
2818c2aff7Sartem #include <sys/dktp/fdisk.h>
2918c2aff7Sartem #include <sys/fs/pc_label.h>
3018c2aff7Sartem 
3118c2aff7Sartem #include <libhal.h>
3218c2aff7Sartem #include "fsutils.h"
3318c2aff7Sartem 
3418c2aff7Sartem /*
3518c2aff7Sartem  * Separates dos notation device spec into device and drive number
3618c2aff7Sartem  */
3718c2aff7Sartem boolean_t
dos_to_dev(char * path,char ** devpath,int * num)3818c2aff7Sartem dos_to_dev(char *path, char **devpath, int *num)
3918c2aff7Sartem {
4018c2aff7Sartem 	char *p;
4118c2aff7Sartem 
4218c2aff7Sartem 	if ((p = strrchr(path, ':')) == NULL) {
4318c2aff7Sartem 		return (B_FALSE);
4418c2aff7Sartem 	}
4518c2aff7Sartem 	if ((*num = atoi(p + 1)) == 0) {
4618c2aff7Sartem 		return (B_FALSE);
4718c2aff7Sartem 	}
4818c2aff7Sartem 	p[0] = '\0';
4918c2aff7Sartem 	*devpath = strdup(path);
5018c2aff7Sartem 	p[0] = ':';
51