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