diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-07-14 03:06:20 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-07-15 01:45:26 -0400 |
| commit | 6096dc5f94bf69cb73b0fc89d36bf125f7ff6467 (patch) | |
| tree | 9fd47a9ae9ea9f73f9ca2b24867cdf6fc0450ec2 /std/os.zig | |
| parent | 7d9ee5d6d53011e9edc7ca10b76d64af807a833f (diff) | |
| download | zig-6096dc5f94bf69cb73b0fc89d36bf125f7ff6467.tar.gz zig-6096dc5f94bf69cb73b0fc89d36bf125f7ff6467.zip | |
move some of the installation from cmake to zig build
This moves the installation of shipped source files from large
CMakeLists.txt lists to zig build recursive directory installation.
On my computer a cmake `make install` takes 2.4 seconds even when it has
to do nothing, and prints a lot of unnecessary lines to stdout that say
"up-to-date: [some file it is installing]".
After this commit, the default output of `make` is down to 1
second, and it does not print any junk to stdout. Further, a `make
install` is no longer required and `make` is sufficient.
This closes #2874.
It also closes #2585. `make` now always invokes `zig build` for
installing files and libuserland.a, and zig's own caching system makes
that go fast.
Diffstat (limited to 'std/os.zig')
| -rw-r--r-- | std/os.zig | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/std/os.zig b/std/os.zig index 1971b51df4..190f02101e 100644 --- a/std/os.zig +++ b/std/os.zig @@ -2546,6 +2546,45 @@ pub fn sigaction(sig: u6, act: *const Sigaction, oact: ?*Sigaction) void { } } +pub const FutimensError = error{ + /// times is NULL, or both tv_nsec values are UTIME_NOW, and either: + /// * the effective user ID of the caller does not match the owner + /// of the file, the caller does not have write access to the + /// file, and the caller is not privileged (Linux: does not have + /// either the CAP_FOWNER or the CAP_DAC_OVERRIDE capability); + /// or, + /// * the file is marked immutable (see chattr(1)). + AccessDenied, + + /// The caller attempted to change one or both timestamps to a value + /// other than the current time, or to change one of the timestamps + /// to the current time while leaving the other timestamp unchanged, + /// (i.e., times is not NULL, neither tv_nsec field is UTIME_NOW, + /// and neither tv_nsec field is UTIME_OMIT) and either: + /// * the caller's effective user ID does not match the owner of + /// file, and the caller is not privileged (Linux: does not have + /// the CAP_FOWNER capability); or, + /// * the file is marked append-only or immutable (see chattr(1)). + PermissionDenied, + + ReadOnlyFileSystem, + + Unexpected, +}; + +pub fn futimens(fd: fd_t, times: *const [2]timespec) FutimensError!void { + switch (errno(system.futimens(fd, times))) { + 0 => return, + EACCES => return error.AccessDenied, + EPERM => return error.PermissionDenied, + EBADF => unreachable, // always a race condition + EFAULT => unreachable, + EINVAL => unreachable, + EROFS => return error.ReadOnlyFileSystem, + else => |err| return unexpectedErrno(err), + } +} + test "" { _ = @import("os/darwin.zig"); _ = @import("os/freebsd.zig"); |
