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