uss: Tidy up header includes
[openafs.git] / src / venus / livesys.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
13
14 #include <afs/afs_args.h>
15 #include <rx/xdr.h>
16 #include <sys/ioctl.h>
17 #include <sys/socket.h>
18 #include <netdb.h>
19 #include <errno.h>
20 #include <stdio.h>
21 #include <netinet/in.h>
22 #include <sys/stat.h>
23 #include <string.h>
24 #include <afs/stds.h>
25 #include <afs/com_err.h>
26 #include <afs/vice.h>
27 #include <afs/venus.h>
28 #include <afs/com_err.h>
29 #include <afs/afs_consts.h>
30 #include <afs/sys_prototypes.h>
31 #ifdef  AFS_AIX32_ENV
32 #include <signal.h>
33 #endif
34
35 static char space[AFS_PIOCTL_MAXSIZE];
36
37 int
38 main(int argc, char **argv)
39 {
40     afs_int32 code;
41     struct ViceIoctl blob;
42     char *input = space;
43     afs_int32 setp = 0;
44
45 #ifdef  AFS_AIX32_ENV
46     /*
47      * The following signal action for AIX is necessary so that in case of a
48      * crash (i.e. core is generated) we can include the user's data section
49      * in the core dump. Unfortunately, by default, only a partial core is
50      * generated which, in many cases, isn't too useful.
51      */
52     struct sigaction nsa;
53
54     sigemptyset(&nsa.sa_mask);
55     nsa.sa_handler = SIG_DFL;
56     nsa.sa_flags = SA_FULLDUMP;
57     sigaction(SIGSEGV, &nsa, NULL);
58 #endif
59
60     blob.in = space;
61     blob.out = space;
62     blob.out_size = AFS_PIOCTL_MAXSIZE;
63     blob.in_size = sizeof(afs_int32);
64     memcpy(space, &setp, sizeof(afs_int32));
65     code = pioctl(0, VIOC_AFS_SYSNAME, &blob, 1);
66     if (code) {
67         fprintf(stderr, "livesys: %s\n", afs_error_message(code));
68         return 1;
69     }
70     input = space;
71     memcpy(&setp, input, sizeof(afs_int32));
72     input += sizeof(afs_int32);
73     if (!setp) {
74         fprintf(stderr, "No sysname name value was found\n");
75         return 1;
76     }
77     printf("%s\n", input);
78     return 0;
79 }