xref: /illumos-gate/usr/src/cmd/hal/utils/fsutils.c (revision 422ee277)
118c2aff7Sartem /***************************************************************************
218c2aff7Sartem  *
318c2aff7Sartem  * fsutils.c : filesystem utilities
418c2aff7Sartem  *
5*422ee277Sartem  * 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  *
1018c2aff7Sartem  **************************************************************************/
1118c2aff7Sartem 
1292f38132Sartem #pragma ident	"%Z%%M%	%I%	%E% SMI"
1318c2aff7Sartem 
1418c2aff7Sartem #ifdef HAVE_CONFIG_H
1518c2aff7Sartem #  include <config.h>
1618c2aff7Sartem #endif
1718c2aff7Sartem 
1818c2aff7Sartem #include <stdio.h>
1918c2aff7Sartem #include <sys/types.h>
2018c2aff7Sartem #include <sys/scsi/impl/uscsi.h>
2118c2aff7Sartem #include <string.h>
2218c2aff7Sartem #include <strings.h>
2318c2aff7Sartem #include <ctype.h>
2418c2aff7Sartem #include <unistd.h>
2518c2aff7Sartem #include <stdlib.h>
2618c2aff7Sartem #include <errno.h>
2718c2aff7Sartem #include <fcntl.h>
2818c2aff7Sartem #include <sys/dkio.h>
2918c2aff7Sartem #include <libintl.h>
3018c2aff7Sartem #include <sys/dktp/fdisk.h>
3118c2aff7Sartem #include <sys/fs/pc_label.h>
3218c2aff7Sartem 
3318c2aff7Sartem #include <libhal.h>
3418c2aff7Sartem #include "fsutils.h"
3518c2aff7Sartem 
3618c2aff7Sartem /*
3718c2aff7Sartem  * Separates dos notation device spec into device and drive number
3818c2aff7Sartem  */
3918c2aff7Sartem boolean_t
4018c2aff7Sartem dos_to_dev(char *path, char **devpath, int *num)
4118c2aff7Sartem {
4218c2aff7Sartem 	char *p;
4318c2aff7Sartem 
4418c2aff7Sartem 	if ((p = strrchr(path, ':')) == NULL) {
4518c2aff7Sartem 		return (B_FALSE);
4618c2aff7Sartem 	}
4718c2aff7Sartem 	if ((*num = atoi(p + 1)) == 0) {
4818c2aff7Sartem 		return (B_FALSE);
49