next up previous contents index
Next: Chmod Up: Functions and procedures Previous: CFSetOSpeed

Chown

   

Declaration:

Function Chown (Path : Pathstr;NewUid,NewGid : Longint) : Boolean;

Description:

Chown sets the User ID and Group ID of the file in Path to NewUid, NewGid.

The function returns True if the call was succesfull, False if the call failed.

Errors:

Errors are returned in LinuxError.

sys_eperm
The effective UID doesn't match the ownership of the file, and is not zero. Owner or group were not specified correctly.
sys_eaccess
One of the directories in Path has no search (=execute) permission.
sys_enoent
A directory entry in Path does not exist or is a symbolic link pointing to a non-existent directory.
sys_enotdir
A directory entry in OldPath or NewPath is nor a directory.
sys_enomem
Insufficient kernel memory.
sys_erofs
The file is on a read-only filesystem.
sys_eloop
Path has a reference to a circular symbolic link, i.e. a symbolic link, whose expansion points to itself.

See also:

Chmod, Access, Chown (()2)

Example
Program Example24;

{ Program to demonstrate the Chown function. }

Uses linux;

Var UID,GID : Longint;
    F : Text;
    
begin
  
  Writeln ('This will only work if you are root.');
  Write ('Enter a UID : ');readln(UID);
  Write ('Enter a GID : ');readln(GID);
  Assign (f,'test.txt');
  Rewrite (f);
  Writeln (f,'The owner of this file should become : ');
  Writeln (f,'UID : ',UID);
  Writeln (f,'GID : ',GID);
  Close (F);
  if not Chown ('test.txt',UID,GID) then
    if LinuxError=Sys_EPERM then
      Writeln ('You are not root !')
    else
      Writeln ('Chmod failed with exit code : ',LinuxError)
  else
    Writeln ('Changed owner successfully !');
end.



Michael Van Canneyt
Thu Sep 10 13:59:33 CEST 1998