2 Copyright © 1995-2009, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
12 #include "__arosc_privdata.h"
16 /*****************************************************************************
29 Change the user and group ownership of a file.
32 path - the path to file
37 0 on success and -1 on error. If an error occurred, the global
38 variable errno is set.
41 This implementation was done by looking at Olaf 'Olsen' Barthels
52 ******************************************************************************/
56 struct FileInfoBlock
*fib
= NULL
;
59 /* check for empty path before potential conversion from "." to "" */
60 if (__doupath
&& path
&& *path
== '\0')
66 path
= __path_u2a(path
);
70 /* should some id not be changed */
71 if (owner
== -1 || group
== -1)
73 if (!(fib
= AllocDosObject(DOS_FIB
, NULL
)))
75 errno
= IoErr2errno(IoErr());
79 if (!(lock
= Lock(path
, SHARED_LOCK
)) || !Examine(lock
, fib
))
81 errno
= IoErr2errno(IoErr());
85 /* set to previous id */
87 owner
= fib
->fib_OwnerUID
;
90 group
= fib
->fib_OwnerGID
;
92 if (owner
== fib
->fib_OwnerUID
&& group
== fib
->fib_OwnerGID
)
96 if (owner
> 65535 || group
> 65535)
102 if (changed
&& !SetOwner(path
, owner
<< 16 | group
))
104 errno
= IoErr2errno(IoErr());
113 FreeDosObject(DOS_FIB
, fib
);