summaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2018-11-02 22:44:48 -0400
committerTavian Barnes <tavianator@tavianator.com>2018-11-02 22:44:48 -0400
commit5cbf11475b9135c30f1da76268dbb3b27df55cd6 (patch)
tree0632af2aede29fa97f7a394b9352a50964054424 /util.c
parent2d0b6b31caff9405ae551079ca67e9f1061f9afc (diff)
downloadbfs-5cbf11475b9135c30f1da76268dbb3b27df55cd6.tar.xz
util: Provide fallback implementations of makedev()/major()/minor()
Diffstat (limited to 'util.c')
-rw-r--r--util.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/util.c b/util.c
index 7f68e7c..74f9d55 100644
--- a/util.c
+++ b/util.c
@@ -32,6 +32,8 @@
#if __GLIBC__ || BFS_HAS_INCLUDE(<sys/sysmacros.h>)
# include <sys/sysmacros.h>
+#elif BFS_HAS_INCLUDE(<sys/mkdev.h>)
+# include <sys/mkdev.h>
#endif
int xreaddir(DIR *dir, struct dirent **de) {
@@ -446,13 +448,25 @@ int ynprompt() {
}
dev_t bfs_makedev(int ma, int mi) {
+#ifdef makedev
return makedev(ma, mi);
+#else
+ return (ma << 8) | mi;
+#endif
}
int bfs_major(dev_t dev) {
+#ifdef major
return major(dev);
+#else
+ return dev >> 8;
+#endif
}
int bfs_minor(dev_t dev) {
+#ifdef minor
return minor(dev);
+#else
+ return dev & 0xFF;
+#endif
}