diff options
author | Cy Schubert <cy@FreeBSD.org> | 2016-08-31 00:08:49 +0000 |
---|---|---|
committer | Cy Schubert <cy@FreeBSD.org> | 2016-08-31 00:08:49 +0000 |
commit | ca57057f598bfc7119f79f71bf38ec88244ab396 (patch) | |
tree | 051f78ef258707b493cc7cb21569b6949915f6c7 /libamu | |
parent | e66b16bf080ead1c51f321eaf56710c771778706 (diff) | |
download | src-vendor/amd.tar.gz src-vendor/amd.zip |
Import am-utils 6.2,vendor/amd/6.2vendor/amd
Suggested by: pfg@
Obtained from: ftp://ftp.am-utils.org/pub/am-utils/
Notes
Notes:
svn path=/vendor/amd/dist/; revision=305100
svn path=/vendor/amd/6.2/; revision=305101; tag=vendor/amd/6.2
Diffstat (limited to 'libamu')
-rw-r--r-- | libamu/Makefile.am | 88 | ||||
-rw-r--r-- | libamu/Makefile.in | 732 | ||||
-rw-r--r-- | libamu/alloca.c | 504 | ||||
-rw-r--r-- | libamu/amu.h | 13 | ||||
-rw-r--r-- | libamu/clnt_sperrno.c | 13 | ||||
-rw-r--r-- | libamu/hasmntopt.c | 12 | ||||
-rw-r--r-- | libamu/memcmp.c | 67 | ||||
-rw-r--r-- | libamu/misc_rpc.c | 8 | ||||
-rw-r--r-- | libamu/mount_fs.c | 1097 | ||||
-rw-r--r-- | libamu/mtab.c | 12 | ||||
-rw-r--r-- | libamu/nfs_prot_xdr.c | 19 | ||||
-rw-r--r-- | libamu/strcasecmp.c | 59 | ||||
-rw-r--r-- | libamu/strerror.c | 10 | ||||
-rw-r--r-- | libamu/strlcat.c | 83 | ||||
-rw-r--r-- | libamu/strlcpy.c | 80 | ||||
-rw-r--r-- | libamu/strstr.c | 93 | ||||
-rw-r--r-- | libamu/strutil.c | 42 | ||||
-rw-r--r-- | libamu/ualarm.c | 68 | ||||
-rw-r--r-- | libamu/wire.c | 19 | ||||
-rw-r--r-- | libamu/xdr_func.c | 2057 | ||||
-rw-r--r-- | libamu/xutil.c | 192 |
21 files changed, 4297 insertions, 971 deletions
diff --git a/libamu/Makefile.am b/libamu/Makefile.am new file mode 100644 index 000000000000..08e58d694c96 --- /dev/null +++ b/libamu/Makefile.am @@ -0,0 +1,88 @@ +## Process this file with automake to produce Makefile.in + +# Package: am-utils +# Level: Makefile for libamu/ directory +# Author: Erez Zadok + +#noinst_LIBRARIES = libamu.a +lib_LTLIBRARIES = libamu.la + +# headers this depends on, not to be installed +noinst_HEADERS = amu.h + +# these sources must be included: +libamu_la_SOURCES = \ + misc_rpc.c \ + mount_fs.c \ + mtab.c \ + nfs_prot_xdr.c \ + strutil.c \ + wire.c \ + xdr_func.c \ + xutil.c + +## no need to list other optional sources because automake will add them +## automatically. +## XXX: must add the files after memcmp.c until automake 1.4+ is out +EXTRA_DIST = memcmp.c \ + clnt_sperrno.c \ + hasmntopt.c \ + strcasecmp.c \ + strerror.c \ + strlcat.c \ + strlcpy.c \ + strstr.c \ + ualarm.c + +DISTCLEANFILES = mountutil.c mtabutil.c transputil.c umount_fs.c + +# these may be added automatically by automake if needed: +# alloca.c +# clnt_sperrno.c +# hasmntopt.c +# memcmp.c (via AC_FUNC_MEMCMP) +# strcasecmp.c +# strerror.c +# strstr.c +# ualarm.c +# +# files optionally compiled: +# mountutil.c: mount utilities +# umount_fs.c: un-mount utilities +# +# files that are always compiled, but to a different path: +# mtabutil.c: mount table utilities +# transputil.c: transport (Sockets or TLI) utilities +BUILT_SOURCES = \ + mountutil.c \ + umount_fs.c \ + mtabutil.c \ + transputil.c + +## XXX: Use the next line when automake newer than 1.4 +## XXX: Instead of the two lines that follow. +## libamu_la_LIBADD = @LTLIBOBJS@ @LTALLOCA@ +libamu_la_LIBADD = @AMU_LIB_OBJS@ +libamu_la_DEPENDENCIES = @AMU_LIB_OBJS@ + + +# LDFLAGS should include standard ones plus LIBTOOL ones +AM_LDFLAGS = @LDFLAGS@ @LIBTOOL_LDFLAGS@ + +AM_CPPFLAGS = -I$(top_srcdir)/include + +# allow users to add their own flags via "configure --enable-am-flags=ARG" +AMU_CFLAGS = @AMU_CFLAGS@ +AM_CFLAGS = $(AMU_CFLAGS) + +# dependencies +$(libamu_la_OBJECTS) $(libamu_la_LIBADD): \ + ../config.h \ + ../aux_conf.h \ + $(top_srcdir)/include/am_compat.h \ + $(top_srcdir)/include/am_defs.h \ + $(top_srcdir)/include/am_utils.h \ + $(top_srcdir)/include/am_xdr_func.h \ + $(top_srcdir)/include/amq_defs.h \ + @AMU_NFS_PROT_HEADER@ \ + $(noinst_HEADERS) diff --git a/libamu/Makefile.in b/libamu/Makefile.in new file mode 100644 index 000000000000..ec213a713a6c --- /dev/null +++ b/libamu/Makefile.in @@ -0,0 +1,732 @@ +# Makefile.in generated by automake 1.14.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2013 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +# Package: am-utils +# Level: Makefile for libamu/ directory +# Author: Erez Zadok + + +VPATH = @srcdir@ +am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = libamu +DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ + $(top_srcdir)/mkinstalldirs $(top_srcdir)/depcomp \ + $(noinst_HEADERS) +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 $(top_srcdir)/vers.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(libdir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +am_libamu_la_OBJECTS = misc_rpc.lo mount_fs.lo mtab.lo nfs_prot_xdr.lo \ + strutil.lo wire.lo xdr_func.lo xutil.lo +libamu_la_OBJECTS = $(am_libamu_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +am__v_CC_1 = +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +am__v_CCLD_1 = +SOURCES = $(libamu_la_SOURCES) +DIST_SOURCES = $(libamu_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +HEADERS = $(noinst_HEADERS) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMD_FS_OBJS = @AMD_FS_OBJS@ +AMD_INFO_OBJS = @AMD_INFO_OBJS@ +AMTAR = @AMTAR@ +AMU_AUTOFS_PROT_HEADER = @AMU_AUTOFS_PROT_HEADER@ + +# allow users to add their own flags via "configure --enable-am-flags=ARG" +AMU_CFLAGS = @AMU_CFLAGS@ +AMU_LIB_OBJS = @AMU_LIB_OBJS@ +AMU_NFS_PROT_HEADER = @AMU_NFS_PROT_HEADER@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBTOOL_DEPS = @LIBTOOL_DEPS@ +LIBTOOL_LDFLAGS = @LIBTOOL_LDFLAGS@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +UNMOUNT_PROGRAM = @UNMOUNT_PROGRAM@ +VERSION = @VERSION@ +WRAPLIB = @WRAPLIB@ +YACC = @YACC@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +am_utils_unmount_args = @am_utils_unmount_args@ +am_utils_unmount_call = @am_utils_unmount_call@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ + +#noinst_LIBRARIES = libamu.a +lib_LTLIBRARIES = libamu.la + +# headers this depends on, not to be installed +noinst_HEADERS = amu.h + +# these sources must be included: +libamu_la_SOURCES = \ + misc_rpc.c \ + mount_fs.c \ + mtab.c \ + nfs_prot_xdr.c \ + strutil.c \ + wire.c \ + xdr_func.c \ + xutil.c + +EXTRA_DIST = memcmp.c \ + clnt_sperrno.c \ + hasmntopt.c \ + strcasecmp.c \ + strerror.c \ + strlcat.c \ + strlcpy.c \ + strstr.c \ + ualarm.c + +DISTCLEANFILES = mountutil.c mtabutil.c transputil.c umount_fs.c + +# these may be added automatically by automake if needed: +# alloca.c +# clnt_sperrno.c +# hasmntopt.c +# memcmp.c (via AC_FUNC_MEMCMP) +# strcasecmp.c +# strerror.c +# strstr.c +# ualarm.c +# +# files optionally compiled: +# mountutil.c: mount utilities +# umount_fs.c: un-mount utilities +# +# files that are always compiled, but to a different path: +# mtabutil.c: mount table utilities +# transputil.c: transport (Sockets or TLI) utilities +BUILT_SOURCES = \ + mountutil.c \ + umount_fs.c \ + mtabutil.c \ + transputil.c + +libamu_la_LIBADD = @AMU_LIB_OBJS@ +libamu_la_DEPENDENCIES = @AMU_LIB_OBJS@ + +# LDFLAGS should include standard ones plus LIBTOOL ones +AM_LDFLAGS = @LDFLAGS@ @LIBTOOL_LDFLAGS@ +AM_CPPFLAGS = -I$(top_srcdir)/include +AM_CFLAGS = $(AMU_CFLAGS) +all: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libamu/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu libamu/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libamu.la: $(libamu_la_OBJECTS) $(libamu_la_DEPENDENCIES) $(EXTRA_libamu_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) -rpath $(libdir) $(libamu_la_OBJECTS) $(libamu_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc_rpc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mount_fs.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mtab.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nfs_prot_xdr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strutil.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wire.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xdr_func.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xutil.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-am +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-am + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-am + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: + for dir in "$(DESTDIR)$(libdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) +clean: clean-am + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-libLTLIBRARIES + +.MAKE: all check install install-am install-strip + +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \ + ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-libLTLIBRARIES install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES + + +# dependencies +$(libamu_la_OBJECTS) $(libamu_la_LIBADD): \ + ../config.h \ + ../aux_conf.h \ + $(top_srcdir)/include/am_compat.h \ + $(top_srcdir)/include/am_defs.h \ + $(top_srcdir)/include/am_utils.h \ + $(top_srcdir)/include/am_xdr_func.h \ + $(top_srcdir)/include/amq_defs.h \ + @AMU_NFS_PROT_HEADER@ \ + $(noinst_HEADERS) + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libamu/alloca.c b/libamu/alloca.c deleted file mode 100644 index 31fb4e0d4e06..000000000000 --- a/libamu/alloca.c +++ /dev/null @@ -1,504 +0,0 @@ -/* alloca.c -- allocate automatically reclaimed memory - (Mostly) portable public-domain implementation -- D A Gwyn - - This implementation of the PWB library alloca function, - which is used to allocate space off the run-time stack so - that it is automatically reclaimed upon procedure exit, - was inspired by discussions with J. Q. Johnson of Cornell. - J.Otto Tennant <jot@cray.com> contributed the Cray support. - - There are some preprocessor constants that can - be defined when compiling for your specific system, for - improved efficiency; however, the defaults should be okay. - - The general concept of this implementation is to keep - track of all alloca-allocated blocks, and reclaim any - that are found to be deeper in the stack than the current - invocation. This heuristic does not reclaim storage as - soon as it becomes invalid, but it will do so eventually. - - As a special case, alloca(0) reclaims storage without - allocating any. It is a good idea to use alloca(0) in - your main control loop, etc. to force garbage collection. */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#ifdef HAVE_STRING_H -#include <string.h> -#endif -#ifdef HAVE_STDLIB_H -#include <stdlib.h> -#endif - -#ifdef emacs -#include "blockinput.h" -#endif - -/* If compiling with GCC 2, this file's not needed. */ -#if !defined (__GNUC__) || __GNUC__ < 2 - -/* If someone has defined alloca as a macro, - there must be some other way alloca is supposed to work. */ -#ifndef alloca - -#ifdef emacs -#ifdef static -/* actually, only want this if static is defined as "" - -- this is for usg, in which emacs must undefine static - in order to make unexec workable - */ -#ifndef STACK_DIRECTION -you -lose --- must know STACK_DIRECTION at compile-time -#endif /* STACK_DIRECTION undefined */ -#endif /* static */ -#endif /* emacs */ - -/* If your stack is a linked list of frames, you have to - provide an "address metric" ADDRESS_FUNCTION macro. */ - -#if defined (CRAY) && defined (CRAY_STACKSEG_END) -long i00afunc (); -#define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg)) -#else -#define ADDRESS_FUNCTION(arg) &(arg) -#endif - -#if __STDC__ -typedef void *pointer; -#else -typedef char *pointer; -#endif - -#ifndef NULL -#define NULL 0 -#endif - -/* Different portions of Emacs need to call different versions of - malloc. The Emacs executable needs alloca to call xmalloc, because - ordinary malloc isn't protected from input signals. On the other - hand, the utilities in lib-src need alloca to call malloc; some of - them are very simple, and don't have an xmalloc routine. - - Non-Emacs programs expect this to call use xmalloc. - - Callers below should use malloc. */ - -#ifndef emacs -#define malloc xmalloc -#endif -extern pointer malloc (); - -/* Define STACK_DIRECTION if you know the direction of stack - growth for your system; otherwise it will be automatically - deduced at run-time. - - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ - -#ifndef STACK_DIRECTION -#define STACK_DIRECTION 0 /* Direction unknown. */ -#endif - -#if STACK_DIRECTION != 0 - -#define STACK_DIR STACK_DIRECTION /* Known at compile-time. */ - -#else /* STACK_DIRECTION == 0; need run-time code. */ - -static int stack_dir; /* 1 or -1 once known. */ -#define STACK_DIR stack_dir - -static void -find_stack_direction () -{ - static char *addr = NULL; /* Address of first `dummy', once known. */ - auto char dummy; /* To get stack address. */ - - if (addr == NULL) - { /* Initial entry. */ - addr = ADDRESS_FUNCTION (dummy); - - find_stack_direction (); /* Recurse once. */ - } - else - { - /* Second entry. */ - if (ADDRESS_FUNCTION (dummy) > addr) - stack_dir = 1; /* Stack grew upward. */ - else - stack_dir = -1; /* Stack grew downward. */ - } -} - -#endif /* STACK_DIRECTION == 0 */ - -/* An "alloca header" is used to: - (a) chain together all alloca'ed blocks; - (b) keep track of stack depth. - - It is very important that sizeof(header) agree with malloc - alignment chunk size. The following default should work okay. */ - -#ifndef ALIGN_SIZE -#define ALIGN_SIZE sizeof(double) -#endif - -typedef union hdr -{ - char align[ALIGN_SIZE]; /* To force sizeof(header). */ - struct - { - union hdr *next; /* For chaining headers. */ - char *deep; /* For stack depth measure. */ - } h; -} header; - -static header *last_alloca_header = NULL; /* -> last alloca header. */ - -/* Return a pointer to at least SIZE bytes of storage, - which will be automatically reclaimed upon exit from - the procedure that called alloca. Originally, this space - was supposed to be taken from the current stack frame of the - caller, but that method cannot be made to work for some - implementations of C, for example under Gould's UTX/32. */ - -pointer -alloca (size) - unsigned size; -{ - auto char probe; /* Probes stack depth: */ - register char *depth = ADDRESS_FUNCTION (probe); - -#if STACK_DIRECTION == 0 - if (STACK_DIR == 0) /* Unknown growth direction. */ - find_stack_direction (); -#endif - - /* Reclaim garbage, defined as all alloca'd storage that - was allocated from deeper in the stack than currently. */ - - { - register header *hp; /* Traverses linked list. */ - -#ifdef emacs - BLOCK_INPUT; -#endif - - for (hp = last_alloca_header; hp != NULL;) - if ((STACK_DIR > 0 && hp->h.deep > depth) - || (STACK_DIR < 0 && hp->h.deep < depth)) - { - register header *np = hp->h.next; - - free ((pointer) hp); /* Collect garbage. */ - - hp = np; /* -> next header. */ - } - else - break; /* Rest are not deeper. */ - - last_alloca_header = hp; /* -> last valid storage. */ - -#ifdef emacs - UNBLOCK_INPUT; -#endif - } - - if (size == 0) - return NULL; /* No allocation required. */ - - /* Allocate combined header + user data storage. */ - - { - register pointer new = malloc (sizeof (header) + size); - /* Address of header. */ - - if (new == 0) - abort(); - - ((header *) new)->h.next = last_alloca_header; - ((header *) new)->h.deep = depth; - - last_alloca_header = (header *) new; - - /* User storage begins just after header. */ - - return (pointer) ((char *) new + sizeof (header)); - } -} - -#if defined (CRAY) && defined (CRAY_STACKSEG_END) - -#ifdef DEBUG_I00AFUNC -#include <stdio.h> -#endif - -#ifndef CRAY_STACK -#define CRAY_STACK -#ifndef CRAY2 -/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */ -struct stack_control_header - { - long shgrow:32; /* Number of times stack has grown. */ - long shaseg:32; /* Size of increments to stack. */ - long shhwm:32; /* High water mark of stack. */ - long shsize:32; /* Current size of stack (all segments). */ - }; - -/* The stack segment linkage control information occurs at - the high-address end of a stack segment. (The stack - grows from low addresses to high addresses.) The initial - part of the stack segment linkage control information is - 0200 (octal) words. This provides for register storage - for the routine which overflows the stack. */ - -struct stack_segment_linkage - { - long ss[0200]; /* 0200 overflow words. */ - long sssize:32; /* Number of words in this segment. */ - long ssbase:32; /* Offset to stack base. */ - long:32; - long sspseg:32; /* Offset to linkage control of previous - segment of stack. */ - long:32; - long sstcpt:32; /* Pointer to task common address block. */ - long sscsnm; /* Private control structure number for - microtasking. */ - long ssusr1; /* Reserved for user. */ - long ssusr2; /* Reserved for user. */ - long sstpid; /* Process ID for pid based multi-tasking. */ - long ssgvup; /* Pointer to multitasking thread giveup. */ - long sscray[7]; /* Reserved for Cray Research. */ - long ssa0; - long ssa1; - long ssa2; - long ssa3; - long ssa4; - long ssa5; - long ssa6; - long ssa7; - long sss0; - long sss1; - long sss2; - long sss3; - long sss4; - long sss5; - long sss6; - long sss7; - }; - -#else /* CRAY2 */ -/* The following structure defines the vector of words - returned by the STKSTAT library routine. */ -struct stk_stat - { - long now; /* Current total stack size. */ - long maxc; /* Amount of contiguous space which would - be required to satisfy the maximum - stack demand to date. */ - long high_water; /* Stack high-water mark. */ - long overflows; /* Number of stack overflow ($STKOFEN) calls. */ - long hits; /* Number of internal buffer hits. */ - long extends; /* Number of block extensions. */ - long stko_mallocs; /* Block allocations by $STKOFEN. */ - long underflows; /* Number of stack underflow calls ($STKRETN). */ - long stko_free; /* Number of deallocations by $STKRETN. */ - long stkm_free; /* Number of deallocations by $STKMRET. */ - long segments; /* Current number of stack segments. */ - long maxs; /* Maximum number of stack segments so far. */ - long pad_size; /* Stack pad size. */ - long current_address; /* Current stack segment address. */ - long current_size; /* Current stack segment size. This - number is actually corrupted by STKSTAT to - include the fifteen word trailer area. */ - long initial_address; /* Address of initial segment. */ - long initial_size; /* Size of initial segment. */ - }; - -/* The following structure describes the data structure which trails - any stack segment. I think that the description in 'asdef' is - out of date. I only describe the parts that I am sure about. */ - -struct stk_trailer - { - long this_address; /* Address of this block. */ - long this_size; /* Size of this block (does not include - this trailer). */ - long unknown2; - long unknown3; - long link; /* Address of trailer block of previous - segment. */ - long unknown5; - long unknown6; - long unknown7; - long unknown8; - long unknown9; - long unknown10; - long unknown11; - long unknown12; - long unknown13; - long unknown14; - }; - -#endif /* CRAY2 */ -#endif /* not CRAY_STACK */ - -#ifdef CRAY2 -/* Determine a "stack measure" for an arbitrary ADDRESS. - I doubt that "lint" will like this much. */ - -static long -i00afunc (long *address) -{ - struct stk_stat status; - struct stk_trailer *trailer; - long *block, size; - long result = 0; - - /* We want to iterate through all of the segments. The first - step is to get the stack status structure. We could do this - more quickly and more directly, perhaps, by referencing the - $LM00 common block, but I know that this works. */ - - STKSTAT (&status); - - /* Set up the iteration. */ - - trailer = (struct stk_trailer *) (status.current_address - + status.current_size - - 15); - - /* There must be at least one stack segment. Therefore it is - a fatal error if "trailer" is null. */ - - if (trailer == 0) - abort (); - - /* Discard segments that do not contain our argument address. */ - - while (trailer != 0) - { - block = (long *) trailer->this_address; - size = trailer->this_size; - if (block == 0 || size == 0) - abort (); - trailer = (struct stk_trailer *) trailer->link; - if ((block <= address) && (address < (block + size))) - break; - } - - /* Set the result to the offset in this segment and add the sizes - of all predecessor segments. */ - - result = address - block; - - if (trailer == 0) - { - return result; - } - - do - { - if (trailer->this_size <= 0) - abort (); - result += trailer->this_size; - trailer = (struct stk_trailer *) trailer->link; - } - while (trailer != 0); - - /* We are done. Note that if you present a bogus address (one - not in any segment), you will get a different number back, formed - from subtracting the address of the first block. This is probably - not what you want. */ - - return (result); -} - -#else /* not CRAY2 */ -/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP. - Determine the number of the cell within the stack, - given the address of the cell. The purpose of this - routine is to linearize, in some sense, stack addresses - for alloca. */ - -static long -i00afunc (long address) -{ - long stkl = 0; - - long size, pseg, this_segment, stack; - long result = 0; - - struct stack_segment_linkage *ssptr; - - /* Register B67 contains the address of the end of the - current stack segment. If you (as a subprogram) store - your registers on the stack and find that you are past - the contents of B67, you have overflowed the segment. - - B67 also points to the stack segment linkage control - area, which is what we are really interested in. */ - - stkl = CRAY_STACKSEG_END (); - ssptr = (struct stack_segment_linkage *) stkl; - - /* If one subtracts 'size' from the end of the segment, - one has the address of the first word of the segment. - - If this is not the first segment, 'pseg' will be - nonzero. */ - - pseg = ssptr->sspseg; - size = ssptr->sssize; - - this_segment = stkl - size; - - /* It is possible that calling this routine itself caused - a stack overflow. Discard stack segments which do not - contain the target address. */ - - while (!(this_segment <= address && address <= stkl)) - { -#ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl); -#endif - if (pseg == 0) - break; - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - this_segment = stkl - size; - } - - result = address - this_segment; - - /* If you subtract pseg from the current end of the stack, - you get the address of the previous stack segment's end. - This seems a little convoluted to me, but I'll bet you save - a cycle somewhere. */ - - while (pseg != 0) - { -#ifdef DEBUG_I00AFUNC - fprintf (stderr, "%011o %011o\n", pseg, size); -#endif - stkl = stkl - pseg; - ssptr = (struct stack_segment_linkage *) stkl; - size = ssptr->sssize; - pseg = ssptr->sspseg; - result += size; - } - return (result); -} - -#endif /* not CRAY2 */ -#endif /* CRAY */ - -#endif /* no alloca */ -#endif /* not GCC version 2 */ diff --git a/libamu/amu.h b/libamu/amu.h index 1e7834a15261..9415fc404ea4 100644 --- a/libamu/amu.h +++ b/libamu/amu.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2014 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -16,11 +16,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * 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 acknowledgment: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -47,11 +43,14 @@ /* * Decide what maximum level of NFS server to try and mount with. */ -#ifdef HAVE_FS_NFS3 +#if defined(HAVE_FS_NFS4) +# define NFS_VERS_MAX NFS_VERSION4 +#elif defined(HAVE_FS_NFS3) # define NFS_VERS_MAX NFS_VERSION3 #else /* not HAVE_FS_NFS3 */ # define NFS_VERS_MAX NFS_VERSION #endif /* not HAVE_FS_NFS3 */ +# define NFS_VERS_MIN NFS_VERSION /* some systems like ncr2 do not define this in <rpcsvc/mount.h> */ #ifndef MNTPATHLEN diff --git a/libamu/clnt_sperrno.c b/libamu/clnt_sperrno.c index d3b48d1cd405..b19c15199b38 100644 --- a/libamu/clnt_sperrno.c +++ b/libamu/clnt_sperrno.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-1998 Erez Zadok + * Copyright (c) 1997-2014 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -16,11 +16,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * 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 University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -36,9 +32,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * %W% (Berkeley) %G% * - * $Id: clnt_sperrno.c,v 5.2.2.1 1992/02/09 15:08:40 jsp beta $ + * File: am-utils/libamu/clnt_sperrno.c * */ @@ -57,7 +52,7 @@ * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE - * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the diff --git a/libamu/hasmntopt.c b/libamu/hasmntopt.c index 14cceb53b5cb..e5a6f2e80dfe 100644 --- a/libamu/hasmntopt.c +++ b/libamu/hasmntopt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2014 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -16,11 +16,7 @@ n * modification, are permitted provided that the following conditions * 2. Redistributions in binary form must reproduce the above copyright * 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 acknowledgment: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -67,7 +63,7 @@ nextmntopt(char **p) /* * Skip past white space */ - while (*cp && isspace((int) *cp)) + while (*cp && isspace((unsigned char) *cp)) cp++; /* @@ -106,7 +102,7 @@ amu_hasmntopt(mntent_t *mnt, char *opt) char t[MNTMAXSTR]; char *f; char *o = t; - int l = strlen(opt); + size_t l = strlen(opt); xstrlcpy(t, mnt->mnt_opts, sizeof(t)); diff --git a/libamu/memcmp.c b/libamu/memcmp.c new file mode 100644 index 000000000000..620991836160 --- /dev/null +++ b/libamu/memcmp.c @@ -0,0 +1,67 @@ +/* + * Copyright (c) 1997-2014 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * + * File: am-utils/libamu/memcmp.c + * + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ +#include <am_defs.h> +#include <amu.h> + + +/* + * compare two strings for up to length "len". + * this will normally be included on systems that either have no memcmp() + * and no bcmp(), or on systems that have both but the memcmp() is not 8-bit + * clean (such as SunOS 4.1.3). + * + * SunOS 4.x with gcc requires prototype of (const voidp, const voidp, size_t) + */ +int +am_memcmp(const voidp s1, const voidp s2, size_t len) +{ + unsigned char *ucp1 = (unsigned char *) s1; + unsigned char *ucp2 = (unsigned char *) s2; + int i = len; + + while (i-- > 0) + if (*ucp1++ != *ucp2++) + return (ucp1[-1] >= ucp2[-1] ? 1 : -1); + + return 0; +} diff --git a/libamu/misc_rpc.c b/libamu/misc_rpc.c index de0a92036b7f..c6ad4486d7d9 100644 --- a/libamu/misc_rpc.c +++ b/libamu/misc_rpc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2014 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -16,11 +16,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * 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 acknowledgment: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * diff --git a/libamu/mount_fs.c b/libamu/mount_fs.c index 74f064ede648..b5576bdc6d14 100644 --- a/libamu/mount_fs.c +++ b/libamu/mount_fs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2014 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -16,11 +16,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * 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 acknowledgment: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -46,6 +42,7 @@ #endif /* HAVE_CONFIG_H */ #include <am_defs.h> #include <amu.h> +#include <nfs_common.h> /* ensure that mount table options are delimited by a comma */ @@ -105,6 +102,30 @@ struct opt_tab mnt_flags[] = {MNTTAB_OPT_OVERLAY, MNT2_GEN_OPT_OVERLAY}, #endif /* defined(MNT2_GEN_OPT_OVERLAY) && defined(MNTTAB_OPT_OVERLAY) */ +#if defined(MNT2_GEN_OPT_LOG) && defined(MNTTAB_OPT_LOG) + {MNTTAB_OPT_LOG, MNT2_GEN_OPT_LOG}, +#endif /* defined(MNT2_GEN_OPT_LOG) && defined(MNTTAB_OPT_LOG) */ + +#if defined(MNT2_GEN_OPT_NOATIME) && defined(MNTTAB_OPT_NOATIME) + {MNTTAB_OPT_NOATIME, MNT2_GEN_OPT_NOATIME}, +#endif /* defined(MNT2_GEN_OPT_NOATIME) && defined(MNTTAB_OPT_NOATIME) */ + +#if defined(MNT2_GEN_OPT_NODEVMTIME) && defined(MNTTAB_OPT_NODEVMTIME) + {MNTTAB_OPT_NODEVMTIME, MNT2_GEN_OPT_NODEVMTIME}, +#endif /* defined(MNT2_GEN_OPT_NODEVMTIME) && defined(MNTTAB_OPT_NODEVMTIME) */ + +#if defined(MNT2_GEN_OPT_SOFTDEP) && defined(MNTTAB_OPT_SOFTDEP) + {MNTTAB_OPT_SOFTDEP, MNT2_GEN_OPT_SOFTDEP}, +#endif /* defined(MNT2_GEN_OPT_SOFTDEP) && defined(MNTTAB_OPT_SOFTDEP) */ + +#if defined(MNT2_GEN_OPT_SYMPERM) && defined(MNTTAB_OPT_SYMPERM) + {MNTTAB_OPT_SYMPERM, MNT2_GEN_OPT_SYMPERM}, +#endif /* defined(MNT2_GEN_OPT_SYMPERM) && defined(MNTTAB_OPT_SYMPERM) */ + +#if defined(MNT2_GEN_OPT_UNION) && defined(MNTTAB_OPT_UNION) + {MNTTAB_OPT_UNION, MNT2_GEN_OPT_UNION}, +#endif /* defined(MNT2_GEN_OPT_UNION) && defined(MNTTAB_OPT_UNION) */ + /* * Do not define MNT2_NFS_OPT_* entries here! This is for generic * mount(2) options only, not for NFS mount options. If you need to put @@ -158,6 +179,25 @@ compute_automounter_mount_flags(mntent_t *mntp) } +#if defined(MOUNT_TABLE_ON_FILE) && defined(MNTTAB_OPT_VERS) +/* + * add the extra vers={2,3} field to the mount table, + * unless already specified by user + */ +static void +addvers(char *zopts, size_t l, mntent_t *mnt, u_long have_vers, + u_long want_vers) +{ + if (have_vers == want_vers && + hasmntval(mnt, MNTTAB_OPT_VERS) != want_vers) { + char optsbuf[48]; + xsnprintf(optsbuf, sizeof(optsbuf), + "%s=%d", MNTTAB_OPT_VERS, want_vers); + append_opts(zopts, l, optsbuf); + } +} +#endif /* MOUNT_TABLE_ON_FILE && MNTTAB_OPT_VERS */ + int mount_fs(mntent_t *mnt, int flags, caddr_t mnt_data, int retry, MTYPE_TYPE type, u_long nfs_version, const char *nfs_proto, const char *mnttabname, int on_autofs) { @@ -166,17 +206,17 @@ mount_fs(mntent_t *mnt, int flags, caddr_t mnt_data, int retry, MTYPE_TYPE type, char *zopts = NULL, *xopts = NULL; size_t l; #endif /* MOUNT_TABLE_ON_FILE */ - char *mnt_dir = 0; + char *mnt_dir = NULL; #ifdef NEED_AUTOFS_SPACE_HACK - char *old_mnt_dir = 0; + char *old_mnt_dir = NULL; /* perform space hack */ if (on_autofs) { old_mnt_dir = mnt->mnt_dir; mnt->mnt_dir = mnt_dir = autofs_strdup_space_hack(old_mnt_dir); } else #endif /* NEED_AUTOFS_SPACE_HACK */ - mnt_dir = strdup(mnt->mnt_dir); + mnt_dir = xstrdup(mnt->mnt_dir); dlog("'%s' fstype " MTYPE_PRINTF_TYPE " (%s) flags %#x (%s)", mnt_dir, type, mnt->mnt_type, flags, mnt->mnt_opts); @@ -256,19 +296,15 @@ again: } # endif /* MNTTAB_OPT_DEV */ +# if defined(HAVE_FS_NFS4) && defined(MNTTAB_OPT_VERS) + addvers(zopts, l, mnt, nfs_version, NFS_VERSION4); +# endif /* defined(HAVE_FS_NFS4) && defined(MNTTAB_OPT_VERS) */ # if defined(HAVE_FS_NFS3) && defined(MNTTAB_OPT_VERS) - /* - * add the extra vers={2,3} field to the mount table, - * unless already specified by user - */ - if (nfs_version == NFS_VERSION3 && - hasmntval(mnt, MNTTAB_OPT_VERS) != NFS_VERSION3) { - char optsbuf[48]; - xsnprintf(optsbuf, sizeof(optsbuf), - "%s=%d", MNTTAB_OPT_VERS, NFS_VERSION3); - append_opts(zopts, l, optsbuf); - } + addvers(zopts, l, mnt, nfs_version, NFS_VERSION3); # endif /* defined(HAVE_FS_NFS3) && defined(MNTTAB_OPT_VERS) */ +# ifdef MNTTAB_OPT_VERS + addvers(zopts, l, mnt, nfs_version, NFS_VERSION2); +# endif /* MNTTAB_OPT_VERS */ # ifdef MNTTAB_OPT_PROTO /* @@ -333,7 +369,7 @@ again: * with caution. */ static void -compute_nfs_attrcache_flags(nfs_args_t *nap, mntent_t *mntp) +compute_nfs_attrcache_flags(struct nfs_common_args *nap, mntent_t *mntp) { int acval = 0; int err_acval = 1; /* 1 means we found no 'actimeo' value */ @@ -365,7 +401,9 @@ compute_nfs_attrcache_flags(nfs_args_t *nap, mntent_t *mntp) nap->acregmin = acval; /* min ac timeout for reg files (sec) */ } else { # ifdef MNTTAB_OPT_ACREGMIN - err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACREGMIN, (int *) &nap->acregmin); + int tmp; + err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACREGMIN, &tmp); + nap->acregmin = tmp; # else /* not MNTTAB_OPT_ACREGMIN */ nap->acregmin = 0; # endif /* not MNTTAB_OPT_ACREGMIN */ @@ -384,7 +422,9 @@ compute_nfs_attrcache_flags(nfs_args_t *nap, mntent_t *mntp) nap->acregmax = acval; /* max ac timeout for reg files (sec) */ } else { # ifdef MNTTAB_OPT_ACREGMAX - err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACREGMAX, (int *) &nap->acregmax); + int tmp; + err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACREGMAX, &tmp); + nap->acregmax = tmp; # else /* not MNTTAB_OPT_ACREGMAX */ nap->acregmax = 0; # endif /* not MNTTAB_OPT_ACREGMAX */ @@ -403,7 +443,9 @@ compute_nfs_attrcache_flags(nfs_args_t *nap, mntent_t *mntp) nap->acdirmin = acval; /* min ac timeout for dirs (sec) */ } else { # ifdef MNTTAB_OPT_ACDIRMIN - err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACDIRMIN, (int *) &nap->acdirmin); + int tmp; + err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACDIRMIN, &tmp); + nap->acdirmin = tmp; # else /* not MNTTAB_OPT_ACDIRMIN */ nap->acdirmin = 0; # endif /* not MNTTAB_OPT_ACDIRMIN */ @@ -422,7 +464,9 @@ compute_nfs_attrcache_flags(nfs_args_t *nap, mntent_t *mntp) nap->acdirmax = acval; /* max ac timeout for dirs (sec) */ } else { # ifdef MNTTAB_OPT_ACDIRMAX - err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACDIRMAX, (int *) &nap->acdirmax); + int tmp; + err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACDIRMAX, &tmp); + nap->acdirmax = tmp; # else /* not MNTTAB_OPT_ACDIRMAX */ nap->acdirmax = 0; # endif /* not MNTTAB_OPT_ACDIRMAX */ @@ -443,148 +487,16 @@ compute_nfs_attrcache_flags(nfs_args_t *nap, mntent_t *mntp) } -/* - * Fill in the many possible fields and flags of struct nfs_args. - * - * nap: pre-allocated structure to fill in. - * mntp: mount entry structure (includes options) - * genflags: generic mount flags already determined - * nfsncp: (TLI only) netconfig entry for this NFS mount - * ip_addr: IP address of file server - * nfs_version: 2, 3, (4 in the future), or 0 if unknown - * nfs_proto: "udp", "tcp", or NULL. - * fhp: file handle structure pointer - * host_name: name of remote NFS host - * fs_name: remote file system name to mount - */ -void -compute_nfs_args(nfs_args_t *nap, - mntent_t *mntp, - int genflags, - struct netconfig *nfsncp, - struct sockaddr_in *ip_addr, - u_long nfs_version, - char *nfs_proto, - am_nfs_handle_t *fhp, - char *host_name, - char *fs_name) -{ - /* initialize just in case */ - memset((voidp) nap, 0, sizeof(nfs_args_t)); - - /* compute all of the NFS attribute-cache flags */ - compute_nfs_attrcache_flags(nap, mntp); - - /************************************************************************/ - /*** FILEHANDLE DATA AND LENGTH ***/ - /************************************************************************/ -#ifdef HAVE_FS_NFS3 - if (nfs_version == NFS_VERSION3) { -# if defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) - /* - * Some systems (Irix/bsdi3) have a separate field in nfs_args for - * the length of the file handle for NFS V3. They insist that - * the file handle set in nfs_args be plain bytes, and not - * include the length field. - */ - NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v3.am_fh3_data); -# else /* not defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) */ - NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v3); -# endif /* not defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) */ -# ifdef MNT2_NFS_OPT_NFSV3 - nap->flags |= MNT2_NFS_OPT_NFSV3; -# endif /* MNT2_NFS_OPT_NFSV3 */ -# ifdef MNT2_NFS_OPT_VER3 - nap->flags |= MNT2_NFS_OPT_VER3; -# endif /* MNT2_NFS_OPT_VER3 */ - } else -#endif /* HAVE_FS_NFS3 */ - NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v2); - -#ifdef HAVE_NFS_ARGS_T_FHSIZE -# ifdef HAVE_FS_NFS3 - if (nfs_version == NFS_VERSION3) - nap->fhsize = fhp->v3.am_fh3_length; - else -# endif /* HAVE_FS_NFS3 */ - nap->fhsize = FHSIZE; -#endif /* HAVE_NFS_ARGS_T_FHSIZE */ - - /* this is the version of the nfs_args structure, not of NFS! */ -#ifdef HAVE_NFS_ARGS_T_FH_LEN -# ifdef HAVE_FS_NFS3 - if (nfs_version == NFS_VERSION3) - nap->fh_len = fhp->v3.am_fh3_length; - else -# endif /* HAVE_FS_NFS3 */ - nap->fh_len = FHSIZE; -#endif /* HAVE_NFS_ARGS_T_FH_LEN */ - /************************************************************************/ - /*** HOST NAME ***/ - /************************************************************************/ - /* - * XXX: warning, using xstrlcpy in NFS_HN_DREF, which may corrupt a - * struct nfs_args, or truncate our concocted "hostname:/path" - * string prematurely. - */ - NFS_HN_DREF(nap->hostname, host_name); -#ifdef MNT2_NFS_OPT_HOSTNAME - nap->flags |= MNT2_NFS_OPT_HOSTNAME; -#endif /* MNT2_NFS_OPT_HOSTNAME */ - - /************************************************************************/ - /*** IP ADDRESS OF REMOTE HOST ***/ - /************************************************************************/ - if (ip_addr) { -#ifdef HAVE_TRANSPORT_TYPE_TLI - nap->addr = ALLOC(struct netbuf); /* free()'ed at end of mount_nfs_fh() */ -#endif /* HAVE_TRANSPORT_TYPE_TLI */ - NFS_SA_DREF(nap, ip_addr); - } - - /************************************************************************/ - /*** NFS PROTOCOL (UDP, TCP) AND VERSION ***/ - /************************************************************************/ +static void +compute_nfs_common_args(struct nfs_common_args *nap, mntent_t *mntp, + const char *nfs_proto, u_long nfs_version) +{ #ifdef MNT2_NFS_OPT_TCP if (nfs_proto && STREQ(nfs_proto, "tcp")) nap->flags |= MNT2_NFS_OPT_TCP; #endif /* MNT2_NFS_OPT_TCP */ -#ifdef HAVE_NFS_ARGS_T_SOTYPE - /* bsdi3 uses this */ - if (nfs_proto) { - if (STREQ(nfs_proto, "tcp")) - nap->sotype = SOCK_STREAM; - else if (STREQ(nfs_proto, "udp")) - nap->sotype = SOCK_DGRAM; - } -#endif /* HAVE_NFS_ARGS_T_SOTYPE */ - -#ifdef HAVE_NFS_ARGS_T_PROTO - nap->proto = 0; /* bsdi3 sets this field to zero */ -# ifdef IPPROTO_TCP - if (nfs_proto) { - if (STREQ(nfs_proto, "tcp")) /* AIX 4.2.x needs this */ - nap->proto = IPPROTO_TCP; - else if (STREQ(nfs_proto, "udp")) - nap->proto = IPPROTO_UDP; - } -# endif /* IPPROTO_TCP */ -#endif /* HAVE_NFS_ARGS_T_SOTYPE */ - -#ifdef HAVE_NFS_ARGS_T_VERSION -# ifdef NFS_ARGSVERSION - nap->version = NFS_ARGSVERSION; /* BSDI 3.0 and OpenBSD 2.2 */ -# endif /* NFS_ARGSVERSION */ -# ifdef DG_MOUNT_NFS_VERSION - nap->version = DG_MOUNT_NFS_VERSION; /* dg-ux */ -# endif /* DG_MOUNT_NFS_VERSION */ -#endif /* HAVE_NFS_ARGS_VERSION */ - - /************************************************************************/ - /*** OTHER NFS SOCKET RELATED OPTIONS AND FLAGS ***/ - /************************************************************************/ #ifdef MNT2_NFS_OPT_NOCONN /* check if user specified to use unconnected or connected sockets */ if (amu_hasmntopt(mntp, MNTTAB_OPT_NOCONN) != NULL) @@ -624,28 +536,6 @@ compute_nfs_args(nfs_args_t *nap, # endif /* not MNTTAB_OPT_RESVPORT */ #endif /* MNT2_NFS_OPT_RESVPORT */ - /************************************************************************/ - /*** OTHER FLAGS AND OPTIONS ***/ - /************************************************************************/ - -#ifdef HAVE_TRANSPORT_TYPE_TLI - /* set up syncaddr field */ - nap->syncaddr = (struct netbuf *) NULL; - - /* set up knconf field */ - if (get_knetconfig(&nap->knconf, nfsncp, nfs_proto) < 0) { - plog(XLOG_FATAL, "cannot fill knetconfig structure for nfs_args"); - going_down(1); - } - /* update the flags field for knconf */ - nap->flags |= MNT2_NFS_OPT_KNCONF; -#endif /* HAVE_TRANSPORT_TYPE_TLI */ - -#ifdef MNT2_NFS_OPT_FSNAME - nap->fsname = fs_name; - nap->flags |= MNT2_NFS_OPT_FSNAME; -#endif /* MNT2_NFS_OPT_FSNAME */ - nap->rsize = hasmntval(mntp, MNTTAB_OPT_RSIZE); #ifdef MNT2_NFS_OPT_RSIZE if (nap->rsize) @@ -674,11 +564,6 @@ compute_nfs_args(nfs_args_t *nap, nap->flags |= MNT2_NFS_OPT_RETRANS; #endif /* MNT2_NFS_OPT_RETRANS */ -#ifdef MNT2_NFS_OPT_BIODS - if ((nap->biods = hasmntval(mntp, MNTTAB_OPT_BIODS))) - nap->flags |= MNT2_NFS_OPT_BIODS; -#endif /* MNT2_NFS_OPT_BIODS */ - #ifdef MNT2_NFS_OPT_SOFT if (amu_hasmntopt(mntp, MNTTAB_OPT_SOFT) != NULL) nap->flags |= MNT2_NFS_OPT_SOFT; @@ -687,7 +572,7 @@ compute_nfs_args(nfs_args_t *nap, #ifdef MNT2_NFS_OPT_SPONGY if (amu_hasmntopt(mntp, MNTTAB_OPT_SPONGY) != NULL) { nap->flags |= MNT2_NFS_OPT_SPONGY; - if (nap->flags & MNT2_NFS_OPT_SOFT) { + if (*flags & MNT2_NFS_OPT_SOFT) { plog(XLOG_USER, "Mount opts soft and spongy are incompatible - soft ignored"); nap->flags &= ~MNT2_NFS_OPT_SOFT; } @@ -720,6 +605,11 @@ compute_nfs_args(nfs_args_t *nap, # endif /* MNT2_NFS_OPT_NOINT */ #endif /* MNTTAB_OPT_INTR */ +#ifdef MNT2_NFS_OPT_NOACL + if (amu_hasmntopt(mntp, MNTTAB_OPT_NOACL) != NULL) + nap->flags |= MNT2_NFS_OPT_NOACL; +#endif /* MNT2_NFS_OPT_NOACL */ + #ifdef MNTTAB_OPT_NODEVS if (amu_hasmntopt(mntp, MNTTAB_OPT_NODEVS) != NULL) nap->flags |= MNT2_NFS_OPT_NODEVS; @@ -735,39 +625,17 @@ compute_nfs_args(nfs_args_t *nap, nap->flags |= MNT2_NFS_OPT_PRIVATE; #endif /* MNTTAB_OPT_PRIVATE */ -#ifdef MNTTAB_OPT_SYMTTL /* symlink cache time-to-live */ - if ((nap->symttl = hasmntval(mntp, MNTTAB_OPT_SYMTTL))) - nap->flags |= MNT2_NFS_OPT_SYMTTL; -#endif /* MNTTAB_OPT_SYMTTL */ - -#ifdef MNT2_NFS_OPT_PGTHRESH /* paging threshold */ - if ((nap->pg_thresh = hasmntval(mntp, MNTTAB_OPT_PGTHRESH))) - nap->flags |= MNT2_NFS_OPT_PGTHRESH; -#endif /* MNT2_NFS_OPT_PGTHRESH */ #if defined(MNT2_NFS_OPT_NOCTO) && defined(MNTTAB_OPT_NOCTO) if (amu_hasmntopt(mntp, MNTTAB_OPT_NOCTO) != NULL) nap->flags |= MNT2_NFS_OPT_NOCTO; #endif /* defined(MNT2_NFS_OPT_NOCTO) && defined(MNTTAB_OPT_NOCTO) */ -#if defined(MNT2_NFS_OPT_POSIX) && defined(MNTTAB_OPT_POSIX) - if (amu_hasmntopt(mntp, MNTTAB_OPT_POSIX) != NULL) { - nap->flags |= MNT2_NFS_OPT_POSIX; - nap->pathconf = NULL; - } -#endif /* MNT2_NFS_OPT_POSIX && MNTTAB_OPT_POSIX */ - #if defined(MNT2_NFS_OPT_PROPLIST) && defined(MNTTAB_OPT_PROPLIST) if (amu_hasmntopt(mntp, MNTTAB_OPT_PROPLIST) != NULL) nap->flags |= MNT2_NFS_OPT_PROPLIST; #endif /* defined(MNT2_NFS_OPT_PROPLIST) && defined(MNTTAB_OPT_PROPLIST) */ -#if defined(MNT2_NFS_OPT_MAXGRPS) && defined(MNTTAB_OPT_MAXGROUPS) - nap->maxgrouplist = hasmntval(mntp, MNTTAB_OPT_MAXGROUPS); - if (nap->maxgrouplist != 0) - nap->flags |= MNT2_NFS_OPT_MAXGRPS; -#endif /* defined(MNT2_NFS_OPT_MAXGRPS) && defined(MNTTAB_OPT_MAXGROUPS) */ - #if defined(MNT2_NFS_OPT_NONLM) && defined(MNTTAB_OPT_NOLOCK) if (amu_hasmntopt(mntp, MNTTAB_OPT_NOLOCK) != NULL) nap->flags |= MNT2_NFS_OPT_NONLM; @@ -777,77 +645,35 @@ compute_nfs_args(nfs_args_t *nap, if (amu_hasmntopt(mntp, MNTTAB_OPT_XLATECOOKIE) != NULL) nap->flags |= MNT2_NFS_OPT_XLATECOOKIE; #endif /* defined(MNT2_NFS_OPT_XLATECOOKIE) && defined(MNTTAB_OPT_XLATECOOKIE) */ - -#ifdef HAVE_NFS_ARGS_T_OPTSTR - nap->optstr = mntp->mnt_opts; -#endif /* HAVE_NFS_ARGS_T_OPTSTR */ - - /************************************************************************/ - /*** FINAL ACTIONS ***/ - /************************************************************************/ - -#ifdef HAVE_NFS_ARGS_T_GFS_FLAGS - /* Ultrix stores generic flags in nfs_args.gfs_flags. */ - nap->gfs_flags = genflags; -#endif /* HAVE_NFS_ARGS_T_FLAGS */ - - return; /* end of compute_nfs_args() function */ } - -/* - * Fill in special values for flags and fields of nfs_args, for an - * automounter NFS mount. - */ -void -compute_automounter_nfs_args(nfs_args_t *nap, mntent_t *mntp) +static void +print_nfs_common_args(const struct nfs_common_args *a) { -#ifdef MNT2_NFS_OPT_SYMTTL - /* - * Don't let the kernel cache symbolic links we generate, or else lookups - * will bypass amd and fail to remount stuff as needed. - */ - plog(XLOG_INFO, "turning on NFS option symttl and setting value to 0"); - nap->flags |= MNT2_NFS_OPT_SYMTTL; - nap->symttl = 0; -#endif /* MNT2_NFS_OPT_SYMTTL */ - - /* - * This completes the flags for the HIDE_MOUNT_TYPE code in the - * mount_amfs_toplvl() function in amd/amfs_toplvl.c. - * Some systems don't have a mount type, but a mount flag. - */ -#ifdef MNT2_NFS_OPT_AUTO - nap->flags |= MNT2_NFS_OPT_AUTO; -#endif /* MNT2_NFS_OPT_AUTO */ -#ifdef MNT2_NFS_OPT_IGNORE - nap->flags |= MNT2_NFS_OPT_IGNORE; -#endif /* MNT2_NFS_OPT_IGNORE */ -#ifdef MNT2_GEN_OPT_AUTOMNTFS - nap->flags |= MNT2_GEN_OPT_AUTOMNTFS; -#endif /* not MNT2_GEN_OPT_AUTOMNTFS */ + plog(XLOG_DEBUG, "NA->flags = 0x%lx", a->flags); -#ifdef MNT2_NFS_OPT_DUMBTIMR - /* - * Don't let the kernel start computing throughput of Amd. The numbers - * will be meaningless because of the way Amd does mount retries. - */ - plog(XLOG_INFO, "%s: disabling nfs congestion window", mntp->mnt_dir); - nap->flags |= MNT2_NFS_OPT_DUMBTIMR; -#endif /* MNT2_NFS_OPT_DUMBTIMR */ - - /* compute all of the NFS attribute-cache flags */ - compute_nfs_attrcache_flags(nap, mntp); + plog(XLOG_DEBUG, "NA->rsize = %lu", a->rsize); + plog(XLOG_DEBUG, "NA->wsize = %lu", a->wsize); + plog(XLOG_DEBUG, "NA->timeo = %lu", a->timeo); + plog(XLOG_DEBUG, "NA->retrans = %lu", a->retrans); - /* - * Provide a slight bit more security by requiring the kernel to use - * reserved ports. - */ -#ifdef MNT2_NFS_OPT_RESVPORT - nap->flags |= MNT2_NFS_OPT_RESVPORT; -#endif /* MNT2_NFS_OPT_RESVPORT */ +#ifdef HAVE_NFS_ARGS_T_ACREGMIN + plog(XLOG_DEBUG, "NA->acregmin = %lu", a->acregmin); + plog(XLOG_DEBUG, "NA->acregmax = %lu", a->acregmax); + plog(XLOG_DEBUG, "NA->acdirmin = %lu", a->acdirmin); + plog(XLOG_DEBUG, "NA->acdirmax = %lu", a->acdirmax); +#endif /* HAVE_NFS_ARGS_T_ACREGMIN */ } +static void +discard_nfs23_args(nfs_args_t *nap) +{ +#ifdef HAVE_TRANSPORT_TYPE_TLI + free_knetconfig(nap->knconf); + if (nap->addr) + XFREE(nap->addr); /* allocated in compute_nfs_args() */ +#endif /* HAVE_TRANSPORT_TYPE_TLI */ +} #ifdef DEBUG /* get string version (in hex) of identifier */ @@ -855,29 +681,48 @@ static char * get_hex_string(u_int len, const char *fhdata) { u_int i; - static char buf[128]; /* better not go over it! */ + static u_int xlen; + static char *buf; + static u_short *arr; char str[16]; - short int arr[64]; - if (!fhdata) + if (!fhdata || len == 0 || len > 10240) return NULL; + i = len * 4 + 1; + if (xlen < i) { + buf = xrealloc(buf, i); + arr = xrealloc(arr, len * sizeof(*arr)); + xlen = i; + } + buf[0] = '\0'; - memset(&arr[0], 0, (64 * sizeof(short int))); - memcpy(&arr[0], &fhdata[0], len); - for (i=0; i<len/sizeof(unsigned short int); i++) { + memset(arr, 0, len * sizeof(*arr)); + memcpy(arr, fhdata, len); + len /= sizeof(*arr); + for (i = 0; i < len; i++) { xsnprintf(str, sizeof(str), "%04x", ntohs(arr[i])); - xstrlcat(buf, str, sizeof(buf)); + xstrlcat(buf, str, xlen); } return buf; } +static void +print_nfs_sockaddr_in(const char *tag, const struct sockaddr_in *sap) +{ + char name[64]; + plog(XLOG_DEBUG, "NA->%s.sin_family = %d", tag, sap->sin_family); + plog(XLOG_DEBUG, "NA->%s.sin_port = %d", tag, ntohs(sap->sin_port)); + if (inet_ntop(AF_INET, &sap->sin_addr, name, sizeof(name)) == NULL) + return; + plog(XLOG_DEBUG, "NA->%s.sin_addr = \"%s\"", tag, name); +} /* * print a subset of fields from "struct nfs_args" that are otherwise * not being provided anywhere else. */ -void -print_nfs_args(const nfs_args_t *nap, u_long nfs_version) +static void +print_nfs23_args(const nfs_args_t *nap, u_long nfs_version) { int fhlen = 32; /* default: NFS V.2 file handle length is 32 */ #ifdef HAVE_TRANSPORT_TYPE_TLI @@ -886,6 +731,7 @@ print_nfs_args(const nfs_args_t *nap, u_long nfs_version) #else /* not HAVE_TRANSPORT_TYPE_TLI */ struct sockaddr_in *sap; #endif /* not HAVE_TRANSPORT_TYPE_TLI */ + struct nfs_common_args a; if (!nap) { plog(XLOG_DEBUG, "NULL nfs_args!"); @@ -919,17 +765,11 @@ print_nfs_args(const nfs_args_t *nap, u_long nfs_version) # else /* not NFS_ARGS_T_ADDR_IS_POINTER */ sap = (struct sockaddr_in *) &nap->addr; # endif /* not NFS_ARGS_T_ADDR_IS_POINTER */ - plog(XLOG_DEBUG, "NA->addr {sockaddr_in} (len=%d) = \"%s\"", - (int) sizeof(struct sockaddr_in), - get_hex_string(sizeof(struct sockaddr_in), (const char *)sap)); #ifdef HAVE_STRUCT_SOCKADDR_SA_LEN /* as per POSIX, sin_len need not be set (used internally by kernel) */ plog(XLOG_DEBUG, "NA->addr.sin_len = %d", sap->sin_len); #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ - plog(XLOG_DEBUG, "NA->addr.sin_family = %d", sap->sin_family); - plog(XLOG_DEBUG, "NA->addr.sin_port = %d", sap->sin_port); - plog(XLOG_DEBUG, "NA->addr.sin_addr = \"%s\"", - get_hex_string(sizeof(struct in_addr), (const char *) &sap->sin_addr)); + print_nfs_sockaddr_in("addr", sap); #endif /* not HAVE_TRANSPORT_TYPE_TLI */ #ifdef HAVE_NFS_ARGS_T_ADDRLEN plog(XLOG_DEBUG, "NA->addrlen = %d", nap->addrlen); @@ -972,22 +812,13 @@ print_nfs_args(const nfs_args_t *nap, u_long nfs_version) plog(XLOG_DEBUG, "NA->version = %d", nap->version); #endif /* HAVE_NFS_ARGS_T_VERSION */ - plog(XLOG_DEBUG, "NA->flags = 0x%x", (int) nap->flags); + put_nfs_common_args(nap, a); + print_nfs_common_args(&a); - plog(XLOG_DEBUG, "NA->rsize = %d", (int) nap->rsize); - plog(XLOG_DEBUG, "NA->wsize = %d", (int) nap->wsize); #ifdef HAVE_NFS_ARGS_T_BSIZE plog(XLOG_DEBUG, "NA->bsize = %d", nap->bsize); #endif /* HAVE_NFS_ARGS_T_BSIZE */ - plog(XLOG_DEBUG, "NA->timeo = %d", (int) nap->timeo); - plog(XLOG_DEBUG, "NA->retrans = %d", (int) nap->retrans); -#ifdef HAVE_NFS_ARGS_T_ACREGMIN - plog(XLOG_DEBUG, "NA->acregmin = %d", (int) nap->acregmin); - plog(XLOG_DEBUG, "NA->acregmax = %d", (int) nap->acregmax); - plog(XLOG_DEBUG, "NA->acdirmin = %d", (int) nap->acdirmin); - plog(XLOG_DEBUG, "NA->acdirmax = %d", (int) nap->acdirmax); -#endif /* HAVE_NFS_ARGS_T_ACREGMIN */ #ifdef MNTTAB_OPT_SYMTTL plog(XLOG_DEBUG, "NA->symttl = %d", nap->symttl); #endif /* MNTTAB_OPT_SYMTTL */ @@ -1001,3 +832,665 @@ print_nfs_args(const nfs_args_t *nap, u_long nfs_version) } #endif /* DEBUG */ + +/* + * Fill in the many possible fields and flags of struct nfs_args. + * + * nap: pre-allocated structure to fill in. + * mntp: mount entry structure (includes options) + * genflags: generic mount flags already determined + * nfsncp: (TLI only) netconfig entry for this NFS mount + * ip_addr: IP address of file server + * nfs_version: 2, 3, or 0 if unknown + * nfs_proto: "udp", "tcp", or NULL. + * fhp: file handle structure pointer + * host_name: name of remote NFS host + * fs_name: remote file system name to mount + */ +static void +compute_nfs23_args(nfs_args_t *nap, + mntent_t *mntp, + int genflags, + struct netconfig *nfsncp, + struct sockaddr_in *ip_addr, + u_long nfs_version, + char *nfs_proto, + am_nfs_handle_t *fhp, + char *host_name, + char *fs_name) +{ + struct nfs_common_args a; + /* initialize just in case */ + memset((voidp) nap, 0, sizeof(nfs_args_t)); + + /* compute all of the NFS attribute-cache flags */ + memset(&a, 0, sizeof(a)); + compute_nfs_attrcache_flags(&a, mntp); + compute_nfs_common_args(&a, mntp, nfs_proto, nfs_version); + get_nfs_common_args(nap, a); + + /************************************************************************/ + /*** FILEHANDLE DATA AND LENGTH ***/ + /************************************************************************/ +#ifdef HAVE_FS_NFS3 + if (nfs_version == NFS_VERSION3) { + if (fhp == NULL) { + plog(XLOG_FATAL, "cannot pass NULL fh for NFSv%lu", nfs_version); + going_down(1); + return; + } + +# if defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) + /* + * Some systems (Irix/bsdi3) have a separate field in nfs_args for + * the length of the file handle for NFS V3. They insist that + * the file handle set in nfs_args be plain bytes, and not + * include the length field. + */ + NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v3.am_fh3_data); +# else /* not defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) */ + NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v3); +# endif /* not defined(HAVE_NFS_ARGS_T_FHSIZE) || defined(HAVE_NFS_ARGS_T_FH_LEN) */ +# ifdef MNT2_NFS_OPT_NFSV3 + nap->flags |= MNT2_NFS_OPT_NFSV3; +# endif /* MNT2_NFS_OPT_NFSV3 */ +# ifdef MNT2_NFS_OPT_VER3 + nap->flags |= MNT2_NFS_OPT_VER3; +# endif /* MNT2_NFS_OPT_VER3 */ + } else +#endif /* HAVE_FS_NFS3 */ + { + if (fhp == NULL) { + plog(XLOG_FATAL, "cannot pass NULL fh for NFSv%lu", nfs_version); + going_down(1); + return; + } + NFS_FH_DREF(nap->NFS_FH_FIELD, &fhp->v2); + } + +#ifdef HAVE_NFS_ARGS_T_FHSIZE +# ifdef HAVE_FS_NFS3 + if (nfs_version == NFS_VERSION3) + nap->fhsize = fhp->v3.am_fh3_length; + else +# endif /* HAVE_FS_NFS3 */ + nap->fhsize = FHSIZE; +#endif /* HAVE_NFS_ARGS_T_FHSIZE */ + + /* this is the version of the nfs_args structure, not of NFS! */ +#ifdef HAVE_NFS_ARGS_T_FH_LEN +# ifdef HAVE_FS_NFS3 + if (nfs_version == NFS_VERSION3) + nap->fh_len = fhp->v3.am_fh3_length; + else +# endif /* HAVE_FS_NFS3 */ + nap->fh_len = FHSIZE; +#endif /* HAVE_NFS_ARGS_T_FH_LEN */ + + /************************************************************************/ + /*** HOST NAME ***/ + /************************************************************************/ + /* + * XXX: warning, using xstrlcpy in NFS_HN_DREF, which may corrupt a + * struct nfs_args, or truncate our concocted "hostname:/path" + * string prematurely. + */ + NFS_HN_DREF(nap->hostname, host_name); +#ifdef MNT2_NFS_OPT_HOSTNAME + nap->flags |= MNT2_NFS_OPT_HOSTNAME; +#endif /* MNT2_NFS_OPT_HOSTNAME */ + + /************************************************************************/ + /*** IP ADDRESS OF REMOTE HOST ***/ + /************************************************************************/ + if (ip_addr) { +#ifdef HAVE_TRANSPORT_TYPE_TLI + nap->addr = ALLOC(struct netbuf); /* free()'ed at end of mount_nfs_fh() */ +#endif /* HAVE_TRANSPORT_TYPE_TLI */ + NFS_SA_DREF(nap, ip_addr); + } + + /************************************************************************/ + /*** NFS PROTOCOL (UDP, TCP) AND VERSION ***/ + /************************************************************************/ +#ifdef HAVE_NFS_ARGS_T_SOTYPE + /* bsdi3 uses this */ + if (nfs_proto) { + if (STREQ(nfs_proto, "tcp")) + nap->sotype = SOCK_STREAM; + else if (STREQ(nfs_proto, "udp")) + nap->sotype = SOCK_DGRAM; + } +#endif /* HAVE_NFS_ARGS_T_SOTYPE */ + +#ifdef HAVE_NFS_ARGS_T_PROTO + nap->proto = 0; /* bsdi3 sets this field to zero */ +# ifdef IPPROTO_TCP + if (nfs_proto) { + if (STREQ(nfs_proto, "tcp")) /* AIX 4.2.x needs this */ + nap->proto = IPPROTO_TCP; + else if (STREQ(nfs_proto, "udp")) + nap->proto = IPPROTO_UDP; + } +# endif /* IPPROTO_TCP */ +#endif /* HAVE_NFS_ARGS_T_SOTYPE */ + +#ifdef HAVE_NFS_ARGS_T_VERSION +# ifdef NFS_ARGSVERSION + nap->version = NFS_ARGSVERSION; /* BSDI 3.0 and OpenBSD 2.2 */ +# endif /* NFS_ARGSVERSION */ +# ifdef DG_MOUNT_NFS_VERSION + nap->version = DG_MOUNT_NFS_VERSION; /* dg-ux */ +# endif /* DG_MOUNT_NFS_VERSION */ +#endif /* HAVE_NFS_ARGS_VERSION */ + + /************************************************************************/ + /*** OTHER NFS SOCKET RELATED OPTIONS AND FLAGS ***/ + /************************************************************************/ + + /************************************************************************/ + /*** OTHER FLAGS AND OPTIONS ***/ + /************************************************************************/ + +#ifdef MNT2_NFS_OPT_BIODS + if ((nap->biods = hasmntval(mntp, MNTTAB_OPT_BIODS))) + nap->flags |= MNT2_NFS_OPT_BIODS; +#endif /* MNT2_NFS_OPT_BIODS */ + +#ifdef MNTTAB_OPT_SYMTTL /* symlink cache time-to-live */ + if ((nap->symttl = hasmntval(mntp, MNTTAB_OPT_SYMTTL))) + nap->args.flags |= MNT2_NFS_OPT_SYMTTL; +#endif /* MNTTAB_OPT_SYMTTL */ + +#ifdef MNT2_NFS_OPT_PGTHRESH /* paging threshold */ + if ((nap->pg_thresh = hasmntval(mntp, MNTTAB_OPT_PGTHRESH))) + nap->args.flags |= MNT2_NFS_OPT_PGTHRESH; +#endif /* MNT2_NFS_OPT_PGTHRESH */ + +#if defined(MNT2_NFS_OPT_POSIX) && defined(MNTTAB_OPT_POSIX) + if (amu_hasmntopt(mntp, MNTTAB_OPT_POSIX) != NULL) { + nap->flags |= MNT2_NFS_OPT_POSIX; +# ifdef HAVE_NFS_ARGS_T_PATHCONF + nap->pathconf = NULL; +# endif /* HAVE_NFS_ARGS_T_PATHCONF */ + } +#endif /* MNT2_NFS_OPT_POSIX && MNTTAB_OPT_POSIX */ + +#ifdef HAVE_TRANSPORT_TYPE_TLI + /* set up syncaddr field */ + nap->syncaddr = (struct netbuf *) NULL; + + /* set up knconf field */ + if (get_knetconfig(&nap->knconf, nfsncp, nfs_proto) < 0) { + plog(XLOG_FATAL, "cannot fill knetconfig structure for nfs_args"); + going_down(1); + return; + } + /* update the flags field for knconf */ + nap->args.flags |= MNT2_NFS_OPT_KNCONF; +#endif /* HAVE_TRANSPORT_TYPE_TLI */ + +#ifdef MNT2_NFS_OPT_FSNAME + nap->fsname = fs_name; + nap->args.flags |= MNT2_NFS_OPT_FSNAME; +#endif /* MNT2_NFS_OPT_FSNAME */ + + +#ifdef HAVE_NFS_ARGS_T_OPTSTR + nap->optstr = mntp->mnt_opts; +#endif /* HAVE_NFS_ARGS_T_OPTSTR */ + +#if defined(MNT2_NFS_OPT_MAXGRPS) && defined(MNTTAB_OPT_MAXGROUPS) + nap->maxgrouplist = hasmntval(mntp, MNTTAB_OPT_MAXGROUPS); + if (nap->maxgrouplist != 0) + nap->flags |= MNT2_NFS_OPT_MAXGRPS; +#endif /* defined(MNT2_NFS_OPT_MAXGRPS) && defined(MNTTAB_OPT_MAXGROUPS) */ + + /************************************************************************/ + /*** FINAL ACTIONS ***/ + /************************************************************************/ + +#ifdef HAVE_NFS_ARGS_T_GFS_FLAGS + /* Ultrix stores generic flags in nfs_args.gfs_flags. */ + nap->gfs_flags = genflags; +#endif /* HAVE_NFS_ARGS_T_FLAGS */ + + return; /* end of compute_nfs_args() function */ +} + +#ifdef HAVE_FS_NFS4 + +#define RPC_AUTH_GSS_KRB5 390003 +#define RPC_AUTH_GSS_KRB5I 390004 +#define RPC_AUTH_GSS_KRB5P 390005 +#define RPC_AUTH_GSS_LKEY 390006 +#define RPC_AUTH_GSS_LKEYI 390007 +#define RPC_AUTH_GSS_LKEYP 390008 +#define RPC_AUTH_GSS_SPKM 390009 +#define RPC_AUTH_GSS_SPKMI 390010 +#define RPC_AUTH_GSS_SPKMP 390011 + +struct { + const char *name; + int num; +} flavours[] = { + { "unix", AUTH_UNIX }, + { "krb5", RPC_AUTH_GSS_KRB5 }, + { "krb5i", RPC_AUTH_GSS_KRB5I }, + { "krb5p", RPC_AUTH_GSS_KRB5P }, + { "lkey", RPC_AUTH_GSS_LKEY }, + { "lkeyi", RPC_AUTH_GSS_LKEYI }, + { "lkeyp", RPC_AUTH_GSS_LKEYP }, + { "spkm", RPC_AUTH_GSS_SPKM }, + { "spkmi", RPC_AUTH_GSS_SPKMI }, + { "spkmp", RPC_AUTH_GSS_SPKMP }, +}; + +static char * +set_nfs4_security(nfs4_args_t *nap, mntent_t *mntp) +{ + const char *o = hasmnteq(mntp, MNTTAB_OPT_SEC); + char *q, *s, *ss; + size_t l, i; + + if (o == NULL) + o = "unix"; + + for (l = 1, q = strchr(o, ','); q; q = strchr(q + 1, ',')) + l++; + + nap->auth_flavours = xmalloc(l * sizeof(*nap->auth_flavours)); + + s = ss = xstrdup(o); + for (;;) { + q = strchr(s, ','); + if (q) + *q = '\0'; + + for (l = 0, i = 0; i < sizeof(flavours) / sizeof(flavours[0]); i++) + if (strcmp(flavours[i].name, s) == 0) { + nap->auth_flavours[l++] = flavours[i].num; + break; + } + + if (i == sizeof(flavours) / sizeof(flavours[0])) + plog(XLOG_ERROR, "Unknown NFSv4 security mechanism %s\n", s); + + if (q == NULL) + break; + + *q = ':'; + s = ++q; + } + + nap->auth_flavourlen = l; + return ss; +} + +static int +get_my_ipv4addr(struct nfs_string *ns) +{ + struct hostent *hp; + char myname[MAXHOSTNAMELEN]; + + if (gethostname(myname, sizeof(myname)) == -1) + return -1; + if ((hp = gethostbyname(myname)) == NULL) + return -1; + if (inet_ntop(AF_INET, hp->h_addr, myname, sizeof(myname)) == NULL) + return -1; + ns->len = strlen(myname); + ns->data = xmalloc(ns->len + 1); + memcpy(ns->data, myname, ns->len + 1); + return 0; +} + +static void +add_nfs4_mntopts(const nfs4_args_t *nap, mntent_t *mntp, char *sec) +{ + char *opts = mntp->mnt_opts; + char buf[1024], addr[128]; + size_t len = strlen(mntp->mnt_opts); + + if (inet_ntop(AF_INET, + &((const struct sockaddr_in *)nap->host_addr)->sin_addr, + addr, sizeof(addr)) == NULL) + return; + + xsnprintf(buf, sizeof(buf), ",clientaddr=%s,addr=%s", nap->client_addr.data, + addr); + + len += strlen(buf) + 1; + + if (sec && strcmp(sec, "unix") != 0) { + len += strlen(sec) + strlen(MNTTAB_OPT_SEC) + 2; /* 2 = ",=" */ + } else + sec = NULL; + + opts = xrealloc(mntp->mnt_opts, len); + xstrlcat(opts, buf, len); + + if (sec) { + xstrlcat(opts, ",", len); + xstrlcat(opts, MNTTAB_OPT_SEC, len); + xstrlcat(opts, "=", len); + xstrlcat(opts, sec, len); + } + + mntp->mnt_opts = opts; +} + +static void +print_nfs4_security(const nfs4_args_t *nap) +{ + char buf[1024]; + char num[64]; + size_t i, j; + + buf[0] = '\0'; + + for (i = 0; i < nap->auth_flavourlen; i++) { + + for (j = 0; j < sizeof(flavours) / sizeof(flavours[0]); j++) + if (flavours[j].num == nap->auth_flavours[i]) { + xstrlcpy(num, flavours[j].name, sizeof(num)); + break; + } + + if (j == sizeof(flavours) / sizeof(flavours[0])) { + plog(XLOG_ERROR, "Unknown NFSv4 security mechanism %d\n", + nap->auth_flavours[i]); + xsnprintf(num, sizeof(num), "*%d*", nap->auth_flavours[i]); + } + + if (buf[0]) + xstrlcat(buf, ":", sizeof(buf)); + + xstrlcat(buf, num, sizeof(buf)); + } + + plog(XLOG_DEBUG, "NA->auth_flavours \"%s\"\n", buf); +} + +static void +discard_nfs4_args(nfs4_args_t *nap) +{ + if (nap->client_addr.data) + free(nap->client_addr.data); + if (nap->hostname.data) + free(nap->hostname.data); + if (nap->mnt_path.data) + free(nap->mnt_path.data); + if (nap->host_addr) + free(nap->host_addr); + if (nap->auth_flavours) + free(nap->auth_flavours); +} + +/* + * Fill in the many possible fields and flags of struct nfs4_args. + * + * nap: pre-allocated structure to fill in. + * mntp: mount entry structure (includes options) + * genflags: generic mount flags already determined + * nfsncp: (TLI only) netconfig entry for this NFS mount + * ip_addr: IP address of file server + * nfs_version: 4, or 0 if unknown + * nfs_proto: "udp", "tcp", or NULL. + * fhp: file handle structure pointer + * host_name: name of remote NFS host + * fs_name: remote file system name to mount + */ +static void +compute_nfs4_args(nfs4_args_t *nap, + mntent_t *mntp, + int genflags, + struct netconfig *nfsncp, + struct sockaddr_in *ip_addr, + u_long nfs_version, + char *nfs_proto, + am_nfs_handle_t *fhp, + char *host_name, + char *fs_name) +{ + char *s; + struct nfs_common_args a; + uint16_t nfs_port; + + /* initialize just in case */ + memset((voidp) nap, 0, sizeof(nfs4_args_t)); + + /* compute all of the NFS attribute-cache flags */ + memset(&a, 0, sizeof(a)); + compute_nfs_attrcache_flags(&a, mntp); + compute_nfs_common_args(&a, mntp, nfs_proto, nfs_version); + get_nfs_common_args(nap, a); + + get_my_ipv4addr(&nap->client_addr); + + /************************************************************************/ + /*** HOST NAME ***/ + /************************************************************************/ + nap->hostname.len = strlen(host_name); + nap->hostname.data = xmalloc(nap->hostname.len + 1); + memcpy(nap->hostname.data, host_name, nap->hostname.len + 1); + + if ((s = strchr(fs_name, ':')) != NULL) + s++; + else + s = fs_name; + + nap->mnt_path.len = strlen(s); + nap->mnt_path.data = xmalloc(nap->mnt_path.len + 1); + memcpy(nap->mnt_path.data, s, nap->mnt_path.len + 1); + plog(XLOG_DEBUG, "dir name %s\n", nap->mnt_path.data); + + /************************************************************************/ + /*** IP ADDRESS OF REMOTE HOST ***/ + /************************************************************************/ + nap->host_addrlen = sizeof(*ip_addr); + nap->host_addr = xmalloc(nap->host_addrlen); + memcpy(nap->host_addr, ip_addr, nap->host_addrlen); + + nfs_port = hasmntval(mntp, MNTTAB_OPT_PORT); + if (nfs_port == 0) + nfs_port = htons(NFS_PORT); + else + nfs_port = htons(nfs_port); + + ((struct sockaddr_in *)nap->host_addr)->sin_port = nfs_port; + + nap->proto = 0; /* bsdi3 sets this field to zero */ + if (nfs_proto) { + if (STREQ(nfs_proto, "tcp")) /* AIX 4.2.x needs this */ + nap->proto = IPPROTO_TCP; + else if (STREQ(nfs_proto, "udp")) + nap->proto = IPPROTO_UDP; + } + + nap->version = NFS4_MOUNT_VERSION; /* BSDI 3.0 and OpenBSD 2.2 */ + + /************************************************************************/ + /*** OTHER NFS SOCKET RELATED OPTIONS AND FLAGS ***/ + /************************************************************************/ + + + /************************************************************************/ + /*** OTHER FLAGS AND OPTIONS ***/ + /************************************************************************/ + +#if defined(MNT2_NFS_OPT_POSIX) && defined(MNTTAB_OPT_POSIX) + if (amu_hasmntopt(mntp, MNTTAB_OPT_POSIX) != NULL) { + nap->args.flags |= MNT2_NFS_OPT_POSIX; +# ifdef HAVE_NFS_ARGS_T_PATHCONF + nap->pathconf = NULL; +# endif /* HAVE_NFS_ARGS_T_PATHCONF */ + } +#endif /* MNT2_NFS_OPT_POSIX && MNTTAB_OPT_POSIX */ + +#if defined(MNT2_NFS_OPT_MAXGRPS) && defined(MNTTAB_OPT_MAXGROUPS) + nap->maxgrouplist = hasmntval(mntp, MNTTAB_OPT_MAXGROUPS); + if (nap->maxgrouplist != 0) + nap->args.flags |= MNT2_NFS_OPT_MAXGRPS; +#endif /* defined(MNT2_NFS_OPT_MAXGRPS) && defined(MNTTAB_OPT_MAXGROUPS) */ + +#ifdef HAVE_NFS_ARGS_T_OPTSTR + nap->optstr = mntp->mnt_opts; +#endif /* HAVE_NFS_ARGS_T_OPTSTR */ + + /************************************************************************/ + /*** FINAL ACTIONS ***/ + /************************************************************************/ + +#ifdef HAVE_NFS_ARGS_T_GFS_FLAGS + /* Ultrix stores generic flags in nfs_args.gfs_flags. */ + nap->gfs_flags = genflags; +#endif /* HAVE_NFS_ARGS_T_FLAGS */ + + s = set_nfs4_security(nap, mntp); + + /* Add addresses to the mount options */ + add_nfs4_mntopts(nap, mntp, s); + + return; /* end of compute_nfs4_args() function */ +} + +#ifdef DEBUG +static void +print_nfs4_args(const nfs4_args_t *nap, u_long nfs_version) +{ + struct sockaddr_in *sap; + struct nfs_common_args a; + + if (!nap) { + plog(XLOG_DEBUG, "NULL nfs_args!"); + return; + } + + plog(XLOG_DEBUG, "NA->client_addr \"%s\"\n", nap->client_addr.data); + plog(XLOG_DEBUG, "NA->mnt_path = \"%s\"", nap->mnt_path.data); + plog(XLOG_DEBUG, "NA->hostname = \"%s\"", nap->hostname.data); + sap = (struct sockaddr_in *) nap->host_addr; + print_nfs_sockaddr_in("host_addr", sap); + plog(XLOG_DEBUG, "NA->proto = %d", (int) nap->proto); +#ifdef HAVE_NFS_ARGS_T_VERSION + plog(XLOG_DEBUG, "NA->version = %d", nap->version); +#endif /* HAVE_NFS_ARGS_T_VERSION */ + print_nfs4_security(nap); + + put_nfs_common_args(nap, a); + print_nfs_common_args(&a); +} +#endif +#endif /* HAVE_FS_NFS4 */ + +void +compute_nfs_args(void *nap, + mntent_t *mntp, + int genflags, + struct netconfig *nfsncp, + struct sockaddr_in *ip_addr, + u_long nfs_version, + char *nfs_proto, + am_nfs_handle_t *fhp, + char *host_name, + char *fs_name) +{ +#ifdef HAVE_FS_NFS4 + if (nfs_version == NFS_VERSION4) + compute_nfs4_args(nap, mntp, genflags, nfsncp, ip_addr, nfs_version, + nfs_proto, fhp, host_name, fs_name); + else +#endif /* HAVE_FS_NFS4 */ + compute_nfs23_args(nap, mntp, genflags, nfsncp, ip_addr, nfs_version, + nfs_proto, fhp, host_name, fs_name); +} + +void +discard_nfs_args(void *nap, u_long nfs_version) +{ +#ifdef HAVE_FS_NFS4 + if (nfs_version == NFS_VERSION4) + discard_nfs4_args(nap); + else +#endif /* HAVE_FS_NFS4 */ + discard_nfs23_args(nap); +} + +#ifdef DEBUG +void +print_nfs_args(const void *nap, u_long nfs_version) +{ +#ifdef HAVE_FS_NFS4 + if (nfs_version == NFS_VERSION4) + print_nfs4_args(nap, nfs_version); + else +#endif /* HAVE_FS_NFS4 */ + print_nfs23_args(nap, nfs_version); +} +#endif + + +/* + * Fill in special values for flags and fields of nfs_args, for an + * automounter NFS mount. + */ +void +compute_automounter_nfs_args(nfs_args_t *nap, mntent_t *mntp) +{ + struct nfs_common_args a; + +#ifdef MNT2_NFS_OPT_SYMTTL + /* + * Don't let the kernel cache symbolic links we generate, or else lookups + * will bypass amd and fail to remount stuff as needed. + */ + plog(XLOG_INFO, "turning on NFS option symttl and setting value to 0"); + nap->flags |= MNT2_NFS_OPT_SYMTTL; + nap->symttl = 0; +#endif /* MNT2_NFS_OPT_SYMTTL */ + + /* + * This completes the flags for the HIDE_MOUNT_TYPE code in the + * mount_amfs_toplvl() function in amd/amfs_toplvl.c. + * Some systems don't have a mount type, but a mount flag. + */ +#ifdef MNT2_NFS_OPT_AUTO + nap->flags |= MNT2_NFS_OPT_AUTO; +#endif /* MNT2_NFS_OPT_AUTO */ +#ifdef MNT2_NFS_OPT_IGNORE + nap->flags |= MNT2_NFS_OPT_IGNORE; +#endif /* MNT2_NFS_OPT_IGNORE */ +#ifdef MNT2_GEN_OPT_AUTOMNTFS + nap->flags |= MNT2_GEN_OPT_AUTOMNTFS; +#endif /* not MNT2_GEN_OPT_AUTOMNTFS */ + +#ifdef MNT2_NFS_OPT_DUMBTIMR + /* + * Don't let the kernel start computing throughput of Amd. The numbers + * will be meaningless because of the way Amd does mount retries. + */ + plog(XLOG_INFO, "%s: disabling nfs congestion window", mntp->mnt_dir); + nap->flags |= MNT2_NFS_OPT_DUMBTIMR; +#endif /* MNT2_NFS_OPT_DUMBTIMR */ + + /* compute all of the NFS attribute-cache flags */ + memset(&a, 0, sizeof(a)); + a.flags = nap->flags; + compute_nfs_attrcache_flags(&a, mntp); + get_nfs_common_args(nap, a); + + /* + * Provide a slight bit more security by requiring the kernel to use + * reserved ports. + */ +#ifdef MNT2_NFS_OPT_RESVPORT + nap->flags |= MNT2_NFS_OPT_RESVPORT; +#endif /* MNT2_NFS_OPT_RESVPORT */ +} + +int +nfs_valid_version(u_long v) +{ + return v >= NFS_VERS_MIN && v <= NFS_VERS_MAX; +} diff --git a/libamu/mtab.c b/libamu/mtab.c index 50ba994733f0..ee603af34359 100644 --- a/libamu/mtab.c +++ b/libamu/mtab.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2014 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -16,11 +16,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * 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 acknowledgment: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -233,9 +229,9 @@ hasmntstr(mntent_t *mnt, char *opt) char *endptr = strchr(eq, ','); - /* if saw no comma, return strdup'd string */ + /* if saw no comma, return xstrdup'd string */ if (!endptr) - return strdup(eq); + return xstrdup(eq); else { /* else we need to copy only the chars needed */ int len = endptr - eq; diff --git a/libamu/nfs_prot_xdr.c b/libamu/nfs_prot_xdr.c index df8a0b006b55..bfdc7b2492a3 100644 --- a/libamu/nfs_prot_xdr.c +++ b/libamu/nfs_prot_xdr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2014 Erez Zadok * Copyright (c) 1989 Jan-Simon Pendry * Copyright (c) 1989 Imperial College of Science, Technology & Medicine * Copyright (c) 1989 The Regents of the University of California. @@ -16,11 +16,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * 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 acknowledgment: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -56,3 +52,14 @@ xdr_amq_string(XDR *xdrs, amq_string *objp) } return (TRUE); } + + +bool_t +xdr_amq_sync_umnt(XDR *xdrs, amq_sync_umnt *objp) +{ + + if (!xdr_opaque(xdrs, (char *) objp, sizeof(*objp))) { + return (FALSE); + } + return (TRUE); +} diff --git a/libamu/strcasecmp.c b/libamu/strcasecmp.c new file mode 100644 index 000000000000..3947a94851b7 --- /dev/null +++ b/libamu/strcasecmp.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 1997-2014 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * + * File: am-utils/libamu/strcasecmp.c + * + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ +#include <am_defs.h> +#include <amu.h> + +/* + * Compare two strings case insensitive. + */ +int +strcasecmp(const char *s1, const char *s2) +{ + const unsigned char *cp1 = (const unsigned char *)s1; + const unsigned char *cp2 = (const unsigned char *)s2; + + while (tolower(*cp1) == tolower(*cp2++)) + if (*cp1++ == '\0') + return (0); + return (tolower(*cp1) - tolower(*--cp2)); +} diff --git a/libamu/strerror.c b/libamu/strerror.c index 49dd2fc3ce9f..faf2916f31e6 100644 --- a/libamu/strerror.c +++ b/libamu/strerror.c @@ -1,6 +1,6 @@ /* - * Copyright (c) 2002-2006 Ion Badulescu - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 2002-2014 Ion Badulescu + * Copyright (c) 1997-2014 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -17,11 +17,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * 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 acknowledgment: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * diff --git a/libamu/strlcat.c b/libamu/strlcat.c new file mode 100644 index 000000000000..154eaa8eae40 --- /dev/null +++ b/libamu/strlcat.c @@ -0,0 +1,83 @@ +/* + * Copyright (c) 1997-2014 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * + * File: am-utils/libamu/strlcat.c + * + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ +#include <am_defs.h> +#include <amu.h> + +/* + * Implementation of strlcat(3) from OpenBSD/NetBSD. + */ + +/* + * Appends src to string dst of size siz (unlike strncat, siz is the + * full size of dst, not space left). At most siz-1 characters + * will be copied. Always NUL terminates (unless siz <= strlen(dst)). + * Returns strlen(src) + MIN(siz, strlen(initial dst)). + * If retval >= siz, truncation occurred. + */ +size_t +strlcat(char *dst, const char *src, size_t siz) +{ + char *d = dst; + const char *s = src; + size_t n = siz; + size_t dlen; + + /* Find the end of dst and adjust bytes left but don't go past end */ + while (n-- != 0 && *d != '\0') + d++; + dlen = d - dst; + n = siz - dlen; + + if (n == 0) + return(dlen + strlen(s)); + while (*s != '\0') { + if (n != 1) { + *d++ = *s; + n--; + } + s++; + } + *d = '\0'; + + return(dlen + (s - src)); /* count does not include NUL */ +} diff --git a/libamu/strlcpy.c b/libamu/strlcpy.c new file mode 100644 index 000000000000..f0c4f6782e62 --- /dev/null +++ b/libamu/strlcpy.c @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1997-2014 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * + * File: am-utils/libamu/strlcpy.c + * + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ +#include <am_defs.h> +#include <amu.h> + +/* + * Implementation of strlcpy(3) from OpenBSD/NetBSD. + */ + +/* + * Copy src to string dst of size siz. At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + */ +size_t +strlcpy(char *dst, const char *src, size_t siz) +{ + char *d = dst; + const char *s = src; + size_t n = siz; + + + /* Copy as many bytes as will fit */ + if (n != 0 && --n != 0) { + do { + if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } + + /* Not enough room in dst, add NUL and traverse rest of src */ + if (n == 0) { + if (siz != 0) + *d = '\0'; /* NUL-terminate dst */ + while (*s++) + ; + } + + return(s - src - 1); /* count does not include NUL */ +} diff --git a/libamu/strstr.c b/libamu/strstr.c new file mode 100644 index 000000000000..bd89991dda11 --- /dev/null +++ b/libamu/strstr.c @@ -0,0 +1,93 @@ +/* + * Copyright (c) 1997-2014 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from the Free Software Foundation, Inc. GNU utilities. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * + * File: am-utils/libamu/strstr.c + * + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ +#include <am_defs.h> +#include <amu.h> + + +/* strstr.c -- return the offset of one string within another + Copyright (C) 1989, 1990 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Author: + Mike Rendell Department of Computer Science + michael@garfield.mun.edu Memorial University of Newfoundland + ..!uunet!garfield!michael St. John's, Nfld., Canada + (709) 737-4550 A1C 5S7 +*/ + + +/* + * Return the starting address of string S2 in S1; + * return 0 if it is not found. + */ +char * +strstr(char *s1, char *s2) +{ + int i; + char *p1; + char *p2; + char *s = s1; + + for (p2 = s2, i = 0; *s; p2 = s2, i++, s++) { + for (p1 = s; *p1 && *p2 && *p1 == *p2; p1++, p2++) + ; + if (!*p2) + break; + } + if (!*p2) + return s1 + i; + + return 0; +} diff --git a/libamu/strutil.c b/libamu/strutil.c index 5a1e759bff67..03a8e88f6080 100644 --- a/libamu/strutil.c +++ b/libamu/strutil.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2014 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -16,11 +16,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * 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 acknowledgment: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -268,3 +264,37 @@ xvsnprintf(char *str, size_t size, const char *format, va_list ap) return ret; } + +static size_t +vstrlen(const char *src, va_list ap) +{ + size_t len = strlen(src); + while ((src = va_arg(ap, const char *)) != NULL) + len += strlen(src); + return len; +} + +static void +vstrcpy(char *dst, const char *src, va_list ap) +{ + strcpy(dst, src); + while ((src = va_arg(ap, const char *)) != NULL) + strcat(dst, src); +} + +char * +strvcat(const char *src, ...) +{ + size_t len; + char *dst; + va_list ap; + + va_start(ap, src); + len = vstrlen(src, ap); + va_end(ap); + dst = xmalloc(len + 1); + va_start(ap, src); + vstrcpy(dst, src, ap); + va_end(ap); + return dst; +} diff --git a/libamu/ualarm.c b/libamu/ualarm.c new file mode 100644 index 000000000000..86280d92b75a --- /dev/null +++ b/libamu/ualarm.c @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1997-2014 Erez Zadok + * Copyright (c) 1990 Jan-Simon Pendry + * Copyright (c) 1990 Imperial College of Science, Technology & Medicine + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry at Imperial College, London. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * + * File: am-utils/libamu/ualarm.c + * + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif /* HAVE_CONFIG_H */ +#include <am_defs.h> +#include <amu.h> + +#define USPS 1000000 /* # of microseconds in a second */ + + +/* + * Generate a SIGALRM signal in ``usecs'' microseconds. + * If ``reload'' is non-zero, keep generating SIGALRM + * every ``reload'' microseconds after the first signal. + */ +u_int +ualarm(u_int usecs, u_int interval) +{ + struct itimerval new, old; + + new.it_interval.tv_usec = interval % USPS; + new.it_interval.tv_sec = interval / USPS; + new.it_value.tv_usec = usecs % USPS; + new.it_value.tv_sec = usecs / USPS; + + if (setitimer(ITIMER_REAL, &new, &old) == 0) + return (old.it_value.tv_sec * USPS + old.it_value.tv_usec); + + return -1; +} diff --git a/libamu/wire.c b/libamu/wire.c index c1852cdca7f1..c9da0fe276a5 100644 --- a/libamu/wire.c +++ b/libamu/wire.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2014 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -16,11 +16,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * 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 acknowledgment: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -226,7 +222,7 @@ getwire_lookup(u_long address, u_long netmask, int ishost) } /* fill in network number (string) */ - al->ip_net_num = strdup(netNumberBuf); + al->ip_net_num = xstrdup(netNumberBuf); if (np != NULL) s = np->n_name; @@ -242,7 +238,7 @@ getwire_lookup(u_long address, u_long netmask, int ishost) } /* fill in network name (string) */ - al->ip_net_name = strdup(s); + al->ip_net_name = xstrdup(s); /* Let's be cautious here about buffer overflows -Ion */ if (strlen(s) > MAXHOSTNAMELEN) { al->ip_net_name[MAXHOSTNAMELEN] = '\0'; @@ -318,9 +314,14 @@ is_network_member(const char *net) if (STREQ(net, al->ip_net_name) || STREQ(net, al->ip_net_num)) return TRUE; } else { - char *netstr = strdup(net), *maskstr; + char *netstr = xstrdup(net), *maskstr; u_long netnum, masknum = 0; maskstr = strchr(netstr, '/'); + if (maskstr == NULL) { + plog(XLOG_ERROR, "%s: netstr %s does not have a `/'", __func__, netstr); + XFREE(netstr); + return FALSE; + } maskstr[0] = '\0'; /* null terminate netstr */ maskstr++; if (*maskstr == '\0') /* if empty string, make it NULL */ diff --git a/libamu/xdr_func.c b/libamu/xdr_func.c index 6bd0254318c6..7453f701638a 100644 --- a/libamu/xdr_func.c +++ b/libamu/xdr_func.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2014 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -16,11 +16,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * 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 acknowledgment: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -951,7 +947,6 @@ xdr_am_mountres3_ok(XDR *xdrs, am_mountres3_ok *objp) return (TRUE); } - bool_t xdr_am_mountres3(XDR *xdrs, am_mountres3 *objp) { @@ -968,6 +963,75 @@ xdr_am_mountres3(XDR *xdrs, am_mountres3 *objp) return (TRUE); } +bool_t +xdr_am_cookieverf3(XDR *xdrs, am_cookieverf3 objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_cookieverf3:"); + + if (!xdr_opaque(xdrs, objp, AM_NFS3_COOKIEVERFSIZE)) + return FALSE; + return TRUE; +} + +/* + * Not ideal, xdr_u_int64_t() is not defined in Linux glibc RPC + * but xdr_u_quad_t() is. But in libtirpc xdr_u_quad_t() is not + * defined and xdr_u_int64_t() is. So xdr_u_int64_t() is probably + * an expected standard xdr function so, if it isn't defined use + * an internal xdr_u_int64_t() that uses xdr_u_quad_t(). + */ +#ifndef HAVE_XDR_U_INT64_T +#define xdr_u_int64_t(xdrs, objp) xdr_u_quad_t(xdrs, objp) +#endif /* HAVE_XDR_U_INT64_T */ + +bool_t +xdr_uint64(XDR *xdrs, uint64 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_uint64:"); + + if (!xdr_u_int64_t(xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_cookie3(XDR *xdrs, am_cookie3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_cookie3:"); + + if (!xdr_uint64(xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_nfs_fh3(XDR *xdrs, am_nfs_fh3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_nfs_fh3:"); + + if (!xdr_u_int(xdrs, &objp->am_fh3_length)) + return (FALSE); + if (objp->am_fh3_length > AM_FHSIZE3) + return (FALSE); + if (!xdr_opaque(xdrs, objp->am_fh3_data, objp->am_fh3_length)) + return (FALSE); + return (TRUE); +} + +bool_t +xdr_am_nfsstat3(XDR *xdrs, am_nfsstat3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_nfsstat3:"); + + if (!xdr_enum(xdrs, (enum_t *)objp)) + return (FALSE); + return (TRUE); +} bool_t xdr_am_diropargs3(XDR *xdrs, am_diropargs3 *objp) @@ -982,7 +1046,6 @@ xdr_am_diropargs3(XDR *xdrs, am_diropargs3 *objp) return (TRUE); } - bool_t xdr_am_filename3(XDR *xdrs, am_filename3 *objp) { @@ -994,6 +1057,315 @@ xdr_am_filename3(XDR *xdrs, am_filename3 *objp) return (TRUE); } +bool_t +xdr_am_ftype3(XDR *xdrs, am_ftype3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_ftype3:"); + + if (!xdr_enum(xdrs, (enum_t *) objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_mode3(XDR *xdrs, am_mode3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_mode3:"); + + if (!xdr_u_int(xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_uid3(XDR *xdrs, am_uid3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_uid3:"); + + if (!xdr_u_int(xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_gid3(XDR *xdrs, am_gid3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_gid3:"); + + if (!xdr_u_int(xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_size3(XDR *xdrs, am_size3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_size3:"); + + if (!xdr_uint64(xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_fileid3(XDR *xdrs, am_fileid3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_fileid3:"); + + if (!xdr_uint64(xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_specdata3(XDR *xdrs, am_specdata3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_specdata3:"); + + if (!xdr_u_int(xdrs, &objp->specdata1)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->specdata2)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_nfstime3(XDR *xdrs, am_nfstime3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_nfstime3:"); + + if (!xdr_u_int(xdrs, &objp->seconds)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->nseconds)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_fattr3(XDR *xdrs, am_fattr3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_fattr3:"); + + if (!xdr_am_ftype3(xdrs, &objp->type)) + return FALSE; + if (!xdr_am_mode3(xdrs, &objp->mode)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->nlink)) + return FALSE; + if (!xdr_am_uid3(xdrs, &objp->uid)) + return FALSE; + if (!xdr_am_gid3(xdrs, &objp->gid)) + return FALSE; + if (!xdr_am_size3(xdrs, &objp->size)) + return FALSE; + if (!xdr_am_size3(xdrs, &objp->used)) + return FALSE; + if (!xdr_am_specdata3(xdrs, &objp->rdev)) + return FALSE; + if (!xdr_uint64(xdrs, &objp->fsid)) + return FALSE; + if (!xdr_am_fileid3(xdrs, &objp->fileid)) + return FALSE; + if (!xdr_am_nfstime3(xdrs, &objp->atime)) + return FALSE; + if (!xdr_am_nfstime3(xdrs, &objp->mtime)) + return FALSE; + if (!xdr_am_nfstime3(xdrs, &objp->ctime)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_post_op_attr(XDR *xdrs, am_post_op_attr *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_post_op_attr:"); + + if (!xdr_bool(xdrs, &objp->attributes_follow)) + return FALSE; + switch (objp->attributes_follow) { + case TRUE: + if (!xdr_am_fattr3(xdrs, &objp->am_post_op_attr_u.attributes)) + return FALSE; + break; + case FALSE: + break; + default: + return FALSE; + } + return TRUE; +} + +bool_t +xdr_am_stable_how(XDR *xdrs, am_stable_how *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_stable_how:"); + + if (!xdr_enum(xdrs, (enum_t *) objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_offset3(XDR *xdrs, am_offset3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_offset3:"); + + if (!xdr_uint64(xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_count3(XDR *xdrs, am_count3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_count3:"); + + if (!xdr_u_int(xdrs, objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_wcc_attr(XDR *xdrs, am_wcc_attr *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_wcc_attr:"); + + if (!xdr_am_size3(xdrs, &objp->size)) + return FALSE; + if (!xdr_am_nfstime3(xdrs, &objp->mtime)) + return FALSE; + if (!xdr_am_nfstime3(xdrs, &objp->ctime)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_pre_op_attr(XDR *xdrs, am_pre_op_attr *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, ":xdr_am_pre_op_attr"); + + if (!xdr_bool(xdrs, &objp->attributes_follow)) + return FALSE; + switch (objp->attributes_follow) { + case TRUE: + if (!xdr_am_wcc_attr(xdrs, &objp->am_pre_op_attr_u.attributes)) + return FALSE; + break; + case FALSE: + break; + default: + return FALSE; + } + return TRUE; +} + +bool_t +xdr_am_wcc_data(XDR *xdrs, am_wcc_data *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_wcc_data:"); + + if (!xdr_am_pre_op_attr(xdrs, &objp->before)) + return FALSE; + if (!xdr_am_post_op_attr(xdrs, &objp->after)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_WRITE3args(XDR *xdrs, am_WRITE3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_WRITE3args:"); + + if (!xdr_am_nfs_fh3(xdrs, &objp->file)) + return FALSE; + if (!xdr_am_offset3(xdrs, &objp->offset)) + return FALSE; + if (!xdr_am_count3(xdrs, &objp->count)) + return FALSE; + if (!xdr_am_stable_how(xdrs, &objp->stable)) + return FALSE; + if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, + (u_int *) &objp->data.data_len, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_writeverf3(XDR *xdrs, am_writeverf3 objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_writeverf3:"); + + if (!xdr_opaque(xdrs, objp, AM_NFS3_WRITEVERFSIZE)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_WRITE3resok(XDR *xdrs, am_WRITE3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_WRITE3resok:"); + + if (!xdr_am_wcc_data(xdrs, &objp->file_wcc)) + return FALSE; + if (!xdr_am_count3(xdrs, &objp->count)) + return FALSE; + if (!xdr_am_stable_how(xdrs, &objp->committed)) + return FALSE; + if (!xdr_am_writeverf3(xdrs, objp->verf)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_WRITE3resfail(XDR *xdrs, am_WRITE3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_WRITE3resfail:"); + + if (!xdr_am_wcc_data(xdrs, &objp->file_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_WRITE3res(XDR *xdrs, am_WRITE3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_WRITE3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_WRITE3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_WRITE3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} bool_t xdr_am_LOOKUP3args(XDR *xdrs, am_LOOKUP3args *objp) @@ -1006,7 +1378,6 @@ xdr_am_LOOKUP3args(XDR *xdrs, am_LOOKUP3args *objp) return (TRUE); } - bool_t xdr_am_LOOKUP3res(XDR *xdrs, am_LOOKUP3res *objp) { @@ -1028,25 +1399,17 @@ xdr_am_LOOKUP3res(XDR *xdrs, am_LOOKUP3res *objp) return (TRUE); } - bool_t xdr_am_LOOKUP3resfail(XDR *xdrs, am_LOOKUP3resfail *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_am_LOOKUP3resfail:"); - /* - * Don't xdr post_op_attr: amd doesn't need them, but they require many - * additional xdr functions. - */ -#if 0 - if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) + if (!xdr_am_post_op_attr(xdrs, &objp->dir_attributes)) return (FALSE); -#endif return (TRUE); } - bool_t xdr_am_LOOKUP3resok(XDR *xdrs, am_LOOKUP3resok *objp) { @@ -1055,44 +1418,1656 @@ xdr_am_LOOKUP3resok(XDR *xdrs, am_LOOKUP3resok *objp) if (!xdr_am_nfs_fh3(xdrs, &objp->object)) return (FALSE); - /* - * Don't xdr post_op_attr: amd doesn't need them, but they require many - * additional xdr functions. - */ -#if 0 - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) return (FALSE); - if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) + if (!xdr_am_post_op_attr(xdrs, &objp->dir_attributes)) return (FALSE); -#endif return (TRUE); } +bool_t +xdr_am_COMMIT3args(XDR *xdrs, am_COMMIT3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_COMMIT3args:"); + + if (!xdr_am_nfs_fh3(xdrs, &objp->file)) + return FALSE; + if (!xdr_am_offset3(xdrs, &objp->offset)) + return FALSE; + if (!xdr_am_count3(xdrs, &objp->count)) + return FALSE; + return TRUE; +} bool_t -xdr_am_nfs_fh3(XDR *xdrs, am_nfs_fh3 *objp) +xdr_am_COMMIT3resok(XDR *xdrs, am_COMMIT3resok *objp) { if (amuDebug(D_XDRTRACE)) - plog(XLOG_DEBUG, "xdr_am_nfs_fh3:"); + plog(XLOG_DEBUG, "xdr_am_COMMIT3resok:"); - if (!xdr_u_int(xdrs, &objp->am_fh3_length)) - return (FALSE); - if (objp->am_fh3_length > AM_FHSIZE3) - return (FALSE); - if (!xdr_opaque(xdrs, objp->am_fh3_data, objp->am_fh3_length)) - return (FALSE); - return (TRUE); + if (!xdr_am_wcc_data(xdrs, &objp->file_wcc)) + return FALSE; + if (!xdr_am_writeverf3(xdrs, objp->verf)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_COMMIT3resfail(XDR *xdrs, am_COMMIT3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_COMMIT3resfail:"); + + if (!xdr_am_wcc_data(xdrs, &objp->file_wcc)) + return FALSE; + return TRUE; } +bool_t +xdr_am_COMMIT3res(XDR *xdrs, am_COMMIT3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_COMMIT3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_COMMIT3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_COMMIT3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} bool_t -xdr_am_nfsstat3(XDR *xdrs, am_nfsstat3 *objp) +xdr_am_ACCESS3args(XDR *xdrs, am_ACCESS3args *objp) { if (amuDebug(D_XDRTRACE)) - plog(XLOG_DEBUG, "xdr_am_nfsstat3:"); + plog(XLOG_DEBUG, "xdr_am_ACCESS3args:"); - if (!xdr_enum(xdrs, (enum_t *)objp)) - return (FALSE); - return (TRUE); + if (!xdr_am_nfs_fh3(xdrs, &objp->object)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->access)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_ACCESS3resok(XDR *xdrs, am_ACCESS3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_ACCESS3resok:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->access)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_ACCESS3resfail(XDR *xdrs, am_ACCESS3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_ACCESS3resfail:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_ACCESS3res(XDR *xdrs, am_ACCESS3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_ACCESS3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_ACCESS3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_ACCESS3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_GETATTR3args(XDR *xdrs, am_GETATTR3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_GETATTR3args:"); + + if (!xdr_am_nfs_fh3(xdrs, &objp->object)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_GETATTR3resok(XDR *xdrs, am_GETATTR3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_GETATTR3resok:"); + + if (!xdr_am_fattr3(xdrs, &objp->obj_attributes)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_GETATTR3res(XDR *xdrs, am_GETATTR3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_GETATTR3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_GETATTR3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + break; + } + return TRUE; +} + +bool_t +xdr_am_time_how(XDR *xdrs, am_time_how *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_time_how:"); + + if (!xdr_enum(xdrs, (enum_t *) objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_set_mode3(XDR *xdrs, am_set_mode3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_set_mode3:"); + + if (!xdr_bool(xdrs, &objp->set_it)) + return FALSE; + switch (objp->set_it) { + case TRUE: + if (!xdr_am_mode3(xdrs, &objp->am_set_mode3_u.mode)) + return FALSE; + break; + default: + break; + } + return TRUE; +} + +bool_t +xdr_am_set_uid3(XDR *xdrs, am_set_uid3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_set_uid3:"); + + if (!xdr_bool(xdrs, &objp->set_it)) + return FALSE; + switch (objp->set_it) { + case TRUE: + if (!xdr_am_uid3(xdrs, &objp->am_set_uid3_u.uid)) + return FALSE; + break; + default: + break; + } + return TRUE; +} + +bool_t +xdr_am_set_gid3(XDR *xdrs, am_set_gid3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_set_gid3:"); + + if (!xdr_bool(xdrs, &objp->set_it)) + return FALSE; + switch (objp->set_it) { + case TRUE: + if (!xdr_am_gid3(xdrs, &objp->am_set_gid3_u.gid)) + return FALSE; + break; + default: + break; + } + return TRUE; +} + +bool_t +xdr_am_set_size3(XDR *xdrs, am_set_size3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_set_size3:"); + + if (!xdr_bool(xdrs, &objp->set_it)) + return FALSE; + switch (objp->set_it) { + case TRUE: + if (!xdr_am_size3(xdrs, &objp->am_set_size3_u.size)) + return FALSE; + break; + default: + break; + } + return TRUE; +} + +bool_t +xdr_am_set_atime(XDR *xdrs, am_set_atime *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_set_atime:"); + + if (!xdr_am_time_how(xdrs, &objp->set_it)) + return FALSE; + switch (objp->set_it) { + case AM_SET_TO_CLIENT_TIME: + if (!xdr_am_nfstime3(xdrs, &objp->am_set_atime_u.atime)) + return FALSE; + break; + default: + break; + } + return TRUE; +} + +bool_t +xdr_am_set_mtime(XDR *xdrs, am_set_mtime *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_set_mtime:"); + + if (!xdr_am_time_how(xdrs, &objp->set_it)) + return FALSE; + switch (objp->set_it) { + case AM_SET_TO_CLIENT_TIME: + if (!xdr_am_nfstime3(xdrs, &objp->am_set_mtime_u.mtime)) + return FALSE; + break; + default: + break; + } + return TRUE; +} + +bool_t +xdr_am_sattr3(XDR *xdrs, am_sattr3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_sattr3:"); + + if (!xdr_am_set_mode3(xdrs, &objp->mode)) + return FALSE; + if (!xdr_am_set_uid3(xdrs, &objp->uid)) + return FALSE; + if (!xdr_am_set_gid3(xdrs, &objp->gid)) + return FALSE; + if (!xdr_am_set_size3(xdrs, &objp->size)) + return FALSE; + if (!xdr_am_set_atime(xdrs, &objp->atime)) + return FALSE; + if (!xdr_am_set_mtime(xdrs, &objp->mtime)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_createmode3(XDR *xdrs, am_createmode3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_createmode3:"); + + if (!xdr_enum(xdrs, (enum_t *) objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_createverf3(XDR *xdrs, am_createverf3 objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_createverf3:"); + + if (!xdr_opaque(xdrs, objp, AM_NFS3_CREATEVERFSIZE)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_createhow3(XDR *xdrs, am_createhow3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_createhow3:"); + + if (!xdr_am_createmode3(xdrs, &objp->mode)) + return FALSE; + switch (objp->mode) { + case AM_UNCHECKED: + if (!xdr_am_sattr3(xdrs, &objp->am_createhow3_u.obj_attributes)) + return FALSE; + break; + case AM_GUARDED: + if (!xdr_am_sattr3(xdrs, &objp->am_createhow3_u.g_obj_attributes)) + return FALSE; + break; + case AM_EXCLUSIVE: + if (!xdr_am_createverf3(xdrs, objp->am_createhow3_u.verf)) + return FALSE; + break; + default: + return FALSE; + } + return TRUE; +} + +bool_t +xdr_am_CREATE3args(XDR *xdrs, am_CREATE3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_CREATE3args:"); + + if (!xdr_am_diropargs3(xdrs, &objp->where)) + return FALSE; + if (!xdr_am_createhow3(xdrs, &objp->how)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_post_op_fh3(XDR *xdrs, am_post_op_fh3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_post_op_fh3:"); + + if (!xdr_bool(xdrs, &objp->handle_follows)) + return FALSE; + switch (objp->handle_follows) { + case TRUE: + if (!xdr_am_nfs_fh3(xdrs, &objp->am_post_op_fh3_u.handle)) + return FALSE; + break; + case FALSE: + break; + default: + return FALSE; + } + return TRUE; +} + +bool_t +xdr_am_CREATE3resok(XDR *xdrs, am_CREATE3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_CREATE3resok:"); + + if (!xdr_am_post_op_fh3(xdrs, &objp->obj)) + return FALSE; + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + if (!xdr_am_wcc_data(xdrs, &objp->dir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_CREATE3resfail(XDR *xdrs, am_CREATE3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_CREATE3resfail:"); + + if (!xdr_am_wcc_data(xdrs, &objp->dir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_CREATE3res(XDR *xdrs, am_CREATE3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_CREATE3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_CREATE3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_CREATE3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_REMOVE3args(XDR *xdrs, am_REMOVE3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_REMOVE3args:"); + + if (!xdr_am_diropargs3(xdrs, &objp->object)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_REMOVE3resok(XDR *xdrs, am_REMOVE3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_REMOVE3resok:"); + + if (!xdr_am_wcc_data(xdrs, &objp->dir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_REMOVE3resfail(XDR *xdrs, am_REMOVE3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_REMOVE3resfail:"); + + if (!xdr_am_wcc_data(xdrs, &objp->dir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_REMOVE3res(XDR *xdrs, am_REMOVE3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_REMOVE3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_REMOVE3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_REMOVE3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_READ3args(XDR *xdrs, am_READ3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READ3args:"); + + if (!xdr_am_nfs_fh3(xdrs, &objp->file)) + return FALSE; + if (!xdr_am_offset3(xdrs, &objp->offset)) + return FALSE; + if (!xdr_am_count3(xdrs, &objp->count)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_READ3resok(XDR *xdrs, am_READ3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READ3resok:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->file_attributes)) + return FALSE; + if (!xdr_am_count3(xdrs, &objp->count)) + return FALSE; + if (!xdr_bool(xdrs, &objp->eof)) + return FALSE; + if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_READ3resfail(XDR *xdrs, am_READ3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READ3resfail:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->file_attributes)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_READ3res(XDR *xdrs, am_READ3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READ3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_READ3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_READ3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_FSINFO3args(XDR *xdrs, am_FSINFO3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_FSINFO3args:"); + + if (!xdr_am_nfs_fh3(xdrs, &objp->fsroot)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_FSINFO3resok(XDR *xdrs, am_FSINFO3resok *objp) +{ + register int32_t *buf; + + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_FSINFO3resok:"); + + if (xdrs->x_op == XDR_ENCODE) { + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + buf = XDR_INLINE(xdrs, 7 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_int(xdrs, &objp->rtmax)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->rtpref)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->rtmult)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->wtmax)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->wtpref)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->wtmult)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->dtpref)) + return FALSE; + } else { + IXDR_PUT_U_LONG(buf, objp->rtmax); + IXDR_PUT_U_LONG(buf, objp->rtpref); + IXDR_PUT_U_LONG(buf, objp->rtmult); + IXDR_PUT_U_LONG(buf, objp->wtmax); + IXDR_PUT_U_LONG(buf, objp->wtpref); + IXDR_PUT_U_LONG(buf, objp->wtmult); + IXDR_PUT_U_LONG(buf, objp->dtpref); + } + if (!xdr_am_size3(xdrs, &objp->maxfilesize)) + return FALSE; + if (!xdr_am_nfstime3(xdrs, &objp->time_delta)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->properties)) + return FALSE; + return TRUE; + } else if (xdrs->x_op == XDR_DECODE) { + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + buf = XDR_INLINE(xdrs, 7 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_int (xdrs, &objp->rtmax)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->rtpref)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->rtmult)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->wtmax)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->wtpref)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->wtmult)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->dtpref)) + return FALSE; + } else { + objp->rtmax = IXDR_GET_U_LONG(buf); + objp->rtpref = IXDR_GET_U_LONG(buf); + objp->rtmult = IXDR_GET_U_LONG(buf); + objp->wtmax = IXDR_GET_U_LONG(buf); + objp->wtpref = IXDR_GET_U_LONG(buf); + objp->wtmult = IXDR_GET_U_LONG(buf); + objp->dtpref = IXDR_GET_U_LONG(buf); + } + if (!xdr_am_size3(xdrs, &objp->maxfilesize)) + return FALSE; + if (!xdr_am_nfstime3(xdrs, &objp->time_delta)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->properties)) + return FALSE; + return TRUE; + } + + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->rtmax)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->rtpref)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->rtmult)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->wtmax)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->wtpref)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->wtmult)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->dtpref)) + return FALSE; + if (!xdr_am_size3(xdrs, &objp->maxfilesize)) + return FALSE; + if (!xdr_am_nfstime3(xdrs, &objp->time_delta)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->properties)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_FSINFO3resfail(XDR *xdrs, am_FSINFO3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_FSINFO3resfail:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_FSINFO3res(XDR *xdrs, am_FSINFO3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_FSINFO3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_FSINFO3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_FSINFO3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_FSSTAT3args(XDR *xdrs, am_FSSTAT3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_FSSTAT3args:"); + + if (!xdr_am_nfs_fh3(xdrs, &objp->fsroot)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_FSSTAT3resok(XDR *xdrs, am_FSSTAT3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_FSSTAT3resok:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + if (!xdr_am_size3(xdrs, &objp->tbytes)) + return FALSE; + if (!xdr_am_size3(xdrs, &objp->fbytes)) + return FALSE; + if (!xdr_am_size3(xdrs, &objp->abytes)) + return FALSE; + if (!xdr_am_size3(xdrs, &objp->tfiles)) + return FALSE; + if (!xdr_am_size3(xdrs, &objp->ffiles)) + return FALSE; + if (!xdr_am_size3(xdrs, &objp->afiles)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->invarsec)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_FSSTAT3resfail(XDR *xdrs, am_FSSTAT3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_FSSTAT3resfail:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_FSSTAT3res(XDR *xdrs, am_FSSTAT3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_FSSTAT3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_FSSTAT3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_FSSTAT3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_PATHCONF3args(XDR *xdrs, am_PATHCONF3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_PATHCONF3args:"); + + if (!xdr_am_nfs_fh3(xdrs, &objp->object)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_PATHCONF3resok(XDR *xdrs, am_PATHCONF3resok *objp) +{ + register int32_t *buf; + + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_PATHCONF3resok:"); + + if (xdrs->x_op == XDR_ENCODE) { + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_int(xdrs, &objp->linkmax)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->name_max)) + return FALSE; + if (!xdr_bool(xdrs, &objp->no_trunc)) + return FALSE; + if (!xdr_bool(xdrs, &objp->chown_restricted)) + return FALSE; + if (!xdr_bool(xdrs, &objp->case_insensitive)) + return FALSE; + if (!xdr_bool(xdrs, &objp->case_preserving)) + return FALSE; + } else { + IXDR_PUT_U_LONG(buf, objp->linkmax); + IXDR_PUT_U_LONG(buf, objp->name_max); + IXDR_PUT_BOOL(buf, objp->no_trunc); + IXDR_PUT_BOOL(buf, objp->chown_restricted); + IXDR_PUT_BOOL(buf, objp->case_insensitive); + IXDR_PUT_BOOL(buf, objp->case_preserving); + } + return TRUE; + } else if (xdrs->x_op == XDR_DECODE) { + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + buf = XDR_INLINE(xdrs, 6 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_int(xdrs, &objp->linkmax)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->name_max)) + return FALSE; + if (!xdr_bool(xdrs, &objp->no_trunc)) + return FALSE; + if (!xdr_bool(xdrs, &objp->chown_restricted)) + return FALSE; + if (!xdr_bool(xdrs, &objp->case_insensitive)) + return FALSE; + if (!xdr_bool(xdrs, &objp->case_preserving)) + return FALSE; + } else { + objp->linkmax = IXDR_GET_U_LONG(buf); + objp->name_max = IXDR_GET_U_LONG(buf); + objp->no_trunc = IXDR_GET_BOOL(buf); + objp->chown_restricted = IXDR_GET_BOOL(buf); + objp->case_insensitive = IXDR_GET_BOOL(buf); + objp->case_preserving = IXDR_GET_BOOL(buf); + } + return TRUE; + } + + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->linkmax)) + return FALSE; + if (!xdr_u_int(xdrs, &objp->name_max)) + return FALSE; + if (!xdr_bool(xdrs, &objp->no_trunc)) + return FALSE; + if (!xdr_bool(xdrs, &objp->chown_restricted)) + return FALSE; + if (!xdr_bool(xdrs, &objp->case_insensitive)) + return FALSE; + if (!xdr_bool(xdrs, &objp->case_preserving)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_PATHCONF3resfail(XDR *xdrs, am_PATHCONF3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_PATHCONF3resfail:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_PATHCONF3res(XDR *xdrs, am_PATHCONF3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_PATHCONF3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_PATHCONF3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_PATHCONF3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_nfspath3(XDR *xdrs, am_nfspath3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_nfspath3:"); + + if (!xdr_string(xdrs, objp, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_symlinkdata3(XDR *xdrs, am_symlinkdata3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_symlinkdata3:"); + + if (!xdr_am_sattr3(xdrs, &objp->symlink_attributes)) + return FALSE; + if (!xdr_am_nfspath3(xdrs, &objp->symlink_data)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_SYMLINK3args(XDR *xdrs, am_SYMLINK3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_SYMLINK3args:"); + + if (!xdr_am_diropargs3(xdrs, &objp->where)) + return FALSE; + if (!xdr_am_symlinkdata3(xdrs, &objp->symlink)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_SYMLINK3resok(XDR *xdrs, am_SYMLINK3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_SYMLINK3resok:"); + + if (!xdr_am_post_op_fh3(xdrs, &objp->obj)) + return FALSE; + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + if (!xdr_am_wcc_data(xdrs, &objp->dir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_SYMLINK3resfail(XDR *xdrs, am_SYMLINK3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_SYMLINK3resfail:"); + + if (!xdr_am_wcc_data(xdrs, &objp->dir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_SYMLINK3res(XDR *xdrs, am_SYMLINK3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_SYMLINK3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_SYMLINK3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_SYMLINK3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_READLINK3args(XDR *xdrs, am_READLINK3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READLINK3args:"); + + if (!xdr_am_nfs_fh3(xdrs, &objp->symlink)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_READLINK3resok(XDR *xdrs, am_READLINK3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READLINK3resok:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->symlink_attributes)) + return FALSE; + if (!xdr_am_nfspath3(xdrs, &objp->data)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_READLINK3resfail(XDR *xdrs, am_READLINK3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READLINK3resfail:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->symlink_attributes)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_READLINK3res(XDR *xdrs, am_READLINK3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READLINK3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_READLINK3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_READLINK3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_devicedata3(XDR *xdrs, am_devicedata3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_devicedata3:"); + + if (!xdr_am_sattr3(xdrs, &objp->dev_attributes)) + return FALSE; + if (!xdr_am_specdata3(xdrs, &objp->spec)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_mknoddata3(XDR *xdrs, am_mknoddata3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_mknoddata3:"); + + if (!xdr_am_ftype3(xdrs, &objp->type)) + return FALSE; + switch (objp->type) { + case AM_NF3CHR: + if (!xdr_am_devicedata3(xdrs, &objp->am_mknoddata3_u.chr_device)) + return FALSE; + break; + case AM_NF3BLK: + if (!xdr_am_devicedata3(xdrs, &objp->am_mknoddata3_u.blk_device)) + return FALSE; + break; + case AM_NF3SOCK: + if (!xdr_am_sattr3(xdrs, &objp->am_mknoddata3_u.sock_attributes)) + return FALSE; + break; + case AM_NF3FIFO: + if (!xdr_am_sattr3(xdrs, &objp->am_mknoddata3_u.pipe_attributes)) + return FALSE; + break; + default: + break; + } + return TRUE; +} + +bool_t +xdr_am_MKNOD3args(XDR *xdrs, am_MKNOD3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_MKNOD3args:"); + + if (!xdr_am_diropargs3(xdrs, &objp->where)) + return FALSE; + if (!xdr_am_mknoddata3(xdrs, &objp->what)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_MKNOD3resok(XDR *xdrs, am_MKNOD3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_MKNOD3resok:"); + + if (!xdr_am_post_op_fh3(xdrs, &objp->obj)) + return FALSE; + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + if (!xdr_am_wcc_data(xdrs, &objp->dir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_MKNOD3resfail(XDR *xdrs, am_MKNOD3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_MKNOD3resfail:"); + + if (!xdr_am_wcc_data(xdrs, &objp->dir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_MKNOD3res(XDR *xdrs, am_MKNOD3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, ":"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_MKNOD3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_MKNOD3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_MKDIR3args(XDR *xdrs, am_MKDIR3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, ":"); + + if (!xdr_am_diropargs3(xdrs, &objp->where)) + return FALSE; + if (!xdr_am_sattr3(xdrs, &objp->attributes)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_MKDIR3resok(XDR *xdrs, am_MKDIR3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_MKDIR3resok:"); + + if (!xdr_am_post_op_fh3(xdrs, &objp->obj)) + return FALSE; + if (!xdr_am_post_op_attr(xdrs, &objp->obj_attributes)) + return FALSE; + if (!xdr_am_wcc_data(xdrs, &objp->dir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_MKDIR3resfail(XDR *xdrs, am_MKDIR3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_MKDIR3resfail:"); + + if (!xdr_am_wcc_data(xdrs, &objp->dir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_MKDIR3res(XDR *xdrs, am_MKDIR3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_MKDIR3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_MKDIR3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_MKDIR3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_RMDIR3args(XDR *xdrs, am_RMDIR3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_RMDIR3args:"); + + if (!xdr_am_diropargs3(xdrs, &objp->object)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_RMDIR3resok(XDR *xdrs, am_RMDIR3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_RMDIR3resok:"); + + if (!xdr_am_wcc_data(xdrs, &objp->dir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_RMDIR3resfail(XDR *xdrs, am_RMDIR3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_RMDIR3resfail:"); + + if (!xdr_am_wcc_data(xdrs, &objp->dir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_RMDIR3res(XDR *xdrs, am_RMDIR3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_RMDIR3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_RMDIR3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_RMDIR3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_RENAME3args(XDR *xdrs, am_RENAME3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_RENAME3args:"); + + if (!xdr_am_diropargs3(xdrs, &objp->from)) + return FALSE; + if (!xdr_am_diropargs3(xdrs, &objp->to)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_RENAME3resok(XDR *xdrs, am_RENAME3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_RENAME3resok:"); + + if (!xdr_am_wcc_data(xdrs, &objp->fromdir_wcc)) + return FALSE; + if (!xdr_am_wcc_data(xdrs, &objp->todir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_RENAME3resfail(XDR *xdrs, am_RENAME3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_RENAME3resfail:"); + + if (!xdr_am_wcc_data(xdrs, &objp->fromdir_wcc)) + return FALSE; + if (!xdr_am_wcc_data(xdrs, &objp->todir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_RENAME3res(XDR *xdrs, am_RENAME3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_RENAME3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_RENAME3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_RENAME3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_READDIRPLUS3args(XDR *xdrs, am_READDIRPLUS3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READDIRPLUS3args:"); + + if (!xdr_am_nfs_fh3(xdrs, &objp->dir)) + return FALSE; + if (!xdr_am_cookie3(xdrs, &objp->cookie)) + return FALSE; + if (!xdr_am_cookieverf3(xdrs, objp->cookieverf)) + return FALSE; + if (!xdr_am_count3(xdrs, &objp->dircount)) + return FALSE; + if (!xdr_am_count3(xdrs, &objp->maxcount)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_entryplus3(XDR *xdrs, am_entryplus3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_entryplus3:"); + + if (!xdr_am_fileid3(xdrs, &objp->fileid)) + return FALSE; + if (!xdr_am_filename3(xdrs, &objp->name)) + return FALSE; + if (!xdr_am_cookie3(xdrs, &objp->cookie)) + return FALSE; + if (!xdr_am_post_op_attr(xdrs, &objp->name_attributes)) + return FALSE; + if (!xdr_am_post_op_fh3(xdrs, &objp->name_handle)) + return FALSE; + if (!xdr_pointer(xdrs, (char **)&objp->nextentry, + sizeof(am_entryplus3), (xdrproc_t) xdr_am_entryplus3)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_dirlistplus3(XDR *xdrs, am_dirlistplus3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_dirlistplus3:"); + + if (!xdr_pointer(xdrs, (char **)&objp->entries, + sizeof(am_entryplus3), (xdrproc_t) xdr_am_entryplus3)) + return FALSE; + if (!xdr_bool(xdrs, &objp->eof)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_READDIRPLUS3resok(XDR *xdrs, am_READDIRPLUS3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READDIRPLUS3resok:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->dir_attributes)) + return FALSE; + if (!xdr_am_cookieverf3(xdrs, objp->cookieverf)) + return FALSE; + if (!xdr_am_dirlistplus3(xdrs, &objp->reply)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_READDIRPLUS3resfail(XDR *xdrs, am_READDIRPLUS3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READDIRPLUS3resfail:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->dir_attributes)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_READDIRPLUS3res(XDR *xdrs, am_READDIRPLUS3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READDIRPLUS3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_READDIRPLUS3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_READDIRPLUS3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_READDIR3args(XDR *xdrs, am_READDIR3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READDIR3args:"); + + if (!xdr_am_nfs_fh3(xdrs, &objp->dir)) + return FALSE; + if (!xdr_am_cookie3(xdrs, &objp->cookie)) + return FALSE; + if (!xdr_am_cookieverf3(xdrs, objp->cookieverf)) + return FALSE; + if (!xdr_am_count3(xdrs, &objp->count)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_entry3(XDR *xdrs, am_entry3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_entry3:"); + + if (!xdr_am_fileid3(xdrs, &objp->fileid)) + return FALSE; + if (!xdr_am_filename3(xdrs, &objp->name)) + return FALSE; + if (!xdr_am_cookie3(xdrs, &objp->cookie)) + return FALSE; + if (!xdr_pointer(xdrs, (char **)&objp->nextentry, + sizeof(am_entry3), (xdrproc_t) xdr_am_entry3)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_dirlist3(XDR *xdrs, am_dirlist3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_dirlist3:"); + + if (!xdr_pointer(xdrs, (char **)&objp->entries, + sizeof(am_entry3), (xdrproc_t) xdr_am_entry3)) + return FALSE; + if (!xdr_bool (xdrs, &objp->eof)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_READDIR3resok(XDR *xdrs, am_READDIR3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READDIR3resok:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->dir_attributes)) + return FALSE; + if (!xdr_am_cookieverf3(xdrs, objp->cookieverf)) + return FALSE; + if (!xdr_am_dirlist3(xdrs, &objp->reply)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_READDIR3resfail(XDR *xdrs, am_READDIR3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READDIR3resfail:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->dir_attributes)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_READDIR3res(XDR *xdrs, am_READDIR3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_READDIR3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_READDIR3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_READDIR3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_LINK3args(XDR *xdrs, am_LINK3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_LINK3args:"); + + if (!xdr_am_nfs_fh3(xdrs, &objp->file)) + return FALSE; + if (!xdr_am_diropargs3(xdrs, &objp->link)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_LINK3resok(XDR *xdrs, am_LINK3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_LINK3resok:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->file_attributes)) + return FALSE; + if (!xdr_am_wcc_data(xdrs, &objp->linkdir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_LINK3resfail(XDR *xdrs, am_LINK3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_LINK3resfail:"); + + if (!xdr_am_post_op_attr(xdrs, &objp->file_attributes)) + return FALSE; + if (!xdr_am_wcc_data(xdrs, &objp->linkdir_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_LINK3res(XDR *xdrs, am_LINK3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_LINK3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_LINK3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_LINK3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; +} + +bool_t +xdr_am_sattrguard3(XDR *xdrs, am_sattrguard3 *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_sattrguard3:"); + + if (!xdr_bool(xdrs, &objp->check)) + return FALSE; + switch (objp->check) { + case TRUE: + if (!xdr_am_nfstime3(xdrs, &objp->am_sattrguard3_u.obj_ctime)) + return FALSE; + break; + case FALSE: + break; + default: + return FALSE; + } + return TRUE; +} + +bool_t +xdr_am_SETATTR3args(XDR *xdrs, am_SETATTR3args *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_SETATTR3args:"); + + if (!xdr_am_nfs_fh3(xdrs, &objp->object)) + return FALSE; + if (!xdr_am_sattr3(xdrs, &objp->new_attributes)) + return FALSE; + if (!xdr_am_sattrguard3(xdrs, &objp->guard)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_SETATTR3resok(XDR *xdrs, am_SETATTR3resok *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_SETATTR3resok:"); + + if (!xdr_am_wcc_data(xdrs, &objp->obj_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_SETATTR3resfail(XDR *xdrs, am_SETATTR3resfail *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_SETATTR3resfail:"); + + if (!xdr_am_wcc_data(xdrs, &objp->obj_wcc)) + return FALSE; + return TRUE; +} + +bool_t +xdr_am_SETATTR3res(XDR *xdrs, am_SETATTR3res *objp) +{ + if (amuDebug(D_XDRTRACE)) + plog(XLOG_DEBUG, "xdr_am_SETATTR3res:"); + + if (!xdr_am_nfsstat3(xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case AM_NFS3_OK: + if (!xdr_am_SETATTR3resok(xdrs, &objp->res_u.ok)) + return FALSE; + break; + default: + if (!xdr_am_SETATTR3resfail(xdrs, &objp->res_u.fail)) + return FALSE; + break; + } + return TRUE; } -#endif /* not HAVE_FS_NFS3 */ +#endif /* HAVE_FS_NFS3 */ diff --git a/libamu/xutil.c b/libamu/xutil.c index 3a33b9c0b149..1159fe5ec83e 100644 --- a/libamu/xutil.c +++ b/libamu/xutil.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997-2006 Erez Zadok + * Copyright (c) 1997-2014 Erez Zadok * Copyright (c) 1990 Jan-Simon Pendry * Copyright (c) 1990 Imperial College of Science, Technology & Medicine * Copyright (c) 1990 The Regents of the University of California. @@ -16,11 +16,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * 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 acknowledgment: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -63,14 +59,13 @@ static char am_hostname[MAXHOSTNAMELEN] = "unknown"; /* Hostname */ pid_t am_mypid = -1; /* process ID */ serv_state amd_state; /* amd's state */ int foreground = 1; /* 1 == this is the top-level server */ -int debug_flags = 0; +u_int debug_flags = D_CONTROL; /* set regardless if compiled with debugging */ #ifdef HAVE_SYSLOG int syslogging; #endif /* HAVE_SYSLOG */ -int xlog_level = XLOG_ALL & ~XLOG_MAP & ~XLOG_STATS; -int xlog_level_init = ~0; -static int amd_program_number = AMQ_PROGRAM; +static u_int xlog_level = XLOG_DEFAULT; +static u_long amd_program_number = AMQ_PROGRAM; #ifdef DEBUG_MEM # if defined(HAVE_MALLINFO) && defined(HAVE_MALLOC_VERIFY) @@ -92,23 +87,23 @@ static void real_plog(int lvl, const char *fmt, va_list vargs) struct opt_tab dbg_opt[] = { {"all", D_ALL}, /* All non-disruptive options */ - {"amq", D_AMQ}, /* Don't register for AMQ program */ - {"daemon", D_DAEMON}, /* Don't enter daemon mode */ - {"fork", D_FORK}, /* Don't fork server */ + {"defaults", D_DEFAULT}, /* Default options */ + {"test", D_TEST}, /* Full debug - no daemon, no fork, no amq, local mtab */ + {"amq", D_AMQ}, /* Register for AMQ program */ + {"daemon", D_DAEMON}, /* Enter daemon mode */ + {"fork", D_FORK}, /* Fork server (hlfsd only) */ {"full", D_FULL}, /* Program trace */ #ifdef HAVE_CLOCK_GETTIME {"hrtime", D_HRTIME}, /* Print high resolution time stamps */ #endif /* HAVE_CLOCK_GETTIME */ - /* info service specific debugging (hesiod, nis, etc) */ - {"info", D_INFO}, + {"info", D_INFO}, /* info service specific debugging (hesiod, nis, etc) */ {"mem", D_MEM}, /* Trace memory allocations */ {"mtab", D_MTAB}, /* Use local mtab file */ {"readdir", D_READDIR}, /* Check on browsable_dirs progress */ {"str", D_STR}, /* Debug string munging */ - {"test", D_TEST}, /* Full debug - no daemon, no amq, local mtab */ {"trace", D_TRACE}, /* Protocol trace */ {"xdrtrace", D_XDRTRACE}, /* Trace xdr routines */ - {0, 0} + {NULL, 0} }; #endif /* DEBUG */ @@ -118,6 +113,7 @@ struct opt_tab dbg_opt[] = struct opt_tab xlog_opt[] = { {"all", XLOG_ALL}, /* All messages */ + {"defaults", XLOG_DEFAULT}, /* Default messages */ #ifdef DEBUG {"debug", XLOG_DEBUG}, /* Debug messages */ #endif /* DEBUG */ /* DEBUG */ @@ -129,7 +125,7 @@ struct opt_tab xlog_opt[] = {"user", XLOG_USER}, /* Non-fatal user errors */ {"warn", XLOG_WARNING}, /* Warnings */ {"warning", XLOG_WARNING}, /* Warnings */ - {0, 0} + {NULL, 0} }; @@ -150,7 +146,7 @@ am_get_progname(void) void am_set_hostname(char *hn) { - xstrlcpy(am_hostname, hn, MAXHOSTNAMELEN); + xstrlcpy(am_hostname, hn, sizeof(am_hostname)); } @@ -295,17 +291,23 @@ expand_error(const char *f, char *e, size_t maxlen) const char *p; char *q; int error = errno; - int len = 0; + size_t len = 0, l; - for (p = f, q = e; (*q = *p) && (size_t) len < maxlen; len++, q++, p++) { + *e = '\0'; + for (p = f, q = e; len < maxlen && (*q = *p); len++, q++, p++) { if (p[0] == '%' && p[1] == 'm') { - xstrlcpy(q, strerror(error), maxlen); - len += strlen(q) - 1; - q += strlen(q) - 1; + if (len >= maxlen) + break; + xstrlcpy(q, strerror(error), maxlen - len); + l = strlen(q); + if (l != 0) + l--; + len += l; + q += l; p++; } } - e[maxlen-1] = '\0'; /* null terminate, to be sure */ + e[maxlen - 1] = '\0'; /* null terminate, to be sure */ return e; } @@ -317,7 +319,7 @@ static void show_time_host_and_name(int lvl) { static time_t last_t = 0; - static char *last_ctime = 0; + static char *last_ctime = NULL; time_t t; #if defined(HAVE_CLOCK_GETTIME) && defined(DEBUG) struct timespec ts; @@ -390,21 +392,63 @@ show_time_host_and_name(int lvl) int debug_option(char *opt) { - return cmdoption(opt, dbg_opt, &debug_flags); + u_int dl = debug_flags; + static int initialized_debug_flags = 0; + int rc = cmdoption(opt, dbg_opt, &dl); + + if (rc) /* if got any error, don't update debug flags */ + return EINVAL; + + /* + * If we already initialized the debugging flags once (via amd.conf), then + * don't allow "immutable" flags to be changed again (via amq -D), because + * they could mess Amd's state and only make sense to be set once when Amd + * starts. + */ + if (initialized_debug_flags && + debug_flags != 0 && + (dl & D_IMMUTABLE) != (debug_flags & D_IMMUTABLE)) { + plog(XLOG_ERROR, "cannot change immutable debug flags"); + /* undo any attempted change to an immutable flag */ + dl = (dl & ~D_IMMUTABLE) | (debug_flags & D_IMMUTABLE); + } + initialized_debug_flags = 1; + debug_flags = dl; + + return rc; } void dplog(const char *fmt, ...) { +#ifdef HAVE_SIGACTION + sigset_t old, chld; +#else /* not HAVE_SIGACTION */ + int mask; +#endif /* not HAVE_SIGACTION */ va_list ap; +#ifdef HAVE_SIGACTION + sigemptyset(&chld); + sigaddset(&chld, SIGCHLD); +#else /* not HAVE_SIGACTION */ + mask = sigblock(sigmask(SIGCHLD)); +#endif /* not HAVE_SIGACTION */ + + sigprocmask(SIG_BLOCK, &chld, &old); if (!logfp) logfp = stderr; /* initialize before possible first use */ va_start(ap, fmt); real_plog(XLOG_DEBUG, fmt, ap); va_end(ap); + +#ifdef HAVE_SIGACTION + sigprocmask(SIG_SETMASK, &old, NULL); +#else /* not HAVE_SIGACTION */ + mask = sigblock(sigmask(SIGCHLD)); +#endif /* not HAVE_SIGACTION */ } #endif /* DEBUG */ @@ -412,14 +456,33 @@ dplog(const char *fmt, ...) void plog(int lvl, const char *fmt, ...) { +#ifdef HAVE_SIGACTION + sigset_t old, chld; +#else /* not HAVE_SIGACTION */ + int mask; +#endif /* not HAVE_SIGACTION */ va_list ap; +#ifdef HAVE_SIGACTION + sigemptyset(&chld); + sigaddset(&chld, SIGCHLD); + sigprocmask(SIG_BLOCK, &chld, &old); +#else /* not HAVE_SIGACTION */ + mask = sigblock(sigmask(SIGCHLD)); +#endif /* not HAVE_SIGACTION */ + if (!logfp) logfp = stderr; /* initialize before possible first use */ va_start(ap, fmt); real_plog(lvl, fmt, ap); va_end(ap); + +#ifdef HAVE_SIGACTION + sigprocmask(SIG_SETMASK, &old, NULL); +#else /* not HAVE_SIGACTION */ + sigsetmask(mask); +#endif /* not HAVE_SIGACTION */ } @@ -497,11 +560,11 @@ real_plog(int lvl, const char *fmt, va_list vargs) switch (last_count) { case 0: /* never printed at all */ last_count = 1; - if (strlcpy(last_msg, msg, 1024) >= 1024) /* don't use xstrlcpy here (recursive!) */ + if (strlcpy(last_msg, msg, sizeof(last_msg)) >= sizeof(last_msg)) /* don't use xstrlcpy here (recursive!) */ fprintf(stderr, "real_plog: string \"%s\" truncated to \"%s\"\n", last_msg, msg); last_lvl = lvl; show_time_host_and_name(lvl); /* mimic syslog header */ - fwrite(msg, ptr - msg, 1, logfp); + __IGNORE(fwrite(msg, ptr - msg, 1, logfp)); fflush(logfp); break; @@ -510,11 +573,11 @@ real_plog(int lvl, const char *fmt, va_list vargs) last_count++; } else { /* last msg printed once, new one differs */ /* last_count remains at 1 */ - if (strlcpy(last_msg, msg, 1024) >= 1024) /* don't use xstrlcpy here (recursive!) */ + if (strlcpy(last_msg, msg, sizeof(last_msg)) >= sizeof(last_msg)) /* don't use xstrlcpy here (recursive!) */ fprintf(stderr, "real_plog: string \"%s\" truncated to \"%s\"\n", last_msg, msg); last_lvl = lvl; show_time_host_and_name(lvl); /* mimic syslog header */ - fwrite(msg, ptr - msg, 1, logfp); + __IGNORE(fwrite(msg, ptr - msg, 1, logfp)); fflush(logfp); } break; @@ -527,7 +590,7 @@ real_plog(int lvl, const char *fmt, va_list vargs) show_time_host_and_name(last_lvl); xsnprintf(last_msg, sizeof(last_msg), "last message repeated %d times\n", last_count); - fwrite(last_msg, strlen(last_msg), 1, logfp); + __IGNORE(fwrite(last_msg, strlen(last_msg), 1, logfp)); fflush(logfp); last_count = 0; /* start from scratch */ break; @@ -539,13 +602,13 @@ real_plog(int lvl, const char *fmt, va_list vargs) show_time_host_and_name(last_lvl); xsnprintf(last_msg, sizeof(last_msg), "last message repeated %d times\n", last_count); - fwrite(last_msg, strlen(last_msg), 1, logfp); + __IGNORE(fwrite(last_msg, strlen(last_msg), 1, logfp)); if (strlcpy(last_msg, msg, 1024) >= 1024) /* don't use xstrlcpy here (recursive!) */ fprintf(stderr, "real_plog: string \"%s\" truncated to \"%s\"\n", last_msg, msg); last_count = 1; last_lvl = lvl; show_time_host_and_name(lvl); /* mimic syslog header */ - fwrite(msg, ptr - msg, 1, logfp); + __IGNORE(fwrite(msg, ptr - msg, 1, logfp)); fflush(logfp); } break; @@ -573,7 +636,7 @@ show_opts(int ch, struct opt_tab *opts) int -cmdoption(char *s, struct opt_tab *optb, int *flags) +cmdoption(char *s, struct opt_tab *optb, u_int *flags) { char *p = s; int errs = 0; @@ -581,7 +644,7 @@ cmdoption(char *s, struct opt_tab *optb, int *flags) while (p && *p) { int neg; char *opt; - struct opt_tab *dp, *dpn = 0; + struct opt_tab *dp, *dpn = NULL; s = p; p = strchr(p, ','); @@ -624,7 +687,7 @@ cmdoption(char *s, struct opt_tab *optb, int *flags) * This will log to stderr when parsing the command line * since any -l option will not yet have taken effect. */ - plog(XLOG_USER, "option \"%s\" not recognized", s); + plog(XLOG_ERROR, "option \"%s\" not recognized", s); errs++; } @@ -645,22 +708,22 @@ cmdoption(char *s, struct opt_tab *optb, int *flags) int switch_option(char *opt) { - int xl = xlog_level; + u_int xl = xlog_level; int rc = cmdoption(opt, xlog_opt, &xl); - if (rc) { - rc = EINVAL; - } else { - /* - * Keep track of initial log level, and - * don't allow options to be turned off. - */ - if (xlog_level_init == ~0) - xlog_level_init = xl; - else - xl |= xlog_level_init; - xlog_level = xl; + if (rc) /* if got any error, don't update flags */ + return EINVAL; + + /* + * Don't allow "mandatory" flags to be turned off, because + * we must always be able to report on flag re/setting errors. + */ + if ((xl & XLOG_MANDATORY) != XLOG_MANDATORY) { + plog(XLOG_ERROR, "cannot turn off mandatory logging options"); + xl |= XLOG_MANDATORY; } + if (xlog_level != xl) + xlog_level = xl; /* set new flags */ return rc; } @@ -801,7 +864,7 @@ switch_to_logfile(char *logfile, int old_umask, int truncate_log) } else { /* regular log file */ (void) umask(old_umask); if (truncate_log) - truncate(logfile, 0); + __IGNORE(truncate(logfile, 0)); new_logfp = fopen(logfile, "a"); umask(0); } @@ -834,7 +897,8 @@ switch_to_logfile(char *logfile, int old_umask, int truncate_log) void unregister_amq(void) { - if (!amuDebug(D_AMQ)) { + + if (amuDebug(D_AMQ)) { /* find which instance of amd to unregister */ u_long amd_prognum = get_amd_program_number(); @@ -875,7 +939,7 @@ going_down(int rc) /* return the rpc program number under which amd was used */ -int +u_long get_amd_program_number(void) { return amd_program_number; @@ -884,7 +948,7 @@ get_amd_program_number(void) /* set the rpc program number used for amd */ void -set_amd_program_number(int program) +set_amd_program_number(u_long program) { amd_program_number = program; } @@ -955,9 +1019,9 @@ amu_release_controlling_tty(void) close(fd); } return; -#endif /* not TIOCNOTTY */ - +#else plog(XLOG_ERROR, "unable to release controlling tty"); +#endif /* not TIOCNOTTY */ } @@ -1012,7 +1076,7 @@ mkdirs(char *path, int mode) /* * take a copy in case path is in readonly store */ - char *p2 = strdup(path); + char *p2 = xstrdup(path); char *sp = p2; struct stat stb; int error_so_far = 0; @@ -1056,7 +1120,7 @@ mkdirs(char *path, int mode) void rmdirs(char *dir) { - char *xdp = strdup(dir); + char *xdp = xstrdup(dir); char *dp; do { @@ -1089,3 +1153,15 @@ rmdirs(char *dir) XFREE(xdp); } + +/* + * Dup a string + */ +char * +xstrdup(const char *s) +{ + size_t len = strlen(s); + char *sp = xmalloc(len + 1); + memcpy(sp, s, len + 1); + return sp; +} |