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