projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gen-uni-tables: Say "gen-uni-tables.c" consistently.
[gnulib.git]
/
lib
/
careadlinkat.c
diff --git
a/lib/careadlinkat.c
b/lib/careadlinkat.c
index
7a7806d
..
e2909c7
100644
(file)
--- a/
lib/careadlinkat.c
+++ b/
lib/careadlinkat.c
@@
-22,10
+22,9
@@
#include "careadlinkat.h"
#include "careadlinkat.h"
-#include "allocator.h"
-
#include <errno.h>
#include <limits.h>
#include <errno.h>
#include <limits.h>
+#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
@@
-38,15
+37,20
@@
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
#endif
# define SSIZE_MAX ((ssize_t) (SIZE_MAX / 2))
#endif
+#include "allocator.h"
+
#if ! HAVE_READLINKAT
#if ! HAVE_READLINKAT
-/*
Ignore FD. 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. */
+/*
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. */
ssize_t
careadlinkatcwd (int fd, char const *filename, char *buffer,
size_t buffer_size)
{
ssize_t
careadlinkatcwd (int fd, char const *filename, char *buffer,
size_t buffer_size)
{
- (void) fd;
+ /* FD must be AT_FDCWD here, otherwise the caller is using this
+ function in contexts for which it was not meant for. */
+ if (fd != AT_FDCWD)
+ abort ();
return readlink (filename, buffer, buffer_size);
}
#endif
return readlink (filename, buffer, buffer_size);
}
#endif
@@
-65,7
+69,10
@@
careadlinkatcwd (int fd, char const *filename, char *buffer,
the returned value if it is nonnull and is not BUFFER. A null
ALLOC stands for the standard allocator.
the returned value if it is nonnull and is not BUFFER. A null
ALLOC stands for the standard allocator.
- The PREADLINKAT function specifies how to read links.
+ The PREADLINKAT function specifies how to read links. It operates
+ like POSIX readlinkat()
+ <http://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html>
+ but can assume that its first argument is the same as FD.
If successful, return the buffer address; otherwise return NULL and
set errno. */
If successful, return the buffer address; otherwise return NULL and
set errno. */