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>
This commit is contained in:
parent
1c66260df6
commit
a35aa68fef
11
lib.c
11
lib.c
|
@ -27,6 +27,17 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <limits.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
|
/* This fill contains various 'library' style function. They
|
||||||
* have no dependency on anything outside this file.
|
* have no dependency on anything outside this file.
|
||||||
*/
|
*/
|
||||||
|
|
2
mdadm.h
2
mdadm.h
|
@ -45,6 +45,7 @@ extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <stdbool.h>
|
||||||
/* Newer glibc requires sys/sysmacros.h directly for makedev() */
|
/* Newer glibc requires sys/sysmacros.h directly for makedev() */
|
||||||
#include <sys/sysmacros.h>
|
#include <sys/sysmacros.h>
|
||||||
#ifdef __dietlibc__
|
#ifdef __dietlibc__
|
||||||
|
@ -1499,6 +1500,7 @@ extern int check_partitions(int fd, char *dname,
|
||||||
extern int fstat_is_blkdev(int fd, char *devname, dev_t *rdev);
|
extern int fstat_is_blkdev(int fd, char *devname, dev_t *rdev);
|
||||||
extern int stat_is_blkdev(char *devname, dev_t *rdev);
|
extern int stat_is_blkdev(char *devname, dev_t *rdev);
|
||||||
|
|
||||||
|
extern bool is_dev_alive(char *path);
|
||||||
extern int get_mdp_major(void);
|
extern int get_mdp_major(void);
|
||||||
extern int get_maj_min(char *dev, int *major, int *minor);
|
extern int get_maj_min(char *dev, int *major, int *minor);
|
||||||
extern int dev_open(char *dev, int flags);
|
extern int dev_open(char *dev, int flags);
|
||||||
|
|
Loading…
Reference in New Issue