xref: /dragonfly/test/testcases/posixipc/file_test/file_test.c (revision 0bba68feaae2960c1f2b5feb6978a8918f571707)
1 #include <common.h>
2 
3 int
main(void)4 main(void) {
5           struct stat sb;
6           sem_t *id;
7           int error;
8 
9           id = sem_open(TEST_PATH, O_CREAT, 0777, 0);
10           if (id == SEM_FAILED) {
11                     perror("sem_open");
12                     return 1;
13           }
14 
15           error = stat("/var/run/sem", &sb);
16           if (error) {
17                     perror("stat");
18                     return 1;
19           }
20           if ((sb.st_mode & ALLPERMS) != (S_IRWXU|S_IRWXG|S_IRWXO|S_ISTXT)) {
21                     fprintf(stderr, "semaphore dir has incorrect mode: 0%o\n",
22                                (sb.st_mode & ALLPERMS));
23                     return 1;
24           }
25 
26           sem_close(id);
27           return 0;
28 }
29