6

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".

2
  • I might well be short for "is". Possibly "integer", though. Commented Aug 21, 2015 at 18:22
  • 3
    The earliest I can find these constants in C code is in UNIX 4th edition inode.h. Given that the file name is inode.h, the structure name is inode, and all the structure elements and constants begin with i or I, it's tempting to conclude that I comes from inode. Commented Aug 23, 2015 at 13:29

1 Answer 1

7

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."

1
  • 1
    Thanks, this "SaVed TeXt" meaning seems also documented in the file permissions info page: For regular files on some older systems, save the program’s text image on the swap device so it will load more quickly when run; this is called the "sticky bit". Got any idea about the meaning/origin of the I letter?
    – Lekensteyn
    Commented Aug 22, 2015 at 19:32

You must log in to answer this question.

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