system_chown(3f) - [M_system:FILE_SYSTEM] change file owner and group (LICENSE:PD)
Synopsis
Description
Options
Return Value
Examples
elemental impure logical function system_chown(path,owner,group)
character(len=*),intent(in) :: path integer,intent(in) :: owner integer,intent(in) :: group
The chown(3f) function changes owner and group of a fileThe path argument points to a pathname naming a file. The user ID and group ID of the named file shall be set to the numeric values contained in owner and group, respectively.
Only processes with an effective user ID equal to the user ID of the file or with appropriate privileges may change the ownership of a file.
path a character string representing a file pathname. Trailing spaces are ignored. owner UID of owner that ownership is to be changed to group GID of group that ownership is to be changed to
The system_chown(3f) function should return zero 0 if successful. Otherwise, these functions shall return 1 and set errno to indicate the error. If 1 is returned, no changes are made in the user ID and group ID of the file.
Sample program:
program demo_system_chown use M_system, only : system_chown use M_system, only : system_getuid use M_system, only : system_getgid use M_system, only : system_perror implicit none integer :: i character(len=80),parameter :: names(*)=[& & character(len=80) :: & & myfile1,& & /usr/local] do i=1,size(names) if(.not. system_chown(& & trim(names(i)), & & system_getuid(), & & system_getgid()) & )then call system_perror(*demo_system_chown* //trim(names(i))) endif enddo end program demo_system_chown
Nemo Release 3.1 | system_chown (3m_system) | March 07, 2025 |