Defined applyUmask.

geesefs-0-30-9
Aaron Jacobs 2015-03-16 13:00:01 +11:00
parent 2d607d4b3d
commit 84fe345196
1 changed files with 9 additions and 1 deletions

View File

@ -71,7 +71,15 @@ func currentGid() uint32 {
}
// Transform the supplied mode by the current umask.
func applyUmask(m os.FileMode) os.FileMode
func applyUmask(m os.FileMode) os.FileMode {
// HACK(jacobsa): Use umask(2) to change and restore the umask in order to
// figure out what the mask is. See the listing in `man getumask`.
umask := syscall.Umask(0)
syscall.Umask(umask)
// Apply it.
return m &^ os.FileMode(umask)
}
////////////////////////////////////////////////////////////////////////
// Boilerplate