[m-rev.] for review: attempt to preserve file mode when copying

Julien Fischer jfischer at opturion.com
Sun Jan 7 16:24:44 AEDT 2024


On Sun, 7 Jan 2024, Zoltan Somogyi wrote:

> On 2024-01-07 14:27 +11:00 AEDT, "Julien Fischer" <jfischer at opturion.com> wrote:
>>  %-----------------------------------------------------------------------------%
>> +%
>> +% Getting and setting file modes.
>> +%
>
> On my iMac, "man 2 stat" says this about file modes:
>
>     #define S_IFMT 0170000           /* type of file */
>     #define        S_IFIFO  0010000  /* named pipe (fifo) */
>     #define        S_IFCHR  0020000  /* character special */
>     #define        S_IFDIR  0040000  /* directory */
>     #define        S_IFBLK  0060000  /* block special */
>     #define        S_IFREG  0100000  /* regular */
>     #define        S_IFLNK  0120000  /* symbolic link */
>     #define        S_IFSOCK 0140000  /* socket */
>     #define        S_IFWHT  0160000  /* whiteout */
>     #define S_ISUID 0004000  /* set user id on execution */
>     #define S_ISGID 0002000  /* set group id on execution */
>     #define S_ISVTX 0001000  /* save swapped text even after use */
>     #define S_IRUSR 0000400  /* read permission, owner */
>     #define S_IWUSR 0000200  /* write permission, owner */
>     #define S_IXUSR 0000100  /* execute/search permission, owner */
>
> Preserving the S_IFMT part of this by getting it on one file and
> setting it on another would be nonsensical if the set operation
> would modify this part of the mode. This is why the chmod syscall
> does not even attempt to set these bits.
>
> I would therefore prefer to rename file_name to file_permission
> to reflect the semantics of what is left, in all parts of this diff.

You presumably meant file_mode there?

Julien.


More information about the reviews mailing list