1

(This is on MacOS Monterey)

When performing a backup using rsync --delete .... to a USB stick, I noticed that there was a file which rsync could not delete, with error message Operation not permitted. I could verify this when I did manually a rm -f ... of this file. Checking the permissions of the file using stat, I see

16777231 936844 -rwxrwxrwx 1 ronaldfischer staff 0 692785057 "Mar 28 09:40:06 2023" "Sep 28 14:41:38 2020" "Sep 28 14:41:38 2020" "Nov 11 10:54:25 2022" 131072 1353216 0x2 /Volumes/SANKESU/gitwrk/vp5-e/.git/modules/repository/objects/pack/pack-f9012a97f8775c87b9d24fc0b4c276b883a6eb6a.pack

and checking the permissions on the directory which holds this file, I see

16777231 1125079 drwxrwxrwx 1 ronaldfischer staff 0 131072 "Nov 11 10:54:10 2022" "Apr 11 15:44:46 2023" "Apr 11 15:44:46 2023" "Nov 11 10:54:11 2022" 131072 256 0 /Volumes/SANKESU/gitwrk/vp5-e/.git/modules/repository/objects/pack

It does not look like a permission problem. What could be the reason?

BTW, from the time stamp given in the stat command, I can conclude that both directory and file had been created by a rsync running on Windows/Cygwin, but I don't see how this would explain the error message.

Other files in the backup of my repo are deleted without problems by rsync. Problems seem to occur only in entries which are located below .git/objects. I am aware that when doing the backup, there is no real need to backup the directory .git as well (except that when doing it, I can cd into the backup of my repository and perform git commands), but still I would like to know the reason for this problem.

2
  • Was the file in use, by any chance?
    – Allan
    Commented May 31, 2023 at 12:56
  • @Allan : No, unless rsync has used it by itself, which is not likely. I also did not have a Finder window open on this directory. Commented Jun 1, 2023 at 12:57

1 Answer 1

1

The file, pack-f9012a97f8775c87b9d24fc0b4c276b883a6eb6a.pack, has the user immutable flag set. The field before the path/filename from the output of stat contains the file_flag (lock) which is 0x2 (user immutable flag).

2
  • Any idea how to remove this flag? On MacOS I don't have chattr. Commented Jun 1, 2023 at 13:32
  • Ah, I found a way: I located the file using Finder, did a context-click on the file name, and selected "Get Info". Then a dialogue with information on this file appeared, and there was a checkmark on "Locked". I removed the checkmark, and now the file is unlocked. If you know of a less complicated way, please add it to your answer, as this would make it even more useful. Commented Jun 1, 2023 at 13:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .