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