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{
42444244 SystemResources,
42454245 UserResourceLimitReached,
42464246 NotDir,
4247 WatchAlreadyExists,
42474248} || UnexpectedError;
42484249
42494250/// 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
42664267 .NOMEM => return error.SystemResources,
42674268 .NOSPC => return error.UserResourceLimitReached,
42684269 .NOTDIR => return error.NotDir,
4270 .EXIST => return error.WatchAlreadyExists,
42694271 else => |err| return unexpectedErrno(err),
42704272 }
42714273}
lib/std/os/linux.zig+1
......@@ -2976,6 +2976,7 @@ pub const IN = struct {
29762976 pub const ONLYDIR = 0x01000000;
29772977 pub const DONT_FOLLOW = 0x02000000;
29782978 pub const EXCL_UNLINK = 0x04000000;
2979 pub const MASK_CREATE = 0x10000000;
29792980 pub const MASK_ADD = 0x20000000;
29802981
29812982 pub const ISDIR = 0x40000000;