From 2185f91d88f0666ffa3b1b000b8a078692e5a65c Mon Sep 17 00:00:00 2001 From: Jeffrey Hutzelman Date: Tue, 9 Oct 2001 07:32:58 +0000 Subject: [PATCH] add-live-sys-cmd-20011008 The attached patch adds a program named 'livesys' to the venus directory. This program has exactly the same interface as 'sys', but actually does a pioctl to find out the current sysname instead of printing a value compiled into it. It is intended for sites who want 'sys' to report the active, locally-assigned sysname of the machine on which it is run. --- src/venus/Makefile.in | 15 +++++++++- src/venus/livesys.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 src/venus/livesys.c diff --git a/src/venus/Makefile.in b/src/venus/Makefile.in index 37b3db8..1d6cdf2 100644 --- a/src/venus/Makefile.in +++ b/src/venus/Makefile.in @@ -69,7 +69,7 @@ CMLIBS=${TOP_LIBDIR}/libsys.a \ LIBS = ${FSLIBS} -all: fs up fstrace cmdebug kdump kdump64 +all: fs up fstrace cmdebug livesys kdump kdump64 # # Build targets @@ -82,6 +82,9 @@ cacheout.o: cacheout.c ${DEST}/bin/fs ${DEST}/root.server/usr/afs/bin/fs: fs ${INSTALL} -s $? $@ +${DEST}/bin/livesys: livesys + ${INSTALL} -s $? $@ + ${DEST}/bin/up: up ${INSTALL} -s $? $@ @@ -135,6 +138,11 @@ fs.o: fs.c ${INCLS} AFS_component_version_number.c fs: fs.o $(LIBS) ${CC} ${CFLAGS} -g -o fs fs.o ${TOP_LIBDIR}/libprot.a $(LIBS) ${XLIBS} +livesys.o: livesys.c ${INCLS} AFS_component_version_number.c + +livesys: livesys.c $(LIBS) + ${CC} -g -o livesys $(CFLAGS) livesys.c $(LIBS) ${XLIBS} + twiddle: twiddle.c $(LIBS) ${CC} -g -o twiddle $(CFLAGS) twiddle.c $(LIBS) ${XLIBS} @@ -263,6 +271,7 @@ kdump64 : kdump64.o # install: \ ${DESTDIR}${bindir}/fs \ + ${DESTDIR}${bindir}/livesys \ ${DESTDIR}${afssrvbindir}/fs \ ${DESTDIR}${bindir}/up \ ${DESTDIR}${sbindir}/fstrace \ @@ -285,6 +294,9 @@ include ../config/Makefile.version ${DESTDIR}${bindir}/fs: fs ${INSTALL} -s $? $@ +${DESTDIR}${bindir}/livesys: livesys + ${INSTALL} -s $? $@ + ${DESTDIR}${afssrvbindir}/fs: fs ${INSTALL} -s $? $@ @@ -331,6 +343,7 @@ ${DESTDIR}${sbindir}/kdump64: kdump64 dest: \ ${DEST}/bin/fs \ + ${DEST}/bin/livesys \ ${DEST}/root.server/usr/afs/bin/fs \ ${DEST}/bin/up \ ${DEST}/etc/fstrace \ diff --git a/src/venus/livesys.c b/src/venus/livesys.c new file mode 100644 index 0000000..f736bb1 --- /dev/null +++ b/src/venus/livesys.c @@ -0,0 +1,78 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +#include +#include + +RCSID("$Header$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef AFS_AIX32_ENV +#include +#endif +#include + +#define MAXSIZE 2048 +static char space[MAXSIZE]; + +int main(argc, argv) + int argc; + char **argv; +{ + afs_int32 code; + struct ViceIoctl blob; + char *input = space; + afs_int32 setp = 0; + +#ifdef AFS_AIX32_ENV + /* + * The following signal action for AIX is necessary so that in case of a + * crash (i.e. core is generated) we can include the user's data section + * in the core dump. Unfortunately, by default, only a partial core is + * generated which, in many cases, isn't too useful. + */ + struct sigaction nsa; + + sigemptyset(&nsa.sa_mask); + nsa.sa_handler = SIG_DFL; + nsa.sa_flags = SA_FULLDUMP; + sigaction(SIGSEGV, &nsa, NULL); +#endif + + blob.in = space; + blob.out = space; + blob.out_size = MAXSIZE; + blob.in_size = sizeof(afs_int32); + memcpy(space, &setp, sizeof(afs_int32)); + code = pioctl(0, VIOC_AFS_SYSNAME, &blob, 1); + if (code) { + fprintf(stderr, "livesys: %s\n", error_message(code)); + return 1; + } + input = space; + memcpy(&setp, input, sizeof(afs_int32)); + input += sizeof(afs_int32); + if (!setp) { + fprintf(stderr, "No sysname name value was found\n"); + return 1; + } + printf("%s\n", input); + return 0; +} -- 1.9.4