Import Upstream version 1.8.5
[hcoop/debian/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 <afsconfig.h>
15 #include <afs/param.h>
16
17
18 #ifdef AFS_NAMEI_ENV
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <errno.h>
22 #include <fcntl.h>
23 #include <fcntl.h>
24 #include <sys/stat.h>
25 #include <lock.h>
26 #include <afs/afsutil.h>
27 #include "nfs.h"
28 #include <afs/afsint.h>
29 #include "ihandle.h"
30 #include "vnode.h"
31 #include "volume.h"
32 #include "viceinode.h"
33 #include "voldefs.h"
34 #include "partition.h"
35 #include <dirent.h>
36
37
38 char *prog = "nicreate";
39 IHandle_t *GetLinkHandle(char *part, int volid);
40
41 void
42 Usage(void)
43 {
44 printf("Usage: %s partition RWvolid p1 p2 p3 p4\n", prog);
45 exit(1);
46 }
47
48 main(int ac, char **av)
49 {
50 char *part;
51 int volid;
52 int p1, p2, p3, p4;
53 IHandle_t lh, *lhp;
54 Inode ino;
55
56 if (ac != 7)
57 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 } else {
80 printf("Returned inode %s\n", PrintInode(NULL, ino));
81 }
82 }
83
84 #endif /* AFS_NAMEI_ENV */