Merge pull request #293 from kkebo/fix-freebsd

Fix FreeBSD build
This commit is contained in:
Guillaume Lessard authored and GitHub committed 2026-02-06 15:04:21 -08:00
commit 71db29e931
2 files changed
+12 -12

No files matched your search

+2 -1
View File
@@ -693,8 +693,9 @@ internal var _S_IFLNK: mode_t { S_IFLNK }
internal var _S_IFSOCK: mode_t { S_IFSOCK }
#if SYSTEM_PACKAGE_DARWIN || os(FreeBSD)
// `S_IFWHT` is `Int32` on FreeBSD.
@_alwaysEmitIntoClient
internal var _S_IFWHT: mode_t { S_IFWHT }
internal var _S_IFWHT: mode_t { .init(S_IFWHT) }
#endif
// MARK: - stat/chflags File Flags
+10 -11
View File
@@ -118,7 +118,7 @@ private struct StatTests {
#expect(targetStat.type == .regular)
#expect(symlinkStat.type == .symbolicLink)
#expect(symlinkStat.size < targetStat.size)
#expect(symlinkStat.sizeAllocated < targetStat.sizeAllocated)
#expect(symlinkStat.sizeAllocated <= targetStat.sizeAllocated)
// Set each .st_atim back to its original value for comparison
@@ -368,14 +368,11 @@ private struct StatTests {
]
#elseif os(FreeBSD)
let userSettableFlags: FileFlags = [
.noDump, .userImmutable, .userAppend,
.opaque, .tracked, .hidden,
.userNoUnlink,
.offline,
.readOnly,
.reparse,
.sparse,
.system
.noDump, .hidden, .offline,
.readOnly, .sparse, .system
// The following flags throw EPERM on ZFS.
// .userImmutable, .userAppend, .opaque,
// .userNoUnlink, .reparse,
]
#else // os(OpenBSD)
let userSettableFlags: FileFlags = [
@@ -384,13 +381,15 @@ private struct StatTests {
#endif
flags.insert(userSettableFlags)
try #require(fchflags(fd.rawValue, flags.rawValue) == 0, "\(Errno.current)")
// On FreeBSD, the second argument of `fchflags` requires `UInt` instead of`UInt32`.
try #require(fchflags(fd.rawValue, .init(flags.rawValue)) == 0, "\(Errno.current)")
stat = try fd.stat()
#expect(stat.flags == flags)
flags.remove(userSettableFlags)
try #require(fchflags(fd.rawValue, flags.rawValue) == 0, "\(Errno.current)")
// On FreeBSD, the second argument of `fchflags` requires `UInt` instead of`UInt32`.
try #require(fchflags(fd.rawValue, .init(flags.rawValue)) == 0, "\(Errno.current)")
stat = try fd.stat()
#expect(stat.flags == flags)