Bug 11486

Summary: chmod -c reports all files as having mode changed
Product: Busybox Reporter: John Ata <john.ata>
Component: Standard ComplianceAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.29.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:
Attachments: When comparing modes for detecting change, filter the file type

Description John Ata 2018-11-02 19:21:32 UTC
Created attachment 7856 [details]
When comparing modes for detecting change, filter the file type

The "-c" option is only supposed to report changed modes.  However, if a numeric mode is supplied (e.g. 0644), it will always report the result as a mode change even if the mode was not requested to change.  This is because the mode field returned from the stat call is being directly compared with the requested mode.  However, stat (2) will place both the file type and mode in the st_mode field so the values will never compare leading chmod to treat it as a change.  A fix is to compare the st_mode field anded with 0x07777 thus allowing identical modes to be identified.