| author | |
| committer | |
| log | 44422886561f5c0029f3d61898609220bd35deea |
| tree | 7cd6dadebd1c3a5f881dae35d655644c55eeb4ee |
| parent | 4ceefca14be313e91a248fdc532e37edf4a02a51 |
2 files changed, 9 insertions(+), 3 deletions(-)
lib/std/Build/Watch.zig+5-2| ... | @@ -516,7 +516,7 @@ const Os = switch (builtin.os.tag) { | ... | @@ -516,7 +516,7 @@ const Os = switch (builtin.os.tag) { |
| 516 | pub fn init() !Watch { | 516 | pub fn init() !Watch { |
| 517 | switch (builtin.os.tag) { | 517 | switch (builtin.os.tag) { |
| 518 | .linux => { | 518 | .linux => { |
| 519 | const fan_fd = try std.posix.fanotify_init(.{ | 519 | const fan_fd = std.posix.fanotify_init(.{ |
| 520 | .CLASS = .NOTIF, | 520 | .CLASS = .NOTIF, |
| 521 | .CLOEXEC = true, | 521 | .CLOEXEC = true, |
| 522 | .NONBLOCK = true, | 522 | .NONBLOCK = true, |
| ... | @@ -524,7 +524,10 @@ pub fn init() !Watch { | ... | @@ -524,7 +524,10 @@ pub fn init() !Watch { |
| 524 | .REPORT_DIR_FID = true, | 524 | .REPORT_DIR_FID = true, |
| 525 | .REPORT_FID = true, | 525 | .REPORT_FID = true, |
| 526 | .REPORT_TARGET_FID = true, | 526 | .REPORT_TARGET_FID = true, |
| 527 | }, 0); | 527 | }, 0) catch |err| switch (err) { |
| 528 | error.UnsupportedFlags => fatal("fanotify_init failed due to old kernel; requires 5.17+", .{}), | ||
| 529 | else => |e| return e, | ||
| 530 | }; | ||
| 528 | return .{ | 531 | return .{ |
| 529 | .dir_table = .{}, | 532 | .dir_table = .{}, |
| 530 | .os = switch (builtin.os.tag) { | 533 | .os = switch (builtin.os.tag) { |
lib/std/posix.zig+4-1| ... | @@ -4544,13 +4544,16 @@ pub const FanotifyInitError = error{ | ... | @@ -4544,13 +4544,16 @@ pub const FanotifyInitError = error{ |
| 4544 | SystemFdQuotaExceeded, | 4544 | SystemFdQuotaExceeded, |
| 4545 | SystemResources, | 4545 | SystemResources, |
| 4546 | PermissionDenied, | 4546 | PermissionDenied, |
| 4547 | /// The kernel does not recognize the flags passed, likely because it is an | ||
| 4548 | /// older version. | ||
| 4549 | UnsupportedFlags, | ||
| 4547 | } || UnexpectedError; | 4550 | } || UnexpectedError; |
| 4548 | 4551 | ||
| 4549 | pub fn fanotify_init(flags: std.os.linux.fanotify.InitFlags, event_f_flags: u32) FanotifyInitError!i32 { | 4552 | pub fn fanotify_init(flags: std.os.linux.fanotify.InitFlags, event_f_flags: u32) FanotifyInitError!i32 { |
| 4550 | const rc = system.fanotify_init(flags, event_f_flags); | 4553 | const rc = system.fanotify_init(flags, event_f_flags); |
| 4551 | switch (errno(rc)) { | 4554 | switch (errno(rc)) { |
| 4552 | .SUCCESS => return @intCast(rc), | 4555 | .SUCCESS => return @intCast(rc), |
| 4553 | .INVAL => unreachable, | 4556 | .INVAL => return error.UnsupportedFlags, |
| 4554 | .MFILE => return error.ProcessFdQuotaExceeded, | 4557 | .MFILE => return error.ProcessFdQuotaExceeded, |
| 4555 | .NFILE => return error.SystemFdQuotaExceeded, | 4558 | .NFILE => return error.SystemFdQuotaExceeded, |
| 4556 | .NOMEM => return error.SystemResources, | 4559 | .NOMEM => return error.SystemResources, |