authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-09 23:34:08-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-07-12 00:14:08-07:00
log2ebf021061b8789226fa8bafe36f7827925d7022
treed6b928d9c8a88267d7e5d2a020ae58be14a2af3b
parent7bccef3e4e4d48c2e1d34ec28754d8c33902f2bb

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

Otherwise it reports EBADF.

2 files changed, 6 insertions(+), 2 deletions(-)

lib/compiler/build_runner.zig+2-2
...@@ -419,7 +419,7 @@ pub fn main() !void {...@@ -419,7 +419,7 @@ pub fn main() !void {
419 std.posix.fanotify_mark(w.fan_fd, .{419 std.posix.fanotify_mark(w.fan_fd, .{
420 .ADD = true,420 .ADD = true,
421 .ONLYDIR = true,421 .ONLYDIR = true,
422 }, Watch.fan_mask, path.root_dir.handle.fd, path.subPathOpt()) catch |err| {422 }, Watch.fan_mask, path.root_dir.handle.fd, path.subPathOrDot()) catch |err| {
423 fatal("unable to watch {}: {s}", .{ path, @errorName(err) });423 fatal("unable to watch {}: {s}", .{ path, @errorName(err) });
424 };424 };
425425
...@@ -471,7 +471,7 @@ pub fn main() !void {...@@ -471,7 +471,7 @@ pub fn main() !void {
471 try std.posix.fanotify_mark(w.fan_fd, .{471 try std.posix.fanotify_mark(w.fan_fd, .{
472 .REMOVE = true,472 .REMOVE = true,
473 .ONLYDIR = true,473 .ONLYDIR = true,
474 }, Watch.fan_mask, path.root_dir.handle.fd, path.subPathOpt());474 }, Watch.fan_mask, path.root_dir.handle.fd, path.subPathOrDot());
475475
476 w.dir_table.swapRemoveAt(i);476 w.dir_table.swapRemoveAt(i);
477 w.handle_table.swapRemoveAt(i);477 w.handle_table.swapRemoveAt(i);
lib/std/Build/Cache/Path.zig+4
...@@ -173,6 +173,10 @@ pub fn subPathOpt(self: Path) ?[]const u8 {...@@ -173,6 +173,10 @@ pub fn subPathOpt(self: Path) ?[]const u8 {
173 return if (self.sub_path.len == 0) null else self.sub_path;173 return if (self.sub_path.len == 0) null else self.sub_path;
174}174}
175175
176pub fn subPathOrDot(self: Path) []const u8 {
177 return if (self.sub_path.len == 0) "." else self.sub_path;
178}
179
176/// Useful to make `Path` a key in `std.ArrayHashMap`.180/// Useful to make `Path` a key in `std.ArrayHashMap`.
177pub const TableAdapter = struct {181pub const TableAdapter = struct {
178 pub const Hash = std.hash.Wyhash;182 pub const Hash = std.hash.Wyhash;