]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Improve ftw handling.
authorNeil Brown <neilb@suse.de>
Mon, 26 Jun 2006 05:10:48 +0000 (15:10 +1000)
committerNeil Brown <neilb@suse.de>
Mon, 26 Jun 2006 05:10:48 +0000 (15:10 +1000)
If not 'ftw' is available, still allow openning of devices by dev number.

More recent version of uclibc support nftw, so add support to check
for that.

ChangeLog
mdadm.h
util.c

index 75e53bbbcfb91f4fe0e4f26a61f297a41b6dfdde..3ff36ce8c0825b0209bba74353bc1e16805a565a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,8 @@ Changes Prior to this release
        information in superblocks.
     -   Don't claim newly added spares are InSync!! (don't know why that
        code was ever in there)
+    -   Work better when no 'ftw' is available, and check to see
+       if current uclibc provides ftw.
 
 Changes Prior to 2.5.1 release
     -   Various fixes for gcc warnings
diff --git a/mdadm.h b/mdadm.h
index 9113560a76ba6cfc8624a26362cabaf7a68ab35f..6afdf863e2ff53e9a6802c6187fb75dfefd82314 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -343,16 +343,32 @@ extern struct supertype *guess_super(int fd);
 struct stat64;
 #endif
 
+#define HAVE_NFTW  we assume
+#define HAVE_FTW
+
 #ifdef UCLIBC
-  struct FTW {};
+# include <features.h>
+# ifndef  __UCLIBC_HAS_FTW__
+#  undef HAVE_FTW
+#  undef HAVE_NFTW
+# endif
+#endif
+
+#ifdef __dietlibc__
+# undef HAVE_NFTW
+#endif
+
+#ifndef HAVE_NFTW
 # define FTW_PHYS 1
-#else
-# include <ftw.h>
-# ifdef __dietlibc__
-#  define FTW_PHYS 1
+# ifndef HAVE_FTW
+  struct FTW {};
 # endif
 #endif
 
+#ifdef HAVE_FTW
+# include <ftw.h>
+#endif
+
 extern int add_dev(const char *name, const struct stat *stb, int flag, struct FTW *s);
 
 
diff --git a/util.c b/util.c
index 2cb6dd316f8e173ab913e54a778e96110a450524..08319cb6bccadb86b9c68884a066f1e96b8ef2f0 100644 (file)
--- a/util.c
+++ b/util.c
@@ -354,32 +354,6 @@ struct devmap {
 } *devlist = NULL;
 int devlist_ready = 0;
 
-#ifdef UCLIBC
-int add_dev(const char *name, const struct stat *stb, int flag, struct FTW *s)
-{
-       return 0;
-}
-char *map_dev(int major, int minor, int create)
-{
-#if 0
-       fprintf(stderr, "Warning - fail to map %d,%d to a device name\n",
-               major, minor);
-#endif
-       return NULL;
-}
-#else
-
-#ifdef __dietlibc__
-int add_dev_1(const char *name, const struct stat *stb, int flag)
-{
-       return add_dev(name, stb, flag, NULL);
-}
-int nftw(const char *path, int (*han)(const char *name, const struct stat *stb, int flag, struct FTW *s), int nopenfd, int flags)
-{
-       return ftw(path, add_dev_1, nopenfd);
-}
-#endif
-
 int add_dev(const char *name, const struct stat *stb, int flag, struct FTW *s)
 {
        struct stat st;
@@ -404,6 +378,28 @@ int add_dev(const char *name, const struct stat *stb, int flag, struct FTW *s)
        return 0;
 }
 
+#ifndef HAVE_NFTW
+#ifdef HAVE_FTW
+int add_dev_1(const char *name, const struct stat *stb, int flag)
+{
+       return add_dev(name, stb, flag, NULL);
+}
+int nftw(const char *path, int (*han)(const char *name, const struct stat *stb, int flag, struct FTW *s), int nopenfd, int flags)
+{
+       return ftw(path, add_dev_1, nopenfd);
+}
+#else
+int add_dev(const char *name, const struct stat *stb, int flag, struct FTW *s)
+{
+       return 0;
+}
+int nftw(const char *path, int (*han)(const char *name, const struct stat *stb, int flag, struct FTW *s), int nopenfd, int flags)
+{
+       return 0;
+}
+#endif /* HAVE_FTW */
+#endif /* HAVE_NFTW */
+
 /*
  * Find a block device with the right major/minor number.
  * If we find multiple names, choose the shortest.
@@ -464,8 +460,6 @@ char *map_dev(int major, int minor, int create)
        return nonstd ? nonstd : std;
 }
 
-#endif
-
 unsigned long calc_csum(void *super, int bytes)
 {
        unsigned long long newcsum = 0;