diff options
author | Artur Paszkiewicz <artur.paszkiewicz@intel.com> | 2016-03-29 15:20:29 +0200 |
---|---|---|
committer | Jes Sorensen <Jes.Sorensen@redhat.com> | 2016-03-30 17:23:52 +0200 |
commit | f96b13022403b593ce05455b2ebc91429f2d6d0c (patch) | |
tree | 7dd0ddae6fb9c0473aa4b3ce5e54f880e2da59d1 /lib.c | |
parent | mdadm:Add '--nodes' option in GROW mode (diff) | |
download | mdadm-f96b13022403b593ce05455b2ebc91429f2d6d0c.tar.xz mdadm-f96b13022403b593ce05455b2ebc91429f2d6d0c.zip |
Introduce stat2kname() and fd2kname()
These are similar to stat2devnm() and fd2devnm() but not limited to md
devices. If the device is a partition they will return its kernel name,
not the whole device's name. For more information see commit:
8d83493 ("Introduce devid2kname - slightly different to devid2devnm.")
Also remove unsued declaration for fmt_devname().
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 15 |
1 files changed, 15 insertions, 0 deletions
@@ -84,6 +84,21 @@ char *devid2kname(int devid) return NULL; } +char *stat2kname(struct stat *st) +{ + if ((S_IFMT & st->st_mode) != S_IFBLK) + return NULL; + return devid2kname(st->st_rdev); +} + +char *fd2kname(int fd) +{ + struct stat stb; + if (fstat(fd, &stb) == 0) + return stat2kname(&stb); + return NULL; +} + char *devid2devnm(int devid) { char path[30]; |