/* Ensure the last component was a symlink. */
char *dir_arg = xstrdup (dir);
strip_trailing_slashes (dir);
- ret = lstat (dir, &st);
- if (ret == 0 && S_ISLNK (st.st_mode))
+ char linkbuf[1];
+ if (0 <= readlink (dir, linkbuf, 1))
{
error (0, 0,
_("failed to remove %s:"
then mark the file as not tailable. */
f->tailable = !(reopen_inaccessible_files && fd < 0);
- if (! disable_inotify && ! lstat (f->name, &new_stats)
- && S_ISLNK (new_stats.st_mode))
+ char linkbuf[1];
+ if (! disable_inotify && 0 <= readlink (f->name, linkbuf, 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)
{
- struct stat st;
+ char linkbuf[1];
for (int i = 0; i < n_files; i++)
- if (lstat (f[i].name, &st) == 0 && S_ISLNK (st.st_mode))
+ if (0 <= readlink (f[i].name, linkbuf, 1))
return true;
return false;
}
case 'h': /* File is a symbolic link? */
unary_advance ();
- return (lstat (argv[pos - 1], &stat_buf) == 0
- && S_ISLNK (stat_buf.st_mode));
+ char linkbuf[1];
+ return 0 <= readlink (argv[pos - 1], linkbuf, 1);
case 'u': /* File is setuid? */
unary_advance ();