Lines Matching +full:m +full:- +full:mode

3 /*-
34 * Test the SVID-compatible Message Queue facility.
37 #include <atf-c.h>
111 ATF_REQUIRE_MSG(output != -1, "Failed to create %s", path); in write_int()
125 if (input == -1) in read_int()
126 return -1; in read_int()
161 if (fd == -1) { in get_ftok()
164 return (key_t)-1; in get_ftok()
170 ATF_REQUIRE_MSG(unlink(token_key) != -1, "unlink() failed: %d", errno); in get_ftok()
171 ATF_REQUIRE_MSG(rmdir(token_dir) != -1, "rmdir() failed: %d", errno); in get_ftok()
188 struct testmsg m; in ATF_TC_BODY() local
202 ATF_REQUIRE_MSG(sigaction(SIGSYS, &sa, NULL) != -1, in ATF_TC_BODY()
206 ATF_REQUIRE_MSG(msgkey != (key_t)-1, "get_ftok failed"); in ATF_TC_BODY()
209 ATF_REQUIRE_MSG(sender_msqid != -1, "msgget: %d", errno); in ATF_TC_BODY()
217 ATF_REQUIRE_MSG(msgctl(sender_msqid, IPC_STAT, &m_ds) != -1, in ATF_TC_BODY()
222 m_ds.msg_perm.mode = (m_ds.msg_perm.mode & ~0777) | 0600; in ATF_TC_BODY()
224 ATF_REQUIRE_MSG(msgctl(sender_msqid, IPC_SET, &m_ds) != -1, in ATF_TC_BODY()
229 ATF_REQUIRE_MSG(msgctl(sender_msqid, IPC_STAT, &m_ds) != -1, in ATF_TC_BODY()
232 ATF_REQUIRE_MSG((m_ds.msg_perm.mode & 0777) == 0600, in ATF_TC_BODY()
233 "IPC_SET of mode didn't hold"); in ATF_TC_BODY()
240 case -1: in ATF_TC_BODY()
256 m.mtype = MTYPE_1; in ATF_TC_BODY()
257 strlcpy(m.mtext, m1_str, sizeof(m.mtext)); in ATF_TC_BODY()
258 ATF_REQUIRE_MSG(msgsnd(sender_msqid, &m, MESSAGE_TEXT_LEN, in ATF_TC_BODY()
259 0) != -1, "sender: msgsnd 1: %d", errno); in ATF_TC_BODY()
261 ATF_REQUIRE_MSG(msgrcv(sender_msqid, &m, MESSAGE_TEXT_LEN, in ATF_TC_BODY()
270 m.mtype = MTYPE_2; in ATF_TC_BODY()
271 strlcpy(m.mtext, m2_str, sizeof(m.mtext)); in ATF_TC_BODY()
272 ATF_REQUIRE_MSG(msgsnd(sender_msqid, &m, MESSAGE_TEXT_LEN, 0) != -1, in ATF_TC_BODY()
275 ATF_REQUIRE_MSG(msgrcv(sender_msqid, &m, MESSAGE_TEXT_LEN, in ATF_TC_BODY()
285 wait_result, wait_result == -1 ? strerror(errno) : ""); in ATF_TC_BODY()
291 ATF_REQUIRE_MSG(msgctl(sender_msqid, IPC_STAT, &m_ds) != -1, in ATF_TC_BODY()
305 if (sender_msqid != -1) in ATF_TC_CLEANUP()
306 if (msgctl(sender_msqid, IPC_RMID, NULL) == -1) in ATF_TC_CLEANUP()
311 print_msqid_ds(struct msqid_ds *mp, mode_t mode) in print_msqid_ds() argument
316 printf("PERM: uid %d, gid %d, cuid %d, cgid %d, mode 0%o\n", in print_msqid_ds()
317 mp->msg_perm.uid, mp->msg_perm.gid, in print_msqid_ds()
318 mp->msg_perm.cuid, mp->msg_perm.cgid, in print_msqid_ds()
319 mp->msg_perm.mode & 0777); in print_msqid_ds()
322 mp->msg_qnum, (u_long)mp->msg_qbytes, mp->msg_lspid, in print_msqid_ds()
323 mp->msg_lrpid); in print_msqid_ds()
325 printf("stime: %s", ctime(&mp->msg_stime)); in print_msqid_ds()
326 printf("rtime: %s", ctime(&mp->msg_rtime)); in print_msqid_ds()
327 printf("ctime: %s", ctime(&mp->msg_ctime)); in print_msqid_ds()
333 ATF_REQUIRE_MSG(mp->msg_perm.uid == uid && mp->msg_perm.cuid == uid, in print_msqid_ds()
336 ATF_REQUIRE_MSG(mp->msg_perm.gid == gid && mp->msg_perm.cgid == gid, in print_msqid_ds()
339 ATF_REQUIRE_MSG((mp->msg_perm.mode & 0777) == mode, "mode mismatch"); in print_msqid_ds()
345 struct testmsg m; in receiver() local
348 if ((msqid = msgget(msgkey, 0)) == -1) in receiver()
355 if (msgrcv(msqid, &m, MESSAGE_TEXT_LEN, MTYPE_1, 0) != MESSAGE_TEXT_LEN) in receiver()
358 printf("%s\n", m.mtext); in receiver()
359 if (strcmp(m.mtext, m1_str) != 0) in receiver()
362 m.mtype = MTYPE_1_ACK; in receiver()
364 if (msgsnd(msqid, &m, MESSAGE_TEXT_LEN, 0) == -1) in receiver()
371 if (msgrcv(msqid, &m, MESSAGE_TEXT_LEN, MTYPE_2, 0) != MESSAGE_TEXT_LEN) in receiver()
374 printf("%s\n", m.mtext); in receiver()
375 if (strcmp(m.mtext, m2_str) != 0) in receiver()
378 m.mtype = MTYPE_2_ACK; in receiver()
380 if (msgsnd(msqid, &m, MESSAGE_TEXT_LEN, 0) == -1) in receiver()
388 * Test the SVID-compatible Semaphore facility.
418 ATF_REQUIRE_MSG(sigaction(SIGSYS, &sa, NULL) != -1, in ATF_TC_BODY()
422 ATF_REQUIRE_MSG(semkey != (key_t)-1, "get_ftok failed"); in ATF_TC_BODY()
425 ATF_REQUIRE_MSG(sender_semid != -1, "semget: %d", errno); in ATF_TC_BODY()
434 ATF_REQUIRE_MSG(semctl(sender_semid, 0, IPC_STAT, sun) != -1, in ATF_TC_BODY()
439 s_ds.sem_perm.mode = (s_ds.sem_perm.mode & ~0777) | 0600; in ATF_TC_BODY()
442 ATF_REQUIRE_MSG(semctl(sender_semid, 0, IPC_SET, sun) != -1, in ATF_TC_BODY()
448 ATF_REQUIRE_MSG(semctl(sender_semid, 0, IPC_STAT, sun) != -1, in ATF_TC_BODY()
451 ATF_REQUIRE_MSG((s_ds.sem_perm.mode & 0777) == 0600, in ATF_TC_BODY()
452 "IPC_SET of mode didn't hold"); in ATF_TC_BODY()
460 case -1: in ATF_TC_BODY()
479 if (i == -1) in ATF_TC_BODY()
490 ATF_REQUIRE_MSG(semctl(sender_semid, 0, SETVAL, sun) != -1, in ATF_TC_BODY()
496 while (child_count-- > 0) { in ATF_TC_BODY()
498 ATF_REQUIRE_MSG(wait_result != -1, "wait failed: %s", in ATF_TC_BODY()
507 ATF_REQUIRE_MSG(semctl(sender_semid, 0, IPC_STAT, sun) != -1, in ATF_TC_BODY()
522 if (sender_semid != -1) in ATF_TC_CLEANUP()
523 if (semctl(sender_semid, 0, IPC_RMID) == -1) in ATF_TC_CLEANUP()
528 print_semid_ds(struct semid_ds *sp, mode_t mode) in print_semid_ds() argument
533 printf("PERM: uid %d, gid %d, cuid %d, cgid %d, mode 0%o\n", in print_semid_ds()
534 sp->sem_perm.uid, sp->sem_perm.gid, in print_semid_ds()
535 sp->sem_perm.cuid, sp->sem_perm.cgid, in print_semid_ds()
536 sp->sem_perm.mode & 0777); in print_semid_ds()
538 printf("nsems %u\n", sp->sem_nsems); in print_semid_ds()
540 printf("otime: %s", ctime(&sp->sem_otime)); in print_semid_ds()
541 printf("ctime: %s", ctime(&sp->sem_ctime)); in print_semid_ds()
547 ATF_REQUIRE_MSG(sp->sem_perm.uid == uid && sp->sem_perm.cuid == uid, in print_semid_ds()
550 ATF_REQUIRE_MSG(sp->sem_perm.gid == gid && sp->sem_perm.cgid == gid, in print_semid_ds()
553 ATF_REQUIRE_MSG((sp->sem_perm.mode & 0777) == mode, in print_semid_ds()
554 "mode mismatch %o != %o", (sp->sem_perm.mode & 0777), mode); in print_semid_ds()
563 if ((semid = semget(semkey, 1, 0)) == -1) in waiter()
570 s.sem_op = -1; in waiter()
573 if (semop(semid, &s, 1) == -1) in waiter()
574 err(1, "waiter: semop -1"); in waiter()
586 if (semop(semid, &s, 1) == -1) in waiter()
593 * Test the SVID-compatible Shared Memory facility.
621 ATF_REQUIRE_MSG(sigaction(SIGSYS, &sa, NULL) != -1, in ATF_TC_BODY()
627 ATF_REQUIRE_MSG(shmkey != (key_t)-1, "get_ftok failed"); in ATF_TC_BODY()
630 IPC_CREAT | 0640)) != -1, in ATF_TC_BODY()
634 ATF_REQUIRE_MSG(shmctl(sender_shmid, IPC_STAT, &s_ds) != -1, in ATF_TC_BODY()
639 s_ds.shm_perm.mode = (s_ds.shm_perm.mode & ~0777) | 0600; in ATF_TC_BODY()
641 ATF_REQUIRE_MSG(shmctl(sender_shmid, IPC_SET, &s_ds) != -1, in ATF_TC_BODY()
646 ATF_REQUIRE_MSG(shmctl(sender_shmid, IPC_STAT, &s_ds) != -1, in ATF_TC_BODY()
649 ATF_REQUIRE_MSG((s_ds.shm_perm.mode & 0777) == 0600, in ATF_TC_BODY()
650 "IPC_SET of mode didn't hold"); in ATF_TC_BODY()
655 ATF_REQUIRE_MSG(shm_buf != (void *) -1, "sender: shmat: %d", errno); in ATF_TC_BODY()
665 case -1: in ATF_TC_BODY()
682 wait_result, wait_result == -1 ? strerror(errno) : ""); in ATF_TC_BODY()
688 ATF_REQUIRE_MSG(shmctl(sender_shmid, IPC_STAT, &s_ds) != -1, in ATF_TC_BODY()
703 if (shmid != -1) { in shmid_cleanup()
704 if (shmctl(shmid, IPC_RMID, NULL) == -1) in shmid_cleanup()
716 print_shmid_ds(struct shmid_ds *sp, mode_t mode) in print_shmid_ds() argument
721 printf("PERM: uid %d, gid %d, cuid %d, cgid %d, mode 0%o\n", in print_shmid_ds()
722 sp->shm_perm.uid, sp->shm_perm.gid, in print_shmid_ds()
723 sp->shm_perm.cuid, sp->shm_perm.cgid, in print_shmid_ds()
724 sp->shm_perm.mode & 0777); in print_shmid_ds()
727 (u_long)sp->shm_segsz, sp->shm_lpid, sp->shm_cpid, in print_shmid_ds()
728 sp->shm_nattch); in print_shmid_ds()
730 printf("atime: %s", ctime(&sp->shm_atime)); in print_shmid_ds()
731 printf("dtime: %s", ctime(&sp->shm_dtime)); in print_shmid_ds()
732 printf("ctime: %s", ctime(&sp->shm_ctime)); in print_shmid_ds()
738 ATF_REQUIRE_MSG(sp->shm_perm.uid == uid && sp->shm_perm.cuid == uid, in print_shmid_ds()
741 ATF_REQUIRE_MSG(sp->shm_perm.gid == gid && sp->shm_perm.cgid == gid, in print_shmid_ds()
744 ATF_REQUIRE_MSG((sp->shm_perm.mode & 0777) == mode, "mode mismatch"); in print_shmid_ds()
754 if (shmid == -1) in sharer()
758 if (shm_buf == (void *) -1) in sharer()
785 ATF_REQUIRE_MSG(shmkey != (key_t)-1, "get_ftok failed"); in ATF_TC_BODY()
788 IPC_CREAT | 0640)) != -1, "shmget: %d", errno); in ATF_TC_BODY()
792 MAP_ANON | MAP_PRIVATE, -1, 0)) != MAP_FAILED, "mmap: %d", errno); in ATF_TC_BODY()
794 ATF_REQUIRE_MSG(shmat(shmid_remap, shm_buf, 0) == (void *)-1, in ATF_TC_BODY()