FAT | XFS
getfname()
PROTOTYPE
#include <posix.h>
char *getfname(uint32_t fileno, char *buf, size_t size);
DESCRIPTION
getfname() is a non-standard routine that gets a file’s leaf name. 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 leaf name is copied to this buffer, followed by a terminating null.
If buf equals NULL, size is ignored and getfname() calls malloc() internally to allocate a buffer of suitable size before copying the name to it. This buffer must be freed, by calling free(), once it is no longer needed by the application.
If successful, getfname() returns a pointer to the file’s leaf name, either buf or the buffer allocated by getfname(). 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 file name. |
| ERANGE | buf is not NULL and size is negative or less than the length of the file name, including the terminating ‘\0’. |
EXAMPLE
char *fname;
fname = getfname(fileno, NULL, 0);
if (fname)
puts(fname);
free(fname);