1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-07-25 10:16:53 +02:00

(mode_changed, change_file_mode):

There's no need to invoke both lstat and stat here, so call just
one of the two functions.
This commit is contained in:
Jim Meyering
2001-05-12 08:04:44 +00:00
parent 1af93e3d71
commit ba94ef5b1b
+4 -23
View File
@@ -100,23 +100,13 @@ mode_changed (const char *file, mode_t old_mode)
{
struct stat new_stats;
if (lstat (file, &new_stats))
if (stat (file, &new_stats))
{
if (force_silent == 0)
error (0, errno, _("getting new attributes of %s"), quote (file));
return 0;
}
#ifdef S_ISLNK
if (S_ISLNK (new_stats.st_mode)
&& stat (file, &new_stats))
{
if (force_silent == 0)
error (0, errno, _("getting new attributes of %s"), quote (file));
return 0;
}
#endif
return old_mode != new_stats.st_mode;
}
@@ -165,25 +155,16 @@ change_file_mode (const char *file, const struct mode_change *changes,
int fail;
int saved_errno;
if (lstat (file, &file_stats))
if (deref_symlink ? stat (file, &file_stats) : lstat (file, &file_stats))
{
if (force_silent == 0)
error (0, errno, _("getting attributes of %s"), quote (file));
return 1;
}
#ifdef S_ISLNK
if (S_ISLNK (file_stats.st_mode))
{
if (! deref_symlink)
return 0;
else
if (stat (file, &file_stats))
{
if (force_silent == 0)
error (0, errno, _("getting attributes of %s"), quote (file));
return 1;
}
}
return 0;
#endif
newmode = mode_adjust (file_stats.st_mode, changes);