diff options
author | Hans Insulander <hin@cvs.openbsd.org> | 2002-06-07 04:28:58 +0000 |
---|---|---|
committer | Hans Insulander <hin@cvs.openbsd.org> | 2002-06-07 04:28:58 +0000 |
commit | 0f2eb5b99819cd2227abf27bf90e6a062ba6ba73 (patch) | |
tree | 01a20a816971f899ddc16a3cd178506bd790bfd7 /usr.sbin | |
parent | 9a5c00694971aecfbf13260be3c1af2ab8db1ee8 (diff) |
merge
Diffstat (limited to 'usr.sbin')
113 files changed, 4060 insertions, 3344 deletions
diff --git a/usr.sbin/afs/src/appl/Makefile.in b/usr.sbin/afs/src/appl/Makefile.in index 4bc98c0e020..5db5bcf895c 100644 --- a/usr.sbin/afs/src/appl/Makefile.in +++ b/usr.sbin/afs/src/appl/Makefile.in @@ -1,6 +1,7 @@ -# $Id: Makefile.in,v 1.1 2000/09/11 14:40:30 art Exp $ +# $KTH: Makefile.in,v 1.63.2.1 2001/10/23 23:30:31 ahltorp Exp $ srcdir = @srcdir@ +top_builddir = .. VPATH = @srcdir@ SHELL = /bin/sh diff --git a/usr.sbin/afs/src/appl/afsmgr/Makefile.in b/usr.sbin/afs/src/appl/afsmgr/Makefile.in index aac547858f7..83f1f7a6bcf 100644 --- a/usr.sbin/afs/src/appl/afsmgr/Makefile.in +++ b/usr.sbin/afs/src/appl/afsmgr/Makefile.in @@ -1,6 +1,7 @@ -# $Id: Makefile.in,v 1.1 2000/09/11 14:40:33 art Exp $ +# $KTH: Makefile.in,v 1.3 2000/10/25 07:16:13 lha Exp $ srcdir = @srcdir@ +top_builddir = ../.. VPATH = @srcdir@ CC = @CC@ @@ -91,7 +92,7 @@ clean : mostlyclean: clean distclean: clean - rm -f Makefile config.status + rm -f Makefile realclean: distclean rm -f TAGS diff --git a/usr.sbin/afs/src/appl/afsmgr/afsaclmgr.in b/usr.sbin/afs/src/appl/afsmgr/afsaclmgr.in index e65ee2e8f82..20c45504d41 100644 --- a/usr.sbin/afs/src/appl/afsmgr/afsaclmgr.in +++ b/usr.sbin/afs/src/appl/afsmgr/afsaclmgr.in @@ -7,7 +7,7 @@ ;; ;; -;; $Id: afsaclmgr.in,v 1.1 2000/09/11 14:40:33 art Exp $ +;; $KTH: afsaclmgr.in,v 1.3 1999/10/23 17:49:56 lha Exp $ ;; (use-modules (gtk gtk)) diff --git a/usr.sbin/afs/src/appl/afsutils/Makefile.in b/usr.sbin/afs/src/appl/afsutils/Makefile.in index ed5960e7772..1ef2c4b2014 100644 --- a/usr.sbin/afs/src/appl/afsutils/Makefile.in +++ b/usr.sbin/afs/src/appl/afsutils/Makefile.in @@ -1,6 +1,7 @@ -# $Id: Makefile.in,v 1.1 2000/09/11 14:40:33 art Exp $ +# $KTH: Makefile.in,v 1.15.2.3 2001/10/23 23:47:41 ahltorp Exp $ srcdir = @srcdir@ +top_builddir = ../.. VPATH = @srcdir@ CC = @CC@ @@ -29,6 +30,7 @@ SHELL = /bin/sh CFLAGS = @CFLAGS@ X_CFLAGS = @X_CFLAGS@ +LDFLAGS = @LDFLAGS@ ETAGS = etags MAKEDEPEND = makedepend @@ -47,7 +49,7 @@ INCLUDES = -I$(srcdir)/../.. \ DEFINES = REALCFLAGS = $(INCLUDES) @KRB4_INC_FLAGS@ $(DEFINES) $(CFLAGS) \ - $(X_CFLAGS) @PLWP_INC_FLAGS@ + $(X_CFLAGS) @PLWP_INC_FLAGS@ @INC_roken@ RXKAD_LIBS = @MILKO_RXKAD_LIBS@ KERNEL_INCLUDE = @KERNEL_INCLUDE@ KAFS_LIBS = @AIX_EXTRA_KAFS@ @KAFS_LIBS@ @@ -57,15 +59,14 @@ LIBS = -L../lib -larlalib \ -L../../rx -lrx \ -L../../lwp -llwp @PLWP_LIB_FLAGS@ \ -L../../lib/ko -lko -L../../util -lutil \ - -L../../lib/roken \ + @LIB_roken@ \ $(RXKAD_LIBS) \ $(KAFS_LIBS) \ - $(RXKAD_LIBS) \ - -lroken @LIBS@ + $(RXKAD_LIBS) @LIBS@ LIBDEPENDS = ../../rxdef/librxdefclient.a ../../rx/librx.a ../../lwp/liblwp.a \ - ../../util/libutil.a ../../lib/sl/libsl.a ../../lib/roken/libroken.a \ - ../../lib/ko/libko.a + ../../util/libutil.a ../../lib/sl/libsl.a \ + ../../lib/ko/libko.a ../lib/libarlalib.a PROGS = aklog klog sys tokens unlog up AKLOG_SRCS = aklog.c @@ -107,7 +108,7 @@ install: all e=`echo $$x | sed 's/.*\.\([1-9a-zA-Z]*\)$$/\1/'`; \ f=`echo $$n | sed '$(transform)'`; \ $(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$$e ; \ - $(INSTALL_PROGRAM) $(srcdir)/$$x \ + $(INSTALL_DATA) $(srcdir)/$$x \ $(DESTDIR)$(mandir)/man$$e/$$f.$$e; \ done @@ -160,7 +161,7 @@ clean : mostlyclean: clean distclean: clean - rm -f Makefile config.status + rm -f Makefile realclean: distclean rm -f TAGS diff --git a/usr.sbin/afs/src/appl/afsutils/aklog.1 b/usr.sbin/afs/src/appl/afsutils/aklog.1 index e69ba897790..45bd1e4adc3 100644 --- a/usr.sbin/afs/src/appl/afsutils/aklog.1 +++ b/usr.sbin/afs/src/appl/afsutils/aklog.1 @@ -1,4 +1,4 @@ -.\" $Id: aklog.1,v 1.3 2001/07/25 10:04:57 mpech Exp $ +.\" $KTH: aklog.1,v 1.3 2000/08/06 20:37:05 lha Exp $ .Dd Aug 06, 2000 .Dt AKLOG SECTION .Os Arla diff --git a/usr.sbin/afs/src/appl/afsutils/aklog.c b/usr.sbin/afs/src/appl/afsutils/aklog.c index 1e31fb94a86..9a7705e3b90 100644 --- a/usr.sbin/afs/src/appl/afsutils/aklog.c +++ b/usr.sbin/afs/src/appl/afsutils/aklog.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -41,7 +41,7 @@ #include <config.h> #endif -RCSID("$Id: aklog.c,v 1.1 2000/09/11 14:40:33 art Exp $"); +RCSID("$KTH: aklog.c,v 1.6.2.2 2001/10/03 22:52:44 assar Exp $"); #include "appl_locl.h" #include "kafs.h" @@ -61,7 +61,62 @@ main(int argc, char **argv) static int krb_afslog_uid (const char *cell, const char *realm, uid_t afsid) { - return k_afslog_uid(cell, realm, afsid); + return k_afsklog_uid(cell, realm, afsid); +} +#endif + +#ifndef HAVE_KRB_GET_DEFAULT_PRINCIPAL + +/* stolen from krb4's lib/krb/get_default_principal.c */ + +static int +krb_get_default_principal(char *name, char *instance, char *realm) +{ + char *file; + int ret; + char *p; + + file = tkt_string (); + + ret = krb_get_tf_fullname(file, name, instance, realm); + if(ret == KSUCCESS) + return 0; + + p = getenv("KRB4PRINCIPAL"); + if(p && kname_parse(name, instance, realm, p) == KSUCCESS) + return 1; + +#ifdef HAVE_PWD_H + { + struct passwd *pw; + pw = getpwuid(getuid()); + if(pw == NULL){ + return -1; + } + + strlcpy (name, pw->pw_name, ANAME_SZ); + strlcpy (instance, "", INST_SZ); + krb_get_lrealm(realm, 1); + + if(strcmp(name, "root") == 0) { + p = NULL; +#if defined(HAVE_GETLOGIN) && !defined(POSIX_GETLOGIN) + p = getlogin(); +#endif + if(p == NULL) + p = getenv("USER"); + if(p == NULL) + p = getenv("LOGNAME"); + if(p){ + strlcpy (name, p, ANAME_SZ); + strlcpy (instance, "root", INST_SZ); + } + } + return 1; + } +#else + return -1; +#endif } #endif @@ -182,38 +237,38 @@ get_tokens (const char **cells, } -struct getargs args[] = { - {"cell", 0, arg_string, &arg_cell, - "cell to authenticate to", "cell name", arg_optional}, - {"createuser", 0, arg_flag, &arg_createuser, - "create PTS user in remote cell", NULL, arg_optional}, - {"debug", 0, arg_flag, &arg_debug, - "print debugging information", NULL, arg_optional}, - {"help", 0, arg_flag, &arg_help, - "print help", NULL, arg_optional}, - {"hosts", 0, arg_flag, &arg_hosts, - "print host address information (unimplemented)", NULL, arg_optional}, - {"krbrealm", 0, arg_string, &arg_realm, - "kerberos realm for cell", "kerberos realm", arg_optional}, - {"noprdb", 0, arg_flag, &arg_noprdb, - "don't try to determine AFS ID", NULL, arg_optional}, - {"path", 0, arg_string, &arg_path, - "AFS path to authenticate to", "path", arg_optional}, - {"quiet", 0, arg_flag, &arg_quiet, - "fail silently if no ticket cache", NULL, arg_optional}, - {"unlog", 0, arg_flag, &arg_unlog, - "discard tokens", NULL, arg_optional}, - {"version", 0, arg_flag, &arg_version, - "print version", NULL, arg_optional}, - {"zsubs", 0, arg_flag, &arg_zsubs, +struct agetargs args[] = { + {"cell", 0, aarg_string, &arg_cell, + "cell to authenticate to", "cell name", aarg_optional}, + {"createuser", 0, aarg_flag, &arg_createuser, + "create PTS user in remote cell", NULL, aarg_optional}, + {"debug", 0, aarg_flag, &arg_debug, + "print debugging information", NULL, aarg_optional}, + {"help", 0, aarg_flag, &arg_help, + "print help", NULL, aarg_optional}, + {"hosts", 0, aarg_flag, &arg_hosts, + "print host address information (unimplemented)", NULL, aarg_optional}, + {"krbrealm", 0, aarg_string, &arg_realm, + "kerberos realm for cell", "kerberos realm", aarg_optional}, + {"noprdb", 0, aarg_flag, &arg_noprdb, + "don't try to determine AFS ID", NULL, aarg_optional}, + {"path", 0, aarg_string, &arg_path, + "AFS path to authenticate to", "path", aarg_optional}, + {"quiet", 0, aarg_flag, &arg_quiet, + "fail silently if no ticket cache", NULL, aarg_optional}, + {"unlog", 0, aarg_flag, &arg_unlog, + "discard tokens", NULL, aarg_optional}, + {"version", 0, aarg_flag, &arg_version, + "print version", NULL, aarg_optional}, + {"zsubs", 0, aarg_flag, &arg_zsubs, "update zephyr subscriptions (unimplemented)"}, - {NULL, 0, arg_end, NULL, NULL}, + {NULL, 0, aarg_end, NULL, NULL}, }; static void usage (int exit_code) { - arg_printusage (args, NULL, "<cell or path>", ARG_AFSSTYLE|ARG_USEFIRST); + aarg_printusage (args, NULL, "<cell or path>", AARG_AFSSTYLE|AARG_USEFIRST); exit (exit_code); } @@ -227,10 +282,20 @@ main (int argc, char **argv) const char *cell = NULL; char cellbuf[64]; const char *localcell; + Log_method *method; int optind = 0; int rc; - rc = getarg(args, argc, argv, &optind, ARG_AFSSTYLE|ARG_USEFIRST); + set_progname(argv[0]); + + ports_init(); + method = log_open (get_progname(), "/dev/stderr:notime"); + if (method == NULL) + errx (1, "log_open failed"); + cell_init(0, method); + localcell = cell_getthiscell(); + + rc = agetarg(args, argc, argv, &optind, AARG_AFSSTYLE|AARG_USEFIRST); if(rc && *argv[optind] == '-') { warnx ("Bad argument: %s", argv[optind]); usage (1); @@ -248,15 +313,11 @@ main (int argc, char **argv) if(!k_hasafs()) errx (1, "AFS support is not loaded."); - ports_init(); - cell_init(0); - localcell = cell_getthiscell(); - /* * get the realm and name of the user */ - if (krb_get_default_principal(krb_name, krb_instance, krb_realm)) { + if (krb_get_default_principal(krb_name, krb_instance, krb_realm) < 0) { if (!arg_quiet) warnx ("Could not even figure out who you are"); exit (1); diff --git a/usr.sbin/afs/src/appl/afsutils/klog.1 b/usr.sbin/afs/src/appl/afsutils/klog.1 index e69e6f7c8d2..e3b0a807d4f 100644 --- a/usr.sbin/afs/src/appl/afsutils/klog.1 +++ b/usr.sbin/afs/src/appl/afsutils/klog.1 @@ -1,4 +1,4 @@ -.\" $Id: klog.1,v 1.3 2001/07/25 10:04:57 mpech Exp $ +.\" $KTH: klog.1,v 1.4 2000/08/06 18:12:21 lha Exp $ .\" .Dd July 7, 1999 .Dt KLOG 1 diff --git a/usr.sbin/afs/src/appl/afsutils/klog.c b/usr.sbin/afs/src/appl/afsutils/klog.c index 16ab67b2db5..695a0268743 100644 --- a/usr.sbin/afs/src/appl/afsutils/klog.c +++ b/usr.sbin/afs/src/appl/afsutils/klog.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -42,9 +37,9 @@ Written by Chris Wing - wingc@engin.umich.edu based on examples of AFS code: pts.c (Arla) and kauth.c (KTH-KRB) - Hacked to use getarg by Love Hörnquist-Åstrand <lha@stacken.kth.se> + Hacked to use agetarg by Love Hörnquist-Åstrand <lha@stacken.kth.se> - Hacked to use getarg and still work properly by Chris Wing + Hacked to use agetarg and still work properly by Chris Wing This is a reimplementation of klog from AFS. The following new features have been added: @@ -56,7 +51,7 @@ #include <config.h> #endif -RCSID("$Id: klog.c,v 1.2 2001/07/09 07:04:59 deraadt Exp $"); +RCSID("$KTH: klog.c,v 1.29.2.1 2001/10/03 22:52:01 assar Exp $"); #include "appl_locl.h" #include "klog.h" @@ -77,7 +72,7 @@ static char *arg_principal = NULL; static char *arg_cell = NULL; static char *arg_realm = NULL; static char *arg_password = NULL; -static getarg_strings arg_servers; +static agetarg_strings arg_servers; static char *arg_lifetime = NULL; static int arg_timeout = 0; static int arg_pipe = 0; @@ -247,7 +242,7 @@ int get_afs_token(void) #ifdef HAVE_KRB_AFSLOG_UID rc = krb_afslog_uid(arg_cell, arg_realm, afsid); #else - rc = k_afslog_uid(arg_cell, arg_realm, afsid); + rc = k_afsklog_uid(arg_cell, arg_realm, afsid); #endif if(rc) warnx("Unable to get an AFS token: %s", krb_get_err_text(rc)); @@ -305,6 +300,9 @@ do_timeout (int (*function)(void) ) close(writer); + if (reader >= FD_SETSIZE) + diet (1, "do_timeout(): fd too large"); + /* this is how you set up a select call */ FD_ZERO(&readfds); FD_SET(reader, &readfds); @@ -401,47 +399,47 @@ randfilename(void) dietx (1, "could not create ticket file"); } -struct getargs args[] = { - { "principal", 0, arg_string, &arg_principal, +struct agetargs args[] = { + { "principal", 0, aarg_string, &arg_principal, "principal to obtain token for", - "user name", arg_optional}, - { "password", 0, arg_string, &arg_password, + "user name", aarg_optional}, + { "password", 0, aarg_string, &arg_password, "password to use (NOT RECOMENDED TO USE)", - "AFS password", arg_optional}, - { "servers", 0, arg_strings, &arg_servers, + "AFS password", aarg_optional}, + { "servers", 0, aarg_strings, &arg_servers, "list of servers to contact", - "AFS dbservers", arg_optional}, - { "lifetime", 0, arg_string, &arg_lifetime, + "AFS dbservers", aarg_optional}, + { "lifetime", 0, aarg_string, &arg_lifetime, "lifetime given in hh[:mm[:ss]]", - "hh:mm:ss", arg_optional}, - { "pipe", 0, arg_flag, &arg_pipe, + "hh:mm:ss", aarg_optional}, + { "pipe", 0, aarg_flag, &arg_pipe, "read password from stdin and close stdout", - NULL, arg_optional}, - { "timeout", 0, arg_integer, &arg_timeout, + NULL, aarg_optional}, + { "timeout", 0, aarg_integer, &arg_timeout, "network timeout given in seconds (default is forever)", - "seconds", arg_optional}, - { "setpag", 0, arg_flag, &arg_setpag, + "seconds", aarg_optional}, + { "setpag", 0, aarg_flag, &arg_setpag, "store token in new PAG and spawn a shell", - NULL, arg_optional}, - { "silent", 0, arg_flag, &arg_silent, + NULL, aarg_optional}, + { "silent", 0, aarg_flag, &arg_silent, "close stderr", - NULL, arg_optional}, - { "tmp", 0, arg_flag, &arg_getkrbtgt, + NULL, aarg_optional}, + { "tmp", 0, aarg_flag, &arg_getkrbtgt, "get a Kerberos TGT (possibly overwriting any current one)", - NULL, arg_optional}, - { "cell", 0, arg_string, &arg_cell, + NULL, aarg_optional}, + { "cell", 0, aarg_string, &arg_cell, "cell where to obtain token", - "cell name", arg_optional}, - { "realm", 0, arg_string, &arg_realm, + "cell name", aarg_optional}, + { "realm", 0, aarg_string, &arg_realm, "Kerberos realm to get TGT in (default same as AFS cell)", - "Kerberos realm", arg_optional}, - { "help", 0, arg_flag, &arg_help, "help", - NULL, arg_optional}, - { "version", 0, arg_flag, &arg_version, "print version", - NULL, arg_optional}, - { NULL, 0, arg_generic_string, &arg_kname, "Kerberos identity", - "user@cell", arg_optional}, - { NULL, 0, arg_end, NULL, NULL } + "Kerberos realm", aarg_optional}, + { "help", 0, aarg_flag, &arg_help, "help", + NULL, aarg_optional}, + { "version", 0, aarg_flag, &arg_version, "print version", + NULL, aarg_optional}, + { NULL, 0, aarg_generic_string, &arg_kname, "Kerberos identity", + "user@cell", aarg_optional}, + { NULL, 0, aarg_end, NULL, NULL } }; /* @@ -451,7 +449,7 @@ struct getargs args[] = { static void do_help (int exitval) { - arg_printusage(args, NULL, NULL, ARG_AFSSTYLE); + aarg_printusage(args, NULL, NULL, AARG_AFSSTYLE); exit(exitval); } @@ -479,14 +477,19 @@ main(int argc, char **argv) char prompt[PW_PROMPT_MAX]; int rc; int optind = 0; + Log_method *method; char pwbuf[PASSWD_MAX]; - /* for Rx - Arlalib stuff */ + set_progname (argv[0]); + + method = log_open (get_progname(), "/dev/stderr:notime"); + if (method == NULL) + errx (1, "log_open failed"); + cell_init(0, method); ports_init(); - cell_init(0); /* XXX */ - rc = getarg(args, argc, argv, &optind, ARG_AFSSTYLE); + rc = agetarg(args, argc, argv, &optind, AARG_AFSSTYLE); if(rc) { warnx ("Bad argument: %s", argv[optind]); do_help(1); @@ -658,7 +661,7 @@ main(int argc, char **argv) /* * FIXME: we should also erase the copy in argv[]. * Is it safe to overwrite bits of argv, and is there - * any nice way to do this from the getarg() + * any nice way to do this from the agetarg() * framework? */ int pwlen; @@ -787,7 +790,7 @@ main(int argc, char **argv) shell = pwd->pw_shell; } - execl(shell, shell, (char *)NULL); + execl(shell, shell, NULL); /* the AFS token is useless if the shell exec fails, because it is in a PAG that will soon go away. */ diff --git a/usr.sbin/afs/src/appl/afsutils/klog.ctx b/usr.sbin/afs/src/appl/afsutils/klog.ctx index c9c10d6e185..73b3b296d12 100644 --- a/usr.sbin/afs/src/appl/afsutils/klog.ctx +++ b/usr.sbin/afs/src/appl/afsutils/klog.ctx @@ -1,5 +1,5 @@ # -# $Id: klog.ctx,v 1.1 2000/09/11 14:40:33 art Exp $ +# $KTH: klog.ctx,v 1.1 2000/06/01 18:38:34 lha Exp $ # %name description diff --git a/usr.sbin/afs/src/appl/afsutils/klog.h b/usr.sbin/afs/src/appl/afsutils/klog.h index 1dcdea258bc..4b18b2c6cc0 100644 --- a/usr.sbin/afs/src/appl/afsutils/klog.h +++ b/usr.sbin/afs/src/appl/afsutils/klog.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: klog.h,v 1.1 2000/09/11 14:40:33 art Exp $ */ +/* $KTH: klog.h,v 1.4 2000/10/03 00:06:24 lha Exp $ */ /* Function prototypes for klog.c */ diff --git a/usr.sbin/afs/src/appl/afsutils/sys.c b/usr.sbin/afs/src/appl/afsutils/sys.c index 1bf5cb0f899..42d6a2a554f 100644 --- a/usr.sbin/afs/src/appl/afsutils/sys.c +++ b/usr.sbin/afs/src/appl/afsutils/sys.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -44,7 +39,7 @@ #include <config.h> #endif -RCSID("$Id: sys.c,v 1.1 2000/09/11 14:40:33 art Exp $"); +RCSID("$KTH: sys.c,v 1.3 2000/10/03 00:06:30 lha Exp $"); #include "appl_locl.h" diff --git a/usr.sbin/afs/src/appl/afsutils/tokens.1 b/usr.sbin/afs/src/appl/afsutils/tokens.1 index 4739a78d75f..1e3a2538575 100644 --- a/usr.sbin/afs/src/appl/afsutils/tokens.1 +++ b/usr.sbin/afs/src/appl/afsutils/tokens.1 @@ -1,4 +1,4 @@ -.\" $Id: tokens.1,v 1.3 2001/07/25 10:04:57 mpech Exp $ +.\" $KTH: tokens.1,v 1.3 2000/08/06 17:11:47 lha Exp $ .\" .Dd July 7, 1999 .Dt TOKENS 1 diff --git a/usr.sbin/afs/src/appl/afsutils/tokens.c b/usr.sbin/afs/src/appl/afsutils/tokens.c index 8be36102348..334705b27b8 100644 --- a/usr.sbin/afs/src/appl/afsutils/tokens.c +++ b/usr.sbin/afs/src/appl/afsutils/tokens.c @@ -24,7 +24,7 @@ #include "appl_locl.h" -RCSID("$Id: tokens.c,v 1.1 2000/09/11 14:40:34 art Exp $"); +RCSID("$KTH: tokens.c,v 1.9 2000/09/02 12:55:56 lha Exp $"); #include "tokens.h" @@ -52,22 +52,22 @@ static int got_tokens = 0; static int got_anything = 0; -/* arguments for getarg() */ +/* arguments for agetarg() */ -struct getargs args[] = { - { "athena", 0, arg_flag, &arg_athena, +struct agetargs args[] = { + { "athena", 0, aarg_flag, &arg_athena, "generate 'klist' style output instead of AFS style", - NULL, arg_optional}, - { "verbose", 'v', arg_flag, &arg_verbose, + NULL, aarg_optional}, + { "verbose", 'v', aarg_flag, &arg_verbose, "generate verbose output", - NULL, arg_optional}, - { "help", 0, arg_flag, &arg_help, + NULL, aarg_optional}, + { "help", 0, aarg_flag, &arg_help, "display this message", - NULL, arg_optional}, - { "version", 0, arg_flag, &arg_version, + NULL, aarg_optional}, + { "version", 0, aarg_flag, &arg_version, "print version", - NULL, arg_optional}, - { NULL, 0, arg_end, NULL, NULL } + NULL, aarg_optional}, + { NULL, 0, aarg_end, NULL, NULL } }; /* @@ -80,7 +80,7 @@ struct getargs args[] = { static void do_help(int exitval) { - arg_printusage(args, NULL, NULL, ARG_AFSSTYLE); + aarg_printusage(args, NULL, NULL, AARG_AFSSTYLE); exit(exitval); } @@ -225,7 +225,7 @@ int main(int argc, char **argv) errx (1, "kerberos support isn't compiled in"); #endif - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { warnx ("Bad argument: %s", argv[optind]); do_help(1); } diff --git a/usr.sbin/afs/src/appl/afsutils/unlog.1 b/usr.sbin/afs/src/appl/afsutils/unlog.1 index 2882db83b88..2d663be455b 100644 --- a/usr.sbin/afs/src/appl/afsutils/unlog.1 +++ b/usr.sbin/afs/src/appl/afsutils/unlog.1 @@ -1,4 +1,4 @@ -.\" $Id: unlog.1,v 1.3 2001/07/25 10:04:57 mpech Exp $ +.\" $KTH: unlog.1,v 1.3 2000/08/06 17:22:33 lha Exp $ .\" .Dd July 7, 1999 .Dt UNLOG 1 diff --git a/usr.sbin/afs/src/appl/afsutils/unlog.c b/usr.sbin/afs/src/appl/afsutils/unlog.c index 568627a66d8..3c65f0adcff 100644 --- a/usr.sbin/afs/src/appl/afsutils/unlog.c +++ b/usr.sbin/afs/src/appl/afsutils/unlog.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -47,7 +42,7 @@ #include "appl_locl.h" -RCSID("$Id: unlog.c,v 1.1 2000/09/11 14:40:34 art Exp $"); +RCSID("$KTH: unlog.c,v 1.9 2000/10/03 00:06:36 lha Exp $"); #include "unlog.h" @@ -67,7 +62,7 @@ static int lost_tokens = 0; static int unlog_version = 0; static int unlog_help = 0; -static getarg_strings unlog_cells, unlog_cells_no_argument; +static agetarg_strings unlog_cells, unlog_cells_no_argument; /* * Various helper functions that we call @@ -158,18 +153,18 @@ void restoretoken(struct token *tok) * options to program */ -struct getargs args[] = { - { "cell", 0, arg_strings, &unlog_cells, +struct agetargs args[] = { + { "cell", 0, aarg_strings, &unlog_cells, "only remove tokens for this cell or cells", - "AFS cell name(s)", arg_optional}, - { NULL, 0, arg_generic_string, &unlog_cells_no_argument, + "AFS cell name(s)", aarg_optional}, + { NULL, 0, aarg_generic_string, &unlog_cells_no_argument, "only remove tokens for this cell or cells", - "AFS cell name(s)", arg_optional}, - { "help", 0, arg_flag, &unlog_help, "help", - NULL, arg_optional}, - { "version", 0, arg_flag, &unlog_version, "print version", - NULL, arg_optional}, - { NULL, 0, arg_end, NULL, NULL } + "AFS cell name(s)", aarg_optional}, + { "help", 0, aarg_flag, &unlog_help, "help", + NULL, aarg_optional}, + { "version", 0, aarg_flag, &unlog_version, "print version", + NULL, aarg_optional}, + { NULL, 0, aarg_end, NULL, NULL } }; /* @@ -179,7 +174,7 @@ struct getargs args[] = { static void do_help(int exitval) { - arg_printusage(args, NULL, NULL, ARG_AFSSTYLE); + aarg_printusage(args, NULL, NULL, AARG_AFSSTYLE); exit(exitval); } @@ -192,7 +187,7 @@ main(int argc, char **argv) { int i, j, optind = 0; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { warnx("Bad argument: %s", argv[optind]); do_help(1); } diff --git a/usr.sbin/afs/src/appl/afsutils/up.c b/usr.sbin/afs/src/appl/afsutils/up.c index c82ef097e99..0e1dce86e4f 100644 --- a/usr.sbin/afs/src/appl/afsutils/up.c +++ b/usr.sbin/afs/src/appl/afsutils/up.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include "appl_locl.h" #include <kafs.h> -RCSID("$Id: up.c,v 1.1 2000/09/11 14:40:34 art Exp $"); +RCSID("$KTH: up.c,v 1.6 2000/10/03 00:06:41 lha Exp $"); static void do_help (int exitval); static int copyacl (char *from, char *to); @@ -52,28 +47,28 @@ static int arg_force = 0; static int arg_backup = 0; static int arg_savedate = 0; -struct getargs args[] = { - { NULL , 'h', arg_flag, &arg_help, - "verbose", NULL, arg_optional}, - { NULL , 'v', arg_flag, &arg_verbose, - "verbose", NULL, arg_optional}, - { NULL , '1', arg_flag, &arg_one, - "top level only", NULL, arg_optional}, - { NULL , 'f', arg_flag, &arg_force, - "force", NULL, arg_optional}, - { NULL , 'r', arg_flag, &arg_backup, - "verbose", NULL, arg_optional}, - { NULL , 'x', arg_flag, &arg_savedate, - "verbose", NULL, arg_optional}, - { NULL, 0, arg_end, NULL, NULL } +struct agetargs args[] = { + { NULL , 'h', aarg_flag, &arg_help, + "verbose", NULL, aarg_optional}, + { NULL , 'v', aarg_flag, &arg_verbose, + "verbose", NULL, aarg_optional}, + { NULL , '1', aarg_flag, &arg_one, + "top level only", NULL, aarg_optional}, + { NULL , 'f', aarg_flag, &arg_force, + "force", NULL, aarg_optional}, + { NULL , 'r', aarg_flag, &arg_backup, + "verbose", NULL, aarg_optional}, + { NULL , 'x', aarg_flag, &arg_savedate, + "verbose", NULL, aarg_optional}, + { NULL, 0, aarg_end, NULL, NULL } }; static void do_help (int exitval) { - arg_printusage(args, NULL, - "<from-directory> <to-directory>", - ARG_SHORTARG); + aarg_printusage(args, NULL, + "<from-directory> <to-directory>", + AARG_SHORTARG); exit(exitval); } @@ -138,7 +133,7 @@ main(int argc, char **argv) char *todir; int ret; - if (getarg (args, argc, argv, &optind, ARG_SHORTARG)) + if (agetarg (args, argc, argv, &optind, AARG_SHORTARG)) do_help(1); if (arg_help) diff --git a/usr.sbin/afs/src/appl/amon/Makefile.in b/usr.sbin/afs/src/appl/amon/Makefile.in index 1125f05dfa0..ea2e8338720 100644 --- a/usr.sbin/afs/src/appl/amon/Makefile.in +++ b/usr.sbin/afs/src/appl/amon/Makefile.in @@ -1,6 +1,7 @@ -# $Id: Makefile.in,v 1.1 2000/09/11 14:40:34 art Exp $ +# $KTH: Makefile.in,v 1.8.2.1 2001/05/28 11:31:55 mattiasa Exp $ srcdir = @srcdir@ +top_builddir = ../.. VPATH = @srcdir@ CC = @CC@ @@ -44,7 +45,7 @@ INCLUDES = -I$(srcdir)/../lib \ DEFINES = REALCFLAGS = $(INCLUDES) @KRB4_INC_FLAGS@ $(DEFINES) $(CFLAGS) \ - $(X_CFLAGS) @PLWP_INC_FLAGS@ + $(X_CFLAGS) @PLWP_INC_FLAGS@ @INC_roken@ RXKAD_LIBS = @MILKO_RXKAD_LIBS@ KERNEL_INCLUDE = @KERNEL_INCLUDE@ KAFS_LIBS = @AIX_EXTRA_KAFS@ @KAFS_LIBS@ @@ -56,18 +57,17 @@ LIBS = -L../lib -larlalib \ -L../../lib/ko -lko -L../../util -lutil \ -L../../lib/sl -lsl \ @LIB_readline@ \ - -L../../lib/roken \ $(RXKAD_LIBS) \ $(KAFS_LIBS) \ $(RXKAD_LIBS) \ - -lroken @LIBS@ + @LIB_roken@ @LIBS@ AMON_LIBS = @X_LIBS@ \ -lXaw -lXt -lXmu -lXext @X_PRE_LIBS@ -lX11 @X_EXTRA_LIBS@ LIBDEPENDS = ../../rxdef/librxdefclient.a ../../rx/librx.a ../../lwp/liblwp.a \ - ../../util/libutil.a ../../lib/sl/libsl.a ../../lib/roken/libroken.a \ - ../../lib/ko/libko.a + ../../util/libutil.a ../../lib/sl/libsl.a \ + ../../lib/ko/libko.a ../lib/libarlalib.a X_PROGS_BIN = amon PROGS = @MAKE_X_PROGS_BIN@ @@ -87,7 +87,7 @@ install: all PROG_BIN='$(APPL_BIN)'; for x in $$PROG_BIN; do \ f=`echo $$x | sed '$(transform)'`; \ $(INSTALL_PROGRAM) $$x $(DESTDIR)$(bindir)/$$f; \ - done ;\ + done ; uninstall: PROG_BIN='$(APPL_BIN)'; for x in $$PROG_BIN; do \ @@ -115,7 +115,7 @@ clean : mostlyclean: clean distclean: clean - rm -f Makefile config.status + rm -f Makefile realclean: distclean rm -f TAGS diff --git a/usr.sbin/afs/src/appl/amon/amon.c b/usr.sbin/afs/src/appl/amon/amon.c index 0c7ad8c7b34..8b91bbef6d3 100644 --- a/usr.sbin/afs/src/appl/amon/amon.c +++ b/usr.sbin/afs/src/appl/amon/amon.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -59,7 +54,7 @@ #include "appl_locl.h" -RCSID("$Id: amon.c,v 1.1 2000/09/11 14:40:34 art Exp $"); +RCSID("$KTH: amon.c,v 1.9 2000/10/03 00:06:46 lha Exp $"); #if 0 static XrmOptionDescRec options[] = {}; diff --git a/usr.sbin/afs/src/appl/asrvutil/Makefile.in b/usr.sbin/afs/src/appl/asrvutil/Makefile.in index bdaeeee23f3..bda594261ae 100644 --- a/usr.sbin/afs/src/appl/asrvutil/Makefile.in +++ b/usr.sbin/afs/src/appl/asrvutil/Makefile.in @@ -1,6 +1,7 @@ -# $Id: Makefile.in,v 1.1 2000/09/11 14:40:34 art Exp $ +# $KTH: Makefile.in,v 1.6.2.1 2001/05/28 11:32:00 mattiasa Exp $ srcdir = @srcdir@ +top_builddir = ../.. VPATH = @srcdir@ CC = @CC@ @@ -40,7 +41,8 @@ INCLUDES = -I$(srcdir)/../.. \ $(KERNEL_INCLUDE) \ -I$(srcdir)/../../xfs/include \ -I$(srcdir)/../../arlad \ - $(RXKADINC) + @INC_roken@ \ + $(RXKADINC) DEFINES = REALCFLAGS = $(INCLUDES) @KRB4_INC_FLAGS@ $(DEFINES) $(CFLAGS) \ @@ -56,16 +58,15 @@ LIBS = -L../lib -larlalib \ -L../../lwp -llwp @PLWP_LIB_FLAGS@ \ -L../../lib/ko -lko -L../../util -lutil \ -L../../lib/sl -lsl \ - -L../../lib/roken \ $(READLINE_lib) \ $(RXKAD_LIBS) \ $(KAFS_LIBS) \ $(RXKAD_LIBS) \ - -lroken @LIBS@ + @ROKEN@ @LIBS@ LIBDEPENDS = ../../rxdef/librxdefclient.a ../../rx/librx.a ../../lwp/liblwp.a \ ../../util/libutil.a ../../lib/sl/libsl.a ../../lib/roken/libroken.a \ - ../../lib/ko/libko.a + ../../lib/ko/libko.a ../lib/libarlalib.a PROGS = asrvutil ASRVUTIL_SRCS = asrvutil.c @@ -113,7 +114,7 @@ clean : mostlyclean: clean distclean: clean - rm -f Makefile config.status + rm -f Makefile realclean: distclean rm -f TAGS diff --git a/usr.sbin/afs/src/appl/asrvutil/asrvutil.c b/usr.sbin/afs/src/appl/asrvutil/asrvutil.c index 0a41e76f3c0..d4f9a7f6aad 100644 --- a/usr.sbin/afs/src/appl/asrvutil/asrvutil.c +++ b/usr.sbin/afs/src/appl/asrvutil/asrvutil.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -42,7 +37,7 @@ #include <ka.cs.h> #include <err.h> -RCSID("$Id: asrvutil.c,v 1.1 2000/09/11 14:40:34 art Exp $"); +RCSID("$KTH: asrvutil.c,v 1.7 2000/10/03 00:06:52 lha Exp $"); static int help_cmd (int argc, char **argv); @@ -173,7 +168,7 @@ get_cmd (int argc, char **argv) char *cell = (char *) cell_getthiscell(); int noauth = 0; - static struct getargs get_args[] = { + static struct agetargs get_args[] = { {"name", 0, arg_string, NULL, "what name to use", NULL}, {"instance", 0, arg_string, NULL, "what instance to use", @@ -192,7 +187,7 @@ get_cmd (int argc, char **argv) arg->value = &cell; arg++; arg->value = &noauth; arg++; - if (getarg (get_args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (getarg (get_args, argc, argv, &optind, AARG_AFSSTYLE)) { get_usage(); return 0; } @@ -318,8 +313,13 @@ main (int argc, char **argv) { int ret; + set_progname(argv[0]); + + method = log_open (get_progname(), "/dev/stderr:notime"); + if (method == NULL) + errx (1, "log_open failed"); + cell_init(0, method); ports_init(); - cell_init(0); /* XXX */ if(argc > 1) { ret = sl_command(cmds, argc - 1, argv + 1); diff --git a/usr.sbin/afs/src/appl/bos/Makefile.in b/usr.sbin/afs/src/appl/bos/Makefile.in index 8e3127cf153..a4386b6471b 100644 --- a/usr.sbin/afs/src/appl/bos/Makefile.in +++ b/usr.sbin/afs/src/appl/bos/Makefile.in @@ -1,6 +1,7 @@ -# $Id: Makefile.in,v 1.1 2000/09/11 14:40:35 art Exp $ +# $KTH: Makefile.in,v 1.10.2.2 2001/10/23 23:49:18 ahltorp Exp $ srcdir = @srcdir@ +top_builddir = ../.. VPATH = @srcdir@ CC = @CC@ @@ -16,10 +17,13 @@ exec_prefix = @exec_prefix@ libdir = @libdir@ libexecdir = @libexecdir@ bindir = @bindir@ +mandir = @mandir@ + transform = @program_transform_name@ EXECSUFFIX = @EXECSUFFIX@ APPL_BIN = bos +MANPAGES = bos.8 DEFS = @DEFS@ @@ -27,6 +31,7 @@ SHELL = /bin/sh CFLAGS = @CFLAGS@ X_CFLAGS = @X_CFLAGS@ +LDFLAGS = @LDFLAGS@ ETAGS = etags MAKEDEPEND = makedepend @@ -40,7 +45,8 @@ INCLUDES = -I$(srcdir)/../.. \ $(KERNEL_INCLUDE) \ -I$(srcdir)/../../xfs/include \ -I$(srcdir)/../../arlad \ - $(RXKADINC) + $(RXKADINC) \ + @INC_roken@ DEFINES = REALCFLAGS = $(INCLUDES) @KRB4_INC_FLAGS@ $(DEFINES) $(CFLAGS) \ @@ -56,16 +62,15 @@ LIBS = -L../lib -larlalib \ -L../../lwp -llwp @PLWP_LIB_FLAGS@ \ -L../../lib/ko -lko -L../../util -lutil \ -L../../lib/sl -lsl \ - -L../../lib/roken \ $(READLINE_lib) \ + @LIB_roken@ \ $(RXKAD_LIBS) \ $(KAFS_LIBS) \ - $(RXKAD_LIBS) \ - -lroken @LIBS@ + $(RXKAD_LIBS) @LIBS@ LIBDEPENDS = ../../rxdef/librxdefclient.a ../../rx/librx.a ../../lwp/liblwp.a \ - ../../util/libutil.a ../../lib/sl/libsl.a ../../lib/roken/libroken.a \ - ../../lib/ko/libko.a + ../../util/libutil.a ../../lib/sl/libsl.a \ + ../../lib/ko/libko.a ../lib/libarlalib.a PROGS = bos BOS_SRCS = bos.c bos_status.c bos_adduser.c bos_getrestart.c bos_listhosts.c bos_listusers.c @@ -86,11 +91,25 @@ install: all f=`echo $$x | sed '$(transform)'`; \ $(INSTALL_PROGRAM) $$x $(DESTDIR)$(bindir)/$$f; \ done ;\ + MANPAGES='$(MANPAGES)'; for x in $$MANPAGES; do \ + n=`echo $$x | sed 's/\(.*\)\.[1-9a-zA-Z]*$$/\1/'`; \ + e=`echo $$x | sed 's/.*\.\([1-9a-zA-Z]*\)$$/\1/'`; \ + f=`echo $$n | sed '$(transform)'`; \ + $(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$$e ; \ + $(INSTALL_DATA) $(srcdir)/$$x \ + $(DESTDIR)$(mandir)/man$$e/$$f.$$e; \ + done uninstall: PROG_BIN='$(APPL_BIN)'; for x in $$PROG_BIN; do \ f=`echo $$x | sed '$(transform)'`; \ rm -f $(DESTDIR)$(bindir)/$$f; \ + done ;\ + MANPAGES='$(MANPAGES)'; for x in $$MANPAGES; do \ + n=`echo $$x | sed 's/\(.*\)\.[1-9a-zA-Z]*$$/\1/'`; \ + e=`echo $$x | sed 's/.*\.\([1-9a-zA-Z]*\)$$/\1/'`; \ + f=`echo $$n | sed '$(transform)'`; \ + rm -rf $(DESTDIR)$(mandir)/$$f.$$e; \ done bos: $(BOS_OBJS) $(LIBDEPENDS) @@ -113,7 +132,7 @@ clean : mostlyclean: clean distclean: clean - rm -f Makefile config.status + rm -f Makefile realclean: distclean rm -f TAGS diff --git a/usr.sbin/afs/src/appl/bos/bos.c b/usr.sbin/afs/src/appl/bos/bos.c index 238c99d95b1..aab1932d598 100644 --- a/usr.sbin/afs/src/appl/bos/bos.c +++ b/usr.sbin/afs/src/appl/bos/bos.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include <sl.h> #include "bos_local.h" -RCSID("$Id: bos.c,v 1.1 2000/09/11 14:40:35 art Exp $"); +RCSID("$KTH: bos.c,v 1.7 2000/10/03 00:06:57 lha Exp $"); int bos_interactive = 0; @@ -55,38 +50,39 @@ static int apropos_cmd(int argc, char **argv); */ static SL_cmd cmds[] = { - {"addhost", empty_cmd, "not yet implemented"}, - {"addkey", empty_cmd, "not yet implemented"}, - {"adduser", bos_adduser, "add users to super-user list"}, - {"apropos", apropos_cmd, "apropos help"}, - {"create", empty_cmd, "not yet implemented"}, - {"delete", empty_cmd, "not yet implemented"}, - {"exec", empty_cmd, "not yet implemented"}, - {"exit", quit_cmd, "exit interactive mode"}, - {"getdate", empty_cmd, "not yet implemented"}, - {"getlog", empty_cmd, "not yet implemented"}, - {"getrestart",bos_getrestart, "get restart times"}, - {"help", help_cmd, "print help"}, - {"install", empty_cmd, "not yet implemented"}, - {"listhosts", bos_listhosts, "list VLDB-servers"}, - {"listkeys", empty_cmd, "not yet implemented"}, - {"listusers", bos_listusers, "list super-users"}, - {"prune", empty_cmd, "not yet implemented"}, - {"removehost", empty_cmd, "not yet implemented"}, - {"removekey", empty_cmd, "not yet implemented"}, - {"removeuser", empty_cmd, "not yet implemented"}, - {"restart", empty_cmd, "not yet implemented"}, - {"salvage", empty_cmd, "not yet implemented"}, - {"setauth", empty_cmd, "not yet implemented"}, - {"setcellname", empty_cmd, "not yet implemented"}, - {"setrestart", empty_cmd, "not yet implemented"}, - {"shutdown", empty_cmd, "not yet implemented"}, - {"start", empty_cmd, "not yet implemented"}, - {"status", bos_status, "Show volume server transactions"}, - {"stop", empty_cmd, "not yet implemented"}, - {"uninstall", empty_cmd, "not yet implemented"}, - {"quit", quit_cmd, "exit interactive mode"}, - {NULL} + {"addhost", empty_cmd, "not yet implemented"}, + {"addkey", empty_cmd, "not yet implemented"}, + {"adduser", bos_adduser, "add users to super-user list"}, + {"apropos", apropos_cmd, "apropos help"}, + {"create", empty_cmd, "not yet implemented"}, + {"delete", empty_cmd, "not yet implemented"}, + {"exec", empty_cmd, "not yet implemented"}, + {"exit", quit_cmd, "exit interactive mode"}, + {"getdate", empty_cmd, "not yet implemented"}, + {"getlog", empty_cmd, "not yet implemented"}, + {"getrestart", bos_getrestart, "get restart times"}, + {"help", help_cmd, "print help"}, + {"install", empty_cmd, "not yet implemented"}, + {"listhosts", bos_listhosts, "list VLDB-servers"}, + {"listkeys", empty_cmd, "not yet implemented"}, + {"listusers", bos_listusers, "list super-users"}, + {"prune", empty_cmd, "not yet implemented"}, + {"removehost", empty_cmd, "not yet implemented"}, + {"removekey", empty_cmd, "not yet implemented"}, + {"removeuser", empty_cmd, "not yet implemented"}, + {"restart", empty_cmd, "not yet implemented"}, + {"salvage", empty_cmd, "not yet implemented"}, + {"setauth", empty_cmd, "not yet implemented"}, + {"setcellname", empty_cmd, "not yet implemented"}, + {"setrestart", empty_cmd, "not yet implemented"}, + {"shutdown", empty_cmd, "not yet implemented"}, + {"start", empty_cmd, "not yet implemented"}, + {"status", bos_status, + "Show volume server transactions"}, + {"stop", empty_cmd, "not yet implemented"}, + {"uninstall", empty_cmd, "not yet implemented"}, + {"quit", quit_cmd, "exit interactive mode"}, + {NULL} }; /* @@ -96,8 +92,8 @@ static SL_cmd cmds[] = { static int empty_cmd(int argc, char **argv) { - printf("%s%s has not been implemented yet!\n", PROGNAME, argv[0]); - return 0; + printf("%s%s has not been implemented yet!\n", PROGNAME, argv[0]); + return 0; } /* @@ -107,8 +103,8 @@ empty_cmd(int argc, char **argv) static int quit_cmd(int argc, char **argv) { - printf("exiting\n"); - return 1; + printf("exiting\n"); + return 1; } /* @@ -118,8 +114,8 @@ quit_cmd(int argc, char **argv) static int help_cmd(int argc, char **argv) { - sl_help(cmds, argc, argv); - return 0; + sl_help(cmds, argc, argv); + return 0; } /* @@ -129,13 +125,13 @@ help_cmd(int argc, char **argv) static int apropos_cmd(int argc, char **argv) { - if (argc == 0) { - fprintf (stderr, "apropos: missing topic"); + if (argc == 0) { + fprintf (stderr, "apropos: missing topic"); + return 0; + } + + sl_apropos(cmds, argv[1]); return 0; - } - - sl_apropos(cmds, argv[1]); - return 0; } @@ -146,18 +142,24 @@ apropos_cmd(int argc, char **argv) int main(int argc, char **argv) { - int ret = 0; + Log_method *method; + int ret = 0; + + set_progname(argv[0]); + + method = log_open (get_progname(), "/dev/stderr:notime"); + if (method == NULL) + errx (1, "log_open failed"); + cell_init(0, method); + ports_init(); - cell_init(0); - ports_init(); - - if (argc > 1) - ret = sl_command(cmds, argc - 1, argv + 1); - else { - bos_interactive = 1; - printf("bos - an arla tool for administrating AFS-servers.\n"); - printf("Type \"help\" to get a list of commands.\n"); - ret = sl_loop(cmds, __progname": "); - } - return ret; + if (argc > 1) + ret = sl_command(cmds, argc - 1, argv + 1); + else { + bos_interactive = 1; + printf("bos - an arla tool for administrating AFS-servers.\n"); + printf("Type \"help\" to get a list of commands.\n"); + ret = sl_loop(cmds, __progname": "); + } + return ret; } diff --git a/usr.sbin/afs/src/appl/bos/bos_adduser.c b/usr.sbin/afs/src/appl/bos/bos_adduser.c index 7e2283d16e6..5d80e278a64 100644 --- a/usr.sbin/afs/src/appl/bos/bos_adduser.c +++ b/usr.sbin/afs/src/appl/bos/bos_adduser.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -43,44 +38,49 @@ #include <bos.cs.h> -RCSID("$Id: bos_adduser.c,v 1.1 2000/09/11 14:40:35 art Exp $"); +RCSID("$KTH: bos_adduser.c,v 1.6 2000/10/03 00:07:02 lha Exp $"); static int adduser(const char *cell, const char *host, const char *user, - int noauth, int localauth, int verbose) + int noauth, int localauth, int verbose) { - struct rx_connection *connvolser = NULL; - int error; - connvolser = arlalib_getconnbyname(cell, - host, - afsbosport, - BOS_SERVICE_ID, - arlalib_getauthflag(noauth,localauth,0,0)); - if (connvolser == NULL) - return -1; - - printf ("65 %s on %s in %s\n", user, host, cell); - if (( error = BOZO_AddSUser(connvolser, user)) == 0) { - printf ("67\n"); - printf ("bos: User %s added to the UserList on server %s\n", user, host); - } - switch (error) { - case BZACCESS: - printf ("bos: You are not allowed to add the user %s to the userlist on server %s\n", user,host); - break; - case EEXIST: - printf ("bos: User %s alredy exists on the userlist on host %s\n", user, host); - break; - case EIO: - printf ("bos: the UserList-file could not be opened or closed on server %s\n", host); - break; - default: - printf("bos: GetStat failed with: %s (%d)\n",koerr_gettext(error),error); + struct rx_connection *conn = NULL; + int error; - } + conn = arlalib_getconnbyname(cell, + host, + afsbosport, + BOS_SERVICE_ID, + arlalib_getauthflag(noauth, localauth,0,0)); + if (conn == NULL) + return -1; + + error = BOZO_AddSUser(conn, user); + switch (error) { + case BZACCESS: + printf ("bos adduser: You are not allowed to add the user %s " + "to the userlist on server %s\n", user, host); + break; + case EEXIST: + printf ("bos adduser: User %s alredy exists on the userlist " + "on host %s\n", user, host); + break; + case EIO: + printf ("bos adduser: the UserList-file could not be opened or " + "closed on server %s\n", host); + break; + case 0: + printf ("bos adduser: User %s added to the UserList on " + "server %s\n", user, host); + break; + default: + printf("bos adduser: GetStat failed with: %s (%d)\n", + koerr_gettext(error), error); + break; + } - arlalib_destroyconn(connvolser); - return 0; + arlalib_destroyconn(conn); + return 0; } @@ -92,49 +92,49 @@ static int noauth; static int localauth; static int verbose; -static struct getargs args[] = { - {"server", 0, arg_string, &server, "server", NULL, arg_mandatory}, - {"user", 0, arg_string, &user, "user", NULL, arg_mandatory}, - {"cell", 0, arg_string, &cell, "cell", NULL}, - {"noauth", 0, arg_flag, &noauth, "do not authenticate", NULL}, - {"local", 0, arg_flag, &localauth, "localauth"}, - {"verbose", 0, arg_flag, &verbose, "be verbose", NULL}, - {"help", 0, arg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL, NULL, NULL} +static struct agetargs args[] = { + {"server", 0, aarg_string, &server, "server", NULL, aarg_mandatory}, + {"user", 0, aarg_string, &user, "user", NULL, aarg_mandatory}, + {"cell", 0, aarg_string, &cell, "cell", NULL}, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, + {"local", 0, aarg_flag, &localauth, "localauth"}, + {"verbose", 0, aarg_flag, &verbose, "be verbose", NULL}, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, + {NULL, 0, aarg_end, NULL, NULL, NULL} }; static void usage (void) { - arg_printusage (args, "bos adduser", "", ARG_AFSSTYLE); + aarg_printusage (args, "bos adduser", "", AARG_AFSSTYLE); } int bos_adduser(int argc, char **argv) { - int optind = 0; - - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { - usage (); - return 0; - } + int optind = 0; + + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { + usage (); + return 0; + } + + if (helpflag) { + usage (); + return 0; + } + + argc -= optind; + argv += optind; + + if (server == NULL) { + printf ("bos adduser: missing -server\n"); + return 0; + } + + if (cell == NULL) + cell = cell_getcellbyhost (server); - if (helpflag) { - usage (); + adduser (cell, server, user, noauth, localauth, verbose); return 0; - } - - argc -= optind; - argv += optind; - - if (server == NULL) { - printf ("bos adduser: missing -server\n"); - return 0; - } - - if (cell == NULL) - cell = cell_getcellbyhost (server); - printf ("3333 %s\n", cell); - adduser (cell, server, user, noauth, localauth, verbose); - return 0; } diff --git a/usr.sbin/afs/src/appl/bos/bos_getrestart.c b/usr.sbin/afs/src/appl/bos/bos_getrestart.c index c39236cf47d..8799e9dc0bd 100644 --- a/usr.sbin/afs/src/appl/bos/bos_getrestart.c +++ b/usr.sbin/afs/src/appl/bos/bos_getrestart.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -41,38 +36,48 @@ #include "bos_local.h" #include <bos.h> #include <bos.cs.h> -/* #include <time.h> we schould .... */ -RCSID("$Id: bos_getrestart.c,v 1.1 2000/09/11 14:40:35 art Exp $"); +RCSID("$KTH: bos_getrestart.c,v 1.6 2000/10/03 00:07:07 lha Exp $"); static int printrestart(const char *cell, const char *host, - int noauth, int localauth, int verbose) + int noauth, int localauth, int verbose) { - struct rx_connection *connvolser = NULL; - struct bozo_netKTime time; - int error; - - connvolser = arlalib_getconnbyname(cell, - host, - afsbosport, - BOS_SERVICE_ID, - arlalib_getauthflag(noauth, - localauth,0,0)); - - if (connvolser == NULL) - return -1; - - if (( error = BOZO_GetRestartTime(connvolser, 1, &time)) == 0) { - printf ("Server %s restarts at %02d:%02d:%02d at day %d\n", host, time.hour, time.min, time.sec, time.day); - - } - if (( error = BOZO_GetRestartTime(connvolser, 2, &time)) == 0) { - printf ("Server %s restarts for new binaries at %02d:%02d:%02d at day %d\n", host, time.hour, time.min, time.sec, time.day); - } - - arlalib_destroyconn(connvolser); - return 0; + struct rx_connection *conn; + struct bozo_netKTime time; + int error; + + conn = arlalib_getconnbyname(cell, + host, + afsbosport, + BOS_SERVICE_ID, + arlalib_getauthflag(noauth, localauth,0,0)); + + if (conn == NULL) { + printf ("bos restart: failed to open connection to %s\n", host); + return 0; + } + + error = BOZO_GetRestartTime(conn, BOZO_RESTARTTIME_GENERAL, &time); + if (error) { + printf("bos: GetRestartTime(GENERAL) failed with: %s (%d)\n", + koerr_gettext(error), error); + return 0; + } + printf ("Server %s restarts at %02d:%02d:%02d at day %d\n", + host, time.hour, time.min, time.sec, time.day); + + error = BOZO_GetRestartTime(conn, BOZO_RESTARTTIME_NEWBIN, &time); + if (error) { + printf("bos: GetRestartTime(NEWBIN) failed with: %s (%d)\n", + koerr_gettext(error), error); + return 0; + } + printf ("Server %s restarts for new binaries at %02d:%02d:%02d at day %d\n", + host, time.hour, time.min, time.sec, time.day); + + arlalib_destroyconn(conn); + return 0; } @@ -83,48 +88,48 @@ static int noauth; static int localauth; static int verbose; -static struct getargs args[] = { - {"server", 0, arg_string, &server, "server", NULL, arg_mandatory}, - {"cell", 0, arg_string, &cell, "cell", NULL}, - {"noauth", 0, arg_flag, &noauth, "do not authenticate", NULL}, - {"local", 0, arg_flag, &localauth, "localauth"}, - {"verbose", 0, arg_flag, &verbose, "be verbose", NULL}, - {"help", 0, arg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL, NULL, NULL} +static struct agetargs args[] = { + {"server", 0, aarg_string, &server, "server", NULL, aarg_mandatory}, + {"cell", 0, aarg_string, &cell, "cell", NULL}, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, + {"local", 0, aarg_flag, &localauth, "localauth"}, + {"verbose", 0, aarg_flag, &verbose, "be verbose", NULL}, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, + {NULL, 0, aarg_end, NULL, NULL, NULL} }; static void usage (void) { - arg_printusage (args, "bos getrestart", "", ARG_AFSSTYLE); + aarg_printusage (args, "bos getrestart", "", AARG_AFSSTYLE); } int bos_getrestart(int argc, char **argv) { - int optind = 0; - - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { - usage (); + int optind = 0; + + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { + usage (); + return 0; + } + + if (helpflag) { + usage (); + return 0; + } + + argc -= optind; + argv += optind; + + if (server == NULL) { + printf ("bos getrestart: missing -server\n"); + return 0; + } + + if (cell == NULL) + cell = cell_getcellbyhost (server); + + printrestart (cell, server, noauth, localauth, verbose); return 0; - } - - if (helpflag) { - usage (); - return 0; - } - - argc -= optind; - argv += optind; - - if (server == NULL) { - printf ("bos getrestart: missing -server\n"); - return 0; - } - - if (cell == NULL) - cell = cell_getcellbyhost (server); - - printrestart (cell, server, noauth, localauth, verbose); - return 0; } diff --git a/usr.sbin/afs/src/appl/bos/bos_listhosts.c b/usr.sbin/afs/src/appl/bos/bos_listhosts.c index 7722c00c647..93f0ff23b91 100644 --- a/usr.sbin/afs/src/appl/bos/bos_listhosts.c +++ b/usr.sbin/afs/src/appl/bos/bos_listhosts.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -43,100 +38,139 @@ #include <bos.cs.h> -RCSID("$Id: bos_listhosts.c,v 1.1 2000/09/11 14:40:35 art Exp $"); +RCSID("$KTH: bos_listhosts.c,v 1.7 2000/10/03 00:07:13 lha Exp $"); static int printhosts(const char *cell, const char *host, - int noauth, int localauth, int verbose) + int noauth, int localauth, int verbose, int cellservdb, + const char *comment_text) { - struct rx_connection *connvolser = NULL; - unsigned int i; - int error; - char *server_name; - char *cell_name; - - connvolser = arlalib_getconnbyname(cell, - host, - afsbosport, - BOS_SERVICE_ID, - arlalib_getauthflag(noauth, - localauth,0,0)); - - if (connvolser == NULL) - return -1; - - /* which cell is this anyway ? */ - if (( error = BOZO_GetCellName(connvolser, &cell_name)) == 0) { - printf("Cell name is %s\n",cell_name); - } - else { - printf ("bos %s: %s\n", host, koerr_gettext (error)); - } + struct rx_connection *conn = NULL; + unsigned int nservers, i; + int error; + char **server_names = NULL; + char cell_name[BOZO_BSSIZE]; + + if (comment_text == NULL) + comment_text = ""; + + conn = arlalib_getconnbyname(cell, + host, + afsbosport, + BOS_SERVICE_ID, + arlalib_getauthflag(noauth, localauth,0,0)); + + if (conn == NULL) + return -1; + + /* which cell is this anyway ? */ + error = BOZO_GetCellName(conn, cell_name); + if (error) { + printf ("bos GetCellName %s: %s\n", host, koerr_gettext (error)); + return 0; + } - /* Who are the VLDB-servers ? */ - i = 0; - while ((error = BOZO_GetCellHost(connvolser, i, - &server_name)) == 0) { - printf("\t Host %d is %s\n",i+1,server_name); - i++; - } - - if (error != BZDOM) - printf ("bos %s: %s\n", host, koerr_gettext (error)); - arlalib_destroyconn(connvolser); - return 0; + /* Who are the DB-servers ? */ + nservers = 0; + while (1) { + server_names = erealloc (server_names, + (nservers + 1) * sizeof(*server_names)); + server_names[nservers] = emalloc (BOZO_BSSIZE); + error = BOZO_GetCellHost(conn, nservers, server_names[nservers]); + if (error) + break; + nservers++; + } + + if (error != BZDOM) { + printf ("bos listhosts: %s\n", koerr_gettext (error)); + } else { + if (!cellservdb) { + printf("Cell name is %s\n", cell_name); + for (i = 0; i < nservers; i++) + printf ("\t%s\n", server_names[i]); + } else { + printf (">%s #%s\n", cell_name, comment_text); + for (i = 0; i < nservers; i++) { + struct hostent *he; + char *addr; + struct in_addr inaddr; + + he = gethostbyname(server_names[i]); + if (he == NULL) + addr = "not-in-dns"; + else { + memcpy(&inaddr, he->h_addr, sizeof(inaddr)); + addr = inet_ntoa(inaddr); + } + printf ("%s #%s\n", addr, server_names[i]); + } + } + } + for (i = 0; i < nservers; i++) + free (server_names[i]); + free (server_names); + + arlalib_destroyconn(conn); + return 0; } static int helpflag; +static int dbflag; +static const char *comment_text; static const char *server; static const char *cell; static int noauth; static int localauth; static int verbose; -static struct getargs args[] = { - {"server", 0, arg_string, &server, "server", NULL, arg_mandatory}, - {"cell", 0, arg_string, &cell, "cell", NULL}, - {"noauth", 0, arg_flag, &noauth, "do not authenticate", NULL}, - {"local", 0, arg_flag, &localauth, "localauth"}, - {"verbose", 0, arg_flag, &verbose, "be verbose", NULL}, - {"help", 0, arg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL, NULL, NULL} +static struct agetargs args[] = { + {"server", 0, aarg_string, &server, "server", NULL, aarg_mandatory}, + {"db", 0, aarg_flag, &dbflag, "print in CellServDB format", NULL}, + {"comment", 0, aarg_string, &comment_text, + "comment text when CellServDB format is used", NULL}, + {"cell", 0, aarg_string, &cell, "cell", NULL}, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, + {"local", 0, aarg_flag, &localauth, "localauth"}, + {"verbose", 0, aarg_flag, &verbose, "be verbose", NULL}, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, + {NULL, 0, aarg_end, NULL, NULL, NULL} }; static void usage (void) { - arg_printusage (args, "bos listhosts", "", ARG_AFSSTYLE); + aarg_printusage (args, "bos listhosts", "", AARG_AFSSTYLE); } int bos_listhosts(int argc, char **argv) { - int optind = 0; - - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { - usage (); + int optind = 0; + + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { + usage (); + return 0; + } + + if (helpflag) { + usage (); + return 0; + } + + argc -= optind; + argv += optind; + + if (server == NULL) { + printf ("bos listhosts: missing -server\n"); + return 0; + } + + if (cell == NULL) + cell = cell_getcellbyhost (server); + + printhosts (cell, server, noauth, localauth, verbose, dbflag, + comment_text); return 0; - } - - if (helpflag) { - usage (); - return 0; - } - - argc -= optind; - argv += optind; - - if (server == NULL) { - printf ("bos listhosts: missing -server\n"); - return 0; - } - - if (cell == NULL) - cell = cell_getcellbyhost (server); - - printhosts (cell, server, noauth, localauth, verbose); - return 0; } diff --git a/usr.sbin/afs/src/appl/bos/bos_listusers.c b/usr.sbin/afs/src/appl/bos/bos_listusers.c index 3fa4852d9e7..13e53a9051b 100644 --- a/usr.sbin/afs/src/appl/bos/bos_listusers.c +++ b/usr.sbin/afs/src/appl/bos/bos_listusers.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -43,41 +38,52 @@ #include <bos.cs.h> -RCSID("$Id: bos_listusers.c,v 1.1 2000/09/11 14:40:35 art Exp $"); +RCSID("$KTH: bos_listusers.c,v 1.6.2.1 2001/04/18 13:50:22 lha Exp $"); static int printusers(const char *cell, const char *host, - int noauth, int localauth, int verbose) + int noauth, int localauth, int verbose) { - struct rx_connection *connvolser = NULL; - unsigned int i; - int error; - char *user_name[256]; - - connvolser = arlalib_getconnbyname(cell, - host, - afsbosport, - BOS_SERVICE_ID, - 0); - if (connvolser == NULL) - return -1; - - if (( error = BOZO_ListSUsers(connvolser, 0, &user_name[0])) == 1) { - printf ("bos %s: UserList could not be opened or no users on this server\n", host); - return -1; - } - - /* who is superuser on server_name ? */ - i = 0; - printf("SUsers are: "); - while (( error = BOZO_ListSUsers(connvolser, i, &user_name[i])) == 0) { - printf("%s ",user_name[i]); - i++; - } - printf("\n"); - - arlalib_destroyconn(connvolser); - return 0; + struct rx_connection *conn = NULL; + int i, error, done; + char user_name[BOZO_BSSIZE]; + + conn = arlalib_getconnbyname(cell, + host, + afsbosport, + BOS_SERVICE_ID, + arlalib_getauthflag(noauth, localauth,0,0)); + if (conn == NULL) + return -1; + + printf("SUsers are: "); + done = i = 0; + while (!done) { + error = BOZO_ListSUsers(conn, i, user_name); + switch (error) { + case 1: + if (i == 0) { + printf ("bos listusers: UserList could not be opened or no " + "users on this server\n"); + return 0; + } + done = 1; + break; + case 0: + printf("%s ", user_name); + break; + default: + printf ("bos listusers: %s(%d)\n", + koerr_gettext (error), error); + return 0; + } + + i++; + } + printf("\n"); + + arlalib_destroyconn(conn); + return 0; } @@ -88,48 +94,48 @@ static int noauth; static int localauth; static int verbose; -static struct getargs args[] = { - {"server", 0, arg_string, &server, "server", NULL, arg_mandatory}, - {"cell", 0, arg_string, &cell, "cell", NULL}, - {"noauth", 0, arg_flag, &noauth, "do not authenticate", NULL}, - {"local", 0, arg_flag, &localauth, "localauth"}, - {"verbose", 0, arg_flag, &verbose, "be verbose", NULL}, - {"help", 0, arg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL, NULL, NULL} +static struct agetargs args[] = { + {"server", 0, aarg_string, &server, "server", NULL, aarg_mandatory}, + {"cell", 0, aarg_string, &cell, "cell", NULL}, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, + {"local", 0, aarg_flag, &localauth, "localauth"}, + {"verbose", 0, aarg_flag, &verbose, "be verbose", NULL}, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, + {NULL, 0, aarg_end, NULL, NULL, NULL} }; static void usage (void) { - arg_printusage (args, "bos listusers", "", ARG_AFSSTYLE); + aarg_printusage (args, "bos listusers", "", AARG_AFSSTYLE); } int bos_listusers(int argc, char **argv) { - int optind = 0; - - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { - usage (); + int optind = 0; + + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { + usage (); + return 0; + } + + if (helpflag) { + usage (); + return 0; + } + + argc -= optind; + argv += optind; + + if (server == NULL) { + printf ("bos listusers: missing -server\n"); + return 0; + } + + if (cell == NULL) + cell = cell_getcellbyhost (server); + + printusers (cell, server, noauth, localauth, verbose); return 0; - } - - if (helpflag) { - usage (); - return 0; - } - - argc -= optind; - argv += optind; - - if (server == NULL) { - printf ("bos listusers: missing -server\n"); - return 0; - } - - if (cell == NULL) - cell = cell_getcellbyhost (server); - - printusers (cell, server, noauth, localauth, verbose); - return 0; } diff --git a/usr.sbin/afs/src/appl/bos/bos_local.h b/usr.sbin/afs/src/appl/bos/bos_local.h index 71a1b21f4cf..defe049713a 100644 --- a/usr.sbin/afs/src/appl/bos/bos_local.h +++ b/usr.sbin/afs/src/appl/bos/bos_local.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +32,7 @@ */ /* - * RCSID("$Id: bos_local.h,v 1.1 2000/09/11 14:40:35 art Exp $"); + * RCSID("$KTH: bos_local.h,v 1.3 2000/10/03 00:07:23 lha Exp $"); */ /* diff --git a/usr.sbin/afs/src/appl/bos/bos_status.c b/usr.sbin/afs/src/appl/bos/bos_status.c index bc2473db685..f291c4dda42 100644 --- a/usr.sbin/afs/src/appl/bos/bos_status.c +++ b/usr.sbin/afs/src/appl/bos/bos_status.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -43,7 +38,7 @@ #include <bos.cs.h> -RCSID("$Id: bos_status.c,v 1.1 2000/09/11 14:40:35 art Exp $"); +RCSID("$KTH: bos_status.c,v 1.11 2000/10/03 00:07:28 lha Exp $"); /* * @@ -93,8 +88,8 @@ printstatus(const char *cell, struct rx_connection *conn; unsigned int i; int error; - char *instance_name; int getstatus_int; + char instance_name[BOZO_BSSIZE]; char getstatus_str[BOZO_BSSIZE]; conn = arlalib_getconnbyname(cell, @@ -108,7 +103,7 @@ printstatus(const char *cell, i = 0; do { - error = BOZO_EnumerateInstance(conn, i, &instance_name); + error = BOZO_EnumerateInstance(conn, i, instance_name); if (error == 0) { error = BOZO_GetStatus(conn, instance_name, &getstatus_int, getstatus_str); @@ -148,14 +143,14 @@ static int noauth; static int localauth; static int verbose; -static struct getargs args[] = { - {"server", 0, arg_string, &server, "server", NULL, arg_mandatory}, - {"cell", 0, arg_string, &cell, "cell", NULL}, - {"noauth", 0, arg_flag, &noauth, "do not authenticate", NULL}, - {"local", 0, arg_flag, &localauth, "localauth"}, - {"verbose", 0, arg_flag, &verbose, "be verbose"}, - {"help", 0, arg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL, NULL, NULL} +static struct agetargs args[] = { + {"server", 0, aarg_string, &server, "server", NULL, aarg_mandatory}, + {"cell", 0, aarg_string, &cell, "cell", NULL}, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, + {"local", 0, aarg_flag, &localauth, "localauth"}, + {"verbose", 0, aarg_flag, &verbose, "be verbose"}, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, + {NULL, 0, aarg_end, NULL, NULL, NULL} }; /* @@ -165,7 +160,7 @@ static struct getargs args[] = { static int usage (int exit_code) { - arg_printusage (args, "bos status", "", ARG_AFSSTYLE); + aarg_printusage (args, "bos status", "", AARG_AFSSTYLE); return exit_code; } @@ -178,7 +173,7 @@ bos_status(int argc, char **argv) { int optind = 0; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) return usage (0); if (helpflag) diff --git a/usr.sbin/afs/src/appl/fs/Makefile.in b/usr.sbin/afs/src/appl/fs/Makefile.in index ffebeb9a762..0cb69e7c74e 100644 --- a/usr.sbin/afs/src/appl/fs/Makefile.in +++ b/usr.sbin/afs/src/appl/fs/Makefile.in @@ -1,6 +1,7 @@ -# $Id: Makefile.in,v 1.1 2000/09/11 14:40:35 art Exp $ +# $KTH: Makefile.in,v 1.11.2.2 2001/10/23 23:50:43 ahltorp Exp $ srcdir = @srcdir@ +top_builddir = ../.. VPATH = @srcdir@ CC = @CC@ @@ -29,6 +30,7 @@ SHELL = /bin/sh CFLAGS = @CFLAGS@ X_CFLAGS = @X_CFLAGS@ +LDFLAGS = @LDFLAGS@ ETAGS = etags MAKEDEPEND = makedepend @@ -42,6 +44,7 @@ INCLUDES = -I$(srcdir)/../.. \ $(KERNEL_INCLUDE) \ -I$(srcdir)/../../xfs/include \ -I$(srcdir)/../../arlad \ + @INC_roken@ \ $(RXKADINC) DEFINES = @@ -58,27 +61,29 @@ LIBS = -L../lib -larlalib \ -L../../lwp -llwp @PLWP_LIB_FLAGS@ \ -L../../lib/ko -lko -L../../util -lutil \ -L../../lib/sl -lsl \ - -L../../lib/roken \ $(READLINE_lib) \ $(RXKAD_LIBS) \ $(KAFS_LIBS) \ $(RXKAD_LIBS) \ - -lroken @LIBS@ + @LIB_roken@ @LIBS@ LIBDEPENDS = ../../rxdef/librxdefclient.a ../../rx/librx.a ../../lwp/liblwp.a \ - ../../util/libutil.a ../../lib/sl/libsl.a ../../lib/roken/libroken.a \ - ../../lib/ko/libko.a + ../../util/libutil.a ../../lib/sl/libsl.a \ + ../../lib/ko/libko.a ../lib/libarlalib.a PROGS = fs -FS_SRCS = fs.c +FS_SRCS = fs.c arladebu.c SRCS = $(FS_SRCS) -FS_OBJS = fs.o +FS_OBJS = fs.o arladebu.o HDRS = all: $(PROGS) .PHONY: all install uninstall depend tags clean +arladebu.c: $(srcdir)/../../arlad/arladebu.c + test -f arladebu.c || $(LN_S) $(srcdir)/../../arlad/arladebu.c arladebu.c + .c.o: $(CC) -c $(CPPFLAGS) $(DEFS) -I$(srcdir) -I. $(REALCFLAGS) $< @@ -94,7 +99,7 @@ install: all e=`echo $$x | sed 's/.*\.\([1-9a-zA-Z]*\)$$/\1/'`; \ f=`echo $$n | sed '$(transform)'`; \ $(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$$e ; \ - $(INSTALL_PROGRAM) $(srcdir)/$$x \ + $(INSTALL_DATA) $(srcdir)/$$x \ $(DESTDIR)$(mandir)/man$$e/$$f.$$e; \ done @@ -125,12 +130,12 @@ TAGS: $(SRCS) $(HDRS) $(ETAGS) -t $(SRCS) $(HDRS) clean : - rm -f $(PROGS) $(OBJS) *~ *.o core + rm -f $(PROGS) $(OBJS) *~ *.o core arladebu.c mostlyclean: clean distclean: clean - rm -f Makefile config.status + rm -f Makefile realclean: distclean rm -f TAGS diff --git a/usr.sbin/afs/src/appl/fs/fs.1 b/usr.sbin/afs/src/appl/fs/fs.1 index 6857e40386e..753f226510a 100644 --- a/usr.sbin/afs/src/appl/fs/fs.1 +++ b/usr.sbin/afs/src/appl/fs/fs.1 @@ -1,5 +1,5 @@ -.\" $OpenBSD: fs.1,v 1.3 2001/07/25 10:04:57 mpech Exp $ -.\" $Id: fs.1,v 1.3 2001/07/25 10:04:57 mpech Exp $ +.\" $OpenBSD: fs.1,v 1.4 2002/06/07 04:28:42 hin Exp $ +.\" $KTH: fs.1,v 1.2.2.1 2001/03/04 04:35:56 lha Exp $ .Dd March 29, 2000 .Dt FS 1 .Os @@ -34,7 +34,7 @@ tweek arla-debugging flags .It Cm checkservers check if servers are up .It Cm checkvolumes -not yet implemented +check that all volume mapping are correct .It Cm cleanacl not yet implemented .It Cm copyacl @@ -98,6 +98,10 @@ show a mount point not yet implemented .It Cm mkmount create mount point +.It Cm mkm +shorthand of the +.Cm mkmount +comman .It Cm connect connect mode .It Cm monitor @@ -222,7 +226,8 @@ printed. .Pp .Ic fs checkvolumes .Bd -filled -offset indent -compact -Not implemented yet. +check that all volume mapping are correct and flush all mountpoints +from the cache to force them to be reread. .Ed .Pp .Ic fs cleanacl @@ -386,8 +391,17 @@ Not implemented yet. .Ic fs mkmount .Ar directory .Ar volume +.Op Fl cell Ar cell +.Op Fl rw .Bd -filled -offset indent -compact -Create a mountpoint. +Create a mountpoint point to +.Ar volume +in optional +.Ar cell. +If +.Fl rw +is given, a mountpoint to the readwrite volume is created. +.Pp Note that the there must not exist a directory named as the mount point you are creating. .Ed @@ -566,7 +580,10 @@ comand .Ar path .Ar quota .Bd -filled -offset indent -compact -Set the quota (in Kbytes) on a volume. +Set the +.Ar quota +(in Kbytes) on a volume pointed out by +.Ar path . .Ed .Pp .Ic fs sq diff --git a/usr.sbin/afs/src/appl/fs/fs.c b/usr.sbin/afs/src/appl/fs/fs.c index be74aece171..dfb05459cb5 100644 --- a/usr.sbin/afs/src/appl/fs/fs.c +++ b/usr.sbin/afs/src/appl/fs/fs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -46,13 +41,14 @@ #include "fs_local.h" #include <arladeb.h> -RCSID("$Id: fs.c,v 1.1 2000/09/11 14:40:35 art Exp $"); +RCSID("$KTH: fs.c,v 1.92.2.4 2001/10/02 16:12:37 jimmy Exp $"); static int empty_cmd (int argc, char **argv); static int apropos_cmd (int argc, char **argv); static int arladebug_cmd (int argc, char **argv); static int calculate_cmd (int argc, char **argv); static int checkservers_cmd (int argc, char **argv); +static int checkvolumes_cmd (int argc, char **argv); static int copyacl_cmd (int argc, char **argv); static int diskfree_cmd (int argc, char **argv); static int examine_cmd (int argc, char **argv); @@ -63,10 +59,12 @@ static int getcache_cmd (int argc, char **argv); static int getcrypt_cmd (int argc, char **argv); static int getcellstatus_cmd (int argc, char **argv); static int getfid_cmd (int argc, char **argv); +static int getstatistics_cmd (int argc, char **argv); static int getprio_cmd (int argc, char **argv); static int getmaxprio_cmd (int argc, char **argv); static int help_cmd (int argc, char **argv); static int invalidate_cmd (int argc, char **argv); +static int incompat_cmd (int argc, char **argv); static int listacl_cmd (int argc, char **argv); static int listcells_cmd (int argc, char **argv); static int suidcells_cmd (int argc, char **argv); @@ -101,10 +99,11 @@ static SL_cmd cmds[] = { {"arladebug", arladebug_cmd, "tweek arla-debugging flags"}, {"calculate cache", calculate_cmd, "calculate the usege of cache"}, {"checkservers", checkservers_cmd,"check if servers is up"}, - {"checkvolumes", empty_cmd, "lookup mappings between volume-Id's and names"}, + {"checkvolumes", checkvolumes_cmd, "lookup mappings between volume-Id's and names"}, {"cleanacl", empty_cmd, "clear out numeric acl-entries"}, {"copyacl", copyacl_cmd, "copy acl"}, {"diskfree", diskfree_cmd, "show free partition space"}, + {"df"}, {"examine", examine_cmd, "examine volume status"}, {"flush", flush_cmd, "remove file from cache"}, {"flushvolume", flushvolume_cmd, "remove volumedata (and files in volume) from cache"}, @@ -114,11 +113,13 @@ static SL_cmd cmds[] = { {"getcellstatus", getcellstatus_cmd, "get suid cell status"}, {"getfid", getfid_cmd, "get fid"}, {"getserverprefs", empty_cmd, "show server rank"}, + {"getstatistics", getstatistics_cmd, "get statistics"}, {"getpriority", getprio_cmd, "get priority of a file/dir"}, {"gp"}, {"getmaxpriority", getmaxprio_cmd, "get max priority for file gc"}, {"gmp"}, {"help", help_cmd, "help for commands"}, + {"incompat", incompat_cmd, "using old interface"}, {"invalidate", invalidate_cmd, "invalidate (callback) path"}, {"listacl", listacl_cmd, "show acl"}, {"la"}, @@ -203,13 +204,6 @@ nop_cmd(int argc, char **argv) } static int -connect_usage(void) -{ - printf("connect [connected|fetch|disconnected]\n"); - return 0; -} - -static int checkservers_cmd (int argc, char **argv) { char *cell = NULL; @@ -220,19 +214,19 @@ checkservers_cmd (int argc, char **argv) int ret; int i; - struct getargs cksargs[] = { - {"cell", 0, arg_string, NULL, "cell", NULL}, - {"nopoll", 0, arg_flag, NULL, "dont ping each server, " + struct agetargs cksargs[] = { + {"cell", 0, aarg_string, NULL, "cell", NULL}, + {"nopoll", 0, aarg_flag, NULL, "dont ping each server, " "use internal info", NULL}, - {NULL, 0, arg_end, NULL}}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = cksargs; arg->value = &cell; arg++; arg->value = &nopoll; arg++; - if (getarg (cksargs, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(cksargs, "checkservers", NULL, ARG_AFSSTYLE); + if (agetarg (cksargs, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(cksargs, "checkservers", NULL, AARG_AFSSTYLE); return 0; } @@ -275,6 +269,24 @@ checkservers_cmd (int argc, char **argv) return 0; } +static int +checkvolumes_cmd (int argc, char **argv) +{ + int ret; + + ret = fs_checkvolumes(); + if (ret) + fserr (PROGNAME, ret, NULL); + return 0; +} + +static int +connect_usage(void) +{ + printf("connect [connected|fetch|disconnected]\n"); + return 0; +} + static int connect_cmd(int argc, char **argv) { @@ -627,30 +639,76 @@ static int mkmount_cmd (int argc, char **argv) { char buf[MAXSIZE]; + char prefix; + char *dirname = NULL; + char *volname = NULL; + char *cell = NULL; + int rwflag = 0; + int helpflag = 0; + int optind = 0; - argc--; - argv++; + struct agetargs mkmargs[] = { + {"dir", 0, aarg_string, NULL, "mount point directory name", + "directory", aarg_mandatory}, + {"vol", 0, aarg_string, NULL, "volume to mount", + "volume", aarg_mandatory}, + {"cell", 0, aarg_string, NULL, "cell of volume", + "cell", aarg_optional_swless}, + {"rw", 0, aarg_flag, NULL, "mount read-write", NULL}, + {"help", 0, aarg_flag, NULL, NULL, NULL}, + {NULL, 0, aarg_end, NULL}}, *arg; + + arg = mkmargs; + arg->value = &dirname; arg++; + arg->value = &volname; arg++; + arg->value = &cell; arg++; + arg->value = &rwflag; arg++; + arg->value = &helpflag; arg++; - if (argc == 0) { - printf ("fs: Required parameter '-dir' missing\n"); + if (agetarg (mkmargs, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(mkmargs, "fs mkmount", "", AARG_AFSSTYLE); + return 0; + } + + argc -= optind; + argv += optind; + + if (argc) { + printf("unknown option %s\n", *argv); return 0; } - else if (argc == 1) { - printf ("fs: Required parameter '-vol' missing\n"); + + if (rwflag) + prefix = '%'; + else + prefix = '#'; + if (cell) + snprintf(buf, sizeof(buf), "%c%s:%s.", prefix, cell, volname); + else + snprintf(buf, sizeof(buf), "%c%s.", prefix, volname); + + if (symlink (buf, dirname) == -1) { + perror ("fs"); return 0; } - else { - if (argc > 2) - snprintf(buf, sizeof(buf), "#%s:%s.", argv[2], argv[1]); + + return 0; +} + +static int +incompat_cmd (int argc, char **argv) +{ + int status, ret; + + ret = fs_incompat_renumber(&status); + if (ret) { + fserr(PROGNAME, ret, NULL); + } else { + if (status) + printf ("new interface\n"); else - snprintf(buf, sizeof(buf), "#%s.", argv[1]); - - if (symlink (buf, argv[0]) == -1) { - perror ("fs"); - return 0; - } + printf ("old interface\n"); } - return 0; } @@ -702,14 +760,14 @@ listcells_cmd (int argc, char **argv) int printsuid = 0; int optind = 0; - struct getargs lcargs[] = { - {"servers", 's', arg_negative_flag, + struct agetargs lcargs[] = { + {"servers", 's', aarg_negative_flag, NULL,"do not print servers in cell", NULL}, - {"resolve", 'r', arg_negative_flag, + {"resolve", 'r', aarg_negative_flag, NULL,"do not resolve hostnames", NULL}, - {"suid", 'p', arg_flag, + {"suid", 'p', aarg_flag, NULL,"print if cell is suid", NULL }, - {NULL, 0, arg_end, NULL}}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = lcargs; @@ -717,8 +775,8 @@ listcells_cmd (int argc, char **argv) arg->value = &resolve; arg++; arg->value = &printsuid; arg++; - if (getarg (lcargs, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(lcargs, "listcells", NULL, ARG_AFSSTYLE); + if (agetarg (lcargs, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(lcargs, "listcells", NULL, AARG_AFSSTYLE); return 0; } @@ -763,18 +821,18 @@ static int newcell_cmd (int argc, char **argv) { char *cell = NULL; - getarg_strings servers = { 0, NULL }; + agetarg_strings servers = { 0, NULL }; int ret, help = 0; int optind = 0; - struct getargs ncargs[] = { - {"cell", 'c', arg_string, - NULL, "new cell", NULL}, - {"servers", 's', arg_strings, + struct agetargs ncargs[] = { + {"cell", 'c', aarg_string, + NULL, "new cell", NULL, aarg_mandatory}, + {"servers", 's', aarg_strings, NULL, "server in cell", "one server"}, - {"help", 'h', arg_flag, + {"help", 'h', aarg_flag, NULL, "get help", NULL}, - {NULL, 0, arg_end, NULL}}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = ncargs; @@ -782,18 +840,13 @@ newcell_cmd (int argc, char **argv) arg->value = &servers; arg++; arg->value = &help; arg++; - if (getarg (ncargs, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(ncargs, "newcell", NULL, ARG_AFSSTYLE); + if (agetarg (ncargs, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(ncargs, "newcell", NULL, AARG_AFSSTYLE); return 0; } if (help) { - arg_printusage(ncargs, "newcell", NULL, ARG_AFSSTYLE); - goto out; - } - - if (cell == NULL) { - fprintf (stderr, "You have to give a cell\n"); + aarg_printusage(ncargs, "newcell", NULL, AARG_AFSSTYLE); goto out; } @@ -840,6 +893,211 @@ getprio_usage(void) return 0; } +static void +printtimeslot(u_int32_t slot) +{ + int v; + + v = 1 << slot; + + if (v < 1000) { + printf("%3d us ", v); + return; + } + if (v < 1000000) { + printf("%3d ms ", v / 1000); + return; + } + printf("%3d s ", v / 1000000); +} + +static void +printsizeslot(u_int32_t slot) +{ + int v; + + v = 1 << slot; + + if (v < 1024) { + printf("%3d ", v); + return; + } + if (v < 1000000) { + printf("%3d K ", v / 1000); + return; + } + printf("%3d M ", v / 1000000); +} + +static void +print_stat_header(char *server, char *part, + int type, int time, int size, int *once) +{ + if (*once) + return; + *once = 1; + printf("%30s %10s\n", server, part); + + if (time) + printf("%6s ", "tmrng"); + + if (size) + printf("%5s ", "szrng"); + + printf("%6s ", "#req"); + + printf("%8s ", "tot B"); + printf("%8s ", "tot us"); + printf("%8s ", "avg us"); + printf("%8s\n", "KB/s"); +} + +static void +print_statistics(int64_t count, int64_t items_total, int64_t total_time, + int timeslot, int sizeslot, int time, int size) +{ + if (time) + printtimeslot(timeslot); + if (size) + printsizeslot(sizeslot); + + printf("%6lld %8lld %8lld %8lld %8lld\n", + count, items_total, + total_time, + total_time/count, + items_total*1000LL/total_time); +} + +static int +getstatistics_cmd (int argc, char **argv) +{ + u_int32_t host[100]; + u_int32_t part[100]; + int n = 100; + int i; + int j; + int k; + char server_name[100]; + char partition_name[100]; + u_int32_t count[32]; + int64_t items_total[32]; + int64_t total_time[32]; + int64_t tot_total_time; + int64_t tot_count; + int64_t tot_items_total; + int error; + int type; + char *reqtype = NULL; + char *filter_host = NULL; + int time = 0, size = 0, help = 0; + int optind = 0; + int printed_header = 0; + + struct agetargs statargs[] = { + {"type", 0, aarg_string, + NULL, "request type", "type", aarg_mandatory}, + {"host", 0, aarg_string, + NULL, "host", "type", aarg_optional}, + {"time", 0, aarg_flag, + NULL, "time statistics", NULL}, + {"size", 0, aarg_flag, + NULL, "size statistics", NULL}, + {"help", 0, aarg_flag, + NULL, "get help", NULL}, + {NULL, 0, aarg_end, NULL}}, + *arg; + + arg = statargs; + arg->value = &reqtype; arg++; + arg->value = &filter_host; arg++; + arg->value = &time; arg++; + arg->value = &size; arg++; + arg->value = &help; arg++; + + + if (agetarg (statargs, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(statargs, "getstatistics", NULL, AARG_AFSSTYLE); + return 0; + } + + if (help) { + aarg_printusage(statargs, "getstatistics", NULL, AARG_AFSSTYLE); + return 0; + } + + + if (strcmp(reqtype, "fetchstatus") == 0) { + type = STATISTICS_REQTYPE_FETCHSTATUS; + } else if (strcmp(reqtype, "fetchdata") == 0) { + type = STATISTICS_REQTYPE_FETCHDATA; + } else if (strcmp(reqtype, "bulkstatus") == 0) { + type = STATISTICS_REQTYPE_BULKSTATUS; + } else { + fprintf(stderr, "type must be fetchstatus, fetchdata or bulkstatus\n"); + return 0; + } + + error = fs_statistics_list(host, part, &n); + if (error) { + fserr(PROGNAME, error, NULL); + return 0; + } + + for (i = 0; i < n; i++) { + printed_header = 0; + arlalib_host_to_name(host[i], server_name, 100); + if (filter_host && strcmp(filter_host, server_name) != 0) + continue; + partition_num2name(part[i], partition_name, 100); + + tot_total_time = 0; + tot_count = 0; + tot_items_total = 0; + for (j = 0; j < 32; j++) { + error = fs_statistics_entry(host[i], part[i], type, + j, count, items_total, total_time); + if (error) { + fserr(PROGNAME, error, NULL); + return 0; + } + if (size) { + tot_total_time = 0; + tot_count = 0; + tot_items_total = 0; + } + for (k = 0; k < 32; k++) { + if (count[k]) { + if (time && size) { + print_stat_header(server_name, partition_name, + type, time, size, &printed_header); + print_statistics(count[k], items_total[k], + total_time[k], k, j, + time, size); + } + tot_total_time += total_time[k]; + tot_count += count[k]; + tot_items_total += items_total[k]; + } + } + if (!time && size && tot_count) { + print_stat_header(server_name, partition_name, + type, time, size, &printed_header); + print_statistics(tot_count, tot_items_total, + tot_total_time, 0, j, + time, size); + } + } + if (!time && !size && tot_count) { + print_stat_header(server_name, partition_name, + type, time, size, &printed_header); + print_statistics(tot_count, tot_items_total, + tot_total_time, 0, 0, + time, size); + } + } + return 0; +} + static int getprio_cmd (int argc, char **argv) { @@ -903,16 +1161,47 @@ getmaxprio_cmd (int argc, char **argv) static int setquota_cmd (int argc, char **argv) { - if(argc!=3) { - printf("Usage: fs sq <path> <max quota in kbytes>\n"); - return 0; + char *path = NULL; + int quota = 0; + int helpflag = 0; + int optind = 0; + + struct agetargs sqargs[] = { + {"path", 0, aarg_string, NULL, "pathname to file/directory", + "pathname", aarg_mandatory}, + {"max", 0, aarg_integer, NULL, "max quota in kbytes", + "kbytes", aarg_mandatory}, + {"help", 0, aarg_flag, NULL }, + {NULL, 0, aarg_end, NULL}}, *arg; + + arg = sqargs; + arg->value = &path; arg++; + arg->value = "a; arg++; + arg->value = &helpflag; arg++; + + if (agetarg (sqargs, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(sqargs, "fs setquota", NULL, AARG_AFSSTYLE); + return 0; } - afs_setmaxquota(argv[1],(int32_t) atoi(argv[2])); + if (helpflag) { + aarg_printusage(sqargs, "fs setquota", NULL, AARG_AFSSTYLE); + return 0; + } + argc -= optind; + argv += optind; + if (argc) { + printf("unknown option %s\n", *argv); + return 0; + } + + afs_setmaxquota(path, quota); + return 0; } + static int lsmount_cmd (int argc, char **argv) { @@ -1142,11 +1431,11 @@ venuslog_cmd (int argc, char **argv) static int fsversion_cmd(int argc, char **argv) { - if (argc != 0) + if (argc != 1) printf ("version: extraneous arguments ignored\n"); printf("fs: %s\nfs_lib: %s\n", - "$Id: fs.c,v 1.1 2000/09/11 14:40:35 art Exp $", + "$KTH: fs.c,v 1.92.2.4 2001/10/02 16:12:37 jimmy Exp $", fslib_version()); return 0; } @@ -1456,8 +1745,13 @@ afs_listacl(char *path) struct AclEntry *position; int i; - if((acl=afs_getacl(path))==NULL) - exit(1); + acl = afs_getacl(path); + if (acl == NULL) { + if (errno == EACCES) + return; + else + exit(1); + } printf("Access list for %s is\n", path); if(acl->NumPositiveEntries) { @@ -2119,25 +2413,25 @@ getcache_cmd (int argc, char **argv) u_int32_t max_bytes, used_bytes, max_vnodes, used_vnodes; int optind = 0, bytes_flag = 0; - struct getargs ncargs[] = { - {"byte", 'b', arg_flag, + struct agetargs ncargs[] = { + {"byte", 'b', aarg_flag, NULL, "show result in byte instead of kbyte", NULL}, - {"help", 'h', arg_flag, + {"help", 'h', aarg_flag, NULL, "get help", NULL}, - {NULL, 0, arg_end, NULL}}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = ncargs; arg->value = &bytes_flag; arg++; arg->value = &help; arg++; - if (getarg (ncargs, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(ncargs, "getcacheparams", NULL, ARG_AFSSTYLE); + if (agetarg (ncargs, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(ncargs, "getcacheparams", NULL, AARG_AFSSTYLE); return 0; } if (help) { - arg_printusage(ncargs, "getcacheparams", NULL, ARG_AFSSTYLE); + aarg_printusage(ncargs, "getcacheparams", NULL, AARG_AFSSTYLE); return 0; } diff --git a/usr.sbin/afs/src/appl/fs/fs_local.h b/usr.sbin/afs/src/appl/fs/fs_local.h index 8128de4e427..d7e192df6fb 100644 --- a/usr.sbin/afs/src/appl/fs/fs_local.h +++ b/usr.sbin/afs/src/appl/fs/fs_local.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +32,7 @@ */ /* - * $Id: fs_local.h,v 1.1 2000/09/11 14:40:36 art Exp $ + * $KTH: fs_local.h,v 1.31 2000/10/03 00:07:40 lha Exp $ */ #define MAXNAME 100 diff --git a/usr.sbin/afs/src/appl/lib/Makefile.in b/usr.sbin/afs/src/appl/lib/Makefile.in index 8a4777045c1..2f3d15adc0c 100644 --- a/usr.sbin/afs/src/appl/lib/Makefile.in +++ b/usr.sbin/afs/src/appl/lib/Makefile.in @@ -1,10 +1,11 @@ # -# $Id: Makefile.in,v 1.1 2000/09/11 14:40:36 art Exp $ +# $KTH: Makefile.in,v 1.13 2001/01/07 13:09:00 lha Exp $ # SHELL = /bin/sh srcdir = @srcdir@ +top_builddir = ../.. VPATH = @srcdir@ CC = @CC@ @@ -18,7 +19,8 @@ INCLUDES = -I. \ -I../../rxdef \ -I$(srcdir)/../../arlad \ -I$(srcdir)/../../xfs/include \ - @KRB4_INC_FLAGS@ + @INC_roken@ \ + @KRB4_INC_FLAGS@ \ CFLAGS = @CFLAGS@ @@ -29,6 +31,7 @@ LN_S = @LN_S@ prefix = @prefix@ exec_prefix = @exec_prefix@ +includedir = @includedir@ libdir = @libdir@ sysconfdir = @sysconfdir@ ARLACACHEDIR = @ARLACACHEDIR@ @@ -51,11 +54,13 @@ LIB = $(LIBNAME).$(LIBEXT) DEFS = @DEFS@ -LIB_SOURCES = arlalib.c arladeb.c fs_lib.c +LIB_SOURCES = arlalib.c fs_lib.c ka-procs.c tokens.c SOURCES = $(LIB_SOURCES) -LIB_OBJECTS = arlalib.o arladeb.o fs_lib.o +HEADERS = arlalib.h ka-procs.h + +LIB_OBJECTS = arlalib.o fs_lib.o ka-procs.o tokens.o OBJECTS = $(LIB_OBJECTS) @@ -64,18 +69,21 @@ all: $(LIB) Wall: make CFLAGS="-g -Wall -Wno-comment -Wmissing-prototypes -Wmissing-declarations -D__USE_FIXED_PROTOTYPES__" -arladeb.c: $(srcdir)/../../arlad/arladeb.c - test -f arladeb.c || $(LN_S) $(srcdir)/../../arlad/arladeb.c arladeb.c - .c.o: $(CC) -c $(CPPFLAGS) $(DEFS) $(INCLUDES) $(CFLAGS) $(PICFLAGS) $< install: all $(MKINSTALLDIRS) $(DESTDIR)$(libdir) $(INSTALL_DATA) $(LIB) $(DESTDIR)$(libdir)/$(LIB) + for i in $(HEADERS); do \ + $(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir)/$$i; \ + done uninstall: rm -f $(DESTDIR)$(libdir)/$(LIB) + for i in $(HEADERS); do \ + rm -f $(DESTDIR)$(includedir)/$$i; \ + done TAGS: $(SOURCES) etags $(SOURCES) diff --git a/usr.sbin/afs/src/appl/lib/appl_locl.h b/usr.sbin/afs/src/appl/lib/appl_locl.h index f743979f2f6..8689ee6e589 100644 --- a/usr.sbin/afs/src/appl/lib/appl_locl.h +++ b/usr.sbin/afs/src/appl/lib/appl_locl.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: appl_locl.h,v 1.1 2000/09/11 14:40:36 art Exp $ */ +/* $KTH: appl_locl.h,v 1.33 2000/10/03 00:07:46 lha Exp $ */ #ifdef HAVE_CONFIG_H #include <config.h> @@ -89,7 +84,7 @@ #include <atypes.h> #include <roken.h> -#include <getarg.h> +#include <agetarg.h> #include <err.h> #include <assert.h> diff --git a/usr.sbin/afs/src/appl/lib/arlalib.c b/usr.sbin/afs/src/appl/lib/arlalib.c index b51285187d1..beee976b1d7 100644 --- a/usr.sbin/afs/src/appl/lib/arlalib.c +++ b/usr.sbin/afs/src/appl/lib/arlalib.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -38,7 +33,7 @@ #include "appl_locl.h" -RCSID("$Id: arlalib.c,v 1.1 2000/09/11 14:40:36 art Exp $"); +RCSID("$KTH: arlalib.c,v 1.41.2.2 2001/10/02 16:13:00 jimmy Exp $"); static struct rx_securityClass *secureobj = NULL ; @@ -64,8 +59,8 @@ get_cred(const char *princ, const char *inst, const char *krealm, } static int -arlalib_get_cred(const char *cell, const char *host, CREDENTIALS *c, - arlalib_authflags_t auth) +arlalib_get_cred_krb (const char *cell, const char *host, CREDENTIALS *c, + arlalib_authflags_t auth) { char krealm[REALM_SZ]; char *rrealm; @@ -80,18 +75,46 @@ arlalib_get_cred(const char *cell, const char *host, CREDENTIALS *c, if (k_errno != KSUCCESS) k_errno = get_cred("afs", "", krealm, c); - if (k_errno != KSUCCESS) { - fprintf(stderr, - "Can't get a ticket for realm %s: %s\n", - krealm, krb_get_err_text(k_errno)); + if (k_errno != KSUCCESS) return -1; - } ret = k_errno; } else ret = EOPNOTSUPP; return ret; } + +static int +find_token (const char *secret, size_t secret_sz, + const struct ClearToken *ct, + const char *cell, void *arg) +{ + CREDENTIALS *c = (CREDENTIALS *)arg; + + memcpy(c->ticket_st.dat, secret, secret_sz) ; + c->ticket_st.length = secret_sz; + + strlcpy (c->realm, cell, sizeof(c->realm)); + strupr(c->realm); + + c->kvno = ct->AuthHandle; + memcpy (c->session, ct->HandShakeKey, sizeof(c->session)); + c->issue_date = ct->BeginTimestamp - 1; + + return 0; +} + +static int +arlalib_get_cred_afs (const char *cell, CREDENTIALS *c, + arlalib_authflags_t auth) +{ + if (cell == NULL) + cell = cell_getthiscell(); + + return arlalib_token_iter (cell, find_token, c); +} + + #endif /* KERBEROS */ int @@ -121,31 +144,39 @@ arlalib_getsecurecontext(const char *cell, const char *host, #ifdef KERBEROS CREDENTIALS c; #endif /* KERBEROS */ - struct rx_securityClass* sec; + struct rx_securityClass* sec = NULL; if (secureobj != NULL) return secureobj; #ifdef KERBEROS - - if (auth && - arlalib_get_cred(cell, host, &c, auth) == KSUCCESS) { - - sec = rxkad_NewClientSecurityObject(rxkad_auth, - &c.session, - c.kvno, - c.ticket_st.length, - c.ticket_st.dat); - secureindex = 2; - } else { + if (auth) { + int ret; + + ret = arlalib_get_cred_krb (cell, host, &c, auth); + if (ret == KSUCCESS) { + ret = 0; + } else { + ret = arlalib_get_cred_afs (cell, &c, auth); + } + if (ret == 0) { + sec = rxkad_NewClientSecurityObject(rxkad_auth, + &c.session, + c.kvno, + c.ticket_st.length, + c.ticket_st.dat); + secureindex = 2; + } else { + fprintf(stderr, "Can't get a token for cell %s\n", + cell ? cell : cell_getthiscell()); + } + } #endif /* KERBEROS */ - + + if (sec == NULL) { sec = rxnull_NewClientSecurityObject(); secureindex = 0; - -#ifdef KERBEROS } -#endif /* KERBEROS */ secureobj = sec; @@ -194,15 +225,25 @@ arlalib_getconnbyname(const char *cell, const char *host, int32_t port, int32_t servid, arlalib_authflags_t auth) { - struct in_addr server; + struct addrinfo hints, *res; + int error; + int32_t addr; - if (str2inaddr (host, &server) == NULL ) { + memset (&hints, 0, sizeof(hints)); + hints.ai_family = PF_INET; + hints.ai_socktype = SOCK_DGRAM; + + error = getaddrinfo(host, NULL, &hints, &res); + if (error) { fprintf (stderr, "Cannot find host %s\n", host); return NULL; } - return arlalib_getconnbyaddr(cell, server.s_addr, host, port, servid, - auth); + assert (res->ai_family == PF_INET); + addr = ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr; + freeaddrinfo(res); + + return arlalib_getconnbyaddr(cell, addr, host, port, servid, auth); } int @@ -552,6 +593,7 @@ int arlalib_try_next_db (int error) { switch (error) { + case ARLA_CALL_DEAD: case UNOTSYNC : case ENETDOWN : return TRUE; @@ -578,3 +620,26 @@ free_db_server_context(struct db_server_context *context) free(context->conn); } +/* + * give a name for the server `addr' + */ + +void +arlalib_host_to_name (u_int32_t addr, char *str, size_t str_sz) +{ + struct sockaddr_in sock; + int error; + + memset (&sock, 0, sizeof(sock)); +#if HAVE_STRUCT_SOCKADDR_IN_SIN_LEN + sock.sin_len = sizeof(sock); +#endif + sock.sin_family = AF_INET; + sock.sin_port = 0; + sock.sin_addr.s_addr = addr; + + error = getnameinfo((struct sockaddr *)&sock, sizeof(sock), + str, str_sz, NULL, 0, 0); + if (error) + strlcpy (str, "<unknown>", str_sz); +} diff --git a/usr.sbin/afs/src/appl/lib/arlalib.h b/usr.sbin/afs/src/appl/lib/arlalib.h index 9f87e44b3f0..d2747ac5681 100644 --- a/usr.sbin/afs/src/appl/lib/arlalib.h +++ b/usr.sbin/afs/src/appl/lib/arlalib.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: arlalib.h,v 1.1 2000/09/11 14:40:36 art Exp $ */ +/* $KTH: arlalib.h,v 1.37.2.3 2001/10/02 16:13:01 jimmy Exp $ */ #ifndef ARLALIB_H #define ARLALIB_H 1 @@ -81,6 +76,22 @@ int arlalib_getsyncsite(const char *cell, const char *host, int32_t port, /* + * Token managment + */ + +struct ClearToken; + +typedef int (*arlalib_token_iter_func) (const char *secret, size_t secret_sz, + const struct ClearToken *ct, + const char *cell, + void *arg); + +int +arlalib_token_iter (const char *cell, + arlalib_token_iter_func func, void *arg); + + +/* * Wrappers around pioctl calls */ @@ -118,6 +129,8 @@ int fs_getaviatorstats(u_int32_t *max_workers, int fs_checkservers(char *cell, int32_t flags, u_int32_t *hosts, int numhosts); +int fs_checkvolumes (void); + int fs_set_sysname (const char *sys); @@ -159,6 +172,17 @@ int fs_rmmount (const char *path); int +fs_incompat_renumber (int *ret); + +int +fs_statistics_list(u_int32_t *host, u_int32_t *part, int *n); + +int +fs_statistics_entry(u_int32_t host, u_int32_t part, u_int32_t type, + u_int32_t items_slot, u_int32_t *count, + int64_t *items_total, int64_t *total_time); + +int arlalib_get_viceid (const char *username, const char *cellname, int32_t *viceId); diff --git a/usr.sbin/afs/src/appl/lib/fs_lib.c b/usr.sbin/afs/src/appl/lib/fs_lib.c index 64ce7a315ba..d73e4aa9f8d 100644 --- a/usr.sbin/afs/src/appl/lib/fs_lib.c +++ b/usr.sbin/afs/src/appl/lib/fs_lib.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -39,7 +34,7 @@ #include "appl_locl.h" #include <kafs.h> -RCSID("$Id: fs_lib.c,v 1.1 2000/09/11 14:40:36 art Exp $"); +RCSID("$KTH: fs_lib.c,v 1.31.2.3 2001/10/02 16:13:02 jimmy Exp $"); enum { PIOCTL_MAXSIZE = 2000 }; @@ -50,7 +45,7 @@ enum { PIOCTL_MAXSIZE = 2000 }; const char * fslib_version(void) { - return "$Id: fs_lib.c,v 1.1 2000/09/11 14:40:36 art Exp $"; + return "$KTH: fs_lib.c,v 1.31.2.3 2001/10/02 16:13:02 jimmy Exp $"; } /* @@ -578,6 +573,26 @@ fs_checkservers(char *cell, int32_t flags, u_int32_t *hosts, int numhosts) } /* + * check validity of cached volume information + */ + +int +fs_checkvolumes (void) +{ + struct ViceIoctl a_params; + + a_params.in = NULL; + a_params.in_size = 0; + a_params.out = NULL; + a_params.out_size = 0; + + if (k_pioctl (NULL, VIOCCKBACK, &a_params, 0) < 0) + return errno; + else + return 0; +} + +/* * return current sysname in `sys' (of max length `sys_sz') */ @@ -747,7 +762,7 @@ fs_newcell (const char *cell, int nservers, char **servers) struct ViceIoctl a_params; int len; char *buf; - int i; + int i, ret; u_int32_t *hp; nservers = min (nservers, 8); @@ -761,13 +776,20 @@ fs_newcell (const char *cell, int nservers, char **servers) strcpy (buf + 8 * sizeof(u_int32_t), cell); hp = (u_int32_t *)buf; for (i = 0; i < nservers; ++i) { - struct in_addr addr; - - if (str2inaddr (servers[i], &addr) == NULL) { + struct addrinfo hints, *res; + + memset (&hints, 0, sizeof(hints)); + hints.ai_family = PF_INET; + hints.ai_socktype = SOCK_DGRAM; + + ret = getaddrinfo(servers[i], NULL, &hints, &res); + if (ret < 0) { free (buf); return EINVAL; } - hp[i] = addr.s_addr; + assert (res->ai_family == PF_INET); + hp[i] = ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr; + freeaddrinfo(res); } a_params.in_size = len; @@ -775,10 +797,11 @@ fs_newcell (const char *cell, int nservers, char **servers) a_params.in = (caddr_t)buf; a_params.out = NULL; - if (k_pioctl (NULL, VIOCNEWCELL, &a_params, 0) < 0) + ret = k_pioctl (NULL, VIOCNEWCELL, &a_params, 0); + free (buf); + if (ret < 0) return errno; - else - return 0; + return 0; } /* @@ -919,3 +942,132 @@ fs_rmmount (const char *path) { return internal_mp (path, VIOC_AFS_DELETE_MT_PT, NULL); } + +int +fs_incompat_renumber (int *ret) +{ + struct ViceIoctl a_params; + unsigned char buf[1024]; + + a_params.in_size = 0; + a_params.out_size = sizeof(buf); + a_params.in = 0; + a_params.out = (caddr_t) buf; + + /* getcrypt or getinitparams */ + if (k_pioctl (NULL, _VICEIOCTL(49), &a_params, 0) < 0) { + if (errno == EINVAL) { + + /* not openafs or old openafs */ + + a_params.in_size = 0; + a_params.out_size = 4; + a_params.in = 0; + a_params.out = (caddr_t) buf; + + if (k_pioctl (NULL, _VICEIOCTL(49), &a_params, 0) < 0) { + if (errno == EINVAL) { + + a_params.in_size = 0; + a_params.out_size = 4; + a_params.in = 0; + a_params.out = (caddr_t) buf; + + /* might be new interface */ + + if (k_pioctl (NULL, _VICEIOCTL(55), &a_params, 0) < 0) + return errno; /* dunno */ + + *ret = 1; + return 0; + } else { + return errno; + } + } + *ret = 0; + return 0; + } else + return errno; + } + *ret = 1; + return 0; +} + + +/* + * + */ + +int +fs_statistics_list(u_int32_t *host, u_int32_t *part, int *n) +{ + u_int32_t data[512]; + u_int32_t indata; + struct ViceIoctl a_params; + int i; + + indata = STATISTICS_OPCODE_LIST; + + a_params.in_size = sizeof(indata); + a_params.out_size = sizeof(data); + a_params.in = (char *) &indata; + a_params.out = (char *) data; + + memset (data, 0, sizeof(data)); + + if (k_pioctl (NULL, AIOC_STATISTICS , &a_params, 0) == -1) + return errno; + + if (data[0] < *n) + *n = data[0]; + + for (i = 0; i < *n; i++) { + host[i] = data[2 * i + 1]; + part[i] = data[2 * i + 2]; + } + + return 0; +} + +int +fs_statistics_entry(u_int32_t host, u_int32_t part, u_int32_t type, + u_int32_t items_slot, u_int32_t *count, + int64_t *items_total, int64_t *total_time) +{ + u_int32_t data[160]; + u_int32_t indata[5]; + struct ViceIoctl a_params; + int i; + int j; + + indata[0] = STATISTICS_OPCODE_GETENTRY; + indata[1] = host; + indata[2] = part; + indata[3] = type; + indata[4] = items_slot; + + a_params.in_size = sizeof(indata); + a_params.out_size = sizeof(data); + a_params.in = (char *) indata; + a_params.out = (char *) data; + + memset (data, 0, sizeof(data)); + + if (k_pioctl (NULL, AIOC_STATISTICS , &a_params, 0) == -1) + return errno; + + j = 0; + for (i = 0; i < 32; i++) { + count[i] = data[j++]; + } + for (i = 0; i < 32; i++) { + memcpy(&items_total[i], &data[j], 8); + j+=2; + } + for (i = 0; i < 32; i++) { + memcpy(&total_time[i], &data[j], 8); + j+=2; + } + + return 0; +} diff --git a/usr.sbin/afs/src/appl/pts/Makefile.in b/usr.sbin/afs/src/appl/pts/Makefile.in index 59f0ce3fe4f..35669d2351d 100644 --- a/usr.sbin/afs/src/appl/pts/Makefile.in +++ b/usr.sbin/afs/src/appl/pts/Makefile.in @@ -1,6 +1,7 @@ -# $Id: Makefile.in,v 1.1 2000/09/11 14:40:36 art Exp $ +# $KTH: Makefile.in,v 1.11.2.2 2001/10/23 23:51:06 ahltorp Exp $ srcdir = @srcdir@ +top_builddir = ../.. VPATH = @srcdir@ CC = @CC@ @@ -29,6 +30,7 @@ SHELL = /bin/sh CFLAGS = @CFLAGS@ X_CFLAGS = @X_CFLAGS@ +LDFLAGS = @LDFLAGS@ ETAGS = etags MAKEDEPEND = makedepend @@ -42,6 +44,7 @@ INCLUDES = -I$(srcdir)/../.. \ $(KERNEL_INCLUDE) \ -I$(srcdir)/../../xfs/include \ -I$(srcdir)/../../arlad \ + @INC_roken@ \ $(RXKADINC) DEFINES = @@ -58,16 +61,15 @@ LIBS = -L../lib -larlalib \ -L../../lwp -llwp @PLWP_LIB_FLAGS@ \ -L../../lib/ko -lko -L../../util -lutil \ -L../../lib/sl -lsl \ - -L../../lib/roken \ $(READLINE_lib) \ + @LIB_roken@ \ $(RXKAD_LIBS) \ $(KAFS_LIBS) \ - $(RXKAD_LIBS) \ - -lroken @LIBS@ + $(RXKAD_LIBS) @LIBS@ LIBDEPENDS = ../../rxdef/librxdefclient.a ../../rx/librx.a ../../lwp/liblwp.a \ - ../../util/libutil.a ../../lib/sl/libsl.a ../../lib/roken/libroken.a \ - ../../lib/ko/libko.a + ../../util/libutil.a ../../lib/sl/libsl.a \ + ../../lib/ko/libko.a ../lib/libarlalib.a PROGS = pts PTS_SRCS = pts.c @@ -94,7 +96,7 @@ install: all e=`echo $$x | sed 's/.*\.\([1-9a-zA-Z]*\)$$/\1/'`; \ f=`echo $$n | sed '$(transform)'`; \ $(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$$e ; \ - $(INSTALL_PROGRAM) $(srcdir)/$$x \ + $(INSTALL_DATA) $(srcdir)/$$x \ $(DESTDIR)$(mandir)/man$$e/$$f.$$e; \ done @@ -130,7 +132,7 @@ clean : mostlyclean: clean distclean: clean - rm -f Makefile config.status + rm -f Makefile realclean: distclean rm -f TAGS diff --git a/usr.sbin/afs/src/appl/pts/pts.1 b/usr.sbin/afs/src/appl/pts/pts.1 index ed69def7891..4ff1aabfe42 100644 --- a/usr.sbin/afs/src/appl/pts/pts.1 +++ b/usr.sbin/afs/src/appl/pts/pts.1 @@ -1,5 +1,5 @@ -.\" $OpenBSD: pts.1,v 1.3 2001/07/25 10:04:57 mpech Exp $ -.\" $Id: pts.1,v 1.3 2001/07/25 10:04:57 mpech Exp $ +.\" $OpenBSD: pts.1,v 1.4 2002/06/07 04:28:42 hin Exp $ +.\" $KTH: pts.1,v 1.1.2.1 2001/07/26 19:54:02 lha Exp $ .Dd March 25, 2000 .Dt PTS 1 .Os @@ -245,7 +245,6 @@ implemented yet. .Bd -filled -offset indent -compact This command has not been implemented yet. .Ed -.Pp .Sh SEE ALSO .Xr afsd 8 , .Xr fs 1 , diff --git a/usr.sbin/afs/src/appl/pts/pts.c b/usr.sbin/afs/src/appl/pts/pts.c index 61755ade643..0a21f2e6d9a 100644 --- a/usr.sbin/afs/src/appl/pts/pts.c +++ b/usr.sbin/afs/src/appl/pts/pts.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,9 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska * Höskolan and its contributors. * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -39,7 +36,7 @@ #include <sl.h> #include "appl_locl.h" -RCSID("$Id: pts.c,v 1.1 2000/09/11 14:40:36 art Exp $"); +RCSID("$KTH: pts.c,v 1.50.2.2 2001/07/06 01:40:11 lha Exp $"); static int help_cmd (int argc, char **argv); @@ -53,60 +50,36 @@ empty_cmd (int argc, char **argv) return 0; } -static void -dump_usage (void) -{ - printf("Usage: pts dump <vldb server>+ [-cell <cell>]\n"); -} +/* + * Dump the pts database + */ static int -dump_cmd (int argc, char **argv) +dump_1 (struct rx_connection *connptdb) { - struct rx_connection *connptdb = NULL; struct prdebugentry entry; struct prheader header; - const char *host; - int noauth = 0; + unsigned int pos; int error; - argc--; - argv++; - - if (argc < 1) { - dump_usage (); - return -1; - } - - host = argv[0]; - - connptdb = arlalib_getconnbyname(cell_getcellbyhost(host), - host, - afsprport, - PR_SERVICE_ID, - arlalib_getauthflag (noauth, 0, 0, 0)); - - if (connptdb == NULL) - return 0; - error = PR_DumpEntry(connptdb, 0, (struct prdebugentry *) &header); - if (error) { printf("dump_cmd: DumpEntry failed with: %s (%d)\n", koerr_gettext(error), error); return 0; } - - for (pos = header.headerSize; pos < header.eofPtr; pos += sizeof (struct prdebugentry)) { + + for (pos = header.headerSize; + pos < header.eofPtr; + pos += sizeof (struct prdebugentry)) { error = PR_DumpEntry(connptdb, pos, &entry); if (error) { printf("dump_cmd: DumpEntry failed with: %s (%d)\n", koerr_gettext(error), error); -/* return -1;*/ - } - else { + } else { printf("-----\n"); printf("Name: %s, id: %d, owner: %d, creator: %d,\n", entry.name, entry.id, entry.owner, entry.creator); @@ -129,13 +102,57 @@ dump_cmd (int argc, char **argv) printf (" PRACCESS"); if ((entry.flags & PRQUOTA) == PRQUOTA) printf (" PRQUOTA"); - + printf (" , group quota: %d.\n", entry.ngroups); } } + return 0; +} + +/* + * Dump the pts database, should be replaced with 'pts liste' + */ + +static int +dump_cmd (int argc, char **argv) +{ + struct rx_connection *conn; + struct db_server_context conn_context; + const char *host = NULL; + const char *cell = (char *) cell_getthiscell(); + int noauth = 0; + int optind = 0; + int error = ENETDOWN; + + struct agetargs args[] = { + {"host", 0, aarg_string, NULL, NULL, NULL, aarg_mandatory}, + {"cell", 0, aarg_string, NULL, "what cell to use", NULL}, + {"noauth", 0, aarg_flag, NULL, "don't authenticate", NULL}, + {NULL, 0, aarg_end, NULL}}, + *arg; + arg = args; + arg->value = &host; arg++; + arg->value = &cell; arg++; + arg->value = &noauth; arg++; + + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(args, "pts dump", NULL, AARG_AFSSTYLE); + return 0; + } + + cell = cell_expand_cell (cell); + + for (conn = arlalib_first_db(&conn_context, + cell, host, afsprport, PR_SERVICE_ID, + arlalib_getauthflag (noauth, 0, 0, 0)); + conn != NULL && arlalib_try_next_db(error); + conn = arlalib_next_db(&conn_context)) { + error = dump_1 (conn); + } + free_db_server_context(&conn_context); + return error; - arlalib_destroyconn(connptdb); return 0; } @@ -662,7 +679,10 @@ pts_name_to_id(struct rx_connection *conn, const char *name, int32_t *id) errx(1, "Out of memory"); strlcpy(nlist.val[0], name, sizeof(prname)); res = PR_NameToID(conn, &nlist, &ilist); - *id = ilist.val[0]; + if (res == 0) + *id = ilist.val[0]; + if (*id == PR_ANONYMOUSID) + res = PRNOENT; free(ilist.val); free(nlist.val); return res; @@ -678,8 +698,6 @@ listowned_1 (struct rx_connection *conn, const char *user) prlist pr; int i; - printf("%s\n", user); - error = pts_name_to_id (conn, user, &id); if(error != 0) return error; @@ -689,14 +707,10 @@ listowned_1 (struct rx_connection *conn, const char *user) if(pr.val == NULL) errx(1, "Out of memory"); - printf("%d\n", id); error = PR_ListOwned(conn, id, &pr, &over); if(error != 0) return error; - printf("id = %d\n", id); - printf("pr.len = %d\n", pr.len); - i = 0; name = malloc(PR_MAXNAMELEN); if(name == NULL) @@ -747,14 +761,14 @@ create_cmd(int argc, char **argv, int groupp, const char *cmd_name) int error; int optind = 0; - struct getargs createuserarg[] = { - {"name", 0, arg_string, NULL, NULL, NULL, arg_mandatory}, - {"owner", 0, arg_string, NULL, "owner of the group"}, - {"id", 0, arg_integer, NULL, "id of user", NULL}, - {"cell", 0, arg_string, NULL, "what cell to use", NULL}, - {"host", 0, arg_string, NULL, "specified db", NULL}, - {"noauth", 0, arg_flag, NULL, "don't authenticate", NULL}, - {NULL, 0, arg_end, NULL}}, + struct agetargs createuserarg[] = { + {"name", 0, aarg_string, NULL, NULL, NULL, aarg_mandatory}, + {"owner", 0, aarg_string, NULL, "owner of the group"}, + {"id", 0, aarg_integer, NULL, "id of user", NULL}, + {"cell", 0, aarg_string, NULL, "what cell to use", NULL}, + {"host", 0, aarg_string, NULL, "specified db", NULL}, + {"noauth", 0, aarg_flag, NULL, "don't authenticate", NULL}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = createuserarg; @@ -773,11 +787,13 @@ create_cmd(int argc, char **argv, int groupp, const char *cmd_name) memmove (&createuserarg[1], &createuserarg[2], 6 * sizeof(createuserarg[0])); - if (getarg (createuserarg, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(createuserarg, cmd_name, NULL, ARG_AFSSTYLE); + if (agetarg (createuserarg, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(createuserarg, cmd_name, NULL, AARG_AFSSTYLE); return 0; } + cell = cell_expand_cell (cell); + error = pr_create(cell, host, name, owner, &id, groupp, arlalib_getauthflag (noauth, 0, 0, 0)); if (error) { @@ -825,13 +841,13 @@ adduser_cmd(int argc, char **argv) int error; int optind = 0; - struct getargs addarg[] = { - {"name", 0, arg_string, NULL, "username", NULL, arg_mandatory}, - {"group", 0, arg_string, NULL, "groupname",NULL, arg_mandatory}, - {"cell", 0, arg_string, NULL, "what cell to use", NULL}, - {"host", 0, arg_string, NULL, "specified db", NULL}, - {"noauth", 0, arg_flag, NULL, "don't authenticate", NULL}, - {NULL, 0, arg_end, NULL}}, + struct agetargs addarg[] = { + {"name", 0, aarg_string, NULL, "username", NULL, aarg_mandatory}, + {"group", 0, aarg_string, NULL, "groupname",NULL, aarg_mandatory}, + {"cell", 0, aarg_string, NULL, "what cell to use", NULL}, + {"host", 0, aarg_string, NULL, "specified db", NULL}, + {"noauth", 0, aarg_flag, NULL, "don't authenticate", NULL}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = addarg; @@ -841,11 +857,13 @@ adduser_cmd(int argc, char **argv) arg->value = &host; arg++; arg->value = &noauth; arg++; - if (getarg (addarg, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(addarg, "pts adduser", NULL, ARG_AFSSTYLE); + if (agetarg (addarg, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(addarg, "pts adduser", NULL, AARG_AFSSTYLE); return 0; } + cell = cell_expand_cell (cell); + error = pr_adduser(cell, host, user, group, arlalib_getauthflag (noauth, 0, 0, 0)); if (error) { @@ -863,19 +881,19 @@ adduser_cmd(int argc, char **argv) static int delete_cmd(int argc, char **argv) { - const char *user; + const char *user = NULL; const char *cell = cell_getthiscell(); const char *host = NULL; int noauth = 0; int error; int optind = 0; - struct getargs deletearg[] = { - {"name", 0, arg_string, NULL, "username", NULL, arg_mandatory}, - {"cell", 0, arg_string, NULL, "what cell to use", NULL}, - {"host", 0, arg_string, NULL, "specified db", NULL}, - {"noauth", 0, arg_flag, NULL, "don't authenticate", NULL}, - {NULL, 0, arg_end, NULL}}, + struct agetargs deletearg[] = { + {"name", 0, aarg_string, NULL, "username", NULL, aarg_mandatory}, + {"cell", 0, aarg_string, NULL, "what cell to use", NULL}, + {"host", 0, aarg_string, NULL, "specified db", NULL}, + {"noauth", 0, aarg_flag, NULL, "don't authenticate", NULL}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = deletearg; @@ -884,11 +902,13 @@ delete_cmd(int argc, char **argv) arg->value = &host; arg++; arg->value = &noauth; arg++; - if (getarg (deletearg, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(deletearg, "pts delete", NULL, ARG_AFSSTYLE); + if (agetarg (deletearg, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(deletearg, "pts delete", NULL, AARG_AFSSTYLE); return 0; } + cell = cell_expand_cell (cell); + error = pr_delete(cell, host, user, arlalib_getauthflag (noauth, 0, 0, 0)); if (error) { @@ -908,21 +928,21 @@ delete_cmd(int argc, char **argv) static int removeuser_cmd(int argc, char **argv) { - const char *user; - const char *group; + const char *user = NULL; + const char *group = NULL; const char *cell = cell_getthiscell(); const char *host = NULL; int noauth = 0; int error; int optind = 0; - struct getargs removearg[] = { - {"user", 0, arg_string, NULL, "username", NULL, arg_mandatory}, - {"group", 0, arg_string, NULL, "group", NULL, arg_mandatory}, - {"cell", 0, arg_string, NULL, "what cell to use", NULL}, - {"host", 0, arg_string, NULL, "specified db", NULL}, - {"noauth", 0, arg_flag, NULL, "don't authenticate", NULL}, - {NULL, 0, arg_end, NULL}}, + struct agetargs removearg[] = { + {"user", 0, aarg_string, NULL, "username", NULL, aarg_mandatory}, + {"group", 0, aarg_string, NULL, "group", NULL, aarg_mandatory}, + {"cell", 0, aarg_string, NULL, "what cell to use", NULL}, + {"host", 0, aarg_string, NULL, "specified db", NULL}, + {"noauth", 0, aarg_flag, NULL, "don't authenticate", NULL}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = removearg; @@ -932,11 +952,13 @@ removeuser_cmd(int argc, char **argv) arg->value = &host; arg++; arg->value = &noauth; arg++; - if (getarg (removearg, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(removearg, "pts remove", NULL, ARG_AFSSTYLE); + if (agetarg (removearg, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(removearg, "pts remove", NULL, AARG_AFSSTYLE); return 0; } + cell = cell_expand_cell (cell); + error = pr_removeuser(cell, host, user, group, arlalib_getauthflag (noauth, 0, 0, 0)); if (error) { @@ -956,21 +978,21 @@ removeuser_cmd(int argc, char **argv) static int rename_cmd(int argc, char **argv) { - const char *fromname; - const char *toname; + const char *fromname = NULL; + const char *toname = NULL; const char *cell = cell_getthiscell(); const char *host = NULL; int noauth = 0; int error; int optind = 0; - struct getargs renamearg[] = { - {"from", 0, arg_string, NULL, "from name",NULL, arg_mandatory}, - {"to", 0, arg_string, NULL, "to name", NULL, arg_mandatory}, - {"cell", 0, arg_string, NULL, "what cell to use", NULL}, - {"host", 0, arg_string, NULL, "specified db", NULL}, - {"noauth", 0, arg_flag, NULL, "don't authenticate", NULL}, - {NULL, 0, arg_end, NULL}}, + struct agetargs renamearg[] = { + {"from", 0, aarg_string, NULL, "from name",NULL, aarg_mandatory}, + {"to", 0, aarg_string, NULL, "to name", NULL, aarg_mandatory}, + {"cell", 0, aarg_string, NULL, "what cell to use", NULL}, + {"host", 0, aarg_string, NULL, "specified db", NULL}, + {"noauth", 0, aarg_flag, NULL, "don't authenticate", NULL}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = renamearg; @@ -980,11 +1002,13 @@ rename_cmd(int argc, char **argv) arg->value = &host; arg++; arg->value = &noauth; arg++; - if (getarg (renamearg, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(renamearg, "pts rename", NULL, ARG_AFSSTYLE); + if (agetarg (renamearg, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(renamearg, "pts rename", NULL, AARG_AFSSTYLE); return 0; } + cell = cell_expand_cell (cell); + error = pr_rename(cell, host, fromname, toname, arlalib_getauthflag (noauth, 0, 0, 0)); if (error) { @@ -1016,7 +1040,7 @@ setfields_error(void) static int setfields_cmd(int argc, char **argv) { - const char *name; + const char *name = NULL; const char *strflags = NULL; int flags = -1; int gquota = -1; @@ -1027,15 +1051,15 @@ setfields_cmd(int argc, char **argv) int error; int optind = 0; - struct getargs setfieldarg[] = { - {"name", 0, arg_string, NULL, "name of user/group", - NULL, arg_mandatory}, - {"flags", 0, arg_string, NULL, "flags", NULL}, - {"groupquota", 0, arg_integer, NULL, "groupquota",NULL}, - {"cell", 0, arg_string, NULL, "what cell to use", NULL}, - {"host", 0, arg_string, NULL, "specified db", NULL}, - {"noauth", 0, arg_flag, NULL, "don't authenticate", NULL}, - {NULL, 0, arg_end, NULL}}, + struct agetargs setfieldarg[] = { + {"name", 0, aarg_string, NULL, "name of user/group", + NULL, aarg_mandatory}, + {"flags", 0, aarg_string, NULL, "flags", NULL}, + {"groupquota", 0, aarg_integer, NULL, "groupquota",NULL}, + {"cell", 0, aarg_string, NULL, "what cell to use", NULL}, + {"host", 0, aarg_string, NULL, "specified db", NULL}, + {"noauth", 0, aarg_flag, NULL, "don't authenticate", NULL}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = setfieldarg; @@ -1046,8 +1070,8 @@ setfields_cmd(int argc, char **argv) arg->value = &host; arg++; arg->value = &noauth; arg++; - if (getarg (setfieldarg, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(setfieldarg, "pts setfields", NULL, ARG_AFSSTYLE); + if (agetarg (setfieldarg, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(setfieldarg, "pts setfields", NULL, AARG_AFSSTYLE); return 0; } @@ -1089,6 +1113,8 @@ setfields_cmd(int argc, char **argv) return setfields_error(); } + cell = cell_expand_cell (cell); + error = pr_setfields(cell, host, name, flags, gquota, uquota, arlalib_getauthflag (noauth, 0, 0, 0)); if (error) { @@ -1108,23 +1134,23 @@ setfields_cmd(int argc, char **argv) static int chown_cmd(int argc, char **argv) { - const char *name; - const char *owner; + const char *name = NULL; + const char *owner = NULL; const char *cell = cell_getthiscell(); - const char *host; + const char *host = NULL; int noauth = 0; int error; int optind = 0; - struct getargs chownarg[] = { - {"name", 0, arg_string, NULL, "user or group name", - NULL, arg_mandatory}, - {"owner", 0, arg_string, NULL, "new owner", - NULL, arg_mandatory}, - {"host", 0, arg_string, NULL, "specified db", NULL}, - {"cell", 0, arg_string, NULL, "what cell to use", NULL}, - {"noauth", 0, arg_flag, NULL, "don't authenticate", NULL}, - {NULL, 0, arg_end, NULL}}, + struct agetargs chownarg[] = { + {"name", 0, aarg_string, NULL, "user or group name", + NULL, aarg_mandatory}, + {"owner", 0, aarg_string, NULL, "new owner", + NULL, aarg_mandatory}, + {"host", 0, aarg_string, NULL, "specified db", NULL}, + {"cell", 0, aarg_string, NULL, "what cell to use", NULL}, + {"noauth", 0, aarg_flag, NULL, "don't authenticate", NULL}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = chownarg; @@ -1134,11 +1160,13 @@ chown_cmd(int argc, char **argv) arg->value = &host; arg++; arg->value = &noauth; arg++; - if (getarg (chownarg, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(chownarg, "pts chown", NULL, ARG_AFSSTYLE); + if (agetarg (chownarg, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(chownarg, "pts chown", NULL, AARG_AFSSTYLE); return 0; } + cell = cell_expand_cell (cell); + error = pr_chown(cell, host, name, owner, arlalib_getauthflag (noauth, 0, 0, 0)); if (error) { @@ -1156,7 +1184,7 @@ chown_cmd(int argc, char **argv) */ static int -examine1 (struct rx_connection *conn, getarg_strings *users) +examine1 (struct rx_connection *conn, agetarg_strings *users) { namelist nlist; idlist ilist; @@ -1212,20 +1240,20 @@ examine_cmd (int argc, char **argv) struct rx_connection *connptdb = NULL; struct db_server_context conn_context; int noauth = 1; - getarg_strings users = {0 , NULL }; + agetarg_strings users = {0 , NULL }; int optind = 0; int error = -1; - struct getargs examinearg[] = { - {"nameorid", 0, arg_strings, NULL, "user or group name", - NULL, arg_mandatory}, - {"cell", 0, arg_string, NULL, "what cell to use", - NULL, arg_optional}, - {"host", 0, arg_string, NULL, "specified db", - NULL, arg_optional}, - {"noauth", 0, arg_flag, NULL, "don't authenticate", - NULL, arg_optional}, - {NULL, 0, arg_end, NULL}}, *arg; + struct agetargs examinearg[] = { + {"nameorid", 0, aarg_strings, NULL, "user or group name", + NULL, aarg_mandatory}, + {"cell", 0, aarg_string, NULL, "what cell to use", + NULL, aarg_optional}, + {"host", 0, aarg_string, NULL, "specified db", + NULL, aarg_optional}, + {"noauth", 0, aarg_flag, NULL, "don't authenticate", + NULL, aarg_optional}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = examinearg; arg->value = &users; arg++; @@ -1233,11 +1261,13 @@ examine_cmd (int argc, char **argv) arg->value = &host; arg++; arg->value = &noauth; arg++; - if (getarg (examinearg, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(examinearg, "pts examine", NULL, ARG_AFSSTYLE); + if (agetarg (examinearg, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(examinearg, "pts examine", NULL, AARG_AFSSTYLE); return 0; } + cell = cell_expand_cell (cell); + error = ENETDOWN; for (connptdb = arlalib_first_db(&conn_context, cell, host, afsprport, PR_SERVICE_ID, @@ -1263,25 +1293,27 @@ listmax_cmd (int argc, char **argv) int optind = 0; int noauth = 0; - struct getargs examinearg[] = { - {"cell", 0, arg_string, NULL, "what cell to use", - NULL, arg_optional}, - {"host", 0, arg_string, NULL, "specified db", - NULL, arg_optional}, - {"noauth", 0, arg_flag, NULL, "don't authenticate", - NULL, arg_optional}, - {NULL, 0, arg_end, NULL}}, *arg; + struct agetargs examinearg[] = { + {"cell", 0, aarg_string, NULL, "what cell to use", + NULL, aarg_optional}, + {"host", 0, aarg_string, NULL, "specified db", + NULL, aarg_optional}, + {"noauth", 0, aarg_flag, NULL, "don't authenticate", + NULL, aarg_optional}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = examinearg; arg->value = &cell; arg++; arg->value = &host; arg++; arg->value = &noauth; arg++; - if (getarg (examinearg, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(examinearg, "pts listmax", NULL, ARG_AFSSTYLE); + if (agetarg (examinearg, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(examinearg, "pts listmax", NULL, AARG_AFSSTYLE); return 0; } + cell = cell_expand_cell (cell); + error = ENETDOWN; for (connptdb = arlalib_first_db(&conn_context, cell, host, afsprport, PR_SERVICE_ID, @@ -1303,41 +1335,35 @@ listmembershipbyname(struct rx_connection *conn, const char *name) { int32_t res = 0; int32_t id = 0; + int32_t over; + int i; + prlist elist; res = pts_name_to_id(conn, name, &id); - if(res) { - fprintf(stderr, "membership: error %s (%d)\n", - koerr_gettext(res), res); + if(res) return res; - } else { - int32_t over; - int i; - prlist elist; - elist.len = PR_MAXGROUPS; /* XXX this will allocate 5000 ints, should - check how many groups first. That will take - a lot of code though. */ - elist.val = malloc(sizeof(int32_t) * elist.len); - if(elist.val == NULL) - errx(1, "Out of memory"); - res = PR_ListElements(conn, id, &elist, &over); - if(res != 0) { - fprintf(stderr, "membership: error %s (%d)\n", - koerr_gettext(res), res); - return res; - } else { - if(id>=0) - printf("Groups %s (id: %d) is a member of:\n", name, id); - else - printf("Members of %s (id: %d) are:\n", name, id); - for(i = 0; i < elist.len; i++) { - prname pr; - res = pts_id_to_name(conn, elist.val[i], &pr); - printf(" %s\n", (char *)&pr); - } - free(elist.val); - return 0; - } + + elist.len = PR_MAXGROUPS; /* XXX this will allocate 5000 ints, should + check how many groups first. That will take + a lot of code though. */ + elist.val = malloc(sizeof(int32_t) * elist.len); + if(elist.val == NULL) + errx(1, "Out of memory"); + res = PR_ListElements(conn, id, &elist, &over); + if(res != 0) + return res; + + if(id>=0) + printf("Groups %s (id: %d) is a member of:\n", name, id); + else + printf("Members of %s (id: %d) are:\n", name, id); + for(i = 0; i < elist.len; i++) { + prname pr; + res = pts_id_to_name(conn, elist.val[i], &pr); + printf(" %s\n", (char *)&pr); } + free(elist.val); + return 0; } static int @@ -1351,17 +1377,17 @@ member_cmd (int argc, char **argv) int32_t noauth = 0; int i = 0; int optind = 0; - getarg_strings users = {0 , NULL }; - - struct getargs memarg[] = { - {"nameorid", 0, arg_strings, NULL, "user or group name", - NULL, arg_mandatory}, - {"cell", 0, arg_string, NULL, "what cell to use", - NULL, arg_optional}, - {"host", 0, arg_string, NULL, "specified db", NULL}, - {"noauth", 0, arg_flag, NULL, "don't authenticate", - NULL, arg_optional}, - {NULL, 0, arg_end, NULL}}, *arg; + agetarg_strings users = {0 , NULL }; + + struct agetargs memarg[] = { + {"nameorid", 0, aarg_strings, NULL, "user or group name", + NULL, aarg_mandatory}, + {"cell", 0, aarg_string, NULL, "what cell to use", + NULL, aarg_optional}, + {"host", 0, aarg_string, NULL, "specified db", NULL}, + {"noauth", 0, aarg_flag, NULL, "don't authenticate", + NULL, aarg_optional}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = memarg; arg->value = &users; arg++; @@ -1369,14 +1395,15 @@ member_cmd (int argc, char **argv) arg->value = &host; arg++; arg->value = &noauth; arg++; - if (getarg (memarg, argc, argv, &optind, ARG_AFSSTYLE)) { - arg_printusage(memarg, "pts membership", NULL, ARG_AFSSTYLE); + if (agetarg (memarg, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage(memarg, "pts membership", NULL, AARG_AFSSTYLE); return 0; } - for(i=0;i<users.num_strings;i++) - printf("%s\n", users.strings[i]); - + cell = cell_expand_cell (cell); + + memset(&conn_context, '\0', sizeof(struct db_server_context)); + error = ENETDOWN; for (connptdb = arlalib_first_db(&conn_context, cell, host, afsprport, PR_SERVICE_ID, @@ -1390,16 +1417,13 @@ member_cmd (int argc, char **argv) error = tmp; } } + if (error) + fprintf(stderr, "membership: %s (%d)\n", + koerr_gettext(error), error); free_db_server_context(&conn_context); return 0; } -static void -listowned_usage(void) -{ - printf("Usage: pts [-id] <user or group> [-cell <cell>] [-noauth] [-help]\n"); -} - static int listowned_cmd(int argc, char **argv) { @@ -1410,14 +1434,14 @@ listowned_cmd(int argc, char **argv) const char *host = NULL; int noauth = 0; - static struct getargs listowned_args[] = { - {"id", 0, arg_string, NULL, "id of user/group", - NULL, arg_mandatory}, - {"cell", 0, arg_string, NULL, "what cell to use", + static struct agetargs listowned_args[] = { + {"id", 0, aarg_string, NULL, "id of user/group", + NULL, aarg_mandatory}, + {"cell", 0, aarg_string, NULL, "what cell to use", NULL}, - {"host", 0, arg_string, NULL, "specified db", NULL}, - {"noauth", 0, arg_flag, NULL, "don't authenticate", NULL}, - {NULL, 0, arg_end, NULL}}, *arg; + {"host", 0, aarg_string, NULL, "specified db", NULL}, + {"noauth", 0, aarg_flag, NULL, "don't authenticate", NULL}, + {NULL, 0, aarg_end, NULL}}, *arg; arg = listowned_args; arg->value = &user; arg++; @@ -1425,11 +1449,13 @@ listowned_cmd(int argc, char **argv) arg->value = &host; arg++; arg->value = &noauth; arg++; - if (getarg (listowned_args, argc, argv, &optind, ARG_AFSSTYLE)) { - listowned_usage(); + if (agetarg (listowned_args, argc, argv, &optind, AARG_AFSSTYLE)) { + aarg_printusage (listowned_args, "pts listowned", NULL, AARG_AFSSTYLE); return 0; } + cell = cell_expand_cell (cell); + error = pr_listowned (cell, host, user, arlalib_getauthflag (noauth, 0, 0, 0)); if (error) @@ -1494,12 +1520,19 @@ int main(int argc, char **argv) { int ret = 0; + Log_method *method; char **myargv; int pos = 0; int i; + set_progname(argv[0]); + tzset(); + + method = log_open (get_progname(), "/dev/stderr:notime"); + if (method == NULL) + errx (1, "log_open failed"); + cell_init(0, method); ports_init(); - cell_init(0); /* XXX */ myargv = malloc((argc + 1) * sizeof(char *)); if (myargv == NULL) diff --git a/usr.sbin/afs/src/appl/udebug/Makefile.in b/usr.sbin/afs/src/appl/udebug/Makefile.in index 9213138dca7..b6841d47dd8 100644 --- a/usr.sbin/afs/src/appl/udebug/Makefile.in +++ b/usr.sbin/afs/src/appl/udebug/Makefile.in @@ -1,6 +1,7 @@ -# $Id: Makefile.in,v 1.1 2000/09/11 14:40:36 art Exp $ +# $KTH: Makefile.in,v 1.11.2.2 2001/10/23 23:52:12 ahltorp Exp $ srcdir = @srcdir@ +top_builddir = ../.. VPATH = @srcdir@ CC = @CC@ @@ -29,6 +30,7 @@ SHELL = /bin/sh CFLAGS = @CFLAGS@ X_CFLAGS = @X_CFLAGS@ +LDFLAGS = @LDFLAGS@ ETAGS = etags MAKEDEPEND = makedepend @@ -42,6 +44,7 @@ INCLUDES = -I$(srcdir)/../.. \ $(KERNEL_INCLUDE) \ -I$(srcdir)/../../xfs/include \ -I$(srcdir)/../../arlad \ + @INC_roken@ \ $(RXKADINC) DEFINES = @@ -58,16 +61,15 @@ LIBS = -L../lib -larlalib \ -L../../lwp -llwp @PLWP_LIB_FLAGS@ \ -L../../lib/ko -lko -L../../util -lutil \ -L../../lib/sl -lsl \ - -L../../lib/roken \ $(READLINE_lib) \ + @LIB_roken@ \ $(RXKAD_LIBS) \ $(KAFS_LIBS) \ - $(RXKAD_LIBS) \ - -lroken @LIBS@ + $(RXKAD_LIBS) @LIBS@ LIBDEPENDS = ../../rxdef/librxdefclient.a ../../rx/librx.a ../../lwp/liblwp.a \ - ../../util/libutil.a ../../lib/sl/libsl.a ../../lib/roken/libroken.a \ - ../../lib/ko/libko.a + ../../util/libutil.a ../../lib/sl/libsl.a \ + ../../lib/ko/libko.a ../lib/libarlalib.a PROGS = udebug UDEBUG_SRCS = udebug.c @@ -94,7 +96,7 @@ install: all e=`echo $$x | sed 's/.*\.\([1-9a-zA-Z]*\)$$/\1/'`; \ f=`echo $$n | sed '$(transform)'`; \ $(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$$e ; \ - $(INSTALL_PROGRAM) $(srcdir)/$$x \ + $(INSTALL_DATA) $(srcdir)/$$x \ $(DESTDIR)$(mandir)/man$$e/$$f.$$e; \ done @@ -130,7 +132,7 @@ clean : mostlyclean: clean distclean: clean - rm -f Makefile config.status + rm -f Makefile realclean: distclean rm -f TAGS diff --git a/usr.sbin/afs/src/appl/udebug/udebug.1 b/usr.sbin/afs/src/appl/udebug/udebug.1 index 12db791a070..8fe6d5ee71d 100644 --- a/usr.sbin/afs/src/appl/udebug/udebug.1 +++ b/usr.sbin/afs/src/appl/udebug/udebug.1 @@ -1,7 +1,6 @@ -.\" Copyright (c) 2000 Kungliga Tekniska Högskolan -.\" $Id: udebug.1,v 1.3 2001/07/25 10:04:57 mpech Exp $ +.\" $KTH: udebug.1,v 1.3 2000/09/09 14:28:54 lha Exp $ .Dd Aug 06, 2000 -.Dt UDEBUG SECTION +.Dt UDEBUG 1 .Os Arla .Sh NAME .Nm udebug diff --git a/usr.sbin/afs/src/appl/udebug/udebug.c b/usr.sbin/afs/src/appl/udebug/udebug.c index b5d62b76351..5a7f1c4b649 100644 --- a/usr.sbin/afs/src/appl/udebug/udebug.c +++ b/usr.sbin/afs/src/appl/udebug/udebug.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +32,7 @@ */ #include "appl_locl.h" -RCSID("$Id: udebug.c,v 1.1 2000/09/11 14:40:36 art Exp $"); +RCSID("$KTH: udebug.c,v 1.18 2000/10/10 17:30:04 lha Exp $"); static int verbose = 0; @@ -45,7 +40,7 @@ static void usage(void) { fprintf(stderr, - "udebug: Version $Id: udebug.c,v 1.1 2000/09/11 14:40:36 art Exp $\n" + "udebug: Version $KTH: udebug.c,v 1.18 2000/10/10 17:30:04 lha Exp $\n" "usage: udebug -servers server ... -port port -noauth -long\n"); exit(1); } @@ -54,16 +49,23 @@ usage(void) static void newhost(u_int32_t **hosts, int *len, char *host) { - struct in_addr server; + struct addrinfo hints, *res; u_int32_t *ptr; + int ret; if (host == NULL) return; - - if (str2inaddr (host, &server) == NULL) { + + memset (&hints, 0, sizeof(hints)); + hints.ai_family = PF_INET; + hints.ai_socktype = SOCK_DGRAM; + + ret = getaddrinfo(host, NULL, &hints, &res); + if (ret < 0) { warnx("cant find addr for '%s'.", host); return; } + assert (res->ai_family == PF_INET); ptr = realloc(*hosts, sizeof(u_int32_t) * ++*len); if (ptr == NULL) @@ -71,14 +73,17 @@ newhost(u_int32_t **hosts, int *len, char *host) *hosts = ptr; - ptr[*len-1] = server.s_addr; + ptr[*len-1] = ((struct sockaddr_in *)res->ai_addr)->sin_addr.s_addr; + + freeaddrinfo(res); } static const char * -myctime(const time_t *time, char *datestr, size_t sz) +myctime(time_t time, char *datestr, size_t sz) { struct tm tm; - strftime (datestr, sz, "%c", localtime_r(time, &tm)); + strftime (datestr, sz, "%Y-%m-%d %H:%M:%S", + localtime_r(&time, &tm)); return datestr; } @@ -122,18 +127,18 @@ ProbeHost(u_int32_t host, u_int16_t port, arlalib_authflags_t auth) printf("Host %s time is %s\n", inet_ntoa(server), - myctime(&db.now, datestring, sizeof(datestring))); + myctime(db.now, datestring, sizeof(datestring))); printf("Localtime is %s, differ %d seconds\n", - myctime(&tv.tv_sec, datestring, sizeof(datestring)), + myctime(tv.tv_sec, datestring, sizeof(datestring)), abs(db.now - tv.tv_sec)); server.s_addr = htonl(db.syncHost); printf("Last yes vote for %s secs was %d ago (at %s)\n", inet_ntoa(server), ABS_COMP_DB(db,lastYesTime), - myctime(&db.lastYesTime, datestring, sizeof(datestring))); + myctime(db.lastYesTime, datestring, sizeof(datestring))); printf("Last vote started %d secs ago (at %s)\n", ABS_COMP_DB(db,syncTime), - myctime(&db.lastYesTime, datestring, sizeof(datestring))); + myctime(db.lastYesTime, datestring, sizeof(datestring))); printf("Local db version is %u.%u\n", db.localVersion.epoch, db.localVersion.counter); @@ -147,7 +152,7 @@ ProbeHost(u_int32_t host, u_int16_t port, arlalib_authflags_t auth) printf("I'm the synchost for %d seconds more (%s)\n", db.syncSiteUntil - db.now, - myctime(&db.syncSiteUntil, datestring, sizeof(datestring))); + myctime(db.syncSiteUntil, datestring, sizeof(datestring))); } else { server.s_addr = htonl(db.syncHost); printf("I'm not the synchost, but %s is.\n", @@ -180,7 +185,7 @@ ProbeHost(u_int32_t host, u_int16_t port, arlalib_authflags_t auth) printf("Last time a new db version was laballed was:\n" "\t\t%d secs ago (at %s)\n\n", ABS_COMP_DB(db,epochTime), - myctime(&db.epochTime, datestring, sizeof(datestring))); + myctime(db.epochTime, datestring, sizeof(datestring))); for (i = 0; i < db.nServers - 1; i++) { @@ -197,11 +202,11 @@ ProbeHost(u_int32_t host, u_int16_t port, arlalib_authflags_t auth) sdb.remoteVersion.counter); printf("\tlast vote recived %d secs ago (at %s)\n", ABS_COMP_DB(sdb,lastVoteTime), - myctime(&sdb.lastVoteTime, + myctime(sdb.lastVoteTime, datestring, sizeof(datestring))); printf("\tlast beacon sent %d secs ago (at %s)\n", ABS_COMP_DB(sdb,lastBeaconSent), - myctime(&sdb.lastBeaconSent, + myctime(sdb.lastBeaconSent, datestring, sizeof(datestring))); printf("\tdbcurrent=%d, up=%d, beaconSince=%u\n", sdb.currentDB, diff --git a/usr.sbin/afs/src/appl/vos/Makefile.in b/usr.sbin/afs/src/appl/vos/Makefile.in index d43e09975b1..3d91a9d4804 100644 --- a/usr.sbin/afs/src/appl/vos/Makefile.in +++ b/usr.sbin/afs/src/appl/vos/Makefile.in @@ -1,6 +1,7 @@ -# $Id: Makefile.in,v 1.1 2000/09/11 14:40:37 art Exp $ +# $KTH: Makefile.in,v 1.12.2.3 2001/10/23 23:52:40 ahltorp Exp $ srcdir = @srcdir@ +top_builddir = ../.. VPATH = @srcdir@ CC = @CC@ @@ -29,6 +30,7 @@ SHELL = /bin/sh CFLAGS = @CFLAGS@ X_CFLAGS = @X_CFLAGS@ +LDFLAGS = @LDFLAGS@ ETAGS = etags MAKEDEPEND = makedepend @@ -42,6 +44,7 @@ INCLUDES = -I$(srcdir)/../.. \ $(KERNEL_INCLUDE) \ -I$(srcdir)/../../xfs/include \ -I$(srcdir)/../../arlad \ + @INC_roken@ \ $(RXKADINC) DEFINES = @@ -58,29 +61,28 @@ LIBS = -L../lib -larlalib \ -L../../lwp -llwp @PLWP_LIB_FLAGS@ \ -L../../lib/ko -lko -L../../util -lutil \ -L../../lib/sl -lsl \ - -L../../lib/roken \ $(READLINE_lib) \ + @LIB_roken@ \ $(RXKAD_LIBS) \ $(KAFS_LIBS) \ - $(RXKAD_LIBS) \ - -lroken @LIBS@ + $(RXKAD_LIBS) @LIBS@ LIBDEPENDS = ../../rxdef/librxdefclient.a ../../rx/librx.a ../../lwp/liblwp.a \ - ../../util/libutil.a ../../lib/sl/libsl.a ../../lib/roken/libroken.a \ - ../../lib/ko/libko.a + ../../util/libutil.a ../../lib/sl/libsl.a \ + ../../lib/ko/libko.a ../lib/libarlalib.a PROGS = vos VOS_SRCS = vos.c vos_common.c vos_examine.c vos_listvol.c \ vos_partinfo.c vos_status.c vos_createentry.c \ vos_listpart.c vos_syncsite.c vos_listvldb.c vos_dump.c \ vos_createvolume.c vos_endtrans.c vos_vldbexamine.c \ - vos_lock.c vos_unlock.c + vos_lock.c vos_unlock.c vos_backup.c SRCS = $(VOS_SRCS) VOS_OBJS = vos.o vos_common.o vos_examine.o vos_listvol.o \ vos_partinfo.o vos_status.o vos_createentry.o \ vos_listpart.o vos_syncsite.o vos_listvldb.o vos_dump.o \ vos_createvolume.o vos_endtrans.o vos_vldbexamine.o \ - vos_lock.o vos_unlock.o + vos_lock.o vos_unlock.o vos_backup.o HDRS = all: $(PROGS) @@ -102,7 +104,7 @@ install: all e=`echo $$x | sed 's/.*\.\([1-9a-zA-Z]*\)$$/\1/'`; \ f=`echo $$n | sed '$(transform)'`; \ $(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$$e ; \ - $(INSTALL_PROGRAM) $(srcdir)/$$x \ + $(INSTALL_DATA) $(srcdir)/$$x \ $(DESTDIR)$(mandir)/man$$e/$$f.$$e; \ done @@ -138,7 +140,7 @@ clean : mostlyclean: clean distclean: clean - rm -f Makefile config.status + rm -f Makefile realclean: distclean rm -f TAGS diff --git a/usr.sbin/afs/src/appl/vos/vos.8 b/usr.sbin/afs/src/appl/vos/vos.8 index 4722f419fc9..68a47ad1a26 100644 --- a/usr.sbin/afs/src/appl/vos/vos.8 +++ b/usr.sbin/afs/src/appl/vos/vos.8 @@ -1,5 +1,5 @@ -.\" $OpenBSD: vos.8,v 1.1 2000/09/11 14:40:37 art Exp $ -.\" $Id: vos.8,v 1.1 2000/09/11 14:40:37 art Exp $ +.\" $OpenBSD: vos.8,v 1.2 2002/06/07 04:28:42 hin Exp $ +.\" $KTH: vos.8,v 1.1 2000/08/07 12:10:49 lha Exp $ .Dd March 26, 2000 .Dt VOS 1 .Os diff --git a/usr.sbin/afs/src/appl/vos/vos.c b/usr.sbin/afs/src/appl/vos/vos.c index 7f1a030bec3..14a502e9e65 100644 --- a/usr.sbin/afs/src/appl/vos/vos.c +++ b/usr.sbin/afs/src/appl/vos/vos.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos.c,v 1.2 2002/01/28 19:33:21 fgsch Exp $"); +RCSID("$KTH: vos.c,v 1.61.2.2 2001/09/18 00:24:17 mattiasa Exp $"); int vos_interactive = 0; @@ -57,8 +52,8 @@ static int apropos_cmd(int argc, char **argv); static SL_cmd cmds[] = { {"addsite", empty_cmd, "not yet implemented"}, {"apropos", apropos_cmd, "apropos"}, - {"backup", empty_cmd, "not yet implemented"}, - {"backupsys", empty_cmd, "not yet implemented"}, + {"backup", vos_backup, "Make a backup copy of a volume"}, + {"backupsys", vos_backupsys, "Make backup copies of multiple volumes"}, {"changeaddr", empty_cmd, "not yet implemented"}, {"create", vos_create, "create a volume"}, {"createentry",vos_createentry, "create a vldb entry"}, @@ -149,9 +144,16 @@ apropos_cmd(int argc, char **argv) int main(int argc, char **argv) { + Log_method *method; int ret = 0; - cell_init(0); + set_progname(argv[0]); + tzset(); + + method = log_open (get_progname(), "/dev/stderr:notime"); + if (method == NULL) + errx (1, "log_open failed"); + cell_init(0, method); ports_init(); if (argc > 1) diff --git a/usr.sbin/afs/src/appl/vos/vos_common.c b/usr.sbin/afs/src/appl/vos/vos_common.c index 36733c4c398..2854b4b8020 100644 --- a/usr.sbin/afs/src/appl/vos/vos_common.c +++ b/usr.sbin/afs/src/appl/vos/vos_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos_common.c,v 1.1 2000/09/11 14:40:37 art Exp $"); +RCSID("$KTH: vos_common.c,v 1.10.2.2 2001/09/18 00:15:32 mattiasa Exp $"); /* * Print the first of RW, RO, or BACKUP that there's a clone of @@ -262,10 +257,22 @@ get_vlentry (const char *cell, const char *host, const char *volname, arlalib_authflags_t auth, nvldbentry *nvldbentry) { struct rx_connection *conn; + struct db_server_context *conn_context = NULL; int error; - conn = arlalib_getconnbyname(cell, host, afsvldbport, VLDB_SERVICE_ID, - auth); + if(host == NULL) { + conn_context = malloc(sizeof(struct db_server_context)); + memset(conn_context, sizeof(struct db_server_context), 0); + for (conn = arlalib_first_db(conn_context, + cell, host, afsvldbport, VLDB_SERVICE_ID, + auth); + conn != NULL && arlalib_try_next_db(error); + conn = arlalib_next_db(conn_context)); + } else { + conn = arlalib_getconnbyname(cell, host, afsvldbport, VLDB_SERVICE_ID, + auth); + } + if (conn == NULL) return -1; @@ -278,7 +285,14 @@ get_vlentry (const char *cell, const char *host, const char *volname, if (error == 0) vldb2vldbN (&vlentry, nvldbentry); } + arlalib_destroyconn(conn); + + if(conn_context != NULL) { + free_db_server_context(conn_context); + free(conn_context); + } + return error; } @@ -350,3 +364,27 @@ find_db_cell_and_host (const char **cell, const char **host) *host = cell_findnamedbbyname (*cell); } } + +/* + * give a name for the server `addr' + */ + +void +get_servername (u_int32_t addr, char *str, size_t str_sz) +{ + struct sockaddr_in sock; + int error; + + memset (&sock, 0, sizeof(sock)); +#if HAVE_STRUCT_SOCKADDR_IN_SIN_LEN + sock.sin_len = sizeof(sock); +#endif + sock.sin_family = AF_INET; + sock.sin_port = 0; + sock.sin_addr.s_addr = addr; + + error = getnameinfo((struct sockaddr *)&sock, sizeof(sock), + str, str_sz, NULL, 0, 0); + if (error) + strlcpy (str, "<unknown>", str_sz); +} diff --git a/usr.sbin/afs/src/appl/vos/vos_createentry.c b/usr.sbin/afs/src/appl/vos/vos_createentry.c index 84b7fb6c911..e7285fec8ec 100644 --- a/usr.sbin/afs/src/appl/vos/vos_createentry.c +++ b/usr.sbin/afs/src/appl/vos/vos_createentry.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos_createentry.c,v 1.1 2000/09/11 14:40:37 art Exp $"); +RCSID("$KTH: vos_createentry.c,v 1.10 2000/10/03 00:08:30 lha Exp $"); static int helpflag; static char *vol; @@ -54,25 +49,25 @@ static int rw_number; static int ro_number; static int bk_number; -static struct getargs args[] = { - {"id", 0, arg_string, &vol, "id of volume", NULL, arg_mandatory}, - {"host", 0, arg_string, &host, "what host to use", NULL, arg_mandatory}, - {"fsserver",0, arg_string, &fsserver, "fsserver where the volume resides", NULL, arg_mandatory}, - {"partition",0, arg_string, &partition, "partition where the volume resides", NULL, arg_mandatory}, - {"rw", 0, arg_integer, &rw_number, "volume RW number", NULL}, - {"ro", 0, arg_integer, &ro_number, "volume RO number", NULL}, - {"bk", 0, arg_integer, &bk_number, "volume BK number", NULL}, - {"cell", 0, arg_string, &cell, "what cell to use", NULL}, - {"noauth", 0, arg_flag, &noauth, "if to use authentication", NULL}, - {"localauth",0,arg_flag, &localauth, "localauth", NULL}, - {"help", 0, arg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL} +static struct agetargs args[] = { + {"id", 0, aarg_string, &vol, "id of volume", NULL, aarg_mandatory}, + {"host", 0, aarg_string, &host, "what host to use", NULL, aarg_mandatory}, + {"fsserver",0, aarg_string, &fsserver, "fsserver where the volume resides", NULL, aarg_mandatory}, + {"partition",0, aarg_string, &partition, "partition where the volume resides", NULL, aarg_mandatory}, + {"rw", 0, aarg_integer, &rw_number, "volume RW number", NULL}, + {"ro", 0, aarg_integer, &ro_number, "volume RO number", NULL}, + {"bk", 0, aarg_integer, &bk_number, "volume BK number", NULL}, + {"cell", 0, aarg_string, &cell, "what cell to use", NULL}, + {"noauth", 0, aarg_flag, &noauth, "if to use authentication", NULL}, + {"localauth",0,aarg_flag, &localauth, "localauth", NULL}, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, + {NULL, 0, aarg_end, NULL} }; static void usage(void) { - arg_printusage(args, "vos createentry", "", ARG_AFSSTYLE); + aarg_printusage(args, "vos createentry", "", AARG_AFSSTYLE); } int @@ -96,7 +91,7 @@ vos_createentry(int argc, char **argv) bk_number = 0; cell = NULL; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { usage (); } diff --git a/usr.sbin/afs/src/appl/vos/vos_createvolume.c b/usr.sbin/afs/src/appl/vos/vos_createvolume.c index 9b5fc50bc5e..fde9a6b53b7 100644 --- a/usr.sbin/afs/src/appl/vos/vos_createvolume.c +++ b/usr.sbin/afs/src/appl/vos/vos_createvolume.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -39,7 +34,7 @@ #include "appl_locl.h" #include "vos_local.h" -RCSID("$Id: vos_createvolume.c,v 1.1 2000/09/11 14:40:37 art Exp $"); +RCSID("$KTH: vos_createvolume.c,v 1.5 2000/10/03 00:08:35 lha Exp $"); /* * create volume @@ -214,24 +209,24 @@ static int localauth; static int helpflag; static int verbose; -static struct getargs args[] = { - {"server", 0, arg_string, &server, - "server", NULL, arg_mandatory}, - {"part", 0, arg_string, &part, - "part", NULL, arg_mandatory}, - {"volume", 0, arg_string, &volume, - "volume", NULL, arg_mandatory}, - {"cell", 0, arg_string, &cell, +static struct agetargs args[] = { + {"server", 0, aarg_string, &server, + "server", NULL, aarg_mandatory}, + {"part", 0, aarg_string, &part, + "part", NULL, aarg_mandatory}, + {"volume", 0, aarg_string, &volume, + "volume", NULL, aarg_mandatory}, + {"cell", 0, aarg_string, &cell, "cell", NULL}, - {"noauth", 0, arg_flag, &noauth, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, - {"localauth", 0, arg_flag, &localauth, + {"localauth", 0, aarg_flag, &localauth, "use local authentication", NULL}, - {"verbose", 0, arg_flag, &verbose, + {"verbose", 0, aarg_flag, &verbose, "verbose output", NULL}, - {"help", 0, arg_flag, &helpflag, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL} + {NULL, 0, aarg_end, NULL} }; /* @@ -241,7 +236,7 @@ static struct getargs args[] = { static void usage(void) { - arg_printusage (args, "vos create", "", ARG_AFSSTYLE); + aarg_printusage (args, "vos create", "", AARG_AFSSTYLE); } /* @@ -258,7 +253,7 @@ vos_create(int argc, char **argv) server = cell = NULL; noauth = localauth = helpflag = 0; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { usage(); return 0; } diff --git a/usr.sbin/afs/src/appl/vos/vos_dump.c b/usr.sbin/afs/src/appl/vos/vos_dump.c index 9c81f06998b..60417cab231 100644 --- a/usr.sbin/afs/src/appl/vos/vos_dump.c +++ b/usr.sbin/afs/src/appl/vos/vos_dump.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos_dump.c,v 1.1 2000/09/11 14:40:38 art Exp $"); +RCSID("$KTH: vos_dump.c,v 1.7 2000/10/03 00:08:40 lha Exp $"); static void dump_volume (const char *volume, @@ -166,24 +161,24 @@ static int localauth; static int verbose; static int helpflag; -static struct getargs args[] = { - {"id", 0, arg_string, &vol, "id of volume", "volume", - arg_mandatory}, - {"server", 0, arg_string, &server, "what server to use", NULL}, - {"partition",0, arg_string, &part, "what partition to use", NULL}, - {"cell", 0, arg_string, &cell, "what cell to use", NULL}, - {"file", 0, arg_string, &file, "file to dump to", NULL}, - {"noauth", 0, arg_flag, &noauth, "do not authenticate", NULL}, - {"localauth",0,arg_flag, &localauth, "localauth", NULL}, - {"verbose", 0, arg_flag, &verbose, "be verbose", NULL}, - {"help", 0, arg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL} +static struct agetargs args[] = { + {"id", 0, aarg_string, &vol, "id of volume", "volume", + aarg_mandatory}, + {"server", 0, aarg_string, &server, "what server to use", NULL}, + {"partition",0, aarg_string, &part, "what partition to use", NULL}, + {"cell", 0, aarg_string, &cell, "what cell to use", NULL}, + {"file", 0, aarg_string, &file, "file to dump to", NULL}, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, + {"localauth",0,aarg_flag, &localauth, "localauth", NULL}, + {"verbose", 0, aarg_flag, &verbose, "be verbose", NULL}, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, + {NULL, 0, aarg_end, NULL} }; static void usage(void) { - arg_printusage(args, "vos dump", "", ARG_AFSSTYLE); + aarg_printusage(args, "vos dump", "", AARG_AFSSTYLE); } int @@ -194,7 +189,7 @@ vos_dump(int argc, char **argv) noauth = localauth = verbose = 0; file = cell = server = part = vol = NULL; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { usage (); return 0; } diff --git a/usr.sbin/afs/src/appl/vos/vos_endtrans.c b/usr.sbin/afs/src/appl/vos/vos_endtrans.c index b00daab733f..6ed689588fa 100644 --- a/usr.sbin/afs/src/appl/vos/vos_endtrans.c +++ b/usr.sbin/afs/src/appl/vos/vos_endtrans.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -39,7 +34,7 @@ #include "appl_locl.h" #include "vos_local.h" -RCSID("$Id: vos_endtrans.c,v 1.1 2000/09/11 14:40:38 art Exp $"); +RCSID("$KTH: vos_endtrans.c,v 1.5 2000/10/03 00:08:46 lha Exp $"); /* * end a transaction on `host' with transaction id `trans' @@ -97,22 +92,22 @@ static int localauth; static int helpflag; static int verbose; -static struct getargs args[] = { - {"server", 0, arg_string, &server, - "server", NULL, arg_mandatory}, - {"trans", 0, arg_integer, &transid, - "trans", NULL, arg_mandatory}, - {"cell", 0, arg_string, &cell, +static struct agetargs args[] = { + {"server", 0, aarg_string, &server, + "server", NULL, aarg_mandatory}, + {"trans", 0, aarg_integer, &transid, + "trans", NULL, aarg_mandatory}, + {"cell", 0, aarg_string, &cell, "cell", NULL}, - {"noauth", 0, arg_flag, &noauth, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, - {"localauth", 0, arg_flag, &localauth, + {"localauth", 0, aarg_flag, &localauth, "use local authentication", NULL}, - {"verbose", 0, arg_flag, &verbose, + {"verbose", 0, aarg_flag, &verbose, "verbose output", NULL}, - {"help", 0, arg_flag, &helpflag, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL} + {NULL, 0, aarg_end, NULL} }; /* @@ -122,7 +117,7 @@ static struct getargs args[] = { static void usage(void) { - arg_printusage (args, "vos endtransaction", "", ARG_AFSSTYLE); + aarg_printusage (args, "vos endtransaction", "", AARG_AFSSTYLE); } /* @@ -138,7 +133,7 @@ vos_endtrans(int argc, char **argv) server = cell = NULL; noauth = localauth = helpflag = 0; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { usage(); return 0; } diff --git a/usr.sbin/afs/src/appl/vos/vos_examine.c b/usr.sbin/afs/src/appl/vos/vos_examine.c index ccf73d7d118..3ef205995a9 100644 --- a/usr.sbin/afs/src/appl/vos/vos_examine.c +++ b/usr.sbin/afs/src/appl/vos/vos_examine.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos_examine.c,v 1.1 2000/09/11 14:40:38 art Exp $"); +RCSID("$KTH: vos_examine.c,v 1.17.2.3 2001/09/19 10:03:36 mattiasa Exp $"); static void print_extended_stats (const xvolintInfo *v) @@ -98,9 +93,9 @@ print_volume (const nvldbentry *nvlentry, const xvolintInfo *v, char timestr[30]; printf("%s\t\t\t%10u %s ", - nvlentry->name, - nvlentry->volumeId[0], - getvolumetype(nvlentry->serverFlags[0])); + v->name, + v->volid, + getvolumetype2(v->type)); if (v != NULL) printf("%8d K %s\n", v->size, v->status == VOK ? "On-line" : "Busy"); @@ -108,6 +103,8 @@ print_volume (const nvldbentry *nvlentry, const xvolintInfo *v, printf("unknown K\n"); if (v != NULL && v->status == VOK) { + struct tm tm; + partition_num2name (nvlentry->serverPartition[0], part_name, sizeof(part_name)); @@ -125,16 +122,14 @@ print_volume (const nvldbentry *nvlentry, const xvolintInfo *v, printf("\n MaxQuota %10d K\n", v->maxquota); - /* Get and format date */ - strlcpy(timestr, - ctime( (time_t*) &v->creationDate), - sizeof(timestr)); + memset (&tm, 0, sizeof(tm)); + strftime (timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S %Z", + localtime_r((time_t*) &v->creationDate, &tm)); printf(" Creation %s\n", timestr); - /* Get and format date */ - strlcpy(timestr, - ctime((time_t *) &v->updateDate), - sizeof(timestr)); + memset (&tm, 0, sizeof(tm)); + strftime (timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S %Z", + localtime_r((time_t*) &v->updateDate, &tm)); printf(" Last Update %s\n", timestr); printf(" %d accesses in the past day (i.e., vnode references)\n\n", @@ -146,7 +141,7 @@ print_volume (const nvldbentry *nvlentry, const xvolintInfo *v, } static int -printvolstat(const char *volname, const char *cell, const char *host, +printvolstat(const char *vol, const char *cell, const char *host, arlalib_authflags_t auth, int verbose, int extended) { struct rx_connection *connvolser; @@ -154,10 +149,15 @@ printvolstat(const char *volname, const char *cell, const char *host, int i; xvolEntries xvolint; nvldbentry nvlentry; - struct in_addr server_addr; char server_name[MAXHOSTNAMELEN]; char part_name[17]; int was_xvol = 1; + char volname[VLDB_MAXNAMELEN]; + int type; + u_int32_t server; + int part; + int bit; + int xvolintp = 0; find_db_cell_and_host (&cell, &host); @@ -171,6 +171,9 @@ printvolstat(const char *volname, const char *cell, const char *host, return -1; } + strlcpy (volname, vol, sizeof(volname)); + type = volname_canonicalize (volname); + if (verbose) fprintf (stderr, "Getting volume `%s' from the VLDB at `%s'...", @@ -187,11 +190,38 @@ printvolstat(const char *volname, const char *cell, const char *host, if (verbose) fprintf (stderr, "done\n"); - server_addr.s_addr = htonl(nvlentry.serverNumber[0]); - inaddr2str (server_addr, server_name, sizeof(server_name)); + switch (type) { + case RWVOL : + bit = VLSF_RWVOL; + break; + case ROVOL : + bit = VLSF_ROVOL; + break; + case BACKVOL : + bit = (VLSF_BACKVOL|VLSF_RWVOL); + break; + default : + abort (); + } + + for (i = 0; i < nvlentry.nServers; ++i) + if (nvlentry.serverFlags[i] & bit) { + server = nvlentry.serverNumber[i]; + part = nvlentry.serverPartition[i]; + break; + } + + if (i == nvlentry.nServers) { + fprintf (stderr, "Volume %s does not have a %s clone\n", + volname, getvolumetype2(type)); + return -1; + } + + get_servername (htonl(server), + server_name, sizeof(server_name)); connvolser = arlalib_getconnbyaddr(cell, - server_addr.s_addr, + htonl(server), NULL, afsvolport, VOLSERVICE_ID, @@ -201,13 +231,13 @@ printvolstat(const char *volname, const char *cell, const char *host, if (verbose) { fprintf (stderr, "getting information on `%s' from %s\n", - volname, server_name); + vol, server_name); } xvolint.val = NULL; error = VOLSER_AFSVolXListOneVolume(connvolser, - nvlentry.serverPartition[0], - nvlentry.volumeId[0], + part, + nvlentry.volumeId[type], &xvolint); if (error == RXGEN_OPCODE) { @@ -216,8 +246,8 @@ printvolstat(const char *volname, const char *cell, const char *host, was_xvol = 0; volint.val = NULL; error = VOLSER_AFSVolListOneVolume(connvolser, - nvlentry.serverPartition[0], - nvlentry.volumeId[0], + part, + nvlentry.volumeId[type], &volint); if (error == 0) { xvolint.val = emalloc (sizeof (*xvolint.val)); @@ -225,34 +255,50 @@ printvolstat(const char *volname, const char *cell, const char *host, } } - if (error != 0) + if (error != 0) { printf("ListOneVolume of %s from %s failed with: %s (%d)\n", - volname, server_name, + vol, server_name, koerr_gettext(error), error); + } else { + xvolintp = 1; + if (verbose) + fprintf (stderr, "done\n"); + } - if (verbose) - fprintf (stderr, "done\n"); - - print_volume (&nvlentry, xvolint.val, server_name, was_xvol && extended); + + if(xvolintp) + print_volume (&nvlentry, xvolint.val, server_name, was_xvol && extended); + else { + printf("\nDump only information from VLDB\n\n"); + printf("%s\n", nvlentry.name); + } printf(" "); - printf("RWrite: %u\t", nvlentry.flags & VLF_RWEXISTS ? nvlentry.volumeId[RWVOL] : 0); - printf("ROnly: %u\t", nvlentry.flags & VLF_ROEXISTS ? nvlentry.volumeId[ROVOL] : 0); - printf("Backup: %u\t", nvlentry.flags & VLF_BACKEXISTS ? nvlentry.volumeId[BACKVOL] : 0); + if(nvlentry.flags & VLF_RWEXISTS) + printf("RWrite: %u\t", nvlentry.volumeId[RWVOL]); + if(nvlentry.flags & VLF_ROEXISTS) + printf("ROnly: %u\t", nvlentry.volumeId[ROVOL]); + if(nvlentry.flags & VLF_BACKEXISTS) + printf("Backup: %u\t", nvlentry.volumeId[BACKVOL]); printf("\n number of sites -> %d\n", nvlentry.nServers ); for (i = 0; i < nvlentry.nServers; i++) { printf(" "); - server_addr.s_addr = htonl(nvlentry.serverNumber[i]); - inaddr2str (server_addr, server_name, sizeof(server_name)); + get_servername (htonl(nvlentry.serverNumber[i]), + server_name, sizeof(server_name)); partition_num2name (nvlentry.serverPartition[i], part_name, sizeof(part_name)); - printf("server %s partition %s %s Site\n", + printf("server %s partition %s %s Site", server_name, part_name, getvolumetype(nvlentry.serverFlags[i])); + + if (nvlentry.serverFlags[i] & VLSF_DONTUSE) + printf(" -- not replicated yet"); + + printf("\n"); } free(xvolint.val); @@ -269,23 +315,23 @@ static int localauth; static int verbose; static int extended; -static struct getargs args[] = { - {"id", 0, arg_string, &vol, "id of volume", "volume", - arg_mandatory}, - {"host", 0, arg_string, &host, "what host to use", NULL}, - {"cell", 0, arg_string, &cell, "what cell to use", NULL}, - {"noauth", 0, arg_flag, &noauth, "do not authenticate", NULL}, - {"localauth",0,arg_flag, &localauth, "localauth", NULL}, - {"verbose", 0, arg_flag, &verbose, "be verbose", NULL}, - {"extended",0, arg_flag, &extended, "more output", NULL}, - {"help", 0, arg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL} +static struct agetargs args[] = { + {"id", 0, aarg_string, &vol, "id of volume", "volume", + aarg_mandatory}, + {"host", 0, aarg_string, &host, "what host to use", NULL}, + {"cell", 0, aarg_string, &cell, "what cell to use", NULL}, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, + {"localauth",0,aarg_flag, &localauth, "localauth", NULL}, + {"verbose", 0, aarg_flag, &verbose, "be verbose", NULL}, + {"extended",0, aarg_flag, &extended, "more output", NULL}, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, + {NULL, 0, aarg_end, NULL} }; static void usage(void) { - arg_printusage(args, "vos examine", "", ARG_AFSSTYLE); + aarg_printusage(args, "vos examine", "", AARG_AFSSTYLE); } int @@ -296,7 +342,7 @@ vos_examine(int argc, char **argv) helpflag = noauth = localauth = verbose = extended = 0; host = cell = vol = NULL; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { usage (); return 0; } diff --git a/usr.sbin/afs/src/appl/vos/vos_listpart.c b/usr.sbin/afs/src/appl/vos/vos_listpart.c index 6f8c6c2e424..b7381256a05 100644 --- a/usr.sbin/afs/src/appl/vos/vos_listpart.c +++ b/usr.sbin/afs/src/appl/vos/vos_listpart.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos_listpart.c,v 1.1 2000/09/11 14:40:38 art Exp $"); +RCSID("$KTH: vos_listpart.c,v 1.5.2.1 2001/09/25 22:06:15 mattiasa Exp $"); static int printlistparts(const char *cell, const char *server, @@ -77,19 +72,20 @@ static int noauth; static int localauth; static int verbose; -static struct getargs listp_args[] = { - {"server", 0, arg_string, &server, "server", NULL, arg_mandatory}, - {"cell", 0, arg_string, &cell, "cell", NULL}, - {"noauth", 0, arg_flag, &noauth, "no authentication", NULL}, - {"localauth",0, arg_flag, &localauth, "local authentication", NULL}, - {"verbose", 0, arg_flag, &verbose, "be verbose", NULL}, - {"help", 0, arg_flag, &helpflag, NULL, NULL} +static struct agetargs listp_args[] = { + {"server", 0, aarg_string, &server, "server", NULL, aarg_mandatory}, + {"cell", 0, aarg_string, &cell, "cell", NULL}, + {"noauth", 0, aarg_flag, &noauth, "no authentication", NULL}, + {"localauth",0, aarg_flag, &localauth, "local authentication", NULL}, + {"verbose", 0, aarg_flag, &verbose, "be verbose", NULL}, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, + {NULL} }; static void usage(void) { - arg_printusage(listp_args, "vos listpart", "", ARG_AFSSTYLE); + aarg_printusage(listp_args, "vos listpart", "", AARG_AFSSTYLE); } int @@ -100,7 +96,7 @@ vos_listpart(int argc, char **argv) helpflag = noauth = localauth = verbose = 0; server = cell = NULL; - if (getarg (listp_args,argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (listp_args,argc, argv, &optind, AARG_AFSSTYLE)) { usage (); return 0; } diff --git a/usr.sbin/afs/src/appl/vos/vos_listvldb.c b/usr.sbin/afs/src/appl/vos/vos_listvldb.c index 0817df0c94b..c1b83f9d7b5 100644 --- a/usr.sbin/afs/src/appl/vos/vos_listvldb.c +++ b/usr.sbin/afs/src/appl/vos/vos_listvldb.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,59 +35,96 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos_listvldb.c,v 1.1 2000/09/11 14:40:38 art Exp $"); +RCSID("$KTH: vos_listvldb.c,v 1.9.2.2 2001/11/16 15:02:30 mattiasa Exp $"); /* * listvldb iteration over all entries in the DB */ int -vos_listvldb_iter (const char *host, const char *cell, +vos_listvldb_iter (const char *db_host, const char *cell, const char *volname, + const char *fileserver, const char *part, arlalib_authflags_t auth, int (*proc)(void *data, struct vldbentry *), void *data) { struct rx_connection *connvldb = NULL; - struct vldbentry entry; - int error; - int32_t num, count; + struct vldbentry *entry; + struct vldbentry vol; + int error,i; + int32_t num; + bulkentries bulkent; + struct VldbListByAttributes attr; + struct hostent *he; + + memset(&attr, '\0', sizeof(struct VldbListByAttributes)); - find_db_cell_and_host (&cell, &host); + find_db_cell_and_host (&cell, &db_host); if (cell == NULL) { - fprintf (stderr, "Unable to find cell of host '%s'\n", host); + fprintf (stderr, "Unable to find cell of host '%s'\n", db_host); return -1; } - if (host == NULL) { + if (db_host == NULL) { fprintf (stderr, "Unable to find DB server in cell '%s'\n", cell); return -1; } - connvldb = arlalib_getconnbyname(cell, host, + connvldb = arlalib_getconnbyname(cell, db_host, afsvldbport, VLDB_SERVICE_ID, auth); - num = 0; - do { - error = VL_ListEntry (connvldb, - num, - &count, - &num, - &entry); - if (error) - break; - entry.name[VLDB_MAXNAMELEN-1] = '\0'; + if(volname != NULL) { - error = proc (data, &entry); - if (error) - break; + error = VL_GetEntryByName(connvldb, volname, &vol); + if (error) { + fprintf(stderr, "vos_listvldb: error %s (%d)\n", + koerr_gettext(error), error); + return -1; + } - } while (num != -1); + attr.volumeid = vol.volumeId[vol.volumeType]; + attr.Mask |= VLLIST_VOLUMEID; - if (error) { - warnx ("listvldb: VL_ListEntry: %s", koerr_gettext(error)); - return -1; + } + + if(fileserver != NULL) { + he = gethostbyname(fileserver); + if (he == NULL) { + warnx("listvldb: unknown host: %s\n", fileserver); + return -1; + } + memcpy (&attr.server, he->h_addr_list[0], 4); + attr.server = ntohl(attr.server); + attr.Mask |= VLLIST_SERVER; + } + + if(part != NULL) { + attr.partition = partition_name2num(part); + attr.Mask |= VLLIST_PARTITION; + } + + error = VL_ListAttributes (connvldb, + &attr, + &num, + &bulkent); + if(error) { + warnx ("listvldb: VL_ListAttributes: %s", koerr_gettext(error)); + } + + + for(i=0; i<num ; i++) { + + entry = &bulkent.val[i]; + error = proc (data, entry); + if (error) + break; + + if (error) { + warnx ("listvldb: VL_ListEntry: %s", koerr_gettext(error)); + return -1; + } } arlalib_destroyconn(connvldb); @@ -108,19 +140,28 @@ listvldb_print (void *data, struct vldbentry *e) { int i; char *hostname; + char part_name[30]; assert (e); printf ("%s\n", e->name); + if(e->flags & VLF_RWEXISTS) + printf (" RWrite: %d", e->volumeId[RWVOL]); + if(e->flags & VLF_ROEXISTS) + printf (" ROnly: %d", e->volumeId[ROVOL]); + if(e->flags & VLF_BACKEXISTS) + printf (" Backup: %d", e->volumeId[BACKVOL]); + printf("\n"); printf (" Number of sites -> %d\n", e->nServers); for (i = 0 ; i < e->nServers ; i++) { if (e->serverNumber[i] == 0) continue; if (arlalib_getservername(htonl(e->serverNumber[i]), &hostname)) continue; - printf (" server %s partition /vicep%c Site %s\n", + partition_num2name (e->serverPartition[i], part_name, sizeof(part_name)); + printf (" server %s partition %s Site %s\n", hostname, - 'a' + e->serverPartition[i], + part_name, getvolumetype (e->serverFlags[i])); free (hostname); } @@ -135,30 +176,39 @@ listvldb_print (void *data, struct vldbentry *e) * list vldb */ -char *server; -char *cell; -int noauth; -int localauth; -int helpflag; - -static struct getargs args[] = { - {"server", 0, arg_string, &server, - "server", NULL, arg_mandatory}, - {"cell", 0, arg_string, &cell, +static char *volume; +static char *fileserver; +static char *partition; +static char *cell; +static char *dbserver; +static int noauth; +static int localauth; +static int helpflag; + +static struct agetargs args[] = { + {"name", 0, aarg_string, &volume, + "Volume to list", NULL, aarg_optional_swless}, + {"fileserver", 0, aarg_string, &fileserver, + "fileserver to list", NULL, aarg_optional_swless}, + {"partition", 0, aarg_string, &partition, + "partition", NULL, aarg_optional_swless}, + {"cell", 0, aarg_string, &cell, "cell", NULL}, - {"noauth", 0, arg_flag, &noauth, + {"dbserver", 0, aarg_string, &dbserver, + "dbserver", NULL}, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, - {"localauth", 0, arg_flag, &localauth, + {"localauth", 0, aarg_flag, &localauth, "use local authentication", NULL}, - {"help", 0, arg_flag, &helpflag, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL} + {NULL, 0, aarg_end, NULL} }; static void usage(void) { - arg_printusage (args, "vos listvldb", "", ARG_AFSSTYLE); + aarg_printusage (args, "vos listvldb", "", AARG_AFSSTYLE); } int @@ -166,10 +216,10 @@ vos_listvldb(int argc, char **argv) { int optind = 0; - server = cell = NULL; + volume = fileserver = dbserver = cell = NULL; noauth = localauth = helpflag = 0; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { usage(); return 0; } @@ -183,7 +233,8 @@ vos_listvldb(int argc, char **argv) argv += optind; - vos_listvldb_iter (server, cell, + vos_listvldb_iter (dbserver, cell, volume, + fileserver, partition, arlalib_getauthflag (noauth, localauth, 0, 0), listvldb_print, NULL); diff --git a/usr.sbin/afs/src/appl/vos/vos_listvol.c b/usr.sbin/afs/src/appl/vos/vos_listvol.c index d02fdcb2261..a3756ed1a8f 100644 --- a/usr.sbin/afs/src/appl/vos/vos_listvol.c +++ b/usr.sbin/afs/src/appl/vos/vos_listvol.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos_listvol.c,v 1.1 2000/09/11 14:40:38 art Exp $"); +RCSID("$KTH: vos_listvol.c,v 1.5.2.1 2001/09/17 21:42:29 mattiasa Exp $"); /* * list volume on a afs-server @@ -55,30 +50,30 @@ int localauth; int helpflag; int fast; -static struct getargs args[] = { - {"server", 0, arg_string, &server, - "server", NULL, arg_mandatory}, - {"partition", 0, arg_string, &partition, - "partition", NULL}, - {"machine", 'm', arg_flag, &listvol_machine, +static struct agetargs args[] = { + {"server", 0, aarg_string, &server, + "server", NULL, aarg_mandatory}, + {"partition", 0, aarg_string, &partition, + "partition", NULL, aarg_optional_swless}, + {"machine", 'm', aarg_flag, &listvol_machine, "machineparseableform", NULL}, - {"cell", 0, arg_string, &cell, + {"cell", 0, aarg_string, &cell, "cell", NULL}, - {"noauth", 0, arg_flag, &noauth, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, - {"localauth", 0, arg_flag, &localauth, + {"localauth", 0, aarg_flag, &localauth, "use local authentication", NULL}, - {"fast", 0, arg_flag, &fast, + {"fast", 0, aarg_flag, &fast, "only list IDs", NULL}, - {"help", 0, arg_flag, &helpflag, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL} + {NULL, 0, aarg_end, NULL} }; static void usage(void) { - arg_printusage (args, "vos listvol", "", ARG_AFSSTYLE); + aarg_printusage (args, "vos listvol", "", AARG_AFSSTYLE); } int @@ -91,7 +86,7 @@ vos_listvol(int argc, char **argv) server = partition = cell = NULL; listvol_machine = noauth = localauth = helpflag = fast = 0; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { usage(); return 0; } diff --git a/usr.sbin/afs/src/appl/vos/vos_local.h b/usr.sbin/afs/src/appl/vos/vos_local.h index f01220ebcc8..016c6cc5fd9 100644 --- a/usr.sbin/afs/src/appl/vos/vos_local.h +++ b/usr.sbin/afs/src/appl/vos/vos_local.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +32,7 @@ */ /* - * RCSID("$Id: vos_local.h,v 1.1 2000/09/11 14:40:38 art Exp $"); + * RCSID("$KTH: vos_local.h,v 1.12.2.2 2001/09/17 23:59:02 mattiasa Exp $"); */ #define LISTVOL_PART 0x1 @@ -66,8 +61,11 @@ int vos_syncsite (int, char **); int vos_dump (int, char **); int vos_create(int argc, char **argv); int vos_endtrans(int argc, char **argv); +int vos_backup(int argc, char **argv); +int vos_backupsys(int argc, char **argv); -int vos_listvldb_iter (const char *host, const char *cell, +int vos_listvldb_iter (const char *host, const char *cell, const char *volname, + const char *fileserver, const char *part, arlalib_authflags_t auth, int (*proc)(void *data, struct vldbentry *), void *data); @@ -92,3 +90,4 @@ int vos_endtransaction (const char *cell, const char *host, int32_t trans, arlalib_authflags_t auth, int verbose); void find_db_cell_and_host (const char **cell, const char **host); +void get_servername (u_int32_t addr, char *str, size_t str_sz); diff --git a/usr.sbin/afs/src/appl/vos/vos_lock.c b/usr.sbin/afs/src/appl/vos/vos_lock.c index 125166e3b85..70973770d9f 100644 --- a/usr.sbin/afs/src/appl/vos/vos_lock.c +++ b/usr.sbin/afs/src/appl/vos/vos_lock.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos_lock.c,v 1.1 2000/09/11 14:40:38 art Exp $"); +RCSID("$KTH: vos_lock.c,v 1.4.2.1 2001/11/16 16:56:39 mattiasa Exp $"); /* * lock a volume @@ -53,20 +48,20 @@ static int localauth; static int helpflag; static int verbose; -static struct getargs args[] = { - {"id", 0, arg_string, &vol, - "id or name of volume", NULL, arg_mandatory}, - {"cell", 0, arg_string, &cell, +static struct agetargs args[] = { + {"id", 0, aarg_string, &vol, + "id or name of volume", NULL, aarg_mandatory}, + {"cell", 0, aarg_string, &cell, "cell", NULL}, - {"noauth", 0, arg_flag, &noauth, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, - {"localauth", 0, arg_flag, &localauth, + {"localauth", 0, aarg_flag, &localauth, "use local authentication", NULL}, - {"verbose", 0, arg_flag, &verbose, + {"verbose", 0, aarg_flag, &verbose, "verbose output", NULL}, - {"help", 0, arg_flag, &helpflag, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL} + {NULL, 0, aarg_end, NULL} }; static int @@ -76,6 +71,7 @@ vos_lock_volume(char *volname) const char *host = NULL; arlalib_authflags_t auth; int error; + int32_t dbhost; vldbentry vol; find_db_cell_and_host((const char **)&cell, &host); @@ -90,10 +86,18 @@ vos_lock_volume(char *volname) auth = arlalib_getauthflag(noauth, localauth, 0, 0); - connvldb = arlalib_getconnbyname(cell, host, - afsvldbport, - VLDB_SERVICE_ID, - auth); + error = arlalib_getsyncsite(cell, NULL, afsvldbport, + &dbhost, auth); + if (error) { + fprintf (stderr, "vos_createvolume: arla_getsyncsite: %s\n", + koerr_gettext(error)); + return -1; + } + + connvldb = arlalib_getconnbyaddr(cell, dbhost, NULL, + afsvldbport, + VLDB_SERVICE_ID, + auth); if(connvldb == NULL) { fprintf(stderr, "can't connect to vldb server %s in cell %s\n", @@ -126,7 +130,7 @@ vos_lock_volume(char *volname) static void usage(void) { - arg_printusage(args, "vos dump", "", ARG_AFSSTYLE); + aarg_printusage(args, "vos dump", "", AARG_AFSSTYLE); } int @@ -137,7 +141,7 @@ vos_lock(int argc, char **argv) cell = vol = NULL; noauth = localauth = helpflag = verbose = 0; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { usage (); return 0; } diff --git a/usr.sbin/afs/src/appl/vos/vos_partinfo.c b/usr.sbin/afs/src/appl/vos/vos_partinfo.c index 958bc25b011..bbe49ca9725 100644 --- a/usr.sbin/afs/src/appl/vos/vos_partinfo.c +++ b/usr.sbin/afs/src/appl/vos/vos_partinfo.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos_partinfo.c,v 1.1 2000/09/11 14:40:38 art Exp $"); +RCSID("$KTH: vos_partinfo.c,v 1.7.2.1 2001/01/09 02:13:00 lha Exp $"); static int print_one_partition (struct rx_connection *conn, const char *part) @@ -118,20 +113,21 @@ static int noauth; static int localauth; static int verbose; -static struct getargs args[] = { - {"server", 0, arg_string, &server, "server", NULL, arg_mandatory}, - {"cell", 0, arg_string, &cell, "cell", NULL}, - {"partition",0, arg_string, &part, "partition", NULL}, - {"noauth", 0, arg_flag, &noauth, "no authentication", NULL}, - {"localauth",0,arg_flag, &localauth, "localauth", NULL}, - {"verbose", 0, arg_flag, &verbose, "be verbose", NULL}, - {"help", 0, arg_flag, &helpflag, NULL, NULL} +static struct agetargs args[] = { + {"server", 0, aarg_string, &server, "server", NULL, aarg_mandatory}, + {"cell", 0, aarg_string, &cell, "cell", NULL}, + {"partition",0, aarg_string, &part, "partition", NULL}, + {"noauth", 0, aarg_flag, &noauth, "no authentication", NULL}, + {"localauth",0,aarg_flag, &localauth, "localauth", NULL}, + {"verbose", 0, aarg_flag, &verbose, "be verbose", NULL}, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, + {NULL, 0, aarg_end, NULL} }; static void usage(void) { - arg_printusage(args, "vos partinfo", "", ARG_AFSSTYLE); + aarg_printusage(args, "vos partinfo", "", AARG_AFSSTYLE); } int @@ -142,7 +138,7 @@ vos_partinfo(int argc, char **argv) helpflag = noauth = localauth = verbose = 0; server = cell = part = NULL; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { usage (); return 0; } diff --git a/usr.sbin/afs/src/appl/vos/vos_status.c b/usr.sbin/afs/src/appl/vos/vos_status.c index 3cae9eaca96..dd8bc092d5d 100644 --- a/usr.sbin/afs/src/appl/vos/vos_status.c +++ b/usr.sbin/afs/src/appl/vos/vos_status.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,11 +35,11 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos_status.c,v 1.1 2000/09/11 14:40:38 art Exp $"); +RCSID("$KTH: vos_status.c,v 1.7.2.1 2001/03/04 04:16:20 lha Exp $"); static int -printstatus(const char *cell, const char *host, - int noauth, int verbose) +printstatus (const char *cell, const char *host, + int noauth, int verbose) { struct rx_connection *connvolser = NULL; struct transDebugInfo *entries; @@ -61,14 +56,13 @@ printstatus(const char *cell, const char *host, if (connvolser == NULL) return -1; - if ((error = VOLSER_AFSVolMonitor(connvolser, - &info)) != 0) { + error = VOLSER_AFSVolMonitor(connvolser, &info); + if (error) { printf("printstatus: GetStat failed with: %s (%d)\n", - koerr_gettext(error), - error); + koerr_gettext(error), error); return -1; } - + entries_len = info.len; entries = info.val; @@ -76,8 +70,17 @@ printstatus(const char *cell, const char *host, printf ("No active transactions on %s\n", host); else { for (i = 0; i < entries_len; i--) { + struct tm tm; + char timestr[20]; + char part[100]; + printf("--------------------------------------\n"); - printf("transaction: %d created: %s", entries->tid, ctime((time_t *) &entries->creationTime)); + + memset (&tm, 0, sizeof(tm)); + strftime (timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S %Z", + localtime_r((time_t*) &entries->creationTime, &tm)); + printf("transaction: %d created: %s\n", entries->tid, + timestr); printf("attachFlags: "); if ((entries->iflags & ITOffline) == ITOffline) @@ -91,8 +94,15 @@ printstatus(const char *cell, const char *host, if ((entries->iflags & ITCreateVolID) == ITCreateVolID) printf("create-VolID"); - printf("\nvolume: %d partition: <insert partition name here> procedure: %s\n", entries->volid, entries->lastProcName); - printf("packetRead: %d lastReceiveTime: %d packetSend: %d lastSendTime: %d\n", entries->readNext, entries->lastReceiveTime, entries->transmitNext, entries->lastSendTime); + partition_num2name(entries->partition, part, sizeof(part)); + printf("\nvolume: %d partition: %s procedure: %s\n", + entries->volid, part, entries->lastProcName); + printf("packetRead: %d lastReceiveTime: %d " + "packetSend: %d lastSendTime: %d\n", + entries->readNext, + entries->lastReceiveTime, + entries->transmitNext, + entries->lastSendTime); entries++; } printf("--------------------------------------\n"); @@ -108,19 +118,19 @@ static const char *cell; static int noauth; static int verbose; -static struct getargs args[] = { - {"server", 0, arg_string, &server, "server", NULL, arg_mandatory}, - {"cell", 0, arg_string, &cell, "cell", NULL}, - {"noauth", 0, arg_flag, &noauth, "do not authenticate", NULL}, - {"verbose", 0, arg_flag, &verbose, "be verbose", NULL}, - {"help", 0, arg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL, NULL, NULL} +static struct agetargs args[] = { + {"server", 0, aarg_string, &server, "server", NULL,aarg_mandatory}, + {"cell", 0, aarg_string, &cell, "cell", NULL}, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, + {"verbose", 0, aarg_flag, &verbose, "be verbose", NULL}, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, + {NULL, 0, aarg_end, NULL, NULL, NULL} }; static void usage (void) { - arg_printusage (args, "vos status", "", ARG_AFSSTYLE); + aarg_printusage (args, "vos status", "", AARG_AFSSTYLE); } int @@ -128,7 +138,7 @@ vos_status(int argc, char **argv) { int optind = 0; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { usage (); return 0; } diff --git a/usr.sbin/afs/src/appl/vos/vos_syncsite.c b/usr.sbin/afs/src/appl/vos/vos_syncsite.c index 3d3c78b2054..f242b840b2a 100644 --- a/usr.sbin/afs/src/appl/vos/vos_syncsite.c +++ b/usr.sbin/afs/src/appl/vos/vos_syncsite.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,22 +35,22 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos_syncsite.c,v 1.1 2000/09/11 14:40:38 art Exp $"); +RCSID("$KTH: vos_syncsite.c,v 1.12.2.1 2001/03/04 04:16:21 lha Exp $"); static int helpflag; static char *cell; static int resolvep = 1; -static struct getargs args[] = { - {"cell", 'c', arg_string, &cell, "cell", NULL}, - {"help", 'h', arg_flag, &helpflag, NULL, NULL}, - {"resolve", 'n', arg_negative_flag, &resolvep, NULL, NULL} +static struct agetargs args[] = { + {"cell", 'c', aarg_string, &cell, "cell", NULL}, + {"help", 'h', aarg_flag, &helpflag, NULL, NULL}, + {"resolve", 'n', aarg_negative_flag, &resolvep, NULL, NULL} }; static void usage(void) { - arg_printusage(args, "vos syncsite", "", ARG_AFSSTYLE); + aarg_printusage(args, "vos syncsite", "", AARG_AFSSTYLE); } int @@ -68,7 +63,7 @@ vos_syncsite (int argc, char **argv) helpflag = 0; cell = NULL; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { usage (); return 0; } @@ -90,11 +85,13 @@ vos_syncsite (int argc, char **argv) if (!resolvep) printf("%s's vldb syncsite is %s.\n", cell, inet_ntoa(saddr)); else { - char name[256]; + char server_name[256]; - inaddr2str (saddr, name, sizeof(name)); - printf("%s's vldb syncsite is %s (%s).\n", cell, name, + get_servername (saddr.s_addr, server_name, sizeof(server_name)); + + printf("%s's vldb syncsite is %s (%s).\n", cell, server_name, inet_ntoa(saddr)); + } return 0; } diff --git a/usr.sbin/afs/src/appl/vos/vos_unlock.c b/usr.sbin/afs/src/appl/vos/vos_unlock.c index 1d5985db87d..ddaacfae10f 100644 --- a/usr.sbin/afs/src/appl/vos/vos_unlock.c +++ b/usr.sbin/afs/src/appl/vos/vos_unlock.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos_unlock.c,v 1.1 2000/09/11 14:40:38 art Exp $"); +RCSID("$KTH: vos_unlock.c,v 1.4.2.1 2001/11/16 16:57:00 mattiasa Exp $"); /* * unlock a volume @@ -53,20 +48,20 @@ static int localauth; static int helpflag; static int verbose; -static struct getargs args[] = { - {"id", 0, arg_string, &vol, - "id or name of volume", NULL, arg_mandatory}, - {"cell", 0, arg_string, &cell, +static struct agetargs args[] = { + {"id", 0, aarg_string, &vol, + "id or name of volume", NULL, aarg_mandatory}, + {"cell", 0, aarg_string, &cell, "cell", NULL}, - {"noauth", 0, arg_flag, &noauth, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, - {"localauth", 0, arg_flag, &localauth, + {"localauth", 0, aarg_flag, &localauth, "use local authentication", NULL}, - {"verbose", 0, arg_flag, &verbose, + {"verbose", 0, aarg_flag, &verbose, "verbose output", NULL}, - {"help", 0, arg_flag, &helpflag, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL} + {NULL, 0, aarg_end, NULL} }; static int @@ -76,6 +71,7 @@ vos_unlock_volume(char *volname) const char *host = NULL; arlalib_authflags_t auth; int error; + int32_t dbhost; vldbentry vol; find_db_cell_and_host((const char **)&cell, &host); @@ -90,11 +86,18 @@ vos_unlock_volume(char *volname) auth = arlalib_getauthflag(noauth, localauth, 0, 0); - connvldb = arlalib_getconnbyname(cell, host, - afsvldbport, - VLDB_SERVICE_ID, - auth); - + error = arlalib_getsyncsite(cell, NULL, afsvldbport, + &dbhost, auth); + if (error) { + fprintf (stderr, "vos_createvolume: arla_getsyncsite: %s\n", + koerr_gettext(error)); + return -1; + } + + connvldb = arlalib_getconnbyaddr(cell, dbhost, NULL, + afsvldbport, + VLDB_SERVICE_ID, + auth); if(connvldb == NULL) { fprintf(stderr, "can't connect to vldb server %s in cell %s\n", host, cell); @@ -128,7 +131,7 @@ vos_unlock_volume(char *volname) static void usage(void) { - arg_printusage(args, "vos dump", "", ARG_AFSSTYLE); + aarg_printusage(args, "vos dump", "", AARG_AFSSTYLE); } int @@ -139,7 +142,7 @@ vos_unlock(int argc, char **argv) cell = vol = NULL; noauth = localauth = helpflag = verbose = 0; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { usage (); return 0; } diff --git a/usr.sbin/afs/src/appl/vos/vos_vldbexamine.c b/usr.sbin/afs/src/appl/vos/vos_vldbexamine.c index 6e09e62d1a4..ace807bcd44 100644 --- a/usr.sbin/afs/src/appl/vos/vos_vldbexamine.c +++ b/usr.sbin/afs/src/appl/vos/vos_vldbexamine.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ #include <sl.h> #include "vos_local.h" -RCSID("$Id: vos_vldbexamine.c,v 1.1 2000/09/11 14:40:38 art Exp $"); +RCSID("$KTH: vos_vldbexamine.c,v 1.11.2.1 2001/03/04 04:16:23 lha Exp $"); static void print_volume (const nvldbentry *nvlentry, const char *server_name) @@ -77,7 +72,6 @@ printvolstat(const char *volname, const char *cell, const char *host, int error; int i; nvldbentry nvlentry; - struct in_addr server_addr; char server_name[MAXHOSTNAMELEN]; char part_name[17]; @@ -109,9 +103,8 @@ printvolstat(const char *volname, const char *cell, const char *host, if (verbose) fprintf (stderr, "done\n"); - server_addr.s_addr = htonl(nvlentry.serverNumber[0]); - inaddr2str (server_addr, server_name, sizeof(server_name)); - + get_servername (htonl(nvlentry.serverNumber[0]), + server_name, sizeof(server_name)); print_volume (&nvlentry, server_name); printf(" "); @@ -124,8 +117,8 @@ printvolstat(const char *volname, const char *cell, const char *host, for (i = 0; i < nvlentry.nServers; i++) { printf(" "); - server_addr.s_addr = htonl(nvlentry.serverNumber[i]); - inaddr2str (server_addr, server_name, sizeof(server_name)); + get_servername (htonl(nvlentry.serverNumber[i]), + server_name, sizeof(server_name)); partition_num2name (nvlentry.serverPartition[i], part_name, sizeof(part_name)); @@ -145,22 +138,22 @@ static int noauth; static int localauth; static int verbose; -static struct getargs args[] = { - {"id", 0, arg_string, &vol, "id of volume", "volume", - arg_mandatory}, - {"host", 0, arg_string, &host, "what host to use", NULL}, - {"cell", 0, arg_string, &cell, "what cell to use", NULL}, - {"noauth", 0, arg_flag, &noauth, "do not authenticate", NULL}, - {"localauth",0,arg_flag, &localauth, "localauth", NULL}, - {"verbose", 0, arg_flag, &verbose, "be verbose", NULL}, - {"help", 0, arg_flag, &helpflag, NULL, NULL}, - {NULL, 0, arg_end, NULL} +static struct agetargs args[] = { + {"id", 0, aarg_string, &vol, "id of volume", "volume", + aarg_mandatory}, + {"host", 0, aarg_string, &host, "what host to use", NULL}, + {"cell", 0, aarg_string, &cell, "what cell to use", NULL}, + {"noauth", 0, aarg_flag, &noauth, "do not authenticate", NULL}, + {"localauth",0,aarg_flag, &localauth, "localauth", NULL}, + {"verbose", 0, aarg_flag, &verbose, "be verbose", NULL}, + {"help", 0, aarg_flag, &helpflag, NULL, NULL}, + {NULL, 0, aarg_end, NULL} }; static void usage(void) { - arg_printusage(args, "vos vldbexamine", "", ARG_AFSSTYLE); + aarg_printusage(args, "vos vldbexamine", "", AARG_AFSSTYLE); } int @@ -171,7 +164,7 @@ vos_vldbexamine(int argc, char **argv) helpflag = noauth = localauth = verbose = 0; host = cell = vol = NULL; - if (getarg (args, argc, argv, &optind, ARG_AFSSTYLE)) { + if (agetarg (args, argc, argv, &optind, AARG_AFSSTYLE)) { usage (); return 0; } diff --git a/usr.sbin/afs/src/arlad/.gdbinit b/usr.sbin/afs/src/arlad/.gdbinit index cab126d8928..644d8d62a7b 100644 --- a/usr.sbin/afs/src/arlad/.gdbinit +++ b/usr.sbin/afs/src/arlad/.gdbinit @@ -1,5 +1,5 @@ # -# $Id: .gdbinit,v 1.1 2000/09/11 14:40:39 art Exp $ +# $KTH: .gdbinit,v 1.5 2000/11/02 12:41:46 lha Exp $ # @@ -107,3 +107,87 @@ end document lwp_ps Print all processes, running or blocked end + +define list_count + set $count = 0 + set $current = ((List *)$arg0)->head + while $current != 0 + set $count = $count + 1 + set $current = $current->next + end + printf "List contains %d entries\n", $count +end + +document list_count +Count number of elements on util LIST. +end + +define volume_print + set $current = 'volcache.c'::lrulist->head + while $current != 0 + set $entry = (VolCacheEntry *)$current->data + if $entry->refcount != 0 + printf "%p - %s ref: %d\n", $entry, $entry->entry->name, $entry->refcount + end + set $current = $current->next + end +end + +document volume_print +Print the volume in the volcache +end + +define volume_count + set $cnt = 0 + set $vol_refs = 0 + set $total_cnt = 0 + set $current = 'volcache.c'::lrulist->head + while $current != 0 + set $entry = (VolCacheEntry *)$current->data + if $entry->refcount != 0 + set $cnt = $cnt + 1 + set $total_cnt = $total_cnt + $entry->refcount + end + set $vol_refs = $vol_refs + $entry->vol_refs + set $current = $current->next + end + printf "Used volcache: counted: %d count: %d max: %d\n", $cnt, nactive_volcacheentries, nvolcacheentries + printf "Refcount total: %d, used fcache nodes are: %d\n", $total_cnt, 'fcache.c'::usedvnodes + printf "Volrefs total to %d\n", $vol_refs +end + +document volume_count +Print the number of active entries in volcache, by counting +them and printing the accounting variables +end + +define volume_check + set $current = 'volcache.c'::lrulist->head + while $current != 0 + set $entry = (VolCacheEntry *)$current->data + printf "checking %s\n", $entry->entry->name + + if $entry->refcount != 0 + set $cnt = 0 + printf " checking fcache\n" + set $fcur = 'fcache.c'::lrulist->head + while $fcur != 0 + if ((FCacheEntry *)$fcur->data)->volume == $entry + set $cnt = $cnt + 1 + end + set $fcur = $fcur->next + end + if $cnt != $entry->refcount + printf " failed %d fcache entries used, while entry was accounted for %d\n", $cnt, $entry->refcount + else + printf " ok\n" + end + end + + set $current = $current->next + end +end + +document volume_check +Check volcache consistency WRT fcache usage, too slow to use ! +end diff --git a/usr.sbin/afs/src/arlad/CellServDB.5 b/usr.sbin/afs/src/arlad/CellServDB.5 index bbd835c6a0a..c3424ef83f7 100644 --- a/usr.sbin/afs/src/arlad/CellServDB.5 +++ b/usr.sbin/afs/src/arlad/CellServDB.5 @@ -1,5 +1,5 @@ -.\" $OpenBSD: CellServDB.5,v 1.1 2000/09/11 14:40:39 art Exp $ -.\" $Id: CellServDB.5,v 1.1 2000/09/11 14:40:39 art Exp $ +.\" $OpenBSD: CellServDB.5,v 1.2 2002/06/07 04:28:57 hin Exp $ +.\" $KTH: CellServDB.5,v 1.3 2000/09/25 07:24:18 lha Exp $ .Dd April 19, 2000 .Dt CellServDB 5 .Os @@ -26,10 +26,20 @@ is read when .Nm arlad is started, normally when the system boots. .Pp -The text after the # is NOT a comment, it the hostname of the db-server. +The text after the # is NOT a comment, it the hostname of the +db-server, and it's used to lookup the address. The address is only +used when the hostname doesn't resolve. .Pp Entires in the file are searched and expanded by many programs +.Pp +There is better way to distribute database-server location then +CellServDB and that is via a DNS resource record called AFSDB. This +is better since there will be no more obsolete CellServDB files laying +around with no longer valid information. +.Pp +When useing AFSDB-rr, entries entries should still be listed, but +without listing any hosts. This is needed for dynroot to work. .Sh FILES -.Pa CellServDB +.Pa /usr/arla/etc/CellServDB .Sh SEE ALSO -.Xr arlad 1 +.Xr arlad 8 diff --git a/usr.sbin/afs/src/arlad/Makefile.in b/usr.sbin/afs/src/arlad/Makefile.in index a2044d467c8..a89d823791e 100644 --- a/usr.sbin/afs/src/arlad/Makefile.in +++ b/usr.sbin/afs/src/arlad/Makefile.in @@ -1,6 +1,7 @@ -# $Id: Makefile.in,v 1.1 2000/09/11 14:40:39 art Exp $ +# $KTH: Makefile.in,v 1.83.2.3 2001/05/28 23:22:46 mattiasa Exp $ srcdir = @srcdir@ +top_builddir = .. VPATH = @srcdir@ CC = @CC@ @@ -15,15 +16,18 @@ exec_prefix = @exec_prefix@ libdir = @libdir@ libexecdir = @libexecdir@ bindir = @bindir@ +sbindir = @sbindir@ sysconfdir = @sysconfdir@ mandir = @mandir@ transform = @program_transform_name@ ARLACACHEDIR = @ARLACACHEDIR@ ARLACONFFILE = @ARLACONFFILE@ -ARLA_BIN = arlad +ARLA_SBIN = arla-cli +ARLA_LIBEXEC = arlad -MANPAGES = CellServDB.5 ThisCell.5 SuidCells.5 arlad.1 +MANPAGES = CellServDB.5 DynRootDB.5 ThisCell.5 \ + SuidCells.5 arlad.8 arla-cli.8 DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)\" \ -DARLACACHEDIR=\"$(ARLACACHEDIR)\" \ @@ -44,6 +48,7 @@ INCLUDES = -I$(srcdir)/.. \ -I$(srcdir)/../include \ -I$(srcdir)/../xfs/include \ -I../rxdef \ + @INC_roken@ \ $(RXKADINC) DEFINES = -DDEBUG REALCFLAGS = $(INCLUDES) @KRB4_INC_FLAGS@ $(DEFINES) $(CFLAGS) \ @@ -51,23 +56,37 @@ REALCFLAGS = $(INCLUDES) @KRB4_INC_FLAGS@ $(DEFINES) $(CFLAGS) \ RXKADLIB = @RXKAD_LIBS@ KAFS_LIBS = @AIX_EXTRA_KAFS@ @KAFS_LIBS@ LIB_tgetent = @LIB_tgetent@ -LIBS = -L../lib/bufdir -lbufdir \ +LIBS_common = -L../lib/bufdir -lbufdir \ -L../rxdef -lrxdefclient -L../rx -lrx -L../lwp \ - -llwp @PLWP_LIB_FLAGS@ \ + -llwp @PLWP_LIB_FLAGS@ + +LIBS_common_post= -L../lib/ko -lko -L../util -lutil\ + @LIB_roken@ $(RXKADLIB) $(KAFS_LIBS) @LIBS@ + +LIBS_arla-cli = $(LIBS_common) \ -L../lib/sl -lsl @LIB_readline@ \ - -L../lib/ko -lko -L../util -lutil\ - -L../lib/roken -lroken $(RXKADLIB) $(KAFS_LIBS) @LIBS@ + $(LIBS_common_post) + +LIBS_arlad = $(LIBS_common) \ + $(LIBS_common_post) + +LIBS_afsdir_check= $(LIBS_common) \ + $(LIBS_common_post) + LIBDEPENDS = ../rxdef/librxdefclient.a ../rx/librx.a ../lwp/liblwp.a \ - ../util/libutil.a ../lib/sl/libsl.a ../lib/roken/libroken.a \ - ../lib/ko/libko.a + ../util/libutil.a ../lib/sl/libsl.a \ + ../lib/ko/libko.a ../lib/bufdir/libbufdir.a KERNEL_SRCS = @KERNEL_SRCS@ -PROGS = arlad afsdir_check +PROGS = $(ARLA_SBIN) $(ARLA_LIBEXEC) afsdir_check + SRCS = \ adir.c \ afsdir_check.c \ arla.c \ + arlad.c \ + arla-cli.c \ arladeb.c \ - arladeb2.c \ + arladebu.c \ cmcb.c \ conn.c \ cred.c \ @@ -108,11 +127,11 @@ HDRS = \ xfs.h \ volcache.h -arlad_OBJS = \ +common_OBJS = \ adir.o \ arla.o \ arladeb.o \ - arladeb2.o \ + arladebu.o \ cmcb.o \ conn.o \ cred.o \ @@ -130,9 +149,13 @@ arlad_OBJS = \ xfs.o \ $(KERNEL_SRCS:.c=.o) -afsdir_check_OBJS = \ - arladeb.o \ - afsdir_check.o +arlad_OBJS = $(common_OBJS) \ + arlad.o + +arla-cli_OBJS = $(common_OBJS) \ + arla-cli.o + +afsdir_check_OBJS = afsdir_check.o .PHONY: all install uninstall depend tags clean @@ -142,10 +165,15 @@ all: $(PROGS) $(CC) -c $(CPPFLAGS) $(DEFS) -I$(srcdir) -I. $(REALCFLAGS) $< install: all - $(MKINSTALLDIRS) $(DESTDIR)$(bindir) - PROG_BIN='$(ARLA_BIN)'; for x in $$PROG_BIN; do \ + $(MKINSTALLDIRS) $(DESTDIR)$(sbindir) + PROG_SBIN='$(ARLA_SBIN)'; for x in $$PROG_SBIN; do \ + f=`echo $$x | sed '$(transform)'`; \ + $(INSTALL_PROGRAM) $$x $(DESTDIR)$(sbindir)/$$f; \ + done ; \ + $(MKINSTALLDIRS) $(DESTDIR)$(libexecdir) ; \ + PROG_LIBEXEC='$(ARLA_LIBEXEC)'; for x in $$PROG_LIBEXEC; do \ f=`echo $$x | sed '$(transform)'`; \ - $(INSTALL_PROGRAM) $$x $(DESTDIR)$(bindir)/$$f; \ + $(INSTALL_PROGRAM) $$x $(DESTDIR)$(libexecdir)/$$f; \ done ; \ $(MKINSTALLDIRS) $(DESTDIR)$(mandir) ; \ MANPAGES='$(MANPAGES)'; for x in $$MANPAGES; do \ @@ -153,7 +181,7 @@ install: all e=`echo $$x | sed 's/.*\.\([1-9a-zA-Z]*\)$$/\1/'`; \ f=`echo $$n | sed '$(transform)'`; \ $(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$$e ; \ - $(INSTALL_PROGRAM) $(srcdir)/$$x \ + $(INSTALL_DATA) $(srcdir)/$$x \ $(DESTDIR)$(mandir)/man$$e/$$f.$$e; \ done @@ -162,6 +190,10 @@ uninstall: f=`echo $$x | sed '$(transform)'`; \ rm -f $(DESTDIR)$(bindir)/$$f; \ done ; \ + PROG_LIBEXEC='$(ARLA_LIBEXEC)'; for x in $$PROG_LIBEXEC; do \ + f=`echo $$x | sed '$(transform)'`; \ + rm -f $(DESTDIR)$(libexecdir)/$$f; \ + done ; \ MANPAGES='$(MANPAGES)'; for x in $$MANPAGES; do \ n=`echo $$x | sed 's/\(.*\)\.[1-9a-zA-Z]*$$/\1/'`; \ e=`echo $$x | sed 's/.*\.\([1-9a-zA-Z]*\)$$/\1/'`; \ @@ -170,10 +202,13 @@ uninstall: done arlad: $(arlad_OBJS) $(LIBDEPENDS) - $(CC) $(LDFLAGS) -o $@ $(arlad_OBJS) $(LIBS) + $(CC) $(LDFLAGS) -o $@ $(arlad_OBJS) $(LIBS_arlad) + +arla-cli: $(arla-cli_OBJS) $(LIBDEPENDS) + $(CC) $(LDFLAGS) -o $@ $(arla-cli_OBJS) $(LIBS_arla-cli) afsdir_check: $(afsdir_check_OBJS) - $(CC) $(LDFLAGS) -o $@ $(afsdir_check_OBJS) $(LIBS) + $(CC) $(LDFLAGS) -o $@ $(afsdir_check_OBJS) $(LIBS_afsdir_check) Makefile: Makefile.in ../config.status cd ..; CONFIG_FILES=arlad/Makefile CONFIG_HEADERS= $(SHELL) config.status diff --git a/usr.sbin/afs/src/arlad/SuidCells.5 b/usr.sbin/afs/src/arlad/SuidCells.5 index 4f857d86b04..5512fb7a136 100644 --- a/usr.sbin/afs/src/arlad/SuidCells.5 +++ b/usr.sbin/afs/src/arlad/SuidCells.5 @@ -1,5 +1,5 @@ -.\" $OpenBSD: SuidCells.5,v 1.1 2000/09/11 14:40:39 art Exp $ -.\" $Id: SuidCells.5,v 1.1 2000/09/11 14:40:39 art Exp $ +.\" $OpenBSD: SuidCells.5,v 1.2 2002/06/07 04:28:57 hin Exp $ +.\" $KTH: SuidCells.5,v 1.3 2000/09/25 07:25:59 lha Exp $ .Dd April 19, 2000 .Dt SuidCells 5 .Os @@ -9,8 +9,12 @@ .Sh DESCRIPTION The setuid bit on binaries executed from within AFS are ignored for the cells that are not listed in +.Nm . +.Pp +The .Nm +file contain a list of cells separated by newline. The cells need to +exist in CellServDB or in DNS (with AFSDB resource records). .Sh SEE ALSO -.Xr arlad 1 , +.Xr arlad 8 , .Xr CellServDB 5 - diff --git a/usr.sbin/afs/src/arlad/ThisCell.5 b/usr.sbin/afs/src/arlad/ThisCell.5 index aaa90f3ed3b..67fdff348ac 100644 --- a/usr.sbin/afs/src/arlad/ThisCell.5 +++ b/usr.sbin/afs/src/arlad/ThisCell.5 @@ -1,5 +1,5 @@ -.\" $OpenBSD: ThisCell.5,v 1.1 2000/09/11 14:40:39 art Exp $ -.\" $Id: ThisCell.5,v 1.1 2000/09/11 14:40:39 art Exp $ +.\" $OpenBSD: ThisCell.5,v 1.2 2002/06/07 04:28:57 hin Exp $ +.\" $KTH: ThisCell.5,v 1.4 2000/09/26 22:36:29 lha Exp $ .Dd April 19, 2000 .Dt ThisCell 5 .Os @@ -17,13 +17,13 @@ default cell to use for commands such as .Xr kauth 1 , .Xr kinit 1 , .Xr afslog 1 , -but other cells can still be used. +but other cells can still be used (often by giving a -cell argument). .Pp It also affects where the cache manager reads the root of afs, so having good connectivity to the default cell is very important. This can be avoided by using the dynroot feature of arlad. .Pp .Sh SEE ALSO -.Xr arlad 1 , +.Xr arlad 8 , .Xr SuidCells 5 , .Xr CellServDB 5 diff --git a/usr.sbin/afs/src/arlad/adir.c b/usr.sbin/afs/src/arlad/adir.c index 4cd197be39f..b5744fcab4e 100644 --- a/usr.sbin/afs/src/arlad/adir.c +++ b/usr.sbin/afs/src/arlad/adir.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -42,7 +37,7 @@ #include "arla_local.h" -RCSID("$Id: adir.c,v 1.3 2000/09/11 14:40:39 art Exp $") ; +RCSID("$KTH: adir.c,v 1.66.2.1 2001/06/04 22:16:34 ahltorp Exp $") ; /* * @@ -81,11 +76,7 @@ get_fbuf_from_fid (VenusFid *fid, CredCacheEntry **ce, */ int -adir_lookup_fcacheentry (FCacheEntry *centry, - VenusFid dir, - const char *name, - VenusFid *file, - CredCacheEntry *ce) +adir_lookup (FCacheEntry *centry, const char *name, VenusFid *file) { int ret; int fd; @@ -96,53 +87,13 @@ adir_lookup_fcacheentry (FCacheEntry *centry, if (ret) return ret; - ret = fdir_lookup (&the_fbuf, &dir, name, file); + ret = fdir_lookup (&the_fbuf, ¢ry->fid, name, file); fbuf_end (&the_fbuf); close (fd); return ret; } /* - * Lookup ``name'' in the AFS directory identified by ``dir'' and - * return the Fid in ``file''. All operations are done as ``cred'' - * and return value is 0 or error code. If ``dentry'' is set, its the - * entry of the ``dir'' if returnvalue is 0. - */ - -int -adir_lookup (VenusFid *dir, - const char *name, - VenusFid *file, - FCacheEntry **dentry, - CredCacheEntry **ce) -{ - int fd; - fbuf the_fbuf; - FCacheEntry *centry; - int ret; - - ret = get_fbuf_from_fid (dir, ce, &fd, &the_fbuf, ¢ry, O_RDONLY, - FBUF_READ|FBUF_PRIVATE); - if (ret) - return ret; - - ret = fdir_lookup (&the_fbuf, dir, name, file); - fbuf_end (&the_fbuf); - close (fd); - if (dentry) { - if (ret) { - *dentry = NULL; - fcache_release (centry); - } else { - *dentry = centry; - } - } else { - fcache_release (centry); - } - return ret; -} - -/* * Lookup `name' in the AFS directory identified by `dir' and change the * fid to `fid'. */ @@ -236,7 +187,7 @@ adir_mkdir (FCacheEntry *dir, fbuf the_fbuf; int ret; - assert (CheckLock(&dir->lock) == -1); + AssertExclLocked(&dir->lock); ret = fcache_get_fbuf (dir, &fd, &the_fbuf, O_RDWR, FBUF_READ|FBUF_WRITE|FBUF_SHARED); diff --git a/usr.sbin/afs/src/arlad/adir.h b/usr.sbin/afs/src/arlad/adir.h index ad7769e34cf..2b9dd3338c6 100644 --- a/usr.sbin/afs/src/arlad/adir.h +++ b/usr.sbin/afs/src/arlad/adir.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ * Interface to directory handling routines */ -/* $Id: adir.h,v 1.3 2000/09/11 14:40:39 art Exp $ */ +/* $KTH: adir.h,v 1.14.2.1 2001/06/04 22:16:35 ahltorp Exp $ */ #ifndef _ADIR_H_ #define _ADIR_H_ @@ -50,13 +45,8 @@ #include "fcache.h" #include "fdir.h" -int adir_lookup (VenusFid *dir, const char *name, VenusFid *file, - FCacheEntry **dentry, CredCacheEntry **ce); - int -adir_lookup_fcacheentry (FCacheEntry *centry, VenusFid dir, - const char *name, - VenusFid *file, CredCacheEntry *ce); +adir_lookup (FCacheEntry *centry, const char *name, VenusFid *file); int adir_changefid (VenusFid *dir, diff --git a/usr.sbin/afs/src/arlad/afsdir_check.c b/usr.sbin/afs/src/arlad/afsdir_check.c index b27b5a770f5..6fdb3c499f0 100644 --- a/usr.sbin/afs/src/arlad/afsdir_check.c +++ b/usr.sbin/afs/src/arlad/afsdir_check.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,26 +35,10 @@ * Check a directory in afs format. */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <stdio.h> -#include <assert.h> -#include <fcntl.h> -#include <sys/types.h> -#include <atypes.h> -#include <sys/stat.h> -#include <err.h> -#include <roken.h> - +#include "arla_local.h" #include <getarg.h> -#include "ko.h" -#include "fbuf.h" -#include "arladeb.h" -#include "afs_dir.h" - -RCSID("$Id: afsdir_check.c,v 1.3 2000/09/11 14:40:39 art Exp $"); +RCSID("$KTH: afsdir_check.c,v 1.21.2.1 2001/10/03 23:36:00 assar Exp $"); static int help_flag; static int verbose = 0; @@ -101,7 +80,7 @@ getentry (DirPage0 *page0, } static int -check (const char *filename) +check_dir (const char *filename) { struct stat statbuf; int fd; @@ -319,13 +298,12 @@ static struct getargs args[] = { "run in test mode", NULL}, {"help", 0, arg_flag, &help_flag, NULL, NULL}, - {NULL, 0, arg_end, NULL, NULL, NULL} }; static void usage (int ret) { - arg_printusage (args, NULL, "[file]", ARG_GNUSTYLE); + arg_printusage (args, sizeof(args)/sizeof(*args), NULL, "[file]"); exit (ret); } @@ -334,7 +312,7 @@ main(int argc, char **argv) { int optind = 0; - if (getarg (args, argc, argv, &optind, ARG_GNUSTYLE)) + if (getarg (args, sizeof(args)/sizeof(*args), argc, argv, &optind)) usage (1); argc -= optind; @@ -346,8 +324,5 @@ main(int argc, char **argv) if (argc != 1) usage (1); - arla_loginit ("/dev/stderr"); - arla_log_set_level ("all"); - - return check (argv[0]); + return check_dir (argv[0]); } diff --git a/usr.sbin/afs/src/arlad/aix-subr.c b/usr.sbin/afs/src/arlad/aix-subr.c index 43c9a9f9fec..a60d351f218 100644 --- a/usr.sbin/afs/src/arlad/aix-subr.c +++ b/usr.sbin/afs/src/arlad/aix-subr.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,8 +31,10 @@ * SUCH DAMAGE. */ +#define _KERNEL + #include "arla_local.h" -RCSID("$Id: aix-subr.c,v 1.1 2000/09/11 14:40:39 art Exp $"); +RCSID("$KTH: aix-subr.c,v 1.14 2000/10/14 19:58:04 map Exp $"); static long blocksize = 1024; @@ -85,7 +82,7 @@ write_dirent(VenusFid *fid, const char *name, void *arg) Result conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { return conv_dir_sub (e, ce, tokens, cache_handle, cache_name, @@ -98,7 +95,7 @@ conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, int dir_remove_name (FCacheEntry *e, const char *filename, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { int ret; diff --git a/usr.sbin/afs/src/arlad/arla.c b/usr.sbin/afs/src/arlad/arla.c index 89621004a0e..39294d7c903 100644 --- a/usr.sbin/afs/src/arlad/arla.c +++ b/usr.sbin/afs/src/arlad/arla.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -41,504 +36,13 @@ */ #include "arla_local.h" -#include <sl.h> #include <parse_units.h> #include <getarg.h> -#include <arla-version.h> - -RCSID("$Id: arla.c,v 1.3 2000/09/11 14:40:39 art Exp $") ; +RCSID("$KTH: arla.c,v 1.135.2.2 2001/09/14 13:26:31 lha Exp $") ; enum connected_mode connected_mode = CONNECTED; -/* creds used for all the interactive usage */ - -static CredCacheEntry *ce; - -static VenusFid cwd; -static VenusFid rootcwd; - -static int arla_chdir(int, char **); -static int arla_ls(int, char **); -static int arla_cat(int, char **); -static int arla_cp(int, char **); -static int arla_wc(int, char **); -static int help(int, char **); -static int arla_quit(int, char **); -static int arla_checkserver(int, char **); -static int arla_conn_status(int, char **); -static int arla_vol_status(int, char **); -static int arla_cred_status(int, char **); -static int arla_fcache_status(int, char **); -static int arla_sysname(int, char**); -#ifdef RXDEBUG -static int arla_rx_status(int argc, char **argv); -#endif -static int arla_flushfid(int argc, char **argv); - -static SL_cmd cmds[] = { - {"chdir", arla_chdir, "chdir directory"}, - {"cd"}, - {"ls", arla_ls, "ls"}, - {"cat", arla_cat, "cat file"}, - {"cp", arla_cp, "copy file"}, - {"wc", arla_wc, "wc file"}, - {"help", help, "help"}, - {"?"}, - {"checkservers", arla_checkserver, "poll servers are down"}, - {"conn-status", arla_conn_status, "connection status"}, - {"vol-status", arla_vol_status, "volume cache status"}, - {"cred-status", arla_cred_status, "credentials status"}, - {"fcache-status", arla_fcache_status, "file cache status"}, -#ifdef RXDEBUG - {"rx-status", arla_rx_status, "rx connection status"}, -#endif - {"flushfid", arla_flushfid, "flush a fid from the cache"}, - {"quit", arla_quit, "quit"}, - {"exit"}, - {"sysname", arla_sysname, "sysname"}, - { NULL } -}; - -/* An emulation of kernel lookup, convert (startdir, fname) into - * (startdir). Strips away leading /afs, removes duobles slashes, - * and resolves symlinks. - * Return 0 for success, otherwise -1. - */ - -static int -walk (VenusFid *startdir, char *fname) -{ - VenusFid cwd = *startdir; - char *base; - VenusFid file; - Result ret; - FCacheEntry *entry; - int error; - char symlink[MAXPATHLEN]; - char store_name[MAXPATHLEN]; - - strlcpy(store_name, fname, sizeof(store_name)); - fname = store_name; - - do { - /* set things up so that fname points to the remainder of the path, - * whereas base points to the whatever preceeds the first / - */ - base = fname; - fname = strchr(fname, '/'); - if (fname) { - /* deal with repeated adjacent / chars by eliminating the - * duplicates. - */ - while (*fname == '/') { - *fname = '\0'; - fname++; - } - } - - /* deal with absolute pathnames first. */ - if (*base == '\0') { - cwd = rootcwd; - if (fname) { - if (strncmp("afs",fname,3) == 0) { - fname += 3; - } - continue; - } else { - break; - } - } - ret = cm_lookup (&cwd, base, &file, &ce, TRUE); - if (ret.res) { - arla_warn (ADEBWARN, ret.error, "lookup(%s)", base); - return -1; - } - error = fcache_get_data (&entry, &file, &ce); - if (error) { - arla_warn (ADEBWARN, error, "fcache_get"); - return -1; - } - - /* handle symlinks here */ - if (entry->status.FileType == TYPE_LINK) { - int len; - int fd; - - fd = fcache_open_file (entry, O_RDONLY); - /* read the symlink and null-terminate it */ - if (fd < 0) { - fcache_release(entry); - arla_warn (ADEBWARN, errno, "fcache_open_file"); - return -1; - } - len = read (fd, symlink, sizeof(symlink)); - close (fd); - if (len <= 0) { - fcache_release(entry); - arla_warnx (ADEBWARN, "cannot read symlink"); - return -1; - } - symlink[len] = '\0'; - /* if we're not at the end (i.e. fname is not null), take - * the expansion of the symlink and append fname to it. - */ - if (fname != NULL) { - strcat (symlink, "/"); - strcat (symlink, fname); - } - strlcpy(store_name, symlink, sizeof(store_name)); - fname = store_name; - } else { - /* if not a symlink, just update cwd */ - cwd = file; - } - fcache_release(entry); - - /* the *fname condition below deals with a trailing / in a - * path-name */ - } while (fname != NULL && *fname); - *startdir = cwd; - return 0; -} - -static int -arla_quit (int argc, char **argv) -{ - printf("Thank you for using arla\n"); - return 1; -} - -static int -arla_flushfid(int argc, char **argv) -{ - AFSCallBack broken_callback = {0, 0, CBDROPPED}; - VenusFid fid; - - if (argc != 2) { - fprintf(stderr, "flushfid fid\n"); - return 0; - } - - if ((sscanf(argv[1], "%d.%d.%d.%d", &fid.Cell, &fid.fid.Volume, - &fid.fid.Vnode, &fid.fid.Unique)) == 4) { - ; - } else if ((sscanf(argv[1], "%d.%d.%d", &fid.fid.Volume, - &fid.fid.Vnode, &fid.fid.Unique)) == 3) { - fid.Cell = cwd.Cell; - } else { - fprintf(stderr, "flushfid fid\n"); - return 0; - } - - fcache_stale_entry(fid, broken_callback); - - return 0; -} - - -static int -arla_chdir (int argc, char **argv) -{ - if (argc != 2) { - printf ("usage: %s dir\n", argv[0]); - return 0; - } - - if(walk (&cwd, argv[1])) - printf ("walk %s failed\n", argv[1]); - return 0; -} - -static void -print_dir (VenusFid *fid, const char *name, void *v) -{ - printf("(%d, %d, %d, %d): %s\n", fid->Cell, - fid->fid.Volume, - fid->fid.Vnode, - fid->fid.Unique, name); -} - -struct ls_context { - VenusFid *dir_fid; - CredCacheEntry *ce; -}; - -static void -print_dir_long (VenusFid *fid, const char *name, void *v) -{ - Result res; - int ret; - AFSFetchStatus status; - VenusFid realfid; - AccessEntry *ae; - struct ls_context *context = (struct ls_context *)v; - char type; - CredCacheEntry *ce = context->ce; - VenusFid *dir_fid = context->dir_fid; - char timestr[20]; - struct tm *t; - time_t ti; - - if (VenusFid_cmp(fid, dir_fid) == 0) - return; - - ret = followmountpoint (fid, dir_fid, &ce); - if (ret) { - printf ("follow %s: %d\n", name, ret); - return; - } - - res = cm_getattr (*fid, &status, &realfid, context->ce, &ae); - if (res.res) { - printf ("%s: %d\n", name, res.res); - return; - } - - switch (status.FileType) { - case TYPE_FILE : - type = '-'; - break; - case TYPE_DIR : - type = 'd'; - break; - case TYPE_LINK : - type = 'l'; - break; - default : - abort (); - } - - printf("(%4d, %8d, %8d, %8d): ", - fid->Cell, - fid->fid.Volume, - fid->fid.Vnode, - fid->fid.Unique); - - ti = status.ClientModTime; - t = localtime (&ti); - strftime (timestr, sizeof(timestr), "%Y-%m-%d", t); - printf ("%c%c%c%c%c%c%c%c%c%c %2d %6d %6d %8d %s ", - type, - status.UnixModeBits & 0x100 ? 'w' : '-', - status.UnixModeBits & 0x080 ? 'r' : '-', - status.UnixModeBits & 0x040 ? 'x' : '-', - status.UnixModeBits & 0x020 ? 'w' : '-', - status.UnixModeBits & 0x010 ? 'r' : '-', - status.UnixModeBits & 0x008 ? 'x' : '-', - status.UnixModeBits & 0x004 ? 'w' : '-', - status.UnixModeBits & 0x002 ? 'r' : '-', - status.UnixModeBits & 0x001 ? 'x' : '-', - status.LinkCount, - status.Owner, - status.Group, - status.Length, - timestr); - - printf ("v %d ", status.DataVersion); - - printf ("%s\n", name); -} - -static int -arla_ls (int argc, char **argv) -{ - struct getargs args[] = { - {NULL, 'l', arg_flag, NULL}, - {NULL, 0, arg_end, NULL} - }; - int l_flag = 0; - int error; - int optind = 0; - struct ls_context context; - - args[0].value = &l_flag; - - if (getarg (args, argc, argv, &optind, ARG_SHORTARG)) { - arg_printusage (args, "ls", NULL, ARG_SHORTARG); - return 0; - } - context.dir_fid = &cwd; - context.ce = ce; - error = adir_readdir (&cwd, l_flag ? print_dir_long : print_dir, - &context, &ce); - if (error) - printf ("adir_readdir failed: %s\n", koerr_gettext(error)); - return 0; -} - -static int -arla_sysname (int argc, char **argv) -{ - switch (argc) { - case 1: - printf("sysname: %s\n", arlasysname); - break; - case 2: - strlcpy(arlasysname, argv[1], SYSNAMEMAXLEN); - printf("setting sysname to: %s\n", arlasysname); - break; - default: - printf("syntax: sysname <sysname>\n"); - break; - } - return 0; -} - - -static int -arla_cat_et_wc (int argc, char **argv, int do_cat, int out_fd) -{ - VenusFid fid; - int fd; - char buf[8192]; - int ret; - FCacheEntry *e; - size_t size = 0; - - if (argc != 2) { - printf ("usage: %s file\n", argv[0]); - return 0; - } - fid = cwd; - if(walk (&fid, argv[1]) == 0) { - - ret = fcache_get_data (&e, &fid, &ce); - if (ret) { - printf ("fcache_get_data failed: %d\n", ret); - return 0; - } - - fd = fcache_open_file (e, O_RDONLY); - - if (fd < 0) { - fcache_release(e); - printf ("fcache_open_file failed: %d\n", errno); - return 0; - } - while ((ret = read (fd, buf, sizeof(buf))) > 0) { - if(do_cat) - write (out_fd, buf, ret); - else - size += ret; - } - if(!do_cat) - printf("%lu %s\n", (unsigned long)size, argv[1]); - close (fd); - fcache_release(e); - } - return 0; -} - -static int -arla_cat (int argc, char **argv) -{ - return arla_cat_et_wc(argc, argv, 1, STDOUT_FILENO); -} - -static int -arla_cp (int argc, char **argv) -{ - char *nargv[3]; - int fd, ret; - - if (argc != 3) { - printf ("usage: %s from-file to-file\n", argv[0]); - return 0; - } - - fd = open (argv[2], O_CREAT|O_WRONLY|O_TRUNC, 0600); - if (fd < 0) { - warn ("open"); - return 0; - } - - nargv[0] = argv[0]; - nargv[1] = argv[1]; - nargv[2] = NULL; - - ret = arla_cat_et_wc(argc-1, nargv, 1, fd); - close (fd); - return ret; - -} - -static int -arla_wc (int argc, char **argv) -{ - return arla_cat_et_wc(argc, argv, 0, -1); -} - - -static int -help (int argc, char **argv) -{ - sl_help(cmds, argc, argv); - return 0; -} - -static int -arla_checkserver (int argc, char **argv) -{ - u_int32_t hosts[12]; - int num = sizeof(hosts)/sizeof(hosts[0]); - - conn_downhosts(cwd.Cell, hosts, &num, 0); - if (num < 0 || num > sizeof(hosts)/sizeof(hosts[0])) { - fprintf (stderr, "conn_downhosts returned bogus num: %d\n", num); - return 0; - } - if (num == 0) { - printf ("no servers down in %s\n", cell_num2name(cwd.Cell)); - } else { - while (num) { - struct in_addr in; - in.s_addr = hosts[num]; - printf ("down: %s\n", inet_ntoa(in)); - num--; - } - } - - return 0; -} - -static int -arla_conn_status (int argc, char **argv) -{ - conn_status (); - return 0; -} - -static int -arla_vol_status (int argc, char **argv) -{ - volcache_status (); - return 0; -} - -static int -arla_cred_status (int argc, char **argv) -{ - cred_status (); - return 0; -} - -static int -arla_fcache_status (int argc, char **argv) -{ - fcache_status (); - return 0; -} - -#ifdef RXDEBUG -static int -arla_rx_status(int argc, char **argv) -{ - rx_PrintStats(stderr); - return 0; -} -#endif - static void initrx (int port) { @@ -549,35 +53,8 @@ initrx (int port) arla_err (1, ADEBERROR, error, "rx_init"); } -#ifdef KERBEROS - -static int -get_cred(const char *princ, const char *inst, const char *krealm, - CREDENTIALS *c) -{ - KTEXT_ST foo; - int k_errno; - - k_errno = krb_get_cred((char*)princ, (char*)inst, (char*)krealm, c); - - if(k_errno != KSUCCESS) { - k_errno = krb_mk_req(&foo, (char*)princ, (char*)inst, (char*)krealm, 0); - if (k_errno == KSUCCESS) - k_errno = krb_get_cred((char*)princ, (char*)inst, (char*)krealm, c); - } - return k_errno; -} - - -#endif /* KERBEROS */ - -#define KERNEL_STACKSIZE (16*1024) - -/* - * - */ -static void +void store_state (void) { arla_warnx (ADEBMISC, "storing state"); @@ -586,76 +63,6 @@ store_state (void) cm_store_state (); } -char *pid_filename; - -static void -write_pid_file (const char *progname) -{ - FILE *fp; - - asprintf (&pid_filename, "/var/run/%s.pid", progname); - if (pid_filename == NULL) - return; - fp = fopen (pid_filename, "w"); - if (fp == NULL) - return; - fprintf (fp, "%u", (unsigned)getpid()); - fclose (fp); -} - -static void -delete_pid_file (void) -{ - if (pid_filename != NULL) { - unlink (pid_filename); - free (pid_filename); - pid_filename = NULL; - } -} - -/* - * signal handlers... - */ - -static void -sigint (int foo) -{ - arla_warnx (ADEBMISC, "fatal signal received"); - store_state (); - delete_pid_file (); - exit (0); -} - -static void -sighup (int foo) -{ - store_state (); - delete_pid_file (); -} - -static void -daemonify (void) -{ - pid_t pid; - int fd; - - pid = fork (); - if (pid < 0) - arla_err (1, ADEBERROR, errno, "fork"); - else if (pid > 0) - exit(0); - if (setsid() == -1) - arla_err (1, ADEBERROR, errno, "setsid"); - fd = open(_PATH_DEVNULL, O_RDWR, 0); - if (fd < 0) - arla_err (1, ADEBERROR, errno, "open " _PATH_DEVNULL); - dup2 (fd, STDIN_FILENO); - dup2 (fd, STDOUT_FILENO); - dup2 (fd, STDERR_FILENO); - if (fd > 2) - close (fd); -} - struct conf_param { const char *name; unsigned *val; @@ -783,71 +190,40 @@ static struct conf_param conf_params[] = { {"dynroot", &dynrootlevel, DYNROOT_DEFAULT}, {NULL, NULL, 0}}; -static int test_flag; -static char *conf_file = ARLACONFFILE; -static char *log_file = NULL; -static char *device_file = "/dev/xfs0"; -static char *debug_levels = NULL; -static char *connected_mode_string = NULL; +char *conf_file = ARLACONFFILE; +char *log_file = NULL; +char *debug_levels = NULL; +char *connected_mode_string = NULL; #ifdef KERBEROS -static char *rxkad_level_string = "auth"; +char *rxkad_level_string = "auth"; #endif -static const char *temp_sysname = NULL; -static char *root_volume; -static char *cache_dir; -static int version_flag; -static int help_flag; -static int fork_flag = 1; -static int client_port = 4711; -static int recover = 0; -static int dynroot_enable = 0; -static int num_workers = 16; -static int usedbytes_consistency = 0; +const char *temp_sysname = NULL; +char *root_volume; +int cpu_usage; +int version_flag; +int help_flag; +int recover = 0; +int dynroot_enable = 0; +int cm_consistency = 0; +/* + * These are exported to other modules + */ + +int num_workers = 16; +char *cache_dir; int fake_mp; +int fork_flag = 1; -static struct getargs args[] = { - {"test", 't', arg_flag, &test_flag, - "run in test mode", NULL}, - {"conffile", 'c', arg_string, &conf_file, - "path to configuration file", "file"}, - {"usedbytes-consistency", 'b', arg_flag, &usedbytes_consistency, - "if we want extra paranoid usedbytes consistency check", NULL }, - {"log", 'l', arg_string, &log_file, - "where to write log (stderr (default), syslog, or path to file)", NULL}, - {"debug", 0, arg_string, &debug_levels, - "what to write in the log", NULL}, - {"device", 'd', arg_string, &device_file, - "the XFS device to use [/dev/xfs0]", "path"}, - {"connected-mode", 0, arg_string, &connected_mode_string, - "initial connected mode [conncted|fetch-only|disconnected]", NULL}, - {"dynroot", 'D', arg_flag, &dynroot_enable, - "if dynroot is enabled", NULL}, - {"fork", 'n', arg_negative_flag, &fork_flag, - "don't fork and demonize", NULL}, -#ifdef KERBEROS - {"rxkad-level", 'r', arg_string, &rxkad_level_string, - "the rxkad level to use (clear, auth or crypt)", NULL}, -#endif - {"sysname", 's', arg_string, &temp_sysname, - "set the sysname of this system", NULL}, - {"root-volume",0, arg_string, &root_volume}, - {"port", 0, arg_integer, &client_port, - "port number to use", "number"}, - {"recover", 'z', arg_negative_flag, &recover, - "don't recover state", NULL}, - {"cache-dir", 0, arg_string, &cache_dir, - "cache directory", "directory"}, - {"workers", 0, arg_integer, &num_workers, - "number of worker threads", NULL}, - {"fake-mp", 0, arg_flag, &fake_mp, - "enable fake mountpoints", NULL}, - {"version", 0, arg_flag, &version_flag, - NULL, NULL}, - {"help", 0, arg_flag, &help_flag, - NULL, NULL}, - {NULL, 0, arg_end, NULL, NULL, NULL} -}; +/* + * Global AFS variables, se arla_local.h for comment + */ + +int afs_BusyWaitPeriod = 15; + +/* + * + */ static int parse_string_list (const char *s, const char **units) @@ -898,50 +274,16 @@ set_connected_mode (const char *s) return parse_string_list (s, connected_levels); } -static void -usage (int ret) -{ - arg_printusage (args, NULL, "[device]", ARG_GNUSTYLE); - exit (ret); -} - - /* * */ int -main (int argc, char **argv) +arla_init (int argc, char **argv) { - PROCESS kernelpid; - int error; - int optind = 0; - char *default_log_file; + log_flags log_flags; char fpriofile[MAXPATHLEN]; - set_progname (argv[0]); - - if (getarg (args, argc, argv, &optind, ARG_GNUSTYLE)) - usage (1); - - argc -= optind; - argv += optind; - - if (help_flag) - usage (0); - - if (version_flag) - errx (1, "%s", arla_version); - - if (argc > 0) { - device_file = *argv; - argc--; - argv++; - } - - if (argc != 0) - usage (1); - if (temp_sysname == NULL) temp_sysname = arla_getsysname (); @@ -954,21 +296,13 @@ main (int argc, char **argv) errx (1, "bad rxkad level `%s'", rxkad_level_string); #endif - signal (SIGINT, sigint); - signal (SIGTERM, sigint); - signal (SIGHUP, sighup); - umask (S_IRWXG|S_IRWXO); /* 077 */ - - if (!test_flag && fork_flag) { - default_log_file = "syslog"; - } else { - default_log_file = "/dev/stderr"; - } - if (log_file == NULL) log_file = default_log_file; - arla_loginit(log_file); + log_flags = 0; + if (cpu_usage) + log_flags |= LOG_CPU_USAGE; + arla_loginit(log_file, log_flags); if (debug_levels != NULL) { if (arla_log_set_level (debug_levels) < 0) { @@ -989,7 +323,7 @@ main (int argc, char **argv) read_conffile(conf_file, conf_params); if (cache_dir == NULL) - cache_dir = ARLACACHEDIR; + cache_dir = get_default_cache_dir(); if (mkdir (cache_dir, 0777) < 0 && errno != EEXIST) arla_err (1, ADEBERROR, errno, "mkdir %s", cache_dir); @@ -1016,7 +350,7 @@ main (int argc, char **argv) arla_warnx (ADEBINIT, "conn_init numconns = %u", numconns); conn_init (numconns); arla_warnx (ADEBINIT, "cellcache"); - cell_init (0); + cell_init (0, arla_log_method); arla_warnx (ADEBINIT, "fprio"); fprio_init(fpriofile); arla_warnx (ADEBINIT, "volcache numvols = %u", numvols); @@ -1048,81 +382,12 @@ main (int argc, char **argv) arla_warnx(ADEBINIT, "cm"); cm_init (); - if (usedbytes_consistency) { - arla_warnx(ADEBINIT, "turning on usedbytes consistency test"); - cm_turn_on_usedbytes_consistency(); + if (cm_consistency) { + arla_warnx(ADEBINIT, "turning on consistency test"); + cm_turn_on_consistency_check(); } arla_warnx(ADEBINIT, "arla init done."); - if (test_flag) { -#ifdef KERBEROS - { - krbstruct krbdata; - int ret; - char *realm; - const char *this_cell = cell_getthiscell (); - const char *db_server = cell_findnamedbbyname (this_cell); - - if (db_server == NULL) - arla_errx (1, ADEBERROR, - "no db server for cell %s", this_cell); - realm = krb_realmofhost (db_server); - - ret = get_cred("afs", this_cell, realm, &krbdata.c); - if (ret) - ret = get_cred("afs", "", realm, &krbdata.c); - - if (ret) { - arla_warnx (ADEBWARN, - "getting ticket for %s: %s", - this_cell, - krb_get_err_text (ret)); - } else if (cred_add_krb4(getuid(), getuid(), &krbdata.c) == NULL) { - arla_warnx (ADEBWARN, "Could not insert tokens to arla"); - } - } -#endif - - ce = cred_get (cell_name2num(cell_getthiscell()), getuid(), CRED_ANY); - - xfs_message_init (); - kernel_opendevice ("null"); - - arla_warnx (ADEBINIT, "Getting root..."); - error = getroot (&rootcwd, ce); - if (error) - arla_err (1, ADEBERROR, error, "getroot"); - cwd = rootcwd; - arla_warnx(ADEBINIT, "arla loop started"); - sl_loop(cmds, "arla> "); - store_state (); - } else { - struct kernel_args kernel_args; - - xfs_message_init (); - kernel_opendevice (device_file); - - kernel_args.num_workers = num_workers; - - if (LWP_CreateProcess (kernel_interface, KERNEL_STACKSIZE, 1, - (char *)&kernel_args, - "Kernel-interface", &kernelpid)) - arla_errx (1, ADEBERROR, - "Cannot create kernel-interface process"); - if (fork_flag) { - daemonify (); - clock_ReInit (); - } - - write_pid_file ("arlad"); - - if (chroot (cache_dir) < 0) - arla_err (1, ADEBERROR, errno, "chroot %s", cache_dir); - - LWP_WaitProcess ((char *)main); - abort (); - } - return 0; } diff --git a/usr.sbin/afs/src/arlad/arla_local.h b/usr.sbin/afs/src/arlad/arla_local.h index da7ad59c892..5932d1a4d15 100644 --- a/usr.sbin/afs/src/arlad/arla_local.h +++ b/usr.sbin/afs/src/arlad/arla_local.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -38,7 +33,7 @@ /* * Include file for whole arlad - * $Id: arla_local.h,v 1.3 2000/09/11 14:40:40 art Exp $ + * $KTH: arla_local.h,v 1.61.2.3 2001/09/14 13:25:45 lha Exp $ */ #ifdef HAVE_CONFIG_H @@ -55,9 +50,7 @@ #include <errno.h> #include <sys/time.h> #if defined(HAVE_DIRENT_H) -#define _KERNEL #include <dirent.h> -#undef _KERNEL #if DIRENT_AND_SYS_DIR_H #include <sys/dir.h> #endif @@ -85,6 +78,9 @@ #ifdef HAVE_SYS_MOUNT_H #include <sys/mount.h> #endif +#ifdef HAVE_SYS_PRCTL_H +#include <sys/prctl.h> +#endif #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> @@ -173,6 +169,48 @@ extern char arlasysname[SYSNAMEMAXLEN]; * This should be a not used uid in the system, * XFS_ANONYMOUSID may be good */ + #define ARLA_NO_AUTH_CRED 4 extern int fake_mp; +extern char *default_log_file; +extern char *default_arla_cachedir; + +extern int fork_flag; /* if the program should fork */ +extern int num_workers; /* number of workers program should use */ +extern int client_port; /* what port the client is using */ +extern int afs_BusyWaitPeriod; /* number of sec to wait on fs when VBUSY */ + +void +store_state (void); + +void +arla_start (char *device_file, const char *cache_dir); + +int +arla_init (int argc, char **argv); + +char * +get_default_cache_dir (void); + +#ifndef O_BINARY +#define O_BINARY 0 +#endif + +extern char *conf_file; +extern char *log_file; +extern char *debug_levels; +extern char *connected_mode_string; +#ifdef KERBEROS +extern char *rxkad_level_string; +#endif +extern const char *temp_sysname; +extern char *root_volume; +extern int cpu_usage; +extern int version_flag; +extern int help_flag; +extern int recover; +extern int dynroot_enable; +extern int cm_consistency; + +extern char *cache_dir; diff --git a/usr.sbin/afs/src/arlad/arlad.8 b/usr.sbin/afs/src/arlad/arlad.8 index 3d3aac00ac5..246d2ddc26c 100644 --- a/usr.sbin/afs/src/arlad/arlad.8 +++ b/usr.sbin/afs/src/arlad/arlad.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: arlad.8,v 1.1 2002/06/07 04:14:22 hin Exp $ +.\" $OpenBSD: arlad.8,v 1.2 2002/06/07 04:28:57 hin Exp $ .\" $KTH: arlad.8,v 1.7.2.2 2001/05/06 22:49:03 ahltorp Exp $ .Dd September 5, 1998 .Dt ARLAD 1 diff --git a/usr.sbin/afs/src/arlad/arladeb.c b/usr.sbin/afs/src/arlad/arladeb.c index bd4ecca8686..f023f4a9416 100644 --- a/usr.sbin/afs/src/arlad/arladeb.c +++ b/usr.sbin/afs/src/arlad/arladeb.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,55 +31,12 @@ * SUCH DAMAGE. */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <assert.h> -#include <stdarg.h> -#include <stdlib.h> -#include <err.h> -#include <parse_units.h> -#include <roken.h> -#include "volcache.h" -#include "ko.h" - -#include "arladeb.h" - -RCSID("$Id: arladeb.c,v 1.3 2000/09/11 14:40:40 art Exp $"); +#include <arla_local.h> +RCSID("$KTH: arladeb.c,v 1.24.2.2 2001/04/30 00:01:59 lha Exp $"); Log_method* arla_log_method = NULL; Log_unit* arla_log_unit = NULL; -#define all (ADEBERROR | ADEBWARN | ADEBDISCONN | ADEBFBUF | \ - ADEBMSG | ADEBKERNEL | ADEBCLEANER | ADEBCALLBACK | \ - ADEBCM | ADEBVOLCACHE | ADEBFCACHE | ADEBINIT | \ - ADEBCONN | ADEBMISC | ADEBVLOG) - -#define DEFAULT_LOG (ADEBWARN | ADEBERROR) - -struct units arla_deb_units[] = { - { "all", all}, - { "almost-all", all & ~ADEBCLEANER}, - { "errors", ADEBERROR }, - { "warnings", ADEBWARN }, - { "disconn", ADEBDISCONN }, - { "fbuf", ADEBFBUF }, - { "messages", ADEBMSG }, - { "kernel", ADEBKERNEL }, - { "cleaner", ADEBCLEANER }, - { "callbacks", ADEBCALLBACK }, - { "cache-manager", ADEBCM }, - { "volume-cache", ADEBVOLCACHE }, - { "file-cache", ADEBFCACHE }, - { "initialization", ADEBINIT }, - { "connection", ADEBCONN }, - { "miscellaneous", ADEBMISC }, - { "venuslog", ADEBVLOG }, - { "default", DEFAULT_LOG }, - { "none", 0 }, - { NULL } -}; - void arla_log(unsigned level, char *fmt, ...) { @@ -97,8 +49,9 @@ arla_log(unsigned level, char *fmt, ...) va_end(args); } + void -arla_loginit(char *log) +arla_loginit(char *log, log_flags flags) { assert (log); @@ -106,9 +59,10 @@ arla_loginit(char *log) if (arla_log_method == NULL) errx (1, "arla_loginit: log_opened failed with log `%s'", log); arla_log_unit = log_unit_init (arla_log_method, "arla", arla_deb_units, - DEFAULT_LOG); + ARLA_DEFAULT_LOG); if (arla_log_unit == NULL) errx (1, "arla_loginit: log_unit_init failed"); + log_setflags (arla_log_method, flags); } int @@ -136,12 +90,6 @@ arla_log_get_level_num (void) return log_get_mask (arla_log_unit); } -void -arla_log_print_levels (FILE *f) -{ - print_flags_table (arla_deb_units, f); -} - /* * */ @@ -229,3 +177,41 @@ arla_vwarnx (unsigned level, const char *fmt, va_list args) { log_vlog (arla_log_unit, level, fmt, args); } + +void +arla_warnx_with_fid (unsigned level, const VenusFid *fid, const char *fmt, ...) +{ + va_list args; + + va_start (args, fmt); + arla_vwarnx_with_fid (level, fid, fmt, args); + va_end(args); +} + +void +arla_vwarnx_with_fid (unsigned level, const VenusFid *fid, const char *fmt, + va_list args) +{ + char *s; + const char *cellname; + char volname[VLDB_MAXNAMELEN]; + + cellname = cell_num2name (fid->Cell); + if (cellname == NULL) + cellname = "<unknown>"; + if (volcache_getname (fid->fid.Volume, fid->Cell, + volname, sizeof(volname)) != 0) + strlcpy(volname, "<unknown>", sizeof(volname)); + + vasprintf (&s, fmt, args); + if (s == NULL) { + log_log (arla_log_unit, level, + "Sorry, no memory to print `%s'...", fmt); + return; + } + log_log (arla_log_unit, level, + "volume %s (%ld) in cell %s (%ld): %s", + volname, (unsigned long)fid->fid.Volume, cellname, + (long)fid->Cell, s); + free (s); +} diff --git a/usr.sbin/afs/src/arlad/arladeb.h b/usr.sbin/afs/src/arlad/arladeb.h index 964ace3ba26..8bb710c5f6e 100644 --- a/usr.sbin/afs/src/arlad/arladeb.h +++ b/usr.sbin/afs/src/arlad/arladeb.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +32,7 @@ */ /* - * $Id: arladeb.h,v 1.3 2000/09/11 14:40:40 art Exp $ + * $KTH: arladeb.h,v 1.24.2.1 2001/04/30 00:02:15 lha Exp $ */ #ifndef _arladeb_h @@ -51,6 +46,7 @@ extern Log_method* arla_log_method; extern Log_unit* arla_log_unit; +extern struct units arla_deb_units[]; /* masks */ #define ADEBANY 0xffffffff @@ -70,10 +66,12 @@ extern Log_unit* arla_log_unit; #define ADEBERROR 0x10000000 /* don't ignore error */ #define ADEBVLOG 0x20000000 /* venuslog output */ +#define ARLA_DEFAULT_LOG (ADEBWARN | ADEBERROR) + extern struct units arla_deb_units[]; void arla_log(unsigned level, char *fmt, ...); -void arla_loginit(char *log); +void arla_loginit(char *log, log_flags flags); int arla_log_set_level (const char *s); void arla_log_set_level_num (unsigned level); void arla_log_get_level (char *s, size_t len); diff --git a/usr.sbin/afs/src/arlad/bsd-subr.c b/usr.sbin/afs/src/arlad/bsd-subr.c index 4a28016aeae..7b0b6946005 100644 --- a/usr.sbin/afs/src/arlad/bsd-subr.c +++ b/usr.sbin/afs/src/arlad/bsd-subr.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,14 +35,16 @@ #ifdef __osf__ #define _OSF_SOURCE #define _BSD +/* Might want to define _KERNEL for osf and use KDIRSIZ */ #endif + #include "arla_local.h" -RCSID("$Id: bsd-subr.c,v 1.3 2000/09/11 14:40:40 art Exp $"); +RCSID("$KTH: bsd-subr.c,v 1.55.2.1 2001/01/29 02:02:17 lha Exp $"); #ifdef __linux__ #include <xfs/xfs_dirent.h> #else -#define XFS_DIRENT_BLOCKSIZE 1024 +#define XFS_DIRENT_BLOCKSIZE 512 #define xfs_dirent dirent #endif @@ -101,7 +98,7 @@ write_dirent(VenusFid *fid, const char *name, void *arg) #endif real->d_fileno = dentry2ino (name, fid, args->e); - strcpy (real->d_name, name); + strlcpy (real->d_name, name, sizeof(real->d_name)); args->ptr += real->d_reclen; args->off += real->d_reclen; args->last = real; @@ -109,7 +106,7 @@ write_dirent(VenusFid *fid, const char *name, void *arg) Result conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { return conv_dir_sub (e, ce, tokens, cache_handle, cache_name, @@ -126,7 +123,7 @@ conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, int dir_remove_name (FCacheEntry *e, const char *filename, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { int ret; diff --git a/usr.sbin/afs/src/arlad/cmcb.c b/usr.sbin/afs/src/arlad/cmcb.c index 10600487f58..2c5a3373d91 100644 --- a/usr.sbin/afs/src/arlad/cmcb.c +++ b/usr.sbin/afs/src/arlad/cmcb.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -41,7 +36,7 @@ */ #include "arla_local.h" -RCSID("$Id: cmcb.c,v 1.3 2000/09/11 14:40:40 art Exp $") ; +RCSID("$KTH: cmcb.c,v 1.29 2000/11/28 01:50:44 lha Exp $") ; #include "cb.ss.h" @@ -93,13 +88,13 @@ RXAFSCB_InitCallBackState (struct rx_call *a_rxCallP) u_long host = rx_HostOf (rx_PeerOf (rx_ConnectionOf (a_rxCallP))); struct in_addr in_addr; - cm_check_usedbytes_consistency(); + cm_check_consistency(); in_addr.s_addr = host; arla_warnx (ADEBCALLBACK, "InitCallBackState (%s)", inet_ntoa(in_addr)); fcache_purge_host (host); - cm_check_usedbytes_consistency(); + cm_check_consistency(); return 0; } @@ -150,7 +145,7 @@ RXAFSCB_CallBack (struct rx_call *a_rxCallP, else fcache_stale_entry (fid, broken_callback); } - cm_check_usedbytes_consistency(); + cm_check_consistency(); return 0; } diff --git a/usr.sbin/afs/src/arlad/cmcb.h b/usr.sbin/afs/src/arlad/cmcb.h index 3a0a4e55379..367ebaf0564 100644 --- a/usr.sbin/afs/src/arlad/cmcb.h +++ b/usr.sbin/afs/src/arlad/cmcb.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: cmcb.h,v 1.2 2000/09/11 14:40:40 art Exp $ */ +/* $KTH: cmcb.h,v 1.3 2000/10/02 22:30:54 lha Exp $ */ #ifndef _CMCB_H_ #define _CMCB_H_ diff --git a/usr.sbin/afs/src/arlad/conn.c b/usr.sbin/afs/src/arlad/conn.c index 6340e7c1b8e..0b8a8ecae10 100644 --- a/usr.sbin/afs/src/arlad/conn.c +++ b/usr.sbin/afs/src/arlad/conn.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995-2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -43,7 +38,7 @@ #include "arla_local.h" #ifdef RCSID -RCSID("$Id: conn.c,v 1.3 2000/09/11 14:40:41 art Exp $") ; +RCSID("$KTH: conn.c,v 1.61.2.3 2001/09/03 22:12:07 ahltorp Exp $") ; #endif #define CONNCACHESIZE 101 @@ -111,7 +106,10 @@ re_probe (ConnCacheEntry *e) listdel (connprobelist, e->probe_le); gettimeofday (&tv, NULL); - e->probe_next = tv.tv_sec + (1 << e->ntries); + if (e->probe_le) + e->probe_next = min(tv.tv_sec + (1 << e->ntries), e->probe_next); + else + e->probe_next = tv.tv_sec + (1 << e->ntries); ++e->ntries; for (item = listhead (connprobelist); @@ -284,7 +282,8 @@ recycle_conn (ConnCacheEntry *e) listdel (connprobelist, e->probe_le); e->probe_le = NULL; } - hashtabdel (connhtab, e); + if (!e->flags.killme) + hashtabdel (connhtab, e); rx_DestroyConnection (e->connection); memset (e, 0, sizeof(*e)); listaddhead (connfreelist, e); @@ -700,6 +699,7 @@ conn_status (void) } struct clear_state { + clear_state_mask mask; int32_t cell; xfs_pag_t cred; int securityindex; @@ -711,26 +711,33 @@ clear_cred (void *ptr, void *arg) ConnCacheEntry *e = (ConnCacheEntry *)ptr; struct clear_state *s = (struct clear_state *)arg; - if (e->cred == s->cred - && (s->cell == 0 || e->cell == s->cell) - && e->securityindex == s->securityindex) { - if (e->refcount > 0) - e->flags.killme = 1; - else - recycle_conn (e); - } + if ((s->mask & CONN_CS_CRED) && s->cred != e->cred) + return FALSE; + if ((s->mask & CONN_CS_CELL) && s->cell != e->cell) + return FALSE; + if ((s->mask & CONN_CS_SECIDX) && s->securityindex != e->securityindex) + return FALSE; + + if (e->refcount > 0) { + e->flags.killme = 1; + hashtabdel (connhtab, e); + } else + recycle_conn (e); + return FALSE; } /* - * Remove all connections matching (cell, cred, securityindex). + * Remove all connections matching mask + (cell, cred, securityindex). */ void -conn_clearcred(int32_t cell, xfs_pag_t cred, int securityindex) +conn_clearcred(clear_state_mask mask, + int32_t cell, xfs_pag_t cred, int securityindex) { struct clear_state s; + s.mask = mask; s.cell = cell; s.cred = cred; s.securityindex = securityindex; @@ -820,3 +827,35 @@ conn_rtt_cmp (const void *v1, const void *v2) return (*e1)->rtt - (*e2)->rtt; } + +/* + * Return true iff this error means we should mark the host as down + * due to network errors + */ + +Bool +host_downp (int error) +{ + switch (error) { + case ARLA_CALL_DEAD : + case ARLA_INVALID_OPERATION : + case ARLA_CALL_TIMEOUT : + case ARLA_EOF : + case ARLA_PROTOCOL_ERROR : + case ARLA_USER_ABORT : + case ARLA_ADDRINUSE : + case ARLA_MSGSIZE : + case RXGEN_CC_MARSHAL : + case RXGEN_CC_UNMARSHAL : + case RXGEN_SS_MARSHAL : + case RXGEN_SS_UNMARSHAL : + case RXGEN_DECODE : + case RXGEN_OPCODE : + case RXGEN_SS_XDRFREE : + case RXGEN_CC_XDRFREE : + return TRUE; + default : + return FALSE; + } +} + diff --git a/usr.sbin/afs/src/arlad/conn.h b/usr.sbin/afs/src/arlad/conn.h index f0a0d75e07b..dbe13504ccb 100644 --- a/usr.sbin/afs/src/arlad/conn.h +++ b/usr.sbin/afs/src/arlad/conn.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ * Header for connection cache */ -/* $Id: conn.h,v 1.3 2000/09/11 14:40:41 art Exp $ */ +/* $KTH: conn.h,v 1.24.2.2 2001/09/28 00:59:11 mattiasa Exp $ */ #ifndef _CONN_H_ #define _CONN_H_ @@ -73,6 +68,14 @@ struct conncacheentry { typedef struct conncacheentry ConnCacheEntry; +typedef enum { CONN_CS_NONE = 0, + CONN_CS_CELL = 1, + CONN_CS_CRED = 2, + CONN_CS_SECIDX = 4, + CONN_CS_ALL = 0xffff + +} clear_state_mask; + extern int conn_rxkad_level; void @@ -105,7 +108,8 @@ void conn_status (void); void -conn_clearcred (int32_t cell, xfs_pag_t cred, int securityindex); +conn_clearcred (clear_state_mask mask, + int32_t cell, xfs_pag_t cred, int securityindex); void conn_downhosts(int32_t cell, u_int32_t *hosts, int *num, int flags); @@ -113,11 +117,14 @@ conn_downhosts(int32_t cell, u_int32_t *hosts, int *num, int flags); int conn_rtt_cmp (const void *v1, const void *v2); +Bool +host_downp (int error); + /* * Random factor to add to rtts when comparing them. - * This is in milliseconds/8 + * This is in microseconds/8 */ -static const int RTT_FUZZ = 400; +static const int RTT_FUZZ = 400000; #endif /* _CONN_H_ */ diff --git a/usr.sbin/afs/src/arlad/cred.c b/usr.sbin/afs/src/arlad/cred.c index 6187e26b18c..85030964a25 100644 --- a/usr.sbin/afs/src/arlad/cred.c +++ b/usr.sbin/afs/src/arlad/cred.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -41,7 +36,7 @@ */ #include "arla_local.h" -RCSID("$Id: cred.c,v 1.3 2000/09/11 14:40:41 art Exp $"); +RCSID("$KTH: cred.c,v 1.33.2.2 2001/04/21 14:55:34 lha Exp $"); #define CREDCACHESIZE 101 @@ -163,7 +158,8 @@ cred_get (long cell, xfs_pag_t cred, int type) static void recycle_entry (CredCacheEntry *ce) { - hashtabdel (credhtab, ce); + if (!ce->flags.killme) + hashtabdel (credhtab, ce); if (ce->cred_data != NULL) free (ce->cred_data); memset (ce, 0, sizeof(*ce)); @@ -266,9 +262,10 @@ cred_add_krb4 (xfs_pag_t cred, uid_t uid, CREDENTIALS *c) void cred_delete (CredCacheEntry *ce) { - if (ce->refcount > 0) + if (ce->refcount > 0) { ce->flags.killme = 1; - else + hashtabdel (credhtab, ce); + } else recycle_entry (ce); } @@ -280,22 +277,15 @@ void cred_expire (CredCacheEntry *ce) { const char *cell_name = cell_num2name (ce->cell); - struct passwd *pwd = getpwuid (ce->uid); - const char *user_name; - - if (pwd != NULL) - user_name = pwd->pw_name; - else - user_name = "<who-are-you?>"; if (cell_name != NULL) arla_warnx (ADEBWARN, - "Credentials for %s (%u) in cell %s has expired", - user_name, (unsigned)ce->uid, cell_name); + "Credentials for UID %u in cell %s has expired", + (unsigned)ce->uid, cell_name); else arla_warnx (ADEBWARN, - "Credentials for %s (%u) in cell unknown %ld has expired", - user_name, (unsigned)ce->uid, ce->cell); + "Credentials for UID %u in cell unknown %ld has expired", + (unsigned)ce->uid, ce->cell); cred_delete (ce); } diff --git a/usr.sbin/afs/src/arlad/cred.h b/usr.sbin/afs/src/arlad/cred.h index 1ac0653d671..f05a3033727 100644 --- a/usr.sbin/afs/src/arlad/cred.h +++ b/usr.sbin/afs/src/arlad/cred.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ * Header for credetial cache */ -/* $Id: cred.h,v 1.3 2000/09/11 14:40:41 art Exp $ */ +/* $KTH: cred.h,v 1.26 2000/10/02 22:31:15 lha Exp $ */ #ifndef _CRED_H_ #define _CRED_H_ diff --git a/usr.sbin/afs/src/arlad/darla.c b/usr.sbin/afs/src/arlad/darla.c index 4a5abf12779..0c41eef72d1 100644 --- a/usr.sbin/afs/src/arlad/darla.c +++ b/usr.sbin/afs/src/arlad/darla.c @@ -29,7 +29,7 @@ #include "arla_local.h" -RCSID("$Id: darla.c,v 1.2 2000/09/11 14:40:41 art Exp $"); +RCSID("$KTH: darla.c,v 1.6 2000/02/12 19:23:54 assar Exp $"); int DARLA_Open(DARLA_file *Dfp, char *fname, int oflag) { diff --git a/usr.sbin/afs/src/arlad/darla.h b/usr.sbin/afs/src/arlad/darla.h index abc0c6c61ac..c95eb730f4e 100644 --- a/usr.sbin/afs/src/arlad/darla.h +++ b/usr.sbin/afs/src/arlad/darla.h @@ -27,7 +27,7 @@ * SUCH DAMAGES. */ -/* $Id: darla.h,v 1.2 2000/09/11 14:40:41 art Exp $ */ +/* $KTH: darla.h,v 1.3 1998/12/21 21:54:03 assar Exp $ */ #ifndef _DARLA_H #define _DARLA_H diff --git a/usr.sbin/afs/src/arlad/discon_log.c b/usr.sbin/afs/src/arlad/discon_log.c index 63b09157fb8..9b3d713a51d 100644 --- a/usr.sbin/afs/src/arlad/discon_log.c +++ b/usr.sbin/afs/src/arlad/discon_log.c @@ -34,7 +34,7 @@ #include "arla_local.h" -RCSID("$Id: discon_log.c,v 1.2 2000/09/11 14:40:41 art Exp $"); +RCSID("$KTH: discon_log.c,v 1.8.40.1 2001/06/04 22:16:35 ahltorp Exp $"); extern int dlog_mod; extern long current_op_no; @@ -50,6 +50,7 @@ int DARLA_Read(DARLA_file *Dfp, char *cp, int len); int DARLA_Write(DARLA_file *Dfp, char *cp, int len); int DARLA_Seek(DARLA_file *Dfp, int offset, int whence); +#if 0 /* * read an entry from the log file described by tfile. The result is * put into the log_ent data. This return 0 if successful, 1 if @@ -75,7 +76,6 @@ read_log_ent(DARLA_file * tfile, log_ent_t *in_log) return 0; } -#if 0 void update_log_ent(offset, flags) long offset; @@ -113,7 +113,7 @@ int flags; /* write the log entries to disk */ -long +static long write_log_ent(int len, log_ent_t *log) { @@ -244,6 +244,7 @@ log_dis_create(struct vcache *parent, struct vcache *child, char *name) return op_no; } +#if 0 long log_dis_remove(struct vcache *avc, FCacheEntry *childentry, char *name) { @@ -389,7 +390,7 @@ log_dis_symlink(struct vcache *pvc, struct vcache *cvc, free(slink); return op_no; } - +#endif /* Log a setattr operation */ long @@ -426,6 +427,7 @@ log_dis_setattr(struct vcache *tvc, struct xfs_attr *attrs) return op_no; } +#if 0 long log_dis_nonmutating(struct vcache *tvc, log_ops_t op) { @@ -477,3 +479,4 @@ log_dis_fsync(struct vcache *tvc) /* treat an fsync as a store */ return log_dis_nonmutating(tvc, DIS_FSYNC); } +#endif diff --git a/usr.sbin/afs/src/arlad/dynroot.c b/usr.sbin/afs/src/arlad/dynroot.c index 826a360ae0d..8d2ce16c91b 100644 --- a/usr.sbin/afs/src/arlad/dynroot.c +++ b/usr.sbin/afs/src/arlad/dynroot.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -44,7 +39,7 @@ #include <arla_local.h> -RCSID("$Id: dynroot.c,v 1.2 2002/04/25 22:55:40 espie Exp $"); +RCSID("$KTH: dynroot.c,v 1.13.2.2 2001/05/28 15:19:20 map Exp $"); struct create_entry { fbuf *thedir; /* pointer to the fbuf that contains the dir */ @@ -87,6 +82,9 @@ create_entry_func (const cell_entry *cell, void *arg) struct create_entry *entry = (struct create_entry *) arg; int ret; + if (!cell_dynroot(cell)) + return 0; + entry->fid.Vnode = cellnum2afs (cell->id); ret = fdir_creat (entry->thedir, cell->name, entry->fid); @@ -167,7 +165,7 @@ Bool dynroot_isvolumep (int cell, const char *volume) { assert (volume); - + if (cell == 0 && strcmp (volume, "1") == 0) return TRUE; @@ -197,9 +195,11 @@ dynroot_fetch_vldbN (nvldbentry *entry) */ static void -dynroot_update_entry (FCacheEntry *entry, int32_t filetype) +dynroot_update_entry (FCacheEntry *entry, int32_t filetype, + xfs_pag_t cred) { struct timeval tv; + AccessEntry *ae; assert (entry); entry->status.InterfaceVersion = 1; @@ -209,10 +209,16 @@ dynroot_update_entry (FCacheEntry *entry, int32_t filetype) entry->status.Owner = 0; entry->status.CallerAccess = ALIST | AREAD; entry->status.AnonymousAccess = ALIST | AREAD; - entry->status.UnixModeBits = - S_IRUSR|S_IXUSR| - S_IRGRP|S_IXGRP| - S_IROTH|S_IXOTH; + switch (filetype) { + case TYPE_DIR: + entry->status.UnixModeBits = 0755; + break; + case TYPE_LINK: + entry->status.UnixModeBits = 0644; + break; + default: + abort(); + } entry->status.ParentVnode = DYNROOT_ROOTDIR; entry->status.ParentUnique = DYNROOT_UNIQUE; entry->status.SegSize = 64*1024; @@ -235,7 +241,9 @@ dynroot_update_entry (FCacheEntry *entry, int32_t filetype) entry->anonaccess = entry->status.AnonymousAccess; - /* XXX CallerAccess */ + findaccess(cred, entry->acccache, &ae); + ae->cred = cred; + ae->access = entry->status.CallerAccess; } /* @@ -243,7 +251,7 @@ dynroot_update_entry (FCacheEntry *entry, int32_t filetype) */ static int -dynroot_get_node (FCacheEntry *entry) +dynroot_get_node (FCacheEntry *entry, CredCacheEntry *ce) { int ret, fd, rootnode; size_t len; @@ -272,6 +280,7 @@ dynroot_get_node (FCacheEntry *entry) } else { ret = dynroot_create_symlink (&dir, entry->fid.fid.Vnode); entry->status.LinkCount = 1; + fcache_mark_as_mountpoint (entry); } if (ret) { @@ -288,7 +297,8 @@ dynroot_get_node (FCacheEntry *entry) if (ret) return ret; - dynroot_update_entry (entry, rootnode ? TYPE_DIR : TYPE_LINK); + dynroot_update_entry (entry, rootnode ? TYPE_DIR : TYPE_LINK, + ce->cred); entry->flags.attrp = TRUE; entry->flags.datap = TRUE; @@ -303,9 +313,9 @@ dynroot_get_node (FCacheEntry *entry) */ int -dynroot_get_attr (FCacheEntry *entry) +dynroot_get_attr (FCacheEntry *entry, CredCacheEntry *ce) { - return dynroot_get_node (entry); + return dynroot_get_node (entry, ce); } @@ -314,9 +324,9 @@ dynroot_get_attr (FCacheEntry *entry) */ int -dynroot_get_data (FCacheEntry *entry) +dynroot_get_data (FCacheEntry *entry, CredCacheEntry *ce) { - return dynroot_get_node (entry); + return dynroot_get_node (entry, ce); } /* diff --git a/usr.sbin/afs/src/arlad/dynroot.h b/usr.sbin/afs/src/arlad/dynroot.h index ee875c928a6..28d9b6445a5 100644 --- a/usr.sbin/afs/src/arlad/dynroot.h +++ b/usr.sbin/afs/src/arlad/dynroot.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +32,7 @@ */ /* - * $Id: dynroot.h,v 1.1 2000/09/11 14:40:41 art Exp $ + * $KTH: dynroot.h,v 1.2.2.1 2001/05/28 15:19:20 map Exp $ */ #define DYNROOT_DEFAULT 0 @@ -46,9 +41,9 @@ int dynroot_fetch_vldbN (nvldbentry *entry); Bool dynroot_isvolumep (int cell, const char *volume); -int dynroot_get_attr (FCacheEntry *entry); +int dynroot_get_attr (FCacheEntry *entry, CredCacheEntry *ce); -int dynroot_get_data (FCacheEntry *entry); +int dynroot_get_data (FCacheEntry *entry, CredCacheEntry *ce); Bool dynroot_is_dynrootp (FCacheEntry *entry); diff --git a/usr.sbin/afs/src/arlad/fcache.c b/usr.sbin/afs/src/arlad/fcache.c index 596d9c4c84e..66ff6c4ff95 100644 --- a/usr.sbin/afs/src/arlad/fcache.c +++ b/usr.sbin/afs/src/arlad/fcache.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -42,7 +37,7 @@ */ #include "arla_local.h" -RCSID("$Id: fcache.c,v 1.3 2000/09/11 14:40:42 art Exp $") ; +RCSID("$KTH: fcache.c,v 1.311.2.20 2001/12/20 16:36:24 mattiasa Exp $") ; /* * Prototypes @@ -153,6 +148,12 @@ fcache_usedbytes(void) } u_long +fcache_lowbytes(void) +{ + return lowbytes; +} + +u_long fcache_highvnodes(void) { return highvnodes; @@ -164,6 +165,266 @@ fcache_usedvnodes(void) return usedvnodes; } +u_long +fcache_lowvnodes(void) +{ + return lowvnodes; +} + +#define HISTOGRAM_SLOTS 32 +#define STATHASHSIZE 997 + +/* Struct with collected statistics */ +struct collect_stat{ + int64_t starttime; +}; + +struct time_statistics { + u_int32_t measure_type; + u_int32_t host; + u_int32_t partition; + u_int32_t measure_items; /* normed by get_histgram_slots */ + u_int32_t count[HISTOGRAM_SLOTS]; + int64_t measure_items_total[HISTOGRAM_SLOTS]; + int64_t elapsed_time[HISTOGRAM_SLOTS]; +}; + +static unsigned +statistics_hash (void *p) +{ + struct time_statistics *stats = (struct time_statistics*)p; + + return stats->measure_type + stats->host + + stats->partition * 32 * 32 + stats->measure_items * 32; +} + +/* + * Compare two entries. Return 0 if and only if the same. + */ + +static int +statistics_cmp (void *a, void *b) +{ + struct time_statistics *f1 = (struct time_statistics*)a; + struct time_statistics *f2 = (struct time_statistics*)b; + + return f1->measure_type != f2->measure_type + || f1->host != f2->host + || f1->partition != f2->partition + || f1->measure_items != f2->measure_items; +} + +static Hashtab *statistics; + +static int +get_histogram_slot(u_int32_t value) +{ + int i; + + for (i = HISTOGRAM_SLOTS - 1; i > 0; i--) { + if (value >> i) + return i; + } + return 0; +} + +static void +add_time_statistics(u_int32_t measure_type, u_int32_t host, + u_int32_t partition, u_int32_t measure_items, + int64_t elapsed_time) +{ + u_int32_t time_slot; + struct time_statistics *ts; + struct time_statistics *ts2; + + ts = malloc(sizeof(*ts)); + + time_slot = get_histogram_slot(elapsed_time); + ts->measure_type = measure_type; + ts->measure_items = get_histogram_slot(measure_items); + ts->host = host; + ts->partition = partition; + ts2 = hashtabsearch (statistics, (void*)(ts)); + if (ts2) { + ts2->count[time_slot]++; + ts2->elapsed_time[time_slot] += elapsed_time; + ts2->measure_items_total[time_slot] += measure_items; + free(ts); + } else { + memset(ts->count, 0, sizeof(ts->count)); + memset(ts->measure_items_total, 0, sizeof(ts->measure_items_total)); + memset(ts->elapsed_time, 0, sizeof(ts->elapsed_time)); + ts->count[time_slot]++; + ts->elapsed_time[time_slot] += elapsed_time; + ts->measure_items_total[time_slot] += measure_items; + hashtabadd(statistics, ts); + } + + time_slot = get_histogram_slot(elapsed_time); +} + +static void +collectstats_init (void) +{ + statistics = hashtabnew (STATHASHSIZE, statistics_cmp, statistics_hash); + + if (statistics == NULL) + arla_err(1, ADEBINIT, errno, "collectstats_init: cannot malloc"); +} + +static void +collectstats_start (struct collect_stat *p) +{ + struct timeval starttime; + + gettimeofday(&starttime, NULL); + p->starttime = starttime.tv_sec * 1000000LL + starttime.tv_usec; +} + +static void +collectstats_stop (struct collect_stat *p, + FCacheEntry *entry, + ConnCacheEntry *conn, + int measure_type, int measure_items) +{ + u_int32_t host = conn->host; + long partition = -1; + int volumetype; + struct nvldbentry vldbentry; + struct timeval stoptime; + int64_t elapsed_time; + int i; + + gettimeofday(&stoptime, NULL); + + volumetype = volcache_volid2bit (entry->volume, entry->fid.fid.Volume); + vldbentry = entry->volume->entry; + + for (i = 0; i < min(NMAXNSERVERS, vldbentry.nServers); ++i) { + if (host == htonl(vldbentry.serverNumber[i]) && + vldbentry.serverFlags[i] & volumetype) { + partition = vldbentry.serverPartition[i]; + } + } + assert(partition != -1); + elapsed_time = stoptime.tv_sec * 1000000LL + stoptime.tv_usec; + elapsed_time -= p->starttime; + add_time_statistics(measure_type, host, partition, + measure_items, elapsed_time); +} + +struct hostpart { + u_int32_t host; + u_int32_t part; +}; + +static unsigned +hostpart_hash (void *p) +{ + struct hostpart *h = (struct hostpart*)p; + + return h->host * 256 + h->part; +} + +static int +hostpart_cmp (void *a, void *b) +{ + struct hostpart *h1 = (struct hostpart*)a; + struct hostpart *h2 = (struct hostpart*)b; + + return h1->host != h2->host || + h1->part != h2->part; +} + +static Bool +hostpart_addhash (void *ptr, void *arg) +{ + Hashtab *hostparthash = (Hashtab *) arg; + struct time_statistics *s = (struct time_statistics *) ptr; + struct hostpart *h; + + h = malloc(sizeof(*h)); + h->host = s->host; + h->part = s->partition; + + hashtabadd(hostparthash, h); + return FALSE; +} + +struct hostpart_collect_args { + u_int32_t *host; + u_int32_t *part; + int *i; + int max; +}; + +static Bool +hostpart_collect (void *ptr, void *arg) +{ + struct hostpart_collect_args *collect_args = + (struct hostpart_collect_args *) arg; + struct hostpart *h = (struct hostpart *) ptr; + + if (*collect_args->i >= collect_args->max) + return TRUE; + + collect_args->host[*collect_args->i] = h->host; + collect_args->part[*collect_args->i] = h->part; + (*collect_args->i)++; + + return FALSE; +} + +int +collectstats_hostpart(u_int32_t *host, u_int32_t *part, int *n) +{ + Hashtab *hostparthash; + int i; + struct hostpart_collect_args collect_args; + + hostparthash = hashtabnew (100, hostpart_cmp, hostpart_hash); + + hashtabforeach(statistics, hostpart_addhash, hostparthash); + + i = 0; + collect_args.host = host; + collect_args.part = part; + collect_args.i = &i; + collect_args.max = *n; + hashtabforeach(hostparthash, hostpart_collect, &collect_args); + *n = i; + + hashtabrelease(hostparthash); + + return 0; +} + +int +collectstats_getentry(u_int32_t host, u_int32_t part, u_int32_t type, + u_int32_t items_slot, u_int32_t *count, + int64_t *items_total, int64_t *total_time) +{ + struct time_statistics ts; + struct time_statistics *ts2; + + ts.measure_type = type; + ts.measure_items = items_slot; + ts.host = host; + ts.partition = part; + ts2 = hashtabsearch (statistics, (void*)(&ts)); + if (ts2 == NULL) { + memset(count, 0, 4 * 32); + memset(items_total, 0, 8 * 32); + memset(total_time, 0, 8 * 32); + } else { + memcpy(count, ts2->count, 4 * 32); + memcpy(items_total, ts2->measure_items_total, 8 * 32); + memcpy(total_time, ts2->elapsed_time, 8 * 32); + } + + return 0; +} + /* * Counters */ @@ -297,14 +558,19 @@ static int fhopen_working; */ static int -fcache_fhopen (xfs_cache_handle *handle, int flags) +fcache_fhopen (fcache_cache_handle *handle, int flags) { + if (!handle->valid) { + errno = EINVAL; + return -1; + } + #if defined(HAVE_GETFH) && defined(HAVE_FHOPEN) { int ret; fhandle_t fh; - memcpy (&fh, handle, sizeof(fh)); + memcpy (&fh, &handle->xfs_handle, sizeof(fh)); ret = fhopen (&fh, flags); if (ret >= 0) return ret; @@ -315,8 +581,8 @@ fcache_fhopen (xfs_cache_handle *handle, int flags) { struct ViceIoctl vice_ioctl; - vice_ioctl.in = (caddr_t)handle; - vice_ioctl.in_size = sizeof(*handle); + vice_ioctl.in = (caddr_t)&handle->xfs_handle; + vice_ioctl.in_size = sizeof(handle->xfs_handle); vice_ioctl.out = NULL; vice_ioctl.out_size = 0; @@ -334,16 +600,19 @@ fcache_fhopen (xfs_cache_handle *handle, int flags) */ int -fcache_fhget (char *filename, xfs_cache_handle *handle) +fcache_fhget (char *filename, fcache_cache_handle *handle) { + handle->valid = 0; #if defined(HAVE_GETFH) && defined(HAVE_FHOPEN) { int ret; fhandle_t fh; ret = getfh (filename, &fh); - if (ret == 0) - memcpy (handle, &fh, sizeof(fh)); + if (ret == 0) { + memcpy (&handle->xfs_handle, &fh, sizeof(fh)); + handle->valid = 1; + } return ret; } @@ -351,6 +620,7 @@ fcache_fhget (char *filename, xfs_cache_handle *handle) #ifdef KERBEROS { struct ViceIoctl vice_ioctl; + int ret; if (!fhopen_working) return 0; @@ -358,10 +628,14 @@ fcache_fhget (char *filename, xfs_cache_handle *handle) vice_ioctl.in = NULL; vice_ioctl.in_size = 0; - vice_ioctl.out = (caddr_t)handle; - vice_ioctl.out_size = sizeof(*handle); + vice_ioctl.out = (caddr_t)&handle->xfs_handle; + vice_ioctl.out_size = sizeof(handle->xfs_handle); - return k_pioctl (filename, VIOC_FHGET, &vice_ioctl, 0); + ret = k_pioctl (filename, VIOC_FHGET, &vice_ioctl, 0); + if (ret == 0) + handle->valid = 1; + + return ret; } #else errno = EINVAL; @@ -453,8 +727,8 @@ throw_data (FCacheEntry *entry) int fd; struct stat sb; - assert (entry->flags.datap && entry->flags.usedp - && CheckLock(&entry->lock) == -1); + assert (entry->flags.datap && entry->flags.usedp); + AssertExclLocked(&entry->lock); fd = fcache_open_file (entry, O_WRONLY); if (fd < 0) { @@ -488,7 +762,7 @@ throw_data (FCacheEntry *entry) entry->flags.extradirp = FALSE; out: - cm_check_usedbytes_consistency(); + cm_check_consistency(); } /* @@ -516,8 +790,8 @@ throw_entry (FCacheEntry *entry) AFSCBs cbs; int ret; - assert (entry->flags.usedp - && CheckLock(&entry->lock) == -1); + assert (entry->flags.usedp); + AssertExclLocked(&entry->lock); hashtabdel (hashtab, entry); @@ -582,7 +856,7 @@ create_nodes (char *arg) while (1) { unsigned int n, i, j; - if (highvnodes <= current_vnodes) + while (highvnodes <= current_vnodes) LWP_WaitProcess (create_nodes); n = highvnodes - current_vnodes; @@ -693,11 +967,13 @@ cleaner (char *arg) && CheckLock(&entry->lock) == 0) { if (!entry->flags.datausedp + && CheckLock(&entry->lock) == 0 /* && this_is_a_good_node_to_gc(entry,state) */) { - listdel (lrulist, item); ObtainWriteLock (&entry->lock); + listdel (lrulist, item); throw_entry (entry); entry->lru_le = listaddtail (lrulist, entry); + assert(entry->lru_le); ReleaseWriteLock (&entry->lock); break; } @@ -759,7 +1035,7 @@ cleaner (char *arg) usedbytes, lowbytes, highbytes, needbytes); - cm_check_usedbytes_consistency(); + cm_check_consistency(); if (needbytes) LWP_NoYieldSignal (fcache_need_bytes); cleaner_working = FALSE; @@ -935,7 +1211,7 @@ find_free_entry (void) if (entry == NULL) arla_warnx (ADEBWARN, "All vnode entries in use"); else { - assert (CheckLock(&entry->lock) == -1); + AssertExclLocked(&entry->lock); ++usedvnodes; } return entry; @@ -953,6 +1229,11 @@ fcache_store_state (void) unsigned n; u_int32_t u1, u2; + if (lrulist == NULL) { + arla_warnx (ADEBFCACHE, "store_state: lrulist is NULL"); + return 0; + } + fd = open ("fcache.new", O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); if (fd < 0) return errno; @@ -1084,6 +1365,7 @@ fcache_recover_state (void) e->hits = 0; e->cleanergen = 0; e->lru_le = listaddhead (lrulist, e); + assert(e->lru_le); e->volume = vol; hashtabadd (hashtab, e); if (e->flags.datap) @@ -1177,6 +1459,8 @@ find_first_fs (FCacheEntry *e, int cell = e->fid.Cell; int ret; + memset(context, 0, sizeof(*context)); + if (ve == NULL) { int type; @@ -1204,7 +1488,8 @@ find_first_fs (FCacheEntry *e, u_long addr = htonl(ve->entry.serverNumber[i]); if (ve->entry.serverFlags[i] & bit - && addr != 0) { + && addr != 0 + && (ve->entry.serverFlags[i] & VLSF_DONTUSE) == 0) { ConnCacheEntry *conn; conn = conn_get (cell, addr, afsport, @@ -1248,6 +1533,7 @@ fcache_init (u_long alowvnodes, #else fhopen_working = 0; #endif + collectstats_init (); node_count = 1; /* XXX */ lowvnodes = alowvnodes; @@ -1289,7 +1575,9 @@ fcache_init (u_long alowvnodes, } /* - * + * set new values for those of lowvnodes, highvnodes, lowbytes, highbytes + * that are not zero. + * return 0 or an error code */ int @@ -1299,16 +1587,13 @@ fcache_reinit(u_long alowvnodes, u_long ahighbytes) { arla_warnx (ADEBFCACHE, "fcache_reinit"); - - if (ahighvnodes < highvnodes) - return EINVAL; - if (ahighvnodes > highvnodes) { - return EINVAL; - highvnodes = ahighvnodes; - LWP_NoYieldSignal (create_nodes); - - abort(); /* XXX resize heap */ + if (ahighvnodes != 0) { + if (ahighvnodes > highvnodes) { + highvnodes = ahighvnodes; + LWP_NoYieldSignal (create_nodes); + } else + highvnodes = ahighvnodes; } if (alowvnodes != 0) @@ -1342,6 +1627,7 @@ find_entry_nolock (VenusFid fid) if (e != NULL) { listdel (lrulist, e->lru_le); e->lru_le = listaddhead (lrulist, e); + assert(e->lru_le); } return e; } @@ -1382,15 +1668,6 @@ stale (FCacheEntry *e, AFSCallBack callback) e->tokens = 0; if (e->flags.kernelp) break_callback (e); -#if 0 - if (e->flags.datap) - throw_data (e); -#endif -#if 0 - e->flags.attrp = FALSE; -#endif - e->flags.attrusedp = FALSE; - e->flags.datausedp = FALSE; ReleaseWriteLock (&e->lock); } } @@ -1472,7 +1749,7 @@ purge_cred (void *ptr, void *arg) ae[i].cred = ARLA_NO_AUTH_CRED; ae[i].access = ANONE; if (e->flags.kernelp) - install_attr (e); + install_attr (e, FCACHE2XFSNODE_RIGHT); break; } } @@ -1601,6 +1878,22 @@ mountpointp (FCacheEntry *entry) } /* + * Mark `entry' as mountpoint or a fake mountpoint depending on + * fake_mp is used or not. + */ + +void +fcache_mark_as_mountpoint (FCacheEntry *entry) +{ + if (fake_mp) { + entry->flags.fake_mp = TRUE; + fake_mp_status (entry); + } else { + entry->flags.mountp = TRUE; + } +} + +/* * Update all the relevant parts of `entry' after having received new * data from the file server. */ @@ -1640,14 +1933,8 @@ update_entry (FCacheEntry *entry, findaccess (cred, entry->acccache, &ae); ae->cred = cred; ae->access = status->CallerAccess; - if (!entry->flags.mountp && mountpointp (entry)) { - if (fake_mp) { - entry->flags.fake_mp = TRUE; - fake_mp_status (entry); - } else { - entry->flags.mountp = TRUE; - } - } + if (!entry->flags.mountp && mountpointp (entry)) + fcache_mark_as_mountpoint (entry); } /* @@ -1789,18 +2076,29 @@ fcache_reobtain_callbacks (void) */ static Bool -try_next_fs (int error) +try_next_fs (int error, const VenusFid *fid) { switch (error) { - case RX_CALL_DEAD : + case RXKADUNKNOWNKEY: + case ARLA_CALL_DEAD : + case ARLA_INVALID_OPERATION : + case ARLA_CALL_TIMEOUT : + case ARLA_EOF : + case ARLA_PROTOCOL_ERROR : + case ARLA_USER_ABORT : + case ARLA_ADDRINUSE : + case ARLA_MSGSIZE : case ARLA_VSALVAGE : case ARLA_VNOSERVICE : case ARLA_VOFFLINE : case ARLA_VBUSY : case ARLA_VIO : - case ARLA_VNOVOL : return TRUE; + case ARLA_VNOVOL : case ARLA_VMOVED : + if (fid && !volcache_reliable (fid->fid.Volume, fid->Cell)) + volcache_invalidate (fid->fid.Volume, fid->Cell); + return TRUE; case 0 : return FALSE; default : @@ -1808,30 +2106,6 @@ try_next_fs (int error) } } - -/* - * Return true iff this error means we should mark the fs as down - */ - -static Bool -fs_downp (int error) -{ - switch (error) { - case RX_CALL_DEAD : - case RXGEN_CC_MARSHAL : - case RXGEN_CC_UNMARSHAL : - case RXGEN_SS_MARSHAL : - case RXGEN_SS_UNMARSHAL : - case RXGEN_DECODE : - case RXGEN_OPCODE : - case RXGEN_SS_XDRFREE : - case RXGEN_CC_XDRFREE : - return TRUE; - default : - return FALSE; - } -} - /* * Fetch the attributes for the file in `entry' from the file_server, * using the credentials in `ce' and returning the connection in @@ -1849,13 +2123,14 @@ do_read_attr (FCacheEntry *entry, ConnCacheEntry **ret_conn, fs_server_context *ret_context) { - int ret = RX_CALL_DEAD; + int ret = ARLA_CALL_DEAD; ConnCacheEntry *conn; AFSFetchStatus status; AFSCallBack callback; AFSVolSync volsync; + struct collect_stat collectstat; - assert (CheckLock(&entry->lock) == -1); + AssertExclLocked(&entry->lock); *ret_conn = NULL; @@ -1868,19 +2143,22 @@ do_read_attr (FCacheEntry *entry, for (conn = find_first_fs (entry, ce, ret_context); conn != NULL; - conn = find_next_fs (ret_context, conn, fs_downp (ret))) { + conn = find_next_fs (ret_context, conn, host_downp (ret))) { + collectstats_start(&collectstat); ret = RXAFS_FetchStatus (conn->connection, &entry->fid.fid, &status, &callback, &volsync); - - if (!try_next_fs (ret)) + collectstats_stop(&collectstat, entry, conn, + STATISTICS_REQTYPE_FETCHSTATUS, 1); + arla_warnx (ADEBFCACHE, "trying to fetch status: %d", ret); + if (!try_next_fs (ret, &entry->fid)) break; } if (ret) { - if (ret == RX_CALL_DEAD) + if (host_downp(ret)) ret = ENETDOWN; arla_warn (ADEBFCACHE, ret, "fetch-status"); free_fs_server_context (ret_context); @@ -1893,7 +2171,7 @@ do_read_attr (FCacheEntry *entry, rx_HostOf (rx_PeerOf (conn->connection)), ce->cred); - assert (CheckLock(&entry->lock) == -1); + AssertExclLocked(&entry->lock); *ret_conn = conn; return 0; @@ -1912,7 +2190,7 @@ read_attr (FCacheEntry *entry, CredCacheEntry *ce) ConnCacheEntry *conn; fs_server_context context; - assert (CheckLock(&entry->lock) == -1); + AssertExclLocked(&entry->lock); init_fs_server_context (&context); ret = do_read_attr (entry, ce, &conn, &context); @@ -1936,10 +2214,11 @@ read_data (FCacheEntry *entry, ConnCacheEntry *conn, CredCacheEntry *ce) AFSFetchStatus status; AFSCallBack callback; AFSVolSync volsync; + struct collect_stat collectstat; arla_warnx (ADEBMISC, "read_data"); - assert (CheckLock(&entry->lock) == -1); + AssertExclLocked(&entry->lock); if (connected_mode == DISCONNECTED) { ret = ENETDOWN; @@ -1966,6 +2245,7 @@ read_data (FCacheEntry *entry, ConnCacheEntry *conn, CredCacheEntry *ce) goto out; } + collectstats_start(&collectstat); ret = StartRXAFS_FetchData (call, &entry->fid.fid, 0, entry->status.Length); if(ret) { @@ -1982,8 +2262,6 @@ read_data (FCacheEntry *entry, ConnCacheEntry *conn, CredCacheEntry *ce) } sizefs = ntohl (sizefs); - assert (sizefs == entry->status.Length); - fd = fcache_open_file (entry, O_RDWR); if (fd < 0) { ret = errno; @@ -2016,6 +2294,8 @@ read_data (FCacheEntry *entry, ConnCacheEntry *conn, CredCacheEntry *ce) arla_warn (ADEBFCACHE, ret, "rx_EndCall"); goto out; } + collectstats_stop(&collectstat, entry, conn, + STATISTICS_REQTYPE_FETCHDATA, sizefs); fcache_counter.fetch_data++; @@ -2029,7 +2309,7 @@ read_data (FCacheEntry *entry, ConnCacheEntry *conn, CredCacheEntry *ce) entry->tokens |= XFS_DATA_R | XFS_DATA_W | XFS_OPEN_NR | XFS_OPEN_NW; out: - assert (CheckLock(&entry->lock) == -1); + AssertExclLocked(&entry->lock); return ret; } @@ -2044,7 +2324,7 @@ write_data (FCacheEntry *entry, AFSStoreStatus *storestatus, { ConnCacheEntry *conn; struct rx_call *call; - int ret = RX_CALL_DEAD; + int ret = ARLA_CALL_DEAD; u_int32_t sizefs; int fd; struct stat statinfo; @@ -2052,7 +2332,7 @@ write_data (FCacheEntry *entry, AFSStoreStatus *storestatus, AFSVolSync volsync; fs_server_context context; - assert (CheckLock(&entry->lock) == -1); + AssertExclLocked(&entry->lock); /* Don't write data to deleted files */ if (entry->flags.silly) @@ -2084,7 +2364,7 @@ write_data (FCacheEntry *entry, AFSStoreStatus *storestatus, for (conn = find_first_fs (entry, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { call = rx_NewCall (conn->connection); if (call == NULL) { @@ -2098,7 +2378,7 @@ write_data (FCacheEntry *entry, AFSStoreStatus *storestatus, 0, sizefs, sizefs); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { rx_EndCall(call, ret); continue; } else if (ret) { @@ -2144,10 +2424,10 @@ write_data (FCacheEntry *entry, AFSStoreStatus *storestatus, entry->flags.datap = FALSE; } } - if (ret == RX_CALL_DEAD) + if (host_downp(ret)) ret = ENETDOWN; free_fs_server_context (&context); - assert (CheckLock(&entry->lock) == -1); + AssertExclLocked(&entry->lock); close (fd); return ret; } @@ -2161,15 +2441,14 @@ truncate_file (FCacheEntry *entry, off_t size, CredCacheEntry *ce) { ConnCacheEntry *conn; struct rx_call *call; - int ret = RX_CALL_DEAD; + int ret = ARLA_CALL_DEAD; AFSStoreStatus storestatus; - u_int32_t sizefs; int fd; AFSFetchStatus status; AFSVolSync volsync; fs_server_context context; - assert (CheckLock(&entry->lock) == -1); + AssertExclLocked(&entry->lock); fd = fcache_open_file (entry, O_RDWR); if (fd < 0) { @@ -2196,9 +2475,10 @@ truncate_file (FCacheEntry *entry, off_t size, CredCacheEntry *ce) if (connected_mode != CONNECTED) return 0; + ret = ENETDOWN; for (conn = find_first_fs (entry, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { call = rx_NewCall (conn->connection); if (call == NULL) { @@ -2214,7 +2494,7 @@ truncate_file (FCacheEntry *entry, off_t size, CredCacheEntry *ce) size, 0, size); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { rx_EndCall(call, ret); continue; } else if(ret) { @@ -2223,28 +2503,21 @@ truncate_file (FCacheEntry *entry, off_t size, CredCacheEntry *ce) break; } - sizefs = htonl (0); - if (rx_Write (call, &sizefs, sizeof(sizefs)) != sizeof(sizefs)) { - ret = conv_to_arla_errno(rx_Error(call)); - arla_warn (ADEBFCACHE, ret, "writing length"); - rx_EndCall(call, 0); - break; - } ret = EndRXAFS_StoreData (call, &status, &volsync); - if (ret) { - rx_EndCall (call, ret); - arla_warnx (ADEBFCACHE, "EndRXAFS_StoreData"); - break; - } + if (ret) { + rx_EndCall (call, ret); + arla_warnx (ADEBFCACHE, "EndRXAFS_StoreData"); + break; + } - ret = rx_EndCall (call, 0); - if (ret) { - arla_warn (ADEBFCACHE, ret, "rx_EndCall"); - } - break; + ret = rx_EndCall (call, 0); + if (ret) { + arla_warn (ADEBFCACHE, ret, "rx_EndCall"); + } + break; } if (ret == 0) { @@ -2252,13 +2525,11 @@ truncate_file (FCacheEntry *entry, off_t size, CredCacheEntry *ce) update_entry (entry, &status, NULL, &volsync, rx_HostOf(rx_PeerOf(conn->connection)), ce->cred); - - assert (entry->status.Length == size); } - if (ret == RX_CALL_DEAD) + if (host_downp(ret)) ret = ENETDOWN; free_fs_server_context (&context); - assert (CheckLock(&entry->lock) == -1); + AssertExclLocked(&entry->lock); return ret; } @@ -2271,11 +2542,11 @@ write_attr (FCacheEntry *entry, const AFSStoreStatus *store_status, CredCacheEntry *ce) { - int ret = RX_CALL_DEAD; + int ret = ARLA_CALL_DEAD; AFSFetchStatus status; AFSVolSync volsync; - assert (CheckLock(&entry->lock) == -1); + AssertExclLocked(&entry->lock); /* Don't write attributes to deleted files */ if (entry->flags.silly) @@ -2288,7 +2559,7 @@ write_attr (FCacheEntry *entry, for (conn = find_first_fs (entry, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { host = rx_HostOf (rx_PeerOf (conn->connection)); @@ -2297,7 +2568,7 @@ write_attr (FCacheEntry *entry, store_status, &status, &volsync); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { continue; } else if (ret) { arla_warn (ADEBFCACHE, ret, "store-status"); @@ -2308,7 +2579,7 @@ write_attr (FCacheEntry *entry, } free_fs_server_context (&context); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { ret = ENETDOWN; goto out; } @@ -2331,7 +2602,7 @@ write_attr (FCacheEntry *entry, } out: - assert (CheckLock(&entry->lock) == -1); + AssertExclLocked(&entry->lock); return ret; } @@ -2346,7 +2617,7 @@ create_file (FCacheEntry *dir_entry, VenusFid *child_fid, AFSFetchStatus *fetch_attr, CredCacheEntry *ce) { - int ret = RX_CALL_DEAD; + int ret = ARLA_CALL_DEAD; AFSFid OutFid; FCacheEntry *child_entry; AFSFetchStatus status; @@ -2355,7 +2626,7 @@ create_file (FCacheEntry *dir_entry, int fd; u_int32_t host; - assert (CheckLock(&dir_entry->lock) == -1); + AssertExclLocked(&dir_entry->lock); if (connected_mode == CONNECTED) { ConnCacheEntry *conn; @@ -2363,7 +2634,7 @@ create_file (FCacheEntry *dir_entry, for (conn = find_first_fs (dir_entry, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { host = rx_HostOf (rx_PeerOf (conn->connection)); @@ -2376,7 +2647,7 @@ create_file (FCacheEntry *dir_entry, &status, &callback, &volsync); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { continue; } else if (ret) { free_fs_server_context (&context); @@ -2387,7 +2658,7 @@ create_file (FCacheEntry *dir_entry, } free_fs_server_context (&context); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { ret = ENETDOWN; goto out; } @@ -2467,7 +2738,7 @@ create_file (FCacheEntry *dir_entry, fcache_release(child_entry); out: - assert (CheckLock(&dir_entry->lock) == -1); + AssertExclLocked(&dir_entry->lock); return ret; } @@ -2482,7 +2753,7 @@ create_directory (FCacheEntry *dir_entry, VenusFid *child_fid, AFSFetchStatus *fetch_attr, CredCacheEntry *ce) { - int ret = RX_CALL_DEAD; + int ret = ARLA_CALL_DEAD; AFSFid OutFid; FCacheEntry *child_entry; AFSFetchStatus status; @@ -2490,7 +2761,7 @@ create_directory (FCacheEntry *dir_entry, AFSVolSync volsync; u_int32_t host; - assert (CheckLock(&dir_entry->lock) == -1); + AssertExclLocked(&dir_entry->lock); if (connected_mode == CONNECTED) { ConnCacheEntry *conn; @@ -2498,7 +2769,7 @@ create_directory (FCacheEntry *dir_entry, for (conn = find_first_fs (dir_entry, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { host = rx_HostOf(rx_PeerOf(conn->connection)); @@ -2512,7 +2783,7 @@ create_directory (FCacheEntry *dir_entry, &callback, &volsync); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { continue; } else if (ret) { free_fs_server_context (&context); @@ -2523,7 +2794,7 @@ create_directory (FCacheEntry *dir_entry, } free_fs_server_context (&context); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { ret = ENETDOWN; goto out; } @@ -2594,7 +2865,7 @@ create_directory (FCacheEntry *dir_entry, fcache_release(child_entry); out: - assert (CheckLock(&dir_entry->lock) == -1); + AssertExclLocked(&dir_entry->lock); return ret; } @@ -2612,7 +2883,7 @@ create_symlink (FCacheEntry *dir_entry, const char *contents, CredCacheEntry *ce) { - int ret = RX_CALL_DEAD; + int ret = ARLA_CALL_DEAD; ConnCacheEntry *conn; AFSFid OutFid; FCacheEntry *child_entry; @@ -2621,14 +2892,14 @@ create_symlink (FCacheEntry *dir_entry, u_int32_t host; fs_server_context context; - assert (CheckLock(&dir_entry->lock) == -1); + AssertExclLocked(&dir_entry->lock); if (connected_mode != CONNECTED) return EINVAL; for (conn = find_first_fs (dir_entry, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { host = rx_HostOf(rx_PeerOf(conn->connection)); @@ -2641,7 +2912,7 @@ create_symlink (FCacheEntry *dir_entry, fetch_attr, &new_status, &volsync); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { continue; } else if (ret) { arla_warn (ADEBFCACHE, ret, "Symlink"); @@ -2652,7 +2923,7 @@ create_symlink (FCacheEntry *dir_entry, } free_fs_server_context (&context); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { ret = ENETDOWN; goto out; } @@ -2684,7 +2955,7 @@ create_symlink (FCacheEntry *dir_entry, fcache_release(child_entry); out: - assert (CheckLock(&dir_entry->lock) == -1); + AssertExclLocked(&dir_entry->lock); return ret; } @@ -2706,14 +2977,14 @@ create_link (FCacheEntry *dir_entry, u_int32_t host; fs_server_context context; - assert (CheckLock(&dir_entry->lock) == -1); + AssertExclLocked(&dir_entry->lock); if (connected_mode != CONNECTED) return EINVAL; for (conn = find_first_fs (dir_entry, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { host = rx_HostOf(rx_PeerOf(conn->connection)); @@ -2724,7 +2995,7 @@ create_link (FCacheEntry *dir_entry, &new_status, &status, &volsync); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { continue; } else if (ret) { free_fs_server_context (&context); @@ -2735,7 +3006,7 @@ create_link (FCacheEntry *dir_entry, } free_fs_server_context (&context); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { ret = ENETDOWN; goto out; } @@ -2747,7 +3018,7 @@ create_link (FCacheEntry *dir_entry, host, ce->cred); out: - assert (CheckLock(&dir_entry->lock) == -1); + AssertExclLocked(&dir_entry->lock); return ret; } @@ -2758,21 +3029,21 @@ out: int remove_file (FCacheEntry *dir_entry, const char *name, CredCacheEntry *ce) { - int ret = RX_CALL_DEAD; + int ret = ARLA_CALL_DEAD; ConnCacheEntry *conn; AFSFetchStatus status; AFSVolSync volsync; u_int32_t host; fs_server_context context; - assert (CheckLock(&dir_entry->lock) == -1); + AssertExclLocked(&dir_entry->lock); if (connected_mode != CONNECTED) return EINVAL; for (conn = find_first_fs (dir_entry, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { host = rx_HostOf(rx_PeerOf(conn->connection)); @@ -2781,7 +3052,7 @@ remove_file (FCacheEntry *dir_entry, const char *name, CredCacheEntry *ce) name, &status, &volsync); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { continue; } else if (ret) { free_fs_server_context (&context); @@ -2792,7 +3063,7 @@ remove_file (FCacheEntry *dir_entry, const char *name, CredCacheEntry *ce) } free_fs_server_context (&context); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { ret = ENETDOWN; goto out; } @@ -2801,7 +3072,7 @@ remove_file (FCacheEntry *dir_entry, const char *name, CredCacheEntry *ce) host, ce->cred); out: - assert (CheckLock(&dir_entry->lock) == -1); + AssertExclLocked(&dir_entry->lock); return ret; } @@ -2814,21 +3085,21 @@ remove_directory (FCacheEntry *dir_entry, const char *name, CredCacheEntry *ce) { - int ret = RX_CALL_DEAD; + int ret = ARLA_CALL_DEAD; ConnCacheEntry *conn; AFSFetchStatus status; AFSVolSync volsync; u_int32_t host; fs_server_context context; - assert (CheckLock(&dir_entry->lock) == -1); + AssertExclLocked(&dir_entry->lock); if (connected_mode != CONNECTED) return EINVAL; for (conn = find_first_fs (dir_entry, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { host = rx_HostOf(rx_PeerOf(conn->connection)); @@ -2837,7 +3108,7 @@ remove_directory (FCacheEntry *dir_entry, name, &status, &volsync); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { continue; } else if (ret) { free_fs_server_context (&context); @@ -2848,7 +3119,7 @@ remove_directory (FCacheEntry *dir_entry, } free_fs_server_context (&context); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { ret = ENETDOWN; goto out; } @@ -2857,7 +3128,7 @@ remove_directory (FCacheEntry *dir_entry, host, ce->cred); out: - assert (CheckLock(&dir_entry->lock) == -1); + AssertExclLocked(&dir_entry->lock); return ret; } @@ -2872,22 +3143,22 @@ rename_file (FCacheEntry *old_dir, const char *new_name, CredCacheEntry *ce) { - int ret = RX_CALL_DEAD; + int ret = ARLA_CALL_DEAD; ConnCacheEntry *conn; AFSFetchStatus orig_status, new_status; AFSVolSync volsync; u_int32_t host; fs_server_context context; - assert (CheckLock(&old_dir->lock) == -1 - && CheckLock(&new_dir->lock) == -1); + AssertExclLocked(&old_dir->lock); + AssertExclLocked(&new_dir->lock); if (connected_mode != CONNECTED) return EINVAL; for (conn = find_first_fs (old_dir, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { host = rx_HostOf(rx_PeerOf(conn->connection)); @@ -2899,7 +3170,7 @@ rename_file (FCacheEntry *old_dir, &orig_status, &new_status, &volsync); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { continue; } else if (ret) { free_fs_server_context (&context); @@ -2910,7 +3181,7 @@ rename_file (FCacheEntry *old_dir, } free_fs_server_context (&context); - if (ret == RX_CALL_DEAD) { + if (host_downp(ret)) { ret = ENETDOWN; goto out; } @@ -2922,8 +3193,8 @@ rename_file (FCacheEntry *old_dir, host, ce->cred); out: - assert (CheckLock(&old_dir->lock) == -1 - && CheckLock(&new_dir->lock) == -1); + AssertExclLocked(&old_dir->lock); + AssertExclLocked(&new_dir->lock); return ret; } @@ -3029,7 +3300,7 @@ fcache_get (FCacheEntry **res, VenusFid fid, CredCacheEntry *ce) { FCacheEntry *old; FCacheEntry *e; - int type; + int type, i; int error; *res = NULL; @@ -3046,10 +3317,11 @@ fcache_get (FCacheEntry **res, VenusFid fid, CredCacheEntry *ce) old = find_entry (fid); if (old) { - assert (CheckLock(&e->lock) == -1); + AssertExclLocked(&e->lock); ReleaseWriteLock (&e->lock); e->lru_le = listaddtail (lrulist, e); + assert(e->lru_le); assert (old->flags.usedp); *res = old; @@ -3063,7 +3335,10 @@ fcache_get (FCacheEntry **res, VenusFid fid, CredCacheEntry *ce) memset (&e->status, 0, sizeof(e->status)); memset (&e->callback, 0, sizeof(e->callback)); memset (&e->volsync, 0, sizeof(e->volsync)); - memset (e->acccache, 0, sizeof(e->acccache)); + for (i = 0; i < NACCESS; i++) { + e->acccache[i].cred = ARLA_NO_AUTH_CRED; + e->acccache[i].access = 0; + } e->anonaccess = 0; e->flags.usedp = TRUE; e->flags.datap = FALSE; @@ -3080,6 +3355,7 @@ fcache_get (FCacheEntry **res, VenusFid fid, CredCacheEntry *ce) e->tokens = 0; memset (&e->parent, 0, sizeof(e->parent)); e->lru_le = listaddhead (lrulist, e); + assert(e->lru_le); e->invalid_ptr = -1; e->volume = NULL; e->priority = fprio_get(fid); @@ -3112,7 +3388,7 @@ fcache_get (FCacheEntry **res, VenusFid fid, CredCacheEntry *ce) void fcache_release (FCacheEntry *e) { - assert (CheckLock (&e->lock) == -1); + AssertExclLocked(&e->lock); ReleaseWriteLock (&e->lock); @@ -3263,12 +3539,18 @@ get_attr_bulk (FCacheEntry *parent_entry, AFSCBs cbs; int i; int len; + u_int32_t host; arla_warnx (ADEBFCACHE, "get_attr_bulk"); if (fcache_enable_bulkstatus == 0) return -1; + if (!parent_entry->flags.datap) { + arla_warnx (ADEBFCACHE, "get_attr_bulk: parent doesn't have data"); + return -1; + } + fids.val = bs.fids; memset (bs.names, 0, sizeof(bs.names)); @@ -3341,11 +3623,11 @@ get_attr_bulk (FCacheEntry *parent_entry, goto out_names; } - ret = RX_CALL_DEAD; + ret = ARLA_CALL_DEAD; for (conn = find_first_fs (parent_entry, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { stats.val = NULL; cbs.val = NULL; @@ -3356,10 +3638,12 @@ get_attr_bulk (FCacheEntry *parent_entry, free (stats.val); free (cbs.val); } - if (!try_next_fs (ret)) + if (!try_next_fs (ret, &parent_entry->fid)) break; } + if (conn != NULL) + host = rx_HostOf (rx_PeerOf (conn->connection)); free_fs_server_context (&context); if (ret) { @@ -3377,28 +3661,34 @@ get_attr_bulk (FCacheEntry *parent_entry, if (ret == 0) { FCacheEntry *e; - VenusFid fid; fcache_counter.fetch_attr_bulk += len; - fid.Cell = parent_entry->fid.Cell; for (i = 0; i < len && ret == 0; i++) { if (prefered_entry && i == 0) { e = prefered_entry; - ret = 0; } else { + VenusFid fid; + + fid.Cell = parent_entry->fid.Cell; + fid.fid = fids.val[i]; + + e = find_entry_nolock (fid); + if (e != NULL && CheckLock(&e->lock) != 0) + continue; + ret = fcache_get (&e, fid, ce); + if (ret) + break; } - if (ret) - break; update_attr_entry (e, &stats.val[i], &cbs.val[i], &sync, - rx_HostOf (rx_PeerOf (conn->connection)), + host, ce->cred); e->parent = parent_entry->fid; - if (!(prefered_entry && i == 0)) { + if (prefered_entry != e) { fcache_release(e); } } @@ -3425,6 +3715,10 @@ get_attr_bulk (FCacheEntry *parent_entry, e = prefered_entry; ret = 0; } else { + e = find_entry_nolock (fid); + if (e != NULL && CheckLock(&e->lock) != 0) + continue; + ret = fcache_get (&e, fid, ce); } if (ret == 0) { @@ -3469,7 +3763,8 @@ get_attr_bulk (FCacheEntry *parent_entry, &e->fid, &stats.val[i], node, - parent_entry->acccache); + parent_entry->acccache, + FCACHE2XFSNODE_ALL); if (parent) *parent = *(struct xfs_handle*) &parent_entry->fid; @@ -3528,7 +3823,7 @@ fcache_verify_attr (FCacheEntry *entry, FCacheEntry *parent_entry, int error; if (dynroot_is_dynrootp (entry)) - return dynroot_get_attr (entry); + return dynroot_get_attr (entry, ce); if (entry->flags.usedp && entry->flags.attrp @@ -3617,7 +3912,7 @@ fcache_verify_attr (FCacheEntry *entry, FCacheEntry *parent_entry, static int do_read_data (FCacheEntry *e, CredCacheEntry *ce) { - int ret = RX_CALL_DEAD; + int ret = ARLA_CALL_DEAD; fs_server_context context; ConnCacheEntry *conn; @@ -3626,14 +3921,14 @@ do_read_data (FCacheEntry *e, CredCacheEntry *ce) for (conn = find_first_fs (e, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { ret = read_data (e, conn, ce); - if (!try_next_fs (ret)) + if (!try_next_fs (ret, &e->fid)) break; } free_fs_server_context (&context); - if (ret == RX_CALL_DEAD) + if (host_downp(ret)) ret = ENETDOWN; return ret; } @@ -3650,10 +3945,10 @@ fcache_verify_data (FCacheEntry *e, CredCacheEntry *ce) fs_server_context context; assert (e->flags.usedp); - assert (CheckLock(&e->lock) == -1); + AssertExclLocked(&e->lock); if (dynroot_is_dynrootp (e)) - return dynroot_get_data (e); + return dynroot_get_data (e, ce); /* Don't get data for deleted files */ if (e->flags.silly) @@ -3722,7 +4017,7 @@ fcache_get_data (FCacheEntry **res, VenusFid *fid, CredCacheEntry **ce) fcache_release (e); *fid = new_fid; e = new_root; - install_attr (e); + install_attr (e, FCACHE2XFSNODE_ALL); } ret = fcache_verify_data (e, *ce); @@ -3838,7 +4133,9 @@ find_volume (const char *volname, int32_t cell, /* * Set `fid' to point to the root of the volume pointed to by the * mount-point in (buf, len). - * If succesful, ` + * + * If succesful, `fid' will be update to the root of the volume, and + * `ce' will point to a cred in the new cell. */ static int @@ -3870,9 +4167,7 @@ get_root_of_volume (VenusFid *fid, const VenusFid *parent, if ((*ce)->cell != cell) { CredCacheEntry *new_ce; - new_ce = cred_get (cell, (*ce)->cred, (*ce)->type); - if (new_ce == NULL) - new_ce = cred_get(cell, (*ce)->cred, CRED_ANY); + new_ce = cred_get(cell, (*ce)->cred, CRED_ANY); if (new_ce == NULL) return ENOMEM; cred_free (*ce); @@ -3896,6 +4191,15 @@ get_root_of_volume (VenusFid *fid, const VenusFid *parent, fid->fid.Volume = volid; fid->fid.Vnode = fid->fid.Unique = 1; + /* + * Check if we are looking up ourself, if we are, just return. + */ + + if (VenusFid_cmp(fid, parent) == 0) { + volcache_free (ve); + return 0; + } + res = fcache_get (&e, *fid, *ce); if (res) { volcache_free (ve); @@ -3908,10 +4212,12 @@ get_root_of_volume (VenusFid *fid, const VenusFid *parent, * properly. */ - e->flags.vol_root = TRUE; - e->parent = *parent; - ve->parent_fid = *parent; - ve->mp_fid = oldfid; + e->flags.vol_root = TRUE; + e->parent = *parent; + if (ve->parent == NULL) { + ve->parent_fid = *parent; + ve->mp_fid = oldfid; + } volcache_volref (ve, volume); fcache_release (e); volcache_free (ve); @@ -3933,7 +4239,8 @@ get_root_of_volume (VenusFid *fid, const VenusFid *parent, */ int -followmountpoint (VenusFid *fid, const VenusFid *parent, CredCacheEntry **ce) +followmountpoint (VenusFid *fid, const VenusFid *parent, FCacheEntry *parent_e, + CredCacheEntry **ce) { FCacheEntry *e; int ret; @@ -3948,7 +4255,7 @@ followmountpoint (VenusFid *fid, const VenusFid *parent, CredCacheEntry **ce) if (ret) return ret; - ret = fcache_verify_attr (e, NULL, NULL, *ce); + ret = fcache_verify_attr (e, parent_e, NULL, *ce); if (ret) { fcache_release(e); return ret; @@ -3977,7 +4284,7 @@ resolve_mp (FCacheEntry *e, VenusFid *ret_fid, CredCacheEntry **ce) u_int32_t length; assert (e->flags.fake_mp || e->flags.mountp); - assert (CheckLock(&e->lock) == -1); + AssertExclLocked(&e->lock); ret = fcache_verify_data (e, *ce); if (ret) @@ -4057,20 +4364,9 @@ fcache_status (void) void fcache_update_length (FCacheEntry *e, size_t len) { - int fd; - struct stat sb; - - fd = fcache_open_file (e, O_RDONLY); - if (fd < 0) - arla_err (1, ADEBERROR, errno, "fcache_open_file"); - - if (fstat (fd, &sb) < 0) - arla_err (1, ADEBERROR, errno, "fstat"); - close(fd); + AssertExclLocked(&e->lock); - assert (len == sb.st_size); - - assert (usedbytes + len >= e->length); + assert (len >= e->length || e->length - len <= usedbytes); usedbytes = usedbytes - e->length + len; e->length = len; @@ -4092,6 +4388,9 @@ getacl(VenusFid fid, int ret; fs_server_context context; + opaque->val = NULL; + opaque->len = 0; + if (connected_mode != CONNECTED) return EINVAL; @@ -4101,14 +4400,21 @@ getacl(VenusFid fid, return ret; } - ret = RX_CALL_DEAD; + ret = ARLA_CALL_DEAD; for (conn = find_first_fs (dire, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { + ret = RXAFS_FetchACL (conn->connection, &fid.fid, opaque, &status, &volsync); - if (!try_next_fs (ret)) + if (ret) { + free(opaque->val); + opaque->val = NULL; + opaque->len = 0; + } + + if (!try_next_fs (ret, &fid)) break; } if (ret) @@ -4118,7 +4424,7 @@ getacl(VenusFid fid, update_entry (dire, &status, NULL, &volsync, rx_HostOf(rx_PeerOf(conn->connection)), ce->cred); - else if (ret == RX_CALL_DEAD) + else if (host_downp(ret)) ret = ENETDOWN; free_fs_server_context (&context); @@ -4155,14 +4461,14 @@ setacl(VenusFid fid, return EINVAL; } - ret = RX_CALL_DEAD; + ret = ARLA_CALL_DEAD; for (conn = find_first_fs (dire, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { ret = RXAFS_StoreACL (conn->connection, &fid.fid, opaque, &status, &volsync); - if (!try_next_fs (ret)) + if (!try_next_fs (ret, &fid)) break; } if (ret) @@ -4172,7 +4478,7 @@ setacl(VenusFid fid, update_entry (dire, &status, NULL, &volsync, rx_HostOf(rx_PeerOf(conn->connection)), ce->cred); - else if (ret == RX_CALL_DEAD) + else if (host_downp(ret)) ret = ENETDOWN; free_fs_server_context (&context); @@ -4211,27 +4517,25 @@ getvolstat(VenusFid fid, CredCacheEntry *ce, return EINVAL; } - ret = RX_CALL_DEAD; + ret = ARLA_CALL_DEAD; for (conn = find_first_fs (dire, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { ret = RXAFS_GetVolumeStatus (conn->connection, fid.fid.Volume, volstat, volumename, offlinemsg, motd); - if (!try_next_fs (ret)) + if (!try_next_fs (ret, &fid)) break; } if (ret) arla_warn (ADEBFCACHE, ret, "GetVolumeStatus"); free_fs_server_context (&context); - if (ret == RX_CALL_DEAD) + if (host_downp(ret)) ret = ENETDOWN; - if (ret == 0 && volumename[0] == '\0') { - const char *tmp = volcache_getname (fid.fid.Volume, fid.Cell); - if (tmp != NULL) - strlcpy (volumename, tmp, AFSNAMEMAX); - } + if (ret == 0 && volumename[0] == '\0') + volcache_getname (fid.fid.Volume, fid.Cell, + volumename, sizeof(volumename)); fcache_release (dire); return ret; @@ -4262,19 +4566,19 @@ setvolstat(VenusFid fid, CredCacheEntry *ce, return EINVAL; } - ret = RX_CALL_DEAD; + ret = ARLA_CALL_DEAD; for (conn = find_first_fs (dire, ce, &context); conn != NULL; - conn = find_next_fs (&context, conn, fs_downp (ret))) { + conn = find_next_fs (&context, conn, host_downp (ret))) { ret = RXAFS_SetVolumeStatus (conn->connection, fid.fid.Volume, volstat, volumename, offlinemsg, motd); - if (!try_next_fs (ret)) + if (!try_next_fs (ret, &fid)) break; } if (ret) { - if (ret == RX_CALL_DEAD) + if (host_downp(ret)) ret = ENETDOWN; arla_warn (ADEBFCACHE, ret, "SetVolumeStatus"); } @@ -4299,7 +4603,7 @@ fcache_get_fbuf (FCacheEntry *centry, int *fd, fbuf *fbuf, unsigned len; struct stat sb; - assert (CheckLock (¢ry->lock) == -1); + AssertExclLocked(¢ry->lock); *fd = fcache_open_file (centry, open_flags); if (*fd < 0) diff --git a/usr.sbin/afs/src/arlad/fcache.h b/usr.sbin/afs/src/arlad/fcache.h index ec877897511..61b55a05214 100644 --- a/usr.sbin/afs/src/arlad/fcache.h +++ b/usr.sbin/afs/src/arlad/fcache.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ * The interface for the file-cache. */ -/* $Id: fcache.h,v 1.3 2000/09/11 14:40:42 art Exp $ */ +/* $KTH: fcache.h,v 1.72.2.2 2001/10/02 16:13:07 jimmy Exp $ */ #ifndef _FCACHE_H_ #define _FCACHE_H_ @@ -74,6 +69,11 @@ enum Access { ANONE = 0x0, AADMIN = 0x40 }; typedef struct { + Bool valid; + xfs_cache_handle xfs_handle; +} fcache_cache_handle; + +typedef struct { struct Lock lock; /* locking information for this entry */ VenusFid fid; /* The fid of the file for this entry */ unsigned refcount; /* reference count */ @@ -85,7 +85,7 @@ typedef struct { AccessEntry acccache[NACCESS]; /* cache for the access rights */ u_int32_t anonaccess; /* the access mask for system:anyuser */ unsigned index; /* this is V%u */ - xfs_cache_handle handle; /* handle */ + fcache_cache_handle handle; /* handle */ struct { unsigned usedp : 1; /* Is this entry used? */ unsigned attrp : 1; /* Are the attributes in status valid? */ @@ -186,7 +186,7 @@ int fcache_open_extra_dir (FCacheEntry *entry, int flag, mode_t mode); int -fcache_fhget (char *filename, xfs_cache_handle *handle); +fcache_fhget (char *filename, fcache_cache_handle *handle); int write_data (FCacheEntry *entry, AFSStoreStatus *status, CredCacheEntry *ce); @@ -259,7 +259,8 @@ int fcache_verify_data (FCacheEntry *e, CredCacheEntry *ce); int -followmountpoint (VenusFid *fid, const VenusFid *parent, CredCacheEntry **ce); +followmountpoint (VenusFid *fid, const VenusFid *parent, FCacheEntry *parent_e, + CredCacheEntry **ce); void fcache_status (void); @@ -296,11 +297,17 @@ u_long fcache_usedbytes(void); u_long +fcache_lowbytes(void); + +u_long fcache_highvnodes(void); u_long fcache_usedvnodes(void); +u_long +fcache_lowvnodes(void); + int fcache_need_bytes(u_long needed); @@ -355,4 +362,15 @@ fcache_calculate_usage (void); const VenusFid * fcache_realfid (const FCacheEntry *entry); +void +fcache_mark_as_mountpoint (FCacheEntry *entry); + +int +collectstats_hostpart(u_int32_t *host, u_int32_t *part, int *n); + +int +collectstats_getentry(u_int32_t host, u_int32_t part, u_int32_t type, + u_int32_t items_slot, u_int32_t *count, + int64_t *items_total, int64_t *total_time); + #endif /* _FCACHE_H_ */ diff --git a/usr.sbin/afs/src/arlad/fprio.c b/usr.sbin/afs/src/arlad/fprio.c index b33d006e023..b24b36104df 100644 --- a/usr.sbin/afs/src/arlad/fprio.c +++ b/usr.sbin/afs/src/arlad/fprio.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -42,7 +37,7 @@ #include "arla_local.h" #include <kafs.h> -RCSID("$Id: fprio.c,v 1.3 2000/09/11 14:40:42 art Exp $"); +RCSID("$KTH: fprio.c,v 1.9 2000/10/02 22:31:43 lha Exp $"); /* Hashtable of entries by name */ static Hashtab *fpriohashtab; diff --git a/usr.sbin/afs/src/arlad/fprio.h b/usr.sbin/afs/src/arlad/fprio.h index a722ce4ecd2..b2b297efafa 100644 --- a/usr.sbin/afs/src/arlad/fprio.h +++ b/usr.sbin/afs/src/arlad/fprio.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ * Our cache of volume information. */ -/* $Id: fprio.h,v 1.3 2000/09/11 14:40:42 art Exp $ */ +/* $KTH: fprio.h,v 1.6 2000/10/02 22:31:48 lha Exp $ */ #ifndef _FPRIO_ #define _FPRIO_ diff --git a/usr.sbin/afs/src/arlad/fs_errors.h b/usr.sbin/afs/src/arlad/fs_errors.h index c20447b01c7..2955f118a63 100644 --- a/usr.sbin/afs/src/arlad/fs_errors.h +++ b/usr.sbin/afs/src/arlad/fs_errors.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,11 +31,13 @@ * SUCH DAMAGE. */ -/* $Id: fs_errors.h,v 1.2 2000/09/11 14:40:42 art Exp $ */ +/* $KTH: fs_errors.h,v 1.10 2000/11/26 21:54:19 lha Exp $ */ #ifndef _FS_ERRORS_H_ #define _FS_ERRORS_H_ 1 +#include <rx/rx.h> + #define VICE_SPECIAL_ERRORS 101 #define VICE_SPECIAL_ERRORS_MIN 101 @@ -61,8 +58,9 @@ #define VRESTARTING -100 -#define ARLA_SPECIAL_ERROR_ADD 4000 -#define ARLA_SPECIAL2_ERROR_ADD 4600 +#define ARLA_SPECIAL_ERROR_ADD 4000 +#define ARLA_SPECIAL2_ERROR_ADD 4600 +#define ARLA_SPECIAL_RX_ERROR_ADD 4800 /* ->4899 */ #define ARLA_VSALVAGE (ARLA_SPECIAL_ERROR_ADD+VSALVAGE) #define ARLA_VNOVNODE (ARLA_SPECIAL_ERROR_ADD+VNOVNODE) @@ -76,8 +74,18 @@ #define ARLA_VBUSY (ARLA_SPECIAL_ERROR_ADD+VBUSY) #define ARLA_VMOVED (ARLA_SPECIAL_ERROR_ADD+VMOVED) #define ARLA_VIO (ARLA_SPECIAL_ERROR_ADD+VIO) + #define ARLA_VRESTARTING (ARLA_SPECIAL2_ERROR_ADD+VRESTARTING) +#define ARLA_CALL_DEAD (ARLA_SPECIAL_RX_ERROR_ADD-RX_CALL_DEAD) +#define ARLA_INVALID_OPERATION (ARLA_SPECIAL_RX_ERROR_ADD-RX_INVALID_OPERATION) +#define ARLA_CALL_TIMEOUT (ARLA_SPECIAL_RX_ERROR_ADD-RX_CALL_TIMEOUT) +#define ARLA_EOF (ARLA_SPECIAL_RX_ERROR_ADD-RX_EOF) +#define ARLA_PROTOCOL_ERROR (ARLA_SPECIAL_RX_ERROR_ADD-RX_PROTOCOL_ERROR) +#define ARLA_USER_ABORT (ARLA_SPECIAL_RX_ERROR_ADD-RX_USER_ABORT) +#define ARLA_ADDRINUSE (ARLA_SPECIAL_RX_ERROR_ADD-RX_ADDRINUSE) +#define ARLA_MSGSIZE (ARLA_SPECIAL_RX_ERROR_ADD-RX_MSGSIZE) + static inline int __attribute__ ((unused)) conv_to_arla_errno(int error) { @@ -86,6 +94,8 @@ conv_to_arla_errno(int error) return error + ARLA_SPECIAL_ERROR_ADD; else if (error == VRESTARTING) return ARLA_VRESTARTING; + else if (error <= RX_MIN_ERROR && error >= RX_MAX_ERROR) + return ARLA_SPECIAL_RX_ERROR_ADD - error; /* RX code are negative */ else return error; } diff --git a/usr.sbin/afs/src/arlad/hpux-subr.c b/usr.sbin/afs/src/arlad/hpux-subr.c index 874f242c4d0..b729b40f654 100644 --- a/usr.sbin/afs/src/arlad/hpux-subr.c +++ b/usr.sbin/afs/src/arlad/hpux-subr.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -39,9 +34,10 @@ /* If this isn't defined, we get a constant for DIRSIZ */ #define DIRSIZ_MACRO +#define _INCLUDE_HPUX_SOURCE #include "arla_local.h" -RCSID("$Id: hpux-subr.c,v 1.1 2000/09/11 14:40:42 art Exp $"); +RCSID("$KTH: hpux-subr.c,v 1.26 2000/10/14 19:58:07 map Exp $"); static long blocksize = 1024; /* XXX */ @@ -83,7 +79,7 @@ write_dirent(VenusFid *fid, const char *name, void *arg) /* real->d_namlen = dirent.d_namlen;*/ real->d_reclen = dirent.d_reclen; real->d_ino = dentry2ino (name, fid, args->e); - strcpy (real->d_name, name); + strlcpy (real->d_name, name, sizeof(real->d_name)); args->ptr += real->d_reclen; args->off += real->d_reclen; #if 0 @@ -94,7 +90,7 @@ write_dirent(VenusFid *fid, const char *name, void *arg) Result conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { return conv_dir_sub (e, ce, tokens, cache_handle, cache_name, @@ -106,7 +102,7 @@ conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, int dir_remove_name (FCacheEntry *e, const char *filename, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { int ret; diff --git a/usr.sbin/afs/src/arlad/inter.c b/usr.sbin/afs/src/arlad/inter.c index 98ad5354707..48731d72504 100644 --- a/usr.sbin/afs/src/arlad/inter.c +++ b/usr.sbin/afs/src/arlad/inter.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -41,11 +36,11 @@ */ #include "arla_local.h" -RCSID("$Id: inter.c,v 1.3 2000/09/11 14:40:42 art Exp $") ; +RCSID("$KTH: inter.c,v 1.110.2.3 2001/06/05 01:27:05 ahltorp Exp $") ; #include <xfs/xfs_message.h> -Bool usedbytes_consistencyp = FALSE; +Bool cm_consistencyp = FALSE; /* * Return the rights for user cred and entry e. @@ -128,7 +123,7 @@ log_operation (const char *fmt, ...) va_list args; struct timeval now; - if(connected_mode == CONNECTED && usedbytes_consistencyp == FALSE) + if(connected_mode == CONNECTED && cm_consistencyp == FALSE) return; va_start (args, fmt); @@ -150,9 +145,9 @@ log_operation (const char *fmt, ...) */ void -cm_turn_on_usedbytes_consistency(void) +cm_turn_on_consistency_check(void) { - usedbytes_consistencyp = TRUE; + cm_consistencyp = TRUE; } /* @@ -161,7 +156,7 @@ cm_turn_on_usedbytes_consistency(void) */ void -cm_check_usedbytes_consistency (void) +cm_check_consistency (void) { static unsigned int log_times = 0; static unsigned int file_times = 0; @@ -169,21 +164,21 @@ cm_check_usedbytes_consistency (void) u_long real_size; char newname[MAXPATHLEN]; - if (usedbytes_consistencyp == FALSE) + if (cm_consistencyp == FALSE) return; calc_size = fcache_calculate_usage(); real_size = fcache_usedbytes (); if (calc_size != real_size) { - log_operation ("usedbytes consistency not guaranteed " + log_operation ("consistency check not guaranteed " "(calc: %d, real: %d), aborting\n", (int) calc_size, (int) real_size); cm_store_state (); abort(); } if (log_times % 100000 == 0) { - log_operation ("usedbytes consistency ok, rotating logs\n"); + log_operation ("consistency check ok, rotating logs\n"); cm_store_state (); snprintf (newname, sizeof(newname), "log.%d", file_times++); rename ("log", newname); @@ -210,7 +205,7 @@ Result cm_open (VenusFid *fid, CredCacheEntry **ce, u_int tokens, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { @@ -246,6 +241,9 @@ cm_open (VenusFid *fid, } if (checkright (entry, mask, *ce)) { +#if 0 + assert(entry->flags.attrusedp); +#endif entry->flags.datausedp = TRUE; entry->tokens |= tokens; ret.res = 0; @@ -265,7 +263,7 @@ cm_open (VenusFid *fid, } fcache_release(entry); - cm_check_usedbytes_consistency(); + cm_check_consistency(); return ret; } @@ -311,7 +309,7 @@ cm_close (VenusFid fid, int flag, AFSStoreStatus *status, CredCacheEntry* ce) ret.res = 0; ret.error = 0; - cm_check_usedbytes_consistency(); + cm_check_consistency(); return ret; } @@ -342,7 +340,7 @@ cm_getattr (VenusFid fid, return ret; } - assert (CheckLock (&entry->lock) == -1); + AssertExclLocked(&entry->lock); error = fcache_verify_attr (entry, NULL, NULL, ce); if (error) { @@ -355,7 +353,7 @@ cm_getattr (VenusFid fid, arla_warnx (ADEBCM, "cm_getattr: done get attr"); if (checkright (entry, - entry->status.FileType == TYPE_FILE ? AREAD : ALIST, + entry->status.FileType == TYPE_FILE ? AREAD : 0, ce)) { *attr = entry->status; ret.res = 0; @@ -375,13 +373,13 @@ cm_getattr (VenusFid fid, *realfid = *fcache_realfid (entry); ret.tokens = entry->tokens; if (!entry->flags.datausedp) - ret.tokens &= ~XFS_DATA_MASK; + ret.tokens &= ~(XFS_DATA_MASK | XFS_OPEN_MASK); fcache_release(entry); arla_warnx (ADEBCM, "cm_getattr: return: %d.%d", ret.res, ret.error); - cm_check_usedbytes_consistency(); + cm_check_consistency(); - assert (CheckLock (&entry->lock) != -1); + AssertNotExclLocked(&entry->lock); return ret; } @@ -425,7 +423,7 @@ cm_setattr (VenusFid fid, AFSStoreStatus *attr, CredCacheEntry* ce) ret.error = EACCES; } fcache_release(entry); - cm_check_usedbytes_consistency(); + cm_check_consistency(); return ret; } @@ -477,7 +475,7 @@ cm_ftruncate (VenusFid fid, off_t size, CredCacheEntry* ce) ret.error = EACCES; } fcache_release(entry); - cm_check_usedbytes_consistency(); + cm_check_consistency(); return ret; } @@ -519,7 +517,7 @@ cm_access (VenusFid fid, int mode, CredCacheEntry* ce) fid.Cell, fid.fid.Volume, fid.fid.Vnode, fid.fid.Unique); fcache_release(entry); - cm_check_usedbytes_consistency(); + cm_check_consistency(); return ret; } @@ -593,60 +591,74 @@ cm_lookup (VenusFid *dir_fid, name = tmp_name; } - error = adir_lookup (dir_fid, name, res, &entry, ce); + error = fcache_get_data(&entry, dir_fid, ce); if (error) { ret.res = -1; ret.error = error; return ret; } - fcache_release (entry); - if (follow_mount_point && - ((error = followmountpoint (res, dir_fid, ce)) != 0)) { + error = adir_lookup (entry, name, res); + if (error) { + fcache_release(entry); ret.res = -1; ret.error = error; - } else { - ret.res = 0; - ret.tokens = 0; - ret.error = 0; + return ret; } - /* Assume that this means a bad .. */ - if ( strcmp("..", name) == 0 - && VenusFid_cmp(dir_fid, res) == 0) { - FCacheEntry *e; - int error; + ret.res = 0; + ret.error = 0; + ret.tokens = 0; - error = fcache_get (&e, *dir_fid, *ce); - if (error) { - ret.res = -1; - ret.error = error; - return ret; - } + /* + * The ".." at the top of a volume just points to the volume root, + * so get the real ".." from the volume cache instead. + * + * Or if we are looking up "." we don't want to follow the + * mountpoint + */ - error = fcache_verify_attr (e, NULL, NULL, *ce); - if (error) { - fcache_release(e); - ret.res = -1; - ret.error = error; - return ret; - } + if (strcmp(".", name) == 0) { - *res = e->volume->parent_fid; /* e->parent */ - ret.res = 0; - ret.error = 0; - ret.tokens = e->tokens; - fcache_release(e); + error = fcache_verify_attr (entry, NULL, NULL, *ce); + if (error) { + ret.res = -1; + ret.error = error; + goto out; + } + + *res = *dir_fid; + ret.tokens = entry->tokens; + } else if ((strcmp("..", name) == 0 && VenusFid_cmp(dir_fid, res) == 0)) { + + error = fcache_verify_attr (entry, NULL, NULL, *ce); + if (error) { + ret.res = -1; + ret.error = error; + goto out; + } + + *res = entry->volume->parent_fid; /* entry->parent */ + ret.tokens = entry->tokens; + } else if (follow_mount_point) { + error = followmountpoint (res, dir_fid, entry, ce); + if (error) { + ret.res = -1; + ret.error = error; + goto out; + } } - +out: + fcache_release(entry); + log_operation ("lookup (%ld,%lu,%lu,%lu) %s\n", dir_fid->Cell, dir_fid->fid.Volume, dir_fid->fid.Vnode, dir_fid->fid.Unique, - name); + name); - cm_check_usedbytes_consistency(); + cm_check_consistency(); return ret; } @@ -696,7 +708,7 @@ cm_create (VenusFid *dir_fid, const char *name, AFSStoreStatus *store_attr, name); fcache_release(dire); - cm_check_usedbytes_consistency(); + cm_check_consistency(); return ret; } @@ -750,7 +762,7 @@ cm_mkdir (VenusFid *dir_fid, const char *name, name); ReleaseWriteLock (&dire->lock); - cm_check_usedbytes_consistency(); + cm_check_consistency(); return ret; } @@ -808,36 +820,49 @@ cm_symlink (VenusFid *dir_fid, goto out; } - error = followmountpoint(res, dir_fid, ce); + error = followmountpoint(res, dir_fid, NULL, ce); if (error) { ret.res = -1; ret.error = error; goto out; } - error = fcache_get (&symlink_entry, *res, *ce); - if (error) { - ret.res = -1; - ret.error = error; - goto out; - } + /* + * If the new symlink is a mountpoint and it points + * to dir_fid we will deadlock if we look it up. + */ + + if (VenusFid_cmp (res, dir_fid) != 0) { + + error = fcache_get (&symlink_entry, *res, *ce); + if (error) { + ret.res = -1; + ret.error = error; + goto out; + } + + error = fcache_verify_attr (symlink_entry, NULL, NULL, *ce); + if (error) { + fcache_release (symlink_entry); + ret.res = -1; + ret.error = error; + goto out; + } + + symlink_entry->flags.kernelp = TRUE; + + *fetch_attr = symlink_entry->status; + *realfid = *fcache_realfid (symlink_entry); - error = fcache_verify_attr (symlink_entry, NULL, NULL, *ce); - if (error) { fcache_release (symlink_entry); - ret.res = -1; - ret.error = error; - goto out; + } else { + *fetch_attr = dire->status; + *realfid = *fcache_realfid (dire); } - - symlink_entry->flags.kernelp = TRUE; - *fetch_attr = symlink_entry->status; - *realfid = *fcache_realfid (symlink_entry); - fcache_release (symlink_entry); ret.res = 0; ret.error = 0; - + log_operation ("symlink (%ld,%lu,%lu,%lu) %s %s\n", dir_fid->Cell, dir_fid->fid.Volume, @@ -845,10 +870,10 @@ cm_symlink (VenusFid *dir_fid, dir_fid->fid.Unique, name, contents); - -out: + + out: fcache_release(dire); - cm_check_usedbytes_consistency(); + cm_check_consistency(); return ret; } @@ -921,7 +946,7 @@ cm_link (VenusFid *dir_fid, out: fcache_release(dire); fcache_release(file); - cm_check_usedbytes_consistency(); + cm_check_consistency(); return ret; } @@ -975,7 +1000,7 @@ sub_remove (VenusFid *dir_fid, const char *name, CredCacheEntry **ce, name); fcache_release(dire); - cm_check_usedbytes_consistency(); + cm_check_consistency(); return ret; } @@ -1007,53 +1032,43 @@ cm_rmdir(VenusFid *dir_fid, */ static int -potential_update_dir(const VenusFid *child_fid, +potential_update_dir(FCacheEntry *child_entry, const VenusFid *new_parent_fid, + FCacheEntry *parent_entry, int *update_child, CredCacheEntry *ce) { - FCacheEntry *fe; int error; - error = fcache_get (&fe, *child_fid, ce); - if (error) + error = fcache_verify_attr (child_entry, parent_entry, NULL, ce); + if (error) return error; - error = fcache_verify_attr (fe, NULL, NULL, ce); - if (error) { - fcache_release (fe); - return error; - } - /* * if we're moving a directory. */ - if (fe->status.FileType == TYPE_DIR) { + if (child_entry->status.FileType == TYPE_DIR) { int fd; fbuf the_fbuf; - error = fcache_verify_data (fe, ce); /* XXX - check fake_mp */ - if (error) { - fcache_release (fe); + error = fcache_verify_data (child_entry, ce); /* XXX - check fake_mp */ + if (error) return error; - } - error = fcache_get_fbuf (fe, &fd, &the_fbuf, O_RDWR, + + error = fcache_get_fbuf (child_entry, &fd, &the_fbuf, O_RDWR, FBUF_READ|FBUF_WRITE|FBUF_SHARED); - if (error) { - fcache_release (fe); + if (error) return error; - } + error = fdir_changefid (&the_fbuf, "..", new_parent_fid); fbuf_end (&the_fbuf); close (fd); - if (error) { - fcache_release (fe); + if (error) return error; - } + *update_child = 1; } - fcache_release (fe); return 0; } @@ -1105,87 +1120,95 @@ cm_rename(VenusFid *old_parent_fid, const char *old_name, if (checkright (old_dir, ADELETE, *ce) && checkright (new_dir, AINSERT, *ce)) { - + error = rename_file (old_dir, old_name, new_dir, new_name, *ce); if (error) { ret.res = -1; ret.error = error; } else { VenusFid new_fid, old_fid; - - /* - * Lookup the old name (to get the fid of the new name) - */ - - error = adir_lookup_fcacheentry (old_dir, - *old_parent_fid, - old_name, &new_fid, *ce); - + + /* + * Lookup the old name (to get the fid of the new name) + */ + + error = adir_lookup (old_dir, old_name, &new_fid); + if (error) { ret.res = -1; ret.error = error; goto out; } - + *child_fid = new_fid; - + if (diff_dir) { - error = potential_update_dir (child_fid, new_parent_fid, - update_child, *ce); + FCacheEntry *child_entry; + + error = fcache_get (&child_entry, *child_fid, *ce); if (error) { ret.res = -1; ret.error = error; goto out; } - } + + child_entry->parent = *new_parent_fid; - /* - * Lookup the new name, if it exists we need to clear it out. - * XXX Should we check the lnkcount and clear it from fcache ? - */ - - error = adir_lookup_fcacheentry (new_dir, - *new_parent_fid, - new_name, &old_fid, *ce); - if (error == 0) - adir_remove (new_dir, new_name); - - /* - * Now do the rename, ie create the new name and remove - * the old name. - */ - - error = adir_creat (new_dir, new_name, new_fid.fid) - || adir_remove (old_dir, old_name); - - if (error) { - ret.res = -1; - ret.error = error; - } else { - ret.res = 0; - ret.error = 0; - } - } - } else { - ret.res = -1; - ret.error = EACCES; - } - - log_operation ("rename (%ld,%lu,%lu,%lu) (%ld,%lu,%lu,%lu) %s %s\n", - old_parent_fid->Cell, - old_parent_fid->fid.Volume, - old_parent_fid->fid.Vnode, - old_parent_fid->fid.Unique, - new_parent_fid->Cell, - new_parent_fid->fid.Volume, - new_parent_fid->fid.Vnode, - new_parent_fid->fid.Unique, - old_name, new_name); - -out: - fcache_release(old_dir); - if (diff_dir) - fcache_release(new_dir); - cm_check_usedbytes_consistency(); - return ret; + error = potential_update_dir (child_entry, new_parent_fid, + new_dir, update_child, *ce); + fcache_release (child_entry); + if (error) { + ret.res = -1; + ret.error = error; + goto out; + } + } + + /* + * Lookup the new name, if it exists we need to clear it out. + * XXX Should we check the lnkcount and clear it from fcache ? + */ + + error = adir_lookup (new_dir, new_name, &old_fid); + if (error == 0) + adir_remove (new_dir, new_name); + + /* + * Now do the rename, ie create the new name and remove + * the old name. + */ + + error = adir_creat (new_dir, new_name, new_fid.fid) + || adir_remove (old_dir, old_name); + + if (error) { + ret.res = -1; + ret.error = error; + } else { + ret.res = 0; + ret.error = 0; + } + } + } else { + ret.res = -1; + ret.error = EACCES; + } + + log_operation ("rename (%ld,%lu,%lu,%lu) (%ld,%lu,%lu,%lu) %s %s\n", + old_parent_fid->Cell, + old_parent_fid->fid.Volume, + old_parent_fid->fid.Vnode, + old_parent_fid->fid.Unique, + new_parent_fid->Cell, + new_parent_fid->fid.Volume, + new_parent_fid->fid.Vnode, + new_parent_fid->fid.Unique, + old_name, new_name); + + out: + fcache_release(old_dir); + if (diff_dir) + fcache_release(new_dir); + cm_check_consistency(); + return ret; } diff --git a/usr.sbin/afs/src/arlad/inter.h b/usr.sbin/afs/src/arlad/inter.h index 8e5b4356391..a0a209b5ea3 100644 --- a/usr.sbin/afs/src/arlad/inter.h +++ b/usr.sbin/afs/src/arlad/inter.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ * The interface to the cache manager. */ -/* $Id: inter.h,v 1.3 2000/09/11 14:40:42 art Exp $ */ +/* $KTH: inter.h,v 1.24 2000/11/28 01:42:15 lha Exp $ */ #ifndef _INTER_H_ #define _INTER_H_ @@ -66,7 +61,7 @@ cm_store_state (void); Result cm_open (VenusFid *fid, CredCacheEntry **ce, u_int tokens, - xfs_cache_handle *, char *, size_t); + fcache_cache_handle *, char *, size_t); Result cm_close (VenusFid fid, int flag, AFSStoreStatus *, CredCacheEntry *ce); @@ -127,9 +122,9 @@ cm_rename(VenusFid *old_parent_fid, const char *old_name, CredCacheEntry **ce); void -cm_check_usedbytes_consistency (void); +cm_check_consistency (void); void -cm_turn_on_usedbytes_consistency(void); +cm_turn_on_consistency_check(void); #endif /* _INTER_H_ */ diff --git a/usr.sbin/afs/src/arlad/irix-subr.c b/usr.sbin/afs/src/arlad/irix-subr.c index a4b4b46813e..7fdd9a55803 100644 --- a/usr.sbin/afs/src/arlad/irix-subr.c +++ b/usr.sbin/afs/src/arlad/irix-subr.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,8 +31,9 @@ * SUCH DAMAGE. */ +#define _KERNEL #include "arla_local.h" -RCSID("$Id: irix-subr.c,v 1.1 2000/09/11 14:40:42 art Exp $"); +RCSID("$KTH: irix-subr.c,v 1.25 2000/10/14 19:58:09 map Exp $"); static long blocksize = 1024; /* XXX */ @@ -71,7 +67,7 @@ write_dirent(VenusFid *fid, const char *name, void *arg) real->d_reclen = dirent.d_reclen; real->d_ino = dentry2ino (name, fid, args->e); - strcpy (real->d_name, name); + strlcpy (real->d_name, name, sizeof(real->d_name)); args->ptr += real->d_reclen; args->off += real->d_reclen; real->d_off = args->off; @@ -80,7 +76,7 @@ write_dirent(VenusFid *fid, const char *name, void *arg) Result conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { return conv_dir_sub (e, ce, tokens, cache_handle, cache_name, @@ -93,7 +89,7 @@ conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, int dir_remove_name (FCacheEntry *e, const char *filename, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { int ret; diff --git a/usr.sbin/afs/src/arlad/kernel.c b/usr.sbin/afs/src/arlad/kernel.c index 8e16d9d419f..fd0e7b886b9 100644 --- a/usr.sbin/afs/src/arlad/kernel.c +++ b/usr.sbin/afs/src/arlad/kernel.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +32,7 @@ */ #include "arla_local.h" -RCSID("$Id: kernel.c,v 1.3 2000/09/11 14:40:42 art Exp $"); +RCSID("$KTH: kernel.c,v 1.27.2.1 2001/03/12 12:22:41 lha Exp $"); /* * The fd we use to talk with the kernel on. @@ -99,6 +94,10 @@ process_message (int msg_length, char *msg) return 0; } +/* no threads available to handle messages */ + +static int overload = FALSE; + /* * The work threads. */ @@ -126,6 +125,8 @@ sub_thread (void *v_myself) arla_warnx (ADEBKERNEL, "worker %d: done", self->number); --workers_used; self->busyp = 0; + overload = FALSE; + LWP_NoYieldSignal(&overload); } } @@ -332,6 +333,8 @@ kernel_opendevice (const char *dev) if (fd < 0) arla_err (1, ADEBERROR, errno, "kern_open %s", dev); kernel_fd = fd; + if (kernel_fd >= FD_SETSIZE) + arla_errx (1, ADEBERROR, "kernel fd too large"); } @@ -400,8 +403,12 @@ kernel_interface (struct kernel_args *args) break; } } - if (i == args->num_workers) - arla_warnx (ADEBWARN, "kernel: all workers busy"); + if (i == args->num_workers) { + arla_warnx (ADEBWARN, "kernel: all %u workers busy", + args->num_workers); + overload = TRUE; + LWP_WaitProcess(&overload); + } } } } diff --git a/usr.sbin/afs/src/arlad/kernel.h b/usr.sbin/afs/src/arlad/kernel.h index 12248be28bb..3c9c856a590 100644 --- a/usr.sbin/afs/src/arlad/kernel.h +++ b/usr.sbin/afs/src/arlad/kernel.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: kernel.h,v 1.3 2000/09/11 14:40:43 art Exp $ */ +/* $KTH: kernel.h,v 1.8 2000/10/02 22:32:26 lha Exp $ */ #ifndef _KERNEL_H_ #define _KERNEL_H_ diff --git a/usr.sbin/afs/src/arlad/messages.c b/usr.sbin/afs/src/arlad/messages.c index 7583b1f3513..c7506d70cf2 100644 --- a/usr.sbin/afs/src/arlad/messages.c +++ b/usr.sbin/afs/src/arlad/messages.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995-2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995-2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +32,7 @@ */ #include "arla_local.h" -RCSID("$Id: messages.c,v 1.3 2000/09/11 14:40:43 art Exp $"); +RCSID("$KTH: messages.c,v 1.231.2.12 2001/10/19 04:25:52 ahltorp Exp $"); #include <xfs/xfs_message.h> @@ -231,20 +226,24 @@ fcacheentry2xfsnode (const VenusFid *fid, const VenusFid *statfid, AFSFetchStatus *status, struct xfs_msg_node *node, - AccessEntry *ae) + AccessEntry *ae, + int flags) { int i; - afsstatus2xfs_attr (status, statfid, &node->attr); memcpy (&node->handle, fid, sizeof(*fid)); - node->anonrights = afsrights2xfsrights(status->AnonymousAccess, - status->FileType, - status->UnixModeBits); - for (i = 0; i < NACCESS; i++) { - node->id[i] = ae[i].cred; - node->rights[i] = afsrights2xfsrights(ae[i].access, - status->FileType, - status->UnixModeBits); + if (flags & FCACHE2XFSNODE_ATTR) + afsstatus2xfs_attr (status, statfid, &node->attr); + if (flags & FCACHE2XFSNODE_RIGHT) { + node->anonrights = afsrights2xfsrights(status->AnonymousAccess, + status->FileType, + status->UnixModeBits); + for (i = 0; i < NACCESS; i++) { + node->id[i] = ae[i].cred; + node->rights[i] = afsrights2xfsrights(ae[i].access, + status->FileType, + status->UnixModeBits); + } } } @@ -284,6 +283,8 @@ xfs_attr2afsstorestatus(struct xfs_attr *xa, /* * Return true iff we should retry the operation. * Also replace `ce' with anonymous creds in case it has expired. + * + * There must not be passed in any NULL pointers. */ static int @@ -291,16 +292,22 @@ try_again (int *ret, CredCacheEntry **ce, xfs_cred *cred, const VenusFid *fid) { switch (*ret) { #ifdef KERBEROS - case RXKADEXPIRED : { + case RXKADEXPIRED : + case RXKADUNKNOWNKEY: { int32_t cell = (*ce)->cell; - conn_clearcred (0, cred->pag, 2); + conn_clearcred (CONN_CS_CRED|CONN_CS_SECIDX, 0, cred->pag, 2); cred_expire (*ce); cred_free (*ce); *ce = cred_get (cell, cred->pag, CRED_ANY); assert (*ce != NULL); return TRUE; } + case RXKADSEALEDINCON : + arla_warnx_with_fid (ADEBWARN, fid, + "seal error"); + *ret = EINVAL; + return FALSE; #endif case ARLA_VSALVAGE : *ret = EIO; @@ -311,7 +318,6 @@ try_again (int *ret, CredCacheEntry **ce, xfs_cred *cred, const VenusFid *fid) case ARLA_VMOVED : case ARLA_VNOVOL : if (fid && !volcache_reliable (fid->fid.Volume, fid->Cell)) { - volcache_invalidate (fid->fid.Volume, fid->Cell); return TRUE; } else { *ret = ENOENT; @@ -333,12 +339,12 @@ try_again (int *ret, CredCacheEntry **ce, xfs_cred *cred, const VenusFid *fid) case ARLA_VBUSY : arla_warnx_with_fid (ADEBWARN, fid, "Waiting for busy volume..."); - IOMGR_Sleep (1); + IOMGR_Sleep (afs_BusyWaitPeriod); return TRUE; case ARLA_VRESTARTING: arla_warnx_with_fid (ADEBWARN, fid, "Waiting for fileserver to restart..."); - IOMGR_Sleep (1); + IOMGR_Sleep (afs_BusyWaitPeriod); return TRUE; case ARLA_VIO : *ret = EIO; @@ -348,6 +354,25 @@ try_again (int *ret, CredCacheEntry **ce, xfs_cred *cred, const VenusFid *fid) } } +/* + * Fetch data and retry if failing + */ + +static int +message_get_data (FCacheEntry **entry, VenusFid *fid, + struct xfs_cred *cred, CredCacheEntry **ce) +{ + int ret; + do { + ret = fcache_get_data (entry, fid, ce); + } while (try_again (&ret, ce, cred, fid)); + return ret; +} + +/* + * + */ + static int xfs_message_getroot (int fd, struct xfs_message_getroot *h, u_int size) { @@ -356,7 +381,7 @@ xfs_message_getroot (int fd, struct xfs_message_getroot *h, u_int size) VenusFid root_fid; VenusFid real_fid; AFSFetchStatus status; - Result result; + Result res; CredCacheEntry *ce; AccessEntry *ae; struct xfs_message_header *h0 = NULL; @@ -369,16 +394,20 @@ xfs_message_getroot (int fd, struct xfs_message_getroot *h, u_int size) ret = getroot (&root_fid, ce); if (ret == 0) { - result = cm_getattr(root_fid, &status, &real_fid, ce, &ae); - if (result.res == -1) - ret = result.error; + res = cm_getattr(root_fid, &status, &real_fid, ce, &ae); + if (res.res) + ret = res.error; + else + ret = res.res; } } while (try_again (&ret, &ce, &h->cred, &root_fid)); if (ret == 0) { fcacheentry2xfsnode (&root_fid, &real_fid, - &status, &msg.node, ae); + &status, &msg.node, ae, + FCACHE2XFSNODE_ALL); + msg.node.tokens = res.tokens & ~XFS_DATA_MASK; msg.header.opcode = XFS_MSG_INSTALLROOT; h0 = (struct xfs_message_header *)&msg; h0_len = sizeof(msg); @@ -433,7 +462,8 @@ xfs_message_getnode (int fd, struct xfs_message_getnode *h, u_int size) } while (try_again (&ret, &ce, &h->cred, report_fid)); if (ret == 0) { - fcacheentry2xfsnode (&fid, &real_fid, &status, &msg.node, ae); + fcacheentry2xfsnode (&fid, &real_fid, &status, &msg.node, ae, + FCACHE2XFSNODE_ALL); msg.node.tokens = res.tokens & ~XFS_DATA_MASK; msg.parent_handle = h->parent_handle; @@ -484,7 +514,8 @@ xfs_message_getattr (int fd, struct xfs_message_getattr *h, u_int size) } while (try_again (&ret, &ce, &h->cred, fid)); if (ret == 0) { - fcacheentry2xfsnode (fid, &real_fid, &status, &msg.node, ae); + fcacheentry2xfsnode (fid, &real_fid, &status, &msg.node, ae, + FCACHE2XFSNODE_ALL); msg.node.tokens = res.tokens; msg.header.opcode = XFS_MSG_INSTALLATTR; @@ -553,17 +584,23 @@ xfs_message_putattr (int fd, struct xfs_message_putattr *h, u_int size) } while (try_again (&ret, &ce, &h->cred, fid)); if (ret == 0) { - res = cm_getattr (*fid, &fetch_status, &real_fid, ce, &ae); - if (res.res == 0) { + do { + res = cm_getattr (*fid, &fetch_status, &real_fid, ce, &ae); + if (res.res) + ret = res.error; + else + ret = res.res; + } while (try_again (&ret, &ce, &h->cred, fid)); + + if (ret == 0) { fcacheentry2xfsnode (fid, &real_fid, - &fetch_status, &msg.node, ae); + &fetch_status, &msg.node, ae, + FCACHE2XFSNODE_ALL); msg.node.tokens = res.tokens; msg.header.opcode = XFS_MSG_INSTALLATTR; h0 = (struct xfs_message_header *)&msg; h0_len = sizeof(msg); - } else { - ret = res.error; } } @@ -600,6 +637,7 @@ xfs_message_create (int fd, struct xfs_message_create *h, u_int size) size_t h2_len = 0; FCacheEntry *dir_entry = NULL; FCacheEntry *child_entry = NULL; + fcache_cache_handle cache_handle; parent_fid = (VenusFid *)&h->parent_handle; arla_warnx (ADEBMSG, "create (%ld.%lu.%lu.%lu) \"%s\"", @@ -638,37 +676,49 @@ xfs_message_create (int fd, struct xfs_message_create *h, u_int size) if (res.res == 0) { - ret = fcache_get_data (&dir_entry, parent_fid, &ce); + ret = message_get_data (&dir_entry, parent_fid, &h->cred, &ce); if (ret) goto out; res = conv_dir (dir_entry, ce, 0, - &msg1.cache_handle, + &cache_handle, msg1.cache_name, sizeof(msg1.cache_name)); if (res.res == -1) { ret = res.error; goto out; } + msg1.cache_handle = cache_handle.xfs_handle; + msg1.flag = 0; + if (cache_handle.valid) + msg1.flag |= XFS_ID_HANDLE_VALID; + msg1.node.tokens = res.tokens; fcacheentry2xfsnode (parent_fid, fcache_realfid(dir_entry), &dir_entry->status, &msg1.node, - dir_entry->acccache); - msg1.flag = 0; + dir_entry->acccache, + FCACHE2XFSNODE_ALL); - ret = fcache_get_data (&child_entry, &child_fid, &ce); + ret = message_get_data (&child_entry, &child_fid, &h->cred, &ce); if (ret) goto out; - msg3.cache_handle = child_entry->handle; + msg3.cache_handle = child_entry->handle.xfs_handle; fcache_file_name (child_entry, msg3.cache_name, sizeof(msg3.cache_name)); msg3.flag = 0; + if (cache_handle.valid) + msg3.flag |= XFS_ID_HANDLE_VALID; + child_entry->flags.kernelp = TRUE; + child_entry->flags.attrusedp = TRUE; child_entry->flags.datausedp = TRUE; +#if 0 + assert(dir_entry->flags.attrusedp); +#endif dir_entry->flags.datausedp = TRUE; msg1.header.opcode = XFS_MSG_INSTALLDATA; @@ -676,7 +726,8 @@ xfs_message_create (int fd, struct xfs_message_create *h, u_int size) h0_len = sizeof(msg1); fcacheentry2xfsnode (&child_fid, &child_fid, - &fetch_status, &msg2.node, dir_entry->acccache); + &fetch_status, &msg2.node, dir_entry->acccache, + FCACHE2XFSNODE_ALL); msg2.node.tokens = XFS_ATTR_R | XFS_OPEN_NW | XFS_OPEN_NR @@ -746,12 +797,17 @@ xfs_message_mkdir (int fd, struct xfs_message_mkdir *h, u_int size) size_t h1_len = 0; struct xfs_message_header *h2 = NULL; size_t h2_len = 0; + fcache_cache_handle cache_handle; struct vcache log_ent_parent, log_ent_child; FCacheEntry parent_entry; AFSStoreStatus log_store_status; +#if 0 parent_fid = fid_translate((VenusFid *)&h->parent_handle); +#else + parent_fid = (VenusFid *)&h->parent_handle; +#endif arla_warnx (ADEBMSG, "mkdir (%ld.%lu.%lu.%lu) \"%s\"", (long)parent_fid->Cell, (unsigned long)parent_fid->fid.Volume, (unsigned long)parent_fid->fid.Vnode, @@ -787,52 +843,64 @@ xfs_message_mkdir (int fd, struct xfs_message_mkdir *h, u_int size) if (res.res == 0) { - ret = fcache_get_data (&dir_entry, parent_fid, &ce); + ret = message_get_data (&dir_entry, parent_fid, &h->cred, &ce); if (ret) goto out; res = conv_dir (dir_entry, ce, 0, - &msg1.cache_handle, + &cache_handle, msg1.cache_name, sizeof(msg1.cache_name)); if (res.res == -1) { ret = res.error; goto out; } + msg1.cache_handle = cache_handle.xfs_handle; + msg1.flag = 0; + if (cache_handle.valid) + msg1.flag |= XFS_ID_HANDLE_VALID; msg1.node.tokens = res.tokens; fcacheentry2xfsnode (parent_fid, fcache_realfid(dir_entry), &dir_entry->status, &msg1.node, - dir_entry->acccache); - msg1.flag = 0; + dir_entry->acccache, + FCACHE2XFSNODE_ALL); msg1.header.opcode = XFS_MSG_INSTALLDATA; h0 = (struct xfs_message_header *)&msg1; h0_len = sizeof(msg1); - ret = fcache_get_data (&child_entry, &child_fid, &ce); + ret = message_get_data (&child_entry, &child_fid, &h->cred, &ce); if (ret) goto out; res = conv_dir (child_entry, ce, 0, - &msg3.cache_handle, + &cache_handle, msg3.cache_name, sizeof(msg3.cache_name)); if (res.res == -1) { ret = res.error; goto out; } + msg3.cache_handle = cache_handle.xfs_handle; + msg3.flag = 0; + if (cache_handle.valid) + msg3.flag |= XFS_ID_HANDLE_VALID; + child_entry->flags.attrusedp = TRUE; child_entry->flags.datausedp = TRUE; +#if 0 + assert(dir_entry->flags.attrusedp); +#endif dir_entry->flags.datausedp = TRUE; - msg3.flag = 0; msg2.node.tokens = res.tokens; fcacheentry2xfsnode (&child_fid, &child_fid, &child_entry->status, &msg2.node, - dir_entry->acccache); + dir_entry->acccache, + FCACHE2XFSNODE_ALL); msg2.parent_handle = h->parent_handle; strlcpy (msg2.name, h->name, sizeof(msg2.name)); @@ -891,6 +959,7 @@ xfs_message_link (int fd, struct xfs_message_link *h, u_int size) size_t h0_len = 0; struct xfs_message_header *h1 = NULL; size_t h1_len = 0; + fcache_cache_handle cache_handle; parent_fid = (VenusFid *)&h->parent_handle; existing_fid = (VenusFid *)&h->from_handle; @@ -919,12 +988,12 @@ xfs_message_link (int fd, struct xfs_message_link *h, u_int size) if (res.res == 0) { FCacheEntry *dir_entry; - ret = fcache_get_data (&dir_entry, parent_fid, &ce); + ret = message_get_data (&dir_entry, parent_fid, &h->cred, &ce); if (ret) goto out; res = conv_dir (dir_entry, ce, 0, - &msg1.cache_handle, + &cache_handle, msg1.cache_name, sizeof(msg1.cache_name)); if (res.res == -1) { @@ -932,22 +1001,30 @@ xfs_message_link (int fd, struct xfs_message_link *h, u_int size) ret = res.error; goto out; } + msg1.cache_handle = cache_handle.xfs_handle; + msg1.flag = 0; + if (cache_handle.valid) + msg1.flag |= XFS_ID_HANDLE_VALID; msg1.node.tokens = res.tokens; +#if 0 + assert(dir_entry->flags.attrusedp); +#endif dir_entry->flags.datausedp = TRUE; fcacheentry2xfsnode (parent_fid, fcache_realfid(dir_entry), &dir_entry->status, &msg1.node, - dir_entry->acccache); - msg1.flag = 0; - + dir_entry->acccache, + FCACHE2XFSNODE_ALL); + msg1.header.opcode = XFS_MSG_INSTALLDATA; h0 = (struct xfs_message_header *)&msg1; h0_len = sizeof(msg1); fcacheentry2xfsnode (existing_fid, existing_fid, &fetch_status, &msg2.node, - dir_entry->acccache); + dir_entry->acccache, + FCACHE2XFSNODE_ALL); fcache_release(dir_entry); msg2.node.tokens = XFS_ATTR_R; /* XXX */ @@ -986,6 +1063,7 @@ xfs_message_symlink (int fd, struct xfs_message_symlink *h, u_int size) size_t h0_len = 0; struct xfs_message_header *h1 = NULL; size_t h1_len = 0; + fcache_cache_handle cache_handle; parent_fid = (VenusFid *)&h->parent_handle; arla_warnx (ADEBMSG, "symlink (%ld.%lu.%lu.%lu) \"%s\"", @@ -1013,12 +1091,12 @@ xfs_message_symlink (int fd, struct xfs_message_symlink *h, u_int size) if (res.res == 0) { FCacheEntry *dir_entry; - ret = fcache_get_data (&dir_entry, parent_fid, &ce); + ret = message_get_data (&dir_entry, parent_fid, &h->cred, &ce); if (ret) goto out; res = conv_dir (dir_entry, ce, 0, - &msg1.cache_handle, + &cache_handle, msg1.cache_name, sizeof(msg1.cache_name)); if (res.res == -1) { @@ -1026,14 +1104,21 @@ xfs_message_symlink (int fd, struct xfs_message_symlink *h, u_int size) ret = res.error; goto out; } + msg1.cache_handle = cache_handle.xfs_handle; msg1.flag = 0; + if (cache_handle.valid) + msg1.flag |= XFS_ID_HANDLE_VALID; msg1.node.tokens = res.tokens; +#if 0 + assert(dir_entry->flags.attrusedp); +#endif dir_entry->flags.datausedp = TRUE; fcacheentry2xfsnode (parent_fid, fcache_realfid(dir_entry), &dir_entry->status, &msg1.node, - dir_entry->acccache); + dir_entry->acccache, + FCACHE2XFSNODE_ALL); msg1.header.opcode = XFS_MSG_INSTALLDATA; h0 = (struct xfs_message_header *)&msg1; @@ -1041,7 +1126,8 @@ xfs_message_symlink (int fd, struct xfs_message_symlink *h, u_int size) fcacheentry2xfsnode (&child_fid, &real_fid, &fetch_status, &msg2.node, - dir_entry->acccache); + dir_entry->acccache, + FCACHE2XFSNODE_ALL); fcache_release(dir_entry); msg2.node.tokens = XFS_ATTR_R; /* XXX */ @@ -1087,6 +1173,7 @@ xfs_message_remove (int fd, struct xfs_message_remove *h, u_int size) unsigned link_count; FCacheEntry *dir_entry = NULL; AFSFetchStatus limbo_status; + fcache_cache_handle cache_handle; parent_fid = (VenusFid *)&h->parent_handle; arla_warnx (ADEBMSG, "remove (%ld.%lu.%lu.%lu) \"%s\"", @@ -1131,7 +1218,6 @@ xfs_message_remove (int fd, struct xfs_message_remove *h, u_int size) do { res = cm_remove(parent_fid, h->name, &ce); - if (res.res) ret = res.error; else @@ -1140,17 +1226,17 @@ xfs_message_remove (int fd, struct xfs_message_remove *h, u_int size) if (ret == 0) { - ret = fcache_get_data (&dir_entry, parent_fid, &ce); + ret = message_get_data (&dir_entry, parent_fid, &h->cred, &ce); if (ret) goto out; if (!dir_entry->flags.extradirp || dir_remove_name (dir_entry, h->name, - &msg1.cache_handle, + &cache_handle, msg1.cache_name, sizeof(msg1.cache_name))) { res = conv_dir (dir_entry, ce, 0, - &msg1.cache_handle, + &cache_handle, msg1.cache_name, sizeof(msg1.cache_name)); if (res.res == -1) { @@ -1158,14 +1244,17 @@ xfs_message_remove (int fd, struct xfs_message_remove *h, u_int size) goto out; } } - + msg1.cache_handle = cache_handle.xfs_handle; msg1.flag = XFS_ID_INVALID_DNLC; + if (cache_handle.valid) + msg1.flag |= XFS_ID_HANDLE_VALID; msg1.node.tokens = res.tokens | XFS_DATA_R; fcacheentry2xfsnode (parent_fid, fcache_realfid(dir_entry), &dir_entry->status, &msg1.node, - dir_entry->acccache); + dir_entry->acccache, + FCACHE2XFSNODE_ALL); msg1.header.opcode = XFS_MSG_INSTALLDATA; h0 = (struct xfs_message_header *)&msg1; @@ -1175,6 +1264,9 @@ xfs_message_remove (int fd, struct xfs_message_remove *h, u_int size) * Set datausedp since we push data to kernel in out: */ +#if 0 + assert(dir_entry->flags.attrusedp); +#endif dir_entry->flags.datausedp = TRUE; /* @@ -1211,7 +1303,8 @@ xfs_message_remove (int fd, struct xfs_message_remove *h, u_int size) fcache_realfid(limbo_entry), &limbo_status, &msg2.node, - limbo_entry->acccache); + limbo_entry->acccache, + FCACHE2XFSNODE_ALL); h1 = (struct xfs_message_header *)&msg2; h1_len = sizeof(msg2); @@ -1243,12 +1336,13 @@ xfs_message_rmdir (int fd, struct xfs_message_rmdir *h, u_int size) struct xfs_message_installdata msg0; struct xfs_message_header *h0 = NULL; size_t h0_len = 0; - struct xfs_message_installdata msg1; + struct xfs_message_installattr msg1; struct xfs_message_header *h1 = NULL; size_t h1_len = 0; FCacheEntry *limbo_entry = NULL; FCacheEntry *dir_entry = NULL; unsigned link_count = 0; + fcache_cache_handle cache_handle; parent_fid = (VenusFid *)&h->parent_handle; arla_warnx (ADEBMSG, "rmdir (%ld.%lu.%lu.%lu) \"%s\"", @@ -1304,17 +1398,17 @@ xfs_message_rmdir (int fd, struct xfs_message_rmdir *h, u_int size) if (res.res == 0) { - ret = fcache_get_data (&dir_entry, parent_fid, &ce); + ret = message_get_data (&dir_entry, parent_fid, &h->cred, &ce); if (ret) goto out; if (!dir_entry->flags.extradirp || dir_remove_name (dir_entry, h->name, - &msg0.cache_handle, + &cache_handle, msg0.cache_name, sizeof(msg0.cache_name))) { res = conv_dir (dir_entry, ce, 0, - &msg0.cache_handle, + &cache_handle, msg0.cache_name, sizeof(msg0.cache_name)); if (res.res == -1) { @@ -1322,14 +1416,18 @@ xfs_message_rmdir (int fd, struct xfs_message_rmdir *h, u_int size) goto out; } } - + msg0.cache_handle = cache_handle.xfs_handle; msg0.flag = XFS_ID_INVALID_DNLC; + if (cache_handle.valid) + msg0.flag |= XFS_ID_HANDLE_VALID; + msg0.node.tokens = res.tokens; fcacheentry2xfsnode (parent_fid, fcache_realfid(dir_entry), &dir_entry->status, &msg0.node, - dir_entry->acccache); + dir_entry->acccache, + FCACHE2XFSNODE_ALL); msg0.header.opcode = XFS_MSG_INSTALLDATA; h0 = (struct xfs_message_header *)&msg0; @@ -1361,11 +1459,15 @@ xfs_message_rmdir (int fd, struct xfs_message_rmdir *h, u_int size) fcache_realfid(limbo_entry), &limbo_entry->status, &msg1.node, - limbo_entry->acccache); + limbo_entry->acccache, + FCACHE2XFSNODE_ALL); h1 = (struct xfs_message_header *)&msg1; h1_len = sizeof(msg1); } +#if 0 + assert(dir_entry->flags.attrusedp); +#endif dir_entry->flags.datausedp = TRUE; } @@ -1407,6 +1509,7 @@ xfs_message_rename (int fd, struct xfs_message_rename *h, u_int size) FCacheEntry *new_entry = NULL; FCacheEntry *child_entry = NULL; int update_child = 0; + fcache_cache_handle cache_handle; old_parent_fid = (VenusFid *)&h->old_parent_handle; new_parent_fid = (VenusFid *)&h->new_parent_handle; @@ -1438,17 +1541,17 @@ xfs_message_rename (int fd, struct xfs_message_rename *h, u_int size) if (res.res == 0) { - ret = fcache_get_data (&old_entry, old_parent_fid, &ce); + ret = message_get_data (&old_entry, old_parent_fid, &h->cred, &ce); if (ret) goto out; if (!old_entry->flags.extradirp || dir_remove_name (old_entry, h->old_name, - &msg1.cache_handle, + &cache_handle, msg1.cache_name, sizeof(msg1.cache_name))) { res = conv_dir (old_entry, ce, 0, - &msg1.cache_handle, + &cache_handle, msg1.cache_name, sizeof(msg1.cache_name)); if (res.res == -1) { @@ -1456,14 +1559,18 @@ xfs_message_rename (int fd, struct xfs_message_rename *h, u_int size) goto out; } } - + msg1.cache_handle = cache_handle.xfs_handle; msg1.flag = XFS_ID_INVALID_DNLC; + if (cache_handle.valid) + msg1.flag |= XFS_ID_HANDLE_VALID; + msg1.node.tokens = res.tokens; fcacheentry2xfsnode (old_parent_fid, fcache_realfid(old_entry), &old_entry->status, &msg1.node, - old_entry->acccache); + old_entry->acccache, + FCACHE2XFSNODE_ALL); msg1.header.opcode = XFS_MSG_INSTALLDATA; h0 = (struct xfs_message_header *)&msg1; @@ -1488,50 +1595,66 @@ xfs_message_rename (int fd, struct xfs_message_rename *h, u_int size) goto out; res = conv_dir (new_entry, ce, 0, - &msg2.cache_handle, + &cache_handle, msg2.cache_name, sizeof(msg2.cache_name)); if (res.res == -1) { ret = res.error; goto out; } + msg2.cache_handle = cache_handle.xfs_handle; msg2.flag = XFS_ID_INVALID_DNLC; + if (cache_handle.valid) + msg2.flag |= XFS_ID_HANDLE_VALID; + msg2.node.tokens = res.tokens; fcacheentry2xfsnode (new_parent_fid, fcache_realfid(new_entry), &new_entry->status, &msg2.node, - new_entry->acccache); + new_entry->acccache, + FCACHE2XFSNODE_ALL); msg2.header.opcode = XFS_MSG_INSTALLDATA; h1 = (struct xfs_message_header *)&msg2; h1_len = sizeof(msg2); - if (old_entry) + if (old_entry) { +#if 0 + assert(old_entry->flags.attrusedp); +#endif old_entry->flags.datausedp = TRUE; + } +#if 0 + assert(new_entry->flags.attrusedp); +#endif new_entry->flags.datausedp = TRUE; if (update_child) { - ret = fcache_get_data (&child_entry, &child_fid, &ce); + ret = message_get_data (&child_entry, &child_fid, &h->cred, &ce); if (ret) goto out; res = conv_dir (child_entry, ce, 0, - &msg3.cache_handle, + &cache_handle, msg3.cache_name, sizeof(msg3.cache_name)); if (res.res == -1) { ret = res.error; goto out; } - + msg3.cache_handle = cache_handle.xfs_handle; msg3.flag = XFS_ID_INVALID_DNLC; + if (cache_handle.valid) + msg3.flag |= XFS_ID_HANDLE_VALID; + msg3.node.tokens = res.tokens; fcacheentry2xfsnode (&child_fid, fcache_realfid(child_entry), &child_entry->status, &msg3.node, - child_entry->acccache); + child_entry->acccache, + FCACHE2XFSNODE_ALL); msg3.header.opcode = XFS_MSG_INSTALLDATA; h2 = (struct xfs_message_header *)&msg3; @@ -1622,6 +1745,7 @@ xfs_message_getdata (int fd, struct xfs_message_getdata *h, u_int size) AccessEntry *ae; struct xfs_message_header *h0 = NULL; size_t h0_len = 0; + fcache_cache_handle cache_handle; fid = (VenusFid *)&h->handle; arla_warnx (ADEBMSG, "getdata (%ld.%lu.%lu.%lu)", @@ -1644,34 +1768,51 @@ xfs_message_getdata (int fd, struct xfs_message_getdata *h, u_int size) if (status.FileType == TYPE_DIR) { FCacheEntry *entry; - ret = fcache_get_data (&entry, fid, &ce); - if (ret) { - try_again (&ret, &ce, &h->cred, NULL); + ret = message_get_data (&entry, fid, &h->cred, &ce); + if (ret) goto out; - } fcacheentry2xfsnode (fid, fcache_realfid(entry), - &entry->status, &msg.node, ae); + &entry->status, &msg.node, ae, + FCACHE2XFSNODE_ALL); res = conv_dir (entry, ce, h->tokens, - &msg.cache_handle, + &cache_handle, msg.cache_name, sizeof(msg.cache_name)); - if (res.res != -1) { + if (res.res) + ret = res.error; + + if (ret == 0) { msg.node.tokens = res.tokens; + msg.cache_handle = cache_handle.xfs_handle; msg.flag = XFS_ID_INVALID_DNLC; + if (cache_handle.valid) + msg.flag |= XFS_ID_HANDLE_VALID; + + entry->flags.attrusedp = TRUE; + entry->flags.datausedp = TRUE; } - entry->flags.datausedp = TRUE; fcache_release(entry); } else { - res = cm_open (fid, &ce, h->tokens, &msg.cache_handle, - msg.cache_name, sizeof(msg.cache_name)); - ret = res.error; - if (ret == 0) { - msg.node.tokens = res.tokens; - fcacheentry2xfsnode (fid, &real_fid, - &status, &msg.node, ae); - } + do { + res = cm_open (fid, &ce, h->tokens, &cache_handle, + msg.cache_name, sizeof(msg.cache_name)); + if (res.res) + ret = res.error; + else + ret = res.res; + } while (try_again (&ret, &ce, &h->cred, fid)); + if (ret == 0) { + msg.cache_handle = cache_handle.xfs_handle; + msg.flag = 0; + if (cache_handle.valid) + msg.flag |= XFS_ID_HANDLE_VALID; + msg.node.tokens = res.tokens; + fcacheentry2xfsnode (fid, &real_fid, + &status, &msg.node, ae, + FCACHE2XFSNODE_ALL); + } } } @@ -1707,10 +1848,6 @@ break_callback (FCacheEntry *entry) assert (entry->flags.kernelp); - entry->flags.kernelp = FALSE; - entry->flags.attrusedp = FALSE; - entry->flags.datausedp = FALSE; - msg.header.opcode = XFS_MSG_INVALIDNODE; memcpy (&msg.handle, &entry->fid, sizeof(entry->fid)); ret = xfs_message_send (kernel_fd, (struct xfs_message_header *)&msg, @@ -1735,13 +1872,14 @@ break_callback (FCacheEntry *entry) */ void -install_attr (FCacheEntry *e) +install_attr (FCacheEntry *e, int flags) { struct xfs_message_installattr msg; + memset (&msg, 0, sizeof(msg)); msg.header.opcode = XFS_MSG_INSTALLATTR; fcacheentry2xfsnode (&e->fid, fcache_realfid(e), &e->status, &msg.node, - e->acccache); + e->acccache, flags); msg.node.tokens = e->tokens; if (!e->flags.datausedp) msg.node.tokens &= ~XFS_DATA_MASK; @@ -1922,7 +2060,7 @@ viocsetacl(int fd, struct xfs_message_pioctl *h, u_int size) } while (try_again (&error, &ce, &h->cred, &fid)); if (error == 0) { - install_attr (e); + install_attr (e, FCACHE2XFSNODE_ALL); fcache_release (e); } else if (error != EACCES) error = EINVAL; @@ -2103,13 +2241,19 @@ get_mount_point (VenusFid fid, FCacheEntry **ret_mp_entry) { FCacheEntry *mp_entry; + FCacheEntry *dentry; VenusFid mp_fid; int error; if (fid.fid.Volume == 0 && fid.fid.Vnode == 0 && fid.fid.Unique == 0) return EINVAL; - error = adir_lookup(&fid, filename, &mp_fid, NULL, ce); + error = fcache_get_data(&dentry, &fid, ce); + if (error) + return error; + + error = adir_lookup(dentry, filename, &mp_fid); + fcache_release(dentry); if (error) return error; @@ -2459,10 +2603,13 @@ vioc_new_cell(int fd, struct xfs_message_pioctl *h, u_int size) if (dbs == NULL) return xfs_send_message_wakeup (fd, h->header.sequence_num, ENOMEM); + memset(dbs, 0, count * sizeof(*dbs)); + hp = (u_int32_t *)h->msg; for (i = 0; i < count; ++i) { dbs[i].name = NULL; dbs[i].addr.s_addr = hp[i]; + dbs[i].timeout = 0; } cellname = h->msg + 8 * sizeof(u_int32_t); @@ -2641,7 +2788,7 @@ viocsettok (int fd, struct xfs_message_pioctl *h, u_int size) if (cell == -1) return ENOENT; - conn_clearcred (cell, h->cred.pag, 2); + conn_clearcred (CONN_CS_ALL, cell, h->cred.pag, 2); fcache_purge_cred(h->cred.pag, cell); cred_add (h->cred.pag, CRED_KRB4, 2, cell, ct.EndTimestamp, &c, sizeof(c), ct.ViceId); @@ -2722,7 +2869,9 @@ viocconnect(int fd, struct xfs_message_pioctl *h, u_int size) DARLA_Close(&log_data); Log_is_open = 0; +#if 0 do_replay("discon_log", log_data.log_entries, 0); +#endif } if (connected_mode == DISCONNECTED) { connected_mode = CONNECTED ; @@ -2793,6 +2942,8 @@ setrxkcrypt(int fd, struct xfs_message_pioctl *h, u_int size) conn_rxkad_level = rxkad_crypt; else error = EINVAL; + if (error == 0) + conn_clearcred (CONN_CS_NONE, 0, -1, -1); } else error = EINVAL; return error; @@ -3048,6 +3199,8 @@ viocgetcacheparms (int fd, struct xfs_message_pioctl *h, u_int size) parms[3] = fcache_usedvnodes(); parms[4] = fcache_highbytes(); parms[5] = fcache_usedbytes(); + parms[6] = fcache_lowbytes(); + parms[7] = fcache_lowvnodes(); h->outsize = sizeof(parms); return xfs_send_message_wakeup_data(fd, h->header.sequence_num, 0, @@ -3184,6 +3337,118 @@ vioc_breakcallback(int fd, struct xfs_message_pioctl *h, u_int size) } /* + * check volume mappings + */ + +static int +statistics_hostpart(int fd, struct xfs_message_pioctl *h, u_int size) +{ + u_int32_t host[100]; + u_int32_t part[100]; + u_int32_t outparms[512]; + int n; + int outsize; + int maxslots; + int i; + + if (h->outsize < sizeof(u_int32_t)) + return xfs_send_message_wakeup (fd, h->header.sequence_num, + EINVAL); + + n = 100; + collectstats_hostpart(host, part, &n); + maxslots = (h->outsize / sizeof(u_int32_t) - 1) / 2; + if (n > maxslots) + n = maxslots; + + outsize = (n * 2 + 1) * sizeof(u_int32_t); + + outparms[0] = n; + for (i = 0; i < n; i++) { + outparms[i*2 + 1] = host[i]; + outparms[i*2 + 2] = part[i]; + } + + return xfs_send_message_wakeup_data (fd, h->header.sequence_num, 0, + (char *) &outparms, outsize); +} + +static int +statistics_entry(int fd, struct xfs_message_pioctl *h, u_int size) +{ + u_int32_t *request = (u_int32_t *) h->msg; + u_int32_t host; + u_int32_t part; + u_int32_t type; + u_int32_t items_slot; + u_int32_t count[32]; + int64_t items_total[32]; + int64_t total_time[32]; + u_int32_t outparms[160]; + int i; + int j; + + if (h->insize < sizeof(u_int32_t) * 5) { + return xfs_send_message_wakeup (fd, h->header.sequence_num, + EINVAL); + } + + if (h->outsize < sizeof(u_int32_t) * 160) { + return xfs_send_message_wakeup (fd, h->header.sequence_num, + EINVAL); + } + + host = request[1]; + part = request[2]; + type = request[3]; + items_slot = request[4]; + + collectstats_getentry(host, part, type, items_slot, + count, items_total, total_time); + + j = 0; + for (i = 0; i < 32; i++) { + outparms[j++] = count[i]; + } + for (i = 0; i < 32; i++) { + memcpy(&outparms[j], &items_total[i], 8); + j+=2; + } + for (i = 0; i < 32; i++) { + memcpy(&outparms[j], &total_time[i], 8); + j+=2; + } + return xfs_send_message_wakeup_data (fd, h->header.sequence_num, 0, + (char *) &outparms, sizeof(outparms)); +} + +static int +aioc_statistics(int fd, struct xfs_message_pioctl *h, u_int size) +{ + u_int32_t opcode; + + if (!all_powerful_p (&h->cred)) + return xfs_send_message_wakeup (fd, h->header.sequence_num, + EPERM); + + if (h->insize < sizeof(u_int32_t)) + return xfs_send_message_wakeup (fd, h->header.sequence_num, + EPERM); + + opcode = *((int32_t *)h->msg); + + if (opcode == 0) { + return statistics_hostpart(fd, h, size); + } else if (opcode == 1) { + return statistics_entry(fd, h, size); + } else { + return xfs_send_message_wakeup (fd, h->header.sequence_num, + EINVAL); + } +} + + +/* * Handle a pioctl message in `h' */ @@ -3451,6 +3716,22 @@ xfs_message_pioctl (int fd, struct xfs_message_pioctl *h, u_int size) #endif error = vioc_breakcallback (fd, h, size); break; +#ifdef VIOCCKBACK_32 + case VIOCCKBACK_32 : + case VIOCCKBACK_64 : +#else + case VIOCCKBACK : +#endif + break; + +#ifdef VIOCCKBACK_32 + case AIOC_STATISTICS_32: + case AIOC_STATISTICS_64: +#else + case AIOC_STATISTICS: +#endif + return aioc_statistics (fd, h, size); + default: arla_warnx (ADEBMSG, "unknown pioctl call %d", h->opcode); error = EINVAL ; diff --git a/usr.sbin/afs/src/arlad/messages.h b/usr.sbin/afs/src/arlad/messages.h index 868e65729c3..893bebbd9a7 100644 --- a/usr.sbin/afs/src/arlad/messages.h +++ b/usr.sbin/afs/src/arlad/messages.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ * */ -/* $Id: messages.h,v 1.3 2000/09/11 14:40:43 art Exp $ */ +/* $KTH: messages.h,v 1.17 2001/01/07 18:32:49 lha Exp $ */ #ifndef _MESSAGES_H_ #define _MESSAGES_H_ @@ -48,7 +43,7 @@ void xfs_message_init (void); int xfs_message_receive (int fd, struct xfs_message_header *h, u_int size); void break_callback (FCacheEntry *e); -void install_attr (FCacheEntry *e); +void install_attr (FCacheEntry *e, int flags); long afsfid2inode(const VenusFid *fid); @@ -60,12 +55,18 @@ void update_fid(VenusFid oldfid, FCacheEntry *old_entry, VenusFid newfid, FCacheEntry *new_entry); +enum { FCACHE2XFSNODE_ATTR = 1, + FCACHE2XFSNODE_RIGHT = 2 } ; + +#define FCACHE2XFSNODE_ALL (FCACHE2XFSNODE_ATTR|FCACHE2XFSNODE_RIGHT) + void fcacheentry2xfsnode (const VenusFid *fid, const VenusFid *statfid, AFSFetchStatus *status, struct xfs_msg_node *node, - AccessEntry *ae); + AccessEntry *ae, + int flags); int VenusFid_cmp (const VenusFid *fid1, const VenusFid *fid2); diff --git a/usr.sbin/afs/src/arlad/reconnect.c b/usr.sbin/afs/src/arlad/reconnect.c index f5cd1d2e1bb..4c4805bc55e 100644 --- a/usr.sbin/afs/src/arlad/reconnect.c +++ b/usr.sbin/afs/src/arlad/reconnect.c @@ -31,9 +31,11 @@ * Do merging of the files that changed with we was in disconnected mode */ +#if 0 + #include "arla_local.h" -RCSID("$Id: reconnect.c,v 1.2 2000/09/11 14:40:43 art Exp $"); +RCSID("$KTH: reconnect.c,v 1.30.2.1 2001/06/04 22:16:39 ahltorp Exp $"); static int reconnect_nonmute(struct vcache *, int, struct timeval); static int reconnect_putattr(struct vcache *, struct xfs_attr *); @@ -797,7 +799,7 @@ int reconnect_remove(struct vcache *vcp, FCacheEntry *childentry, char *name) AFSFetchStatus status; AFSVolSync volsync; char tmp[2 * sizeof(int) + 2]; - xfs_cache_handle cache_handle; + fcache_cache_handle cache_handle; fid = &(vcp->fid); /* points to the VenusFid structure */ fid = fid_translate(fid); @@ -822,7 +824,7 @@ int reconnect_remove(struct vcache *vcp, FCacheEntry *childentry, char *name) if (isupdate) { - xfs_cache_handle cache_handle; + fcache_cache_handle cache_handle; arla_log(ADEBDISCONN, "reconnect_remove: can't remove because file modified!"); @@ -838,7 +840,7 @@ int reconnect_remove(struct vcache *vcp, FCacheEntry *childentry, char *name) res.res = 0; - assert (CheckLock(&fce->lock) == -1); + AssertExclLocked(&fce->lock); conn = find_first_fs (fce, ce, &context); if (conn == NULL) { @@ -915,7 +917,7 @@ reconnect_rmdir(struct vcache *vcp, FCacheEntry *childEntry, char *name) char tmp[2 * sizeof(int) + 2]; int ret = 0; Result tempres; - xfs_cache_handle cache_handle; + fcache_cache_handle cache_handle; ConnCacheEntry *conn; fs_server_context context; @@ -931,7 +933,7 @@ reconnect_rmdir(struct vcache *vcp, FCacheEntry *childEntry, char *name) ce = cred_get (fid->Cell, vcp->cred.pag, CRED_ANY); assert (ce != NULL); - assert (CheckLock(&fce->lock) == -1); + AssertExclLocked(&fce->lock); conn = find_first_fs (fce, ce, &context); if (conn == NULL) { @@ -1001,7 +1003,7 @@ reconnect_mut_chk(FCacheEntry *fce, CredCacheEntry *ce, int version) AFSCallBack callback; AFSVolSync volsync; - assert (CheckLock (&fetched.lock) == -1); + AssertExclLocked(&fetched.lock); /*SWW Aug 01: >= is changed into > */ conn = find_first_fs (&fetched, ce, &context); @@ -1105,7 +1107,7 @@ reconnect_mut_newfile(FCacheEntry **fcep, xfs_pag_t cred,VenusFid *new_fid) VenusFid newfid; int ret; int from, to; - xfs_cache_handle cache_handle; + fcache_cache_handle cache_handle; ret = fcache_find (&parent_fce, (*fcep)->parent); assert (ret == 0); @@ -1376,7 +1378,7 @@ reconnect_putdata(struct vcache *vcp) #endif /* code taken from write_data XXX join */ - assert (CheckLock(&fce->lock) == -1); + AssertExclLocked(&fce->lock); conn = find_first_fs (fce, ce, &context); if (conn == NULL) { @@ -1477,7 +1479,7 @@ int reconnect_rename(struct vcache *vcp_old, struct vcache *vcp_new, fs_server_context context; AFSFetchStatus orig_status, new_status; AFSVolSync volsync; - xfs_cache_handle cache_handle; + fcache_cache_handle cache_handle; fid_old = &vcp_old->fid; fid_old = fid_translate(fid_old); @@ -1528,8 +1530,8 @@ int reconnect_rename(struct vcache *vcp_old, struct vcache *vcp_new, ce = cred_get (vcp_old->fid.Cell, vcp_old->cred.pag, CRED_ANY); assert (ce != NULL); - assert (CheckLock(&fce_old->lock) == -1 - && CheckLock(&fce_new->lock) == -1); + AssertExclLocked(&fce_old->lock); + AssertExclLocked(&fce_new->lock); conn = find_first_fs (fce_old, ce, &context); if (conn == NULL) { @@ -1698,7 +1700,7 @@ int reconnect_create(struct vcache *parent, struct vcache *child, char *name) AFSVolSync volsync; int ret; char tmp[2 * sizeof(int) + 2]; - xfs_cache_handle cache_handle; + fcache_cache_handle cache_handle; int32_t type; parent_fid = &(parent->fid); /* points to the VenusFid structure */ @@ -1914,7 +1916,7 @@ int reconnect_mkdir(struct vcache *parent, struct vcache *curdir, AFSFetchStatus status; AFSCallBack callback; AFSVolSync volsync; - xfs_cache_handle cache_handle; + fcache_cache_handle cache_handle; int32_t type; parent_fid = &(parent->fid); /* points to the VenusFid structure */ @@ -2050,7 +2052,7 @@ int reconnect_link(struct vcache *parent, struct vcache *existing, AFSFetchStatus new_status; AFSFetchStatus status; AFSVolSync volsync; - xfs_cache_handle cache_handle; + fcache_cache_handle cache_handle; parent_fid = &(parent->fid); @@ -2124,7 +2126,7 @@ int reconnect_symlink(struct vcache *parent, struct vcache *child, AFSFetchStatus fetch_attr, new_status; AFSVolSync volsync; - xfs_cache_handle cache_handle; + fcache_cache_handle cache_handle; int32_t type; parent_fid = &(parent->fid); @@ -2204,3 +2206,4 @@ int reconnect_symlink(struct vcache *parent, struct vcache *child, return ret; } +#endif diff --git a/usr.sbin/afs/src/arlad/reconnect.h b/usr.sbin/afs/src/arlad/reconnect.h index 674a1b46816..5698517e0c8 100644 --- a/usr.sbin/afs/src/arlad/reconnect.h +++ b/usr.sbin/afs/src/arlad/reconnect.h @@ -27,7 +27,7 @@ * SUCH DAMAGES. */ -/* $Id: reconnect.h,v 1.2 2000/09/11 14:40:43 art Exp $ */ +/* $KTH: reconnect.h,v 1.4 1999/05/29 18:43:35 assar Exp $ */ #ifndef _RECONNECT_H #define _RECONNECT_H diff --git a/usr.sbin/afs/src/arlad/service.h b/usr.sbin/afs/src/arlad/service.h index 1d7dae436b0..64517e3fa44 100644 --- a/usr.sbin/afs/src/arlad/service.h +++ b/usr.sbin/afs/src/arlad/service.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: service.h,v 1.3 2000/09/11 14:40:43 art Exp $ */ +/* $KTH: service.h,v 1.11 2000/10/06 23:50:58 lha Exp $ */ /* * Service IDs @@ -50,5 +45,7 @@ #define BOS_SERVICE_ID 1 #define VOTE_SERVICE_ID 50 /* ubik */ #define DISK_SERVICE_ID 51 /* ubik */ +#define KA_AUTHENTICATION_SERVICE 731 +#define KA_TICKET_GRANTING_SERVICE 732 #define KA_MAINTENANCE_SERVICE_ID 733 /* ka service */ diff --git a/usr.sbin/afs/src/arlad/solaris-subr.c b/usr.sbin/afs/src/arlad/solaris-subr.c index b5d33f5225b..3d6680e7ba1 100644 --- a/usr.sbin/afs/src/arlad/solaris-subr.c +++ b/usr.sbin/afs/src/arlad/solaris-subr.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +32,7 @@ */ #include "arla_local.h" -RCSID("$Id: solaris-subr.c,v 1.1 2000/09/11 14:40:43 art Exp $"); +RCSID("$KTH: solaris-subr.c,v 1.33 2000/10/27 07:44:18 lha Exp $"); static long blocksize = DIRBUF; @@ -76,6 +71,9 @@ write_dirent(VenusFid *fid, const char *name, void *arg) reclen = DIRSIZ(name); + if (reclen > blocksize - 1) + return; + if (args->ptr + reclen > args->buf + blocksize) flushbuf (args); real = (struct dirent64 *)args->ptr; @@ -91,7 +89,7 @@ write_dirent(VenusFid *fid, const char *name, void *arg) Result conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { return conv_dir_sub (e, ce, tokens, cache_handle, cache_name, @@ -104,7 +102,7 @@ conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, int dir_remove_name (FCacheEntry *e, const char *filename, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { int ret; @@ -149,7 +147,7 @@ dir_remove_name (FCacheEntry *e, const char *filename, * than DIRBUF seems safe. */ len = last_dp->d_reclen + dp->d_reclen; - if (len <= DIRBUF) + if (len <= DIRBUF) /* XXX */ last_dp->d_reclen = len; } dp->d_ino = 0; diff --git a/usr.sbin/afs/src/arlad/subr.c b/usr.sbin/afs/src/arlad/subr.c index 1aec0b63e34..298ef8a21ac 100644 --- a/usr.sbin/afs/src/arlad/subr.c +++ b/usr.sbin/afs/src/arlad/subr.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +32,7 @@ */ #include "arla_local.h" -RCSID("$Id: subr.c,v 1.1 2000/09/11 14:40:43 art Exp $"); +RCSID("$KTH: subr.c,v 1.7 2000/10/14 19:58:12 map Exp $"); /* * come up with a good inode number for `name', `fid' in `parent' @@ -71,7 +66,7 @@ dentry2ino (const char *name, const VenusFid *fid, const FCacheEntry *parent) Result conv_dir_sub (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz, fdir_readdir_func func, void (*flush_func)(void *), diff --git a/usr.sbin/afs/src/arlad/subr.h b/usr.sbin/afs/src/arlad/subr.h index 8f8134af6a6..47bd0bbafd4 100644 --- a/usr.sbin/afs/src/arlad/subr.h +++ b/usr.sbin/afs/src/arlad/subr.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ * Header with prototypes for OS-specific functions. */ -/* $Id: subr.h,v 1.3 2000/09/11 14:40:43 art Exp $ */ +/* $KTH: subr.h,v 1.11 2000/10/14 19:58:13 map Exp $ */ #ifndef _SUBR_H_ #define _SUBR_H_ @@ -66,11 +61,11 @@ dentry2ino (const char *name, const VenusFid *fid, const FCacheEntry *parent); Result conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, - xfs_cache_handle *, char *, size_t); + fcache_cache_handle *, char *, size_t); Result conv_dir_sub (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz, fdir_readdir_func func, void (*flush_func)(void *), @@ -78,7 +73,7 @@ conv_dir_sub (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, int dir_remove_name (FCacheEntry *e, const char *filename, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz); #endif /* _SUBR_H_ */ diff --git a/usr.sbin/afs/src/arlad/sunos-subr.c b/usr.sbin/afs/src/arlad/sunos-subr.c index f95d763d151..59d3ba77be3 100644 --- a/usr.sbin/afs/src/arlad/sunos-subr.c +++ b/usr.sbin/afs/src/arlad/sunos-subr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1996, 1997, 1998, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,8 +31,9 @@ * SUCH DAMAGE. */ +#define _KERNEL #include "arla_local.h" -RCSID("$Id: sunos-subr.c,v 1.1 2000/09/11 14:40:43 art Exp $"); +RCSID("$KTH: sunos-subr.c,v 1.30 2000/10/14 19:58:14 map Exp $"); static long blocksize = 1024; /* XXX */ @@ -81,7 +77,7 @@ write_dirent(VenusFid *fid, const char *name, void *arg) Result conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { return conv_dir_sub (e, ce, tokens, cache_handle, cache_name, @@ -94,7 +90,7 @@ conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, int dir_remove_name (FCacheEntry *e, const char *filename, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { int ret; diff --git a/usr.sbin/afs/src/arlad/unknown-subr.c b/usr.sbin/afs/src/arlad/unknown-subr.c index e4e0fa78801..b782f05b17e 100644 --- a/usr.sbin/afs/src/arlad/unknown-subr.c +++ b/usr.sbin/afs/src/arlad/unknown-subr.c @@ -14,11 +14,6 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * * 4. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. @@ -37,11 +32,11 @@ */ #include "arla_local.h" -RCSID("$Id: unknown-subr.c,v 1.1 2000/09/11 14:40:43 art Exp $"); +RCSID("$KTH: unknown-subr.c,v 1.9 2000/10/14 19:58:15 map Exp $"); int dir_remove_name (FCacheEntry *e, const char *filename, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { return 0; @@ -50,7 +45,7 @@ dir_remove_name (FCacheEntry *e, const char *filename, Result conv_dir (FCacheEntry *e, CredCacheEntry *ce, u_int tokens, - xfs_cache_handle *cache_handle, + fcache_cache_handle *cache_handle, char *cache_name, size_t cache_name_sz) { Result res; diff --git a/usr.sbin/afs/src/arlad/volcache.c b/usr.sbin/afs/src/arlad/volcache.c index a63fa3b67ba..dd5ff49fae5 100644 --- a/usr.sbin/afs/src/arlad/volcache.c +++ b/usr.sbin/afs/src/arlad/volcache.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -41,17 +36,7 @@ */ #include "arla_local.h" -RCSID("$Id: volcache.c,v 1.3 2000/09/11 14:40:43 art Exp $") ; - -/* - * Suffixes for volume names. - */ - -static char *volsuffixes[] = { -"", -ROSUFFIX, -BACKSUFFIX -}; +RCSID("$KTH: volcache.c,v 1.95.2.4 2001/03/04 05:11:19 lha Exp $") ; static const char *root_volume_name = "root.afs"; @@ -208,11 +193,11 @@ create_new_entries (unsigned n) } /* - * re-use `e' if we can. + * mark as not being in use */ static void -try_reuse (VolCacheEntry *e) +mark_unused (VolCacheEntry *e) { if (e->refcount == 0 && e->vol_refs == 0) { listdel (lrulist, e->li); @@ -220,10 +205,6 @@ try_reuse (VolCacheEntry *e) assert (nactive_volcacheentries > 0); assert (nactive_volcacheentries <= nvolcacheentries); --nactive_volcacheentries; - if (e->parent != NULL) { - volcache_volfree (e->parent); - e->parent = NULL; - } } } @@ -239,12 +220,11 @@ recycle_entry (VolCacheEntry *e) assert (e->refcount == 0 && e->vol_refs == 0); - for (i = 0; i < MAXTYPES; ++i) { + for (i = 0; i < MAXTYPES; ++i) if (e->num_ptr[i].ptr != NULL) hashtabdel (volidhashtab, &e->num_ptr[i]); - if (e->name_ptr[i].ptr != NULL) - hashtabdel (volnamehashtab, &e->name_ptr[i]); - } + if (e->name_ptr.ptr != NULL) + hashtabdel (volnamehashtab, &e->name_ptr); if (e->parent) { volcache_volfree (e->parent); e->parent = NULL; @@ -341,8 +321,6 @@ getbyname (const char *volname, int32_t cell, int *type) n = (struct name_ptr *)hashtabsearch (volnamehashtab, (void *)&key); if (n == NULL) return NULL; - if (type != NULL) - *type = n->type; return n->ptr; } @@ -393,13 +371,15 @@ volcache_recover_state (void) e->mp_fid = tmp.mp_fid; e->parent_fid = tmp.parent_fid; e->parent = NULL; + if (tmp.name_ptr.ptr != NULL) { + e->name_ptr.cell = tmp.name_ptr.cell; + strlcpy (e->name_ptr.name, tmp.name_ptr.name, + sizeof(e->name_ptr.name)); + e->name_ptr.ptr = e; + hashtabadd (volnamehashtab, (void *)&e->name_ptr); + } + for (i = 0; i < MAXTYPES; ++i) { - if (tmp.name_ptr[i].ptr != NULL) { - e->name_ptr[i].cell = tmp.name_ptr[i].cell; - strcpy (e->name_ptr[i].name, tmp.name_ptr[i].name); - e->name_ptr[i].ptr = e; - hashtabadd (volnamehashtab, (void *)&e->name_ptr[i]); - } if (tmp.num_ptr[i].ptr != NULL) { e->num_ptr[i].cell = tmp.num_ptr[i].cell; e->num_ptr[i].vol = tmp.num_ptr[i].vol; @@ -507,7 +487,6 @@ static void add_clone (VolCacheEntry *e, int type, int suffix_type) { struct num_ptr *num_ptr = &e->num_ptr[type]; - struct name_ptr *name_ptr = &e->name_ptr[suffix_type]; if (type == suffix_type) { num_ptr->cell = e->cell; @@ -516,13 +495,6 @@ add_clone (VolCacheEntry *e, int type, int suffix_type) num_ptr->type = type; hashtabadd (volidhashtab, (void *) num_ptr); } - - name_ptr->cell = e->cell; - snprintf (name_ptr->name, VLDB_MAXNAMELEN, - "%s%s", e->entry.name, volsuffixes[suffix_type]); - name_ptr->ptr = e; - name_ptr->type = type; - hashtabadd (volnamehashtab, (void *) name_ptr); } /* @@ -532,6 +504,11 @@ add_clone (VolCacheEntry *e, int type, int suffix_type) static void add_to_hashtab (VolCacheEntry *e) { + e->name_ptr.cell = e->cell; + strlcpy (e->name_ptr.name, e->entry.name, sizeof(e->name_ptr.name)); + e->name_ptr.ptr = e; + hashtabadd (volnamehashtab, (void *)&e->name_ptr); + if (e->entry.flags & VLF_RWEXISTS) add_clone (e, RWVOL, RWVOL); else @@ -650,8 +627,6 @@ get_info_loop (VolCacheEntry *e, const char *name, int32_t cell, } else error = VL_GetEntryByNameN (conns[i]->connection, name, &e->entry); - if (error == RX_CALL_DEAD) - conn_dead (conns[i]); switch (error) { case 0 : sanitize_nvldbentry (&e->entry); @@ -666,6 +641,10 @@ get_info_loop (VolCacheEntry *e, const char *name, int32_t cell, case RXKADEXPIRED : try_again = FALSE; break; + case RXKADSEALEDINCON: + case RXKADUNKNOWNKEY: + try_again = FALSE; + break; #endif case RXGEN_OPCODE: if (conns[i]->flags.old == FALSE) { @@ -674,6 +653,8 @@ get_info_loop (VolCacheEntry *e, const char *name, int32_t cell, } break; default : + if (host_downp(error)) + conn_dead (conns[i]); arla_warn (ADEBVOLCACHE, error, "VL_GetEntryByName%s(%s)", conns[i]->flags.old ? "" : "N", @@ -728,53 +709,29 @@ get_info_byname (VolCacheEntry *e, const char *volname, int32_t cell, CredCacheEntry *ce) { int error; - int i; - size_t entry_name_len; - int name_matched; error = get_info_loop (e, volname, cell, ce); if (error) return error; - entry_name_len = strlen(e->entry.name); - name_matched = FALSE; - - for (i = 0; i < MAXTYPES; ++i) { - if (strncmp (volname, e->entry.name, entry_name_len) == 0 - && strcmp (volname + entry_name_len, volsuffixes[i]) == 0) { - name_matched = TRUE; - break; - } - } - /* * If the name we looked up is different from the one we got back, * replace that one with the canonical looked up name. Otherwise, * we're not going to be able to find the volume in question. */ - if (!name_matched) { - size_t volname_len = strlen(volname); - + if (strcmp(volname, e->entry.name) != 0) { arla_warnx (ADEBWARN, "get_info: different volnames: %s - %s", volname, e->entry.name); - for (i = MAXTYPES - 1; i >= 0; --i) - if (strcmp (volname + volname_len - strlen(volsuffixes[i]), - volsuffixes[i]) == 0) { - volname_len -= strlen(volsuffixes[i]); - break; - } - - if (volname_len >= sizeof(e->entry.name)) { + if (strlcpy (e->entry.name, volname, + sizeof(e->entry.name)) >= sizeof(e->entry.name)) { arla_warnx (ADEBWARN, "get_info: too long volume (%.*s)", - volname_len, volname); + (int)strlen(volname), volname); return ENAMETOOLONG; } - memmove (e->entry.name, volname, volname_len); - e->entry.name[volname_len] = '\0'; } return get_info_common (e); @@ -840,27 +797,29 @@ volcache_getbyname (const char *volname, int32_t cell, CredCacheEntry *ce, VolCacheEntry **e, int *type) { int error = 0; + char real_volname[VLDB_MAXNAMELEN]; + + strlcpy (real_volname, volname, sizeof(real_volname)); + *type = volname_canonicalize (real_volname); for(;;) { - *e = getbyname (volname, cell, type); + *e = getbyname (real_volname, cell, type); if (*e == NULL) { - error = add_entry_byname (e, volname, cell, ce); + error = add_entry_byname (e, real_volname, cell, ce); if (error) return error; continue; } - if ((*e)->refcount == 0) - ++nactive_volcacheentries; - ++(*e)->refcount; + + volcache_ref (*e); if (volume_uptodatep (*e)) { return 0; } else { VolCacheEntry tmp_ve; - error = get_info_byname (&tmp_ve, volname, cell, ce); + error = get_info_byname (&tmp_ve, real_volname, cell, ce); if (error) { - --(*e)->refcount; - try_reuse (*e); + volcache_free (*e); return error; } (*e)->flags.stablep = cmp_nvldbentry (&tmp_ve.entry, @@ -889,9 +848,7 @@ volcache_getbyid (u_int32_t volid, int32_t cell, CredCacheEntry *ce, return error; continue; } - if ((*e)->refcount == 0) - ++nactive_volcacheentries; - ++(*e)->refcount; + volcache_ref(*e); if (volume_uptodatep (*e)) { return 0; } else { @@ -899,8 +856,7 @@ volcache_getbyid (u_int32_t volid, int32_t cell, CredCacheEntry *ce, error = get_info_byid (&tmp_ve, volid, cell, ce); if (error) { - --(*e)->refcount; - try_reuse (*e); + volcache_free(*e); return error; } (*e)->flags.stablep = cmp_nvldbentry (&tmp_ve.entry, @@ -983,6 +939,18 @@ volcache_update_volsync (VolCacheEntry *e, AFSVolSync volsync) } /* + * Increment the references to `e' + */ + +void +volcache_ref (VolCacheEntry *e) +{ + if (e->refcount == 0 && e->vol_refs == 0) + ++nactive_volcacheentries; + ++e->refcount; +} + +/* * Decrement the references and possibly remove this entry. */ @@ -990,7 +958,7 @@ void volcache_free (VolCacheEntry *e) { --e->refcount; - try_reuse (e); + mark_unused (e); } /* @@ -1003,6 +971,8 @@ void volcache_volref (VolCacheEntry *e, VolCacheEntry *parent) { if (e->parent == NULL) { + if (parent->refcount == 0 && parent->vol_refs == 0) + ++nactive_volcacheentries; ++parent->vol_refs; e->parent = parent; } @@ -1016,7 +986,7 @@ void volcache_volfree (VolCacheEntry *e) { --e->vol_refs; - try_reuse (e); + mark_unused (e); } /* @@ -1072,18 +1042,21 @@ volume_make_uptodate (VolCacheEntry *e, CredCacheEntry *ce) } /* - * Return a name for a volume (or NULL if it doesn't seem to exist). + * Get a name for a volume in (name, name_sz). + * Return 0 if succesful */ -const char * -volcache_getname (u_int32_t id, int32_t cell) +int +volcache_getname (u_int32_t id, int32_t cell, + char *name, size_t name_sz) { int type; VolCacheEntry *e = getbyid (id, cell, &type); if (e == NULL) - return NULL; - return e->name_ptr[type].name; + return -1; + volname_specific (e->name_ptr.name, type, name, name_sz); + return 0; } /* diff --git a/usr.sbin/afs/src/arlad/volcache.h b/usr.sbin/afs/src/arlad/volcache.h index 297e1f4133b..d923587ebca 100644 --- a/usr.sbin/afs/src/arlad/volcache.h +++ b/usr.sbin/afs/src/arlad/volcache.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -40,7 +35,7 @@ * Our cache of volume information. */ -/* $Id: volcache.h,v 1.3 2000/09/11 14:40:44 art Exp $ */ +/* $KTH: volcache.h,v 1.28.2.2 2001/02/12 12:53:02 assar Exp $ */ #ifndef _VOLCACHE_ #define _VOLCACHE_ @@ -50,9 +45,6 @@ #include <list.h> #include "vldb.h" -#define BACKSUFFIX ".backup" -#define ROSUFFIX ".readonly" - /* * index for number into a VolCacheEntry */ @@ -72,7 +64,6 @@ struct name_ptr { int32_t cell; char name[VLDB_MAXNAMELEN]; struct volcacheentry *ptr; - int32_t type; }; struct volcacheentry { @@ -90,7 +81,7 @@ struct volcacheentry { unsigned validp : 1; unsigned stablep : 1; } flags; - struct name_ptr name_ptr[MAXTYPES]; + struct name_ptr name_ptr; struct num_ptr num_ptr[MAXTYPES]; }; @@ -108,7 +99,7 @@ typedef struct volcacheentry VolCacheEntry; * current version number of the dump file */ -#define VOLCACHE_VERSION 0x2 +#define VOLCACHE_VERSION 0x3 const char *volcache_get_rootvolume (void); @@ -132,6 +123,8 @@ void volcache_update_volsync (VolCacheEntry *e, AFSVolSync volsync); void volcache_free (VolCacheEntry *e); +void volcache_ref (VolCacheEntry *e); + void volcache_volref (VolCacheEntry *e, VolCacheEntry *parent); void volcache_volfree (VolCacheEntry *e); @@ -144,7 +137,7 @@ int volume_make_uptodate (VolCacheEntry *e, CredCacheEntry *ce); Bool volcache_reliable (u_int32_t id, int32_t cell); -const char *volcache_getname (u_int32_t id, int32_t cell); +int volcache_getname (u_int32_t id, int32_t cell, char *, size_t); void volcache_status (void); diff --git a/usr.sbin/afs/src/arlad/xfs.c b/usr.sbin/afs/src/arlad/xfs.c index a1b45d92ae7..3168df9fb55 100644 --- a/usr.sbin/afs/src/arlad/xfs.c +++ b/usr.sbin/afs/src/arlad/xfs.c @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -38,7 +33,7 @@ #include "arla_local.h" -RCSID("$Id: xfs.c,v 1.1 2000/09/11 14:40:44 art Exp $"); +RCSID("$KTH: xfs.c,v 1.13 2000/10/02 22:33:25 lha Exp $"); /* * Begining of breakout of xfs releated junk diff --git a/usr.sbin/afs/src/arlad/xfs.h b/usr.sbin/afs/src/arlad/xfs.h index 0e0f685ba25..0256931badc 100644 --- a/usr.sbin/afs/src/arlad/xfs.h +++ b/usr.sbin/afs/src/arlad/xfs.h @@ -14,12 +14,7 @@ * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the Kungliga Tekniska - * Högskolan and its contributors. - * - * 4. Neither the name of the Institute nor the names of its contributors + * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -37,7 +32,7 @@ */ /* - * $Id: xfs.h,v 1.1 2000/09/11 14:40:44 art Exp $ + * $KTH: xfs.h,v 1.8 2000/10/02 22:33:30 lha Exp $ */ #ifndef __XFS_H_V |