Next: SYSTEM CALL: msgget() Up: Internal and User Data Previous: Kernel msqid_ds structure

#### Kernel `ipc_perm` structure

The kernel stores permission information for IPC objects in a structure of type `ipc_perm`. For example, in the internal structure for a message queue described above, the `msg_perm` member is of this type. It is declared for us in `linux/ipc.h` as follows:

    struct ipc_perm
     {
       key_t  key;
       ushort uid;   /* owner euid and egid */
       ushort gid;
       ushort cuid;  /* creator euid and egid */
       ushort cgid;
       ushort mode;  /* access modes see mode flags below */
       ushort seq;   /* slot usage sequence number */
     };

All of the above are fairly self-explanatory. Stored along with the IPC key of the object is information about both the creator and owner of the object (they may be different). The octal access modes are also stored here, as an `unsigned short`. Finally, the slot usage sequence number is stored at the end. Each time an IPC object is closed via a system call (destroyed), this value gets incremented by the maximum number of IPC objects that can reside in a system. Will you have to concern yourself with this value? No.

NOTE:There is an excellent discussion on this topic, and the security reasons as to its existence and behavior, in Richard Stevens' UNIX Network Programming book, pp. 125.