@@ -35,6 +35,8 @@ enum ChmodError {
3535 PreserveRoot ( PathBuf ) ,
3636 #[ error( "{}" , translate!( "chmod-error-permission-denied" , "file" => _0. quote( ) ) ) ]
3737 PermissionDenied ( PathBuf ) ,
38+ #[ error( "{}" , translate!( "chmod-error-read-only-file-system" , "file" => _0. quote( ) ) ) ]
39+ ReadOnlyFileSystem ( PathBuf ) ,
3840 #[ error( "{}" , translate!( "chmod-error-new-permissions" , "file" => _0. maybe_quote( ) , "actual" => _1. clone( ) , "expected" => _2. clone( ) ) ) ]
3941 NewPermissions ( PathBuf , String , String ) ,
4042}
@@ -609,14 +611,20 @@ impl Chmoder {
609611 let ( new_mode, _) = self . calculate_new_mode ( current_mode, file_path. is_dir ( ) ) ?;
610612
611613 // Use safe traversal to change the mode
612- if let Err ( _e ) = dir_fd. chmod_at ( entry_name, new_mode, symlink_behavior) {
614+ if let Err ( e ) = dir_fd. chmod_at ( entry_name, new_mode, symlink_behavior) {
613615 if self . verbose {
614616 println ! (
615617 "failed to change mode of {} to {new_mode:o}" ,
616618 file_path. quote( ) ,
617619 ) ;
618620 }
619- return Err ( ChmodError :: PermissionDenied ( file_path. into ( ) ) . into ( ) ) ;
621+ let err = if e. kind ( ) == std:: io:: ErrorKind :: ReadOnlyFilesystem {
622+ ChmodError :: ReadOnlyFileSystem ( file_path. into ( ) )
623+ } else {
624+ ChmodError :: PermissionDenied ( file_path. into ( ) )
625+ } ;
626+
627+ return Err ( err. into ( ) ) ;
620628 }
621629
622630 // Report the change using the helper method
0 commit comments