Lines Matching +full:m +full:- +full:mode
1 /*-
34 * Test the SVID-compatible Message Queue facility.
80 int sender_msqid = -1;
90 struct test_mymsg m; in main() local
103 if (sigaction(SIGSYS, &sa, NULL) == -1) in main()
113 if (sigaction(SIGCHLD, &sa, NULL) == -1) in main()
128 if (atexit(cleanup) == -1) in main()
131 if ((sender_msqid = msgget(msgkey, IPC_CREAT | 0640)) == -1) in main()
134 if (msgctl(sender_msqid, IPC_STAT, &m_ds) == -1) in main()
139 m_ds.msg_perm.mode = (m_ds.msg_perm.mode & ~0777) | 0600; in main()
141 if (msgctl(sender_msqid, IPC_SET, &m_ds) == -1) in main()
146 if (msgctl(sender_msqid, IPC_STAT, &m_ds) == -1) in main()
149 if ((m_ds.msg_perm.mode & 0777) != 0600) in main()
150 err(1, "IPC_SET of mode didn't hold"); in main()
155 case -1: in main()
170 m.mtype = MTYPE_1; in main()
171 strcpy(m.mtext, m1_str); in main()
172 if (msgsnd(sender_msqid, &m, strlen(m1_str) + 1, 0) == -1) in main()
175 if (msgrcv(sender_msqid, &m, sizeof(m.mtext), MTYPE_1_ACK, 0) != in main()
184 m.mtype = MTYPE_2; in main()
185 strcpy(m.mtext, m2_str); in main()
186 if (msgsnd(sender_msqid, &m, strlen(m2_str) + 1, 0) == -1) in main()
189 if (msgrcv(sender_msqid, &m, sizeof(m.mtext), MTYPE_2_ACK, 0) != in main()
237 if (msgctl(sender_msqid, IPC_STAT, &m_ds) == -1) in sigchld_handler()
252 if (child_pid != 0 && sender_msqid != -1) { in cleanup()
253 if (msgctl(sender_msqid, IPC_RMID, NULL) == -1) in cleanup()
259 print_msqid_ds(struct msqid_ds *mp, mode_t mode) in print_msqid_ds() argument
264 printf("PERM: uid %d, gid %d, cuid %d, cgid %d, mode 0%o\n", in print_msqid_ds()
265 mp->msg_perm.uid, mp->msg_perm.gid, in print_msqid_ds()
266 mp->msg_perm.cuid, mp->msg_perm.cgid, in print_msqid_ds()
267 mp->msg_perm.mode & 0777); in print_msqid_ds()
270 mp->msg_qnum, (u_long)mp->msg_qbytes, mp->msg_lspid, in print_msqid_ds()
271 mp->msg_lrpid); in print_msqid_ds()
273 printf("stime: %s", ctime(&mp->msg_stime)); in print_msqid_ds()
274 printf("rtime: %s", ctime(&mp->msg_rtime)); in print_msqid_ds()
275 printf("ctime: %s", ctime(&mp->msg_ctime)); in print_msqid_ds()
281 if (mp->msg_perm.uid != uid || mp->msg_perm.cuid != uid) in print_msqid_ds()
284 if (mp->msg_perm.gid != gid || mp->msg_perm.cgid != gid) in print_msqid_ds()
287 if ((mp->msg_perm.mode & 0777) != mode) in print_msqid_ds()
288 errx(1, "mode mismatch"); in print_msqid_ds()
302 struct test_mymsg m; in receiver() local
305 if ((msqid = msgget(msgkey, 0)) == -1) in receiver()
312 if (msgrcv(msqid, &m, sizeof(m.mtext), MTYPE_1, 0) != in receiver()
316 printf("%s\n", m.mtext); in receiver()
317 if (strcmp(m.mtext, m1_str) != 0) in receiver()
320 m.mtype = MTYPE_1_ACK; in receiver()
322 if (msgsnd(msqid, &m, strlen(m1_str) + 1, 0) == -1) in receiver()
329 if (msgrcv(msqid, &m, sizeof(m.mtext), MTYPE_2, 0) != in receiver()
333 printf("%s\n", m.mtext); in receiver()
334 if (strcmp(m.mtext, m2_str) != 0) in receiver()
337 m.mtype = MTYPE_2_ACK; in receiver()
339 if (msgsnd(msqid, &m, strlen(m2_str) + 1, 0) == -1) in receiver()