]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
sysfs: dprintf when we fail to write a sysfs file
authorDan Williams <dan.j.williams@intel.com>
Wed, 24 Sep 2008 12:58:02 +0000 (05:58 -0700)
committerDan Williams <dan.j.williams@intel.com>
Wed, 15 Oct 2008 21:15:51 +0000 (14:15 -0700)
When arrays do not startup correctly it would be nice to know why.  Need
to move the dprintf definition to mdadm.h

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
mdadm.h
mdmon.h
sysfs.c

diff --git a/mdadm.h b/mdadm.h
index 8b6baa6123773a279faf2c900d8a59881d50292a..7a39187e28cacd3b1018f88d3ac454831e805e99 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -844,6 +844,14 @@ static inline int is_subarray(char *vers)
        return (*vers == '/' || *vers == '-');
 }
 
        return (*vers == '/' || *vers == '-');
 }
 
+#ifdef DEBUG
+#define dprintf(fmt, arg...) \
+       fprintf(stderr, fmt, ##arg)
+#else
+#define dprintf(fmt, arg...) \
+        ({ if (0) fprintf(stderr, fmt, ##arg); 0; })
+#endif
+
 #define        LEVEL_MULTIPATH         (-4)
 #define        LEVEL_LINEAR            (-1)
 #define        LEVEL_FAULTY            (-5)
 #define        LEVEL_MULTIPATH         (-4)
 #define        LEVEL_LINEAR            (-1)
 #define        LEVEL_FAULTY            (-5)
diff --git a/mdmon.h b/mdmon.h
index e5b2a727ee233fa5ee6009d9251a92d83b9200df..62f34f7eae2b9706e20ddbcdd5aefaaea626871a 100644 (file)
--- a/mdmon.h
+++ b/mdmon.h
@@ -1,11 +1,3 @@
-#ifdef DEBUG
-#define dprintf(fmt, arg...) \
-       fprintf(stderr, fmt, ##arg)
-#else
-#define dprintf(fmt, arg...) \
-        ({ if (0) fprintf(stderr, fmt, ##arg); 0; })
-#endif
-
 enum array_state { clear, inactive, suspended, readonly, read_auto,
                   clean, active, write_pending, active_idle, bad_word};
 
 enum array_state { clear, inactive, suspended, readonly, read_auto,
                   clean, active, write_pending, active_idle, bad_word};
 
diff --git a/sysfs.c b/sysfs.c
index 727e25085471f59563bfa2210370c78b70a3461d..291a1dc3467b3ea2e165ac85e640db265e60fa74 100644 (file)
--- a/sysfs.c
+++ b/sysfs.c
@@ -389,8 +389,11 @@ int sysfs_set_str(struct mdinfo *sra, struct mdinfo *dev,
                return -1;
        n = write(fd, val, strlen(val));
        close(fd);
                return -1;
        n = write(fd, val, strlen(val));
        close(fd);
-       if (n != strlen(val))
+       if (n != strlen(val)) {
+               dprintf(Name ": failed to write '%s' to '%s' (%s)\n",
+                       val, fname, strerror(errno));
                return -1;
                return -1;
+       }
        return 0;
 }
 
        return 0;
 }