comparison lib/areadlink.c @ 17324:b1b7de2c4a71

careadlinkat: stop exporting careadlinkatcwd Only Emacs used it directly, and Emacs no longer needs it. * NEWS: Document this simplification. * lib/areadlink.c (careadlinkatcwd): Move here from careadlinkat.c, and make it static. Include <stdlib.h>, for abort, and unistd.h, for readlink. * lib/careadlinkat.c (careadlinkatcwd): Move to areadlink.c. Don't include stdlib.h; no longer needed. * lib/careadlinkat.h (careadlinkatcwd): Remove decl. * lib/relocwrapper.c: Adjust comment to match new dependencies. * modules/areadlink (Depends-on): Add readlink. (Maintainer): Add self. * modules/careadlinkat (Depends-on): Remove readlink.
author Paul Eggert <eggert@cs.ucla.edu>
date Fri, 08 Feb 2013 15:12:36 -0800
parents e542fd46ad6f
children 344018b6e5d7
comparison
equal deleted inserted replaced
17323:6c93ff5bc2bd 17324:b1b7de2c4a71
24 /* Specification. */ 24 /* Specification. */
25 #include "areadlink.h" 25 #include "areadlink.h"
26 26
27 #include "careadlinkat.h" 27 #include "careadlinkat.h"
28 28
29 #include <stdlib.h>
30 #include <unistd.h>
31
32 /* Get the symbolic link value of FILENAME and put it into BUFFER, with
33 size BUFFER_SIZE. This function acts like readlink but has
34 readlinkat's signature. */
35 static ssize_t
36 careadlinkatcwd (int fd, char const *filename, char *buffer,
37 size_t buffer_size)
38 {
39 /* FD must be AT_FDCWD here, otherwise the caller is using this
40 function in contexts it was not meant for. */
41 if (fd != AT_FDCWD)
42 abort ();
43 return readlink (filename, buffer, buffer_size);
44 }
45
29 /* Call readlink to get the symbolic link value of FILENAME. 46 /* Call readlink to get the symbolic link value of FILENAME.
30 Return a pointer to that NUL-terminated string in malloc'd storage. 47 Return a pointer to that NUL-terminated string in malloc'd storage.
31 If readlink fails, return NULL and set errno. 48 If readlink fails, return NULL and set errno.
32 If allocation fails, or if the link value is longer than SIZE_MAX :-), 49 If allocation fails, or if the link value is longer than SIZE_MAX :-),
33 return NULL and set errno to ENOMEM. */ 50 return NULL and set errno to ENOMEM. */