diff options
Diffstat (limited to 'lib/areadlink.c')
-rw-r--r-- | lib/areadlink.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/areadlink.c b/lib/areadlink.c index fe65cc67..b4b856c5 100644 --- a/lib/areadlink.c +++ b/lib/areadlink.c @@ -1,7 +1,7 @@ /* areadlink.c -- readlink wrapper to return the link name in malloc'd storage Unlike xreadlink and xreadlink_with_size, don't ever call exit. - Copyright (C) 2001, 2003-2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 2001, 2003-2007, 2009-2014 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,6 +26,23 @@ #include "careadlinkat.h" +#include <stdlib.h> +#include <unistd.h> + +/* Get the symbolic link value of FILENAME and put it into BUFFER, with + size BUFFER_SIZE. This function acts like readlink but has + readlinkat's signature. */ +static ssize_t +careadlinkatcwd (int fd, char const *filename, char *buffer, + size_t buffer_size) +{ + /* FD must be AT_FDCWD here, otherwise the caller is using this + function in contexts it was not meant for. */ + if (fd != AT_FDCWD) + abort (); + return readlink (filename, buffer, buffer_size); +} + /* Call readlink to get the symbolic link value of FILENAME. Return a pointer to that NUL-terminated string in malloc'd storage. If readlink fails, return NULL and set errno. |