UMASK(2)

πŸ’… UMASK(2) β€” the manual page, but make it make sense

okay bestie, gather round, because we're talking about umask(2) β€” the system call version, not the shell builtin, and yes they're different, stay with me 🫢


✨ NAME ✨

umask β€” set file creation mode mask

πŸ“š LIBRARY πŸ“š

Standard C Library (libc, -lc)

🌸 SYNOPSIS 🌸

#include <sys/stat.h>

mode_t
umask(mode_t numask);

πŸ’– DESCRIPTION πŸ’–

so the umask() routine sets your process's file mode creation mask to numask, and then β€” plot twist β€” it returns the previous value of the mask. like it's handing you the receipt for the old one. iconic behavior honestly.

here's the tea: the 9 low-order access permission bits of numask are used by system calls β€” including open(2), mkdir(2), and mkfifo(2) β€” to turn off corresponding bits requested in file mode. (see chmod(2), she's the one who explains all that.) this clearing is literally the whole point: it lets each user restrict the default access to their files. your files, your rules, periodt πŸ”₯

the default mask value is S_IWGRP|S_IWOTH (022, write access for the owner only). and because generational trauma is real, child processes inherit the mask of the calling process. it's giving family business πŸ’€

πŸŽ€ RETURN VALUES πŸŽ€

the previous value of the file mode mask gets returned by the call. that's it, that's the whole return. she's simple, she's reliable, we love her ✨

πŸ™ˆ ERRORS πŸ™ˆ

not a single one, bestie. the umask() system call is always successful. no errno drama, no failure arc, no nothing. she simply does not miss πŸ’…

πŸ‘€ SEE ALSO πŸ‘€

⭐ STANDARDS ⭐

the umask() system call is expected to conform to ISO/IEC 9945-1:1990 ("POSIX.1"). certified, stamped, official πŸ…

πŸ¦‹ HISTORY πŸ¦‹

the umask() function appeared in Version 7 AT&T UNIX. an absolute elder. a legend. we stan a vintage queen πŸ‘‘


okay that's the whole page!! thank you for coming to my TED talk, go forth and mask responsibly πŸ“πŸ’œ

this page came from the Debian crew, dated June 4, 1993, and it's the UMASK(2) page in the System Calls Manual β€” mwah, bye bestie!! πŸ’–βœ¨

πŸ“¦ where this page comes from