afsconfig-and-rcsid-all-around-20010705
[openafs.git] / src / vol / test / nicreate.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 /* nicreate
11  * Test "inode" creation in the user space file system.
12  */
13
14 #include <afs/param.h>
15 #include <afsconfig.h>
16
17 RCSID("$Header$");
18
19 #ifdef AFS_NAMEI_ENV
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <errno.h>
23 #include <fcntl.h>
24 #include <fcntl.h>
25 #include <sys/stat.h>
26 #include <lock.h>
27 #include <afs/afsutil.h>
28 #include "nfs.h"
29 #include <afs/afsint.h>
30 #include "ihandle.h"
31 #include "vnode.h"
32 #include "volume.h"
33 #include "viceinode.h"
34 #include "voldefs.h"
35 #include "partition.h"
36 #include <dirent.h>
37 #include <afs/assert.h>
38
39
40 char *prog = "nicreate";
41 IHandle_t * GetLinkHandle(char *part, int volid);
42
43 void Usage(void)
44 {
45     printf("Usage: %s partition RWvolid p1 p2 p3 p4\n", prog);
46     exit(1);
47 }
48
49 main(int ac, char **av)
50 {
51     char *part;
52     int volid;
53     int p1, p2, p3, p4;
54     IHandle_t lh, *lhp;
55     Inode ino;
56
57     if (ac != 7) Usage();
58
59     part = av[1];
60     volid = atoi(av[2]);
61     p1 = atoi(av[3]);
62     p2 = atoi(av[4]);
63     p3 = atoi(av[5]);
64     p4 = atoi(av[6]);
65
66     if (p2 == -1 && p3 == VI_LINKTABLE)
67         lhp = NULL;
68     else {
69         lhp = GetLinkHandle(part, volid);
70         if (!lhp) {
71             perror("Getting link handle.\n");
72             exit(1);
73         }
74     }
75
76     ino = namei_icreate(lhp, part, p1, p2, p3, p4);
77     if (!VALID_INO(ino)) {
78         perror("namei_icreate");
79     }
80     else {
81         printf("Returned inode %s\n", PrintInode(NULL, ino));
82     }
83 }
84
85 #endif /* AFS_NAMEI_ENV */
86