system_setumask(3f) - [M_system:FILE_SYSTEM] set the file mode
creation umask
(LICENSE:PD)
integer function system_setumask(new_umask) result (old_umask)
integer,intent(in) :: new_umask
integer(kind=c_int) :: umask_c
The system_umask(3f) function sets the file mode creation mask
of the process to cmask and return the previous value of the
mask. Only the file permission bits of cmask (see <sys/stat.h>)
are used; the meaning of the other bits is implementation-defined.
The file mode creation mask of the process is used to turn off
permission bits in the mode argument supplied during calls to
the following functions:
* open(), openat(), creat(), mkdir(), mkdirat(), mkfifo(),
and mkfifoat()
* mknod(), mknodat()
* mq_open()
* sem_open()
Bit positions that are set in cmask are cleared in the mode of
the created file.
The file permission bits in the value returned by umask() shall be
the previous value of the file mode creation mask. The state of any
other bits in that value is unspecified, except that a subsequent
call to umask() with the returned value as cmask shall leave the
state of the mask the same as its state before the first call,
including any unspecified use of those bits.
No errors are defined.
Sample program
program demo_setumask
use M_system, only : system_getumask, system_setumask
integer :: newmask
integer :: i
integer :: old_umask
write(*,101)(system_getumask(),i=1,4)
101 format(1x,i0,1x,"O'",o4.4,"'",1x,'Z"',z0,"'",1x,"B'",b12.12,"'")
newmask=63
old_umask=system_setumask(newmask)
write(*,*)'NEW'
write(*,101)(system_getumask(),i=1,4)
end program demo_setumask
Expected output
18 O'022' Z"12' B'000010010"
NEW
63 O'077' Z"3F' B'000111111"
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | umask_value |
integer function system_setumask(umask_value) result (old_umask)
integer,intent(in) :: umask_value
integer(kind=c_int) :: umask_c
umask_c=umask_value
old_umask=system_umask(umask_c) ! set current umask
end function system_setumask