git: c6890399fc00 - main - makefs: Fix issues building as a cross-tool on non-FreeBSD
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 18 Aug 2022 01:46:46 UTC
The branch main has been updated by jrtc27:
URL: https://cgit.FreeBSD.org/src/commit/?id=c6890399fc00bd628066b94c4add3f7e34815b11
commit c6890399fc00bd628066b94c4add3f7e34815b11
Author: Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2022-08-18 01:46:28 +0000
Commit: Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2022-08-18 01:46:28 +0000
makefs: Fix issues building as a cross-tool on non-FreeBSD
This adds missing includes, uses the standard dirent.h rather than the
BSD-specific sys/dirent.h subset (which works on macOS but not Linux)
and works around Linux's lack of st_birthtim.
This allows usr.sbin/makefs to be added to LOCAL_XTOOL_DIRS again on
macOS and Linux so that disk images can be cross-built.
Reviewed by: markj
Fixes: 240afd8c1fcc ("makefs: Add ZFS support")
Differential Revision: https://reviews.freebsd.org/D36135
---
usr.sbin/makefs/zfs/dsl.c | 1 +
usr.sbin/makefs/zfs/fs.c | 8 +++++++-
usr.sbin/makefs/zfs/objset.c | 1 +
usr.sbin/makefs/zfs/vdev.c | 1 +
usr.sbin/makefs/zfs/zap.c | 1 +
usr.sbin/makefs/zfs/zfs.h | 1 +
6 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/usr.sbin/makefs/zfs/dsl.c b/usr.sbin/makefs/zfs/dsl.c
index 223f5941ef69..28560dd4a429 100644
--- a/usr.sbin/makefs/zfs/dsl.c
+++ b/usr.sbin/makefs/zfs/dsl.c
@@ -29,6 +29,7 @@
*/
#include <assert.h>
+#include <stdlib.h>
#include <string.h>
#include <util.h>
diff --git a/usr.sbin/makefs/zfs/fs.c b/usr.sbin/makefs/zfs/fs.c
index bf8d5483d610..ecade55db52c 100644
--- a/usr.sbin/makefs/zfs/fs.c
+++ b/usr.sbin/makefs/zfs/fs.c
@@ -28,11 +28,12 @@
* SUCH DAMAGE.
*/
-#include <sys/dirent.h>
#include <sys/stat.h>
#include <assert.h>
+#include <dirent.h>
#include <fcntl.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -456,7 +457,12 @@ fs_populate_sattrs(struct fs_populate_arg *arg, const fsnode *cur,
fs_populate_time(fs, attrbuf, &sb->st_mtim, ZPL_ATIME, &bonussz);
fs_populate_time(fs, attrbuf, &sb->st_ctim, ZPL_CTIME, &bonussz);
fs_populate_time(fs, attrbuf, &sb->st_mtim, ZPL_MTIME, &bonussz);
+#ifdef __linux__
+ /* Linux has no st_birthtim; approximate with st_ctim */
+ fs_populate_time(fs, attrbuf, &sb->st_ctim, ZPL_CRTIME, &bonussz);
+#else
fs_populate_time(fs, attrbuf, &sb->st_birthtim, ZPL_CRTIME, &bonussz);
+#endif
fs_populate_varszattr(fs, attrbuf, aces, sizeof(aces), 0,
ZPL_DACL_ACES, &bonussz);
diff --git a/usr.sbin/makefs/zfs/objset.c b/usr.sbin/makefs/zfs/objset.c
index edd0b66d6147..c22a4f6415fe 100644
--- a/usr.sbin/makefs/zfs/objset.c
+++ b/usr.sbin/makefs/zfs/objset.c
@@ -29,6 +29,7 @@
*/
#include <assert.h>
+#include <stdlib.h>
#include <string.h>
#include <util.h>
diff --git a/usr.sbin/makefs/zfs/vdev.c b/usr.sbin/makefs/zfs/vdev.c
index 1709a828b7c5..63a6e7289957 100644
--- a/usr.sbin/makefs/zfs/vdev.c
+++ b/usr.sbin/makefs/zfs/vdev.c
@@ -30,6 +30,7 @@
#include <assert.h>
#include <fcntl.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
diff --git a/usr.sbin/makefs/zfs/zap.c b/usr.sbin/makefs/zfs/zap.c
index 398c0fbf029c..33ca2650cf3d 100644
--- a/usr.sbin/makefs/zfs/zap.c
+++ b/usr.sbin/makefs/zfs/zap.c
@@ -33,6 +33,7 @@
#include <assert.h>
#include <stddef.h>
+#include <stdlib.h>
#include <string.h>
#include <util.h>
diff --git a/usr.sbin/makefs/zfs/zfs.h b/usr.sbin/makefs/zfs/zfs.h
index 6b743b40b3ab..1e37bc54395a 100644
--- a/usr.sbin/makefs/zfs/zfs.h
+++ b/usr.sbin/makefs/zfs/zfs.h
@@ -32,6 +32,7 @@
#define _MAKEFS_ZFS_H_
#include <sys/types.h>
+#include <sys/endian.h>
#include <sys/queue.h>
#include <bitstring.h>