| 152 | CH describes what (if anything) has happened. */ |
| 153 | |
| 154 | static void |
| 155 | describe_change (char const *file, struct change_status const *ch) |
| 156 | { |
| 157 | char perms[12]; /* "-rwxrwxrwx" ls-style modes. */ |
| 158 | char old_perms[12]; |
| 159 | char const *fmt; |
| 160 | char const *quoted_file = quoteaf (file); |
| 161 | |
| 162 | switch (ch->status) |
| 163 | { |
| 164 | case CH_NOT_APPLIED: |
| 165 | printf (_("neither symbolic link %s nor referent has been changed\n"), |
| 166 | quoted_file); |
| 167 | return; |
| 168 | |
| 169 | case CH_NO_STAT: |
| 170 | printf (_("%s could not be accessed\n"), quoted_file); |
| 171 | return; |
| 172 | |
| 173 | case CH_FAILED: case CH_NO_CHANGE_REQUESTED: case CH_SUCCEEDED: |
| 174 | break; |
| 175 | } |
| 176 | |
| 177 | unsigned long int |
| 178 | old_m = ch->old_mode & CHMOD_MODE_BITS, |
| 179 | m = ch->new_mode & CHMOD_MODE_BITS; |
| 180 | |
| 181 | strmode (ch->new_mode, perms); |
| 182 | perms[10] = '\0'; /* Remove trailing space. */ |
| 183 | |
| 184 | strmode (ch->old_mode, old_perms); |
| 185 | old_perms[10] = '\0'; /* Remove trailing space. */ |
| 186 | |
| 187 | switch (ch->status) |
| 188 | { |
| 189 | case CH_SUCCEEDED: |
| 190 | fmt = _("mode of %s changed from %04lo (%s) to %04lo (%s)\n"); |
| 191 | break; |
| 192 | case CH_FAILED: |
| 193 | fmt = _("failed to change mode of %s from %04lo (%s) to %04lo (%s)\n"); |
| 194 | break; |
| 195 | case CH_NO_CHANGE_REQUESTED: |
| 196 | fmt = _("mode of %s retained as %04lo (%s)\n"); |
| 197 | printf (fmt, quoted_file, m, &perms[1]); |
| 198 | return; |
| 199 | case CH_NO_STAT: case CH_NOT_APPLIED: default: |
| 200 | affirm (false); |
| 201 | } |
| 202 | printf (fmt, quoted_file, old_m, &old_perms[1], m, &perms[1]); |
| 203 | } |
| 204 | |
| 205 | /* Change the mode of FILE. |
| 206 | Return true if successful. This function is called |