This commit is contained in:
Michael Kerrisk 2007-06-20 21:18:35 +00:00
parent dd0a09a557
commit bb38b71d15
1 changed files with 106 additions and 155 deletions

View File

@ -50,48 +50,40 @@ For each resource, the system uses a common structure of type
to store information needed in determining permissions to perform an
ipc operation.
The
.B ipc_perm
.I ipc_perm
structure, defined by the
.I <sys/ipc.h>
system header file, includes the following members:
.sp
.B
uid_t cuid;
/* creator user ID */
.br
.B
gid_t cgid;
/* creator group ID */
.br
.B
uid_t uid;
/* owner user ID */
.br
.B
gid_t gid;
/* owner group ID */
.br
.B
ushort mode;
/* r/w permissions */
.in +0.5i
.nf
struct ipc_perm {
uid_t cuid; /* creator user ID */
gid_t cgid; /* creator group ID */
uid_t uid; /* owner user ID */
gid_t gid; /* owner group ID */
ushort mode; /* r/w permissions */
};
.fi
.in
.PP
The
.B mode
.I mode
member of the
.B ipc_perm
.I ipc_perm
structure defines, with its lower 9 bits, the access permissions to the
resource for a process executing an ipc system call.
The permissions are interpreted as follows:
.sp
.nf
0400 Read by user.
0200 Write by user.
0400 Read by user.
0200 Write by user.
.sp .5
0040 Read by group.
0020 Write by group.
0040 Read by group.
0020 Write by group.
.sp .5
0004 Read by others.
0002 Write by others.
0004 Read by others.
0002 Write by others.
.fi
.PP
Bits 0100, 0010, and 0001 (the execute bits) are unused by the system.
@ -128,7 +120,7 @@ Get resource options.
Note that
.B IPC_PRIVATE
is a
.B key_t
.I key_t
type, while all the other symbolic constants are flag fields and can
be OR'ed into an
.I int
@ -141,74 +133,58 @@ and has an associated data structure of type
defined in
.IR <sys/msg.h> ,
containing the following members:
.sp
.B
struct ipc_perm msg_perm;
.br
.B
msgqnum_t msg_qnum;
/* no of messages on queue */
.br
.B
msglen_t msg_qbytes;
/* bytes max on a queue */
.br
.B
pid_t msg_lspid;
/* PID of last msgsnd(2) call */
.br
.B
pid_t msg_lrpid;
/* PID of last msgrcv(2) call */
.br
.B
time_t msg_stime;
/* last msgsnd(2) time */
.br
.B
time_t msg_rtime;
/* last msgrcv(2) time */
.br
.B
time_t msg_ctime;
/* last change time */
.in +0.5i
.nf
struct msqid_ds {
struct ipc_perm msg_perm;
msgqnum_t msg_qnum; /* no of messages on queue */
msglen_t msg_qbytes; /* bytes max on a queue */
pid_t msg_lspid; /* PID of last msgsnd(2) call */
pid_t msg_lrpid; /* PID of last msgrcv(2) call */
time_t msg_stime; /* last msgsnd(2) time */
time_t msg_rtime; /* last msgrcv(2) time */
time_t msg_ctime; /* last change time */
};
.fi
.in
.TP 11
.B msg_perm
.B ipc_perm
.I msg_perm
.I ipc_perm
structure that specifies the access permissions on the message
queue.
.TP
.B msg_qnum
.I msg_qnum
Number of messages currently on the message queue.
.TP
.B msg_qbytes
.I msg_qbytes
Maximum number of bytes of message text allowed on the message
queue.
.TP
.B msg_lspid
.I msg_lspid
ID of the process that performed the last
.BR msgsnd (2)
system call.
.TP
.B msg_lrpid
.I msg_lrpid
ID of the process that performed the last
.BR msgrcv (2)
system call.
.TP
.B msg_stime
.I msg_stime
Time of the last
.BR msgsnd (2)
system call.
.TP
.B msg_rtime
.I msg_rtime
Time of the last
.BR msgrcv (2)
system call.
.TP
.B msg_ctime
.I msg_ctime
Time of the last
system call that changed a member of the
.B msqid_ds
.I msqid_ds
structure.
.SS Semaphore Sets
A semaphore set is uniquely identified by a positive integer
@ -218,81 +194,72 @@ and has an associated data structure of type
defined in
.IR <sys/sem.h> ,
containing the following members:
.sp
.B
struct ipc_perm sem_perm;
.br
.B
time_t sem_otime;
/* last operation time */
.br
.B
time_t sem_ctime;
/* last change time */
.br
.B
ulong sem_nsems;
/* count of sems in set */
.nf
.in +0.5i
.nf
struct semid_ds {
struct ipc_perm sem_perm;
time_t sem_otime; /* last operation time */
time_t sem_ctime; /* last change time */
ulong sem_nsems; /* count of sems in set */
};
.fi
.in
.TP 11
.B sem_perm
.B ipc_perm
.I sem_perm
.I ipc_perm
structure that specifies the access permissions on the semaphore
set.
.TP
.B sem_otime
.I sem_otime
Time of last
.BR semop (2)
system call.
.TP
.B sem_ctime
.I sem_ctime
Time of last
.BR semctl (2)
system call that changed a member of the above structure or of one
semaphore belonging to the set.
.TP
.B sem_nsems
.I sem_nsems
Number of semaphores in the set.
Each semaphore of the set is referenced by a non-negative integer
ranging from
.B 0
to
.BR sem_nsems\-1 .
.IR sem_nsems\-1 .
.PP
A semaphore is a data structure of type
.I "struct sem"
containing the following members:
.sp
.B
int semval;
/* semaphore value */
.br
.B
int sempid;
/* PID for last operation */
.\".br
.\".B
.\" ushort semncnt;
.\"/* nr awaiting semval to increase */
.\".br
.\".B
.\" ushort semzcnt;
.\"/* nr awaiting semval = 0 */
.in +0.5i
.nf
struct sem {
int semval; /* semaphore value */
int sempid; /* PID for last operation */
.\" ushort semncnt; /* nr awaiting semval to increase */
.\" ushort semzcnt; /* nr awaiting semval = 0 */
}
.fi
.in
.TP 11
.B semval
.I semval
Semaphore value: a non-negative integer.
.TP
.B sempid
.I sempid
ID of the last process that performed a semaphore operation
on this semaphore.
.\".TP
.\".B semncnt
.\".I semncnt
.\"Number of processes suspended awaiting for
.\".B semval
.\".I semval
.\"to increase.
.\".TP
.\".B semznt
.\".I semznt
.\"Number of processes suspended awaiting for
.\".B semval
.\".I semval
.\"to become zero.
.SS Shared Memory Segments
A shared memory segment is uniquely identified by a positive integer
@ -302,74 +269,58 @@ and has an associated data structure of type
defined in
.IR <sys/shm.h> ,
containing the following members:
.sp
.B
struct ipc_perm shm_perm;
.br
.B
size_t shm_segsz;
/* size of segment */
.br
.B
pid_t shm_cpid;
/* PID of creator */
.br
.B
pid_t shm_lpid;
/* PID, last operation */
.br
.B
shmatt_t shm_nattch;
/* no. of current attaches */
.br
.B
time_t shm_atime;
/* time of last attach */
.br
.B
time_t shm_dtime;
/* time of last detach */
.br
.B
time_t shm_ctime;
/* time of last change */
.in +0.5i
.nf
struct shmid_ds {
struct ipc_perm shm_perm;
size_t shm_segsz; /* size of segment */
pid_t shm_cpid; /* PID of creator */
pid_t shm_lpid; /* PID, last operation */
shmatt_t shm_nattch; /* no. of current attaches */
time_t shm_atime; /* time of last attach */
time_t shm_dtime; /* time of last detach */
time_t shm_ctime; /* time of last change */
};
.fi
.in
.TP 11
.B shm_perm
.B ipc_perm
.I shm_perm
.I ipc_perm
structure that specifies the access permissions on the shared memory
segment.
.TP
.B shm_segsz
.I shm_segsz
Size in bytes of the shared memory segment.
.TP
.B shm_cpid
.I shm_cpid
ID of the process that created the shared memory segment.
.TP
.B shm_lpid
.I shm_lpid
ID of the last process that executed a
.BR shmat (2)
or
.BR shmdt (2)
system call.
.TP
.B shm_nattch
.I shm_nattch
Number of current alive attaches for this shared memory segment.
.TP
.B shm_atime
.I shm_atime
Time of the last
.BR shmat (2)
system call.
.TP
.B shm_dtime
.I shm_dtime
Time of the last
.BR shmdt (2)
system call.
.TP
.B shm_ctime
.I shm_ctime
Time of the last
.BR shmctl (2)
system call that changed
.BR shmid_ds .
.IR shmid_ds .
.SH "SEE ALSO"
.BR msgctl (2),
.BR msgget (2),