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