* bootstrap.conf (gnulib_modules): Add issymlink and issymlinkat.
* src/copy.c: Include issymlink.h.
(copy_reg): Use issymlink instead of readlinkat.
* src/rmdir.c: Include issymlink.h.
(main): Use issymlink instead of readlink.
* src/tail.c: Include issymlink.h.
(recheck, any_symlinks): Use issymlink instead of readlink.
* src/test.c: Include issymlink.h.
(unary_operator): Use issymlink instead of readlink.
isapipe
isatty
isblank
+ issymlink
+ issymlinkat
largefile
lchmod
ldtoastr
#include "hashcode-file.h"
#include "ignore-value.h"
#include "ioblksize.h"
+#include "issymlink.h"
#include "quote.h"
#include "renameatu.h"
#include "root-uid.h"
/* When trying to copy through a dangling destination symlink,
the above open fails with EEXIST. If that happens, and
- readlinkat shows that it is a symlink, then we
+ issymlinkat shows that it is a symlink, then we
have a problem: trying to resolve this dangling symlink to
a directory/destination-entry pair is fundamentally racy,
so punt. If x->open_dangling_dest_symlink is set (cp sets
only when copying, i.e., not in move_mode. */
if (dest_desc < 0 && dest_errno == EEXIST && ! x->move_mode)
{
- char dummy[1];
- if (0 <= readlinkat (dst_dirfd, dst_relname, dummy, sizeof dummy))
+ if (issymlinkat (dst_dirfd, dst_relname) == 1)
{
if (x->open_dangling_dest_symlink)
{
#include <sys/types.h>
#include "system.h"
+#include "issymlink.h"
#include "prog-fprintf.h"
/* The official name of this program (e.g., no 'g' prefix). */
/* Ensure the last component was a symlink. */
char *dir_arg = xstrdup (dir);
strip_trailing_slashes (dir);
- char linkbuf[1];
- if (0 <= readlink (dir, linkbuf, 1))
+ if (issymlink (dir) == 1)
{
error (0, 0,
_("failed to remove %s:"
#include "fcntl--.h"
#include "iopoll.h"
#include "isapipe.h"
+#include "issymlink.h"
#include "posixver.h"
#include "quote.h"
#include "stat-size.h"
affirm (valid_file_spec (f));
- char linkbuf[1];
- if (! disable_inotify && 0 <= readlink (f->name, linkbuf, 1))
+ if (! disable_inotify && issymlink (f->name) == 1)
{
/* Diagnose the edge case where a regular file is changed
to a symlink. We avoid inotify with symlinks since
static bool
any_symlinks (const struct File_spec *f, int n_files)
{
- char linkbuf[1];
for (int i = 0; i < n_files; i++)
- if (0 <= readlink (f[i].name, linkbuf, 1))
+ if (issymlink (f[i].name) == 1)
return true;
return false;
}
#include "system.h"
#include "assure.h"
#include "c-ctype.h"
+#include "issymlink.h"
#include "quote.h"
#include "stat-time.h"
#include "strnumcmp.h"
case 'h': /* File is a symbolic link? */
unary_advance ();
- char linkbuf[1];
- return 0 <= readlink (argv[pos - 1], linkbuf, 1);
+ return issymlink (argv[pos - 1]) == 1;
case 'u': /* File is setuid? */
unary_advance ();