Whamcloud - gitweb
Define MKDIR_P in the Makefile.in files instead in MCONFIG.in
[tools/e2fsprogs.git] / misc / base_device.c
index f58f2e8..d1c1cd9 100644 (file)
@@ -5,12 +5,12 @@
  * assure that we only fsck one partition on a particular drive at any
  * one time.  Otherwise, the disk heads will be seeking all over the
  * place.  If the base device can not be determined, return NULL.
- * 
+ *
  * The base_device() function returns an allocated string which must
  * be freed.
- * 
+ *
  * Written by Theodore Ts'o, <tytso@mit.edu>
- * 
+ *
  * Copyright (C) 2000 Theodore Ts'o.
  *
  * %Begin-Header%
@@ -18,6 +18,7 @@
  * License.
  * %End-Header%
  */
+#include "config.h"
 #include <stdio.h>
 #if HAVE_UNISTD_H
 #include <unistd.h>
@@ -38,7 +39,7 @@ static const char *devfs_hier[] = {
        "host", "bus", "target", "lun", 0
 };
 
-char *base_device(char *device)
+char *base_device(const char *device)
 {
        char *str, *cp;
        const char **hier, *disk;
@@ -58,7 +59,7 @@ char *base_device(char *device)
        /* Skip over /dev/dsk/... */
        if (strncmp(cp, "dsk/", 4) == 0)
                cp += 4;
-       
+
        /*
         * For md devices, we treat them all as if they were all
         * on one disk, since we don't know how to parallelize them.
@@ -147,10 +148,9 @@ errout:
 }
 
 #ifdef DEBUG
-
-main(int argc, char** argv)
+int main(int argc, char** argv)
 {
-       const char *base;
+       char *base;
        char  buf[256], *cp;
 
        while (1) {
@@ -164,8 +164,8 @@ main(int argc, char** argv)
                        *cp = 0;
                base = base_device(buf);
                printf("%s\t%s\n", buf, base ? base : "NONE");
+               free(base);
        }
        exit(0);
 }
-
 #endif