|
|
| version 1.1.1.2, 2012/05/29 09:29:43 | version 1.1.1.3, 2021/03/17 13:38:46 |
|---|---|
| Line 1 | Line 1 |
| /* areadlink.c -- readlink wrapper to return the link name in malloc'd storage | /* areadlink.c -- readlink wrapper to return the link name in malloc'd storage |
| Unlike xreadlink and xreadlink_with_size, don't ever call exit. | Unlike xreadlink and xreadlink_with_size, don't ever call exit. |
| Copyright (C) 2001, 2003-2007, 2009-2011 Free Software Foundation, Inc. | Copyright (C) 2001, 2003-2007, 2009-2019 Free Software Foundation, Inc. |
| This program is free software: you can redistribute it and/or modify | 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 | it under the terms of the GNU General Public License as published by |
| Line 14 | Line 14 |
| GNU General Public License for more details. | GNU General Public License for more details. |
| You should have received a copy of the GNU General Public License | You should have received a copy of the GNU General Public License |
| along with this program. If not, see <http://www.gnu.org/licenses/>. */ | along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| /* Written by Jim Meyering <jim@meyering.net> | /* Written by Jim Meyering <jim@meyering.net> |
| and Bruno Haible <bruno@clisp.org>. */ | and Bruno Haible <bruno@clisp.org>. */ |
| Line 25 | Line 25 |
| #include "areadlink.h" | #include "areadlink.h" |
| #include "careadlinkat.h" | #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. | /* Call readlink to get the symbolic link value of FILENAME. |
| Return a pointer to that NUL-terminated string in malloc'd storage. | Return a pointer to that NUL-terminated string in malloc'd storage. |