Ondřej Vašík <[EMAIL PROTECTED]> writes:

> -      bool changed = (chmod_succeeded
> -                   && mode_changed (file, old_mode, new_mode));
> +      bool mode_change = mode_changed (file, old_mode, new_mode);
> +      bool changed = (chmod_succeeded && mode change);
> +
> +      if (chmod_succeeded && ((old_mode ^ new_mode) & CHMOD_MODE_BITS))
> +        {
> +
> +          /* Changed to another mode than requested */

This doesn't look right to me.  First, surely there's no need to invoke
mode_changed if chmod_succeeded is false.  Second, ((old_mode ^
new_mode) & CHMOD_MODE_BITS) doesn't tell us whether we changed to
another mode than requested; mode_change tells us that.


> +          struct stat new_stats;
> +          char perms_requested[12];
> +          char perms_actual[12];
> +
> +          if (stat (file, &new_stats) != 0)

Third, this means we've invoked 'stat' twice on the file afterwards,
once here, and once in mode_changed.  We should invoke 'stat' only in
mode_changed.


_______________________________________________
Bug-coreutils mailing list
Bug-coreutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to