kill-uninitialized-variable-warnings-20081026
[openafs.git] / src / venus / test / getinitparams.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 /* Get CM initialization parameters. */
11 #include <afsconfig.h>
12
13 RCSID
14     ("$Header$");
15
16 #include <afs/param.h>
17 #include <stdio.h>
18 #include <netinet/in.h>
19 #include <afs/vice.h>
20 #include <afs/venus.h>
21 #include <afs/cmd.h>
22 #include <fcntl.h>
23 #ifdef AFS_AIX41_ENV
24 #include <signal.h>
25 #endif
26
27 /*
28  * if -file <path> is given, fetch initialization parameters via ioctl()
29  * on that file
30  *
31  * otherwise, fetch initialization paramters via lpioctl()
32  */
33
34
35
36 int
37 GetInitParamsCmd(struct cmd_syndesc *as, void *arock)
38 {
39     struct cm_initparams cm_initParams;
40     struct ViceIoctl blob;
41     int code;
42     int len;
43     char *file = 0;
44     int fd = 0;
45
46     if (as->parms[0].items) {
47         file = as->parms[0].items->data;
48     }
49
50     if (file) {
51         printf("ioctl test\n");
52         fd = open(file, O_RDONLY, 0);
53         if (fd < 0) {
54             perror("open");
55             exit(1);
56         }
57     } else {
58         printf("lpioctl test\n");
59     }
60
61     blob.in = (char *)0;
62     blob.in_size = 0;
63     blob.out = (char *)&cm_initParams;
64     blob.out_size = sizeof(struct cm_initparams);
65
66     if (file) {
67         code = ioctl(fd, VIOC_GETINITPARAMS, &blob);
68         if (code < 0) {
69             perror("ioctl: Error getting CM initialization parameters");
70             exit(1);
71         }
72         close(fd);
73     } else {
74         code = lpioctl(NULL, VIOC_GETINITPARAMS, &blob, 0);
75         if (code) {
76             perror("lpioctl: Error getting CM initialization parameters");
77             exit(1);
78         }
79     }
80
81     printf("cm_initparams version: %d\n", cm_initParams.cmi_version);
82     printf("Chunk Files: %d\n", cm_initParams.cmi_nChunkFiles);
83     printf("Stat Caches: %d\n", cm_initParams.cmi_nStatCaches);
84     printf("Data Caches: %d\n", cm_initParams.cmi_nDataCaches);
85     printf("Volume Caches: %d\n", cm_initParams.cmi_nVolumeCaches);
86     printf("First Chunk Size: %d\n", cm_initParams.cmi_firstChunkSize);
87     printf("Other Chunk Size: %d\n", cm_initParams.cmi_otherChunkSize);
88     printf("Initial Cache Size: %dK\n", cm_initParams.cmi_cacheSize);
89     printf("CM Sets Time: %c\n", cm_initParams.cmi_setTime ? 'Y' : 'N');
90     printf("Disk Based Cache: %c\n", cm_initParams.cmi_memCache ? 'N' : 'Y');
91
92     exit(0);
93 }
94
95
96 main(ac, av)
97      int ac;
98      char **av;
99 {
100     int code;
101     struct cmd_syndesc *ts;
102
103 #ifdef  AFS_AIX32_ENV
104     /*
105      * The following signal action for AIX is necessary so that in case of a 
106      * crash (i.e. core is generated) we can include the user's data section 
107      * in the core dump. Unfortunately, by default, only a partial core is
108      * generated which, in many cases, isn't too useful.
109      */
110     struct sigaction nsa;
111
112     sigemptyset(&nsa.sa_mask);
113     nsa.sa_handler = SIG_DFL;
114     nsa.sa_flags = SA_FULLDUMP;
115     sigaction(SIGSEGV, &nsa, NULL);
116 #endif
117
118     ts = cmd_CreateSyntax(NULL, GetInitParamsCmd, NULL,
119                           "Get CM initialization parameters");
120
121     cmd_AddParm(ts, "-file", CMD_SINGLE, CMD_OPTIONAL, "filename in AFS");
122     code = cmd_Dispatch(ac, av);
123     exit(code);
124 }