1 /* Copyright (C) 2003 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
31 int (*fp
) (const char *, mode_t
);
36 { creat
, "creat", true },
37 { mkdir
, "mkdir", false },
38 { mkfifo
, "mkfifo", false },
40 #define nfcts (sizeof (fcts) / sizeof (fcts[0]))
44 work (const char *fname
, int mask
)
48 for (i
= 0; i
< nfcts
; ++i
)
51 int fd
= fcts
[i
].fp (fname
, 0777);
54 printf ("cannot %s %s: %m\n", fcts
[i
].name
, fname
);
60 if (stat64 (fname
, &st
) == -1)
62 printf ("cannot stat %s after %s: %m\n", fname
, fcts
[i
].name
);
66 if ((st
.st_mode
& mask
) != 0)
68 printf ("mask not successful after %s: %x still set\n",
69 fcts
[i
].name
, (unsigned int) (st
.st_mode
& mask
));
78 static pthread_barrier_t bar
;
84 pthread_barrier_wait (&bar
);
86 int result
= work (arg
, 022);
88 pthread_barrier_wait (&bar
);
90 pthread_barrier_wait (&bar
);
92 return (work (arg
, 0) | result
) ? (void *) -1l : NULL
;
97 do_test (const char *fname
)
102 result
|= work (fname
, 0);
104 pthread_barrier_init (&bar
, NULL
, 2);
107 if (pthread_create (&th
, NULL
, tf
, (void *) fname
) != 0)
109 puts ("cannot create thread");
114 result
|= work (fname
, 022);
116 pthread_barrier_wait (&bar
);
118 pthread_barrier_wait (&bar
);
122 pthread_barrier_wait (&bar
);
125 if (pthread_join (th
, &res
) != 0)
127 puts ("join failed");
133 return result
|| res
!= NULL
;
136 #define TEST_FUNCTION do_test (argc < 2 ? "/tmp/tst-umask.tmp" : argv[1])
137 #include "../test-skeleton.c"