2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
14 #include <sys/types.h>
24 main(int argc
, char **argv
)
29 struct timeval tvp
[2];
33 #define getcwd(x,y) getwd(x)
36 /* venus system tester */
38 return printf("usage: fulltest <dir-to-screw-up>\n");
41 if (chdir(dirName
) < 0) {
45 if (getcwd(tempName
, 1024) == 0) {
46 printf("Could not get working dir.\n");
49 /* now create some files */
50 fd1
= open("hi", O_CREAT
| O_TRUNC
| O_RDWR
, 0666);
59 if (access("hi", 2) < 0) {
60 printf("New file can not be written (access)\n");
63 if (chmod("hi", 0741) < 0) {
67 if (stat("hi", &tstat
) < 0) {
71 if ((tstat
.st_mode
& 0777) != 0741) {
72 printf("chmod failed to set mode properly\n");
75 fd1
= open("hi", O_RDWR
);
80 if (fchmod(fd1
, 0654) < 0) {
84 if (fstat(fd1
, &tstat
) < 0) {
88 if ((tstat
.st_mode
& 0777) != 0654) {
89 printf("fchmod failed to set mode properly\n");
93 /* These appear to be defunct routines;
94 * I don't know what, if anything, replaced them */
95 if (osi_ExclusiveLockNoBlock(fd1
) < 0)
96 {perror("flock1");return -1;}
97 if (osi_UnLock(fd1
) < 0)
98 {perror("flock/unlock");return -1;}
101 /* How about shared lock portability? */
106 fl
.l_whence
= SEEK_SET
;
110 if (fcntl(fd1
, F_SETLK
, &fl
) == -1) {
111 perror("fcntl1: RDLCK");
116 fl
.l_whence
= SEEK_SET
;
120 if (fcntl(fd1
, F_SETLK
, &fl
) == -1) {
121 perror("fcntl2: UNLCK");
126 fl
.l_whence
= SEEK_SET
;
130 if (fcntl(fd1
, F_SETLK
, &fl
) == -1) {
131 perror("fcntl3: WRLCK");
136 fl
.l_whence
= SEEK_SET
;
140 if (fcntl(fd1
, F_SETLK
, &fl
) == -1) {
141 perror("fcntl4: UNLCK");
146 if (fsync(fd1
) < 0) {
150 if (write(fd1
, "hi\n", 3) != 3) {
154 if (ftruncate(fd1
, 2) < 0) {
158 if (close(fd1
) < 0) {
163 fd1
= open("hi", O_RDONLY
);
168 if (read(fd1
, tempName
, 100) != 2) {
172 if (close(fd1
) < 0) {
177 if (link("hi", "bye") < 0) {
181 if (stat("bye", &tstat
) < 0) {
186 if (unlink("bye") < 0) {
191 if (symlink("hi", "bye") < 0) {
195 if (readlink("bye", tempName
, 100) != 2) {
199 if (strncmp(tempName
, "hi", 2) != 0) {
200 printf("readlink contents");
203 if (mkdir("tdir", 0777) < 0) {
207 fd1
= open("tdir/fdsa", O_CREAT
| O_TRUNC
, 0777);
209 if (rmdir("tdir") == 0) {
210 printf("removed non-empty dir\n");
213 if (unlink("tdir/fdsa") < 0) {
214 perror("unlink tdir contents");
217 if (rmdir("tdir") < 0) {
222 fd1
= open(".", O_RDONLY
);
227 if (read(fd1
, tempName
, 20) < 20)
231 fd1
= open("rotest", O_RDWR
| O_CREAT
, 0444);
233 perror("open ronly");
236 code
= fchown(fd1
, 1, -1); /* don't check error code, may fail on Ultrix */
237 code
= write(fd1
, "test", 4);
239 printf("rotest short read (%d)\n", code
);
244 perror("close ronly");
247 code
= stat("rotest", &tstat
);
249 perror("stat ronly");
252 if (tstat
.st_size
!= 4) {
253 printf("rotest short close\n");
256 if (unlink("rotest") < 0) {
257 perror("rotest unlink");
261 if (rename("hi", "bye") < 0) {
265 if (stat("bye", &tstat
) < 0) {
266 perror("rename target invisible\n");
269 if (stat("hi", &tstat
) == 0) {
270 printf("rename source still there\n");
275 /* No truncate(2) on aix so the following are excluded */
276 if (truncate("bye", 1) < 0) {
280 if (stat("bye", &tstat
) < 0) {
281 perror("truncate zapped");
284 if (tstat
.st_size
!= 1) {
285 printf("truncate failed\n");
289 if (utimes("bye", tvp
) < 0) {
293 if (unlink("bye") < 0) {
294 perror("unlink bye");
299 if (chdir("..") < 0) {
304 printf("Test completed successfully.\n");