The meaning of the mode mask names from stat(2) and chmod(2)

chmodhistorypermissionsstat

The stat calls have a series of symbolic names for the various bits in
the mode field. From the stat(2) manual page:

The following mask values are defined for the file mode component of
the st_mode field:

    S_ISUID     04000   set-user-ID bit
    S_ISGID     02000   set-group-ID bit (see below)
    S_ISVTX     01000   sticky bit (see below)

    S_IRWXU     00700   owner has read, write, and execute permission
    S_IRUSR     00400   owner has read permission
    S_IWUSR     00200   owner has write permission
    S_IXUSR     00100   owner has execute permission

    S_IRWXG     00070   group has read, write, and execute permission
    S_IRGRP     00040   group has read permission
    S_IWGRP     00020   group has write permission
    S_IXGRP     00010   group has execute permission

    S_IRWXO     00007   others (not in group) have read,  write,  and
                        execute permission
    S_IROTH     00004   others have read permission
    S_IWOTH     00002   others have write permission
    S_IXOTH     00001   others have execute permission

I can see that S_IRWXU is a combination of rwx and u (Read, Write
and eXecute permissions for the User) and that S_IRUSR is combined
from R and usr (Read permission for the USeR). Likewise for Write
and eXecute, and for GRouP and OTHers.

The S part is probably named after the stat function.

But what about the I part, what does it mean? Is it modelled after the
various S_ISDIR ("is a directory") macros?

What is the VTX part from S_ISVTX? I cannot relate this abbreviation
to "sticky bit".

Best Answer

It's history time, kids! Stevens, "APUE", chapter 4, section 10 quotes thusly:

"The S_ISVTX bit has an interesting history ... if it was set ... a copy of the program's text was saved in the swap area ... this caused the program to load into memory faster the next time ... later versions of Unix referred to this as the saved-text bit, hence the constant S_ISVTX."