2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
6 #include <aros/debug.h>
12 #include "__arosc_privdata.h"
15 /*****************************************************************************
28 Change the user and group ownership of a file.
31 path - the path to file
36 0 on success and -1 on error. If an error occurred, the global
37 variable errno is set.
40 This implementation was done by looking at Olaf 'Olsen' Barthels
51 ******************************************************************************/
53 struct aroscbase
*aroscbase
= __GM_GetBase();
56 struct FileInfoBlock
*fib
= NULL
;
59 /* check for empty path before potential conversion from "." to "" */
60 if (aroscbase
->acb_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
= __arosc_ioerr2errno(IoErr());
79 if (!(lock
= Lock(path
, SHARED_LOCK
)) || !Examine(lock
, fib
))
81 errno
= __arosc_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
= __arosc_ioerr2errno(IoErr());
113 FreeDosObject(DOS_FIB
, fib
);