diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2017-01-31 21:01:14 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2017-01-31 21:01:14 -0500 |
commit | 538e4b2054e9802ebc860943e0a43baf2ee46741 (patch) | |
tree | 70993ee6abf4d7cc0642bf55a5ea1d7edda4ce05 /util.h | |
parent | ab64ca5d29147385b099edb8874d6e101b48c1e0 (diff) | |
download | bfs-538e4b2054e9802ebc860943e0a43baf2ee46741.tar.xz |
Don't trust st_size when reading symlinks
Linux /proc, for example, reports a st_size of 0 for everything. It's
nice to be able to use -lname on them anyway.
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -49,6 +49,19 @@ int xreaddir(DIR *dir, struct dirent **de); /** + * readlinkat() wrapper that dynamically allocates the result. + * + * @param fd + * The base directory descriptor. + * @param path + * The path to the link, relative to fd. + * @param size + * An estimate for the size of the link name (pass 0 if unknown). + * @return The target of the link, allocated with malloc(), or NULL on failure. + */ +char *xreadlinkat(int fd, const char *path, size_t size); + +/** * Check if a file descriptor is open. */ bool isopen(int fd); |