summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorXiao Ni <xni@redhat.com>2021-10-27 14:23:13 +0200
committerJes Sorensen <jsorensen@fb.com>2021-11-02 17:09:17 +0100
commita35aa68fef246a3eb6bc995cd7af75af420418cc (patch)
tree63b9a2675d4df1f033cde8da25ced2fab509eefe /lib.c
parentFix 2 dc stream buffer (diff)
downloadmdadm-a35aa68fef246a3eb6bc995cd7af75af420418cc.tar.xz
mdadm-a35aa68fef246a3eb6bc995cd7af75af420418cc.zip
mdadm/lib: Define a new helper function is_dev_alived
The function is used to check if one member disk is alive. Signed-off-by: Xiao Ni <xni@redhat.com> Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 76d1fbb9..7e3e3d47 100644
--- a/lib.c
+++ b/lib.c
@@ -27,6 +27,17 @@
#include <ctype.h>
#include <limits.h>
+bool is_dev_alive(char *path)
+{
+ if (!path)
+ return false;
+
+ if (access(path, R_OK) == 0)
+ return true;
+
+ return false;
+}
+
/* This fill contains various 'library' style function. They
* have no dependency on anything outside this file.
*/