Mercurial > hg
diff rust/chg/src/procutil.rs @ 44683:065048e66f32
rust-chg: send client side umask to server
This is equivalent to forwardumask() of hgclient.c.
Differential Revision: https://phab.mercurial-scm.org/D8382
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 04 Oct 2018 22:44:37 +0900 |
parents | ce088b38f92b |
children | 426294d06ddc |
line wrap: on
line diff
--- a/rust/chg/src/procutil.rs Sun Oct 07 16:14:21 2018 +0900 +++ b/rust/chg/src/procutil.rs Thu Oct 04 22:44:37 2018 +0900 @@ -25,6 +25,19 @@ unsafe { libc::geteuid() } } +/// Returns the umask of the current process. +/// +/// # Safety +/// +/// This is unsafe because the umask value is temporarily changed, and +/// the change can be observed from the other threads. Don't call this in +/// multi-threaded context. +pub unsafe fn get_umask() -> u32 { + let mask = libc::umask(0); + libc::umask(mask); + mask +} + /// Changes the given fd to blocking mode. pub fn set_blocking_fd(fd: RawFd) -> io::Result<()> { let flags = unsafe { libc::fcntl(fd, libc::F_GETFL) };