2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
5 POSIX.1-2008 function readlink().
8 #include <aros/debug.h>
10 #include <proto/dos.h>
14 #include "__posixc_intbase.h"
17 /*****************************************************************************
30 Places the contents of a symbolic link in a buffer of given size. No NUL
31 char is appended to the buffer.
34 path - the path to the symbolic link
35 buf - pointer to the buffer where to store the symbolic link content
36 bufsize - the size of the buffer in bytes
39 The call returns the count of characters placed in the buffer if it
40 succeeds, or a -1 if an error occurs, placing the error code in the
41 global variable errno.
44 struct PosixCIntBase
*PosixCBase
=
45 (struct PosixCIntBase
*)__aros_getbase_PosixCBase();
47 struct DevProc
*dvp
= NULL
;
49 struct Process
*me
= (struct Process
*)FindTask(NULL
);
51 /* check for empty path before potential conversion from "." to "" */
52 if (PosixCBase
->doupath
&& path
&& *path
== '\0')
58 path
= __path_u2a(path
);
62 dvp
= GetDeviceProc(path
, NULL
);
64 res
= ReadLink(dvp
->dvp_Port
, dvp
->dvp_Lock
, path
, buf
, bufsize
);
70 error
= me
->pr_Result2
= 0;
76 errno
= __stdc_ioerr2errno(error
);