[Toybox] [PATCH] portability: Add some FreeBSD cases
Ed Maste
emaste at freefall.freebsd.org
Fri Jul 29 09:45:58 PDT 2022
From: Ed Maste <emaste at FreeBSD.org>
Use existing Apple or OpenBSD implementations.
---
lib/portability.c | 12 ++++++------
lib/portability.h | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/portability.c b/lib/portability.c
index 58ef384b..6fac2c36 100644
--- a/lib/portability.c
+++ b/lib/portability.c
@@ -192,7 +192,7 @@ struct mtab_list *xgetmountlist(char *path)
#endif
-#if defined(__APPLE__) || defined(__OpenBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/event.h>
@@ -336,7 +336,7 @@ ssize_t xattr_fset(int fd, const char* name,
return fsetxattr(fd, name, value, size, 0, flags);
}
-#elif !defined(__OpenBSD__)
+#elif !defined(__FreeBSD__) && !defined(__OpenBSD__)
ssize_t xattr_get(const char *path, const char *name, void *value, size_t size)
{
@@ -537,7 +537,7 @@ int dev_minor(int dev)
return ((dev&0xfff00000)>>12)|(dev&0xff);
#elif defined(__APPLE__)
return dev&0xffffff;
-#elif defined(__OpenBSD__)
+#elif defined(__FreeBSD__) || defined(__OpenBSD__)
return minor(dev);
#else
#error
@@ -550,7 +550,7 @@ int dev_major(int dev)
return (dev&0xfff00)>>8;
#elif defined(__APPLE__)
return (dev>>24)&0xff;
-#elif defined(__OpenBSD__)
+#elif defined(__FreeBSD__) || defined(__OpenBSD__)
return major(dev);
#else
#error
@@ -563,7 +563,7 @@ int dev_makedev(int major, int minor)
return (minor&0xff)|((major&0xfff)<<8)|((minor&0xfff00)<<12);
#elif defined(__APPLE__)
return (minor&0xffffff)|((major&0xff)<<24);
-#elif defined(__OpenBSD__)
+#elif defined(__FreeBSD__) || defined(__OpenBSD__)
return makedev(major, minor);
#else
#error
@@ -572,7 +572,7 @@ int dev_makedev(int major, int minor)
char *fs_type_name(struct statfs *statfs)
{
-#if defined(__APPLE__) || defined(__OpenBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
// macOS has an `f_type` field, but assigns values dynamically as filesystems
// are registered. They do give you the name directly though, so use that.
return statfs->f_fstypename;
diff --git a/lib/portability.h b/lib/portability.h
index f565191d..4de547a3 100644
--- a/lib/portability.h
+++ b/lib/portability.h
@@ -229,7 +229,7 @@ int posix_fallocate(int, off_t, off_t);
#include <xlocale.h>
#endif
-#if defined(__APPLE__) || defined(__OpenBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
static inline long statfs_bsize(struct statfs *sf) { return sf->f_iosize; }
static inline long statfs_frsize(struct statfs *sf) { return sf->f_bsize; }
#else
--
2.35.1
More information about the Toybox
mailing list