Remove the RCSID macro
[openafs.git] / src / venus / test / owntest.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 #include <afsconfig.h>
11 #include <afs/param.h>
12 #ifdef HAVE_STDLIB_H
13 #include <stdlib.h>
14 #endif
15 #include <stdio.h>
16
17
18 #include <sys/types.h>
19 #include <sys/file.h>
20 #include <sys/stat.h>
21 #include <sys/time.h>
22 #include <errno.h>
23
24 extern int errno;
25
26 main(argc, argv)
27      int argc;
28      char **argv;
29 {
30     struct timeval tv[2];
31     struct stat tstat;
32     register long code;
33     register char *pn;          /* path name we're dealing with */
34
35     if (argc != 2) {
36         printf
37             ("usage: owntest <file owned by somoneelse, but still writable>\n");
38         exit(1);
39     }
40
41     pn = argv[1];
42     printf("Starting tests on %s.\n", pn);
43     code = chmod(pn, 0444);
44     if (code < 0) {
45         perror("chmod to RO");
46         exit(errno);
47     }
48     code = chmod(pn, 0666);
49     if (code < 0) {
50         perror("chmod back to RW");
51         exit(errno);
52     }
53     gettimeofday(&tv[0], NULL);
54     gettimeofday(&tv[1], NULL);
55     tv[0].tv_sec -= 10000;
56     tv[0].tv_usec = 0;
57     tv[1].tv_sec -= 20000;
58     tv[1].tv_usec = 0;
59     code = utimes(pn, tv);
60     if (code < 0) {
61         perror("utimes");
62         exit(errno);
63     }
64     code = stat(pn, &tstat);
65     if (code < 0) {
66         perror("stat");
67         exit(errno);
68     }
69     if (tstat.st_mtime != tv[1].tv_sec) {
70         printf("modtime didn't stick\n");
71         exit(1);
72     }
73     printf("Done.\n");
74     exit(0);
75 }