authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2022-07-31 02:41:32-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-07-31 13:00:16-07:00
log1a1b7a3afdd3edac9e8e351ce7e21c91404f8307
tree5d6132c8a0fcacf702bf3804755e49349bbd4d91
parent075f93fa108030fb0dd12faa6e389ace302cfb4c

Linux: Add IN_MASK_CREATE and corresponding error handling in inotify_add_watch

From https://man7.org/linux/man-pages/man7/inotify.7.html > **IN_MASK_CREATE** (since Linux 4.18) > > Watch pathname only if it does not already have a watch associated with it; the error EEXIST results if pathname is already being watched.

2 files changed, 3 insertions(+), 0 deletions(-)

lib/std/os.zig+2
...@@ -4244,6 +4244,7 @@ pub const INotifyAddWatchError = error{...@@ -4244,6 +4244,7 @@ pub const INotifyAddWatchError = error{
4244 SystemResources,4244 SystemResources,
4245 UserResourceLimitReached,4245 UserResourceLimitReached,
4246 NotDir,4246 NotDir,
4247 WatchAlreadyExists,
4247} || UnexpectedError;4248} || UnexpectedError;
42484249
4249/// add a watch to an initialized inotify instance4250/// add a watch to an initialized inotify instance
...@@ -4266,6 +4267,7 @@ pub fn inotify_add_watchZ(inotify_fd: i32, pathname: [*:0]const u8, mask: u32) I...@@ -4266,6 +4267,7 @@ pub fn inotify_add_watchZ(inotify_fd: i32, pathname: [*:0]const u8, mask: u32) I
4266 .NOMEM => return error.SystemResources,4267 .NOMEM => return error.SystemResources,
4267 .NOSPC => return error.UserResourceLimitReached,4268 .NOSPC => return error.UserResourceLimitReached,
4268 .NOTDIR => return error.NotDir,4269 .NOTDIR => return error.NotDir,
4270 .EXIST => return error.WatchAlreadyExists,
4269 else => |err| return unexpectedErrno(err),4271 else => |err| return unexpectedErrno(err),
4270 }4272 }
4271}4273}
lib/std/os/linux.zig+1
...@@ -2976,6 +2976,7 @@ pub const IN = struct {...@@ -2976,6 +2976,7 @@ pub const IN = struct {
2976 pub const ONLYDIR = 0x01000000;2976 pub const ONLYDIR = 0x01000000;
2977 pub const DONT_FOLLOW = 0x02000000;2977 pub const DONT_FOLLOW = 0x02000000;
2978 pub const EXCL_UNLINK = 0x04000000;2978 pub const EXCL_UNLINK = 0x04000000;
2979 pub const MASK_CREATE = 0x10000000;
2979 pub const MASK_ADD = 0x20000000;2980 pub const MASK_ADD = 0x20000000;
29802981
2981 pub const ISDIR = 0x40000000;2982 pub const ISDIR = 0x40000000;