build runner: don't pass a dirfd + null to fanotify_mark

Otherwise it reports EBADF.
This commit is contained in:
Andrew Kelley
2024-07-09 23:34:08 -07:00
parent 7bccef3e4e
commit 2ebf021061
2 changed files with 6 additions and 2 deletions

View File

@@ -419,7 +419,7 @@ pub fn main() !void {
std.posix.fanotify_mark(w.fan_fd, .{
.ADD = true,
.ONLYDIR = true,
}, Watch.fan_mask, path.root_dir.handle.fd, path.subPathOpt()) catch |err| {
}, Watch.fan_mask, path.root_dir.handle.fd, path.subPathOrDot()) catch |err| {
fatal("unable to watch {}: {s}", .{ path, @errorName(err) });
};
@@ -471,7 +471,7 @@ pub fn main() !void {
try std.posix.fanotify_mark(w.fan_fd, .{
.REMOVE = true,
.ONLYDIR = true,
}, Watch.fan_mask, path.root_dir.handle.fd, path.subPathOpt());
}, Watch.fan_mask, path.root_dir.handle.fd, path.subPathOrDot());
w.dir_table.swapRemoveAt(i);
w.handle_table.swapRemoveAt(i);

View File

@@ -173,6 +173,10 @@ pub fn subPathOpt(self: Path) ?[]const u8 {
return if (self.sub_path.len == 0) null else self.sub_path;
}
pub fn subPathOrDot(self: Path) []const u8 {
return if (self.sub_path.len == 0) "." else self.sub_path;
}
/// Useful to make `Path` a key in `std.ArrayHashMap`.
pub const TableAdapter = struct {
pub const Hash = std.hash.Wyhash;