FAT | XFS
getpath()
PROTOTYPE
#include <posix.h>
char *getpath(uint32_t fileno, char *buf, size_t size);
DESCRIPTION
getpath() is a non-standard routine that gets a file’s absolute pathname. fileno is a File System User ID (FSUID) returned by fid2fileno() or getfileno(). If buf is not NULL, size is the number of bytes in the buffer it points to. The pathname is copied to this buffer, followed by a terminating null.
If buf equals NULL, size is ignored and getpath() calls malloc() to allocate a buffer of suitable size before copying the pathname to it. This buffer must be freed, by calling free(), once it is no longer needed by the application.
If successful, getpath() returns a pointer to the file’s pathname, either buf or a buffer allocated by getpath(). Otherwise, it sets errno and returns NULL.
ERROR CODES
| ENOENT | No file can be found that has fileno as its FSUID. |
| EINVAL | size is 0 and buf is not NULL or fileno is greater than 0x0FFFFFFF. |
| ENOMEM | Unable to allocate memory buffer for path name. |
| ERANGE | buf is not NULL and size is negative or less than the length of the path name, including the terminating ‘\0’. |
EXAMPLE
fname = getpath(fileno, NULL, 0);
fn = open(fname, O_RDONLY);
if (fn == -1)
perror("open() failed");
free(fname);