mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
Use stat (lstat), not safe_stat (safe_lstat).
This commit is contained in:
1 parent
466ecc5db8
commit
99ce9e9832
13 files changed
+40
-58
No files matched your search
+1
-2
@@ -25,7 +25,6 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "safe-lstat.h"
|
||||
#include "error.h"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
@@ -181,7 +180,7 @@ change_file_group (file, group)
|
||||
struct stat file_stats;
|
||||
int errors = 0;
|
||||
|
||||
if (safe_lstat (file, &file_stats))
|
||||
if (lstat (file, &file_stats))
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", file);
|
||||
|
||||
+3
-5
@@ -31,8 +31,6 @@
|
||||
#include "modechange.h"
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "safe-stat.h"
|
||||
#include "safe-lstat.h"
|
||||
#include "error.h"
|
||||
|
||||
void mode_string ();
|
||||
@@ -194,7 +192,7 @@ change_file_mode (file, changes, deref_symlink)
|
||||
unsigned short newmode;
|
||||
int errors = 0;
|
||||
|
||||
if (safe_lstat (file, &file_stats))
|
||||
if (lstat (file, &file_stats))
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", file);
|
||||
@@ -205,8 +203,8 @@ change_file_mode (file, changes, deref_symlink)
|
||||
{
|
||||
if (! deref_symlink)
|
||||
return 0;
|
||||
else
|
||||
if (safe_stat (file, &file_stats))
|
||||
else
|
||||
if (stat (file, &file_stats))
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", file);
|
||||
|
||||
+1
-2
@@ -37,7 +37,6 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "safe-lstat.h"
|
||||
#include "error.h"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
@@ -186,7 +185,7 @@ change_file_owner (file, user, group)
|
||||
gid_t newgroup;
|
||||
int errors = 0;
|
||||
|
||||
if (safe_lstat (file, &file_stats))
|
||||
if (lstat (file, &file_stats))
|
||||
{
|
||||
if (force_silent == 0)
|
||||
error (0, errno, "%s", file);
|
||||
|
||||
+1
-2
@@ -20,7 +20,6 @@
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include "cp.h"
|
||||
#include "safe-stat.h"
|
||||
|
||||
char *hash_insert ();
|
||||
char *hash_insert2 ();
|
||||
@@ -37,7 +36,7 @@ remember_created (path)
|
||||
{
|
||||
struct stat sb;
|
||||
|
||||
if (safe_stat (path, &sb) < 0)
|
||||
if (stat (path, &sb) < 0)
|
||||
{
|
||||
error (0, errno, "%s", path);
|
||||
return 1;
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
#include "cp.h"
|
||||
#include "backupfile.h"
|
||||
#include "version.h"
|
||||
#include "safe-stat.h"
|
||||
#include "safe-lstat.h"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
uid_t geteuid ();
|
||||
@@ -287,9 +285,9 @@ main (argc, argv)
|
||||
of `stat' to call. */
|
||||
|
||||
if (flag_dereference)
|
||||
xstat = safe_stat;
|
||||
xstat = stat;
|
||||
else
|
||||
xstat = safe_lstat;
|
||||
xstat = lstat;
|
||||
|
||||
/* Allocate space for remembering copied and created files. */
|
||||
|
||||
@@ -320,7 +318,7 @@ do_copy (argc, argv)
|
||||
|
||||
dest = argv[argc - 1];
|
||||
|
||||
if (safe_lstat (dest, &sb))
|
||||
if (lstat (dest, &sb))
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
{
|
||||
@@ -337,7 +335,7 @@ do_copy (argc, argv)
|
||||
/* If `dest' is not a symlink to a nonexistent file, use
|
||||
the results of stat instead of lstat, so we can copy files
|
||||
into symlinks to directories. */
|
||||
if (safe_stat (dest, &sbx) == 0)
|
||||
if (stat (dest, &sbx) == 0)
|
||||
sb = sbx;
|
||||
}
|
||||
|
||||
@@ -429,7 +427,7 @@ do_copy (argc, argv)
|
||||
`cp source dest/' to `cp source dest/basename(source)'. */
|
||||
|
||||
if (dest[strlen (dest) - 1] == '/'
|
||||
&& safe_lstat (source, &source_stats) == 0
|
||||
&& lstat (source, &source_stats) == 0
|
||||
&& !S_ISDIR (source_stats.st_mode))
|
||||
{
|
||||
char *source_base;
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#include "fsusage.h"
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "safe-stat.h"
|
||||
#include "error.h"
|
||||
|
||||
char *xmalloc ();
|
||||
@@ -228,7 +227,7 @@ main (argc, argv)
|
||||
stats = (struct stat *)
|
||||
xmalloc ((argc - optind) * sizeof (struct stat));
|
||||
for (i = optind; i < argc; ++i)
|
||||
if (safe_stat (argv[i], &stats[i - optind]))
|
||||
if (stat (argv[i], &stats[i - optind]))
|
||||
{
|
||||
error (0, errno, "%s", argv[i]);
|
||||
exit_status = 1;
|
||||
@@ -271,7 +270,7 @@ print_header ()
|
||||
printf (" Type");
|
||||
else
|
||||
printf (" ");
|
||||
|
||||
|
||||
if (inode_format)
|
||||
printf (" Inodes IUsed IFree %%IUsed");
|
||||
else
|
||||
@@ -341,7 +340,7 @@ show_point (point, statp)
|
||||
{
|
||||
if (me->me_dev == (dev_t) -1)
|
||||
{
|
||||
if (safe_stat (me->me_mountdir, &disk_stats) == 0)
|
||||
if (stat (me->me_mountdir, &disk_stats) == 0)
|
||||
me->me_dev = disk_stats.st_dev;
|
||||
else
|
||||
{
|
||||
|
||||
@@ -47,8 +47,6 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "safe-stat.h"
|
||||
#include "safe-lstat.h"
|
||||
#include "error.h"
|
||||
|
||||
/* Initial number of entries in each hash table entry's table of inodes. */
|
||||
@@ -295,12 +293,12 @@ main (argc, argv)
|
||||
{
|
||||
int c;
|
||||
char *cwd_only[2];
|
||||
|
||||
|
||||
cwd_only[0] = ".";
|
||||
cwd_only[1] = NULL;
|
||||
|
||||
program_name = argv[0];
|
||||
xstat = safe_lstat;
|
||||
xstat = lstat;
|
||||
output_size = getenv ("POSIXLY_CORRECT") ? size_blocks : size_kilobytes;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "abcklsxDLS", long_options, (int *) 0))
|
||||
@@ -344,7 +342,7 @@ main (argc, argv)
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
xstat = safe_stat;
|
||||
xstat = stat;
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
@@ -393,7 +391,7 @@ du_files (files)
|
||||
save_cwd (&cwd);
|
||||
|
||||
/* Remember the inode and device number of the current directory. */
|
||||
if (safe_stat (".", &stat_buf))
|
||||
if (stat (".", &stat_buf))
|
||||
error (1, errno, "current directory");
|
||||
initial_ino = stat_buf.st_ino;
|
||||
initial_dev = stat_buf.st_dev;
|
||||
@@ -425,7 +423,7 @@ du_files (files)
|
||||
count_entry (arg, 1, 0);
|
||||
|
||||
/* chdir if `count_entry' has changed the working directory. */
|
||||
if (safe_stat (".", &stat_buf))
|
||||
if (stat (".", &stat_buf))
|
||||
error (1, errno, ".");
|
||||
if (stat_buf.st_ino != initial_ino || stat_buf.st_dev != initial_dev)
|
||||
{
|
||||
@@ -458,7 +456,7 @@ count_entry (ent, top, last_dev)
|
||||
long size;
|
||||
|
||||
if (((top && opt_dereference_arguments)
|
||||
? safe_stat (ent, &stat_buf)
|
||||
? stat (ent, &stat_buf)
|
||||
: (*xstat) (ent, &stat_buf)) < 0)
|
||||
{
|
||||
error (0, errno, "%s", path->text);
|
||||
@@ -499,8 +497,8 @@ count_entry (ent, top, last_dev)
|
||||
/* If we're dereferencing symlinks and we're about to chdir through
|
||||
a symlink, remember the current directory so we can return to it
|
||||
later. In other cases, chdir ("..") works fine. */
|
||||
through_symlink = (xstat == safe_stat
|
||||
&& safe_lstat (ent, &e_buf) == 0
|
||||
through_symlink = (xstat == stat
|
||||
&& lstat (ent, &e_buf) == 0
|
||||
&& S_ISLNK (e_buf.st_mode));
|
||||
if (through_symlink)
|
||||
save_cwd (&cwd);
|
||||
|
||||
+2
-3
@@ -61,7 +61,6 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "safe-stat.h"
|
||||
#include "modechange.h"
|
||||
#include "makepath.h"
|
||||
#include "error.h"
|
||||
@@ -321,7 +320,7 @@ copy_file (from, to, to_created)
|
||||
struct stat from_stats, to_stats;
|
||||
int target_created = 1;
|
||||
|
||||
if (safe_stat (from, &from_stats))
|
||||
if (stat (from, &from_stats))
|
||||
{
|
||||
error (0, errno, "%s", from);
|
||||
return 1;
|
||||
@@ -331,7 +330,7 @@ copy_file (from, to, to_created)
|
||||
error (0, 0, "`%s' is not a regular file", from);
|
||||
return 1;
|
||||
}
|
||||
if (safe_stat (to, &to_stats) == 0)
|
||||
if (stat (to, &to_stats) == 0)
|
||||
{
|
||||
if (!S_ISREG (to_stats.st_mode))
|
||||
{
|
||||
|
||||
@@ -29,8 +29,6 @@
|
||||
#include "system.h"
|
||||
#include "backupfile.h"
|
||||
#include "version.h"
|
||||
#include "safe-lstat.h"
|
||||
#include "safe-stat.h"
|
||||
#include "error.h"
|
||||
|
||||
int link (); /* Some systems don't declare this anywhere. */
|
||||
@@ -226,7 +224,7 @@ main (argc, argv)
|
||||
`ln source dest/' to `ln source dest/basename(source)'. */
|
||||
|
||||
if (dest[strlen (dest) - 1] == '/'
|
||||
&& safe_lstat (source, &source_stats) == 0
|
||||
&& lstat (source, &source_stats) == 0
|
||||
&& !S_ISDIR (source_stats.st_mode))
|
||||
{
|
||||
PATH_BASENAME_CONCAT (new_dest, dest, source);
|
||||
@@ -274,7 +272,7 @@ do_link (source, dest)
|
||||
{
|
||||
struct stat source_stats;
|
||||
|
||||
if (safe_stat (source, &source_stats) != 0)
|
||||
if (stat (source, &source_stats) != 0)
|
||||
{
|
||||
error (0, errno, "%s", source);
|
||||
return 1;
|
||||
@@ -286,7 +284,7 @@ do_link (source, dest)
|
||||
}
|
||||
}
|
||||
|
||||
if (safe_lstat (dest, &dest_stats) != 0 && errno != ENOENT)
|
||||
if (lstat (dest, &dest_stats) != 0 && errno != ENOENT)
|
||||
{
|
||||
error (0, errno, "%s", dest);
|
||||
return 1;
|
||||
@@ -296,7 +294,7 @@ do_link (source, dest)
|
||||
and the user has not specified --no-dereference), then form the
|
||||
actual destination name by appending basename (source) to the
|
||||
specified destination directory. */
|
||||
lstat_status = safe_lstat (dest, &dest_stats);
|
||||
lstat_status = lstat (dest, &dest_stats);
|
||||
|
||||
if (lstat_status != 0 && errno != ENOENT)
|
||||
{
|
||||
@@ -317,12 +315,12 @@ do_link (source, dest)
|
||||
char *new_dest;
|
||||
PATH_BASENAME_CONCAT (new_dest, dest, source);
|
||||
dest = new_dest;
|
||||
/* Set this to non-zero to force another call to safe_lstat
|
||||
/* Set this to non-zero to force another call to lstat
|
||||
with the new destination. */
|
||||
lstat_status = 1;
|
||||
}
|
||||
|
||||
if (lstat_status == 0 || safe_lstat (dest, &dest_stats) == 0)
|
||||
if (lstat_status == 0 || lstat (dest, &dest_stats) == 0)
|
||||
{
|
||||
if (S_ISDIR (dest_stats.st_mode))
|
||||
{
|
||||
|
||||
@@ -58,8 +58,6 @@
|
||||
#include "obstack.h"
|
||||
#include "ls.h"
|
||||
#include "version.h"
|
||||
#include "safe-stat.h"
|
||||
#include "safe-lstat.h"
|
||||
#include "error.h"
|
||||
|
||||
#define obstack_chunk_alloc xmalloc
|
||||
@@ -1471,14 +1469,14 @@ gobble_file (name, explicit_arg, dirname)
|
||||
|
||||
if (trace_links)
|
||||
{
|
||||
val = safe_stat (path, &files[files_index].stat);
|
||||
val = stat (path, &files[files_index].stat);
|
||||
if (val < 0)
|
||||
/* Perhaps a symbolically-linked to file doesn't exist; stat
|
||||
the link instead. */
|
||||
val = safe_lstat (path, &files[files_index].stat);
|
||||
val = lstat (path, &files[files_index].stat);
|
||||
}
|
||||
else
|
||||
val = safe_lstat (path, &files[files_index].stat);
|
||||
val = lstat (path, &files[files_index].stat);
|
||||
if (val < 0)
|
||||
{
|
||||
error (0, errno, "%s", path);
|
||||
@@ -1501,7 +1499,7 @@ gobble_file (name, explicit_arg, dirname)
|
||||
if (linkpath
|
||||
&& ((explicit_arg && format != long_format)
|
||||
|| indicator_style != none || print_with_color)
|
||||
&& safe_stat (linkpath, &linkstats) == 0)
|
||||
&& stat (linkpath, &linkstats) == 0)
|
||||
{
|
||||
/* Symbolic links to directories that are mentioned on the
|
||||
command line are automatically traced if not being
|
||||
|
||||
@@ -49,7 +49,6 @@
|
||||
#include "system.h"
|
||||
#include "backupfile.h"
|
||||
#include "version.h"
|
||||
#include "safe-lstat.h"
|
||||
#include "error.h"
|
||||
|
||||
#ifndef _POSIX_VERSION
|
||||
@@ -206,7 +205,7 @@ is_real_dir (path)
|
||||
{
|
||||
struct stat stats;
|
||||
|
||||
return safe_lstat (path, &stats) == 0 && S_ISDIR (stats.st_mode);
|
||||
return lstat (path, &stats) == 0 && S_ISDIR (stats.st_mode);
|
||||
}
|
||||
|
||||
/* Move file SOURCE onto DEST. Handles the case when DEST is a directory.
|
||||
@@ -251,13 +250,13 @@ do_move (source, dest)
|
||||
{
|
||||
char *dest_backup = NULL;
|
||||
|
||||
if (safe_lstat (source, &source_stats) != 0)
|
||||
if (lstat (source, &source_stats) != 0)
|
||||
{
|
||||
error (0, errno, "%s", source);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (safe_lstat (dest, &dest_stats) == 0)
|
||||
if (lstat (dest, &dest_stats) == 0)
|
||||
{
|
||||
if (source_stats.st_dev == dest_stats.st_dev
|
||||
&& source_stats.st_ino == dest_stats.st_ino)
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "safe-lstat.h"
|
||||
#include "error.h"
|
||||
|
||||
#ifdef D_INO_IN_DIRENT
|
||||
@@ -199,7 +198,7 @@ rm ()
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (safe_lstat (pathname, &path_stats))
|
||||
if (lstat (pathname, &path_stats))
|
||||
{
|
||||
if (errno == ENOENT && ignore_missing_files)
|
||||
return 0;
|
||||
|
||||
+2
-3
@@ -39,7 +39,6 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "version.h"
|
||||
#include "safe-stat.h"
|
||||
#include "error.h"
|
||||
|
||||
#ifndef STDC_HEADERS
|
||||
@@ -218,7 +217,7 @@ main (argc, argv)
|
||||
|
||||
if (use_ref)
|
||||
{
|
||||
if (safe_stat (ref_file, &ref_stats))
|
||||
if (stat (ref_file, &ref_stats))
|
||||
error (1, errno, "%s", ref_file);
|
||||
date_set++;
|
||||
}
|
||||
@@ -263,7 +262,7 @@ touch (file)
|
||||
struct stat sbuf;
|
||||
int fd;
|
||||
|
||||
if (safe_stat (file, &sbuf))
|
||||
if (stat (file, &sbuf))
|
||||
{
|
||||
if (errno != ENOENT)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user