summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorArtur Paszkiewicz <artur.paszkiewicz@intel.com>2016-03-29 15:20:29 +0200
committerJes Sorensen <Jes.Sorensen@redhat.com>2016-03-30 17:23:52 +0200
commitf96b13022403b593ce05455b2ebc91429f2d6d0c (patch)
tree7dd0ddae6fb9c0473aa4b3ce5e54f880e2da59d1 /lib.c
parentmdadm:Add '--nodes' option in GROW mode (diff)
downloadmdadm-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.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 6808f62d..621edf3b 100644
--- a/lib.c
+++ b/lib.c
@@ -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];