Each shared memory segment has a data structure associated with it, parts of which may be altered by and parts of which determine the actions of
This structure is defined as follows in struct shmid_ds { struct
ipc_perm shm_perm; /* operation permissions */
int shm_segsz; /* size of segment in bytes */
pid_t shm_lpid; /* pid of last shm op */
pid_t shm_cpid; /* pid of creator */
short shm_nattch; /* # of current attaches */
time_t shm_atime; /* last shmat() time*/
time_t shm_dtime; /* last shmdt() time */
time_t shm_ctime; /* last change by shmctl() */
void *shm_internal; /* sysv stupidity */
}; The ipc_perm structure used inside the shmid_ds structure is defined
in and looks like this: struct ipc_perm { ushort cuid; /* creator
user id */
ushort cgid; /* creator group id */
ushort uid; /* user id */
ushort gid; /* group id */
ushort mode; /* r/w permission (see chmod(2)
) */
ushort seq; /* sequence # (to generate unique msg/sem/shm id) */
key_t key; /* user specified msg/sem/shm key */
};
The operation to be performed by is specified in and is one of: Gather information about the shared memory segment and place it in the structure pointed to by Set the value of the and fields in the structure associated with The values are taken from the corresponding fields in the structure pointed to by This operation can only be executed by the super-user, or a process that has an effective user id equal to either or in the data structure associated with the shared memory segment.
Remove the shared memory segment specified by and destroy the data associated with it. Only the super-user or a process with an effective uid equal to the or values in the data structure associated with the queue can do this.
The read and write permissions on a shared memory identifier are determined by the field in the same way as is done with files (see but the effective uid can match either the field or the field, and the effective gid can match either or
An attempt is made to increase the value of through IPC_SET but the caller is not the super-user. The command is IPC_STAT and the caller has no read permission for this shared memory segment. is not a valid shared memory segment identifier.
is not a valid command. specifies an invalid address.