pax_global_header00006660000000000000000000000064115706544000014514gustar00rootroot0000000000000052 comment=b0e739272f3af706c9c37cd95e1413f2325c931c am-utils-6.2+rc20110530/000077500000000000000000000000001157065440000143325ustar00rootroot00000000000000am-utils-6.2+rc20110530/.cvsignore000066400000000000000000000102551157065440000163350ustar00rootroot000000000000002be-mirror.txt A.alpha-dec-osf2.1 A.alpha-dec-osf4.0 A.alphaev5-unknown-linux-gnu-rh5.2 A.hppa1.1-hp-hpux10.10 A.hppa1.1-hp-hpux10.20 A.hppa1.1-hp-hpux11.00 A.hppa1.1-hp-hpux9.01 A.hppa1.1-hp-hpux9.05 A.hppa1.1-hp-hpux9.07 A.i386-apple-darwin6.0 A.i386-pc-bsdi2.1 A.i386-pc-bsdi3.1 A.i386-pc-bsdi4.1 A.i386-pc-solaris2.5.1 A.i386-pc-solaris2.6 A.i386-pc-solaris2.7 A.i386-unknown-freebsd2.2.7 A.i386-unknown-freebsd2.2.8 A.i386-unknown-freebsdelf3.2 A.i386-unknown-freebsdelf3.3 A.i386-unknown-freebsdelf4.0 A.i386-unknown-netbsd1.3.3 A.i386-unknown-netbsd1.4.1 A.i386-unknown-openbsd2.5 A.i486-ncr-sysv4.3.03 A.i486-pc-linux-gnu-rh6.0 A.i486-pc-linux-gnulibc1 A.i486-pc-linux-gnulibc1-rh4.2 A.i586-pc-linux-gnu-rh5.2 A.i586-pc-linux-gnu-rh6.0 A.i586-pc-linux-gnu-rh6.1 A.i586-pc-linux-gnu-rh6.1.92 A.i586-pc-linux-gnulibc1 A.i586-pc-linux-gnulibc1-rh4.2 A.i686-pc-linux-gnu-rh5.2 A.i686-pc-linux-gnu-rh6.0 A.i686-pc-linux-gnu-rh6.1 A.m68k-next-nextstep3 A.m68k-sun-sunos4.1.1 A.mips-sgi-irix5.3 A.mips-sgi-irix6.2 A.mips-sgi-irix6.4 A.mips-sgi-irix6.5 A.powerpc-ibm-aix4.1.5.0 A.powerpc-ibm-aix4.2.1.0 A.powerpc-ibm-aix4.3.1.0 A.rs6000-ibm-aix4.1.4.0 A.rs6000-ibm-aix4.1.5.0 A.sparc-sun-solaris2.3 A.sparc-sun-solaris2.5 A.sparc-sun-solaris2.5.1 A.sparc-sun-solaris2.6 A.sparc-sun-solaris2.7 A.sparc-sun-sunos4.1.3 A.sparc-sun-sunos4.1.3C A.sparc-sun-sunos4.1.3_U1 A.sparc-sun-sunos4.1.4 A.sparc-unknown-linux-gnulibc1-rh4.2 A.sparc64-unknown-linux-gnu-rh5.2 Makefile.in OLD ORIG configure diffs.txt reply-to signature tmp tutorial.txt A.i686-pc-linux-gnu-rh6.1.92 A.i686-pc-linux-gnu-rh6.2 A.i386-unknown-freebsdelf3.4 A.i586-pc-linux-gnu-rh6.2 acinclude.m4 aclocal.m4 config.h.in stamp-h.in A.i386-pc-linux-rh6.1 A.sparc64-unknown-linux-rh6.2 A.i386-pc-linux-rh6.2 A.i386-pc-linux-rh7.0 A.i386-pc-linux-rh7.1 buildall.log autom4te.cache A.sparc-sun-solaris2.8 A.ia64-unknown-linux-rh7.1 A.ia64-hp-hpux11.20 A.i386-unknown-freebsd4.4 A.i386-unknown-netbsdelf1.5.1 A.i386-pc-bsdi4.2 A.i386-pc-linux-rh7.2 A.i386-unknown-freebsd5.0 A.i386-pc-linuxlibc1-rh4.2 A.i386-pc-solaris2.8 A.i386-unknown-freebsd4.5 A.i386-unknown-openbsd2.9 A.i386-pc-linux-rh7.3 A.i386-unknown-freebsd4.6 A.sparc64-unknown-linux-suse7.3 A.ia64-unknown-linux-rh2.1AW A.sparc-sun-solaris2.9 A.i386-pc-linux-rh8.0 autom4te-2.53.cache A.powerpc-ibm-aix5.1.0.0 A.ia64-unknown-linux-rh2.1AS A.ia64-unknown-linux-rh7.2 A.i386-unknown-freebsd4.7 A.i386-pc-linux-rh9 A.powerpc-ibm-aix5.2.0.0 A.i386-unknown-netbsdelf1.6.1 A.i386-unknown-openbsd3.3 A.i386-pc-solaris2.9 A.i386-unknown-freebsd5.1 A.i686-apple-darwin6.6 A.i386-unknown-freebsd4.8 A.x86_64-unknown-linux-rh2.9.5AS A.mipsel-unknown-linux-rhPS2 A.i386-unknown-freebsd4.9 A.i386-unknown-freebsd5.2 A.sparc64-unknown-linux-deb3.0 A.i386-unknown-freebsd5.2.1 A.i386-pc-linux-suse9.1 A.i386-unknown-freebsd4.10 A.i386-pc-linux-suse8.2 A.i386-pc-linux-fc2 A.i386-pc-linux-fc3 A.i386-pc-solaris2.10 A.i386-unknown-freebsd4.11 A.i386-unknown-freebsd5.3 A.i386-unknown-netbsdelf1.6.2 A.i386-unknown-netbsdelf2.0 A.i386-unknown-openbsd3.6 A.powerpc-apple-darwin7.6.0 A.powerpc-ibm-aix5.3.0.0 A.powerpc-ibm-aix5.3.0.0-cc A.i386-pc-linux-rhel3 A.powerpc-apple-darwin7.7.0 A.powerpc-apple-darwin7.8.0 A.i386-unknown-freebsd6.0 A.ia64-unknown-linux-rhel4 A.i386-pc-linux-rhel4 A.sparc-sun-solaris2.10 A.powerpc64-unknown-linux-rhel4 A.powerpc64-unknown-linux-sles9 A.powerpc-apple-darwin7.9.0 A.i386-pc-linux-suse9.2 A.i386-unknown-freebsd5.4 A.i386-pc-linux-gentoo1.4.16 A.powerpc-unknown-linux-yellowdog2.3 A.i386-unknown-netbsdelf2.0.2 A.i386-unknown-openbsd3.7 A.i386-pc-linux-deb3.0 A.alpha-unknown-linux-gentoo1.4.16 A.alphaev56-dec-osf4.0f A.mips-unknown-linux-gentoo1.4.16 A.sparc64-unknown-linux-gentoo1.4.16 A.i386-pc-linux-fc4 A.i386-pc-linux-suse9.3 A.i386-pc-linuxoldld-deb3.1 A.i386-pc-linux-deb3.1 A.powerpc-apple-darwin8.2.0 A.i386-unknown-netbsdelf3.0 A.i386-unknown-netbsdelf2.1 A.i386-unknown-openbsd3.8 A.powerpc-ibm-aix5.2.0.0-cc A.i386-pc-linux-fc5 A.i386-pc-linux-suse10.1 A.powerpc-apple-darwin8.5.0 A.powerpc-apple-darwin8.6.0 A.i386-unknown-freebsd6.1 A.i386-unknown-openbsd3.9 A.i386-pc-solaris2.11-nexentaos A.i386-pc-linux-centos4.4 A.powerpc-apple-darwin8.7.0 A.i386-pc-linux-fc6 A.i386-apple-darwin8.8.1 A.ia64-hp-hpux11.23 am-utils-6.2+rc20110530/AUTHORS000066400000000000000000000360031157065440000154040ustar00rootroot00000000000000PRIMARY AUTHORS AND MAJOR CONTRIBUTORS TO AM_UTILS: Original authors of amd were the Berkeley team and especially Jan-Simon Pendry. Since then many people have contributed patches. This file lists the ones who contributed major code changes, in no particular order, and I thank them all. This is of course not to diminish the smaller contributes of the many others. Thank you all. * Erez Zadok The most significant changes were made by Erez Zadok in terms of bug fixes, ports, and new features added. Erez Zadok is the current maintainer of am-utils, as of January 1997. * Ion Badulescu Co-maintainer of am-utils since late 1999: Linux and Solaris autofs support, Linux NFSv3 support, major code reorganization, etc... * Randall S. Winchester May 7, 1997: contributed a special version of upl102 that included NFS V.3 support. Some of the code was contributed by Christos Zoulas . I (Erez) ported these changes to am-utils. September 12, 1997: lots of small prototype cleanups and fixes to numerous files. January 27, 1998: support pid files in the amd.conf file. Provide base name for hesiod zone files. Always use /etc/amd.conf if exists. August 8, 1998: add detection support for NFS V.3 for NetBSD 1.3F. February 1, 1998: fixes for NetBSD to better detect its features. September 4, 1999: assorted fixes for NetBSD 1.4+. * Hannes Reinecke Back in 1995, contributed code for linux. A new parser for file system specific options that only exist under linux. * Leif Johansson June 22, 1997: minor patch to ensure that systems without an RE library work. June 23, 1997: mount options should be properly comma limited. July 10, 1997: info_ldap.c and prototype changes to all map _init and _mtime functions. Contributed scripts/amd2ldif.pl. August 4, 1997: info_ldap.c fixes and adding two new amd.conf ldap variables: ldap_cache_seconds and ldap_cache_maxmem. * Andreas Stolcke June 22, 1997: patches to ensure that proto= and vers= options work properly in mount tables and can be overridden. Later on, more code contribued to optimize the best combination of proto/vers. July 4, 1997: patches to get NFS V.3 working under irix5. September 9, 1997: initialize all fields of mntent_t structures to 0. October 2, 1997: don't log an RPC timeout as an error but only as an info message. December 19, 1997: detected an FMR (Free Memory Read) in amd/mntfs.c, uninit_mntfs(). * Danny Braniss July, 6 1997: contributed patches to hesiod on bsdi3. * Tom Schmidt July 10, 1997: Recommdation to include libgdbm if libc has no dbm_open. Patches for netgrp(host) command. Mods to aux/config.guess to recognize sun3. January 19, 1998: print correct -l option depending if system supports syslog and/or syslog facilities. January 29, 1998: fix for 0.0.0.0 loopback on SunOS 3.X which defines IFF_ROUTE instead of IFF_LOOPBACK. May 30, 2000: correct logging types for addopts/mergeopts messages. * Daniel S. Riley July 11, 1997: fixes to DU-4.0 to support string POSIX.1 signals, and struct sockaddr with sa_len field. July 13, 1997: Move amd.conf parsing to before switch_option() on log/debug options. Minor type wrt "ro" option in libamu/mount_fs.c. Added more fillers of mnttab options, for acdirmax, acdirmin, acregmax, acregmin, noac, grpid, nosuid, and actimo. August 15, 1998: fix memory leak in processing of /defaults, and avoid accessing uninitialized memory in osf1. * Roman Hodek July 23, 1997: Got lots of patches from the Debian Linux folks, who fixed several generic bugs, and one serious one for Linux. The latter involved using connected sockets for NFS mounts on kernels 1.3.10 and older. Roman's work is baed on amd-upl102, and work from Ian Murdock and Dominik Kubla . * Rainer Orth August 6, 1997: assorted fixes to support hesiod-1.3, solaris 2.4 (which I already fixed but did not release yet), and support for $LDFLAGS at configure/compile time. February 24, 1998: lots of patches for ultrix 4.3 port. February 28, 1998: lots of documentation fixes! January 8, 1999: texi fixes, and more Ultrix 4.3 fixes, among others. January 11, 1999: hesiod_isup function. Fix format errors in dlog/plog. Remove obsolete or unnecessary files/macros. Don't report disabled file systems. More misc fixes. February 3, 1998: don't start autofs listener unless autofs maps were in use. December 10, 1999: assorted fixed and lots of fixes to support in-kernel mount tables in Solaris 8. February 9, 2000: new debug options hrtime (hi-res timer) and xdrtrace. bug fixes. * Jason Thorpe August 25, 1997: make amd work when talking to NIS+ servers in NIS compatibility mode. Fix originally came from Matthieu Herrb . * Chris Metcalf August 29, 1997: patch to make amd use FQHN for NFS/RPC authentication, useful esp. for cross-domain NFS mounts. September 2, 1997: if plock() succeeded, don't display errno string. * Enami Tsugutomo September 4, 1997: don't ping remote servers with NFS V.3 always, but V.2, regardless of client's NFS version. (conf/transp/transp_sockets.c) * Dan Riley September 19, 1997: make sure that amd works with more secure portmappers that do not allow forwarding of RPC messages to other services. * Wolfgang Rupprecht August 10, 1997: netbsd and other bsd systems have a mask flag for pcfs_args (msdos mount). * Christos Zoulas September 25, 1997: fix to initialize uid/gid fields of pcfs_args_t on netbsd. October 10, 1997: compile time cleanups of printf()s in hlfsd code. If nfs server is down or does not support a portmapper call, then mark it down as version 2, and try again later. November 29, 2002: compile fixes for NetBSD, a couple of bug fixes (one already fixed by maintainers) April 12, 2003: support new "unmount" option, useful to timeout removable local media mounts. October 12, 2004: patch to support two new amd.conf options, domain_strip and auto_attrcache. Patch to cleanup NFS attribute-cache flag computation. Patch to fix an inconsistency in timeouts in the RPC code between socket and TLI implementations. Patch to print version string (amd -v) after all options had been initialized, so we can print domain, host, and hostd. Linux patch to use umount2(2) if umount(2) fails. * Bill Paul November 5, 1997: NFS v.3 support for AIX 4.2.1, which does *not* include headers for this. Bill had to guess at the right structures, field names, sizes, alignment, etc. January 15, 1999: small ldap bug fixes. * Stefan Vogel November 14, 1997: typo in the subscription instructions to amd-dev. * Guntram Wolski November 15, 1997: pointed out mismatching documentation for the -o option. * Michael Hucka January 11, 1997: pointed out reversed definition of NFS mount options vers and proto. * Albert Chin January 12, 1998: minor bug in output of amd -H. June 23, 2005: assortment of small compile bugs on aix4, and solaris 5/6/7. * Thomas Richter January 13, 1998: use case insensitive comparisons for variables that need it (such as all hostname related ones, and more). July 20, 1998: don't leak memory in the private version of yp_all (when vendor yp_all is bad). * Fred Korz January 30, 1998: minor typo fixed to tftp example in am-utils.texi. * Donald Buczek March 6, 1998: correctly inherit existing NFS V.3 mounts upon restart. March 17, 1998: compare log file name and syslog string with correct length. March 20, 1998: do not close stdout in case it gets reused elsewhere and to allow startup script to redirect it. Set a temporary secure umask(0022) before writing log file and restore it afterwards. * Matthew Crosby April 20, 1998: allow arbitrary number of interfaces in wire listing. * David O'Brien September 4, 1998: bug fix to avoid overrunning hostname buffer, and minor amd.conf man page typo correction. September 22, 1999: use more secure vsnprintf in real_plog(). * Danny Rathjens October 29, 1998: swap arguments to kill(2) in amd.c. * Mike Mitchell November 3, 1998: amd/nfs_subr.c (nfsproc_lookup_2_svc): try to avoid a race condition between unmounting and re-mounting an entry, by increasing the ttl of a looked up entry before unmounting it. * Douglas K. Rand" December 3, 1998: case insensitive host name match for nfsl. * David Wolfskill January 28, 1999: don't turn on/off noconn option if it was already in that state. * Jeffrey C Honig March 14, 1999: clean up more autogenerated files upon "make distclean". March 15, 1999: avoid overly verbose NIS warning even on systems that don't run NIS. On BSD systems, wire.c uses getifaddrs(), sysctl(), IRS routines, and more fixes. Numerous IP packet security fixes. March 16, 1999: documentation typos. new cdfs options. ufs structure detection for bsdi4. September 17, 1999: fixes to expn. * Paul Balyoz March 26, 1999: ensure lostaltmail displays Y2K compliant dates. * Jon Peatfield March 30, 1999: turn off incomplete NFS V.3 support in HPUX 10.20. September 22, 1999: safe reloading of maps without first clearing old copies, and using cached copies if map failed to reload. * Peter Breitenlohner July 24, 1999: patch for linux 2.2.x to work with older libc5 systems, and nis_isup mis-logic fixes. December 13, 2001: report typos in scripts/amd.conf.5. * Dale Talcott July 26, 1999: added NFS3 support for AIX mounting. * Christophe Kalt July 14, 1999: add netgrpd() syntax function which uses FQHN. * Andrew J. Korty September 5, 1999: pawd works for type:=nfsl. * Nick Williams September 1, 1999: bug fix for incorrect symlinks when two locations are requested simultaneously. November 1, 1999: fixes to sync maps even if they are set to mapcache:=sync. January 19, 2000: fix (and reduce the incidence of) stale file handles when doing rapid mounts and umounts in succession. June 5, 2000: better handling of potential race-conditions during rapid u/mounts. Correctly update d_drops stats for amq -s. * Johann Pfefferl November 16, 1999: fix to ldap code so repeated calls to string2he don't corrupt the string passed. * Amitha Perera December 9, 1999: detect all wire() interfaces correctly. * Steven Danz January 25, 2000: allow browsable auto maps. * Wolfram Klaus . November 21, 2000: recognize proplist mnttab flag. * Thomas Klausner November 21, 2000: lots of NetBSD fixes (many of which are generic). April 18, 2003: patch to reference am-utils info pages in man page. November 28, 2004: small fixes to typos in amd.conf(5) man page. * Olaf Kirch February 1, 2001: important Linux NFS error number mapping fixed * Ahmon Dancy February 9, 2001: Apple Rhapsody/Darwin/OS X port * Sebastien Bahloul July 3, 2001: LDAP fixes and updates to support new APIs March 27, 2002: LDAP bug and port to HPUX-11. * Philippe Troin July 12, 2001: Proper handling of GNU getopt, support for optionally disabling LDAP/Hesiod, fixes for the dev/nodev option on Linux. Texi documentation fix. November 28, 2001: Bug fix. Support "nolock" as an NFS option, not a generic mount option. July 17, 2003: pref:=null core dump fix. libgdbm portability. tcpd/librap support. And a few other things for the 6.0 branch. * Trond Myklebust January 10, 2002: Proper initialization of the timeo parameter on Linux, TCP _must_ have a timeout 2 orders of magnitude larger than UDP * George Ross April 29, 2002: Rework of old code, support for wildcards in LDAP queries, and an FD leak fix. Amd -A support. October 21, 2002: ldap_unbind fix for SIGPIPE, and support for LDAPv3 protocol version parameter (with Tim Colles ). * Matthias Scheler June 14, 2002: patch to use "xlatecookie" NFS mount option. * Jun-ichiro itojun Hagino . June 11, 2002: minor fixes to support NetBSD 1.6A. * Sean Fagan March 14, 2003: detect and use the MNT2_GEN_OPT_AUTOMNTFS mount flag on OS X / Darwin. * Hendrik Scholz June 9, 2003: mk-amd-map should open temp db file using O_EXCL. * Mark Davies July 14, 2003: define "xlatecookie" mnttab option if not defined (for NetBSD). Support null hesiod entries if they start with a ".". * Eric S. Raymond December 9, 2003: fix unbalanced [] typo in fsinfo man page. * Martin Blapp July 6, 2004: recognize fields in pcfs_args_t in FreeBSD 5. * Dan Nelson August 2, 2004: pawd to recognize "host" type mounts. * Hauke Fath August 3, 2004: pawd to recognize "linkx" type mounts. * Michael van Elst September 1, 2004: bug fix to avoid race condition in calls to mntctl on AIX. * Jonathan Chen October 22, 2004: patch/fix to move mlock/mlockall/plock code after the fork(). June 29, 2005: core dump going off end of exported_ap[] array. September 29, 2005: patch/fix for pawd not to go into an infinite loop. October 25, 2005: patch/fix for pawd to repeatedly resolve path. * David Rage January 17, 2005: prevent Amd from logging 'Read-only filesystem' errors when the mount point has an ancestor (i.e. '/') that is mounted read-only. * Kevin Layer January 28, 2005: basic instructions how to setup Amd on Mac OS-X. * Dan Ottavio March 2, 2005: new global amd.conf option debug_mtab_file, to set the debug mtab file when using debug_options=mtab. Default has changed from "./mtab" to "/tmp/mtab" to avoid security problem. Bug fixed to ensure that Amd terminates properly even mtab file doesn't exist. * Erik Kline January 3, 2005: implementation of executable maps for Amd. * Jim Zajkowski March 14, 2005: small patch to amd2ldif. * Adam Morley January 27, 2005: synchronize what amd2ldif does vs. what the ldap.schema expects. * Graeme Wilford July 4, 2005: buffer overflow in pawd. am-utils-6.2+rc20110530/BUGS000066400000000000000000000314341157065440000150220ustar00rootroot00000000000000 LIST OF KNOWN BUGS IN AM-UTILS OR OPERATING SYSTEMS Note: report am-utils bugs via Bugzilla to https://bugzilla.am-utils.org/ or by email to the am-utils mailing list (see www.am-utils.org). (1) mips-sgi-irix* [1A] known to have flaky NFS V.3 and TCP. Amd tends to hang or spin infinitely after a few hours or days of use. Users must install recommended patches from vendor. Patches help, but not all the time. Otherwise avoid using NFS V.3 and TCP on these systems, by setting /defaults opts:=vers=2,proto=udp [1B] yp_all() leaks a file descriptor. Eventually amd runs out of file descriptors and hangs. Am-utils circumvents this by using its own version of yp_all which uses udp and iterates over NIS maps. The latter isn't as reliable as yp_all() which uses TCP, but it is better than hanging. (I have some reports that older version of hpux-9, with older libc, also leak file descriptors.) [1C] SGI's MIPSpro C compiler on IRIX 6 has the unfortunate habit of creating code specificially for the machine it runs on. The ABI and ISA used depend very much on the OS version and compiler release used. This means that the resulting amd binary won't run on machines different from the build host, particularly older ones. Older versions of am-utils enforced the O32 ABI when compiling with cc to work around this, but this ABI is deprecated in favor of the N32 ABI now, so we use -n32 -mips3 to ensure that the binaries run on every host capable of running IRIX 6 at all. If this is not appropriate for you, configure with something like CC='cc -64' instead to get the desired ABI and ISA. (2) alpha-unknown-linux-gnu (RedHat Linux 4.2) hasmntopt(mnt, opt) can go into an infinite loop if opt is any substring of mnt->mnt_opts. Redhat 5.0 does not have this libc bug. Here is an example program: #include #include main() { struct mntent mnt; char *cp; mnt.mnt_opts = "intr,rw,port=1023,timeo=8,foo=br,retrans=110,indirect,map=/usr/local/AMD/etc/amd.proj,boo"; cp = hasmntopt(&mnt, "ro"); printf("cp = %s\n", cp); exit(0); } It is possible that sufficiently newer version of libc for RH4.2 fix this problem. (3) mips-dec-ultrix4.3 Rainer Orth reports [3A] One needs the Kernel Config Files (UDTBIN430) subset installed to compile am-utils, otherwise essential header files (net/if.h, net/route.h, rpcsvc/mount.h, rpcsvc/yp_prot.h, rpcsvc/ypclnt.h, sys/proc.h) are missing. [3B] It's probably impossible to build am-utils with DEC C on Ultrix V4.3. This compiler is pseudo-ANSI only. Maybe the new ANSI C compiler in V4.3A and beyond will do. I successfully used gcc 2.8.1. [3C] You need to build against a recent libhesiod (I used 3.0.2) and libresolv/lib44bsd (I used BIND 4.9.5-P1). The resolver routines in libc seem to cause random memory corruption. It is necessary to specify LIBS=-l44bsd. lib44bsd is a helper library of libresolv used to supply functions like strdup which are missing on the host system. This isn't currently autoconfiscated. [3D] You need to configure with CONFIG_SHELL=/bin/sh5 /bin/sh5 buildall; /bin/sh cannot handle the shell functions used in buildall and is both buggy and slow. [3E] At least the gcc 2.7.0 fixincludes-mangled needs a forward declaration of struct utsname to avoid lots of gcc warnings: RCS file: RCS/utsname.h,v retrieving revision 1.1 diff -u -r1.1 utsname.h --- utsname.h 1995/06/19 13:07:01 1.1 +++ utsname.h 1998/01/27 12:34:26 @@ -59,6 +59,7 @@ #ifdef KERNEL #include "../h/limits.h" #else /* user mode */ +struct utsname; extern int uname _PARAMS((struct utsname *)); #endif #define __SYS_NMLN 32 (4) powerpc-ibm-aix4.2.1.0 [4A] "Randall S. Winchester" reports that for amd to start, you need to kill and restart rpc.mountd and possibly also make sure that nfsd is running. Normally these are not required. [4B] "Stefan Vogel" reports that if your amq executable dump core unexpectedly, then it may be a bug in gcc 2.7.x. Upgrade to gcc 2.8.x or use IBM's xlC compiler. [C] Do not link amd with libnsl. It is buggy and causes amd to core dump in strlen inside strdup inside svc_register(). (5) *-linux-rh51 (RedHat Linux 5.1) There's a UDP file descriptor leak in libnsl in RedHat Linux 5.1. This library part of glibc2. Am-utils currently declares redhat 5.1 systems as having a "broken yp_all" and using an internal, slower, leak-free version. The leak is known to the glibc maintainers and a fix from them is due soon, but it is not yet in the glibc-2.0.7-19 RPM. (6) rs6000-ibm-aix4.1.x A bug in libc results in an amq binary that doesn't work; amq -v dumps core in xdr_string. There is no known fix (source code or vendor patch) at this time. (Please let us know if you have a fix; see www.am-utils.org.) (7) *-aix4.3.2.0 The plock() function will pre-reserve all of the memory up to the maximum listed in the ulimit. If the ulimit is infinite, plock() will try to take all of the system's memory, and fail with ENOMEM (Not Enough Space). Normally ulimit may be set to a few gigs of max memory usage, but even that is too much; Amd doesn't need more than a few megs of resident memory size (depending on the particular usage, number of maps, etc.) Solution: lower your ulimit before starting amd. This can be done inside the ctl-amd script, but be careful not to limit it too low. Alternatively, don't use plock on aix-4.3: set it to plock=no in amd.conf (which is the default if you do nothing). (8) *-linux (systems using glibc 2.1, such as RedHat-6.x) There's a UDP file descriptor leak in the NIS routines in glibc, especially those that do yp_bind. Until this is bug fixed, do not set nis_domain in amd.conf, but let the system pick up the default domain name as set by your system. That would avoid using the buggy yp_bind routines in libc. (9) *-linux (SuSE systems using unfsd) The user-level nfsd (2.2beta44) on older SuSE Linux systems (and possibly others) dies with a SEGV when amd tries to contact it for access to a volume that does not exist, or one for which there is no permission to mount. (10) *-*-hpux11 If you're using NFSv3, you must install HP patches PHNE_20344 and PHNE_20371. If you don't, and you try to use amd with NFSv3 over TCP, your kernel will panic. (11) *-linux* (any system using a 2.2.18+ kernel) The Linux kernels don't support Amd's direct mounts very well, leading to erratic behavior: shares that don't get remounted after the first timeout, inability to restart Amd because its mount points cannot be unmounted, etc. There are some kernel patches on the am-utils Web site, which solve these problems. See http://www.am-utils.org/patches/. Later 2.4.x kernels completely disallow the hack amd was using for direct mounts, so another solution will have to be found. Note: the above is for the old-style amd mount_type = nfs. The autofs mounts don't support direct mounts at all (due to lack of kernel support). (12) *-aix5.1.0.0 and *-hpux9* /bin/sh is broken and fails to run the configure script properly. You need to use /bin/ksh instead. The buildall script will do it for you; if for some reason you need to run configure directly, run it using 'ksh configure' instead of just 'configure'. [12A] *-aix5.2.* Apparently there is an NFS client side bug in vmount() which causes amd to hang when it starts (and tries to NFS-mount itself). According to IBM engineers, this has to do with partial support code for IPv6: the NFS kernel code doesn't appear to recognize the sin_family of the amd vmount(), although amd does the right thing. The bug doesn't appear to be in 5.1 or 4.3.3. A fix from IBM is available, APAR number IY41417. A binary built on 4.3.3 will not work on 5.2, because the kernel ABIs have changed. [12C] *-aix* It is important that you install bos.net.nfs.adt before configuring and building am-utils. If you don't, you will get compile-time or configure-time errors, especially when configure tries to find AIX's definition of struct nfs_args. (13) *-linux and *-darwin6.0 Certain linux kernels (2.4.18+ are fine, 2.4.10- are probably bad, those in between have not been tested) have a bug which causes them to reconnect broken NFS/TCP connections using unprivileged ports (greater than 1024), unlike the initial connections which do originate from privileged ports. This can upset quite a few NFS servers and causes accesses to the mounted shares to fail with "Operation not permitted" (EPERM). The darwin (MacOS X) kernel defaults to using unprivileged ports, but that can be changed by setting the resvport mount flag (which amd sets by default). Nonetheless, if a TCP connection breaks, under certain unclear circumstances the kernel might "forget" about that flag and start using unprivileged ports, causing the same EPERM error above. (14) Solaris The line "%option" in *.l files may cause Solaris /usr/ccs/bin/lex to abort with the error "missing translation value." This is a bug in Solaris lex. Moreover, both Solaris yacc and lex produce code that does not pass strict compilation such as "gcc -Wall -Werror". Use GNU Flex and Bison instead. You can download ready-made binaries from www.sunfreeware.com. Note, however, that sometimes the binaries on sunfreeware.com don't seem to work, often because they are built against an older revision of Solaris or build tools. In that case, build a fresh version of GNU flex and/or bison from the latest stable sources. See http://www.gnu.org/software/flex/ and http://www.gnu.org/software/bison/. (15) Solaris 8 + patch 10899[34]-xx (18 <= xx < 25) or patch 11260[56]-xx With this patch, Sun updated the autofs kernel module and automountd userspace daemon from version 3 to version 4. They also updated the /usr/include/rpcsvc/autofs_prot.x file, but forgot to regenerate the autofs_prot.h file. Thus, when amd is compiled, it uses the old header and thinks it should use autofs version 3, when in fact the kernel now supports (and expects) only version 4. The workaround is to run 'rpcgen -C -h /usr/include/rpcsvc/autofs_prot.x > /usr/include/rpcsvc/autofs_prot.h' and completely reconfigure and rebuild am-utils (removing config.cache before running configure). The problem is fixed in patch revisions 10899[34]-25 and up. (16) Linux kernel 2.4+ and lofs mounts Lofs mounts are not supported by the linux kernel, at all, but since 2.4.0 the kernel supports a similar type of mount called a bind mount. Its semantics are closer to those of a hardlink than to those of lofs, and one of the results is that bind mounts ignore any mount options paseed to them. Amd uses bind mounts internally to emulate lofs mounts, which means that lofs mounts on linux will effectively ignore their mount parameters and inherit whatever options the original filesystem mounted upon had. (17) autoconf 2.57 If you see configure warnings of the following kind: configure: WARNING: sys/proc.h: present but cannot be compiled configure: WARNING: sys/proc.h: check for missing prerequisite headers? configure: WARNING: sys/proc.h: proceeding with the preprocessor's result configure: WARNING: ## ------------------------------------ ## configure: WARNING: ## Report this to bug-autoconf@gnu.org. ## configure: WARNING: ## ------------------------------------ ## please ignore them. They are not real errors, and neither bug-autoconf@gnu.org nor the am-utils maintainers are interested in hearing about them. Autoconf simply tries to do more than we need and attempts to compile each header in isolation, which fails for many system headers. That's ok, because we only need to know if a header file exists -- we know how to use it properly ourselves. While autoconf does offer a way to specify other files to be included with the tested header, in order to avoid these warnings, using it would enlarge the resulting configure script by an order of magnitude, and for no real gain. Configure is big enough as it is, we don't need any more useless baggage in it. (18) NetBSD 2.0.2, FreeBSD 5.4, OpenBSD 3.7, and quite possibly most other BSDs and other OSs (as of September 2005) Some BSD kernels don't have a way to turn off the NFS attribute cache. They don't have a 'noac' mount flag, and setting various cache timeout fields in struct nfs_args doesn't turn off the attribute cache; instead, it sets the attribute cache timeout to some internal hard-coded default (usually anywhere from 5-30 seconds). If Amd cannot turn off the NFS attribute cache, under heavy Amd usage, users could get ESTALE errors from automounted symlinks, or find that those symlinks point to the wrong place. One workaround which would minimize this effect is to set auto_attrcache=1 in your amd.conf, but it doesn't eliminate the problem! The best solutions are (1) to use Amd in Autofs mode, if it's supported in your OS, and (2) talk to your OS vendor to support a true "noac" flag. See README.attrcache for more details. Erez & the am-utils team. am-utils-6.2+rc20110530/COPYING000066400000000000000000000037711157065440000153750ustar00rootroot00000000000000Copyright (c) 1997-2011 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. 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. 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, as well as the Trustees of Columbia University. 4. 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. am-utils-6.2+rc20110530/ChangeLog000066400000000000000000016147171157065440000161250ustar00rootroot000000000000002011-05-19 Christos Zoulas * m4/macros/libtool.m4: for AIX AC_LANG_PROGRAM is incorrectly used and the latest autoconf gives an error. For now just quote it. * configure.in: Fedora Core 15 and RedHat 6 now don't define af_family_t in , but in . Include so that we get indirectly. This caused the detection test to fail. 2010-11-24 Erez Zadok * m4/macros/os_cflags.m4: for linux, define _GNU_SOURCE (to get definitions for O_LARGEFILE and more). 2010-11-20 Christos Zoulas * Update news items, add release readme, mark as rc1 * Fix addopts code to work with options that are key=value when the built-in hasmntopt() code is not used. The problem was that the code passed "key=" to hasmntopt not "key". 2009-12-10 Christos Zoulas * Copy all fields of the am_opts structure When we introduced am_loc we also added a function to create a duplicate of an am_opts structure. As it turns out, that only made a partial copy of the struct and some fields (e.g. opt_cache) was left blank in the new structure. Unfortunately any code that was checking the options through the mntfs structure was mislead by the partial copy: caching was disabled completely, for example, and since browsing relies on caching being enabled it wasn't working either. From: Krisztian Kovacs * Initialize RPC authentication flavor to AUTH_UNIX instead of zero. RHEL 5 uses version 6 of the mount_arg structure that includes the desired RPC authorization flavour. Unfortunately amd initializes that value to zero, meaning AUTH_NULL, resulting in all NFS servers denying operations. From: Krisztian Kovacs * Make sure to remove nodes in the proper order when going down. Depending on what order the nodes got created it's possible that the parent of a node has a bigger am_mapno (index in exported_ap[]) so that it gets freed before its child while the child's am_parent pointer is still pointing to the already freed block of memory. This change makes sure that umount_exported() cleans up all children of a node first before freeing the node. From: Krisztian Kovacs * Fix Linux-specific stuff in ops_tmpfs.c AUTOFS_TMPFS_FS_FLAGS is defined only in the Linux-specific conf_linux.c file, so it cannot be built on Solaris. From: Krisztian Kovacs * Add missing parenthesis to fix defined(XXX From: Krisztian Kovacs * In the previous commit we've already made a change that makes this code unnecessary since the node is returned even if the backing file server is known to be down. Since the code path is unused it should be removed. From: Krisztian Kovacs * amfs_generic_lookup_child() tries to find an alternate file server if it detects that the current one is down. However, in the comparison used to decide if a possible mount is the same as the current one it compares the am_loc pointers instead of the actual mntfs pointers. Since amfs_lookup_one_location() creates a brand new am_loc structure for the returned mntfs structure the am_loc pointer will be different even if the mntfs it's pointing to is the same. This tricks amfs_generic_lookup_child() think it has found an alternate file server while it hasn't and thus starts multiple racing mounts for the very same node and mntfs. From: Krisztian Kovacs * In the new am_loc scheme mounted mntfs structures still have their mf_fo structure left intact. So when restart creates a fake mntfs for an already mounted filesystem it should not free mf_fo right away. From: Krisztian Kovacs * Setting the error flag of the mntfs for which the share is already mounted results in the mount point not being removed when it times out. (Amd considers it an error mntfs and thus umount becomse a no-op.) From: Krisztian Kovacs * Right now AMD sets all timeout values to their defaults even if you explicitly set them to zero. This patch introduces separate flags that store if the respective values have been set and the code path setting default values checks these flags instead of testing the values for zero. [Linux only] From: Krisztian Kovacs * Fix mntfs related lookup/(un)mount race conditions, by introducing a new structure linking an mntfs to a node. From: Krisztian Kovacs * We have to free the buffers allocated by the XDR routines when decoding the mount response after copying them to their final place. From: Krisztian Kovacs 2009-12-09 Christos Zoulas * Free continuation in amfs_retry() if we don't call amfs_bgmount() Normally it's amfs_bgmount() which frees the continuation. However, if the mount is already in progress and we're in amfs_retry() for another node we don't try mounting the filesystem once again. Still, we have to free the continuation as we won't get called again and thus would leak the continuation structure and our am_loc references. From: Krisztian Kovacs * Fix use-after-free and double free of mntfs private data ops_nfs.c(nfs_init) does not clear private data pointer after free(). This leads to use-after-free and double free in case mount() fails. (found by valgrind) From: Krisztian Kovacs 2009-11-23 Christos Zoulas * The temporary filename buffer was leaked in lock_mtab(). From: Krisztian Kovacs 2009-10-27 Christos Zoulas * Deal with errno.h->sys/errno.h better 2009-10-26 Christos Zoulas * Fix issue with autoconf 2.63 * Fix compile warnings for gcc-4.4.x 2009-04-15 Christos Zoulas * Share the LDAP connection between different maps to save resources on the LDAP server. (Olaf Flebbe ) 2009-03-20 Christos Zoulas * Fix largefile re-definitions * Fix compilation error caused in previous patch 2009-02-19 Christos Zoulas * Add a synchronous unmount amq rpc that will wait for the remote filesystem to be unmounted, or return an error. Enabled by amq -uu 2009-01-11 Erez Zadok * amd/ops_udf.c: don't define functions/variables which may not be used. * amd/ops_tmpfs.c (mount_tmpfs): force gcc not to complain about unused variables. * config.guess.long: properly support Fedora Core. 2009-01-09 Christos Zoulas * Fix nfs mounts on linux 2.6.26 by explicitly initializing context. * Treat an empty sublink as an unset sublink; this allows us to say sublink:=; in a spec to override the default. (This produces Bad selector error, but it works. XXX: We need to decide how to unset a selector. I proposed an unset keyword a while ago). 2009-01-06 Christos Zoulas * re-renerate all generated files with newer versions of the auto-tools. * move INSTALL to INSTALL.am-utils to avoid conflicts * fix incompatibilities with new m4 and new autoconf. * add UDF filesystem support. * fix NetBSD nfs file handle detection. 2009-01-02 Christos Zoulas * add nocasetrans, nojoliet, rrcaseins for cd9660 filesystems 2008-12-03 Christos Zoulas * allow ldap queries try a comma-separated list of servers given as: ldap_hostports = host1:port1,host2,host3:port3 original patch from Florian Geyer 2008-09-19 Christos Zoulas * the auth_create gid on NetBSD is int * deal with lossage from flex -P * fix missing/incorrect prototypes 2008-09-17 Christos Zoulas * fix manual page section issues (sorting, non-existant) * add missing forward declarations * avoid null pointer derefs (coverity) * more portable endian detection support * implement tmpfs support * use sizeof var instead of constant * fix yyerror declaration and definition * fix yy function renaming, and correct some renaming issues. * work around automake < 1.9 issue where ylwrap is not being run for a single yacc or lex file. * NetBSD - handle headers that need other headers to compile - add exfs and tmpfs specific glue - add options log, noatime, nocoredump, nodevmtime, softdep, symperm, union - NetBSD's new mount system call needs the size of the opaque filesystem specific structure, but passing 0 for now works. We would need to change a lot more code to pass the size from the fs-specific calls, so for now punt. - recvfrom takes socklen_t * on NetBSD - handle newer NetBSD using statvfs - NetBSD calls its ufs ffs * Linux - Most recent kernels have trouble with trying to parse the pid hostname and do locking. What before was a silent failure, now there is a warning printed and the mount is rejected. This is the simplest fix: (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=479884) 2007-04-13 Erez Zadok * amd/sun_map.c (sun_append_str): When translating '&' from Sun automounter maps, replace it with "${key}" in the Amd map, not with the value of the key at the time. This way '*' maps work too. * config.guess.long: don't use -q option to grep because some systems don't support it. Bug fix for solaris. 2007-03-11 Christos Zoulas * amd/opts.c (expand_op): Don't call xstrlcpy() to truncate a string. It causes spurious xstrlcpy() syslog() errors. Use memcpy() and explicitly terminate the string. 2007-01-20 Erez Zadok * updated copyright year to 2007 on all files. 2006-12-27 Erez Zadok * minor new port: ia64-hp-hpux11.23 * m4/macros/check_libwrap_severity.m4 (LIBS): also test if caller needs to define rfc931_timeout. * amd/sun2amd.c: define rfc931_timeout and allow/deny_severity for libwrap. * amd/amq_svc.c: some versions of libwrap require the caller to define rfc931_timeout in addition to allow/deny_severity. * amd/amfs_toplvl.c (amfs_toplvl_init): properly detect when forced unmount functionality exists for all systems. * libamu/mount_fs.c (compute_nfs_args): reset nfs_args_t->pathconf only if field exists. * conf/nfs_prot/nfs_prot_hpux11.h: prevent HPUX 11.23 from including or (TLI definitions are already included from elsewhere). * configure.in: detect nfs_args_t->pathconf field. 2006-11-27 Erez Zadok * doc/Makefile.am: properly publish html files using newer text2html. 2006-11-27 Erez Zadok * doc/Makefile.am: obfuscate emails in ChangeLog before it is published on web site. * obfuscate many more emails in the distro, esp. of files which get posted on the am-utils web site. 2006-11-26 Erez Zadok * minor new port: i386-apple-darwin8.8.1. * doc/am-utils.texi: remove obvious URLs used by spammers, and replace them with links to the am-utils web site, which uses PNG images to obfuscate the actual email/mailman URLs. 2006-10-30 Erez Zadok * doc/am-utils.texi (Password maps): minor typo reported by Christoph P. Kukulies. 2006-10-26 Erez Zadok * minor new port: i386-pc-linux-fc6. * m4/macros/linux_headers.m4: handle newer Linux kernels which removed UTS_RELEASE from . 2006-10-25 Erez Zadok * minor new ports: i386-pc-linux-centos4.4 and powerpc-apple-darwin8.7.0. * config.guess.long: recognize CentOS Linux. 2006-06-20 Erez Zadok * minor new port: i386-pc-solaris2.11-nexentaos (GNU/OpenSolaris). * config.guess.long: recognize NexentaOS (GNU/OpenSolaris) * config.guess, config.sub: updates from latest official GNU distributions. 2006-05-11 Erez Zadok * Minor new ports: i386-unknown-freebsd6.1 (RELEASE), powerpc-apple-darwin8.6.0, and i386-unknown-openbsd3.9. 2006-05-10 Erez Zadok * libamu/mount_fs.c (compute_nfs_attrcache_flags): fix signedness problems on IRIX-6.5. * conf/autofs/autofs_solaris_v1.c (xdr_umntrequest): fix signedness problems on IRIX-6.5. 2006-05-01 Erez Zadok * configure.in: check if libc already includes dbm functionality (as in FreeBSD 6), then don't bother to check specific libraries such as libdbm, gdbm, etc. 2006-04-21 Erez Zadok * configure.in: detect G/DBM support via gdbm_compat library (Debian 3.1). * minor new port: powerpc-apple-darwin8.5.0 2006-04-20 Erez Zadok * scripts/amd.conf-sample, scripts/amd.conf.5, doc/am-utils.texi, NEWS: document new nfs_allow_any_interface parameter. * include/am_compat.h (INADDR_LOOPBACK): define INADDR_LOOPBACK if not defined, since some systems don't have it. 2006-04-20 Nick Williams * libamu/wire.c (is_interface_local): new boolena function to determine if address represents any of the local interfaces. (getwire): more properly check if address equals INADDR_LOOPBACK, not if IFF_LOOPBACK is not (the latter isn't as correct). * include/am_utils.h: extern for new is_interface_local() function. * conf/transp/transp_{sockets,tli}.c: don't define INADDR_LOOPBACK here but in am_compat.h * amd/nfs_prot_svc.c (nfs_program_2): if nfs_allow_any_interface=yes, then allow NFS packets from any local interface (not just 127.0.0.1). * amd/conf.c (gopt_nfs_allow_any_interface): implement the new amd.conf parameter nfs_allow_any_interface. * amd/amd.h (CFM_NFS_ANY_INTERFACE): define new global flag when al interfaces are acceptable for local NFS packets. 2006-04-18 Christos Zoulas * amd/opts.c: Add support for optionally specifying the hostname to match against the netgroup in the netgrp and netgrpd selectors. 2006-04-16 Erez Zadok * libamu/mtab.c (hasmntval): fix inverted meaning of error from hasmntvalerr(). 2006-04-14 Erez Zadok * libamu/mount_fs.c (compute_nfs_attrcache_flags): use new hasmntvalerr() function to set attribute cache values only if they were set (regardless whether they were set to zero or a non-zero value). Before, we were unable to distinguish between an error to parse an option, and a user who actually wanted to set an attribute-cache value to 0. This now fixes an important performance bug that Amd was turning off the attribute caches even for regular (non-automounter) NFS mounts. * libamu/mtab.c (hasmntvalerr): new function to set the value of an option into an integer, but ONLY if that options was set and parsed correctly. This function returns 1 on error, 0 on success (instead of always setting the option value to 0). (hasmntval): wrapper function around hasmntvalerr, which maintains backwards compatibility (always sets option value to 0, even on error to parse the option). * amd/nfs_subr.c (fh_to_mp3): use long int printf format for fhh_pid. 2006-04-05 Christos Zoulas * amd/amfs_generic.c (amfs_lookup_mntfs): fix use-after-free bug (Coverity). 2006-03-27 Erez Zadok * doc/am-utils.texi, scripts/{amd.conf.5,amd.conf-sample}: document new nfs_retransmit_counter_toplvl and nfs_retry_interval_toplvl global amd.conf parameters. * amd/conf.c (gopt_nfs_retransmit_counter_toplvl, (gopt_nfs_retry_interval_toplvl): parse amd.conf nfs_retransmit_counter_toplvl and nfs_retry_interval_toplvl global parameters. * amd/amfs_toplvl.c (amfs_toplvl_mount): support setting toplvl timeo/retrans parameters for Amd's toplvl mounts, separately from all other UDP or NFS mounts. * amd/amd.h: define a new timeo/retrans parameter for toplvl mounts. 2006-03-22 Erez Zadok * minor new port: i386-pc-linux-suse10.1 (beta 8). 2006-03-21 Christos Zoulas * amd/am_ops.c (merge_opts): Remove useless check found by Coverity; xmalloc never returns NULL. 2006-03-21 Erez Zadok * minor new ports: i386-pc-linux-fc5. * amd/info_ldap.c: as of Linux Fedora Core 5 (which comes with openldap-2.3.9), the ldap.h headers deprecate several functions used in this file, such as ldap_unbind. You get compile errors about missing extern definitions. Those externs are still in , but surrounded by an ifdef LDAP_DEPRECATED. I am turning on that ifdef at the top of info_ldap.c, under the assumption that the functions may be deprecated, but they still work for this (older?) version of the LDAP API. It gets am-utils to compile, but it is not clear if it will work perfectly. * libamu/xdr_func.c (xdr_am_mountres3_ok), amq/amq_xdr.c (xdr_amq_mount_tree, xdr_amq_mount_tree_p, xdr_amq_mount_info_list, xdr_amq_mount_tree_list), amq/amq.c (show_mti), amd/amq_subr.c (xdr_amq_setopt, xdr_amq_mount_subtree, xdr_amq_mount_tree, xdr_amq_mount_tree_list, xdr_amq_mount_tree), libamu/xdr_func.c (xdr_am_mountres3_ok): use casing magic to stop GCC-4.1 from complaining about "dereferencing type-punned pointer will break strict-aliasing rules" here (but not elsewhere). 2006-03-20 Christos Zoulas * libamu/wire.c: avoid potential dereferencing of a NULL pointer (Coverity). * hlfsd/homedir.c (delay): remove unnecessary check for NULL pointer (Coverity). * fsinfo/fsi_analyze.c (analyze_dkmounts, analyze_mounts, analyze_mounts): avoid potential dereferencing of a NULL pointer (Coverity). * conf/transp/transp_sockets.c (create_amq_service): avoid potential dereferencing of a NULL pointer (Coverity). * amd/sched.c (sigchld): properly check for the end of the waiting process list (Coverity). * amd/mapc.c (mapc_create): initialize 'modify' to zero (Coverity). * amd/autil.c (amfs_mkcacheref, am_unmounted): avoid potential dereferencing of a NULL pointer (Coverity). * amd/amfs_generic.c (amfs_lookup_mntfs): free def_opts before reusing it (memory leak bug detected by Coverity). (amfs_bgmount): avoid potential dereferencing of a NULL pointer (Coverity). * amd/am_ops.c (merge_opts): no need to check if newstr is NULL (bug detected by Coverity). 2006-03-08 Ion Badulescu * amd/nfs_subr.c (mp_to_fh): fixed old-style filehandles--the pid comparison was failing. 2006-03-08 Erez Zadok * configure.in: properly test for either or (unfortunately, Autoconf will map both names to the same $ac_cv_* variable name). Some systems support one header or another. Patch inspired by work Debian did. 2006-02-16 Daniel P. Ottavio * amd/sum_map_tok.l: Fixed a bug in a regular expression that prevented dashes in hostnames. This was posted in BZ by Thomas A. Fine. * README.sun2amd: Fixed a typo. Sentence mentions use of autofs type when it should be host type. 2006-01-04 Erez Zadok * doc/am-utils.texi (auto_attrcache Parameter): revise discussion to mention pros and cons of turning on/off this parameter, including impact on Amd's performance, and ways to improve performance while minimizing the window of vulnerability in which kernel may return the wrong (cached) attributes. 2006-01-02 Erez Zadok * updated copyright year to 2006 on all files. 2005-12-20 Erez Zadok * include/am_utils.h, conf/transp/transp_tli.c (amu_svc_register, register_autofs_service): use a consistent prototype for the dispatch function of the autofs service de/registration functions. 2005-12-03 Erez Zadok * minor new ports: i386-unknown-netbsdelf2.1, i386-unknown-netbsdelf3.0 (RELEASE), and i386-unknown-openbsd3.8. 2005-12-02 Erez Zadok * m4/macros/check_field.m4: remove double inclusion of msdosfs headers, which are included in mount_header1.h (netbsd 2.1 doesn't protect which causes compile errors). 2005-11-08 Erez Zadok * minor new port: i386-unknown-freebsd6.0 (RELEASE) 2005-10-26 Erez Zadok * amd/amq_subr.c (amqproc_pawd_1_svc): repeatedly resolve path in Amd, not in pawd (to avoid repeated network RPCs). * amq/pawd.c (transform_dir): move repeated path resolution into Amd. 2005-10-25 Erez Zadok * amq/pawd.c (transform_dir): resolve path repeatedly until finished. Bug fix from Jonathan Chen . Added safety check to prevent infinite loops. 2005-10-19 Erez Zadok * doc/am-utils.texi (opts Option): document new pcfs options longname, nowin95, shortname, user=N, group=N, mask=N, and dirmask=N. * amd/ops_pcfs.c (mount_pcfs): process new pcfs options longname, nowin95, shortname, user=N, group=N, mask=N, and dirmask=N. * include/am_compat.h: provide compatibility mnttab string names, if needed, for pcfs mount options longname, nowin95, shortname, user=N, group=N, mask=N, and dirmask=N. * include/am_utils.h: extern for hasmntstr(). * libamu/mtab.c (hasmntstr): new function to return the string value following a mount option, up to the next comma-delimited options. * configure.in: check for mnttab and pcfs options longname, nowin95, and shortname. * Makefile.am (EXTRA_DIST_M4): distribute new macro check_mnt2_pcfs_opt.m4. * m4/macros/check_mnt2_pcfs_opt.m4: new macro to check for pcfs mnttab and mount options. 2005-10-18 Erez Zadok * libamu/mount_fs.c (print_nfs_args): print nfs_args->addr correctly, depending if it's a pointer or not. * conf/sa_dref/sa_dref_*.h: for each NFS_SA_DREF macro, also #define NFS_ARGS_T_ADDR_IS_POINTER if nfs_args->addr is a pointer or an embedded structure, so we can tell how to print it. * libamu/mount_fs.c (print_nfs_args): print nfs_args->addrlen field, if it exists. * configure.in: check for nfs_args->addrlen field. * wire-test/wire-test.c (main), libamu/mount_fs.c (print_nfs_args), fixmount/fixmount.c (inetresport, clnt_create_timeout), amq/pawd.c (transform_dir), amq/amq.c (main), amd/srvr_nfs.c (find_nfs_srvr), amd/autil.c (amfs_mount): document that as per POSIX, we don't need to set the sa_len/sin_len fields in struct sockaddr/sockaddr_in. The field is used only internally in the kernel. See www.awprofessional.com/articles/article.asp?p=169505&seqNum=2&rl=1 * fixmount/fixmount.c (inetresport): initialize sockaddr_in structure before filling in some fields. 2005-10-11 Erez Zadok * doc/am-utils.texi (nfs_vers, nfs_proto parameters): clarify and correct mistaken description of nfs_proto. 2005-10-10 Erez Zadok ******************************************************************* *** Released am-utils-6.1a1 *** ******************************************************************* * README.sun2amd: revised. 2005-10-09 Daniel P. Ottavio * amd/info_nis.c (nis_search): Bug fix for bugzilla #428; make sure that sun_entry2amd() is not called when yp_match() returns an error, this is done by checking that 'res' is 0. Bug fix (same BZ#); free the output allocated by yp_match() instead of freeing the return value of sun_entry2amd(). * amd/sun_map.c (sun_entry2amd): Fix a comment. * README.sun2amd: Made a first pass at describing the status of the sun2amd feature. Moved the date. 2005-10-09 Erez Zadok * README.sun2amd: place holder. * Makefile.am (EXTRA_DIST): distribute new README.sun2amd file. 2005-10-07 Erez Zadok * m4/macros/check_mnttab_type.m4: move the test for MOUNT_* to the very end, after the test using getvfsbyname(). * m4/macros/expand_run_string.m4: if the string value returned is empty, consider it invalid. * m4/macros/check_varargs_macros.m4: rewrite macro so it'll try and compile the varargs test, not just cpp it. Some systems pass the old cpp test, but not when you actually try to compile the code (Tru64's cc). * conf/autofs/autofs_solaris_v1.h: redefine autofs_strdup_space_hack as a macro to str3cat(NULL,(s)," ",""). This works everywhere and we avoid linking problems, inline functions, etc. * conf/autofs/autofs_solaris_v1.c (autofs_mount_fs): remove autofs_strdup_space_hack() function altogether. * m4/macros/os_cflags.m4: remove hack that hardcodes pte_t=u_int. * configure.in: test for header. Test for pte_t, but only on IRIX6 systems. * Makefile.am (EXTRA_DIST_M4): distribute new type_pte_t.m4 file. * m4/macros/type_pte_t.m4: new test for existence of pte_t typedef, needed on some IRIX-6.5/gcc systems. * m4/macros/header_templates.m4: add missing templates for HAVE_EXTERN_GETDTABLESIZE, HAVE_EXTERN_GETWD, and HAVE_EXTERN_UALARM. * amd/info_exec.c (exec_map_open): break assignment from inside conditional, to work around an IRIX-6.5 cc bug. * amd/Makefile.am (amd_LDADD, sun2amd_LDADD): put libaminfo.a before libamu.la. Some linkers (e.g., IRIX-6.5) incorrectly complain about undefined symbols. * fsinfo/fsi_util.c (set_ether_if), amd/map.c (unmount_mp), libamu/xutil.c (expand_error), libamu/strutil.c (xsnprintf): avoid comparison between signed and unsigned integers. * conf/autofs/autofs_solaris_v1.h, conf/autofs/autofs_solaris_v1.c (autofs_strdup_space_hack): move "space_hack" function from static inline in header, into the only source file that needs it. This is cleaner and also prevents linking problem with some compilers that won't apply CPP macros inside static inline functions (for the strl* functions). * amq/pawd.c (find_mt, find_mlp): remove obsolete, inefficient code. (transform_dir): call the new, efficient amqproc_pawd_1() routine. * amq/amq_clnt.c (amqproc_pawd_1): AMQPROC_PAWD wrapper routine. * amq/amq.h (amqproc_pawd_1): extern for amq's AMQPROC_PAWD wrapper routine. * amd/amq_svc.c (amq_program_1): dispatch point for amqproc_pawd_1_svc. * amd/amq_subr.c (amqproc_pawd_1_svc): moved pawd's path-matching functionality into Amd, where it can be done a lot more efficiently. We don't have to construct and ship a whole export tree from Amd to pawd. We just get a variable-length xdr_wrapstring for the user's path, iterate over the entire export list inside Amd, and return only a matched string if found (otherwise we return "" to indicate that there was no match, and let pawd printf the same string it sent over). * amd/amd.h: extern for amqproc_pawd_1_svc, amd's service routine the AMQPROC_PAWD RPC. 2005-10-06 Erez Zadok * ltmain.sh, m4/macros/libtool.m4: update to libtool-1.5.20. Fixes Tru64 bugs when using ksh. * amd/amfs_toplvl.c (amfs_toplvl_mount): break complex ifdef macro into two sections, to workaround a C99 varargs-macro bug in gcc-3.2.2 (RH9). * libamu/wire.c (print_wires): convert argument-less xsnprintf to xstrlcpy. * include/am_utils.h: use new HAVE_C99_VARARGS_MACROS or HAVE_GCC_VARARGS_MACROS to pass file name and line number to xsnprintf/xvsnprintf. * libamu/strutil.c (xsnprintf, xvsnprintf): if debugging is on, then also print the source file name and line number that called xsnprintf/xvsnprintf with a buffer that wasn't large enough (most likely an am-utils bug). * Makefile.am (EXTRA_DIST_M4): distribute new check_varargs_macros.m4 file. * configure.in: execute new AMU_VARARGS_MACROS test. * m4/macros/check_varargs_macros.m4: new test to check what style of variable-length argument macros, if any, does the compiler/pre-processor supports. * conf/autofs/autofs_solaris_v2_v3.c (autofs_lookup_2_req) conf/autofs/autofs_solaris_v1.c (autofs_mount_1_req), amd/opts.c, amd/nfs_subr.c (nfsproc_lookup_2_svc), amd/nfs_start.c (mount_automounter), amd/get_args.c (get_args), amd/amfs_toplvl.c, amd/amfs_auto.c (amfs_auto_mount), amd/amd.h, amd/amd.c (main): use sizeof() instead of fixed SIZEOF_* macros. * libamu/strutil.c (xstrlcat, xstrlcpy), include/am_utils.h (DEBUG): if debugging is on, then also print the source file name and line number that called xstrl* with a buffer that wasn't large enough (most likely an am-utils bug) * include/am_compat.h (INADDR_NONE): define in a common location, if OS doesn't have it, use 0xffffffffU which should work with any ANSI compiler. * fixmount/fixmount.c, libamu/wire.c: remove local definition of INADDR_NONE. * amd/amfs_toplvl.c (amfs_toplvl_mount), amd/amfs_auto.c (amfs_auto_mount): use common SIZEOF_OPTS in definition and call to autofs_get_opts. * amd/amd.h (SIZEOF_OPTS): moved #define to common header. 2005-10-06 Rainer Orth * amd/opts.c (expand_op): Need to check BUFSPACE for env for vlen+1. Likewise for cp and strlen(cp)+1. * amd/amfs_toplvl.c (amfs_toplvl_mount) [HAVE_FS_AUTOFS]: Pass new size argument to autofs_get_opts. 2005-10-05 Erez Zadok * amq/pawd.c (transform_dir): was using UDP only. Now will also try TCP if UDP failed. Destroy client after use to avoid leftover TCP sockets in the kernel. * libamu/hasmntopt.c (amu_hasmntopt): increase size of MNTMAXSTR from 128 to to 256, because some users have really long option strings. Suggestion from jon+amd-at-spock.org. * amd/opts.c (expand_op): should check BUFSPACE for vlen+1, not just vlen. Bug discovered when started using xstrlcpy(). * ALL: convert from using strcat to the safer xstrlcat, and from strcpy to safer xstrlcpy. 2005-10-04 Erez Zadok * hlfsd/hlfsd.h: remove old fatalerror() and ERRM macros. * hlfsd/hlfsd.c (fatalerror): new function instead of macro. Easier to use xstrlcat in this new function. * amd/amd.h, include/am_utils.h, amd/amd.c: moved 'hostd' extern from am_utils.h to amd.h, and define its size as a macro that could be passed to xstrl*(). * ALL: convert from using sprintf to the safer xsnprintf. * mk-amd-map/Makefile.am (LDADD): link with libamu to get xsnprintf(). * amd/amd.h, amd/amd.c, include/am_utils.h: moved pid_fsname extern from am_utils.h to amd.h, and define its size as a macro that could be passed to xsnprintf(). 2005-10-02 Erez Zadok * libamu/Makefile.am: use strutil.c, not util.c. * libamu/strutil.c: rename from util.c to explain better purpose of file. Move xvsnprintf and xsnprintf from xutil.c to this file. * libamu/xutil.c: explain purpose of file. Move mkdirs/rmdirs code from old util.c. 2005-10-01 Erez Zadok * m4/macros/header_templates.m4: templates for FFS. * m4/macros/check_mnttab_type.m4: on BSD44 systems, check for file system mount table name via the MOUNT_* mount(2) macros (because BSD44 keeps the mount table in the kernel). * configure.in: synchronise order of searching for mnttab entries and mount names. The new order is "ext3 ext2 ffs ufs 4.2 4.3 4.4 efs xfs jfs ultrix" (which would prefer ffs on BSD44 instead of ufs, and ext3 instead of ext2 on Linux). * include/am_defs.h: include if it exists. * conf/nfs_prot/nfs_prot_netbsd1_4.h: NetBSD 3 has both statfs() and statvfs(), but the latter is preferred, so #define to use statvfs. * configure.in: check for statfs(), statvfs(), and . * config.guess.long: strip trailing '.' on "netbsdelf3.0." (Beta). Workaround for bug in config.guess. * config.{guess,sub}: update to latest versions. 2005-09-30 Christos Zoulas * fsinfo/fsi_util.c (set_ether_if): use INADDR_NONE instead of hard-coded value of -1. * include/amq_defs.h (AMQ_STRLEN): increase default size from 2KB to 16KB. We can afford it these days. * libamu/strcasecmp.c (strcasecmp): use unsigned chars in tolower() to avoid sign/size promotion bugs. * libamu/xutil.c (switch_to_logfile): don't output to LOG_CONS by default (it's unfriendly). If user really wants to, they can set it in /etc/syslog.conf. 2005-09-29 Erez Zadok * amq/pawd.c (find_mt): if the auto mount type is used, pawd could go into an infinite loop since the mt_directory and mt_mountpoint fields are the same for auto mounts. Solution: ignore type auto mounts, similar to toplvl. Bug fix from Jonathan Chen . * README.attrcache: document test-attrcache script. * scripts/Makefile.am (noinst_SCRIPTS): build test-attrcache script. * configure.in: build scripts/test-attrcache script and chmod it so it can be executed in place. * scripts/test-attrcache.in: script to test the NFS attribute cache using Amd. 2005-09-26 Erez Zadok * hlfsd/stubs.c (nfsproc_getattr_2_svc, nfsproc_lookup_2_svc, nfsproc_readlink_2_svc, nfsproc_readdir_2_svc), hlfsd/hlfsd.c (hlfsd_init): use new clocktime() function. 2005-09-18 Erez Zadok * README.attrcache: document netbsd's patchs to support noac. * libamu/mount_fs.c (compute_nfs_attrcache_flags): cleanup the code that sets the ac{reg,dir}{min,max} fields so it also sets the appropriate nfs_args->flags such as MNT2_NFS_OPT_ACREGMIN. * configure.in: check for nfs_args fields acregmax and acdirmax. * README.attrcache: new file documenting in detail OS bugs relating to attribute caching, which can affect Amd's reliability under heavy load. Update status of freebsd and openbsd. * doc/Makefile.am: install README.attrcache file as attrache.txt file on am-utils Web site. * Makefile.am (EXTRA_DIST): include README.attrcache in distro. * BUGS, NEWS, doc/am-utils.texi (auto_attrcache Parameter), scripts/amd.conf.5, scripts/amd.conf-sample: document attribute cache bugs on some OSs. 2005-09-17 Erez Zadok * libamu/xutil.c (clocktime): newly implemented routine. Uses gettimeofday() each time to return a high-resolution clock time, and does not "cache" the last time. Returns time in seconds, just like the old implementation. If passed a non-null argument, will fill it in with the current time in seconds+microseconds. * libamu/xutil.c: remove actual declaration of clock_valid, and another never-used declaration for xclock_valid. * include/am_utils.h: remove defunct definition of clocktime() macro and clock_valid variable. Add extern for new definition. * libamu/mount_fs.c (mount_fs), hlfsd/homedir.c (homedir, hlfsd_diskspace, hlfsd_getpwent, plt_reset, table_add), hlfsd/hlfsd.c (main, hlfsd_init, reload, cleanup), conf/mtab/mtab_mach3.c (open_locked_mtab), conf/mtab/mtab_file.c (open_locked_mtab), amd/nfs_start.c (do_select, run_rpc), amd/autil.c (host_normalize): remove defunct clock_valid. * amd/nfs_subr.c (nfsproc_getattr_2_svc): Print microseconds for node's mtime. (fh_to_mp3): use new clocktime() to update mtime and get a better time resolution. * amd/mapc.c (mapc_reload_map): change prototype from returning void to returning an int. If reloading was needed and succeeded, return 1; else return 0. (mapc_sync): update mtime of parent node if needed. This is a CRITICAL FIX, to ensure that the kernel flushes its DNLC/dcache when we run "amq -f" manually or when a map is reloaded. * amd/map.c (new_ttl): update am_ttl and na_atime in one shot. (init_map): use new clocktime(). (unmount_mp): if the OS doesn't support a "symttl" option, then update the mtime of the parent node using the clocktime(); but if the time hasn't gotten changed because of rapid Amd accesses on systems that don't have a micro-second NFS-client resolution, then increment mtime by one arbitrarily (this could, on some systems and under pathological cases, result in mtime's that are in the future). * amd/autil.c (forcibly_timeout_mp): MAJOR BUG FIX: force mtime update of parent dir, to prevent DNLC/dcache from caching the old entry, which could result in ESTALE errors, bad symlinks, and more. (am_mounted): record mount time, and update am_stats at the same time, using the double-action redone clocktime() routine. (am_mounted): update parent's mtime from that of the child. (am_unmounted): when unmounting an entry, update mtime of parent node. * amd/amfs_generic.c (amfs_bgmount): now that clocktime() doesn't remember it's last non-zero value, save it in a temporary variable to avoid a TOCTOU problem (between an "if" and a "dlog"). * libamu/xutil.c (show_time_host_and_name), conf/autofs/autofs_linux.c (autofs_mounted, autofs_timeout_mp), amd/srvr_nfs.c (nfs_keepalive_callback, nfs_keepalive_timeout) (find_nfs_srvr), amd/rpc_fwd.c (fwd_alloc), amd/nfs_subr.c (nfsproc_getattr_2_svc), amd/nfs_start.c (do_select, run_rpc), amd/mapc.c (root_init), amd/map.c(map_flush_srvr, timeout_mp), amd/info_ndbm.c (ndbm_init), amd/info_ldap.c (amu_ldap_rebind), amd/info_file.c (file_open), amd/info_exec.c (fgets_timed, exec_search), amd/clock.c (timeout, softclock), amd/autil.c (forcibly_timeout_mp), amd/amfs_generic.c (amfs_retry, amfs_bgmount, amfs_generic_mount_child), amd/amd.c (main): pass NULL to clocktime(). 2005-09-15 Erez Zadok * amd/nfs_subr.c (nfsproc_getattr_2_svc): initialize 'retry', just in case. (fh_to_mp3): increment amd_stats.d_stale counter only if we are actually returning ESTALE. * amd/info_exec.c (exec_parse_qanswer), amd/info_file.c (file_search_or_reload), amd/info_hesiod.c (hesiod_search), amd/info_ldap.c (amu_ldap_search), amd/info_ndbm.c (search_ndbm), amd/info_nis.c (nis_search), amd/info_nisplus.c (nisplus_search, nisplus_search): don't dereference mnt_map->cfm which may be null if we're not using an amd.conf file. 2005-09-14 Erez Zadok * libamu/xutil.c (unregister_amq): if failed to de-register Amd from portmapper, report it under dlog (debugging), not as an annoying plog that always shows up. 2005-09-13 Erez Zadok * mk-amd-map/mk-amd-map.c (read_file_file), libamu/util.c (strsplit), libamu/hasmntopt.c (nextmntopt), amd/sun_map.c (sun_entry2amd), amd/sun2amd.c (sun2amd_convert_convert), amd/mapc.c (mapc_add_kv), amd/info_file.c (file_search_or_reload), amd/info_exec.c (exec_parse_qanswer): cast isspace() and isascii() arg to unsigned char, which is safer as per Christos. * amd/sun_map.c (sun_entry2amd): isspace takes an int, not a char. * configure.in: keep a dummy unused AM_PROG_LEX, because old Automake (1.6.3) looks for it if you refer to LEX in your Makefile.am files. Silly thing, fixed in newer versions of Automake (1.9.2). 2005-09-11 Erez Zadok * Makefile.am (EXTRA_DIST_M4): add prog_{lex,yacc}.m4 to distro. * configure.in: use new macros AMU_PROG_YACC and AMU_PROG_LEX. * m4/macros/prog_yacc.m4: new macro to check if bison/yacc/byacc exist, but exist with an error if none found. * m4/macros/prog_lex.m4: new macro to check if f/lex exist, but exit with an error if not found (am-utils requires f/lex). 2005-09-07 Erez Zadok * minor new port: powerpc-apple-darwin8.2.0. * m4/macros/type_auth_create_gidlist.m4: Old macosx used "gid_t" but all newer ones (10.4+) use int. * m4/macros/type_recvfrom_fromlen.m4: Old macosx used "int" for 6th arg of recvfrom(), but all newer ones (10.4+) use socklen_t. * minor new port: i386-pc-linux-deb3.1. 2005-09-02 Erez Zadok * conf/mount/mount_linux.c: If autoconf didn't find any disk-based file system on this system (probably because /proc isn't mounted), then provide some default definition for this file to compile. 2005-08-28 Daniel P. Ottavio * amd/sun_map.c (sun_entry2amd) : Wipe out any trailing white spaces or '\n' before passing strings to the parser. * amd/amd.h : oops, reverting bad changes * amd/info_file.c : oops, reverting bad changes * amd/mapc.c : oops, reverting bad changes * amd/sun_map_parse.y : oops, reverting bad changes 2005-08-27 Erez Zadok * libamu/xutil.c: amd_program_number is a u_long now. (unregister_amq): if pmap_unset failed to de-register Amd from the portmapper, print an error message. (get_amd_program_number): returns a u_long now. (set_amd_program_number): take a u_long now. * include/am_utils.h: get_amd_program_number() returns u_long now. set_amd_program_number() takes a u_long now. * amq/amq.c: amd_program_number is a u_long, not int. * amd/nfs_start.c (mount_automounter): when registering Amd with the portmapper (for Amq service), don't fail if just one of TCP or UDP failed to register, but only if both transports failed. That way Amq can still contact Amd using the transport that did register correctly. However, now, if both transports failed to register, then set amd_state to "Done" so it would shutdown cleanly. * conf/transp/transp_{sockets,tli{}.c (amu_svc_register): better comments. * libamu/xutil.c: debug_flags should always be initialized to D_CONTROL (amq,daemon,fork). (debug_option): allow setting initial immutable debug_flags via amd.conf; afterward, prevent it (i.e., one tries it via "amq -D"). * Makefile.am (DISTCLEANFILES): also remove amu_autofs_prot.h, config.cache.old, and dbgcf.h on "make distclean". (CLEANFILES): remove dbgcf on plain "make clean". * amd/Makefile.am (DISTCLEANFILES): also remove ops_autofs.c on "make distclean". 2005-08-27 Daniel P. Ottavio * amd/info_file.c (file_search_or_reload): Changed the key variable that is passed to the sun_entry2amd. * amd/mapc.c (mapc_add_kv): Add support for multiple entries packed into one line. This is a workaround for handling Sun style mounts that contains multiple entries on one line: "multi-mount entries". The sun2amd conversion tools will convert such entries into type:=auto and pack each of the auto-entries into one line separated by '\n'. The mapc_add_kv function will now recognize such entries and add then. * amd/sun2amd.c (sun2amd_convert): Add print statement that includes the line number during a parser failure. * sun_map.c: Fix the AMD_MAP_PREF_KW definition. Fix spelling. (sun_mountpts2amd): removed this function (sun_hsfs2amd): added some more comments (sun_nfs2amd): moved support for multi-mount entries from this function to sun_multi2amd(). (sun_multi2amd): New function to handle multi-mount entries. This function will convert the Sun version to an Amd type:=auto. Each extra auto entry will be appended to the same line separated by a '\n'. (sun_entry2amd): Fixed a bug if-statement. This function now checks for multi-mount entries. * amd/sun_map.h: Add a fstype member to the sun_mountpt struct. * amd/sun_map_parse.y: Parser now supports fstype for multi-mount entries. * amd/sun_map_tok.l: No longer print the line and column number when parsing. This is because the parser is handed strings not files. Therefore, the line number will always be 1. It is now up to the higher level tools to echo line information during error when they feed the parser. 2005-08-24 Erez Zadok * configure.in: wrap all LDAP and HESIOD tests in test whether --with-OPT was used. 2005-08-20 Daniel P. Ottavio * amd/sun_map.c: Clean up #defines (sun_entry2amd) : Verify that the key and entry values passed are not NULL. Free the Sun entry struct when done. * amd/sun_map.h: Add some "not implemented yet" comments to the map and mmap structures. * amd/sun_map_parse.y: Removed automap include functionality, it will need to be re-implemented using a pre-processor. Clean up function calls. 2005-08-16 Daniel P. Ottavio * amd/sun2amd.c (sun2amd_convert): If the input line is too long don't return an error just null terminate and continue. Fix bug: the map key was not written. * amd/sun_map.c: Add a new Amd device, and cdfs constant. (sun_locations2amd): Write the NFS type keyword for each host of the mount entry. Add a space between each mount location. (sun_hsfs2amd): New function to support hsfs to cdfs. (sun_nfs2amd): Don't write the nfs type here. Fix comments. (sun_entry2amd): Change function parameter var for clarity. Add support for hsfs. * amd/sun_map_parse.y (sun_map_parse_read): Reset the entry list after it has been returned. 2005-08-16 Erez Zadok * amd/get_args.c (get_args): initialize debug_flags if they've never been set. 2005-08-15 Erez Zadok * amd/mapc.c (mapc_create): mapc find takes 4th arg, the mount point. Now, we can properly initialize the cfm structure of the mnt_map, so we can have access to the flags (e.g., SUN_MAP_SYNTAX) inside each info_*.c file. (mapc_find): takes 4rd arg (mntpt) and passes it to calls to mapc_create. (root_newmap): pass NULL as 4th arg (mntpt). * amd/amfs_generic.c (amfs_parse_defaults): remove ugly hack to initialize map cfm structure (including flags) so late. * amd/autil.c (amfs_mkcacheref): pass mount point as 4th arg to mapc_find. * amd/amfs_root.c (amfs_root_mount): pass NULL as new 4th arg to mapc_find. * amd/amd.h: extern for mapc_find changed to pass the mount point. * libamu/xutil.c: debug_flags should be unsigned. (dbg_opt): fix comments for updated debug_flags, add "defaults". (debug_option): Don't allow "immutable" (D_IMMUTABLE) flags to be changed, because they could mess Amd's state and only make sense to be set once when Amd starts. Currently these immutable flags are "daemon," "fork," "amq," and "mtab." If Amd not compiled with debugging, set default "control" options (daemon,fork,amq). (unregister_amq): proper use of D_AMQ. * include/am_utils.h: define new D_BASIC, D_CONTROL, D_DEFAULT, D_IMMUTABLE, and D_MASK. Updated definitions of D_ALL and D_TEST. debug_flags extern should be unsigned. * scripts/amd.conf-sample (debug_options): mention new "defaults" option. * scripts/amd.conf.5,doc/am-utils.texi: document new debug option "defaults" and properly explain the corrected meanings of "daemon," "fork," "amq," and their "no" inversions. Better explain "all" and "test" too. Correct default debug_mtab file to /tmp/mtab. * hlfsd/stubs.c (nfsproc_readlink_2_svc): proper use of D_FORK. * hlfsd/homedir.c (homedir): proper use of D_FORK. * hlfsd/hlfsd.c (main, hlfsd_init, cleanup): proper use of D_DAEMON. * amd/nfs_start.c (mount_automounter): proper use of D_AMQ. * amd/amd.h (DEBUG_MNTTAB_FILE): change default to /tmp/mtab, which is more common on more systems (instead of /tmp/mnttab). * amd/amd.c (main): properly use D_DAEMON. 2005-08-14 Erez Zadok * libamu/xutil.c (xlog_opt): define new pseudo log_option named "defaults", which is an alias for "fatal,error,user,warning,info". * scripts/amd.conf.5, doc/am-utils.texi, amd/amd.8: document new log_option "defaults". * amq/amq.8: typo. Arg name for -D is "debug_options" not "log_options". * libamu/xutil.c: make xlog_level static, and initialize it to XLOG_DEFAULT. (cmdoption): take unsigned int as flags argument, and print any errors as XLOG_ERROR (which cannot be turned off). (switch_option): remove old code which disallowed you from turning off flags that were set when Amd started up. Now, you can turn any log option on/off at start time or later on (via amq -x), other than the two mandatory options (fatal+error). * include/am_utils.h (XLOG_*): remove unused XLOG_DEFSTR. Define XLOG_MASK to mask out unused flag bits. Define XLOG_DEFAULT to be what it was before (fatal + error + user + warning + info), but use the new mask. Remove extern's for xlog_level and xlog_level_init. Change extern for cmdoption() to take an unsigned flags argument. * doc/am-utils.texi, amq/amq.8, scripts/amd.conf.5, amd/amd.8: document mandatory log options (fatal+error) which cannot be turned off and are always on by default. They must be on so that Amd can report crucial errors, including those related to setting flags on/off. * hlfsd/hlfsd.c (main): remove hack to initialize log_options. * wire-test/wire-test.c: remove reference to unused xlog_level. * amd/mapc.c (mapc_create): 'alloc' flags variable should be unsigned. * amd/get_args.c (get_args): no need for hack using xlog_level_init. * amd/Makefile.am: separate sources common to amd and sun2amd into a special, locally-built only, static library called libaminfo.a. * libamu/xutil.c (real_plog, xsnprintf): call new xvsnprintf() wrapper function. (xvsnprintf): new function which already gets a va_list. This was needed to avoid nesting va_list's (which apparently isn't allowed). * include/am_utils.h: prototype for new xvsnprintf wrapper. * configure.in: sinclude([vers.m4]) version number file. * vers.m4: new file to separate version number out of configure.in, useful for nightly snapshot script to generate nightly version string. * Makefile.am (EXTRA_DIST_M4): include vers.m4 in distro. 2005-08-14 Daniel P. Ottavio * amd/info_file.c: add key to sun_entry2amd()'s parameters * amd/info_hesiod.c: add key to sun_entry2amd()'s parameters * amd/info_ldap.c: add key to sun_entry2amd()'s parameters * amd/info_ndbm.c: add key to sun_entry2amd()'s parameters * amd/info_nis.c: add key to sun_entry2amd()'s parameters * amd/info_nisplus.c: add key to sun_entry2amd()'s parameters * amd/sun_map.c: New functions to support sun translation to amd. The function sun_entry2amd's parameters were expanded to include the key value. sun_entry_2amd() now returns NULL on error. * amd/sun_map.h: Expand sun_entry2amd's parameters to include key value. * amd/sun_map_parse.y: Change how file system types are parsed out of the list of options for each entry. The previous way was not working properly so now we just look for the 'fstype' keyword in each option. If it exists we copy its key value. Added some comments to sun_map_parse_read(). * amd/amd.h: Added an extern from info_file.c called file_read_line(). Previously this function was static but is now used in sun2amd.c. * amd/info_file.c: Changed the static function read_line() to a public function called file_read_line(). This function is now used in sun2amd.c * amd/sun2amd.8: Filled in the contents of this man page. This is a conversion utility that converts Sun maps to Amd maps. * amd/sun2amd.c: Implemented a working version of this utility. 2005-08-11 Erez Zadok * amd/sun_map_parse.y: instead of using a custom FOO_alloc() function, use Amd's CALLOC(struct FOO) macro. * amd/sun_map.h: remove extern definitions to functions no longer needed. * amd/sun_map.c: removed superfluous *_alloc() functions, some of which caused conflicts with same-named symbols in the parser (since we rename 'yyalloc' to 'sun_map_alloc'). * configure.in: keep AC_INIT on same line, for nightly snapshot build script. * amd/Makefile.am: f/lex libraries are incompatible with multiple scanners, so don't link Amd with libl.a/libfl.a. 2005-08-10 Daniel P. Ottavio * amd/sun_map_tok.l: Clean up regular expression so HPUX stops whining. 2005-08-09 Daniel P. Ottavio * amd/sun_map_parse.y: Moved license below special yacc bracket to be portable with HPUX's yacc. Clean up externs. * amd/sun_map_tok.l: Moved license below special lex bracket to be portable with HPUX's lex. Fixed definitions to allow for a non-flex lex to parse strings instead of files. Added some casts to strlcpy usage to silence warnings. Moved the % options because HPUX was complaining, 2005-08-08 Daniel P. Ottavio * amd/sun_map_tok.l: Applied some definition goop to handle the ECHO symbol that lex defines. This symbol causes problems on RedHat-EL-powerPC platforms. Replaced strncpy with strlcpy. Renamed the function sun_map_yyinput to sun_map_input. This function is a utility function that is not generated by lex. Therefore, the 'yy' may cause confusion. 2005-08-08 Erez Zadok * amd/sun_map_tok.l: allocate more output slots so lex scanners don't run out of memory. * amd/sun_map_parse.y: declare extern for sun_map_parse(). * libamu/xutil.c (xsnprintf): ensure proper comparisons between signed and unsigned quantities. 2005-08-06 Erez Zadok * libamu/util.c, amd/autil.c (strsplit): moved strsplit() function from Amd code to to libamu, so sun2amd could use it. * amd/Makefile.am (sbin_PROGRAMS): build sun2amd binary and man page. (EXTRA_sun2amd_OBJECTS): sun2amd needs to link with all info_*.c files * amd/sun2amd.8: placeholder for man page. * amd/sun2amd.c: placeholder for C version of translator from Sun syntax maps to Amd maps. * */*.[0-9]: include file name in nroff source comment. * ALL: use '0' properly when assigning or passing it to functions. If in the context pointer, use NULL. If in the context of a single char (say within a string), the use '\0'. This is just to make the code clearer. * m4/macros/header_templates.m4: template for HAVE_MAP_SUN. * amd/mapc.c (maptypes): add placeholder for Sun-syntax map methods. * amd/Makefile.am (EXTRA_amd_SOURCES): compile info_sun.c * amd/info_sun.c: placeholder for meta info parser to get info from Sun automount-style /etc/auto_master, possibly following into multiple info services (via /etc/nsswitch.conf). * libamu/xutil.c (xsnprintf): if vsnprintf truncated the output string to avoid an overflow, print an error. Include some code to break out any possible infinite loop between plog() and xsnprintf(). (real_plog): now we can use (carefully) xsnprintf() directly. * amd/sun_map.[hc]: cleanup and formatting. * amd/sun_map_parse.y: to match the literal string "fstype=" use double quotes, not single quotes. * amd/get_args.c (get_args): call conf_parse() using conf_in. * amd/amd.h: use renamed parser symbols (yyparse -> conf_parse; yyin -> conf_in). * ylwrap: Enhance wrapper to avoid the #define hacks done by Gdb, and suggested by the Automake manual. This enhanced parser will prefix each conflicting yacc/lex symbol with a unique name produced from INPUT. For example, if INPUT is foo_parse.y, then yyparse() becomes foo_parse(). This requires that both your .l and corresponding .y files have the same prefix (e.g., foo_parse.y and foo_tok.l). * amd/Makefile.am (BUILT_SOURCES): define which yacc/lex .h/.c source files are built automatically, and therefore should not be in the distro (IMHO), and should be cleaned upon "make clean". (amd_SOURCES): include new sun_map_parse.y and sun_map_tok.l files. * ylwrap: new file needed because we have two parsers now. * amd/sun_map_{parse.y,tok.l}: cleanup and formatting. 2005-08-06 Daniel P. Ottavio * amd/Makefile.am: Added new files sun_map.h, sun_map.c, sun_map_parse.y, and sun_map_tok.l. These files add support for parsing Sun style maps. The yacc/lex files needed custom rules so they don't cause symbol conflicts with each other. * amd/amd.h: Added "#define INFO_MAX_LINE_LEN" that specifies the line limit for info services. * amd/info_exec.c: Replaced MAX_LINE_LEN with INFO_MAX_LINE_LEN * amd/info_file.c: Replaced MAX_LINE_LEN with INFO_MAX_LINE_LEN, added support for parsing Sun style maps. The support for Sun maps is done using the sun_entry2amd() function. This function is called for each entry line that is read only when Sun parsing is enabled. For each entry line that is passed to the function a copy of the Amd equivalent is returned. * amd/sun_map.h: new header file for Sun style map support * amd/sun_map.c: new source file for Sun style map support, clean up comments, additional sun2amd conversion routines * amd/sun_map_parse.y: new yacc file for parsing Sun style maps, fix copyright notice, put filename below license. * amd/sun_map_tok.l: new lex file for parsing Sun style maps, fix copyright notice, put filename below license. * amd/get_args.c: replace usage of strlcat with xstrlcat * include/am_utils.h: added 'extern void xstrlcat()' * libamu/util.c: Added a xstrlcat() function that wraps the syscall strlcat() so that string truncations can be logged. 2005-08-06 Erez Zadok * amd/info_file.c (file_search, file_reload): pass mnt_map to file_search_or_reload. (file_search_or_reload): ensure that mnt_map is never NULL. * amd/info_nis.c (nis_search): call sun_entry2amd() if sun_map_syntax=yes. * amd/info_ldap.c (amu_ldap_search): call sun_entry2amd() if sun_map_syntax=yes. * amd/info_hesiod.c (hesiod_search): call sun_entry2amd() if sun_map_syntax=yes. * amd/info_ndbm.c (ndbm_search): pass mnt_map to search_ndbm. (search_ndbm): call sun_entry2amd() if sun_map_syntax=yes. * amd/info_nisplus.c (nisplus_search): call sun_entry2amd() if sun_map_syntax=yes. * amd/info_exec.c (exec_search): pass mnt_map to exec_parse_qanswer. (exec_parse_qanswer): call sun_entry2amd() if sun_map_syntax=yes. * doc/am-utils.texi (sun_map_syntax Parameter): document new common parameter. * scripts/amd.conf.5: selectors_in_defaults is a common parameter, not just [global]. Use consistent capitalization of Amd/Amq. Document new sun_map_syntax parameter. * scripts/amd.conf-sample: properly list all of the parameters which are common to both the [global] and the per-map sections. (sun_map_syntax): example of new parameter. * doc/am-utils.texi (Common Parameters): selectors_in_defaults is a common parameter, not just [global]. * scripts/amd.conf-sample (sun_map_syntax): example of new flag. * amd/conf.c ({ropt,gopt}_sun_map_syntax): new function to parse sun_map_syntax flag (global or per map). * amd/amd.h (CFM_SUN_MAP_SYNTAX): new flag for users to say if the map uses Sun automounter syntax. * cvs-server.txt: update instructions after branching 6.1-stable. 2005-08-02 Erez Zadok ******************************************************************* *** Released am-utils-6.1.1 *** ******************************************************************* * libamu/xutil.c (xsnprintf): "unsafe" alternative to vsnprintf is vsprintf, not sprintf. * conf/umount/umount_osf.c (umount_fs): refer to proper formal parameter name. (umount2_fs): pass second arg to umount(). * ALL: remove CVS ID and put actual file name in source. * conf/autofs/*.[hc]: proper copyright headers. * whitespace reformatting. Remove remaining '%W%' SCCS IDs. * amd/mntfs.c (free_mntfs): don't discard the last reference to an mntfs that had been mounted already. It won't have the MFF_RESTARTED flag on, as it gets turned off after the entry is mounted, but it will have the MFF_RSTKEEP flag on. * amd/autil.c (mf_mounted), amd/restart.c (restart_fake_mntfs): show the mntfs's flags. 2005-08-01 Erez Zadok * conf/mtab/mtab_linux.c: removed unused code. Cleanup. (handler): removed this bad signal handler. (lock_mtab): Redhat's original code set a signal handler called "handler()" for all non-ALRM signals. The handler called unlock_mntlist(), plog'ed the signal name, and then exit(1)! Never, ever, exit() from inside a utility function. This messed up Amd's careful signal-handling code, and caused Amd to abort uncleanly only any other "innocent" signal (even simple SIGUSR1), leaving behind a hung Amd mnt point. That code should have at least restored the signal handlers' states upon a successful mtab unlocking. Anyway, that handler was unnecessary, because will call unlock_mntlist() properly anyway on exit. * conf/mtab/mtab_{file,isc3,mach3,linux}.c (unlock_mntlist): dlog message that we're inside the unlock_mntlist function. * amd/amd.c (main): use new setup_sighandler() for Amd's four main signals (INT, TERM, HUP, and CHLD). (main) Add SIGINT and SIGTERM to masked_sigs, used in nfs_start.c:do_select() for setjmp/longjmp code; the MASK was set to all four signals if !HAVE_SIGACTION, but only to HUP+CHLD if we HAVE_SIGACTION. So this change makes Amd behave consistently. * include/am_utils.h: extern for new setup_sighandler(). * libamu/xutil.c (setup_sighandler): new utility function to setup a single signal-handler regardless of what method is supported by this OS. (going_down): call unlock_mntlist() when exiting, to ensure that Amd will remove any leftover mtab lock files, if any. * amd/restart.c (restart_automounter_nodes): cleanup function. * minor new port: i386-pc-linuxoldld-deb3.1. * configure.in: include before to get the definition of size_t on Debian-3.1r0a. 2005-07-29 Erez Zadok * amd/srvr_nfs.c (find_nfs_srvr): don't blindly copy the hostent IP address. First check if it differs from the existing one of the fserver, and copy only if it changed. If it did change, flush the fhandle cache to avoid a stale fhandle being reused. This allows Amd to detect IP address changes even for an fserver that lost one or more NFS pings, but not enough to be declared totally down. We handle the "totally down" fserver case in check_fs_addr_change(). * amd/ops_nfs.c (nfs_umount), amd/sched.c (sched_task), amd/nfs_subr.c (nfs_quick_reply): code clarity. * conf/mount/mount_linux.c (linux_nfs_error): dlog mappings of errnos to NFS errors. * conf/umount/umount_linux.c (umount2_fs): cleanup code. Trying stat() seems doomed to hang at times, so don't try stat at all, because umount2() appears to be clever enough to never hang. 2005-07-25 Erez Zadok * amd/amd.h (FSF_FORCE_UNMOUNT): new flag used to indicate that a particular fserver may need forced/lazy unmounts when it's mntfs's are unmounted. * amd/ops_nfs.c (nfs_umount): a simple unmount returned EBUSY, and the user specified forced_unmounts=yes in amd.conf, and this fserver was flagged with FSF_FORCE_UNMOUNT, and the OS supports forced/lazy unmounts, then try forced/lazy unmounts. This should allow a hung mount point to be removed. * amd/srvr_nfs.c (find_nfs_srvr): move away IP-address change detection code to its own function. (check_fs_addr_change): new function to detect if the IP address of a downed host has changed, and do various cleanups and fixups to try and recover as best from that situation (e.g., flushing various caches). Also set the FSF_FORCE_UNMOUNT flag for the fserver in question. (flush_srvr_nfs_cache): pass fserver as argument, so we can selectively flush the NFS cache for a single fserver (or all of them, if you pass NULL). * libamu/xutil.c (switch_to_logfile): truncate a regular-file log file if user passed non-zero "truncate_log" flag. * include/am_utils.h: switch_to_logfile() now takes a 3rd arg. * amd/get_args.c (get_args): pass "truncate_log" flag as per amd.conf global settings. * amd/conf.c (gopt_truncate_log): store global value of truncate_log flag. * amd/amq_subr.c (amqproc_setopt_1_svc), hlfsd/hlfsd.c (main, reload): don't truncate log file when calling switch_to_logfile(). * amd/amd.h (CFM_TRUNCATE_LOG): new flag. Fix comment typo. * NEWS, doc/am-utils.texi (truncate_log Parameter), scripts/amd.conf.5, scripts/amd.conf-sample (log_file): document new truncate_log amd.conf parameter. * amd/conf.c (gopt_forced_unmounts): check Linux kernel version and alert if your version may be too old for MNT_FORCE to work (before 2.4.0) or for MNT_DETACH to work (before 2.6.0). Otherwise it may be impossible to pin down the exact kernel version in which we should enable this feature. * conf/umount/umount_linux.c (umount2_fs): if MNT_FORCE returned EBUSY, then don't try to stat(2) before MNT_DETACH because it could hang. 2005-07-21 Erez Zadok * conf/umount/umount_linux.c (umount_fs): cleanup this function, breaking long "if" statements using "goto out". * conf/umount/umount_{aix,bsd44,osf,default,linux}.c (umount_fs): call new utility function umount2_fs() as needed (EBUSY, EIO, or ESTALE). * conf/umount/umount_{aix,bsd44,osf,default,linux}.c (umount2_fs): define a new utility function to invoke forcible/lazy unmounts without touching any mtab files. This separate utility function is useful because it can be called from elsewhere. * amd/amfs_toplvl.c (amfs_toplvl_init): new function, called before Amd mounts toplvl mounts, which gives us a hook for cleanup of a previously dead Amd. In our case, if the user asked for forced_unmounts, and the OS supports it, then we try forced/lazy unmounts on any previous toplvl mounts. This is useful if a previous Amd died and left behind toplvl mount points (this Amd will clean them up!). WARNING: Don't use forced/lazy unmounts if you have another valid Amd running, because this code WILL force those valid toplvl mount points to be detached as well! * amd/amfs_toplvl.c (amfs_toplvl_umount): don't unconditionally try forced/lazy unmounts because it will prevent a normal Amd from terminating and cleaning up properly (self-deadlocking: detached mounts hang the parent Amd on a stat). Since we already do unmounts in the background, then try a safer policy: after trying the normal unmounts a few times (5 sec), escalate and try forced unmounts a few times (5 more seconds), and if even that failed, then try the ultimate -- detached unmounts (which always succeed). This allows Amd to first try and shutdown cleanly, and gradually try more forcible ways to shutdown. On Linux, this procedure will cleanly shutdown Amd even if there are processes with their CWD on Amd's mount points (which normally result in EBUSY). 2005-07-20 Erez Zadok * Makefile.am (EXTRA_DIST_CONF): add new umount_aix.c to distro. * conf/umount/umount_aix.c: easier if AIX has its own unmount helper file. * m4/macros/check_umount_style.m4: AIX needs its own unmount style file. * doc/am-utils.texi (forced_unmounts Parameter): @xref -> @pxref. 2005-07-19 Erez Zadok * conf/nfs_prot/nfs_prot_aix5_2.h: define compatible forced-unmount flag. * conf/umount/umount_default.c (umount_fs): if regular umount got EBUSY, EIO, or ESTALE, then try forced unmount, if supported. Try umount2 (Solaris) or uvmount (AIX). * conf/umount/umount_{bsd44,osf}.c (umount_fs): if default umount() failed with EIO or ESTALE, also try forced unmount. 2005-07-18 Erez Zadok * amd/autil.c (amfs_mount), amd/amfs_toplvl.c (amfs_toplvl_umount): enable forced/lazy unmounts only if user asked for it (and dlog it). * scripts/amd.conf.5: document new force_unmount global parameter. * doc/am-utils.texi (forced_unmounts Parameter): document new global parameter. * amd/conf.c (gopt_forced_unmounts): process forced_unmounts option (default "no"). Exit with an error if user specified the option as "yes" but configure couldn't find support for either the MNT_FORCE or MNT_DETACH flags. * scripts/amd.conf-sample (forced_unmounts): example usage of new option. * amd/amd.h (CFM_FORCED_UNMOUNTS): new flag for forced_unmounts option. * m4/macros/header_templates.m4: templates for _DETACH and _FORCE. * configure.in: check for generic u/mount options "detach" and "force". * include/am_utils.h (UMOUNT_FS, umount_fs): new prototypes. Define AMU_UMOUNT flags for force, detach, and autofs. * amd/amfs_toplvl.c (amfs_toplvl_umount): pass _FORCE and _DETACH unmount flags unconditionally. Pass them to UMOUNT_FS(). * conf/nfs_prot/nfs_prot_linux.h: define MNT_FORCE and MNT_DETACH if needed, because some Linux systems don't define them (presumably because it would be too dangerous to expose these flags to users). * amd/autil.c (amfs_mount): if mount(2) failed with ESTALE or EIO, then assume that we're in trouble, possibly because a previous mount is hung. So, first try to force a lazy unmount of the old mount. If the forced unmount worked, then try again to mount the desired file system. If the forced unmount failed, then don't retry: just return an error. * amd/amfs_generic.c (amfs_generic_umount), amd/amfs_host.c (amfs_host_umount), amd/ops_cachefs.c (cachefs_umount), amd/ops_cdfs.c (cdfs_umount), amd/ops_efs.c (efs_umount), amd/ops_lofs.c (lofs_umount), amd/ops_nfs.c (nfs_umount), amd/ops_pcfs.c (pcfs_umount), amd/ops_ufs.c (ufs_umount), amd/ops_xfs.c (xfs_umount), conf/umount/umount_bsd44.c (umount_fs), conf/umount/umount_default.c (umount_fs), conf/umount/umount_linux.c (umount_fs), conf/umount/umount_osf.c (umount_fs): compute and use unmount specific flags. 2005-07-16 Erez Zadok * configure.in: better help for users, if nfs_args can't be found. 2005-07-15 Erez Zadok * BUGS: more details on AIX's need to install bos.net.nfs.adt before configuring am-utils (else configure cannot find struct nfs_args on AIX). 2005-07-10 Erez Zadok * amd/srvr_nfs.c (find_nfs_srvr): flush NFS handle cache if the IP address of a down server had changed. * amd/info_union.c (union_reload): use safer xsnprintf() routine. * amd/srvr_nfs.c (find_nfs_srvr): check to see if the IP address of a named but down fserver changed (i.e., the previous IP address is no longer responding). If so, then reset the fserver to the new IP address, and set the fserver's flags such that the function will fall through to doing the usual NFS version/proto checks and pinging. (This should fix one case of bug #308.) * conf/umount/umount_linux.c (umount_fs): warn if plain umount() failed, before we try to ignore any errors or try optional umount2(), possibly with forced/lazy unmount. (umount_fs): dlog when unmount succeeded. 2005-07-08 Erez Zadok * conf/mount/mount_linux.c: add a couple more NFSv2 error codes that are compatible with NFSv3. 2005-07-07 Erez Zadok * m4/macros/header_templates.m4: extern template for strlcat(). * amd/get_args.c (get_version_string): use safer strlcat (or replacement strlcat). Use new wrapper xsnprintf() function, which will use the safer vsnprintf() if available, else default to plain sprintf. * configure.in: check for existence of strlcat() and its extern, replacing with libamu/strlcat.c as needed. * libamu/Makefile.am (EXTRA_DIST): add strlcat.c to distro. * include/am_defs.h: optional strlcat() extern. * include/am_utils.h: extern for new xvsnprintf(). * configure.in: overdue new major libtool shlib version. Check for snprintf function and extern. 2005-07-06 Erez Zadok * conf/nfs_prot/nfs_prot_aix4_3.h: cleanup struct aix4_nfs_args_bis. * Makefile.am (EXTRA_DIST_CONF): include mount_aix3.c in distribution. * conf/mount/mount_aix.c: mount style for aix 5.x and newer. * conf/mount/mount_aix3.c: mount styles for aix 3.x/4.x. * m4/macros/check_mount_style.m4: split mount styles for aix3.x/4.x and the newer (and better) aix 5.x code. 2005-07-05 Erez Zadok * amq/pawd.c (getawd): avoid buffer overflow. Bug fix from Graeme Wilford . 2005-06-30 Erez Zadok * amd/map.c (get_next_exported_ap): Avoid running off the end of the exported_ap[] array. Patch from jon+amd-at-spock.org. Fixed bug #301. 2005-06-25 Erez Zadok * Makefile.am (EXTRA_DIST_CONF): distribute new mtab_linux.c. * conf/mtab/mtab_linux.c (rewrite_mtab): variable declarations must come before C code. * conf/mtab/mtab_linux.c: Linux-specific mount table hanlding that's safe (uses locks, handles symlinks to /proc/mounts, etc.). Patch from Red Hat, which they adapted from mtab_file.c. Minor fixes to this file. * m4/macros/check_mnttab_style.m4: Use Linux-specific mount table handling. 2005-06-24 Erez Zadok * conf/mount/mount_aix.c (mount_aix3): minor cleanup of filehandle copying code. 2005-06-23 Erez Zadok * conf/nfs_prot/nfs_prot_hpux.h: add extern for h_errno, which may be missing from older hpux10 systems. * configure.in: update bug-reporting address to list https://bugzilla.am-utils.org/ as well as the mailing list. * Makefile.am (EXTRA_DIST_M4): distribute new type_rpcvers_t.m4 macro. * conf/transp/transp_tli.c (get_nfs_version): always use rpcvers_t, now that it'll be automatically discovered. * configure.in: check for rpcvers_t type. * m4/macros/type_rpcvers_t.m4: new macro to check for type of rpcvers_t (Some Solaris versions need it). * conf/nfs_prot/nfs_prot_sunos5_8.h: don't define INADDR_NONE here, but in the actual source files that may need it. * libamu/wire.c (INADDR_NONE): define INADDR_NONE if not defined already. * include/am_defs.h: define extern for sleep(3) if needed. * m4/macros/header_templates.m4: template for sleep(3) extern. * configure.in: check for extern for sleep(3), which is missing from some old (and buggy) versions of gcc's fixinc'ed headers. * conf/nfs_prot/nfs_prot_aix4_3.h: update definition of struct nfs_args from actual system headers. * conf/mount/mount_aix.c (mount_aix3): fix name of aix4 "bis" structure. 2005-06-22 Erez Zadok * BUGS: update Solaris information about use of f/lex and yacc/bison. 2005-06-20 Erez Zadok * minor new port: i386-pc-linux-suse9.3. 2005-06-20 Rainer Orth * configure.in (linux/nfs_mount.h): Move __KERNEL__ definition up so u32 is available for . 2005-06-16 Erez Zadok * amd/mapc.c (maptypes): move MAP_EXEC after MAP_FILE, because exec maps will always match when users use amd with command line args (not amd.conf). Using that legacy way, unfortunately, means that Amd will use it's hard-coded info-service search path, which doesn't work for everyone. It's much better to use amd.conf and specify what you want exactly. 2005-06-15 Erez Zadok * minor new port: i386-pc-linux-fc4 (gcc4 catches more bugs). * m4/macros/type_recvfrom_fromlen.m4: linux systems use unsigned int as the type of recvfrom()'s 6th argument. * m4/macros/type_yp_order_outorder.m4: linux systems use unsigned int as the type of yp_order()'s 3rd argument. 2005-06-15 Erez Zadok * scripts/amd.conf-sample (map_type): typo, said mount_type instead of map_type for the 'exec' example. 2005-06-11 Erez Zadok ******************************************************************* *** Released am-utils-6.1 *** ******************************************************************* 2005-06-04 Erez Zadok * amd/ops_nfs.c (mount_nfs_fh): set timeo/retrans mount options only if the user specified them in amd.conf or elsewhere. If they were not specified, don't do anything, which would let the OS use its own defaults. * amd/get_args.c (get_args): negative timeo/retrans are "good" in that they represent uninitialized values (meaning to let the OS use it's default values). So only check if user specified a value equal to zero (invalid). * amd/amd.h: define AMU_TYPE_NONE so we know when users didn't specify timeo/retrans at all. 2005-06-03 Erez Zadok ******************************************************************* *** Released am-utils-6.1-rc7 *** ******************************************************************* * m4/macros/os_cflags.m4 (CFLAGS): use custom-OS C flags for configuring, not just for building. That way the two phases (configure and compile) are in sync. This fixes getwire() on OSF/1 systems. * conf/nfs_prot/nfs_prot_sunos5_8.h: define INADDR_NONE if not defined in system headers. 2005-06-01 Erez Zadok * libamu/Makefile.am (EXTRA_DIST): remove alloca.c as it's no longer needed. 2005-05-28 Erez Zadok * completed set of fixes for irix6.5. * Minor new ports alpha-unknown-linux-gentoo1.4.16 alphaev56-dec-osf4.0f, mips-unknown-linux-gentoo1.4.16, and sparc64-unknown-linux-gentoo1.4.16, and mips-sgi-irix6.5. Test those systems with both cc and gcc, where possible. * include/am_xdr_func.h: remove trailing comma at end of enum list. * m4/macros/os_cflags.m4: with gcc 3.4.3 on irix-6.5, we get pte_t undefined. So give it a dummy value. * libamu/alloca.c: remove file from distro. * configure.in: don't call AC_FUNC_ALLOCA any more. * include/am_defs.h: remove header fixups for , now that we don't need it. * amd/amq_svc.c (amqsvc_is_client_allowed): rewrite function to avoid only use of alloca() in am-utils, and to use strdup explicitly. This way we can avoid using alloca, a feature that's not portable on various systems. * amq/amq.c: remove unused lint/rcsid cruft. 2005-05-27 Erez Zadok * conf/checkmount/checkmount_osf.c (fixmount_check_mount): add extra parentheses around assignments in "if" expressions (gcc complains). * conf/nfs_prot/nfs_prot_osf4.h: add missing extern definitions for plock, hstrerror, getmntinfo, alloca, xdr_exportnode, and xdr_groups. * configure.in: check for , which, if found, appears to be preferable to . Use it to find . On some Linux systems (Gentoo), both exist but only one must be included, or else you get redefined structure errors. * libamu/wire.c (is_network_member): check if masknum is INADDR_NONE, not "< 0" because it's an unsigned quantity. * libamu/util.c (xstrlcpy): remove useless test for size_t < 0, because it's an unsigned quantity. 2005-05-26 Erez Zadok ******************************************************************* *** Released am-utils-6.1-rc6 *** ******************************************************************* 2005-05-25 Erez Zadok * conf/nfs_prot/nfs_prot_aix5_2.h: AIX 5.3 complains about missing definition of struct thread_credentials in but trying to bring that definition in drags a whole lot of other messy stuff. So just provide a dummy definition for this structure. 2005-05-24 Erez Zadok * Makefile.am (EXTRA_DIST_M4): distribute m4/macros/libtool.m4. * m4/macros/header_templates.m4: template for HAVE_EXTERN_MNTCTL. * m4/macros/check_extern.m4: include on AIX systems, so we can find extern definition for mntctl(). * conf/mtab/mtab_aix.c, conf/checkmount/checkmount_aix.c: only define an extern for mntctl() if needed. * amd/ops_nfs.c (prime_nfs_fhandle_cache): never, ever, use C++ style comments in C code. Some C compilers don't accept it. * amd/info_ldap.c (amu_ldap_init, get_ldap_timestamp): force cast of "time_t *ts" to u_long, to avoid complaints on AIX 5.2 with xlC. * amd/get_args.c: rename symbol conf_file to amu_conf_file to avoid conflict with libldap.a from openldap-2.0.21 on AIX 5.2. Oh, when will people who develop libraries learn to always prefix their exported symbols with a library-specific name? * configure.in: check for mntctl() extern on AIX systems. * ltmain.sh: update from latest libtool-1.5.18, so we can properly build on AIX 5.2/5.3 with cc and with gcc. * m4/macros/libtool.m4: update from latest libtool-1.5.18. This time, and from now on, we must include libtool.m4 from the libtool distribution itself. That way we ensure that we use an ltmain.sh that matches the appropriate libtool M4 macros. This makes am-utils no longer dependent on having libtool installed on a given system on which you run bootstrap. 2005-05-23 Erez Zadok * minor new port: i386-pc-linux-deb3.0. 2005-05-22 Erez Zadok * minor new ports: i386-unknown-netbsdelf2.0.2 and i386-unknown-openbsd3.7. 2005-05-20 Erez Zadok * minor new ports: i386-pc-linux-gentoo1.4.16 and powerpc-unknown-linux-yellowdog2.3. * include/{mount_headers2.h, am_defs.h}: safer setup before inclusion of , which is broken on several systems. * configure.in: test for . Separate special test for because we need to define __KERNEL__ for that test, as well as optionally define struct nfs2_fh for some systems (gentoo with 2.4 kernel, yellowdog 2.3, and others). * config.guess.long: support Gentoo and Yellow Dog Linux distros. 2005-05-18 Erez Zadok * minor new ports: i386-pc-linux-suse9.2 and i386-unknown-freebsd5.4. * amd/nfs_subr.c: use NFS_FHSIZE, not FHSIZE. 2005-05-17 Erez Zadok ******************************************************************* *** Released am-utils-6.1-rc5 *** ******************************************************************* * amd/info_ldap.c (amu_ldap_init): change plog to dlog, to avoid sending annoying warning for a minor issue. 2005-05-17 Ion Badulescu * amd/nfs_subr.c: check for NULL pointer before dereferencing it. 2005-05-16 Erez Zadok * minor new ports: powerpc-apple-darwin7.9.0. * m4/macros/host_macros.m4: if a NetBSD system, remove 'elf' part from OS name because it's no longer relevant. Also, don't include the major OS version number in the OS name because that's also unnecessary (and users can always use $osver in maps). * amd/nfs_subr.c: use [1] for out-of-band pointer at the end of struct am_fh, because it's the most portable method. Bug fix suggestion from Dan Riley . Better fix from Ion Badulescu: use [FHSIZE-sizeof(u_int)] which is the actual size we use. * amd/amfs_generic.c (amfs_lookup_mntfs): reset currently used def_opts to options given in -opts, appended with the /default options. Bug fix suggestion from Dan Riley . 2005-05-13 Erez Zadok ******************************************************************* *** Released am-utils-6.1-rc4 *** ******************************************************************* 2005-05-11 Daniel P. Ottavio * amd/amd.c (main) : fixed memory leak detected by valgrind * amd/info_ldap.c (amu_ldap_init) : fixed memory leak detected by valgrind 2005-05-11 Erez Zadok * m4/macros/{check_checkmount_style.m4, check_mnttab_style.m4, check_nfs_fh_dref.m4, check_nfs_prot_headers.m4, check_nfs_sa_dref.m4, check_umount_style.m4, os_cflags.m4}: check for "macosx" as valid OS string, so we compile properly on Darwin systems. ******************************************************************* *** Released am-utils-6.1-rc3 *** ******************************************************************* * rerun bootstrap to get a working configure script that actually checks for limits.h and dependent linux autofs/nfs headers. * configure.in: remove redundant check for limits.h. 2005-05-09 Erez Zadok ******************************************************************* *** Released am-utils-6.1-rc2 *** ******************************************************************* 2005-05-08 Erez Zadok * amd/amfs_generic.c (amfs_lookup_mntfs): removed redundant use of old_def_opts variable. 2005-05-08 Daniel P. Ottavio * amd/amfs_generic.c (amfs_lookup_mntfs) : Make sure when a map entry has a single dash '-', that the default options are reset. This functionality was somehow lost from earlier releases and reported by Dan Riley . 2005-05-05 Erez Zadok * config.guess.long: detect SuSE Enterprise Server and call it "sles" not "suse". 2005-05-02 Erez Zadok * doc/am-utils.texi (amd): document proper use of /etc/hosts.allow. Don't spawn a new Amd process because Amd will get confused if someone else waitpid's on its children (which often do important un/mount work). Issue reported by Francis Montagnac . * minor new ports: powerpc64-unknown-linux-rhel4, and powerpc64-unknown-linux-sles9. 2005-05-01 Daniel P. Ottavio * amd/amfs_host.c (amfs_host_umount): We do not want to pass ENOENT as an error because if the directory does not exists our work is done anyway. * conf/umount/umount_linux.c (umount_fs): If we are successful or there was an ENOENT, remove the mount entry from the mtab file. 2005-05-01 Ion Badulescu * amd/nfs_subr.c: am_fh definition moved here from amd.h; restructured to better reflect its duality (old/new filehandles) (fh_to_mp3): fhh_gen is always used, even for new style f/h (mp_to_fh): ditto * amd/amd.h: moved am_fh definition to nfs_subr.c (which is the only place where it's used) 2005-04-30 Erez Zadok * m4/macros/host_macros.m4: use sw_vers on Apple machines to find out more appropriate OS name (macosx) and OS version (10.3.x) than uname(3) reports. 2005-04-29 Erez Zadok * config.guess, config.sub, doc/texinfo.tex: updates from latest official GNU distributions. * m4/macros/host_macros.m4: for macosx, change architecture value from "Power Macintosh" to "powerpc". * libamu/util.c (xstrlcpy): format 'len' parameter as u_long, not int (it's a size_t). 2005-04-16 Erez Zadok * scripts/amd.conf.5, doc/am-utils.texi (normalize_slashes Parameter), scripts/amd.conf-sample: document new normalize_slashes global configuration parameter. * amd/opts.c (deslashify, normalize_slash): don't touch trailing slashes, even if multiples of them, if user said normalize_slashes=no in amd.conf. * amd/conf.c (gopt_normalize_slashes): new function to record if to normalize slashes or not. * amd/amd.h (CFM_NORMALIZE_SLASHES): new flag to decide if to normalize double-slashes or not ("yes" by default). * amd/autil.c (am_mounted): pass TRUE when calling mf_mounted. This is the parent mntfs which does the mf->mf_fo (am_opts type), and we're passing TRUE here to tell mf_mounted to actually free the am_opts. * amd/autil.c (mf_mounted): Be careful when calling free_ops and XFREE here. Some pseudo file systems like nfsx call this function, even though it would be called by the lower-level amd file system functions. nfsx needs to call this function because of the other actions it takes. So we pass a boolean from the caller (yes, not so clean workaround) to determine if we should free or not. If we're not freeing (often because we're called from a callback function), then just to be sure, we'll zero out the am_opts structure and set the pointer to NULL. The parent mntfs node owns this memory and is going to free it with a call to mf_mounted(mntfs,TRUE). * amd/amd.h: pass flag to mf_mounted, to free or not to free the am_opts. * amd/amfs_nfsx.c (amfs_nfsx_cont): call mf_mounted with FALSE to tell it not to free the am_opts, to avoid double free. * include/am_defs.h: include limits.h if found. * configure.in: check for limits.h. Check for certain Linux headers such as auto_fs.h after checking for limits.h, and include the latter if it exists, because some Linux headers depend on limits.h. This prevents warnings during configure time. 2005-04-12 Erez Zadok * amd/amfs_toplvl.c (amfs_toplvl_mount): do NOT set retrans/timeo values from default global UDP settings, because it can cause unexpected timeouts in Amd on slow systems. The default that each OS provides for these toplvl NFS mounts should be OK, or else you can use the map_options entry. 2005-04-09 Daniel P. Ottavio * amd/nfs_subr.c (mp_to_fh): Replace xstrlcpy with memcpy because the source buffer is treated more as a filehandle than a string. * amd/nfs_subr.c (fh_to_mp3): Replace xstrlcpy with memcpy because the source buffer is treated more as a filehandle than a string. * amd/opts.c (free_op): No longer need to assign pointer to NULL after XFREE. * amd/opts.c (expand_op): Revert back to using strncpy() instead of xstrlcpy. The code is correct and relies on the semantics of strncpy. * libamu/mount_fs.c (compute_nfs_args): Leave XXX warning that use of xstrlcpy in NFS_HN_DREF may corrupt a struct nfs_args, or truncate our concocted "hostname:/path" string prematurely if the nap->hostname field is ever less than 64 bytes long (MAXHOSTNAMELEN). * libamu/util.c (xstrlcpy): Return immediately if len is 0 to avoid unnecessary work. Log an error and return if len is less than 0. 2005-04-07 Erez Zadok * include/am_utils.h (XFREE): XFREE() should nullify the pointer even when compiling without debugging. It's safer this way. * libamu/xutil.c (am_set_hostname), hlfsd/stubs.c (nfsproc_lookup_2_svc), fsinfo/fsinfo.c (fsi_get_args), fixmount/fixmount.c (is_same_host, remove_mount, main), conf/mtab/mtab_isc3.c (mnt_dup, mtab_of), conf/mount/mount_svr4.c (mount_svr4), conf/mount/mount_linux.c (setup_loop_device), conf/hn_dref/hn_dref_linux.h (NFS_HN_DREF), conf/hn_dref/hn_dref_isc3.h (NFS_HN_DREF), amd/opts.c (expand_op), amd/ops_nfs.c (mount_nfs_fh), amd/nfs_subr.c (fh_to_mp3, mp_to_fh), amd/amfs_host.c (amfs_host_mount), amd/am_ops.c (merge_opts): use the new xstrlcpy instead of strncpy. * conf/checkmount/checkmount_{default,svr4}.c (fixmount_check_mount): document why NOT to use xstrlcpy. * libamu/xutil.c: am_hostname need not be MAXHOSTNAMELEN+1 any more, just MAXHOSTNAMELEN. * libamu/xutil.c (real_plog): use strlcpy (not xstrlcpy to avoid recursion, since xstrlcpy may use plog). * libamu/util.c (xstrlcpy): truncating a string is serious. Use XLOG_ERROR not XLOG_WARNING. 2005-04-06 Erez Zadok * include/am_utils.h: external definition for new xstrlcpy function. * libamu/util.c (xstrlcpy): new function. Similar to strncpy, but uses strlcpy to guarantee that the resulting string is null terminated, and also warn if the resulting string was truncated. * libamu/xutil.c (get_server_pid): move this function from util.c which is for general-purpose utilities. * m4/macros/header_templates.m4: template for HAVE_EXTERN_STRLCPY. * include/am_defs.h: provide extern definition for strlcpy, if needed. * libamu/Makefile.am (EXTRA_DIST): include strlcpy.c in distro. * configure.in: search for strlcpy and its extern. * amq/pawd.c (find_mt): It only handles *some* filesystem types, so it breaks on direct xfs mounts for example. The fix (from Christos Zoulas) is simple: We need to exclude toplvl to avoid infinite recursion, but all other fs's are game. 2005-03-31 Erez Zadok * amd/nfs_subr.c (fh_to_mp3): strncpy may not null terminate if copying exactly len bytes, so add null just to be safe. 2005-03-30 Daniel P. Ottavio * amd/nfs_subr.c (fh_to_mp3): Increased the n of strncpy() to make sure it null terminates. 2005-03-29 Daniel P. Ottavio * amd/nfs_subr.c (fh_to_mp3): Fix memset bug. In this case the memset can be removed because strncpy() should padd the buffer with NULLs anyway. 2005-03-21 Rainer Orth * include/am_defs.h: Clarify comment. 2005-03-21 Erez Zadok * include/am_defs.h: undefine "GROUP" so Solaris 10 with gcc-2.96 won't complain about a conflict for this definition between and . 2005-03-20 Erez Zadok * amd/readdir.c (amfs_readdir_browsable): use %p, not %lx. * libamu/mount_fs.c (print_nfs_args): print pointer with %p, not %lx. 2005-03-18 Erez Zadok ******************************************************************* *** Released am-utils-6.1-rc1 *** ******************************************************************* 2005-03-18 Erez Zadok * conf/transp/transp_tli.c (get_nfs_version): use proper type for versout on Solaris (rpcvcers_t). * amd/mapc.c (mapc_showtypes): if last map type to print, don't append newline or comma to it. * libamu/mount_fs.c (print_nfs_args): cast struct netbuf pointer to %lx because on Solaris 10 sparc gcc-3.4.3 complains about casting it to an int (size is different). * configure.in, NEWS: prepare for 6.1-rc1 release. 2005-03-17 Erez Zadok * scripts/amd2ldif.in, ldap.schema: fixes by Adam Morley to synchronize what amd2ldif does vs. what the ldap.schema expects. * amd/map.c (exported_ap_free): We're using a free-list data structure and re-using malloc'ed objects. So, to be safe, memset entire structure when it's freed, not just the pointer. (umount_exported): bug fix to on-exit code. Don't run am_unmounted() unless unmount_mp() didn't run, since the latter already calls am_unmounted(). This way we avoid a double-free bug. 2005-03-15 Erez Zadok * tasks: updates. Executable maps is supported. NFSv4 and FreeBSD autofs isn't. * Makefile.am (EXTRA_DIST): include FAQ in distro. * doc/Makefile.am (alldocs): install README.lda and README.osx. * FAQ: new file, better late than never. 2005-03-14 Erez Zadok * scripts/amd2ldif.in: patch to add the amdMapName attribute to the amdMapTimestamp object when amd2ldif converts it. This is necessary if you are using type:=auto mounts and want those mountmaps looked up through LDAP. Patch from Jim Zajkowski . 2005-03-12 Erez Zadok * minor new ports: i386-pc-linux-rhel4. * minor new ports: powerpc-apple-darwin7.8.0. 2005-03-10 Erez Zadok * amd/ops_nfs.c (prime_nfs_fhandle_cache): rearrange code so it's cleaner. * ltmain.sh: upgrade from libtool-1.5.6. * m4/macros/check_{fs_mntent,mnttab_type,mount_type}.m4: check for Linux 2.6 kernel modules, which have a .ko extension, not .o. Now we can properly detect which file systems exist on Linux 2.6 based systems (SLES9, RHEL4, Fedora, etc.). 2005-03-09 Erez Zadok * m4/macros/host_macros.m4: find out what's the OS software distribution name, if any. * m4/macros/header_templates.m4: template for DISTRO_NAME. * amd/get_args.c (get_version_string): print again full_os, os, osver, and vendor (bug fix). (get_version_string): print distribution name, if known (e.g., rh9, suse8, etc.). * amd/mapc.c (mapc_showtypes): wrap around list of supported map. 2005-03-08 Erez Zadok * amd/map.c (umount_exported): when unmounting file systems on exit (when amd.conf global unmount_on_exit=yes), use unmount_mp() instead of unmount_node() because the latter always unmounts in the foreground, whereas the former unmounts in the bg/fg as needed. Unmounting always in the foreground has two problems: (1) if the unmount hangs, amd hangs, and (2) for type:=program, the unmount script is execve'd(!) thus replacing the main amd process, which never gets to finish up, leaving the amd mount points hung. * NEWS: mention new feature of executable maps. * AUTHORS: Acknowledge Erik Kline. * scripts/amd.conf.5: document executable maps and exec_map_timeout parameter. * scripts/amd.conf-sample: examples of an executable map and exec_map_timeout. * m4/macros/header_templates.m4: template for HAVE_MAP_EXEC. * doc/am-utils.texi: document Executable maps and exec_map_timeout parameter. * amd/conf.c (gopt_exec_map_timeout): function to parse exec_map_timeout [global] parameter. * amd/amd.h (AMFS_EXEC_MAP_TIMEOUT): define default executable map timeout to 10 seconds, and a global placeholder for the configurable value. * amd/amd.c (init_global_options): initialize default executable map timeout. * amd/Makefile.am (EXTRA_amd_SOURCES): include info_exec.c in tarball. * configure.in: enable executable maps. * amd/mapc.c: define executable map functions and behavior. * amd/info_exec.c: executable map implementation from Erik Kline , modified, cleaned-up, and fixed. 2005-03-07 Erez Zadok * amd/info_file.c (file_init_or_mtime): consolidate identical file_init and file_mtime into one function. 2005-03-05 Erez Zadok * doc/am-utils.texi (Program Filesystem): if umount/unmount are not specified, Amd uses "umount ${fs}" by default. * amd/amfs_program.c (amfs_program_match): if neither unmount nor umount parameters are specified, use the default userland umount program with "umount ${fs}". This way type:=program doesn't have to specify the umount program for basic unmounting actions. (amfs_program_init): save unmount program string in mf_private only if it's NULL, not based on mf_refc. * configure.in: auto-detect name of userland unmount program. * aux_conf.h.in (UNMOUNT_PROGRAM): macro for default userland unmount program. * amd/ops_cachefs.c (cachefs_init): save unmount program string in mf_private only if it's NULL, not based on mf_refc. * configure.in: don't "discover" inheritance file system any more, since we don't have the .c file for it. * amd/get_args.c (get_version_string): hack to still show that we support the inherit file system in output of amd -v. 2005-03-05 Ion Badulescu * amd/amfs_inherit.c: removed, dead code * amd/Makefile.am, amd/am_ops.c, amd/amd.h, conf/autofs/autofs_linux.h, conf/autofs/autofs_solaris_v1.h, conf/autofs/autofs_solaris_v2_v3.h, m4/macros/header_templates.m4: removed references to amfs_inherit.c 2005-03-05 Erez Zadok * amd/autil.c (am_mounted): completely rewrite the unmount no/timeout code to (1) make more sense for odd conditions, and (2) allow utimeout=N mount options to override FS_NOTIMEOUT default flags for disk-based file systems such as ufs, pcfs, cdfs, etc. * libamu/mount_fs.c (mount_fs): use safer XFREE() not free(). * conf/umount/umount_linux.c (umount_fs): strtok is destructive, so use strdup'ed string. * conf/mount/mount_linux.c (parse_opts): strtok is destructive, so use strdup'ed string. 2005-03-04 Erez Zadok * scripts/amd.conf.5, doc/am-utils.texi (cache_duration Parameter): clarify actual behavior: this Parameter affects initial mount timeout as well as the linear backoff what happens the initial failed EBUSY unmount. * doc/am-utils.texi (opts Option): better explanation of utimeout=N mount pseudo-option. * amd/amd.h (AM_TTL, AM_TTL_W): better comments, minor cleanup. 2005-03-02 Daniel P. Ottavio * AUTHORS: add Dan Ottavio. * scripts/amd.conf.5: document new debug_mtab_file option. * scripts/amd.conf-sample (debug_mtab_file): show example. * doc/am-utils.texi (debug_mtab_file Parameter): document new option. * conf/mtab/mtab_{file,mach3}.c (open_locked_mtab): if mtab file doesn't exist by the time Amd tries to exist, return a 0 rather than hang indefinitely. * amd/conf.c (gopt_debug_mtab_file): new function to parse debug_mtab_file option. * amd/amd.h: placeholder for debug_mtab_file string. Define default debug_mtab_file to "/tmp/mtab". * NEWS: document new debug_mtab_file option. 2005-03-02 Erez Zadok * conf/transp/transp_{sockets,tli}.c (amu_get_myaddress): when users want Amd's NFS service to bind to some arbitrary "localhost" address, show which address was actually resolved and bound to. 2005-03-01 Erez Zadok * amd/srvr_nfs.c (start_nfs_pings): move code from elsewhere (update_nfs_pingval) that initializes the pinger, as well as turns it on/off as needed, and handles changing its value. This is to avoid races and other infinite-loop conditions that could result in ping storms. * amd/srvr_amfs_auto.c (amfs_generic_find_srvr): when creating a new file server structure, default the ping value to AM_PINGER (30sec) and set the FSF_PING_UNINIT flag. * amd/amd.h (FSF_PING_UNINIT): new flag to tell whether the NFS pinger had been initialized for a given file server. * scripts/ctl-amd.in (stop): no need to check if /var/lock/subsys/amd file exists if you do an rm -f afterward. Ensure that proper return value is returned from script. * NEWS, doc/am-utils.texi (opts Option): update meaning of ping=N so that if N=-1, pings are off; if N=0, pings are set to the default value (currently 30 seconds). 2005-02-28 Erez Zadok * amd/nfs_prot_svc.c (nfs_program_2): on TLI system, try to call __rpc_get_local_uid to verify if the RPC call through the local host interface came from UID 0. * configure.in: look for internal libnsl function __rpc_get_local_uid (seems to be available on all known TLI systems, Solaris and HP-UX 11). * conf/transp/transp_tli.c (amu_svc_getcaller): unnecessary function for TLI systems (and it violated a array's bounds, discovered with libumem.so). (bind_resv_port, bind_resv_port_only_udp, get_autofs_address): just to be on the safe side, set struct t_bind's qlen field to non zero (64 by default). This value cannot be zero for TCP connections, and it's unclear if it's good to have it zero for UDP connections, so setting it to 64 is safer. 2005-02-27 Erez Zadok * doc/am-utils.texi (opts Option, Keep-alives): update text on ping option. * amd/srvr_nfs.c (update_nfs_pingval): new function to update NFS server ping values, turn them off, or re-enable them. (find_nfs_srvr): call update_nfs_pingval() as needed. * hlfsd/hlfsd.c (reaper, cleanup): don't use exit(3) in a signal handler, but use _exit(2) instead. * amd/amd.c (parent_exit): This signal handler is called during Amd initialization. The parent forks a child to do all the hard automounting work, and waits for a SIGQUIT signal from the child. When the parent gets the signal it's supposed to call this handler and exit(3), thus completing the daemonizing process. Alas, on some systems, especially Linux 2.4/2.6 with Glibc, exit(3) doesn't always terminate the parent process. Worse, the parent process now refuses to accept any more SIGQUIT signals -- they are blocked. What's really annoying is that this doesn't happen all the time, suggesting a race condition somewhere. (This happens even if I change the logic to use another signal.) I traced this to something which exit(3) does in addition to exiting the process, probably some atexit() stuff or other side-effects related to signal handling. Either way, since at this stage the parent process just needs to terminate, I'm simply calling _exit(2). Note also that the OpenGroup doesn't list exit(3) as a recommended "Base Interface" but they do list _exit(2) as one. This fix seems to work reliably all the time. * scripts/wait4amd2die.in: change default to recognize that amd is down more quickly (check every 3 seconds instead of 5). 2005-02-26 Erez Zadok * libamu/xutil.c (amu_release_controlling_tty): warn if closing stdin/stdout/stderr failed. No need for tempfd. * scripts/ctl-{amd,hlfsd}.in: before running any real program in these shell scripts, chdir to "/" to avoid possible hangs with existing NFS mounts. This was causing ctl-amd's forked grand-child amd process to hang if restartable_mounts=no. Go figure. 2005-02-25 Erez Zadok * minor new port ia64-unknown-linux-rhel4 * fsinfo/fsi_util.c (set_ether_if): avoid u_long casting to -1 (RHEL4 gcc 3.4.3 ia64 compiler complains). 2005-02-24 Erez Zadok * minor new port i386-unknown-freebsd6.0 (6.0-CURRENT-SNAP001). 2005-02-23 Erez Zadok * minor new port: i386-pc-linux-rhel3. * INSTALL: major update of the compatibility list. * m4/macros/os_cflags.m4: set AMU_CFLAGS not AM_CFLAGS. 2005-02-22 Erez Zadok * scripts/amd.conf.5, doc/am-utils.texi (preferred_amq_port): document new preferred_amq_port [global] option. * scripts/amd.conf-sample (preferred_amq_port): example. * include/am_utils.h: add preferred_amq_port to prototype. * conf/transp/transp_tli.c (bind_preferred_amq_port): new function to bind the Amq RPC service for UDP and TCP to a preferred port (or to any port if preferred_amq_port==0). (create_amq_service): decide if to bind to RPC_ANYFD, or to a requested port. * conf/transp/transp_sockets.c (create_amq_service): if preferred_amq_port is greater than 0, then bind to that port for both UDP and TCP. If preferred_amq_port==0, then bind to any port. * amd/nfs_start.c (mount_automounter): pass global preferred_amq_port value to create_amq_service(). * amd/conf.c (gopt_preferred_amq_port): new function to parse amd.conf value for preferred_amq_port. * amd/amd.h: placeholder for preferred_amq_port. 2005-02-21 Erez Zadok * conf/transp/transp_tli.c (bind_resv_port_only_udp): rename old bindnfs_port to a more proper name. This function binds the NFS service to a specified port, and only for UDP. * conf/transp/transp_tli.c: cleanup some code, rename some functions, in preparation for RPC amq port specification code. 2005-02-19 Erez Zadok * */Makefile.am: don't redefine CFLAGS or LDFLAGS; they are reserved for users to pass them on the command line. Instead, use autoconf's internal AM_CFLAGS and AM_LDFLAGS. * depcomp, install-sh, missing, mkinstalldirs: update from latest versions of Automake 1.9.2. * m4/macros/*.m4: properly quote AC_DEFUN'ed macro name, and fix regexp/patsubst M4 commands. Newer versions of autoconf (e.g., v2.59) complain about those. 2005-02-17 Erez Zadok * amd/opts.c (f_xhost): if we don't have hstrerror, just print the value of h_errno. * configure.in: include -lresolv if it defines the hstrerror() function and not already available in existing libraries. * minor new port: powerpc-apple-darwin7.7.0. * amd/nfs_subr.c (mp_to_fh): pathlen should be u_int because it is later compared against an unsigned quantity (complaint from gcc 3.3 on SuSE 8.2) * include/am_utils.h: remove unnecessary (and conflicting) extern for bind_resv_port2(), which is declared as static in transp_tli.c. * doc/am-utils.texi, scripts/amd.conf.5, scripts/amd.conf-sample, NEWS: document four new amd.conf options: nfs_retry_interval_udp, nfs_retransmit_counter_udp nfs_retry_interval_tcp, and nfs_retransmit_counter_tcp. * amd/ops_nfs.c (mount_nfs_fh): set timeo/retrans values based on wether nfs_proto was "udp" or "tcp". * amd/amfs_toplvl.c (amfs_toplvl_mount): set retrans/timeo values from default UDP settings (because toplvl mounts are UDP for now). * amd/get_args.c (get_args): use parameters to -t option to set both UDP and TCP timeo/retrans values. * amd/conf.c: (gopt_nfs_retransmit_counter_udp, (gopt_nfs_retransmit_counter_tcp, gopt_nfs_retry_interval_udp (gopt_nfs_retry_interval_tcp): new functions to parse UDP and TCP retrans/timeo parameters separately. (gopt_nfs_retry_interval, gopt_nfs_retransmit_counter): if specified, use it to set defaults for both UDP and TCP. * amd/amd.c (init_global_options): initialize default values of both UDP and TCP retrans/timeo values to -1. * amd/amd.h (AMU_TYPE_{TCP,UDP,MAX}): define separate retrans and timeo values, one for udp mounts and another for tcp mounts. 2005-02-16 Erez Zadok * README.osx: new file with some instructions for Mac OS-X users, courtesy Kevin Layer. * amd/get_args.c (get_args): move call to switch_to_logfile() after processing -v, so we don't print "no logfile defined; using stderr" when we're about to print version info and exit anyway. * minor new port: powerpc-ibm-aix5.3.0.0. * hlfsd/hlfsd.c (main): rewrite code to avoid negative array references. * conf/checkmount/checkmount_aix.c: remove extern definition for mntctl(), since AIX 5.3 has it in . * amd/info_union.c (union_reload): rewrite code to avoid negative array references. * amd/opts.c (split_opts, expand_op): rewrite code to avoid negative array references. * conf/mtab/mtab_aix.c: remove extern definition for mntctl(), since AIX 5.3 has it in . * libamu/xutil.c (real_plog): rewrite code to avoid negative array references. * libamu/wire.c (is_network_member): rearrange code slightly to avoid negative array references (AIX 5.3 xlC 7.0 compiler complains about it). 2005-01-26 Erez Zadok * doc/am-utils.texi (xhost Selector Function): document new selector function. * amd/opts.c (f_xhost): new function for use when matching the "host" selector for the current host's name. This function will now match the primary host name as well as all known aliases (CNAMES) that gethostbyname() returns. This function now supports a new function selector called xhost(ARG); the old host==ARG selector is unharmed. 2005-01-17 Ion Badulescu * NEWS: document the ability to restart old mount points * amd/map.c (mount_auto_node): force the fileid of the root to be 1, so that it won't change between restarts; use the root filesystem's own methods instead of hard-coding the use of the default methods * conf/transp/transp_tli.c (create_nfs_service): better cleanup on error conditions. (bind_resv_port2): allow the caller to request a certain port. * conf/transp/transp_sockets.c (bind_resv_port): allow the caller to request a certain port. (create_nfs_service): better cleanup on error conditions. * amd/restart.c (restart_automounter_nodes): new function, takes care of restarting automounter NFS mount points (autofs will come later). (restart): skip all automounter mount points. * amd/nfs_subr.c (fh_to_mp3, mp_to_fh): new filehandle implementation: if the path to the node is shorter than sizeof(fh) chars (currently 32 chars for a NFSv2 fh), simply store it inside the fh. For longer paths, keep the old implementation. * amd/nfs_start.c (mount_automounter): reorder things so that restarting the toplvl filesystems occurs before anything else (so that we can grab all the ports we need before we accidentally use them for something else). * amd/mntfs.c (locate_mntfs): remove dead code; add special handling of restarted toplvl filesystems. * amd/mapc.c (root_keyiter): fix up a comment. * amd/map.c (path_to_exported_ap): new function, searches for and returns a node by the path to it. (get_root_nfs_fh): remove unnecessary fiddling with the root fh. * config.guess.long: support Red Hat Enterprise Linux 2005-01-17 Erez Zadok * libamu/util.c (rmdirs): prevent amd from logging 'Read-only filesystem' errors when the mount point has an ancestor (i.e. '/') that is mounted read-only. Patch from David Rage . 2005-01-17 Ion Badulescu * conf/umount/umount_linux.c (umount_fs): Linux doesn't need the autofs space hack * conf/umount/umount_default.c (umount_fs): there is no need for HAVE_LOOP_DEV, now that Linux has its own dedicated umount_linux.c 2005-01-17 Erez Zadok * doc/am-utils.texi (Automatic Unmounting): document new umount2() behavior on Linux. * conf/umount/umount_linux.c (umount_fs): new file. On Linux, if umount(2) failed with EIO or ESTALE, try umount2(2) with MNT_FORCE+MNT_DETACH. Based on patch from Christos Zoulas . * m4/macros/check_umount_style.m4: pick new linux umount style. * Makefile.am (EXTRA_DIST_CONF): distribute new umount_linux.c file. 2005-01-16 Erez Zadok * conf/nfs_prot/nfs_prot_aix{4_2,4_3,5_1,5_2}.h, m4/macros/struct_nfs_args.m4: minor cleanups for quicker execution of "nfs_args" test. 2005-01-13 Erez Zadok * amd/get_args.c (show_usage): separate function to print usage string. (get_args) Call show_usage() from get_args when needed, then exit. * amd/get_args.c (get_version_string): print also domain, host, and hostd. (get_args): print version string at the very end, after all other values had been initialized. Patch from Christos Zoulas . * conf/transp/transp_sockets.c (check_pmap_up, get_nfs_version), conf/transp/transp_tli.c (check_pmap_up): correct an inconsistency in timeouts in the RPC code between socket and TLI implementations. The clntudp_create timeout has a different meaning than the clnt_call timeout. Set the timeout of the create to 2 seconds which means retry if no answer in two seconds, and the timeout call to 6 seconds, which will give us consistently 2 to 3 pings. This is useful on occasional network UDP loss where a single packet loss would wrongfully mark a server down. (The TLI code is the one that had the problem occurs.) Patch from Christos Zoulas . * libamu/mount_fs.c (compute_nfs_attrcache_flags): make sure code compiles even for systems that don't have the nfs_args ac{reg,dir}{min,max} fields. * amd/amfs_toplvl.c (set_auto_attrcache_timeout): just to be safe, add "noac" if amd.conf option auto_attrcache was set to 0. This should hopefully make the compute_nfs_attrcache_flags patch even safer. * libamu/mount_fs.c (compute_nfs_attrcache_flags): separate function to compute attribute-cache values. This function now computes attribute-cache flags for BOTH Amd's automount points (NFS) as well as any normal NFS mount that Amd performs. (compute_nfs_args, compute_automounter_nfs_args): call compute_nfs_attrcache_flags to figure out attribute-cache related flags. Patch from Christos Zoulas . * scripts/amd.conf-sample: show examples of new global options domain_strip and auto_attrcache. * scripts/amd.conf.5: document new global options domain_strip and auto_attrcache. Add warning to auto_attrcache use in case of ESTALE. * doc/am-utils.texi: minor cleanups and document new global options domain_strip and auto_attrcache. Add warning to auto_attrcache use in case of ESTALE. * amd/conf.c (gopt_auto_attrcache): parse new global amd.conf option auto_attrcache. (gopt_domain_strip): parse new global amd.conf option domain_strip. Part of a patch from Christos Zoulas . * amd/autil.c (host_normalize): don't call domain_strip() unconditionally, but depend on the new global amd.conf flag domain_strip. * amd/amfs_toplvl.c (set_auto_attrcache_timeout): new function to set attribute cache timeout value given other configured global defaults. (amfs_toplvl_mount): set automount point attribute cache option value to "noac" if attrcache=0, else set it to whatever set_auto_attrcache_timeout() returns. * amd/amd.h (CFM_DOMAIN_STRIP, CFM_DEFAULT_FLAGS): flag to decide if to strip the domain from the host name or not, default options set to strip the domain. Store global value of automount attribute cache timeout value. * amd/amd.c (init_global_options): add flag to record automount point attribute cache value. * amd/amd.c (do_memory_locking): new function to encapsulate all of the memory-locking functionality, which was in main() before. Also added a call to madvise(), just in case. (main): call do_memory_locking() to pin process memory if amd.conf asked for it, but do so after the main Amd process daemonizes, because mlock/mlockall is not inherited by fork() by default. Slightly restructured patch from Jonathan Chen . * configure.in: check for madvise(2). * config.guess, config.sub: updates for latest official GNU versions. * m4/GNUmakefile: update paths to "make update" 2005-01-12 Erez Zadok * conf/nfs_prot/nfs_prot_hpux11.h: define an nfs_fh3 structure that's compatible for HPUX11 as well as NFSv3. * include/am_defs.h: On AIX 5.2, both and define MAXDNAME, if compiling with gcc -D_USE_IRS (so that we get extern definitions for hstrerror() and others). So undef MAXDNAME before it gets redefined. * include/am_defs.h: Solaris 10 (build 72) defines GROUP_OBJ in , which is included in many other header files. uses GROUP_OBJ inside enum zotypes. So if you're unlucky enough to include both headers, you get a compile error because the two symbols conflict. Temp hack: undefine acl.h's GROUP_OBJ before including nis.h, because we don't need acl.h for am-utils. * m4/macros/os_cflags.m4: turn -D_USE_IRS for AIX5+ so that certain extern definitions of resolver functions become available. * amd/opts.c (expand_op): use #define for expand_error string because some compilers complain about the use of static const char[] inside a varargs function. * minor new port i386-unknown-netbsdelf1.6.2. * new port i386-unknown-netbsdelf2.0. * minor port i386-unknown-freebsd5.3. * libamu/mount_fs.c (compute_nfs_args): don't compare nap->maxgrouplist against NULL but against 0 directly, because on FreeBSD 4.3, NULL is defined is (void *)0 and gcc 3.4 complains about a type mismatch. * minor port i386-pc-linux-fc3 (Fedora Core 3). 2005-01-11 Erez Zadok * hlfsd/hlfsd.c (main): use sigsuspend() over sigpause(), because FC3 doesn't have proper extern definition for the defunct sigpause(). * configure.in: look for sigsuspend(). 2005-01-01 Erez Zadok * updated copyright year to 2005 on all files. 2004-11-29 Erez Zadok * scripts/amd.conf.5: Small fixes to typos in man page, from Thomas Klausner . 2004-10-22 Erez Zadok * ldap.schema: add this file to distribution. 2004-09-15 Erez Zadok * doc/am-utils.texi: fix old URLs. 2004-09-01 Erez Zadok * conf/mtab/mtab_aix.c (read_mtab): avoid a race condition between multiple calls to mntctl(). Patch suggested by Michael van Elst . 2004-08-07 Erez Zadok * doc/am-utils.texi (Program Filesystem): document how to get double slashes in Amd maps. * amd/opts.c (normalize_slash): support escaped slashes, needed for SMB mounts. Use '\\\/\\\/' in a string to get a double slash. 2004-08-06 Erez Zadok * amd/amfs_program.c (amfs_program_match): bug fix. Complain if both opt_unmount and opt_umount are missing, not when just one of them is missing. 2004-08-03 Erez Zadok * amq/pawd.c (find_mt): recognize "linkx" type mounts. Patch from Hauke Fath . Support "nfsx" while we're at it. * doc/am-utils.texi: mention bugzilla. Fix broken URL HREF's. 2004-08-02 Erez Zadok * amq/pawd.c (find_mt): recognize "host" type mounts. Patch from Dan Nelson . 2004-07-30 Erez Zadok * doc/am-utils.texi, NEWS: minor typos fixed. 2004-07-30 Erez Zadok * include/am_xdr_func.h: cannot have field-less structure; put a dummy field in. * conf/autofs/autofs_solaris_v2_v3.c (xdr_autofs_rddirargs): cast 2nd arg of xdr_u_int to a u_int*, not int*. (autofs_mount_2_req): don't use C++ // comments. 2004-07-30 Erez Zadok * m4/macros/{try_compile_anyfs,check_field}.m4: include if it exists. Part of a set of FreeBSD 5 patches from Martin Blapp . * include/am_defs.h: include if it exists. * amd/ops_pcfs.c (mount_pcfs): set pcfs_args_t.dirmask field to 0777 by default. * configure.in: check for pcfs_args_t.dirmask field. Check for existence of , new on FreeBSD 5. 2004-07-29 Erez Zadok * minor new port: i386-pc-linux-fc2 (Fedora Core 2). * amd/info_ldap.c (amu_ldap_rebind): don't use ldap_enable_cache() unless the function exists in libldap and the extern is in . Recently, openldap removed the extern from ldap.h, but left the function in libldap, for binary compatibility; however ldap_enable_cache and related functions have been deprecated (and no longer listed in the header files), and therefore should be avoided. * m4/macros/check_extern_ldap.m4: new macro to check for LDAP-specific externs. This is separate from check_extern.m4 so as to avoid breaking the general-purpose macro with LDAP-specific headers. * m4/macros/header_templates.m4: extern template for new HAVE_EXTERN_LDAP_ENABLE_CACHE. * configure.in: call new check_extern_ldap.m4 macro. * Makefile.am (EXTRA_DIST_M4): distribute new check_extern_ldap.m4 macro. * config.guess.long: distinguish between redhat and fedora-core releases. 2004-07-23 Erez Zadok * Minor new port i386-pc-linux-suse8.2: minor new port to SuSE 8.2. This systems' latest GCC (gcc version 3.3 20030226 prerelease) correctly caught a lot of possibly bad comparisons between signed and unsigned quantities. * hlfsd/homedir.c (table_add, plt_search): changed first arg of both functions to u_int. * hlfsd/hlfsd.h, hlfsd/hlfsd.c: change 'cache_interval' to u_int. Changed proto for plt_search arg to u_int. * amq/amq.c (show_mi, main): change 'i' to u_int. * amq/pawd.c (find_mlp): change 'i' to u_int. * amd/srvr_nfs.c (find_nfs_srvr): change proto_nfs_version to u_int. * amd/amd.h: change prototype of vreaddir and amfs_error_readdir to use u_int count parameter. * amd/ops_TEMPLATE.c (foofs_readdir), amd/amfs_error.c (amfs_error_readdir): change 'count' parameter in proto to u_int. * amd/amd.h: change proto of amfs_generic_readdir() to use u_int count parameter. * amd/readdir.c (make_entry_chain): preflen should be u_int. (amfs_readdir_browsable): change 'count' to u_int. (amfs_generic_readdir): change 'count' to u_int. * amd/amd.h: amu_global_options's portmap_program field should be u_long, not int (to match RPC conventions). Change am_fh's fhh_gen field to u_int, to match am_gen field in struct am_node. * amd/conf.c (gopt_portmap_program): use atol() instead of atoi() to avoid size differences. * conf/mount/mount_linux.c (find_unused_loop_device): cast to int to avoid comparison between chars and integers. * libamu/mount_fs.c (get_hex_string): change 'i' to u_int to avoid comparisons between signed and unsigned integers. 2004-07-13 Erez Zadok * minor new port: i386-pc-linux-suse9.1. * include/am_defs.h: don't use __kernel_dev_t for dev_t on Linux, because SuSE wants __kernel_old_dev_t. Instead, just define it directly to what they both use: an unsigned short. 2004-05-27 Erez Zadok * minor new port: i386-unknown-freebsd4.10 2004-04-29 Ion Badulescu * amd/amfs_generic.c (amfs_lookup_one_mntfs): fix the creation of mountpoints for autofs-based sublinks the right way 2004-04-28 Ion Badulescu Fixes for various memory management problems discovered by Rainer's purify run: * conf/transp/transp_tli.c (check_pmap_up): zero out struct timeval before using; (get_nfs_version): ditto * amd/map.c (umount_exported): make sure we don't try to free the same am_node multiple times, by setting its corresponding exported_ap slot to null * amd/get_args.c (get_version_string): a static pointer is pretty pointless, make it automatic * amd/conf.c (gopt_debug_options): remove unnecessary strdup(); (gopt_log_options): ditto (gopt_print_version): free version string after using it * amd/autil.c (mf_mounted): free mntfs->mf_fo instead of leaking it * amd/amfs_generic.c (amfs_lookup_one_mntfs): use the CALLOC macro (amfs_lookup_mntfs): free def_opts on return * amd/amd.c (daemon_mode): zero out struct sigaction before using it; (main): ditto 2004-04-27 Ion Badulescu * amd/amfs_generic.c (amfs_lookup_one_mntfs): force FS_MKMNT on the real mount of an autofs-based sublink 2004-04-25 Ion Badulescu * amd/map.c (free_map_if_success): avoid dereferencing a pointer to potentially freed memory 2004-02-26 Erez Zadok * minor new port: i386-unknown-freebsd5.2.1. 2004-01-30 Ion Badulescu * scripts/ctl-hlfsd.in: don't run hlfsd with -D fork 2004-01-25 Erez Zadok * minor new port: sparc64-unknown-linux-deb3.0 * config.guess.long: recoognize Debian Linux. 2004-01-22 Erez Zadok * conf/transp/transp_tli.c (amu_get_myaddress): use htonl(INADDR_LOOPBACK) and define INADDR_LOOPBACK if not already available. 2004-01-21 Erez Zadok * wire-test/wire-test.c, hlfsd/hlfsd.c (main): pass NULL as second parameter to amu_get_myaddress(). * conf/transp/transp_tli.c (amu_get_myaddress): resolve value of localhost_address amd.conf parameter, if defined (else default to HOST_SELF_CONNECT). Removed htonl() around socket address copying (I think it was wrong) since plog("My IP address is...") in amd.c was printing addresses wrong on Solaris x86.. * conf/transp/transp_sockets.c (amu_get_myaddress): comment out old DEBUG code that warns if 127.0.0.1 isn't the same as what get_myaddress() reports. Add code to resolve value of localhost_address amd.conf parameter, if defined (else default to 127.0.0.1). * amd/conf.c (gopt_localhost_address): new function to parse amd.conf parameter localhost_address. * amd/amd.h: global field to store amd.conf localhost_address parameter. * amd/amd.c (main): call amu_get_myaddress with global option, which could have been set in amd.conf. * NEWS, doc/am-utils.texi, scripts/amd.conf-sample, scripts/amd.conf.5: document new option localhost_address. 2004-01-20 Ion Badulescu * amd/conf.c (gopt_nfs_allow_insecure_port): support function for the new "nfs_allow_insecure_port" amd.conf directive * amd/nfs_prot_svc.c (nfs_program_2): complain about the insecure port and drop the request only if the "nfs_allow_insecure_port" option is not set in amd.conf * doc/am-utils.texi (Global Parameters): documented the new amd.conf directive "nfs_allow_insecure_port" * scripts/amd.conf.5 (nfs_allow_insecure_port): ditto * scripts/amd.conf-sample (nfs_allow_insecure_port): added the "nfs_allow_insecure_port" directive 2004-01-20 Erez Zadok * doc/am-utils.texi: amd-workers is defunct. 2004-01-19 Erez Zadok * cvs-server.txt: updated instructions 2004-01-18 Erez Zadok * minor new port: i386-unknown-freebsd5.2. 2004-01-05 Erez Zadok * MIRRORS.{txt,html}: verify each mirror site, update to new locations (if found), and remove stale mirrors URLs. * updated copyright year to 2004 on all files. 2004-01-03 Erez Zadok * MIRRORS.txt: track status. * Makefile.am (install-snapshot): new directory to install snapshots (now that am-utils home page is moved). 2004-01-02 Erez Zadok * INSTALL, README.autofs: remove forced text-mode. * doc/am-utils.texi: fix Amd book URL. * Makefile.am (EXTRA_DIST): include new mirror files in tarball. * AUTHORS, BUGS, README, README.y2k, configure.in, doc/am-utils.texi: revisions to use newer URLs for Web site, FTP, and mailing lists. * MIRRORS.{html,txt}: updates. * doc/Makefile.am: install mirror lists officially. 2004-01-01 Erez Zadok * tasks: things to do after migrating ftp/Web sites. 2003-12-09 Erez Zadok * fsinfo/fsinfo.8: fixed typo (unbalanced []) in man page. Bug report from Eric S. Raymond . 2003-11-18 Erez Zadok * Makefile.am (EXTRA_DIST_M4): exclude removed file m4/macros/struct_nfs_fh3.m4 from distro. 2003-10-24 Rainer Orth * libamu/xdr_func.c (xdr_am_nfs_fh3): Use AM_FHSIZE3 instead of FHSIZE3 (may be undefined). 2003-10-24 Ion Badulescu Compile fix for Solaris7 with LDAP: * include/am_defs.h: moved the ldap headers before am_nfs_prot.h to facilitate using ldap types in it * conf/nfs_prot/nfs_prot_sunos5_7.h: add a couple of ldap definitions that Sun left out of their headers 2003-10-24 Ion Badulescu * conf/nfs_prot/nfs_prot_*.h: remove all NFSv3-related definitions, they are now defined globally * libamu/xdr_func.c: unconditionally define all xdr functions needed for NFSv3, but with an am_ prefix to prevent namespace collisions * amd/amfs_host.c, amd/ops_nfs.c, amd/srvr_nfs.c, libamu/mount_fs.c: added the am_ prefix to all structures and functions having to do with NFSv3 to prevent namespace collisions * include/am_utils.h: moved definition of am_nfs_handle to ... * include/am_xdr_func.h: ... here. Also define AM_FHSIZE3, am_nfs_fh3, AM_NFSPROC3_LOOKUP, am_nfsstat3, am_fhandle3, am_mountstat3, am_mountres3_ok, am_mountres3, am_filename3, am_diropargs3, am_LOOKUP3args, am_LOOKUP3resok, am_LOOKUP3resfail, am_LOOKUP3res here; remove cross-platform compile helper macros AMU_LOOKUP3RES_*. * include/am_defs.h: include am_xdr_func.h before am_utils.h to provide definitions for NFS filehandles * amd/amd.h: removed declaration for xdr_mountres3 * doc/am-utils.text: minor warning fix * BUGS: document the autoconf warnings when trying to compile system header files in isolation 2003-10-23 Ion Badulescu * m4/macros/struct_nfs_fh3.m4: removed, not needed * configure.in: check if struct mounta has the optptr field; removed all NFSv3-related checks, we implement everything internally now * conf/autofs/autofs_solaris_v2_v3.c (autofs_mount_2_free): don't touch mnt->optptr unless HAVE_MOUNTA_OPTPTR is defined 2003-10-22 Ion Badulescu * m4/macros/struct_nfs_fh3.m4: removed, not used anymore * libamu/xdr_func.c (xdr_am_nfs_fh3): update xdr_am_nfs_fh3 comments * configure.in: don't check for xdr_nfs_fh3 and struct nfs_fh3, we always use our own 2003-10-22 Ion Badulescu * BUGS: document the limitations of bind mounts on Linux 2003-10-21 Ion Badulescu * buildall: added support for -i (make install) 2003-10-16 Rainer Orth * NEWS: New minor port i386-pc-solaris2.10 (Solaris 10). * INSTALL: Mention its test status. 2003-10-16 Erez Zadok * amd/ops_nfs.c (nfs_init): declare as static to match forward definition at top of file. * conf/nfs_prot/nfs_prot_{hpux11, netbsd1_4,openbsd,aix5_2}.h: added missing definitions for LOOKUP3res, diropargs3, etc. 2003-10-15 Erez Zadok * libamu/xdr_func.c (xdr_LOOKUP3res, xdr_am_nfs_fh3), libamu/mount_fs.c (compute_nfs_args), amd/ops_nfs.c (got_nfs_fh_mount, got_nfs_fh_webnfs, prime_nfs_fhandle_cache, webnfs_lookup), amd/amfs_host.c (fetch_fhandle): Attempt to cleanup some inconsistencies with how we treat NFSv3 file handles. Whenever we need to get data out of a filehandle given to us, we assume that it uses the OS's native fhandle structure (often struct nfs_fh3). When we store the fhandle data for our own use, however, we store it in one of two ways. The first, is that we use the system's default nfs_fh3 structure; the second is that we define out own struct am_nfs_fh3 in nfs_prot.h (and go through an elaborate autoconf song-and-dance to "discover" it as a native fh3 handle structure). It appears that we do the latter, instead of using the system's default fhandle structure, simply to avoid extra malloc's and free's, because whereas nfsv2's fhandle structure is a simple 32-byte buffer, nfsv3's fhandle structures often just define a "char *" for the fhandle data, and the caller must malloc/free the space inside as needed. Our code was never written with constructor/destructor callbacks for these nfsv3 filehandles. Moreover, we carefully wrote our own am_nfs_fh3 structure so IT JUST SO HAPPENS to align with most (hopefully all) of the fhandle structures for v3: first four bytes are the length fields and the next four bytes are the fhandle data. Sigh. Having this inconsistent use of v3 filehandles can be a real bear, because we simply cannot avoid using the system's default fhandle structure indirectly, through things like diropargs3 in xdr_diropargs3(), which has inside of it a reference to the system's default nfs_fh3 structure. ANYWAY, the current fix I've come up with is to generalize the way we dereference field names within the nfs_fh3 structure (whether ours or the system's) and the same for the system's LOOKUP3res structure. I'm not pleased with this fix; I'd rather we don't use our own am_nfs_fh3 structure at all. * libamu/xdr_func.c (xdr_am_nfs_fh3): always define this function if we have NFS3, because we often use our own, incompatible am_nfs_fh3 structure. * include/am_xdr_func.h: We cannot use the native system's xdr_nfs_fh3 because we are defining our own incompatible am_hfs_fh3 structure for some systems. * include/am_xdr_func.h: Define default values for field names of struct nfs_fh3 and LOOKUP3res. * doc/am-utils.texi (debug_options Parameter): minor typo fixed. * conf/nfs_prot/nfs_prot_freebsd3.h: FreeBSD uses different fields names for struct nfs_fh3 and LOOKUP3res, so override the default names here. * configure.in: AMU_CHECK_FS_MNTENT(nfs3) test before AMU_STRUCT_NFS_FH3, because the latter depends on the former. * amd/ops_nfs.c (prime_nfs_fhandle_cache): add {} to disambiguate and clarify if-the-else clauses. 2003-10-13 Ion Badulescu * amd/get_args.c (get_version_string): change "Built by" to "Configured by", and add a new "Built by" line using the variables below * m4/update_build_version (vers): add BUILD_USER, BUILD_HOST, and BUILD_DATE to build_version.h * amd/mntfs.c (locate_mntfs): fix restarted filesystems: mf_fo must be initialized even for them, otherwise we lose opt_sublink (and perhaps other options as well). Report from Rainer Orth. * amd/amfs_generic.c (amfs_bgmount): The fix for the mf_fo NULL pointer dereferencing was a bit too aggressive and could end up not processing the sublink option if the filesystem was already mounted. 2003-10-11 Ion Badulescu Fix restarted filesystem by disabling the amfs_inherit filesystem and moving the restarting logic into the generic code. The old code is still there, will be removed sometime in the near future. * amd/mntfs.c (locate_mntfs): disable amfs_inherit and simply return the pointer to the restarted filesystem (free_mntfs): check for the MFF_RESTART flag instead of the amfs_inherit ops * amd/autil.c (mf_mounted): remove the MFF_RESTART flag once the filesystem is in use * amd/amfs_nfsx.c (amfs_nfsx_init): only call fs_init() if the filesystem is not being restarted (amfs_nfsx_remount): if the filesystem is already mounted, short-circuit the code and just continue * amd/amfs_generic.c (amfs_bgmount): only call fs_init() if the filesystem is not being restarted; remove hack that was used to work around an amfs_inherit problem 2003-10-09 Rainer Orth Use WebNFS to obtain file handles for mount(2). * NEWS: Document WebNFS support. * configure.in: Check for public mount option. * include/am_compat.h (MNTTAB_OPT_PUBLIC): Define if missing. * doc/am-utils.texi (opts Option): Renamed webnfs to public, update description. * amd/amd.h (FSF_WEBNFS): New mntfs flag. * include/am_utils.h (RPC_XID_WEBNFS): New XID type. * amd/amfs_host.c (amfs_host_mount, amfs_host_umounted): Reject WebNFS mount/umount attempts. * amd/ops_nfs.c (got_nfs_fh_mount): Renamed from got_nfs_fh. (got_nfs_fh_webnfs): New function. (flush_nfs_fhandle_cache): Don't invalidate port for WebNFS servers. (prime_nfs_fhandle_cache): Likewise. Remove unconditional return of public file handle for WebNFS, but get NFS file handles via mountd or WebNFS instead. (webnfs_lookup): New function. (nfs_umounted): Don't inform mountd if MFF_WEBNFS. * amd/rpc_fwd.c (fwd_packet, fwd_reply): Send/receive WebNFS packets. * amd/srvr_nfs.c (recompute_portmap): Don't contact portmap for WebNFS servers. Mention host in info message. (find_nfs_srvr): Handle public mount option. Prefer NFSv3/tcp if the client supports it. Allow port mount option to override default or result from portmap lookup. * libamu/xdr_func.c (xdr_diropargs3, xdr_filename3, xdr_LOOKUP3args, xdr_LOOKUP3res, xdr_LOOKUP3resfail, xdr_LOOKUP3resok, xdr_nfs_fh3, xdr_nfsstat3): New functions. * include/am_xdr_func.h: Declare them. * configure.in: Check for them. * conf/nfs_prot/nfs_prot_linux.h: Provide missing NFSv3 definitions and types. 2003-10-09 Rainer Orth Support IRIX 6 private mount option. * configure.in (AC_CHECK_MNTTAB_OPTS): Check for private option name string. (AC_CHECK_MNT2_NFS_OPTS): Check for private NFS mount option (IRIX 6). * aux/macros/header_templates.m4 (MNTTAB_OPT_PRIVATE, MNT2_NFS_OPT_PRIVATE): Provide templates. * include/am_compat.h (MNTTAB_OPT_PRIVATE): Define if missing. * doc/am-utils.texi (opts Option): Document it. 2003-10-09 Rainer Orth * doc/am-utils.texi (opts Option): Fix Tru64 UNIX name in proplist mount option. 2003-10-09 Rainer Orth * libamu/mount_fs.c (compute_nfs_args) [HAVE_NFS_ARGS_T_FH_LEN]: Don't reference removed fh3. 2003-10-09 Rainer Orth * NEWS: New minor port sparc-sun-solaris2.10 (Solaris 10). * INSTALL: Mention test status of various ports. Describe IRIX 6 autofs status. 2003-10-09 Ion Badulescu * NEWS: updated * amd/amfs_generic.c (amfs_bgmount): don't use mf_fo until after we've done all the tests and we know we have a valid and mountable mntfs. Otherwise we could end up dereferencing null pointers. * amd/amd.h: fixed a copy&paste comment bug * amd/am_ops.c (ops_match): minor code cleanup * doc/am-utils.texi: fixed various typos; added warning about the racy nature of nfsx; removed duplicated listing of debug options; added paragraph about signals supported by hlfsd; removed the long list of (maybe) supported platforms since it duplicates the list in INSTALL. 2003-10-02 Rainer Orth Simplify FD_SET etc. use. * include/am_defs.h (FD_SET, FD_ISSET, FD_CLR, FD_ZERO): Provide if missing. (rpc_pending_now, run_rpc): Use them. * configure.in: Check for fds_bits field in fd_set. * amd/nfs_start.c (run_rpc): Use it. 2003-10-02 Rainer Orth Improve RPC XID handling. * amd/rpc_fwd.c (fwd_packet, fwd_reply): Always log xid. Convert xid to/from host/network byte order. 2003-10-02 Rainer Orth Use NFS V2/V3 file handles instead of mount results. * include/am_utils.h (am_nfs_fhandle): Use NFS V2/V3 file handles only, not MOUNTPROC_MNT results. * amd/amfs_host.c (fetch_fhandle): Use local variables to store MOUNTPROC_MNT results. * amd/autil.c (amfs_mount): Use new am_nfs_fhandle_t. * amd/ops_nfs.c (struct fh_cache): New member fh_status. (got_nfs_fh): Use local variables to store MOUNTPROC_MNT results. Store MOUNTPROC_MNT errors in fh_status. (prime_nfs_fhandle_cache): Get fh_error from fh_status. * hlfsd/hlfsd.c (main): Use new am_nfs_fhandle_t. * libamu/mount_fs.c (compute_nfs_args): Copy NFS V2/V3 file handles straight from new am_nfs_fhandle_t. 2003-10-02 Rainer Orth * amd/clock.c (CID_ALLOC): Remove unused argument. (timeout): Likewise. * amd/ops_nfs.c (FHID_ALLOC): Remove unused argument. (prime_nfs_fhandle_cache): Likewise. (call_mountd): Use UDPMSGSIZE instead of magic constant. * amd/rpc_fwd.c (XID_ALLOC): Remove unused argument. (fwd_packet): Likewise. Handle TLOOK error from t_rcvudata(). 2003-09-30 Ion Badulescu * NEWS: updated * libamu/mount_fs.c (mount_fs): don't try to recreate the mount point if the mount fails with ENOENT: in the best case we would be papering over a bug, and in the worst case we could cause a deadlock (with autofs). If there are races, they need to be exposed and fixed properly. * conf/autofs/autofs_solaris_v1.h, conf/autofs/autofs_solaris_v2_v3.h, conf/autofs/autofs_linux.h: (AUTOFS_NFSX_FS_FLAGS): autofs semantics don't allow us to mount nfsx directly onto an autofs mountpoint, so disallow it * amd/amfs_nfsx.c (amfs_nfsx_match): more restrictive sanity check to avoid trying to memmove(foo, bar, (unsigned)-1) due to invalid map entries... (amfs_nfsx_cont): amfs_retry does most of the cleanup work for us in the upper layer, so don't do anything else beside wakeup() on success (amfs_nfsx_remount): only create the mountpoints as we need them, avoids creating them on the wrong filesystem in the case of hierarchical mounts; fix crash-generating typo (m should really be mf and I swear I hate single-character variable names) * amd/amfs_generic.c (amfs_cont): one more dlog (amfs_bgmount): amazingly enough, even foreground mounts can be backgrounded (in the case of nfsx), so account for this possibility and permit retries * m4/macros/check_autofs_style.m4 (AMU_AUTOFS_PROT_HEADER): define and AC_SUBST it as ${top_builddir}/amu_autofs_prot.h * amd/Makefile.am ($(amd_OBJECTS) $(EXTRA_amd_OBJECTS)): depend on @AMU_AUTOFS_PROT_HEADER@ 2003-09-29 Erez Zadok * minor new port mipsel-unknown-linux-rhPS2 (Linux on Sony PlayStation 2) * amd/srvr_nfs.c (find_nfs_srvr): don't run code that expects "char protocols[]" unless MNTTAB_OPT_PROTO is defined. 2003-09-26 Rainer Orth Consolidate alloca support. * amd/amq_svc.c: Move alloca support ... * include/am_defs.h: ... here. * amd/conf_parse.y: Remove alloca support. * fsinfo/fsi_gram.y: Likewise. 2003-09-25 Rainer Orth Handle Solaris 10. * m4/macros/check_nfs_prot_headers.m4 (AMU_CHECK_NFS_PROT_HEADERS): Don't use wildcards for sunos5.[0-3], solaris 2.[0-3], there were no micro releases. Explicitly match sunos5*, solaris2* for Solaris 8 and beyond. * m4/macros/os_cflags.m4 (AMU_OS_CFLAGS): Dont use wildcards for solaris2.[0-5], sunos5.[0-5], but explicitly handle Solaris 2.5 micro releases to cope with Solaris 2.5.1. Explicitly match solaris2*, sunos5*. 2003-09-25 Rainer Orth * amd/amq_svc.c: Provide alloca prerequisites. * conf/transp/transp_tli.c (register_autofs_service): Fix typo. 2003-09-23 Ion Badulescu * minor new port: x86_64-unknown-linux-rh2.9.5AS. (Red Hat Enterprise Linux 3.0 beta running on a 64-bit AMD64 platform) 2003-09-22 Ion Badulescu * conf/autofs/autofs_solaris_v1.c (autofs_mount_fs): compile fix 2003-09-19 Ion Badulescu * amd/amfs_nfsl.c (amfs_nfsl_match): checking opt_fs is not always enough, we should lstat() the sublink if it's defined. (amfs_nfsl_ffserver): ditto (ALL): Removed some obsolete comments. The nfsl code is now little more than a very straight-forward switch between link and nfs. * amd/amfs_link.c (amfs_link_match): more up-to-date explanation for the prepend-the-dot hack for type link; also, the sublink is already normalized and absolute, so take advantage of that * amd/amfs_generic.c (amfs_lookup_one_mntfs): the sublink is already normalized and absolute, so take advantage of that * amd/am_ops.c (ops_match): normalize the sublink here, early into the matching process * amd/autil.c (am_mounted): be consistent and accept both "nounmount" and "noumount" as pseudo mount options (same as "unmount" and "umount" nearby) * amd/Makefile.am (build_version.h): fixed dependencies (depends on amd_OBJECTS, not OBJECTS -- which doesn't even exist) 2003-09-19 Erez Zadok * amd/amq_subr.c (amqproc_export_1_svc): force double casting to avoid gcc-3.3 complaints on Solaris 9 about "dereferencing type-punned pointer will break strict-aliasing rules". 2003-09-16 Ion Badulescu * Released beta version 6.1b4 2003-09-15 Ion Badulescu * doc/am-utils.texi (opts Option): removed documentation for old ignore_portmapper mount option, documented the new webnfs option * NEWS: webnfs support * amd/srvr_nfs.c (find_nfs_srvr): set MFF_WEBNFS if the "webnfs" (former "ignore_portmapper") mount option is present * amd/ops_nfs.c (prime_nfs_fhandle_cache): generate a public filehandle (all zeros) if MFF_WEBNFS is set (nfs_umounted): don't talk to mountd if MFF_WEBNFS is set * amd/amd.h (MFF_WEBNFS): new flag, obvious meaning 2003-09-13 Ion Badulescu * amd/srvr_nfs.c: renamed np_xid to global_xid; sanitized the NPXID_ALLOC macro and renamed it to XID_ALLOC; renamed start_ping to create_ping_payload; renamed nfs_pinged to nfs_keepalive_callback; renamed nfs_timed_out to nfs_keepalive_timeout; renamed nfs_srvr_port to get_mountd_port; made ping_buf and ping_len arrays with one element for each supported nfs version * amd/amd.h: renamed nfs_srvr_port() to get_mountd_port() * amd/amfs_host.c (amfs_host_init): ditto * amd/ops_nfs.c (call_mountd): ditto 2003-09-03 Rainer Orth * BUGS: Mention fix for broken Solaris 8 patches. 2003-08-31 Erez Zadok * amd/autil.c (strealloc): don't call malloc_verify() unless it exists. * configure.in: move "OPTION PROCESSING" section (opt_debug etc.) after we figure out PROG_CC and other compiler features, because some of the option processing macros need a compiler to function. * libamu/xutil.c: don't define variables that won't be used unless mallinfo() and malloc_verify() exist. (real_plog): don't call checkup_mem unless mallocinfo() and malloc_verify() exist. (checkup_mem): don't define this function unless mallocinfo() and malloc_verify() exist. * m4/macros/opt_debug.m4: check for functions malloc_verify and mallinfo in general libraries and then in libmapmalloc and libmalloc. These seem to have disappeared in FreeBSD 5.x. * libamu/xutil.c (dxfree): print pointer using %p 2003-08-29 Erez Zadok * configure.in: start 6.1b4-pre officially (belated) * minor new port: i686-apple-darwin6.6 2003-08-27 Ion Badulescu * conf/autofs/autofs_solaris_v1.c: convert relative targets to absolute paths when using lofs mounts * conf/autofs/autofs_solaris_v2_v3.c: ditto * conf/autofs/autofs_linux.c: ditto 2003-08-27 Ion Badulescu * README.autofs: added a paragraph about the resource consumption of auto maps over autofs * amd/amfs_generic.c (amfs_lookup_one_mntfs): moved the setting of the MFF_IS_AUTOFS flag from init_mntfs() to amfs_lookup_one_mntfs(), where it belongs * amd/mntfs.c (init_mntfs): ditto 2003-08-27 Ion Badulescu * amd/ops_nfs.c (got_nfs_fh): make the error EACCES if we are denied a filehandle by the server (used to be EIO) 2003-08-27 Erez Zadok * conf/nfs_prot/nfs_prot_bsdi3.h: support na_uid and na_gid. 2003-08-27 Ion Badulescu * conf/autofs/autofs_linux.c (autofs_mount_succeeded): force daemon-initiated timeouts on autofs filesystems, since apparently they appear as "always busy" to the kernel-based expiration routine 2003-08-26 Ion Badulescu * NEWS: updated * conf/autofs/autofs_linux.h (AUTOFS_LINK_FS_FLAGS): remove FS_ON_AUTOFS (AUTOFS_LINKX_FS_FLAGS): ditto * conf/autofs/autofs_solaris_v1.h (AUTOFS_LINK_FS_FLAGS): remove FS_ON_AUTOFS (AUTOFS_LINKX_FS_FLAGS): ditto * conf/autofs/autofs_solaris_v2_v3.h (AUTOFS_LINK_FS_FLAGS): remove FS_ON_AUTOFS (AUTOFS_LINKX_FS_FLAGS): ditto * amd/amfs_generic.c (amfs_lookup_one_mntfs): don't modify the original opt_fs, instead store the new mount point for autofs in a temporary variable and pass it around. Fixes a problem with the link side of nfsl. 2003-08-25 Ion Badulescu * NEWS: updated * amd/ops_nfs.c (prime_nfs_fhandle_cache): use get_mntfs_wchan to initialize the fh_wchan member of the cache entry (prime_nfs_fhandle_cache): use get_mntfs_wchan for the wchan_t argument of call_mountd() * amd/map.c (free_map_if_success): use get_mntfs_wchan for the wchan_t argument of wakeup() * amd/amfs_nfsx.c (amfs_nfsx_cont): use get_mntfs_wchan for the wchan_t argument of wakeup_task() and wakeup() * amd/amfs_host.c (amfs_host_init): use get_mntfs_wchan for the wchan_t argument of nfs_srvr_port() * amd/amfs_generic.c (ALL): use get_mntfs_wchan for the wchan_t argument of sched_task() and wakeup() (amfs_retry): minor cleanup (amfs_bgmount): call nfs_quick_reply on failure * amd/sched.c (get_mntfs_wchan): new function which calls the member function get_wchan if defined, otherwise returns the mntfs pointer itself * amd/amfs_inherit.c (amfs_inherit_get_wchan): new function, calls get_mntfs_wchan() on the inherited filesystem * amd/amfs_*.c, amd/ops_*.c: initialize the new get_wchan member of the ops to 0 * amd/amd.h: new function type vget_wchan (struct mntfs): new member get_wchan which returns the waiting channel associated with the mntfs (normally itself) 2003-08-22 Ion Badulescu * conf/mount/mount_linux.c (parse_opts): minor cleanup * conf/autofs/autofs_linux.c (autofs_handle_fdset): added missing break in case autofs_ptype_expire_multi 2003-08-22 Ion Badulescu * conf/autofs/autofs_solaris_v1.h: undefine autofs support if autofs_args_t cannot be determined (hopefully fixes a reported IRIX 6.5.4 problem). * conf/autofs/autofs_solaris_v1.c: wrap entire file in #ifdef HAVE_FS_AUTOFS / #endif (see above) * conf/autofs/autofs_linux.h: undefine autofs support if the necessary header files are not found (fixes a reported RedHat 6.2 Sparc problem). * conf/autofs/autofs_linux.c: wrap entire file in #ifdef HAVE_FS_AUTOFS / #endif (see above) * libamu/mount_fs.c (compute_nfs_args): only use MNT2_NFS_OPT_SOFT if autoconf detected it (fixes a reported RedHat 6.2 Alpha problem). * amd/map.c (unmount_mp, unmount_exported): move the code that changes the fattr from NFLNK to NFDIR from unmount_mp to unmount_exported, it was causing troubles (ESTALE) after failed unmounts. This is still very very unclean, but it's the same as the old 6.0 code. 2003-08-22 Nick Williams * amd/info_ldap.c (amu_ldap_init): don't try to pass a null pointer as a string to plog, Solaris (and other OS's) don't like it and will dump core. 2003-08-13 Ion Badulescu * amd/amd.h: introduced two new types, wchan_t and opaque_t, as aliases of voidp. This makes reading the code easier on the eyes. :) * ALL: replace various instances of voidp with wchan_t and opaque_t, as appropriate 2003-08-13 Ion Badulescu * NEWS, configure.in: bumped version up to 6.1b4-pre 2003-08-13 Ion Badulescu * Released beta version 6.1b3 2003-08-13 Ion Badulescu * conf/autofs/autofs_linux.c (autofs_mount_fs): HACK: always use symlinks for host mounts; assorted fixes for the symlink mode 2003-08-05 Ion Badulescu * conf/umount/umount_default.c (umount_fs): enable space hack handling for autofs v1 * amd/map.c (get_first_exported_ap, get_next_exported_ap): new functions that facilitate iterating through the list of mountpoints * amd/amfs_union.c (amfs_union_mounted): use get_first_exported_ap and get_next_exported_ap * conf/autofs/autofs_solaris_v2_v3.c (autofs_unmount_2_req): ditto 2003-08-04 Erez Zadok * configure.in: check if system stores mount tables in files (usually in /etc), and configure couldn't find a definition for either struct mntent or struct mnttab. If so, abort configure because this could be a new/misconfigured system, or a bug in am-utils. 2003-08-04 Ion Badulescu * conf/autofs/autofs_solaris_v2_v3.c (autofs_umount_fs): fix compile warning 2003-08-04 Ion Badulescu * conf/autofs/autofs_linux.c (autofs_mount_fs): don't call ops->mount_fs() for an already mounted filesystem (autofs_umount_fs): only call ops->umount_fs() if we're holding the last reference to the filesystem * conf/autofs/autofs_solaris_v1.c (autofs_mount_fs): ditto (autofs_umount_fs): ditto * conf/autofs/autofs_solaris_v2_v3.c (autofs_mount_fs): ditto (autofs_umount_fs): ditto * amd/amfs_generic.c (amfs_lookup_mntfs): remove the shortcut for already-mounted filesystems (amfs_cont): only release the autofs_fh if the filesystem is not mounted; add another comment about the NFS_SCALEDOWN hack (amfs_bgmount): if the mntfs is already mounted, skip just the filesystem initialization, but do call mount_node() * amd/map.c (mount_node): always call autofs_mount_fs(), but only call ops->mount_fs() if the mntfs is not yet mounted (unmount_node): always call autofs_umount_fs(), but only call ops->umount_fs() if the refcount on the mntfs equals 1. 2003-08-02 Erez Zadok * conf/nfs_prot/nfs_prot_openbsd.h: include here with the proper workarounds for openbsd3.3 (define MAXQUOTAS, define dummy struct netexport, and include wrapped in _KERNEL). * conf/nfs_prot/nfs_prot_freebsd3.h: include here with the proper workarounds for freebsd5.1 (define dummy struct ufs_extattr_per_mount). * conf/nfs_prot/nfs_prot_bsdi2.h: include here with the proper workarounds for bsdi2 (define MAXQUOTAS and dummy struct netexport). * include/mount_headers1.h: do not include here, b/c every *BSD system has some sort of problem in including this header file, which includes ugly workarounds. Inclusion of this header was already moved out of am_defs.h (used to compile amd), but we forgot to move it out of mount_headers1.h (used to configure). The specific inclusion of ufsmount.h is now in the OS specific nfs_prot.h file. * configure.in: if configure could not find any definition for "struct nfs_args", abort configure with an explanatory message. There's no point in continuing, as this could be a system bug, buggy am-utils, or a new system to which am-utils wasn't ported to yet. * minor new port: i386-pc-solaris2.9 2003-08-01 Ion Badulescu * doc/am-utils.texi (NFS-Link Filesystem): make the documentation match the code (as well as basic logic operations: the negation of 'a or b' is 'not a and not b', not 'not a or not b') 2003-08-01 Erez Zadok * minor new port: i386-unknown-openbsd3.3. * m4/macros/check_libwrap_severity.m4: new macro to check if libwrap includes the integer variables deny_severity and allow_severity, since some libwrap implementations do and others don't. The test tries to compile and run a simple empty main() program, then the same program while defining these two variables: comparing the results of the two tests, we can tell whether we should define NEED_LIBWRAP_SEVERITY_VARIABLES. * Makefile.am (EXTRA_DIST_M4): distribute new macro check_libwrap_severity.m4. * m4/macros/header_templates.m4: template for HAVE_LIBWRAP (which we must define explicitly since we've overridden the action-if-found in AC_CHECK_LIB(wrap). Also template for NEED_LIBWRAP_SEVERITY_VARIABLES. * amd/amq_svc.c: if libwrap does not include the severity variables, then define and initialize them here. * amd/Makefile.am (LIBS): explicitly include @WRAPLIB@ only for Amd binary. Other am-utils binaries don't need -lwrap. * configure.in: if libwrap is found, only define it in @WRAPLIB@, so we don't automatically link every am-utils binary with -lwrap. Run test for existence of severity variables in libwrap. 2003-07-31 Erez Zadok * conf/nfs_prot/nfs_prot_openbsd.h: define struct fattr fields uid and gid. * configure.in: move check for AC_CHECK_LIB(libwrap) as far down as possible because on modern tcpwrapper systems such as openbsd, the caller must provide two symbols: deny_severity and allow_severity, which determine the logging level of rejected and requested requests, respectively. If this check happens too early, then $LIBS includes -lwrap, which causes many subsequent tests that need to run a compiled program to fail with missing symbols. * m4/macros/header_templates.m4: fix typo in template for readdirplus. * configure.in: check for (OpenBSD 3.3) * minor new port: i386-unknown-netbsdelf1.6.1. * configure.in: save state before system-specific tests are run. * m4/macros/check_gnu_getopt.m4: do NOT abort ./configure just because the compiled test program failed to run. 2003-08-01 Ion Badulescu * NEWS, README.autofs: updated * libamu/mount_fs.c (mount_fs): added support for the space hack * doc/am-utils.texi: mention than UFS/XFS/EFS/CacheFS filesystems are not expired by default; correct and expand the section describing the program filesystem * conf/autofs/autofs_solaris_v2_v3.h (AUTOFS_*_FS_FLAGS): add FS_ON_AUTOFS for supported filesystems * conf/autofs/autofs_solaris_v2_v3.c (autofs_mount_fs): call mf->mount_fs() (autofs_umount_fs): call mf->umount_fs() * conf/autofs/autofs_solaris_v1.h (autofs_strdup_space_hack): add prototype for malloc() (AUTOFS_*_FS_FLAGS): lose the FS_MKMNT flags, add FS_ON_AUTOFS for supported filesystems * conf/autofs/autofs_solaris_v1.c (autofs_mount_fs): add support for the space hack; call mf->mount_fs() (autofs_umount_fs): add support for the space hack; call mf->umount_fs() (autofs_mount_succeeded): add support for the space hack * conf/autofs/autofs_linux.h: lose the FS_MKMNT flags, add FS_ON_AUTOFS for supported filesystems * conf/autofs/autofs_linux.c (AUTOFS_MAX_VERSION): define to AUTOFS_MAX_PROTO_VERSION instead of hardcoding to 4 (autofs_mounted): host mounts are now supported on all autofs versions, remove the hack to turn it off on v3 (autofs_mount_fs): call mf->mount_fs(), create/remove mountpoints as needed (autofs_umount_fs): call mf->umount_fs(), remove mountpoints on success (ALL): use '#if AUTOFS_MAX_VERSION >= 4' instead of '#ifdef autofs_ptype_expire_multi' * amd/map.c (mount_node): autofs_mount_fs() now calls mf->mount_fs() internally (unmount_node): autofs_umount_fs() now calls mf->umount_fs() internally * amd/autil.c (am_mounted): minor cleanup * amd/amfs_program.c (amfs_program_ops): added FS_MKMNT to nfs_fs_flags * amd/amfs_generic.c (amfs_lookup_one_mntfs): use the FS_ON_AUTOFS flag instead of hardcoding filesystem types (amfs_bgmount): better mount_type logging * amd/amd.h (FS_ON_AUTOFS): new flag which tells the code that this filesystem can be mounted directly onto an autofs mountpoint 2003-07-31 Ion Badulescu * amd/amfs_nfsl.c (amfs_nfsl_umount): fix copy&paste error (was calling amfs_link_ops.umount_fs() for NFS filesystems) (amfs_nfsl_umounted): remove rmdirs() hack, it is now handled properly elsewhere (amfs_nfsl_ffserver): remove FS_MKMNT from mf_fsflags if we're using link (not NFS) 2003-07-31 Rainer Orth * README.autofs: Correct IRIX spelling. AutoFS support exists only on IRIX 6. Update IRIX 6 status. Allow AutoFS V1 support to compile on IRIX 6. * conf/autofs/autofs_solaris_v1.c (autofs_mount_1_req): Add SVCXPRT * arg. Remove superfluous \n from dlog messages. (autofs_unmount_1_req): Likewise. Switch to get_exported_ap. (autofs_program_1): Invoke handlers with additional transp arg. * conf/autofs/autofs_solaris_v1.h: Use autofs_args_t to define autofs_fh_t, struct auto_args doesn't exist on IRIX 6. * conf/mount/mount_irix6.c (mount_irix) [HAVE_FS_AUTOFS]: Support AutoFS mounts. [HAVE_FS_LOFS]: Likewise for lofs mounts. * conf/nfs_prot/nfs_prot_irix6.h (AUTOFS_CONFTYPE): Define. Don't disable AutoFS support any more. * conf/transp/transp_sockets.c [HAVE_FS_AUTOFS && AUTOFS_PROG] (register_autofs_service): Define autofs_xprt. * m4/macros/check_autofs_style.m4 (AMU_CHECK_AUTOFS_STYLE): Update Solaris 8+ comment to mention AutoFS V4. (irix6*): Enable AutoFS V1 support on IRIX 6. 2003-07-30 Erez Zadok * NEWS, doc/am-utils.texi, scripts/amd.conf.5: revised explanation of autofs_use_lofs. 2003-07-30 Rainer Orth * amd/ops_efs.c (efs_mount): Replace on_autofs arg with MFF_ON_AUTOFS flag. (efs_umount): Likewise. 2003-07-30 Erez Zadok * conf/umount/umount_bsd44.c (umount_fs): convert to new way of unmounting which takes autofs into account. 2003-07-30 Ion Badulescu * ALL: renamed MFF_AUTOFS to MFF_IS_AUTOFS; removed mf_real_mount hack; pass a new on_autofs argument to mount/umount function, based on the MFF_ON_AUTOFS mntfs flag * NEWS, README.autofs: updated * scripts/amd.conf.5: document new option autofs_use_lofs * scripts/amd.conf-sample (autofs_use_lofs): document new option * m4/macros/check_autofs_style.m4 (am_utils_link_files): symlink the autofs header as amu_autofs_prot.h instead of slurping it into aux_conf.h * libamu/mount_fs.c (mount_fs): removed old stub, renamed mount_fs2 to mount_fs, added new argument on_autofs * doc/am-utils.texi (Direct Automount Filesystem): document problems with nfs direct mounts on modern kernels, document good autofs support for direct mounts on Solaris (autofs_use_lofs Parameter): document this new option (browsable_dirs Parameter): note that mount storms are avoided when using autofs * conf/umount/umount_bsd44.c (umount_fs): removed old stub, renamed umount_fs2 to umount_fs * conf/umount/umount_osf.c (umount_fs): removed old stub, renamed umount_fs2 to umount_fs, added new argument on_autofs * conf/umount/umount_default.c (umount_fs): ditto as above; return an error on ENOENT instead of faking success * conf/autofs/autofs_solaris_v2_v3.c (autofs_lookup_2_req): much simplified, now only consults the map for existance of the key and returns success if key is found (autofs_mount_2_req): request symlinks if CFM_AUTOFS_USE_LOFS is not on; (autofs_mount_2_free): implemented (autofs_unmount_2_req): use get_exported_ap() instead of referencing export_ap directly (autofs_mount_succeeded): remove code for replying to lookup requests, now only mount requests can end up here (autofs_mount_failed): ditto * conf/autofs/autofs_solaris_v1.h (AUTOFS_HOST_FS_FLAGS): removed FS_AUTOFS (AUTOFS_DIRECT_FS_FLAGS): added FS_DIRECTORY * conf/autofs/autofs_solaris_v2_v3.h (AUTOFS_HOST_FS_FLAGS): removed FS_AUTOFS (AUTOFS_DIRECT_FS_FLAGS): added FS_DIRECTORY (AUTOFS_LINK_FS_FLAGS): added FS_MBACKGROUND * conf/autofs/autofs_linux.c (autofs_bind_umount): new function, factored out of autofs_umount_fs() (autofs_mount_fs): renamed from autofs_link_mount() and expanded to deal with filesystems mounted indirectly (via lofs/bind mounts) on autofs and to observe the new CFM_AUTOFS_USE_LOFS flag (autofs_umount_fs): ditto, from autofs_link_umount() * conf/autofs/autofs_solaris_v1.c (autofs_mount_fs): ditto * (autofs_umount_fs): ditto * conf/autofs/autofs_solaris_v2_v3.c (autofs_mount_fs): ditto * (autofs_umount_fs): ditto * amd/opts.c: made fs_static static * amd/ops_nfs.c: made nfs_init, nfs_match, nfs_mount, nfs_umount and nfs_umounted static (mount_nfs_fh): removed unnecessary arguments * amd/ops_cachefs.c (cachefs_ops): use amfs_generic_find_srvr for the ffserver method, because using NULL causes problems * amd/ops_cdfs.c (cdfs_ops): ditto * amd/ops_efs.c (efs_ops): ditto * amd/ops_lofs.c (lofs_ops): ditto * amd/ops_pcfs.c (pcfs_ops): ditto * amd/ops_ufs.c (ufs_ops): ditto * amd/ops_xfs.c (xfs_ops): ditto * amd/nfs_subr.c (fh_to_mp3, fh_to_mp, mp_to_fh): moved here from map.c * amd/nfs_start.c: use get_exported_ap() instead of referencing exported_ap directly * amd/mntfs.c (locate_mntfs): new function, factored out of find_mntfs (locate_mntfs): special-case FS_DIRECT filesystems: for direct mounts we will have two filesystems mounted on the same m/p (realloc_mntfs): removed the old EZK hack for failovers * amd/map.c (get_exported_ap): new function that returns an exported_ap member by its index (root_node,exported_ap,exported_ap_size,first_free_map,last_used_map): made static (fh_to_mp3, fh_to_mp, mp_to_fh): moved to nfs_subr.c (get_root_ap): removed unused second argument (unmount_mp): moved the mk_fattr(NFDIR) here from umount_exported to catch more cases (mount_node): call autofs_mount_fs after ops->mount_fs for autofs nodes (unmount_node): call autofs_umount_fs before ops->umount_fs for autofs nodes * amd/conf.c: new global option "autofs_use_lofs", takes yes/no values * amd/autil.c (amfs_mount): take an extra argument (mf) (amfs_mount): call autofs_compute_mount_flags() for mounts directly on autofs m/p (am_unmounted): document and avoid the race between am_umounted() at shutdown time and amfs_cont() * amd/amfs_union.c (amfs_union_mounted): use get_exported_ap() instead of referencing internal map variables directly * amd/amq_subr.c (amqproc_export_1_svc): ditto * amd/amfs_toplvl.c (amfs_toplvl_ops): removed FS_AUTOFS from nfs_fs_flags (amfs_toplvl_mount): pass extra argument (mf) to amfs_mount() (amfs_toplvl_umount): refuse to attempt the unmount if the mountpoint is not a directory * amd/amfs_nfsx.c (amfs_nfsx_init): propagate the MFF_ON_AUTOFS flag into the nfs f/s at the bottom of the stack * amd/amfs_nfsl.c: call nfs and link member functions through their respective am_ops structures, not directly * amd/amfs_linkx.c (amfs_linkx_umount): new static stub * amd/amfs_link.c: made amfs_link_mount() and amfs_link_umount() static functions (amfs_link_mount): removed call to autofs_link_mount() (amfs_link_umount): removed call to autofs_link_umount() * amd/amfs_host.c (amfs_host_ops): removed FS_AUTOFS from nfs_fs_flags (do_mount): removed superfluous function arguments * amd/amfs_direct.c (amfs_direct_ops): removed FS_AUTOFS from nfs_fs_flags * amd/amfs_auto.c (amfs_auto_ops): removed FS_AUTOFS from nfs_fs_flags (amfs_auto_mount): pass extra argument (mf) to amfs_mount * amd/amd.h (CFM_AUTOFS_USE_LOFS): new flag, tells amd whether to use lofs-mounts or symlinks when mounting on autofs (CFM_DEFAULT_FLAGS): added CFM_AUTOFS_USE_LOFS (VLOOK_LOOKUP): new flag, will merely check if a key exists (MFF_IS_AUTOFS): renamed from MFF_AUTOFS (MFF_ON_AUTOFS): new flag, tells amd if a f/s is mounted directly on an autofs m/p, or indirectly via a lofs mount/symlink (fh_to_mp2): macro expanded throughout the code and removed (mntfs): removed mf_real_mount hack (autofs_mount_fs): renamed from autofs_link_mount (autofs_umount_fs): renamed from autofs_link_umount (mount_lofs): exposed various other cleanups, functions/variables made static and removed * aux_conf.h.in: removed @am_utils_autofs_style@, it is now included directly as amu_autofs_prot.h 2003-07-24 Erez Zadok * doc/am-utils.texi, scripts/amd.conf.5: document that use_tcpwrappers is "yes" by default. * amd/amd.c (init_global_options): set default global options. * amd/amd.h (CFM_DEFAULT_FLAGS): define default options which are always on (plock and use_tcpwrappers). * scripts/amd.conf-sample: reorganize values per option so default one is listed first. 2003-07-23 Erez Zadok * tasks: trim old stuff. Discuss new parser. * amd/conf.c (set_conf_kv): initialize the very first map in conf file from global defaults. Bug fix which was introduced after conf.c code restructuring. 2003-07-18 Erez Zadok * m4/macros/header_templates.m4: template for HAVE_EXTERN_HOSTS_CTL. * include/am_defs.h: define extern for hosts_ctl() if needed. * configure.in (AMU_CHECK_EXTERNS): check for extern definition for libwrap's hosts_ctl() (FreeBSD 5.0 doesn't have it). * m4/macros/check_extern.m4: include tcpd.h if it and libwrap exist. 2003-07-18 Erez Zadok * hlfsd/hlfsd.h: redundant extern for mboxfile removed. * amd/amq_svc.c (amq_program_1): only check for tcpwrappers if amd.conf global option use_tcpwrappers=yes. * scripts/amd.conf.5, scripts/amd.conf-sample (use_tcpwrappers), doc/am-utils.texi (use_tcpwrappers Parameter): document new amd.conf global option. * amd/conf.c (gopt_use_tcpwrappers): define a new amd.conf global option called use_tcpwrappers ("no" by default). * amd/amq_svc.c (amqsvc_is_client_allowed): include tcpd/libwrap code only if both libwrap and tcpd.h exist. (amq_program_1): log warning when an Amq service client is denied, and a debug message when a client is allowed. * amd/amd.h (CFM_USE_TCPWRAPPERS): define [global] amd.conf flag. (AMD_SERVICE_NAME): define AMD_SERVICE_NAME for tcpd/libwrap. * include/am_defs.h: include tcpd.h if available and libwrap available. * configure.in: check for tcpd.h. 2003-07-18 Erez Zadok * scripts/expn.1, amd/amd.8 amq/amq.8, fixmount/fixmount.8, hlfsd/hlfsd.8, scripts/expn.1: remove ".PD 0" nroff command because it removes useful spaces in between paragraphs. Based on smaller patch from Philippe Troin . 2003-07-17 Philippe Troin * amq/amq.8: Document the libwrap/amd behavior. * amd/amq_svc.c (libwrap_check_client): New function to validate an amq connection with libwrap. (amq_program_1): Call libwrap_check_client() and close the connection if libwrap does not allow it. * configure.in: Check for the tcp wrappers library. 2003-07-17 Erez Zadok * amd/amq_subr.c (amqproc_mnttree_1_svc, amqproc_stats_1_svc, amqproc_getmntfs_1_svc, xdr_amq_mount_tree), hlfsd/hlfsd.c (hlfsd_init): cast pointers to void* before casting them to another type, to avoid gcc-3.3 -Wall warnings. * fsinfo/*.[hc]: rename fsinfo function log() to fsi_log(), to avoid conflict with builtin function in gcc-3.3. 2003-07-17 Rainer Orth * scripts/amd.conf-sample: Remove obsolete comment. 2003-07-16 Erez Zadok * amd/info_file.c (read_line): check for errors from fgets(). Although rare, they can occur upon disk or network failures. Patch from Nick Williams . 2003-07-16 Rainer Orth * BUGS (Solaris 8): Update patch revisions, mention old autofs patches, fix filenames and rpcgen command. 2003-07-15 Erez Zadok * doc/am-utils.texi (map_defaults Parameter): document new map_defaults option. * scripts/amd.conf.5: document new map_defaults option. * scripts/amd.conf-sample (map_type): show examples of new map_defaults option. * amd/mapc.c (mapc_create): initialize mnt_map->cfm field to NULL. * amd/get_args.c (get_args): call process_all_regular_maps(). * amd/conf.c: keep head and tail of cfm list. (init_cf_map): reworked reset_cf_map. This one doesn't reset a globaly reused cfm, but rather just inherits [global] options. (set_conf_kv): just store global/map options without actually creating any mnt_map's. Essentially, we now parse the whole amd.conf file, and then try to process the maps one at a time. (process_one_regular_map): new function to process one map, just renamed from process_regular_map. (process_all_regular_maps): new exported function to process all maps. No need for hacky process_last_map(). (find_cf_map): new exported function to return a cf_map_t given a map's mount point (e.g., /home or /net). * amd/amfs_generic.c (amfs_parse_defaults): find if amd.conf specificed a map_defaults for a given map. If so, use that instead of the /defaults that came from the map itself. Also restructure code a bit so it's not one huge long "if" statement. HACK ALERT: there's no easy way to find out what the map mount point is at this point, so I am forced to initialize the mnt_map->cfm field here for the first time, upon the very first search for a /defaults entry in this map. This initialization is much better done in mapc_create(), but it's impossible to do that there with the current code structure. * amd/amd.h: struct cf_map becomes linked list. struct mnt_map includes pointer to cf_map_t, amd.conf defaults and options for a given map. extern cleanups. 2003-07-15 Erez Zadok * amd/info_hesiod.c (hesiod_search): It's not possible to have a key such as ".access" in a hesiod map as that would imply a null node in the DNS tree. So a lookup for such a key must clearly fail. With the current info_hesiod.c it does (after calling hes{,iod}_resolve) but returns an error that confuses some programs - eg. apache. This patch shortcuts the process and just returns ENOENT for any key starting with ".". Patch submitted by by Mark Davies . * include/am_utils.h (CALLOC): redefine macro to use xzalloc, not fsinfo's own xcalloc. * fsinfo/fsi_util.c (xcalloc): remove redundant function. 2003-07-14 Erez Zadok * include/am_compat.h (MNTTAB_OPT_XLATECOOKIE): The NetBSD xlatecookie NFS option doesn't work as MNTTAB_OPT_XLATECOOKIE is never defined. Define it as needed. Patch from Mark Davies . 2003-07-14 Ion Badulescu * BUGS (Note): document the Solaris 8 bug (the upgrade to autofs v4 without updating all the header files) 2003-07-13 Ion Badulescu * NEWS, tasks: updated * amd/amfs_generic.c (free_continuation): free _all_ mntfs's in the am_mfarray, unconditionally (amfs_bgmount): call free_mntfs when we're done with a mntfs, call dup_mntfs when starting processing of a new one; make sure we always go through 'goto failed' for a failed mntfs; use the error code returned by autofs_get_fh() * conf/autofs/autofs_linux.c (autofs_get_fh): return proper error codes in case of problems 2003-07-13 Erez Zadok * BUGS: Document buggy behavior of Solaris /usr/ccs/bin/lex. In short, use flex. 2003-07-13 Erez Zadok * fsinfo/fsi_lex.l, amd/conf_tok.l: allocate more output slots so lex scanners don't run out of mem. 2003-07-13 Ion Badulescu * amd/amfs_generic.c (amfs_lookup_mntfs): ditto as below for the special provision * amd/mntfs.c (find_mntfs): compare the filesystem type (i.e. mf_ops) in addition to mf_info; the special provision mentioned below is really for any filesystem already mounted on our mount point, not just for inherited filesystems 2003-07-13 Erez Zadok * doc/Makefile.am (install-html): build per-chapter HTML manual, as well as manual in one big HTML file. * doc/am-utils.texi: Minor corrections. Ack Ion's autofs work. Ack maintainers. New section on How to get additionl info, including the Amd book. Correct stale URLs and Emails. * amd/amd.8, amq/amq.8, amq/pawd.1, fixmount/fixmount.8, fsinfo/fsinfo.8, hlfsd/hlfsd.8, mk-amd-map/mk-amd-map.8, scripts/amd.conf.5, scripts/automount2amd.8, wire-test/wire-test.8: include references to info pages, proper authors, am-utils Web page, and amd book. 2003-07-13 Ion Badulescu * amd/mntfs.c (find_mntfs): re-add the check for mf_info, but with a special provision for inherited filesystems. This unbreaks the handling of parallel mounts * amd/amfs_generic.c (amfs_lookup_mntfs): for restarted filesystems, there can be no alternative mntfs to try to mount 2003-07-13 Erez Zadok * amd/amd.8: reference am-utils info page in amd man page, as per Thomas Klausner . * fsinfo/fsinfo.h, fsinfo/fsinfo.c (fsi_get_args): don't use yywrap() if it doesn't exist. * amd/conf_parse.y, amd/conf_tok.l, fsinfo/fsi_gram.y, fsinfo/fsi_lex.l: fixes to support old flex 2.5.4, as well as the newer flex 2.5.31 (beta development). These include resolving conflicts with yylineno, unput() vs. nounput(), etc. 2003-07-13 Ion Badulescu * amd/amfs_generic.c (amfs_cont): check for (am_error > 0) before calling assign_error_mntfs() (amfs_generic_mount_child): ditto * amd/autil.c (assign_error_mntfs): move the check for (am_error > 0) up into the caller, it's less confusing that way * tasks: some updates * conf/transp/transp_tli.c (check_pmap_up): new function which detects if the remote portmapper is functional (amu_clnt_create_best_version): removed (get_nfs_version): use a much simplified version of the old amu_clnt_create_best_version(), based on clnt_create_vers() and its _timed() counterpart * conf/transp/transp_sockets.c (check_pmap_up): new function which detects if the remote portmapper is functional (pmap_ping): deleted (get_nfs_version): removed calls to pmap_ping, already done by caller * amd/srvr_nfs.c: call check_pmap_up() before continuing with get_nfs_version() * amd/amfs_generic.c: updated a couple of log messages * configure.in: detect clnt_create_vers and clnt_create_vers_timed; changed LIBTOOL versioning to 3:0:0 2003-07-12 Ion Badulescu * conf/autofs/autofs_linux.h (AUTOFS_HOST_FS_FLAGS): removed FS_AUTOFS because the host mount cannot be a top level mount (AUTOFS_DIRECT_FS_FLAGS): removed FS_AUTOFS because Linux autofs doesn't support direct mounts 2003-07-12 Erez Zadok * amd/conf_parse.y, amd/conf_tok.l: pretty comments on # cpp macros. 2003-07-10 Ion Badulescu * include/am_utils.h (dlog): improved version for gcc, using vararg macros * amd/rpc_fwd.c (fwd_packet): unused variable when compiling without debugging 2003-07-10 Erez Zadok * include/am_utils.h (dlog): change the #define of non-debugging dlog to "nothing" so that all that'll be left behind is a list of args in parenthesis (arg,arg,...). GCC and other native C compilers seem OK with it, even if it doesn't optimize away the whole debugging line. * ltmain.sh: was from libtool 1.4.2. updated to libtool 1.4.3, the latest on RH9 systems (but is not the latest libtool available). Stay with stable version in preparation for 6.1 release. * config.{guess,sub}, doc/texinfo.tex: update to latest off of ftp.gnu.org. 2003-07-09 Erez Zadok * amd/amfs_inherit.c (amfs_inherit_inherit): don't use // C++ style comments: breaks non-C++ compilers (like AIX xlC 6) 2003-07-02 Ion Badulescu * doc/am-utils.texi (opts Option): document ignore_portmapper option * conf/transp/transp_sockets.c (get_nfs_version): better protocol/version cycling while probing remote server; better log messages * amd/srvr_nfs.c (start_ping): improved log message (find_nfs_srvr): always use requested nfs_version/nfs_proto; make sure we have a valid NFS port; start the server as "valid, down" if the remote portmapper tells us the NFS service is not running; implement the "ignore_portmapper" pseudo-mount option * amd/rpc_fwd.c (fwd_packet): better debug messages * amd/ops_nfs.c (got_nfs_fh): log a messages if a root fh is denied; call wakeup even if mountd call fails * amd/amq_subr.c (xdr_amq_mount_info_qelem): use FSRV_ISUP/ISDOWN instead of checking the flags directly * amd/srvr_amfs_auto.c (free_srvr): ditto * amd/amfs_generic.c (amfs_bgmount): refined some error/debug messages * amd/amd.h (FSRV_ERROR): new macro (FSRV_ISDOWN, FSRV_ISUP): a server that doesn't exist (i.e. it's a local filesystem) is always up 2003-06-30 Erez Zadok * amd/autil.c (am_mounted): set AMF_NOTIMEOUT if either unmount or umount options are present. * doc/am-utils.texi (Program Filesystem): document alias options to unmount:=, umount:=. * amd/opts.c (expansions): initialize opt_umount. (to_free): initialize opt_umount. * amd/amfs_program.c (amfs_program_match): ensure that only one of umount:= or unmount:= options are specified, but that at least one of them is listed. * amd/amd.h: support unmount:=XXX as well as umount:=XXX (too annoying in type:program, when one forgets the 'n' in "unmount"). They are two separate fields, so we can catch mistakes when someone tries to define both options. * doc/am-utils.texi (Program Filesystem): explain that both mount and unmount options must be specified. Correct example to show both. 2003-06-25 Erez Zadok * XXX: beginning of new amd.conf option map_defaults: will parse the option and set remember it in the right places. Need to document this and actually hook it up with the rest of the code. Any volunteers? :-) * scripts/amd.conf-sample (map_defaults): example of map_defaults amd.conf option. * amd/conf.c (reset_cf_map): initialize global and per-mount map_defaults. (gopt_map_defaults): parse global map_defaults. (process_regular_option,ropt_map_defaults): parse per-map map_defaults amd.conf option. * amd/amd.h: a place to store global and per-mount map_defaults. * BUGS: more notes about AIX 5.2 problems and how to overcome them. 2003-06-10 Erez Zadok * doc/Makefile.am: force version.texi to be rebuilt regardless of maintainer mode. Silly Automake will not build version.texi if maintainer mode is off (this is hardcoded into the automake perl script!). According to the Automake maintainers, users should always build in CVS trees with maintainer-mode on; but what if I don't want to?! I don't want to distribute Makefiles with maintained rules in them to users. The Automake maintainers also say that "make dist" will rebuild version.texi no matter what. I find that not to be the case. It failed to run a "make" before "make dist" because version.texi doesn't exist! Chicken and Egg situation. So, until Automake deals with version.texi in a more flexible and friendly manner, I adapted a rule to build version.texi and inserted it in this Makefile.am. 2003-06-09 Erez Zadok * mk-amd-map/mk-amd-map.c (main): open temp db file using O_EXCL, next best thing to using mkstemp(). Patch from Hendrik Scholz . 2003-05-08 Ion Badulescu * libamu/mount_fs.c (compute_automounter_mount_flags): use MNT2_GEN_OPT_AUTOMNTFS if available; minor cleanup * m4/macros/header_templates.m4: added template for MNT2_GEN_OPT_AUTOMOUNTED 2003-05-01 Ion Badulescu * amd/ops_xfs.c (mount_xfs): compile fix (s/genflags/flags/) 2003-04-23 Erez Zadok * conf/transp/transp_sockets.c (create_amq_service): minor cpp directive indentation and commenting. 2003-04-22 Ion Badulescu * conf/transp/transp_sockets.c (create_amq_service): Ugly *BSD fix for an RPC library DoS issue (original patch from Martin Blapp, massaged into something more digestable by me) 2003-04-14 Ion Badulescu * conf/autofs/autofs_solaris_v2_v3.c: removed autofs_free_data(), left over from the recent cleanup 2003-04-13 Erez Zadok * doc/Makefile.am (DVIPS): use proper options for dvips. * doc/am-utils.texi (opts Option): document new 'unmount' option, and better explain the 'nounmount' option. Also some misc options for better generation of html manual. * doc/Makefile.am (install-html): support newer texi2html 4.0 options, as older options were renamed or changed behavior. * amd/autil.c (am_mounted): support new 'unmount' option, to allow all file system mounts to timeout and thus expire. This option is useful for removable local media such as CD-ROMs, USB drives, etc. so they can expire when not in use, and get unmounted (such drives can get work out when they keep spinning). Patch from Christos Zoulas (originally from Koji Imada). 2003-04-10 Erez Zadok * configure.in: use AM_MAINTAINER_MODE, so maintainer-only rules do not get added to Makefiles by default (they are confusing to users who don't have autotools installed). 2003-04-09 Ion Badulescu * amd/mntfs.c (find_mntfs): revert the "change of philosophy" (see the 2001-05-23 entry) back to the 6.0 code 2003-04-04 Erez Zadok * libamu/xutil.c (switch_to_logfile): don't try to print logfile if it is null (strlen core dump on solaris). Bug report from John P. Rouillard . 2003-03-31 Erez Zadok * fsinfo/fsinfo.8: typo co-ordinate -> coordinate. Typo report from Perry E. Metzger" . 2003-03-25 Erez Zadok * include/am_defs.h: Don't include malloc.h if stdlib.h exists, because modern systems (e.g., BSD) complain if you use malloc.h instead of stdlib.h. Let's hope there are no systems out there that need both. 2003-03-20 Erez Zadok * minor new port: sparc64-unknown-linux-suse7.3. 2003-03-20 Erez Zadok * minor new port: i386-unknown-freebsd5.0. * configure.in: detect nfsclient/nfsargs.h. * conf/nfs_prot/nfs_prot_freebsd3.h: include , needed in FreeBSD 5.0. 2003-03-15 Erez Zadok * amd/amd.8, amd/amd.8, fixmount/fixmount.8, hlfsd/hlfsd.8, scripts/amd.conf.5, scripts/expn.1: minor spell checking and extraneous space elimination. 2003-03-07 Ion Badulescu * conf/autofs/autofs_linux.c (autofs_get_fh): don't leak file descriptors if limit exceeded (autofs_mounted): call autofs_get_mp(); init am_autofs_ttl (autofs_release_fh): release pending_mounts and pending_umounts queues (autofs_timeout_mp): update am_autofs_ttl instead of am_ttl * amd/mntfs.c (init_mntfs): delete initialization of removed mf_autofs_fh (uninit_mntfs): delete call to autofs_release_fh() * amd/map.c (init_map): init autofs_fh to 0, delete initialization of removed autofs_data (free_map): release autofs_fh after unmounting map; delete call to autofs_free_data() (umount_exported): call autofs_release_mp() prior to unmounting autofs f/s (unmount_mp): ditto (free_map_if_success): call autofs_get_mp() if unmounting fails (timeout_mp): use the dedicated am_autofs_ttl timeout for f/s-wide timeouts instead of the per-mountpoint am_ttl * amd/autil.c (am_unmounted): release autofs_fh after unmounting autofs f/s * amd/amfs_generic.c (amfs_cont): release autofs_fh if mounting autofs f/s fails; (amfs_bgmount): ditto * amd/amd.h: moved autofs_fh from mntfs to am_node, since it's more related to the mount point than to the f/s mounted; added am_autofs_ttl to am_node, for running expirations on entire filesystems * conf/autofs/autofs_*: autofs_get_fh() returns int instead of autofs_fh_t *; autofs_release_fh() now takes an am_node * parameter instead of autofs_fh_t *, in an effort to not deal with autofs-specific data structures outside autofs code; new methods autofs_get_mp() and autofs_release_mp(), which acquire/release autofs resources to allow clean unmount attempts; nuke autofs_data_t, never used * amd/amd.h: prototypes for new and changed autofs functions 2003-03-07 Ion Badulescu * amd/nfs_subr.c (do_readlink): eliminate third argument, never used (nfsproc_getattr_2_svc): reorganize the code a bit * amd/map.c (mk_fattr): take a nfsfattr * argument instead of an am_node * argument * amd/amd.h: changed prototype for mk_fattr() * amd/autil.c (am_unmounted): when remounting, use the parent node's lookup_child() and mount_child() operations, not the generic ones * amd/amfs_generic.c (amfs_cont): minor code optimization 2003-03-06 Ion Badulescu * amd/amfs_auto.c: lots of renames and code moving: amfs_auto_match() -> amfs_generic_match(), moved to generic; amfs_auto_mkcacheref() -> amfs_mkcacheref(), moved to autil.c; amfs_auto_mounted() -> amfs_generic_mounted(), moved to generic; amfs_auto_umount() -> amfs_generic_umount(), moved to generic; free_continuation(): moved to generic, made static; assign_error_mntfs(): moved to autil.c; amfs_auto_cont() -> amfs_cont(), moved to generic, made static; amfs_auto_retry() -> amfs_retry(), moved to generic, made static; try_mount() + mount_node() -> mount_node(), moved to map.c amfs_auto_bgmount() -> amfs_bgmount(), moved to generic; amfs_parse_defaults(): moved to generic; amfs_auto_lookup_node() -> amfs_lookup_node(), moved to generic; amfs_auto_lookup_one_mntfs() -> amfs_lookup_one_mntfs(), in generic; amfs_auto_lookup_mntfs() -> amfs_lookup_mntfs(), moved to generic; amfs_auto_mount_child() -> amfs_generic_mount_child(), in generic; amfs_auto_lookup_child() -> amfs_generic_lookup_child(), in generic; next_nonerror_node(): moved to autil.c; amfs_auto_readdir() -> amfs_generic_readdir(), moved to readdir; amfs_auto_readdir_browsable() -> amfs_readdir_browsable(), in readdir; * amd/amfs_toplvl.c: mount_amfs_toplvl() renamed to amfs_mount() and moved to autil.c * amd/readdir.c, amd/amfs_generic.c: new files with stuff ripped out of amd/amfs_auto.c * amd/amd.h: struct continuation moved to generic.c; prototypes for the renamed functions; NumChild renamed to NumChildren * amd/map.c: collaped unmount_node_wrap() and unmount_node() into the latter * amd/mapc.c: key_already_in_chain(): moved to readdir.c; make_entry_chain(): moved to readdir.c; * amd/srvr_amfs_auto.c: find_amfs_auto_srvr() renamed to amfs_generic_find_srvr() * amd/amfs_*.c: adjustments for the renames above * amd/ops_*.c: low-level filesystems don't need a find_server() method * amd/Makefile.am: added amfs_generic.c and readdir.c * doc/am-utils.texi: minor clarification for auto maps 2003-03-06 Ion Badulescu * amd/amd.h: moved lots and lots of amd-only stuff here, from include/am_utils.h; changed task_fun, cb_fun and fwd_fun typedefs to be function typedefs, not pointer to function typedefs * include/am_utils.h: see above * amd/ops_nfs.c, amd/rpc_fwd.c, amd/sched.c: adjustments for function typedef changes 2003-03-05 Erez Zadok * BUGS: record IBM's patch number for the AIX 5.2 NFS over IPv6 bug. 2003-02-02 Erez Zadok * NEWS: minor new port: ia64-unknown-linux-rh2.1AS 2003-01-31 Ion Badulescu * m4/macros/os_cflags.m4: rhapsody and darwin are the same * amd/autil.c (mount_node): vastly simplified, just a wrapper now * amd/amfs_inherit.c (amfs_inherit_mount): remove the am_mounted() hack, we now do it properly in the generic code * amd/amfs_auto.c (amfs_auto_bgmount): get the autofs_fh _before_ forking the child; set and reset MFF_MOUNTING here, not in mount_node(), because the latter might be running in child context; call am_mounted() after a successful foreground mount 2003-01-29 Ion Badulescu * configure.in: new flag --with[out]-ndbm; don't pull in libldap if building --without-ldap; look for the gdbm/ndbm.h header; make explicit the dependency between the ndbm headers and libraries; define NEW_DBM_H as the ndbm header that should be used * include/am_defs.h: simply include NEW_DBM_H for ndbm stuff, instead of trying to second-guess configure * m4/macros/header_templates.m4: new template for NEW_DBM_H * m4/macros/check_map_funcs.m4: (ac_upcase_map_name): use the third argument correctly * ltmain.sh: working version from libtool-1.4.2-7 * buildall: print the entire configure command, including extra arguments; pass each of the extra arguments separately, not commingled into one 2003-01-28 Ion Badulescu * include/am_utils.h (DEBUG_MNTTAB): define outside of #ifdef DEBUG; it is not used without DEBUG, but it is referenced at compile time. Bug report from John Kilburg . (D_ALL): don't include D_XDRTRACE, too verbose and normally unnecessary 2003-01-28 Erez Zadok * ltmain.sh, config.guess, config.sub, doc/texinfo.tex: updates from latest official GNU versions. 2003-01-25 Erez Zadok * BUGS (Note): document AIX-5.1 NFS-client side bug (hangs in vmount). 2003-01-25 Ion Badulescu * Released beta version 6.1b2 2003-01-24 Ion Badulescu * amd/autil.c (am_unmounted): reset MFF_MKMNT from mf_flags when calling rmdirs() on mountpoint * amd/amfs_auto.c (amfs_auto_bgmount): ditto * amd/amfs_nfsl.c (amfs_nfsl_umounted): ditto * doc/am-utils.texi (opts Option): "sftlookup" -> "softlookup" * NEWS: "sftlookup" -> "softlookup" * amd/ops_nfs.c (nfs_mount): "sftlookup" -> "softlookup", also check for "nosoftlookup" in combination with "soft" 2003-01-23 Ion Badulescu * m4/macros/check_nfs_fh_dref.m4: darwin/rhapsody is another freebsd22 derivative * NEWS: updated for Darwin changes * .cvsignore: added A.i386-apple-darwin6.0 * m4/macros/os_cflags.m4: add -D_P1003_1B_VISIBLE to cflags for Darwin 2003-01-23 Erez Zadok * conf/mount/mount_aix.c (mount_aix3): clean back this file from all the debugging cruft that is no longer needed (and really was never needed in the first place). 2003-01-10 Erez Zadok * scripts/test-amd.{misc,conf}: simple amd.conf and amd.misc (map) files for testing basic amd functionality such as whether it can mount its own mount NFS points. 2002-12-28 Ion Badulescu * amd/srvr_nfs.c (start_nfs_pings): don't set FSF_PINGING if pings are disabled * libamu/xdr_func.c (xdr_ftype): use a local enum_t variable instead of casting the pointer to (enum_t *) (xdr_mountstat3): ditto (xdr_nfsstat): ditto * libamu/misc_rpc.c (make_rpc_packet): fix make_rpc_packet() on 64-bit big-endian platforms, bug report from Bill Fenner * configure.in: increase library patchlevel * libamu/xutil.c (amu_release_controlling_tty): close and reopen file descriptors 0,1,2 before calling setsid() 2002-12-27 Erez Zadok * updated copyright year to 2003 on all files 2002-12-10 Erez Zadok * rename "aux/" subdir into "m4/" so as to avoid problems with MS-DOS systems (where "AUX" is a reserved name). This required fixing numerous files. 2002-12-10 Erez Zadok * configure.in: don't check for bad hasmntopt() function if hasmntopt() doesn't exist on the system, because we will replace it with our own version anyway. * conf/transp/transp_sockets.c (amu_get_myaddress): use "%lx" in dlog because htonl() returns a u_long. 2002-12-10 Erez Zadok * include/am_defs.h: use system's hasmntopt() only if it is found and it is not buggy. * libamu/hasmntopt.c (nextmntopt): isspace() takes an int, not a char. * amd/am_ops.c, amd/amfs_auto.c, amd/autil.c, amd/nfs_subr.c, amd/ops_cdfs.c, amd/ops_nfs.c, amd/srvr_nfs.c, libamu/hasmntopt.c, libamu/mount_fs.c, libamu/mtab.c: rename all uses of hasmntopt() to amu_hasmntopt(). Don't use hasmntopt() directly any more! * aux/macros/func_bad_hasmntopt.m4: new M4 macro to test for a bad hasmntopt() function, which incorrectly finds the option "soft" in a string "hard,softlookup,ro". * libamu/hasmntopt.c (hasmntopt): use 'const' on two args to hasmntopt(), to match what most systems use. * aux/macros/header_templates.m4: template for HAVE_BAD_HASMNTOPT. * configure.in: invoke test for bad hasmntopt() * NEWS: minor new port, i386-pc-linux-rh8.0. Mention autofs-v4 on solaris9 works. * bootstrap: remove any autom4te-*.cache directories, now that autoconf uses a version number for them. 2002-12-09 Ion Badulescu Patches from Christos Zoulas: -1- am_utils.h: add full prototypes -2- amfs_auto.c make functions static and add prototypes -3- map.c: kill double free -5- transp_sockets.c: add full prototypes 2002-12-09 Ion Badulescu * NEWS: updated * doc/am-utils.texi (opts Option): document sftlookup * conf/autofs/autofs_solaris_v2_v3.c: compile fixes 2002-11-22 Erez Zadok * amd/info_ldap.c (amu_ldap_rebind): gopt.ldap_cache_seconds is %ld not %d. 2002-11-21 Erez Zadok * {amd,fsinfo}/Makefile.am: remove special rules for processing yacc/lex files, now that autoconf/automake properly handle them better (esp. now that bison 1.75 behaves differently than older bison versions). 2002-11-21 Erez Zadok * config.guess.long: updated script so it will properly find the version number of the new Itanium 2 machines running "Red Hat Linux Advanced Workstation release 2.1AW (Derry)". The script now will report ia64-unknown-linux-rh2.1AW. 2002-11-20 Ion Badulescu * amfs_auto_bgmount(): almost complete rewrite * fixed amfs_inherit to do the right thing and not dereference freed mntfs'es * #if 0'ed bogus code in fh_to_mp3() -- it is now done properly in amfs_autofs_lookup_child() * release the autofs_fh only in one place * remove the mountpoint only if mf_refc == 1 * print the mntfs type in free_mntfs() * new pseudo-mount option 'sftlookup' which causes lookups to mounted shares from downed servers to return EIO; the default depends on whether the mount is 'hard' or 'soft' * improved querying of supported NFS versions on the server -- don't even try if it's known to be down * solaris autofs mount code moved to transp_{sockets,tli}.c * incipient (non-functional) AIX autofs support 2002-11-11 Ion Badulescu * doc/am-utils.texi (Keep-alives): removed outdated info about not maintaining the state of TCP NFS servers 2002-11-04 Ion Badulescu * include/am_utils.h: prototype for ops_search() * amd/am_ops.c (ops_search): new function for searching the right set of ops for a given filesystem type * amd/restart.c (restart): cleanup and split into two functions in preparation for handling the restart of amd's own mount points (restart_fake_mntfs): new function, factored out from restart() 2002-11-04 Ion Badulescu * amd/ops_cdfs.c (mount_cdfs): remove special code for loop device (cdfs_umount): ditto * conf/mount/mount_linux.c (mount_linux): factor it out to mount_linux_nfs() and mount_linux_nonfs() (mount_linux_nonfs): generalize loop device support to all filesystems (not just cdfs); make it automatic for anything that's a regular file (parse_opts): deprecate the explicit "loop" mount option (do_mount_linux): minor cleanup * conf/umount/umount_default.c (umount_fs2): release loop device on umount() 2002-11-03 Erez Zadok * include/am_defs.h: moved #include of net/if.h above net/route.h, because on AIX 5.2 if.h is needed for route.h (let's hope it doesn't break things on other systems). * include/am_defs.h: AIX 5.2 needs struct sigevent from signal.h to be defined, but I don't want to move the inclusion of signal.h this early into this file. Luckily, amd doesn't need the size of this structure in any other structure that it uses. So we sidestep it for now. * conf/nfs_prot/nfs_prot_aix5_2.h: AIX 5.2 wants 'struct pathcnf', but I couldn't find its definition anywhere. Luckily, amd doesn't need the size of this structure in any other structure that it uses. So we sidestep it for now. 2002-11-02 Erez Zadok * config.guess, config.sub, doc/texinfo.tex: updates from the latest GNU distributions (2002-09-05). 2002-10-30 Erez Zadok * conf/nfs_prot/nfs_prot_aix5_2.h: add more definitions from mount.h for NFSOPT_* and NFSMNT_*. Don't use typedefs that aren't found in system header files. 2002-10-30 Erez Zadok * Makefile.am (EXTRA_DIST_CONF): distribute nfs_prot_aix5_2.h. * conf/nfs_prot/nfs_prot_aix5_2.h: new file. * aux/macros/struct_nfs_args.m4 (ac_cv_have_struct_nfs_args): look for "struct aux52_nfs_args". * aux/macros/check_nfs_prot_headers.m4: define new header file for AIX 5.2. 2002-10-21 Erez Zadok * scripts/amd.conf.5 (ldap_proto_version): document in amd.conf man page. * scripts/amd.conf-sample (ldap_proto_version): show example of use * doc/am-utils.texi (ldap_proto_version Parameter): document new amd.conf option. * amd/conf.c (gopt_ldap_proto_version): new conf function to support ldap_proto_version amd.conf parameter. * amd/amd.h: field to hold LDAP protocol version. * amd/amd.c (init_global_options): set default for ldap_proto_version. ldap_proto_version patch from George Ross and Tim Colles . * amd/info_ldap.c (amu_ldap_unbind): ignore SIGPIPE errors while unbinding from an LDAP server that may have been restarted. Fix from George Ross . 2002-09-17 Ion Badulescu * remove all autoconf stuff added for sys_nerr * amq/amq.c, libamu/xutil.c, hlfsd/hlfsd.c: always use strerror * libamu/strerror.c: more explicit text for unknown errno's 2002-10-01 Erez Zadok * include/am_defs.h: define "extern int sys_err" if needed. * aux/macros/header_templates.m4: template for HAVE_EXTERN_SYS_NERR. * hlfsd/hlfsd.h, libamu/xutil.c (expand_error), amq/amq.c (show_mi): remove "extern int sys_err" * configure.in: execute test for "extern int sys_err" * Makefile.am (EXTRA_DIST_AUX): distribute new extern_sys_err.m4 file. * aux/macros/extern_sys_nerr.m4: new test to check for existence of "extern int sys_nerr" definition in system headers. 2002-09-17 Ion Badulescu * libamu/xutil.c (dbg_opt): bring comments in line with the code * hlfsd/hlfsd.c (main): use amuDebug() instead of touching debug_flags directly * amd/amd.c (main): don't init debug_flags, leave it as zero (no debugging by default) 2002-09-11 Ion Badulescu Debug code sanitization: - amuDebug() becomes an expression, and explicit if() statements are added around it throughout the code - amuDebugNo() goes away (ugh!) - D_AMQ, D_DAEMON and D_FORK reverse their meaning - D_ALL contains only options that don't affect amd's functionality 2002-09-04 Ion Badulescu * amd/amfs_auto.c (free_continuation): avoid double-free'ing the mntfs if there was an error/timeout 2002-09-04 Ion Badulescu * amd/amfs_auto.c (amfs_auto_lookup_mntfs): use ereturn() instead of "return NULL" to signal an error to the upper layers (amfs_auto_mount): use strdup so the string can be free'd later on [Debian bug report from Matt Chapman ] 2002-09-03 Ion Badulescu Patches from George Ross : * amd/amfs_auto.c (assign_error_mntfs): do not discard old mntfs, it will be done in free_continuation(); assorted debugging messages * amd/srvr_nfs.c (nfs_timed_out): allocate a new XID on server timeout to avoid problems with late ping replies * amd/mntfs.c (free_mntfs): sanity check for mf_refc; assorted debugging messages * amd/map.c (unmount_node): more verbose debug message 2002-07-29 Ion Badulescu * amd/amfs_auto.c (amfs_auto_lookup_mntfs): prevent deferencing de-allocated memory in str3cat (amfs_auto_lookup_mntfs): check for buffer overflow 2002-07-11 Erez Zadok * scripts/expn.{1,in}: fixed typos as reported by Thomas Klausner . 2002-06-26 Erez Zadok * doc/Makefile.am (install-html): don't use locally hacked texi2html features. * conf/transp/transp_sockets.c (amu_get_myaddress): Most modern systems should use 127.0.0.1 as the localhost address over which you can do NFS mounts. In the past we found that some NFS clients may not allow mounts from localhost. So we used get_myaddress() and that seemed to work. Alas, on some other systems, get_myaddress() may return one of the interface addresses at random, and thus use a less efficient IP address than 127.0.0.1. The solution is to hard-code 127.0.0.1, but still check if get_myaddress() returns a different value and warn about it. * doc/am-utils.texi: don't use ':' in @cindex entries. 2002-06-25 Ion Badulescu * Released beta version 6.1b1 2002-06-24 Ion Badulescu * aux/macros/struct_nfs_args.m4: added test for aix51_nfs_args * conf/nfs_prot/nfs_prot_aix5_1.h: rename aix42_nfs_args to aix51_nfs_args, rename unknown fields to u, add the unknown new field into the middle of the old 4.2 structure 2002-06-24 Ion Badulescu * include/am_compat.h: better test for struct netconfig (!HAVE_NETCONFIG_H && !HAVE_SYS_NETCONFIG_H) * aux/macros/check_nfs_prot_headers.m4: added new header for aix5.1+ * buildall: fix 'buildall -b' on hpux9 and aix5.1 2002-06-24 Ion Badulescu * INSTALL: updated * conf/autofs/autofs_solaris_v1.c (autofs_link_mount): compile fix (autofs_link_umount): ditto * amd/mntfs.c (init_mntfs): don't use autofs if !amd_use_autofs 2002-06-23 Ion Badulescu * conf/autofs/autofs_linux.c: compile fixes for autofs v3 2002-06-23 Ion Badulescu * conf/autofs/autofs_solaris_v2_v3.c (autofs_mounted): no expirations needed; (autofs_timeout_mp): likewise * conf/autofs/autofs_solaris_v1.c (autofs_mounted): no expirations needed; (autofs_timeout_mp): likewise * conf/autofs/autofs_linux.c (autofs_mounted): set the first expiration interval * amd/autil.c (am_mounted): call autofs_mounted here, instead of in mf_mounted() * amd/amd.h (NEVER): moved here from map.c (autofs_mounted): change argument from mntfs* to am_node* 2002-06-23 Ion Badulescu * conf/autofs/autofs_linux.c (autofs_mounted): set the kernel timeout on the autofs mountpoint to cache_duration (gopt.am_timeo) (autofs_timeout_mp): don't update the ttl if we're going down * amd/map.c (timeout_mp): don't call autofs_timeout_mp unless the timeout on that particular am_node has expired * conf/autofs/autofs_linux.c (autofs_timeout_mp): really update the ttl, as per the comment (compilers are not very good at translating comments into code...) * amd/amfs_auto.c (amfs_auto_lookup_one_mntfs): strdup am_path instead of opt_rfs into opt_fs for autofs, thus avoiding conflicts between link mounts pointing to the same target 2002-06-23 Ion Badulescu * conf/autofs/autofs_linux.c (send_fail, send_ready): new helper functions for sending messages back to the kernel (autofs_expire_one): initial implementation of the kernel-based expiration handler (autofs_handle_expire): call autofs_expire_one() (autofs_handle_expire_multi): ditto (autofs_umount_succeeded): search pending_umounts, send message back to the kernel (autofs_umount_failed): ditto (autofs_mount_succeeded): tell amd core not to expire autofs entries (autofs_timeout_mp): expiration function for autofs filesystems (autofs_timeout_mp_task): helper function for autofs_timeout_mp * conf/autofs/autofs_linux.h: new struct autofs_pending_umount for keeping tracking of pending umounts (autofs_fh_t) rename pending to pending_mounts, add pending_umounts * conf/autofs/autofs_solaris_v1.c (autofs_timeout_mp): stub * conf/autofs/autofs_solaris_v2_v3.c (autofs_timeout_mp): stub * amd/map.c (timeout_mp): call autofs_timeout_mp() for autofs filesystems * amd/autil.c (mf_mounted): move here the call autofs_mounted() from amfs_auto_mounted(). 2002-06-22 Erez Zadok * amd/nfs_start.c (mount_automounter): Security fix. if user sets -D noamq, don't even create listening socket. Suggestion by Ed Ravin . 2002-06-22 Ion Badulescu * hlfsd/homedir.c (homedir): use setgid() instead of setegid() * ALL: #ifdef cleanups, unify some TLI/socket function prototypes 2002-06-22 Erez Zadok * conf/nfs_prot/nfs_prot_netbsd1_4.h: minor port to support na_gid and na_uid. NetBSD patch from Jun-ichiro itojun Hagino . * doc/am-utils.texi (Option): document xlatecookie mount option. * libamu/mount_fs.c (compute_nfs_args): support "xlatecookie" NFS mount option. Patch from Matthias Scheler for NetBSD. 2002-06-22 Ion Badulescu * conf/autofs/autofs_solaris_v1.h: add FS_MBACKGROUND to AUTOFS_LINK_FS_FLAGS * conf/autofs/autofs_solaris_v1.c: convert link mounts to lofs mounts in autofs_link_mount/umount 2002-06-22 Ion Badulescu * configure.in: check for devid inside struct umntrequest * conf/autofs/autofs_solaris_v2_v3.c (xdr_umntrequest): handle the new umntrequest structure in v4. (autofs_unmount_2_req): ditto * README.autofs: updated for Solaris 2.5/2.5.1 2002-06-22 Erez Zadok * configure.in: only define LDAP/Hesiod if both the headers and the libraries exist, and the user didn't explicitly disable those maps. 2002-06-22 Erez Zadok * doc/am-utils.texi: fix typos. Can't use ":" in @cindex entries. 2002-06-22 Erez Zadok * doc/am-utils.texi, scripts/amd.conf.5, scripts/amd.conf-sample, amd/amd.8, amd/get_args.c (get_args): document amd -A option. * amd/get_args.c (get_args): support "amd -A arg" option to override the system's detected architecture. Patch from George Ross . * amd/info_ldap.c (amu_ldap_rebind): don't use ldap_enable_cache() if the system doesn't have it. * configure.in: detect existence of ldap_enable_cache function, because it doesn't exist on Solaris 9's latest ldap libraries. * amd/info_ldap.c: LDAP patches from George Ross . Rework of old code, support for wildcards in LDAP queries, and an FD leak fix. 2002-06-22 Ion Badulescu * buildall: use ksh for configure on aix5.1; pass the extra arguments after "--" to configure, not to make * Makefile.am: added nfs_prot_aix4_3.h to EXTRA_DIST_CONF * conf/mount/mount_aix.c (mount_aix3): if the NFSv3 mount fails with EINVAL and we have MOUNT_TYPE_NFS3_BIS defined, retry the mount with the alternative nfs3_args structure * conf/nfs_prot/nfs_prot_aix4_3.h: added alternative nfs3_args structure, similar to that in aix5.1, for a hack that tries to compensate for IBM's brain fart * conf/nfs_prot/nfs_prot_aix5_1.h: new nfs_prot header for aix5.1+ * aux/macros/check_nfs_prot_headers.m4: added new header for aix5.1+ * BUGS: update for direct mounts on Linux; document the brokenness of /bin/sh on AIX 5.1 and HP-UX 9 * NEWS: aix5.1 port, aix4.3 workaround 2002-06-22 Erez Zadok * ltmain.sh: use libtool 1.4d, needed support for newer AIX. 2002-06-21 Ion Badulescu * aux/macros/check_autofs_style.m4: enable autofs_v2_v3 for all solaris2.6+, not just for 2.[6-8] * conf/autofs/autofs_default.h: disable autofs if configure detects it 2002-06-21 Erez Zadok * aux/macros/with_addon.m4: correct M4 quoting. * aux/macros/cache_check_dynamic.m4: correct M4 quoting. * bootstrap: show version of autotools being used. Helps maintainer debugging. * configure.in: new proper syntax for libtool and ansi2knr-filtering rules, required by autoconf 1.53 and higher. 2002-06-21 Erez Zadok * aux/GNUmakefile: new search paths for "update" target. * config.guess, config.sub, doc/texinfo.tex, ltmain: updates from the latest GNU distributions. 2002-06-11 Ion Badulescu * amd/amfs_auto.c (amfs_auto_lookup_child): split part of this function into the new amfs_auto_lookup_one_child function; return null if all ivecs failed to match 2002-05-30 Erez Zadok * config.guess.long: support SuSE version names in long config.guess format. 2002-05-01 Erez Zadok * scripts/lostaltmail.in (vrfy_user): unlink temp files if too small. 2002-04-07 Ion Badulescu * hlfsd/hlfsd.c (main): compile fix for --enable-debug=no 2002-03-29 Ion Badulescu * README.autofs: solaris 2.5/2.5.1 info, other minor changes * doc/am-utils.texi (History): document solaris 2.5+ support * include/am_utils.h: new member in struct mntfs: mfs_real_mount; autofs_fs_flags becomes conditional of HAVE_AUTOFS_FS; new prototype for umount_fs2(); extra argument for UMOUNT_FS() * hlfsd/hlfsd.c: use the new mount_fs2() and UMOUNT_FS() * libamu/mount_fs.c (mount_fs): wrapper around the new mount_fs2() function; swap mntdir and real_mntdir as necessary for solaris 2.5 autofs support * conf/umount/umount_default.c (umount_fs2): swap mntdir and real_mntdir as necessary for solaris 2.5 autofs support * conf/umount/umount_*.c (umount_fs): wrapper around the new umount_fs2() function (umount_fs2): new function which takes the real mountpoint as an extra argument * conf/nfs_prot/nfs_prot_sunos5_5.h: allow autofs support to be compiled in * conf/autofs/autofs_solaris_v1.h (autofs_strdup_space_hack): new function that appends a space at the end of a string (the famous "Autofs Space Protocol") * conf/autofs/autofs_solaris_v1.c: almost complete reimplementation * conf/autofs/autofs_*.h (AUTOFS_*_FS_FLAGS): add system-specific definitions for these macros * conf/autofs/autofs_linux.c (create_autofs_service): remove hacks which are now handled properly by more generic code (autofs_link_umount): complain if umount_fs() fails, rmdir the mountpoint on success (autofs_umount_succeeded): remove the rmdirs() code, now handled by generic code (autofs_mount_succeeded): ditto * amd/nfs_start.c (checkup): implement it as an emtpy stub if DEBUG is not defined (run_rpc): call autofs_add_fdset() after umount_exported() to avoid passing invalid file descriptors to select(); use plog() instead of perror() * amd/mntfs.c (init_mntfs): initialize mf_real_mount from mp (uninit_mntfs): free mf_real_mount * amd/autil.c (am_unmounted): don't remove the mount point if a remount is pending, also don't make the removal conditional on not being an autofs mount point * amd/amfs_nfsx.c (amfs_nfsx_remount): call mkdirs() on mf->mf_real_mount instead of mf->mf_mount * amd/amfs_nfsl.c, amd/amfs_nfsx.c: (amfs_nfsl_umounted): call rmdirs() on mf->mf_real_mount instead of mf->mf_mount * amd/amfs_host.c (make_mntpt): change the third argument to be the mountpoint, not the entire mntfs structure (do_mount): takes real_mntdir as an extra argument * amd/amfs_auto.c (amfs_auto_bgmount): move the creation of the mountpoint here from try_mount(), otherwise the change to mf_flags is lost for background mounts; remove the mountpoint if we created it and the mount fails (amfs_auto_lookup_mntfs): re-initialize mf->mf_real_mount using autofs_strdup_space_hack() if NEED_AUTOFS_SPACE_HACK is defined * amfs_*.c, ops_*.c: initialize autofs_fs_flags using the AUTOFS_*_FS_FLAGS macro defined in the system-specific autofs header; UMOUNT_FS() takes mf->mf_real_mount as an extra argument; mount_fs() becomes mount_fs2() and takes mf->mf_real_mount as an extra argument * amd/amd.h, amd/ops_nfs.c, amd/amfs_host.c: mount_nfs_fh takes the real mountpoint as an additional argument 2002-03-28 Erez Zadok * amd/ops_cdfs.c (mount_cdfs): correctly interpret error return values back from mount_fs(). Return correct error number from this function. * conf/mount/mount_linux.c (do_mount_linux): cleanup loop mount cruft from this function, moved elsewhere. (mount_linux): prepare for loop-device mounts of ISO images. 2002-03-28 Ion Badulescu * libamu/Makefile.am (EXTRA_DIST): added strerror.c * libamu/strerror.c: strerror() implementation for systems lacking it * doc/am-utils.texi (History): rewrote the history :) about autofs support * conf/autofs/autofs_solaris_v2_v3.c: updated copyright; (autofs_unmount_2_req): minor cleanup (create_autofs_service): print log message (destroy_autofs_service): ditto * conf/autofs/autofs_linux.c: updated copyright * amd/nfs_start.c (mount_automounter): move the debug message into create_autofs_service() * amd/amd.c (main): call destroy_autofs_service() before going_down(), not after * configure.in: added strerror to AC_CHECK_FUNCS(); disable ldap if the ldap headers are not found 2002-03-28 Erez Zadok * amd/info_ldap.c: patch from "Sebastien Bahloul" to fix a simple initialization bug and change "HE" to HE_ENT so as to compile on HPUX. 2002-02-26 Erez Zadok * conf/nfs_prot/nfs_prot_freebsd3.h (na_uid): freebsd4.5 uses nfs atttributes field named "uid". So #define na_uid to it. 2002-02-12 Erez Zadok * scripts/lostaltmail.in: don't verify user if -noverify option was turned on. fix comment typo. 2002-02-11 Erez Zadok * amd/Makefile.am (TESTS): enable one test script, test1.sh. * amd/test1.sh: re-commit simple test script. 2002-02-11 Ion Badulescu * Released snapshot 6.1a5 * NEWS: Solaris autofs readdir() support, Linux autofs sublink fix * README: require newer auto-tools, update mailing list address * README.autofs: major update * configure.in: version changed to 6.1a5 2002-02-11 Ion Badulescu * conf/autofs/autofs_linux.c (autofs_link_mount): don't do a stat() on the am_link if called from the parent amd, to prevent deadlocks * amd/autil.c (am_unmounted): call amfs_link_ops.umount_fs if the fstype is not link but we have a sublink (Linux autofs needs this) (am_mounted): call amfs_link_ops.mount_fs if the fstype is not link but we have a sublink (Linux autofs needs this) * amd/amfs_auto.c (amfs_auto_bgmount): print the real mountpoint, not the amd entry point 2002-02-09 Ion Badulescu * conf/autofs/autofs_solaris_v2_v3.c (amd_rddirres): new custom structure for returning the results from readdir_2() (xdr_amd_putrddirres): renamed from xdr_autofs_putrddirres, changed to process our internal format (which is essentially the NFS readdir format) (xdr_autofs_getrddirres): not needed, deleted (xdr_amd_rddirres): renamed from xdr_autofs_rddirres, other changes to handle amd_rddirres instead of autofs_rddirres (autofs_lookup_2_req): return AUTOFS_NONE instead of AUTOFS_MOUNT_RQ, to prevent mount storms during ls -F (autofs_readdir_2_req): implemented (autofs_readdir_2_free): not needed, deleted (autofs_program_2): changes from autofs_rddirres to amd_rddirres (autofs_get_fh): changed initialization of the fh->map member, it now gets the mountpoint path because it makes it easier to implement readdir (autofs_release_fh): put #ifdef HAVE_AUTOFS_ARGS_T_ADDR around code touching fh->addr (destroy_autofs_service): new function, deregister the autofs service with the portmapper on exit * conf/autofs/autofs_linux.c (autofs_handle_missing): update statistics (destroy_autofs_service): new stub * amd/mapc.c (mapc_find): fixed indentation * amd/map.c (find_ap_recursive): renamed from find_ap2(), made static * amd/amd.h: removed prototype for find_ap2(), added prototype for destroy_autofs_service() * amd/amd.c (main): call destroy_autofs_service() before going down 2002-02-07 Erez Zadok * aux/macros/check_field.m4: need also a new version of AC_CHECK_MEMBERS (plural). 2002-02-06 Erez Zadok * aux/macros/check_field.m4: include a fixed version of AC_CHECK_MEMBER. g/cc will fail to check a member if the .member is itself a data structure, because you cannot compare, in C, a data structure against NULL; you can compare a native data type (int, char) or a pointer. Solution: do what I did in my original member checking macro: try to take the address of the member. You can always take the address of anything. 2002-01-31 Erez Zadok * remove old '%W%' SCCS IDs from all sources. 2002-01-21 Ion Badulescu * conf/mount/mount_linux.c (mount_linux): fix breakage introduced by the loop device mount support. Linux mount takes a real string as the last argument, unless the mount type is NFS, NCP, or SMB. 2002-01-20 Erez Zadok * hlfsd/hlfsd.h (HLFSD_VERSION): up version of hlfsd to 1.2, because we made some important changes. 2002-01-20 Ion Badulescu * include/am_utils.h (D_ALL): do not include D_MTAB and D_HRTIME by default * NEWS: document latest changes * amd/map.c (unmount_mp): same fix as for hlfsd, update the seconds field in mtime because Linux ignores the useconds field * hlfsd/homedir.c: made some global vars static (plt_init): remove all trailing '/' chars from root's home; use root's home, not the username (silly bugfix) 2002-01-20 Ion Badulescu * hlfsd/homedir.c (homedir): don't special case uid 0 as having / as home; instead use the root account's home (plt_init): properly initialize root_home from the root account's home directory, or as "" if root doesn't exist (plt_reset): free root_home 2002-01-20 Erez Zadok * hlfsd/stubs.c (nfsproc_{lookup,getattr}_2_svc): non-SYMTTL code. Increment seconds, not microseconds (which are ignored by NFS). Set symlink owner to euid. * hlfsd/homedir.c (homedir): pass gid to this function, so we can also change the effective GID of the process writing to the user's home dir, as well as the group of the hlfsd symlink. (homedir): run setegid in the right places. 2002-01-15 Erez Zadok * scripts/redhat-ctl-amd.in: refer to @sbindir@ not ${prefix}/sbin. * scripts/ctl-{amd,hlfsd}.in: refer to @sysconfdir@ not ${prefix}/etc. Bug report from "A Braunsdorf" . 2002-01-13 Erez Zadok * configure.in: only check for clock_gettime if --enable-debug was used. * aux/macros/opt_debug.m4: define a cache variable to record value of debug option used. * libamu/xutil.c (show_time_host_and_name): do not use clock_gettime unless debugging was compiled in. This way, if debugging is not compiled, we don't bother linking with librt, libpthread, and a whole lot of other libraries that aren't that necessary (esp. on Linux). 2002-01-12 Erez Zadok * doc/am-utils.texi (opts Option): document loop option. * include/am_utils.h: each mounted file system (mntfs) should optionally store the loop device used in the field mf_loopdev. * conf/nfs_prot/nfs_prot_linux.h: define HAVE_LOOP_DEVICE and some loop function extern definitions. For now this code is here because we only support loop devices on Linux. * conf/mount/mount_linux.c: recognize "loop" as a valid iso9660 mount option. (parse_opts): when skipping over unknown mount options, skip over "loop" (since it was given in amd map entry), but not over loop=/dev/loopX, because the latter will go into /etc/mtab. (do_mount_linux): override actual cdfs mounted device name because with loop devices you don't mount the .iso file directly, but the /dev/loopX device that was setup for it. (show_loop, is_loop_device, find_unused_loop_device, setup_loop_device, delete_loop_device): support code for loop devices. * amd/ops_cdfs.c (mount_cdfs): pass loop device name to function. setup loop device before isofs mount, if "loop" option was given, before actual mount(2). (cdfs_mount): pass loopdev name to mount_cdfs(). (cdfs_umount): delete/unset loop device after a successful unmount, if a loop device was used. * amd/mntfs.c (init_mntfs): initialize mf_loopdev to NULL. * include/am_compat.h: If loop device (header file) exists, define mount table option MNTTTAB_OPT_LOOP. * conf/nfs_prot/nfs_prot_linux.h: hack: define HAVE_LOOP_DEVICE here until we have a better way to detect /dev/loop devices. * include/am_defs.h: include if it exists. Define LARGEFILE support macros, possibly needed for loop devices. Redefine dev_t apropriately for loop devices. * configure.in: check for . 2002-01-10 Ion Badulescu * conf/mount/mount_linux.c (mount_linux): tcp _must_ have a timeo parameter 2 orders of magnitude larger than udp (patch from Trond Myklebust) 2002-01-09 Erez Zadok * aux/macros/linux_headers.m4: properly [quote] a long string in m4 and use AC_MSG_WARN. * ALL: put /* comments */ on #else/#endif lines everywhere. * configure.in, aux/macros/with_addon.m4: due to limitation of AC_HELP_STRING, pass 2nd arg to AMU_WITH_ADDON, listing name of package for help string. * doc/am-utils.texi (FSinfo): fixed various texinfo errors in the FSinfo section of the manual. (map_reload_interval Parameter): document new amd.conf global parameter. * scripts/amd.conf.5 document new global option map_reload_interval. Sort entries for nfs_vers and nfs_proto alphabetically. * amd/nfs_start.c (do_select): increment do_mapc_reload's value by global map_reload_interval value, not by fixed ONE_HOUR. * amd/amd.c (main): increment do_mapc_reload's value by global map_reload_interval value, not by fixed ONE_HOUR. * scripts/amd.conf-sample (map_reload_interval): usage example * amd/amd.c (init_global_options): initialize map_reload_interval to 3600 seconds. * amd/conf.c (gopt_map_reload_interval): support a new global amd.conf option map_reload_interval, to determine how often (in seconds) Amd should check if the map source has changed and then reload it it. This value was hard-coded to one hour, now it's the default if not otherwise specified. * doc/am-utils.texi (plock Parameter): document plock=yes option as using mlockall(2) if found. * scripts/amd.conf.5: document -S option as using mlockall(2) if found. * include/am_defs.h: include if it exists. * configure.in: check for mlockall() function. Check for sys/mman.h. * amd/amd.c (main): support mlockall() on systems that have it and don't have plock(3) for plock=yes. On systems that have both, will try plock() first and then mlockall(), until one of them (if any) succeeds. 2002-01-09 Erez Zadok * aux/macros/opt_debug.m4, opt_cppflags.m4, opt_amu_cflags.m4, with_addon.m4 (ac_upcase): fix help string formatting using AC_HELP_STRING. * amd/test1.sh: simple test script for "make check". Runs "amd -v". * amd/Makefile.am (TESTS): add one simple test script, running "amd -v" and checking its return value. More tests can be added. * aux/macros/linux_headers.m4: use AC_MSG_WARN directly. * aux/macros/*.m4: avoid the cumbersome "changequote" M4 command. Instead, list bracketed regexp patterns in [[double brackets]]. * aux/macros/header_templates.m4: remove all unnecessary HAVE_FIELD_* definitions, now that we're using autoconf's new AC_CHECK_MEMBERS. * aux/macros/field_mntent_t_mnt_time_string.m4: don't call * configure.in: use new syntax for AMU_CHECK_FIELD * aux/macros/check_field.m4: use new and simpler macro AC_CHECK_MEMBERS. Change all sources to use HAVE_aggregate.member instead of HAVE_FIELD_aggregate.member. * aux/amdgrep: simple utility script to egrep the am-utils sources for any pattern. * aux/macros/{check_mnttab_style.m4, check_mount_style.m4, check_umount_style.m4, check_network_transport_type.m4}: use newer AC_LIBOBJ macros instead of modifying $LIBOBJS directly * aux/macros/func_bad_memcmp.m4: redefine to use native AC_FUNC_MEMCMP, and then define HAVE_BAD_MEMCMP as needed. * fsinfo/fsi_gram.y, amd/conf_parse.y: indent #pragma command so pre-ANSI C compilers will ignore it. * conf/autofs/autofs_linux.c (autofs_link_mount): call s/getpgrp() correctly depending on whether it takes a void or a 0. * configure.in: check if s/getpgrp() takes void or a 0. 2002-01-08 Erez Zadok * configure.in: use the newer AC_CONFIG_LINKS instead of AC_LINK_FILES. * aux/macros/check_autofs_style.m4, check_checkmount_style.m4, check_mnttab_style.m4, check_mount_style.m4, check_network_transport_type.m4, check_umount_style.m4, check_nfs_prot_headers.m4: removed backward compatible code for pre-autoconf-2.14. 2002-01-07 Erez Zadok * doc/Makefile.am: define @SET_MAKE@ for AC_PROG_MAKE_SET macro, since this Makefile could explicitly chdir to other directories and run make there. (install-ps): use ${MAKE} with ${MFLAGS}. * Makefile.am (EXTRA_DIST_AUX): distribute new package_*.m4 files. Define @SET_MAKE@ for AC_PROG_MAKE_SET macro, since this Makefile could explicitly chdir to other directories and run make there. (install-snapshot): use ${MAKE} ${MFLAGS}, not hardcoded "make". * configure.in: call AC_PROG_MAKE_SET to check if make program defines $MAKE variable. * amd/get_args.c (get_version_string): use new PACKAGE_* macros and also report the bug-reporting address. * aux/macros/package_{name,version}.m4, header_templates.m4: using new PACKAGE_{NAME,VERSION,BUGREPORT} macros. * aux/macros/name_bugreport.m4: simple macro to print out the bug-reporting address which was configured in AC_INIT. * bootstrap: remove new autoconf messages about misuse of m4_patsubst and m4_regexp (internal GNU M4 macros). * configure.in: remove old comment above AC_OUTPUT. Use AC_CONFIG_FILES and AC_OUTPUT separately. Fix AC_REVISION use. Add AC_COPYRIGHT. Use new style for AC_INIT, listing package name, version, and bug-reporting address. Call new AMU_PACKAGE_* macros. * updated copyright year to 2002 on all files * configure.in: using newly renamed am-utils macros (AMU_*) * aux/macros/*.m4: renamed ALL am-utils specific macros so they start with AMU_*, not AC_*. That way it is easier to distinguish between macros that come with am-utils and those that are part of Autoconf or Automake. It helps to identify those am-utils macros that can be removed once there is generic support for them in a future version of Autoconf. * bootstrap: run automake --copy remove autom4te.cache dir before rerunning autoconf 2001-12-13 Erez Zadok * scripts/amd.conf.5: correct title to section 5, not 8. Correct reversed meaning of nfs_proto and nfs_vers parameters. Typos reported by Peter Breitenlohner . 2001-12-02 Erez Zadok * scripts/ctl-amd.in: run "test" or "[" in front of -x/-f * scripts/ctl-hlfsd.in: run "test" or "[" in front of -x/-f 2001-12-02 Ion Badulescu * hlfsd/homedir.c (plt_print): fix typo (s/plot/plog/) in non-mkstemp code * scripts/ctl-amd.in: touch/remove /var/lock/subsys/amd to make RH happy * scripts/ctl-hlfsd.in: ditto (for hlfsd) * conf/mtab/mtab_file.c (rewrite_mtab): fchmod(644) the file we get from mkstemp(), otherwise samba becomes very unhappy (sigsegv) * conf/mtab/mtab_mach3.c (rewrite_mtab): ditto 2001-11-29 Ion Badulescu * tasks: updated * NEWS: document the fixed autofs fd leak * amq/amq.8: better document the -f option 2001-11-29 Erez Zadok * libamu/mount_fs.c (mnt_flags): same this as for nolock option handling, do for maxgrps. 2001-11-29 Ion Badulescu * conf/autofs/autofs_linux.c (hash_init): determine the max number of fd's at runtime, use it to dynamically scale the hash and list arrays (autofs_get_fh): sanity check, don't allow a pipe() fd greater than autofs_max_fds (autofs_release_fh): close our end of the pipe here (no clue why or when it got commented out) (autofs_mounted): set kernelfd to -1 after closing it 2001-11-28 Philippe Troin * libamu/mount_fs.c (mnt_flags): Drop nolock from generic mount opts. (compute_nfs_args): Added nolock handling. Adapted from an original patch from Avery Pennarun . 2001-11-27 Erez Zadok * ported to ia64-hp-hpux11.20 using HP's ANSI/C compiler. Couldn't use bison/flex because of 32-bit vs. 64-bit binaries issues. Had to use HP's own yacc/lex. 2001-11-26 Erez Zadok * */Makefile.am: don't use $(OBJECTS) directly because it is no longer automatically defined now that Automake has automatic dependency tracking (which I turn off). Instead, hard-code minimal dependencies on am-utils' header files to depend on PROG_OBJECTS (where PROG is the program name being built). This was discovered by using HP's non-GNU make program. * amd/nfs_start.c (checkup): cast getpagesize() return val to long, to avoid conflicts in division of a long by an int (on hpux11i, with their ANSI/C compiler). * INSTALL, doc/am-utils.texi: port updates * minor new ports: ia64-hp-hpux11.20, i386-unknown-freebsd5.0, i386-unknown-freebsd4.4, i386-pc-linux-rh7.2, ia64-unknown-linux-rh7.1. * include/am_defs.h: actually declare extern definition for xdr_callmsg() if it doesn't already exist. * aux/macros/header_templates.m4: declare template for HAVE_EXTERN_XDR_CALLMSG. * configure.in: check for extern definition for xdr_callmsg() because hpux11 has that function but a bad header file that doesn't define it in the right place. * libamu/mount_fs.c (print_nfs_args): cast ->rdev to u_long b/c on hpux11 its type is dev_t. * conf/nfs_prot/nfs_prot_hpux11.h: don't support autofs on hpux11 yet. 2001-11-16 Erez Zadok * buildall (Usage): separate $cnf_flags and $extra_cnf_flags due to /bin/sh limitations. * bootstrap (cmd): turn back on --ignore-deps (this Automake may have problems) * libamu/xutil.c: remove __attribute__ format_arg statement for expand_error() because this function, although taking a printf-like string, does not use it in a printf function; it only expands a non-printf amd-special syntax %m. 2001-11-14 Erez Zadok * conf/nfs_prot/nfs_prot_linux.h: define KERNEL_VERSION macro before using it because older Linux systems don't define this (e.g., Red Hat 4.2) 2001-11-13 Erez Zadok * configure.in: convert to using autoconfig 2.52. Use new macros. AC_MSG_NOTICE for messages; AH_TOP and AH_BOTTOM to top and bottom parts of autogenerated config.h.in; increase autoconf pre-requisite to version 2.50; use AC_DISABLE_SHARED not AM_DISABLE_SHARED. * aux/macros/cache_check_dynamic.m4: finally I can use the new $ECHO_N syntax in macros instead of $ac_n, since I'm using a new autoconf. Isn't it nice to be such forward looking and having placed a comment "XXX: use the next line for autoconf-2.14 and newer"... :-) * aux/macros/save_state.m4: highlight message with ***'s * aux/macros/host_macros.m4: use proper M4 quoting ([], not "") * config.{guess,sub}: upated from latest prep ftp distributions * depcomp, missing, mkinstalldirs: upated from latest Automake 1.5 * ltmain.sh: updated from latest Libtool 1.4.2 * bootstrap: finally, new autoconf doesn't print silly "AC_TRY_RUN called without default to allow cross compiling" warnings. And, it only took like 3+ years to fix this. But, now it has anoter, albeit less annoying warning (which the manual says to ignore): "AC_PROG_LEX invoked multiple times". When autoheader is run, don't treat the "all clear" message "config.h.in is update" as an error. * ltconfig: removed. not needed with latest version of libtool * aux/macros/header_templates.m4: replaces acconfig.h and defines all CPP macros we use in this package, including their accompanying C /* comments */. * acconfig.h: removed. replaced by new autoconf system to generate header templates using AH_TEMPLATE macros and such. * aux/macros/msg.m4: removed. Replaced with new macro AC_MSG_NOTICE * Makefile.am (EXTRA_DIST_AUX): remove aux/macros/msg.m4. Add aux/macros/header_templates.m4 * configure.in: early, in host_macros.m4, I'm renaming silly linux $host_os names such as linux-gnu and lignux to plain "linux". Alas, RMS finally had his way and libtool will NOT recognize "linux" as a valid system, only "linux-gnu". Sigh. Rich, I know you're responsible to Linux's fame. Kudos to you and your cohorts. But please don't force the rest of us to use those ugly or long names. Solution: temporarily name $host_os to "linux-gnu" before calling the AC_PROG_LIBTOOL macro, then name it back to "linux". (That way I don't have to maintain my own version of ltmain.sh. * buildall: force running configure -C (to create and use a local config.cache file). New default behavior for autoconf is NOT to use cache files. Yeah, that's gonna fly real well with am-utils, with its 700+ automatic tests. * conf/mtab/mtab_mach3.c (rewrite_mtab): use mkstemp instead of mktemp, if the former is available. * conf/mtab/mtab_file.c (rewrite_mtab): use mkstemp instead of mktemp, if the former is available. * mk-amd-map/mk-amd-map.c (main): use mkstemp instead of mktemp, if the former is available. * aux/macros/check_nfs_socket_connection.m4: AC_DEFINE calls must be on a separate line, as per new Autoconf manual, to avoid some Bourne Shell syntactical bizarreness. 2001-11-13 Erez Zadok * amd/amfs_auto.c (amfs_auto_readdir_browsable): cast to u_long, for IA64 Linux. 2001-11-12 Ion Badulescu * libamu/mtab.c (hasmntval): strtol can return a non-NULL pointer pointing to '\0' on success, so we need to allow for it. This fixes the problem with rejecting numerical mount options if they are the last option in the string. * configure.in: increased library patchlevel * NEWS: document the parsing bug 2001-10-29 Ion Badulescu * configure.in: bumped version up to 6.1a5-pre * NEWS: fixed speeling mistaike 2001-10-29 Ion Badulescu * released snapshot am-utils-6.1a4 2001-10-26 Ion Badulescu These changes fix autofs support for sublinks. While it is not perfect by any means and is hardly better than non-autofs, at least it works. * conf/autofs/autofs_solaris_v2_v3.c (autofs_lookup_2_req): don't reply if the mount is in progress (autofs_mount_succeeded): handle both delayed lookups and mounts (autofs_mount_failed): ditto * amd/amfs_auto.c (amfs_auto_lookup_mntfs): don't dispose of the original opt_fs if we have a sublink 2001-10-23 Ion Badulescu * amd/amfs_auto.c (amfs_auto_lookup_mntfs): fixed silly typo (mf instead of new_mf) which was causing null pointer error when sublinks were being used 2001-10-22 Ion Badulescu * README.autofs: updated * NEWS: updated * INSTALL: updated * AUTHORS: added myself * doc/am-utils.texi: updated * conf/autofs/autofs_solaris_v2_v3.c (xdr_autofs_rddirargs): use xdr_u_int() and cast things to (int) to appease Solaris 2.7 compile (autofs_readdir_2_req): cast req->rda_offset to (int), same as above 2001-10-22 Ion Badulescu Autofs direct mounts have been verified to work on Solaris2.[67]. * conf/autofs/autofs_solaris_v2_v3.c (autofs_lookup_2_req): retrieve the uid and gid from the lookup request (autofs_mount_2_req): skip the first char in the name (it's a leading '/') if this is a direct mount * amd/amfs_direct.c (amfs_direct_ops): use amfs_auto_lookup_child and amfs_auto_mount_child for amfs_direct's methods * amd/amfs_auto.c (amfs_auto_lookup_child): don't leak an am_node if the mntfs lookup fails 2001-10-21 Ion Badulescu * include/am_utils.h (AMF_REMOUNT): new flag, marks the node as pending a remount (mntfs): new member mf_fsflags, holds a copy of the filesystem's fs_flags (am_ops): new member autofs_fs_flags, holds the filesystem's flags when mounted onto an autofs node; fs_flags renamed to nfs_fs_flags * conf/autofs/autofs_linux.c (create_autofs_service): turn on FS_MKMNT for amfs_auto and FS_MBACKGROUND for amfs_link (autofs_umount_succeeded): don't rmdir the mountpoint if a remount is needed [lest the access that triggered the remount will fail] * amd/mntfs.c (init_mntfs): copy the filesystem's nfs_fs_flags into mf_fsflags on initialization * amd/autil.c (am_unmounted): start the remounting right away if the node is marked as needing a remount [fixes the Linux autofs deadlock when mount/unmount collide] * amd/amfs_auto.c (amfs_auto_lookup_node): mark the node as needing a remount if a mount request comes in while we're unmounting it (amfs_auto_lookup_mntfs): copy the filesystem's autofs_fs_flags into mf_fsflags if this is an autofs node * amd/amfs_*.c, amd/ops_*.c: added initialization for the new autofs_fs_flags member of am_ops 2001-10-20 Ion Badulescu With these changes, Solaris 2.[67] autofs support is finally functional! * conf/autofs/autofs_solaris_v2_v3.c (autofs_readdir_2_req): stub (autofs_readdir_2_free, xdr_autofs_rddirargs, xdr_autofs_putrddirres, xdr_autofs_getrddirres, xdr_autofs_rddirres): new functions (autofs_lookup_2_req): do an actual lookup here, and tell the kernel to create a symlink if necessary (autofs_mount_2_req): no need to am_autofs_data (autofs_program_2): enable AUTOFS_READDIR (autofs_link_mount): no code needed here (autofs_link_umount): return success (autofs_mount_succeeded): lstat real mount points; don't mark symlinks as NOTIMEOUT * amd/mntfs.c (init_mntfs): mf_dev and mf_rdev don't exist anymore * amd/map.c (init_map): init am_dev and am_rdev to -1 (free_map): free am_mfarray and all mntfs's listed * amd/autil.c (mf_mounted): move the lstat of the node to the autofs-specific code * amd/amfs_link.c (amfs_link_ops): don't background symlink creation 2001-10-18 Rainer Orth * aux/macros/os_cflags.m4 (irix6*): Enforce N32 ABI/mips3 ISA with cc. * BUGS: Explain this. 2001-10-02 Erez Zadok * doc/am-utils.texi (redhat-ctl-amd): document new script. * scripts/Makefile.am: build redhat-ctl-amd but do not install it. * scripts/redhat-ctl-amd.in: new script, useful to correctly control Amd on Red Hat Linux systems. Script adapted from ctl-amd and Red Hat's own rc.d script. 2001-10-02 Rainer Orth * conf/nfs_prot/nfs_prot_osf5.h: Renamed from nfs_prot_osf5_1.h. (MNT2_NFS_OPT_AUTO): Disable. * Makefile.am (EXTRA_DIST_CONF): Reflect new name. * aux/macros/check_nfs_prot_headers.m4: Use this file for all Tru64 UNIX V5 and up releases. 2001-09-24 Ion Badulescu * include/mount_headers1.h (MFS): define as 1 instead of nothing, to fix compile problems on OS X (patch from Ahmon Dancy) * aux/macros/try_compile_anyfs.m4 (MFS): ditto 2001-08-13 Erez Zadok * doc/am-utils.texi (in_network Selector Variable): document expanded syntax * libamu/wire.c (is_network_member): support for network/netmask as well as network/bits syntax in in_network() 2001-08-11 Erez Zadok * amq/amq.c (show_mti): print full four digits for year, and print it in MM/DD/YYYY format, not in YY/MM/DD format. 2001-08-11 Ion Badulescu * conf/autofs/autofs_solaris_v2_v3.c (autofs_lookup_2_req): initial attempt to do something useful -- but commented out for now (autofs_link_mount): create an action structure with a link request and pass it up (autofs_mount_2_req): pass the link request to the kernel (autofs_free_data): new helper function * conf/autofs/autofs_linux.h: added definition for autofs_data_t * conf/autofs/autofs_solaris_v2_v3.h: ditto * amd/map.c (init_map): initialize am_autofs_data (free_map): call the autofs cleanup function if necessary * include/am_utils.h (am_node): added private data and cleanup function for autofs * tasks: removed some obsolete entries 2001-08-11 Erez Zadok * amd/map.c (free_map_if_success): run autofs_umount_failed() only if this mount node is of type autofs. 2001-08-11 Ion Badulescu * amd/amd.h: removed mf_array from struct continuation (moved into am_node) * include/am_utils.h: removed VLOOK_LOOKUP; renamed vlookuppn to vlookup_child; added vmount_child; added mount_child to the fs_ops API; added prototypes for amfs_auto_mount_child and amfs_error_mount_child * amd/map.c (init_map): initialize am_mfarray to 0 * amd/amfs_*, amd/ops_*: new API function mount_child, old API function lookuppn renamed to lookup_child * amd/amfs_auto.c: renamed amfs_auto_lookuppn1 to amfs_auto_lookup_node; renamed amfs_auto_lookuppn2 to amfs_auto_lookup_mntfs; renamed amfs_auto_lookuppn3 to amfs_auto_mount_child; moved the freeing of the error mntfs in the newly allocated am_node from lookup_mntfs to mount_child; make sure lookup_child returns a negative error if the node needs to be mounted; removed the call to lookuppn3 from lookup_child * amd/amfs_error.c: added stub implementations of amfs_error_lookup_child and amfs_error_mount_child * amd/amfs_direct.c, amd/amfs_union.c, amd/map.c, amd/nfs_subr.c, conf/autofs/autofs_linux.c, conf/autofs/autofs_solaris_v2_v3.c: call both lookup_child and mount_child, instead of the old lookuppn API method 2001-07-19 Erez Zadok * amd/get_args.c (get_args): a better way to handle GNU and non-GNU getopts without strdup-ing the getopt string. 2001-07-04 Erez Zadok * amd/info_ldap.c (amu_ldap_rebind): The first time you called amu_ldap_init, aldh->ldap is not set. So when amu_ldap_rebind is called, this function is absolutely sure to return 0. Then amu_ldap_init return 0 without having opened any LDAP connection. This is not the correct behavior. (get_ldap_timestamp, amu_ldap_search): error to free an object ("entry") that is automatically freed by the library. Patch from Sebastien Bahloul . 2001-07-19 Ion Badulescu * AUTHORS (variables): added Philippe Troin * Makefile.am (EXTRA_DIST): added bootstrap * include/am_compat.h (xfs_args_t): define as u_int if the filesystem is supported but we can't autodetect the type for xfs_args_t. This allows Linux to mount xfs filesystems. 2001-07-12 Philippe Troin * doc/am-utils.texi: Added @dircategory Administration. 2001-07-12 Philippe Troin * aux/macros/with_addon.m4: Created. Wrapper around AC_ARG_WITH with only the `yes' and `no' as possible answers. * configure.in: Added support for disabling LDAP and HESIOD even if the supporting libraries are found. * Makefile.am (EXTRA_DIST_AUX): Added with_addon.m4 macro file. 2001-07-12 Philippe Troin * include/am_compat.h: Removed forced definition of MNTTAB_OPT_DEV if MNT2_GEN_OPT_NODEV was found. Actually, the dev= (SVR4) options and the linux nodev options are different beasts. * conf/mount/mount_linux.c (opt_map): Removed the MNTTAB_OPT_DEV entry (not really necessary on linux). 2001-07-12 Philippe Troin * amd/get_args.c (get_args): Prepend "+" to the getopt string if HAVE_GNU_GETOPT to avoid getting all options (even the ones after the first non-option argument) slurped in by GNU getopt. * aux/macros/check_gnu_getopt.m4: Created. Defines HAVE_GNU_GETOPT if GNU/glibc getopt implementation is detected. * configure.in: Added call to AC_CHECK_GNU_GETOPT. * acconfig.h: Document HAVE_GNU_GETOPT. * Makefile.am (EXTRA_DIST_AUX): Added check_gnu_getopt.m4 macro file. 2001-06-25 Erez Zadok * LSM.am-utils, NEWS, README.y2k, ChangeLog: make sure all am-utils URL references use www.am-utils.org, not the columbia URL. 2001-06-08 Erez Zadok * conf/transp/transp_sockets.c (create_nfs_service): cast to u_long to ensure clean compile on freebsd5 and bsdi2. 2001-05-23 Ion Badulescu WARNING: WORK IN PROGRESS It works for me on Linux (both autofs and nfs mounts), for nfs and link, but I won't make any guarantees outside those. * amd/mntfs.c (find_mntfs): reuse the mntfs only if both the mount point and the device/fileserver are the same. This is an important change of philosophy, watch out for memory leaks! * amd/map.c (get_ap_child): helper function for amfs_auto_lookuppn, creates a new am_node for key fname, inits it, and inserts it into all necessary structures * amd/amfs_auto.c (free_continuation): free unused mntfs's; don't free any of the removed fields (amfs_auto_lookuppn, amfs_auto_bgmount): split lookuppn into three subfunctions, including some code stolen from bgmount; lookuppn now generates an array of possible mntfs to try mounting, and bgmount will actually try to mount each of them. (amfs_auto_lookuppn[123]): the three new subfunctions for lookuppn (amfs_parse_defaults): new helper function for lookuppn 2001-05-19 Erez Zadok * conf/mount/mount_linux.c: typo: added comma after '0' element. 2001-05-19 Ion Badulescu * conf/autofs/autofs_linux.c (AUTOFS_MAX_VERSION): allow using autofs-v4 again (autofs_get_opts): don't pass pgrp, the kernel will get it automatically anyway, not to mention that we were passing bogus data if amd was not daemonized. * conf/mount/mount_linux.c (linux_nfs_error): don't special case the 0 result, just put it into the translation list 2001-05-19 Ion Badulescu * conf/mount/mount_linux.c (linux_nfs_error): don't report success (0) as error (NE_IO)! 2001-05-18 Ion Badulescu * amd/amfs_host.c (amfs_host_mount): don't fail the mount if at least one share is already mounted 2001-05-17 Ion Badulescu * libamu/util.c (str3cat): updated comment * include/am_utils.h: added VLOOK_LOOKUP and FS_DIRECT * conf/autofs/autofs_linux.c (autofs_get_fh): removed obsolete comment (autofs_mounted): disable autofs support for host f/s if version < 4 (create_autofs_service): turn on FS_MKMNT on auto f/s if using autofs (autofs_umount_succeeded): use rmdirs instead of rmdir (autofs_mount_failed): ditto * amd/opts.c (expand_op): align the debugging messages * amd/map.c (mount_auto_node): use am_node *mp instead of casting the void *arg; update the comment * amd/autil.c (am_mounted): check the FS_DIRECT flag instead of comparing to &amfs_direct_ops (mount_node): ifs_mount doesn't exist, make note of it in the comment * amd/amfs_direct.c (amfs_direct_ops): added FS_DIRECT to fs_flags * amd/amfs_auto.c (amfs_auto_mount): removed the autofs hack to create the mountpoint directory for auto f/s; it is now handled in autofs_linux.c (amfs_auto_bgmount): renamed the mpe parameter to mp_error; renamed dont_retry to retry and reverted its meaning as well; moved the mp variable up one scope and made use of it throughout the function; (amfs_auto_readdir): whitespace (amfs_auto_readdir_browsable): whitespace, also some debugging * amd/am_ops.c (vops): updated a comment * .cvsignore: added A.i386-pc-linux-rh7.[01] 2001-05-01 Ion Badulescu * conf/mount/mount_linux.c: fixed stupid error in the linux nfs_errormap[], which was mapping ENOENT to success!!! 2001-04-28 Ion Badulescu * BUGS: added info about the direct mount problems on Linux and about the kernel patches on www.am-utils.org. * conf/autofs/autofs_solaris_v2_v3.c (autofs_unmount_2_req): removed obsolete comment * amd/autil.c (forcibly_timeout_mp): always log a message when the forced unmount request is ignored (mf_mounted): don't lstat unless this is an autofs mount point, lest we deadlock * amd/amfs_auto.c (amfs_auto_bgmount): don't gratuitously add MFF_MKMNT to the flags, it causes deadlocks later on when unmounting 2001-04-14 Erez Zadok * COPYING: update copyright year * amd/amfs_auto.c, amd/amfs_host.c, amd/amfs_nfsx.c, amd/amfs_toplvl.c, amd/amfs_union.c, amd/conf.c, amd/info_nis.c, amd/info_nisplus.c, amd/mapc.c, amd/nfs_subr.c, amd/ops_nfs.c, amd/rpc_fwd.c, amd/srvr_amfs_auto.c, amd/srvr_nfs.c, conf/autofs/autofs_solaris_v1.c, conf/mtab/mtab_file.c, conf/mtab/mtab_isc3.c, conf/mtab/mtab_svr4.c, conf/transp/transp_sockets.c, conf/transp/transp_tli.c, libamu/mount_fs.c, libamu/mtab.c: rewritten various dlog/plog messages for clarity, to avoid duplication, to better recognize what the message means and where it ran, and to fix typos. * amd/nfs_subr.c (nfsproc_lookup_2_svc): moved trace message of function's name to the beginning of the function, before any other messages are logged. 2001-04-14 Ion Badulescu * conf/mount/mount_linux.c (do_mount_linux): removed plog() of binary data 2001-04-05 Ion Badulescu * include/am_defs.h: define NFSCLIENT, NFS, PCFS, LOFS, RFS, MSDOSFS, MFS and CD9660 to 1, so that both #if FOO and #ifdef FOO work (needed for MacOS X); removed duplicate definition of NFS. 2001-03-29 Ion Badulescu * amd/amd.h, amd/amfs_auto.c, amd/conf.c, doc/am-utils.texi, scripts/amd.conf-sample, scripts/amd.conf.5: renamed selectors_on_default to selectors_in_defaults, kept the former as a deprecated option; renamed CFM_ENABLE_DEFAULT_SELECTORS to CFM_SELECTORS_IN_DEFAULTS; renamed gopt_selectors_on_default() to gopt_selectors_in_defaults() 2001-03-19 Ion Badulescu * amd/amfs_toplvl.c, amd/amfs_auto.c, amd/srvr_nfs.c, include/am_utils.h: compile fixes for --enable-debug=no 2001-03-15 Ion Badulescu * NEWS: updated * README.autofs: updated * conf/mount/mount_linux.c (linux_version_code): export the fn * conf/nfs_prot/nfs_prot_linux.h: ditto * conf/autofs/autofs_linux.c (create_autofs_service): verify the kernel version here, and turn off bind_works if the kernel is older than 2.4.0. (autofs_link_mount): don't touch bind_works here, it's useless b/c we're in a child process; remove the mountpoint directory if the bind mount fails * amd/opts.c (eval_fs_opts): changed some annoying debugging plogs into dlogs * conf/autofs/autofs_linux.c (autofs_link_mount): zero out the mntent struct before initializing it 2001-03-14 Ion Badulescu * conf/mount/mount_linux.c (parse_opts): added support for lofs (mount_linux): support lofs through bind mounts and/or FiST lofs * scripts/ctl-hlfsd.in: search for /var/spool/mail in addition to /var/mail and /usr/spool/mail * conf/nfs_prot/nfs_prot_linux.h (MS_BIND): add define for it, if kernel is newer than 2.4.0 (MNTTYPE_LOFS): ditto * conf/autofs/autofs_solaris_v2_v3.c (autofs_link_umount): new stub (autofs_lookup_failed): removed stub * conf/autofs/autofs_linux.c (autofs_lookup_failed): moved up in the file, made static; (autofs_link_mount): activate MNT2_GEN_OPT_BIND code; use stat() and friends to determine if bind mounts can be used and to trigger further cascading mounts; return proper error codes (autofs_link_umount): distinguish between symlinks and bind mounts and handle both correctly (autofs_umount_succeeded): remove call to autofs_link_umount() * amd/map.c (umount_exported): try to unmount all mount points on an autofs filesystem; this isn't really needed and will be removed when we start handling restarting autofs mounts * amd/amfs_link.c (amfs_link_[u]mount): call autofs_link_[u]mount, if necessary * amd/amfs_auto.c (amfs_auto_bgmount): fixed a bug that was causing the wrong mntfs to be selected when using autofs; removed call to autofs_link_mount() (moved where it belongs, in amfs_link.c) * amd/amfs_link.c: added FS_MBACKGROUND to fs flags -- cleaner solution is needed, because background mounting is only necessary for linux autofs + bind mounts * amd/amd.h: removed prototype for autofs_lookup_failed (internal static function for linux autofs); added prototype for autofs_link_umount * configure.in: bump up library patchlevel 2001-02-28 Ion Badulescu * aux/macros/check_mount_trap.m4, aux/macros/check_nfs_fh_dref.m4, aux/macros/check_nfs_prot_headers.m4, aux/macros/type_recvfrom_fromlen.m4, aux/macros/type_yp_order_outorder.m4: Fixed newer freebsd's fh type, expanded more aix3, osf2, hpux9 to aix[1-3], osf[1-3] and hpux[6-9]. 2001-02-28 Erez Zadok * check_mount_style.m4, check_mount_trap.m4, check_network_transport_type.m4, check_nfs_fh_dref.m4, check_nfs_prot_headers.m4, check_nfs_sa_dref.m4, check_nfs_socket_connection.m4, os_cflags.m4, type_yp_order_outorder.m4: small fixes to Ion's cleanup, and more cleanup (use [[0-1]] instead of M4 changequote commands). * Makefile.am: removed unused conf/trap/trap_hpux11.h 2001-02-27 Ion Badulescu * aux/macros/check_network_transport_type.m4, aux/macros/check_mount_style.m4, aux/macros/check_mount_trap.m4, aux/macros/check_network_transport_type.m4, aux/macros/check_nfs_fh_dref.m4, aux/macros/check_nfs_prot_headers.m4, aux/macros/check_nfs_sa_dref.m4, aux/macros/check_nfs_socket_connection.m4, aux/macros/os_cflags.m4, aux/macros/type_auth_create_gidlist.m4, aux/macros/type_recvfrom_fromlen.m4, aux/macros/type_yp_order_outorder.m4: Reworked the scripts, so that a new _unknown_ version of a known OS will use the option for the newest _known_ version of that OS. For example, when freebsd6 comes out, it will use the stuff for freebsd5, not the stuff for freebsd2. This makes configure more likely to succeed on new systems/versions. * Makefile.am (EXTRA_DIST_AUX): added check_autofs_style.m4 (grr) 2001-02-24 Erez Zadok * Makefile.am (install-snapshot): use a different symlink target for the experimental snapshots. 2001-02-23 Erez Zadok * Makefile.am (EXTRA_DIST_CONF): include nfs_prot_darwin.h in distributions. 2001-02-22 Erez Zadok * released snapshot am-utils-6.1a3 * amd/Makefile.am (EXTRA_amd_SOURCES): don't forget to distribute get_args.c 2001-02-21 Erez Zadok * libamu/mtab.c: added the functions hasmnteq and haseq to ease checks for non-numeric values in opt=value strings. Recoded hasmntval to qualify input as numeric, allow hex and octal strings on rhs of =, and log when the value is missing or invalid. * conf/mount/mount_linux.c: revised mount_linux to use new hasmnteq function to extract type of non-nfs mounts, and added a log message to catch possible failure of strdup. * amd/am_ops.c: revised merge_ops to use new haseq function * amd/srvr_nfs.c: revised find_nfs_srvr to use hasmnteq to discover protocol setting. * include/am_utils.h: added function prototypes for hasmnteq and haseq 2001-02-19 Ion Badulescu * include/mount_headers2.h (_LINUX_NFS3_H): define it, to avoid pulling in unwanted declarations from 2.2.19pre and 2.4.1ac * include/am_defs.h (_LINUX_NFS3_H): ditto * conf/nfs_prot/nfs_prot_linux.h: whitespace, comments 2001-02-19 Erez Zadok * aux/macros/check_fs_mntent.m4 (ac_safe): remove debugging "echo" command. 2001-02-18 Erez Zadok * aux/macros/mount_headers.m4, include/mount_headers[12].h: split mount_headers.h in two because one relative header (nfs_prot.h) file cannot be included inside another from the start directory of the first (it's relative to the directory of the first). 2001-02-09 Ion Badulescu * AUTHORS: added Ahmon Dancy * (all): added Darwin/Rhapsody/Apple OS X support from Ahmon Dancy * aux/macros/mount_headers.m4: moved all the C code into a separate file, include/mount_headers.h; the effect is that configure goes down in size by a factor of 2.5! * include/mount_headers.h: new file, with C code from aux/macros/mount_headers.m4 2001-02-01 Ion Badulescu * conf/mount/mount_linux.c: made linux_nfs_error() more robust. 2001-02-01 Erez Zadok * released snapshot am-utils-6.1a2 * updated ltmain.sh and ltconfig from latest stable version of libtool-1.3.5 2001-02-01 Ion Badulescu * conf/nfs_prot/nfs_prot_linux.h (nfs_error): moved the definition of nfs_error here, from mount_linux.c, so that it can actually be used. * conf/mount/mount_linux.c: added unused errno 41 to the nfs_errormap array, lest the following errno's get shifted up by one! Sat Jan 13 00:04:38 2001 Rainer Orth * amd/amd.h (autofs_lookuppn): Fixup whitespace. * amd/amfs_auto.c (amfs_auto_bgmount): Likewise. * amd/amfs_error.c: (amfs_error_match): Likewise. * amd/amfs_host.c (fetch_fhandle): Fixup whitespace. Remove unnecessary temporary variable. * amd/info_file.c (read_line): Likewise. (search_or_reload_file): Likewise. * amd/info_ldap.c (get_ldap_timestamp): Likewise. * amd/map.c (get_root_ap): Likewise. * amd/nfs_prot_svc.c: Likewise. * amd/ops_TEMPLATE.c (foofs_match, foofs_lookuppn, foofs_readlink, foofs_ffserver): Likewise. * amd/ops_autofs.c (autofs_bgmount): Likewise. * amd/ops_lofs.c (lofs_match): Likewise. * amd/ops_nfs.c (got_nfs_fh): Fixup whitespace. * amd/ops_xfs.c (xfs_match): Likewise. * amd/srvr_amfs_auto.c (srvrlog): Line break. * amd/srvr_nfs.c (got_portmap, call_portmap, nfs_pinged, nfs_srvr_port): Fixup whitespace. * conf/nfs_prot/nfs_prot_bsdi2.h: Likewise. * conf/nfs_prot/nfs_prot_hpux.h: Likewise. * conf/nfs_prot/nfs_prot_hpux11.h: Likewise. * conf/nfs_prot/nfs_prot_irix5.h: Likewise. * conf/nfs_prot/nfs_prot_irix6.h: Likewise. * conf/nfs_prot/nfs_prot_nextstep.h: Likewise. * conf/nfs_prot/nfs_prot_osf2.h: Likewise. * conf/nfs_prot/nfs_prot_osf4.h: Likewise. * conf/nfs_prot/nfs_prot_osf5_1.h: Likewise. * conf/nfs_prot/nfs_prot_sunos3.h: Likewise. * conf/nfs_prot/nfs_prot_sunos4.h: Likewise. * conf/nfs_prot/nfs_prot_ultrix.h: Likewise. * conf/transp/transp_tli.c (get_mount_client): Likewise. * hlfsd/nfs_prot_svc.c: Likewise. * include/am_defs.h (sys_errlist): Likewise. * include/am_utils.h (am_get_progname, am_get_hostname, amq_program_1): Likewise. (nfsxprt): Moved declaration. Fri Jan 12 23:31:45 2001 Rainer Orth Removed support for amq -M. * acconfig.h (ENABLE_AMQ_MOUNT): Removed. * aux/macros/opt_amq_mount.m4: Removed. * Makefile.am (EXTRA_DIST_AUX): Don't distribute opt_amq_mount.m4. * configure.in (AC_OPT_AMQ_MOUNT): Removed invocation. * amd/amq_subr.c (ok_security, amqproc_mount_1_svc): Removed. * amd/amq_svc.c (amq_program_1): Removed amq -M support. * amq/amq.c (mount_map): Removed. (main): Removed -M option handling. Removed transport-type specific CLIENT creation. (get_secure_amd_client, amq_bind_resv_port, privsock): Removed. * amq/amq.8: Removed -M documentation. * doc/am-utils.texi (Top-level Filesystem): Removed amq -M reference, but retain comment on mount -t amd. (Controlling Amd): Likewise. * tasks: Removed this task. Fri Jan 12 23:18:26 2001 Rainer Orth * conf/autofs/autofs_*.c: Bump copyright year to 2001. * hlfsd/hlfsd.h (HLFSD_VERSION): Likewise. * aux/macros/check_autofs_style.m4: Renamed solaris[12] styles to solaris_v1, solaris_v2_v3 to reflect that these are AutoFS protocol version numbers, not solaris versions. * conf/autofs/autofs_solaris[12].[ch]: Renamed to autofs_solaris_{v1, 2_v3}.[ch] to reflect this. * Makefile.am (EXTRA_DIST_CONF): Likewise. * aux/macros/check_autofs_style.m4: Use solaris2 style for both versions 2 and 3 of the AutoFS protocol. Handle missing AUTOFS_POSTUNMOUNT, AUTOFS_POSTMOUNT (unnecessary with Solaris 8 mntfs). * conf/autofs/autofs_solaris2.c (xdr_postumntreq, xdr_postumntres, xdr_postmountreq, xdr_postmountres, autofs_postunmount_2_req, autofs_postmount_2_req ): Don't define for version 3. (autofs_program_2): Don't handle AUTOFS_POSTUNMOUNT, AUTOFS_POSTMOUNT if missing. * conf/nfs_prot/nfs_prot_sunos5_8.h: Enable AutoFS support. * aux/macros/check_autofs_style.m4: Use empty autofs_default.[ch] files on systems without existing autofs port. * conf/autofs/autofs_default.[ch]: New files, empty. * Makefile.am (EXTRA_DIST_CONF): Distribute them. * INSTALL: With this change, Solaris 8 and Tru64 5.1 compile and link. 2001-01-12 Erez Zadok * Makefile.am (EXTRA_DIST): distribute new LDAP files. * README.ldap, ldap-id.txt, ldap-id.ms: LDAP status information, proposed Schema, and internet draft. Fri Jan 12 22:27:07 2001 Rainer Orth * Support Tru64 UNIX V5.1: * conf/nfs_prot/nfs_prot_osf5_1.h: New file. * Makefile.am (EXTRA_DIST_CONF): Distribute it. * aux/macros/check_nfs_prot_headers.m4: Tru64 UNIX V5.1 has AutoFS, need to disable it until a port exists. * INSTALL, doc/am-utils.texi (Supported Platforms): Mention new minor port. 2001-01-09 Erez Zadok * ALL: bump copyright year to 2001. 2001-01-05 Erez Zadok * acconfig.h: correct comments for NODEV/NONDEV mount options Fri Jan 5 05:12:02 2001 Erez Zadok * libamu/xdr_func.c: removed ugly casts to "groups*", now that irix6's nfs_prot.h is fixed. * conf/nfs_prot/nfs_prot_irix6.h: copied relevant parts of here so we don't have to include this header. 2001-01-04 Erez Zadok * conf/nfs_prot/nfs_prot_irix6.h: redefine "groups" typedef to struct groups, not the pointer to this struct. * include/am_xdr_func.h: prototype should take "groups *" as 2nd arg. * libamu/xdr_func.c (xdr_groupnode, xdr_exportnode): change casting of second arg of xdr_groups to "groups *". It's only needed for irix6, due to problems with xdr_groups on that platform. (xdr_groups): prototype should take "groups *" as 2nd arg. * conf/nfs_prot/nfs_prot_aix*.h: correct xdr_groups extern definition. Report from Ahmon Dancy . 2000-12-06 Ion Badulescu * include/am_defs.h: force non-inclusion of via * conf/autofs/autofs_linux.c (autofs_mounted): rename AUTOFS_MIN_PROTO_VERSION to AUTOFS_MIN_VERSION (leftover from previous commit) * configure.in: fixed libtool version 2000-12-02 Ion Badulescu * doc/am-utils.texi (opts Option): document lock/nolock 2000-12-02 Ion Badulescu * conf/autofs/autofs_linux.h: added struct autofs_pending_mount; modified autofs_fh_t to have a linked list of autofs_pending_mount; added some support for autofs4 * conf/autofs/autofs_linux.c: use a linked list for pending request, to allow for handling multiple simultaneous request; incipient non-functional support for autofs4; incipient non-functional support for bind-mounting * amd/amd.c (main): print a warning if PROCLOCK is requested but the O/S doesn't support it * libamu/mount_fs.c (mnt_flags): allow the use of the "nolock" option * include/am_defs.h: don't include on a glibc2 system; include if it exists, instead of * include/am_compat.h: define the "nolock" mnttab option if the NONLM NFS mount option is defined * acconfig.h: added MNT2_NFS_OPT_NONLM, MNT2_GEN_OPT_BIND * configure.in: added detection of the NONLM Linux NFS mount option; added a clarification for the library versioning rules and increased the minor level; added detection of and the MS_BIND generic mount option 2000-11-29 Ion Badulescu * Enabled Solaris 2.7 autofs support (tested, works) * Updated NEWS, README.autofs * Updated Makefile's, make dist is now fixed * Fixed potential memory leak in map.c * Fixed autofs style detection for solaris 2.[67] * Added a few casts in autofs_solaris2.c, needed on Solaris 2.7 2000-11-28 Ion Badulescu More Solaris 2.[67] work in progress: * changed the API for the mount/umount methods: fmount/fumount are gone, and mount/umount now take two arguments (am_node and mntfs) * changed the semantics of the MFF_AUTOFS flag: MFF_AUTOFS now means the mntfs is a filesystem of type autofs, and AMF_AUTOFS means the am_node is a node on a filesystem of type autofs. * renamed nfs_program_2_transp to current_transp so it can be used with autofs * renamed quick_reply() to nfs_quick_reply() * added two more autofs methods: autofs_umount_failed() and autofs_compute_mount_flags() -- it turns out that on sol2.6 the autofs mounts MUST be overlay'ed * moved the autofs_mount_succeeded() into am_mounted() * made amd *not* timeout autofs mounts -- the kernel will do it for us * store dev and rdev of a mounted filesystem in the mntfs structure, to help autofs * moved the rmdirs() call from uninit_mntfs() to am_umounted(), to prevent deadlocking with autofs * amd/Makefile.am: shuffled things around to make update_build_version be the last thing that runs 2000-11-27 Ion Badulescu * split amd/ops_autofs.c into conf/autofs/autofs_.c files and made configure create a symlink to the appropriate one * moved the xdr autofs functions from libamu/xdr_func.c into the system-specific conf/autofs/autofs*.c * added some more experimental code to the sol2.6 autofs support, but it's by no means functional 2000-11-27 Ion Badulescu * libamu/wire.c (getwire_lookup): truncate the hostname to MAXHOSTNAMELEN characters. 2000-11-26 Erez Zadok * include/am_utils.h (MAXHOSTNAMELEN): if not defined, set this to 256 bytes, not 64. Suggestion form Kris Kennaway . 2000-11-26 Erez Zadok * configure.in (AC_CHECK_MNT2_NFS_OPTS): check for NFS mount options kerb, rdirplus, readdirsize, and xlatecookie (NetBSD-1.5K). * acconfig.h: recognize NFS mount options rdirplus, readdirsize, and xlatecookie (NetBSD-1.5K) 2000-11-24 Erez Zadok * amd/srvr_nfs.c: comment on NFS proto search order. * libamu/xutil.c (real_plog): don't try to write the last byte of the fmt buf. security suggtion from NetBSD: Thomas Klausner 2000-11-22 Ion Badulescu * amd/amfs_auto.c (amfs_auto_bgmount): removed the initialization of fattr.na_fileid, it is now done in map.c when the map is initialized * amd/map.c (init_map): initialize fattr.na_fileid to am_gen, not to 0, to avoid cache aliasing problems on Linux (and to follow the NFS spec!) 2000-11-22 Thomas Klausner * libamu/mount_fs.c (mount_fs): avoid using extra limited-size buf (security) * libamu/xutil.c, fsinfo/fsinfo.h, include/am_utils.h: use __attribute__, __format__, and __printf__ for GCC string auditing. * wire-test/wire-test.8: this is not a section 8L man page. * libamu/xutil.c (expand_error): don't use sys_nerr on systems that support strerror(). (dplog): fmt is const (plog): fmt is const (real_plog): fmt is const. use new expand_error function with its new return value. be more careful about running off the end of char[] fixed size buffers. * libamu/wire.c (getwire): fix alignment error on alpha using an extra automatic storage variable ifrpool. * hlfsd/hlfsd.c (fatal): use proper printf style to plog. * fsinfo/fsinfo.c (find_username): getlogin() returns a const. * fsinfo/fsi_util.c (error, lerror, lwarning, fatal, log): use vfprintf. * fsinfo/fsi_lex.l (yyerror): use vfprintf. * fixmount/fixmount.8: this is not a section 8L man page. * doc/am-utils.texi (Hesiod maps): fixed typo. * amd/sched.c (do_task_notify): typo in comment. * amd/opts.c (expand_op): expand_error[] is a const char *. * amd/amd.c (main): use proper printf style to plog. 2000-11-22 Erez Zadok * libamu/mount_fs.c (mnt_flags, compute_nfs_args): recognize proplist mnttab flag. Bug fix from Wolfram Klaus . 2000-11-19 Erez Zadok * updated config.guess, config.sub, and doc/texinfo.tex from mirrors * Makefile.am (update): proper updating of config.* and texinfo from mirrors. * aux/macros/check_nfs_prot_headers.m4: newer netbsd systems reports their system name as "netbsdelf" in config.guess. 2000-11-13 Erez Zadok * doc/am-utils.texi (opts Option): document new mount option "proplist" * include/am_compat.h: define amd mount option "proplist" if the system doesn't recognize it, but the NFS bit flag exists. * configure.in, acconfig.h: recognize/support "proplist" NFS mount option in Amd, useful under DU-4.0 to process ACLs over NFS mounts. 2000-11-10 Ion Badulescu * conf/mount/mount_linux.c (mount_linux): removed unnecessary rsize/wsize defaults -- performance killers on 2.2.18+ and 2.4.0+ 2000-10-16 Erez Zadok * scripts/am-eject.in: accept "cdrom" and "floppy" as arguments. 2000-11-05 Ion Badulescu Too many changes to list them here. Here's a high level description: * Forward-ported the Linux fixes from 6.0.5pre * Got rid of a mountain of #ifdef DEBUG, replaced with smart header-file #ifdef's * and, the grand finale: initial Solaris 2.6 autofs support. Compiles, mounts, gets requests; all the infrastructure is in place to actually implement the calls. Linux autofs might be a bit broken, but only compile-time so it'll be easy to fix. 2000-11-01 Erez Zadok * MIRRORS (Note): added a mirror at ufl.edu 2000-10-11 Erez Zadok * amq/amq.8: synchronize Amq's options with reality * amq/amq.c (main): synchronize Amq's usage() string with reality 2000-10-10 Erez Zadok * scripts/ctl-amd.in: add targets condrestart (redhat) and reload. 2000-10-04 Erez Zadok * scripts/lostaltmail.in (vrfy_user): ensure that MAILDIR is defined. 2000-09-18 Erez Zadok * amd/opts.c (backslash): Bell char (ASCII 007) should be \g, not \a. 2000-09-17 Erez Zadok * include/am_utils.h: removed unused field opt_autopref * amd/opts.c: removed unused variable $autopref 2000-09-05 Erez Zadok * conf/mtab/mtab_svr4.c (lockfile): function not needed unless MOUNT_TABLE_ON_FILE is defined. mtlckname static var is onlyneeded if MOUNT_TABLE_ON_FILE. (update_mnttab_fields): only needed if MOUNT_TABLE_ON_FILE. 2000-09-03 Erez Zadok * buildall (Usage): typo in usage string 2000-08-25 Erez Zadok * conf/mount/mount_linux.c (mount_linux): MNT2_NFS_OPT_VER3 may is no defined on older Linux systems (kernel 2.0.36) 2000-08-19 Erez Zadok * scripts/amd.conf.5: correct swapped descriptions for ldap_base and ldap_hostports. * doc/am-utils.texi: correct swapped descriptions for ldap_base and ldap_hostports. * scripts/amd.conf-sample: swap examples for ldap_base and ldap_hostports. 2000-08-13 Erez Zadok * scripts/amd.conf-sample: -O is CLI equivalent to "os" amd.conf parameter 2000-07-30 Erez Zadok * scripts/amd.conf-sample (nfs_retransmit_counter): correct meaning and use of parameter 2000-07-23 Erez Zadok * doc/am-utils.texi: updated URLs to www.am-utils.org. 2000-07-04 Erez Zadok * doc/am-utils.texi (Supported Platforms): document osf4.0f 2000-06-19 Erez Zadok * doc/am-utils.texi (dollar Selector Variable): document ${dollar}. * amd/opts.c: special new variable ${dollar} which expands into a literal '$' sign. Otherwise there is no way to include a literal dollar symbol in an amd map. 2000-06-11 Ion Badulescu * amd/opts.c (eval_selectors): don't deref opt after it's been XFREE'd 2000-06-11 Erez Zadok * amd/opts.c: move mount_type expansion until later in the list, so common variable are "hit" first. 2000-06-11 Ion Badulescu * amd/opts.c (split_opts, eval_selectors): split old function eval_opts into two, one that only splits non-selectors and assigns the values to fs_static, and one that only evaluates selectors; also simplified the rather obfuscated logic inside these functions (expand_op): made it take a char * instead of a structure from which it was using only one field (a char *). Also now returns a char * instead of modifying said structure in place (expand_opts): deal with the change above (expand_selectors): renamed from expand_key (expand_options): new function, expands non-selectors; it's the complement of expand_selectors, both of which are just wrappers around expand_op() (eval_fs_opts): use the new split_opts, eval_selectors to allow using options (like ${rhost}) in selectors 2000-06-11 Ion Badulescu * config.guess.long: munge config.guess' output so that intel linux appears as i386-pc-linux Fri Jun 9 16:06:56 2000 Erez Zadok * conf/nfs_prot/nfs_prot_bsdi2.h: getifaddrs() on bsdi2 is broken. Don't use it. 2000-06-09 Rainer Orth * amd/mapc.c (maptypes): Change default allocation mode to MAPC_INC where reload support is missing to avoid warning in mapc_create(). 2000-06-09 Erez Zadok * conf/nfs_prot/nfs_prot_sunos5_5.h: turn off autofs support for solaris 2.5 until a full port can be done. 2000-06-07 Erez Zadok * Makefile.am, aux/GNUmakefile: fix maintainer rules to update config.* and texinfo.tex files. * amd/nfs_subr.c (nfsproc_getattr_2_svc): Don't conditionalize the mtime update of the symlinks on the SYMTTL option, but rather delay unmount of what was looked up using am_timeo_w. Patch from Nick Williams . As Nick says "Basically: during unmount, increment the parent dir's mtime (fixes people doing amq -u). During stat, increase the TTL (to fix bad-luck timeouts), but leave the mtime alone." (nfsproc_lookup_2_svc, nfsproc_readlink_2_svc, unlink_or_rmdir, nfsproc_readdir_2_svc): correctly update d_drops stats for amq -s. Patch from Nick Williams . * amd/map.c (unmount_mp): update mtime of amd symlink to further reduce the chances of race conditions between unmounting and looking up an entry again. Patch from Nick Williams . * README: updated instructions * bootstrap: remove log file before existing 2000-06-06 Erez Zadok * configure.in: no longer using aux/ subdir. don't force autoconf 2.14. comment out (but leave explanation) everything that's needed for autoconf 2.14, so for now it works with autoconf-2.13, but the code is ready for 2.14 when it is released. Similar changes to make code work with automake-1.4, until the next release comes out. * libamu/Makefile.am: include definitions that are required in automake 1.4, but won't be necessary when the next release of automake comes out (see XXX comments). * cache_check_dynamic.m4, check_checkmount_style.m4, check_mnttab_style.m4, check_mount_style.m4, check_network_transport_type.m4, check_nfs_prot_headers.m4, check_umount_style.m4: use symlink creation code that works for both autoconf 2.13 and 2.14 (when the latter comes out). * bootstrap: new script for maintainers to run to update autoconf, automake, and libtool related files. Has the same effect as "buildall -K". * removed dependencies on CVS versions of autoconf, automake, and libtool, especially the modified automake I had. This is so that maintainers could built the auto* files out of the latest released GNU autoconf, automake, and libtool. However, without my nice patches to automake, many files that used to live in the aux/ subdir now were moved to the top level source directory: acconfig.h, acinclude.m4, aclocal.m4, aux_conf.h.in, config.guess, config.guess.long, config.h.in, config.sub, configure.in, depcomp, install-sh, ltconfig, ltmain.sh, missing, and mkinstalldirs. Also texinfo.tex and mdate-sh moved from aux/ dir to doc/ dir. 2000-06-05 Erez Zadok * cvs-server.txt: instructions for maintainers to access the CVS server for am-utils. 2000-06-03 Ion Badulescu * amd/restart.c (restart): grr.. passing around initialized structures is *really* bad habit. memset(mo, 0) so at least we can test for NULL pointers... 2000-06-02 Erez Zadok * amd/am_ops.c (ops_match): changed XLOG_USER messages about merging addopts options to the more appropriate XLOG_INFO. Patch submitted by Tom Schmidt . * config.{guess,sub}: make sure chmod'ed a+rx. Updated from latest GNU copies. 2000-05-30 Ion Badulescu * aux/configure.in: bump up the version to 6.1a2 2000-05-29 Ion Badulescu * released snapshot am-utils-6.1a1 2000-05-29 Ion Badulescu * amd/ops_autofs.c (autofs_mounted): retrieve the autofs protocol version and store it in the fh (autofs_get_opts): support protocol version 4 * amd/mntfs.c (uninit_mntfs): clear the autofs fh pointer after releasing it * conf/transp/transp_sockets.c (amu_svc_getcaller): cast result of svc_getcaller() to sockaddr_in, to appease glibc 2.2 * amd/amfs_auto.c (amfs_auto_bgmount): if the filesystem wants autofs handling and the parent is already handled by autofs, handle this filesystem as well (amfs_auto_mount): create the mountpoint for an autofs mount (amfs_auto_umount): do a real UMOUNT_FS() call for autofs mounts * include/am_utils.h (FS_AUTOFS): new flag signalling that the filesystem wants autofs handling; toplvl, auto, host and direct have this flag, at least for now 2000-05-28 Erez Zadok * doc/am-utils.texi (Network Filesystem Group): minor typos 2000-05-28 Ion Badulescu * amd/autil.c (am_unmounted): check mp->am_parent before dereferencing * amd/srvr_nfs.c (find_nfs_srvr): if NFS_SCALEDOWN, force version=2 and proto=udp and try again * amd/ops_nfs.c (prime_nfs_fhandle_cache): take an explicit mntfs instead of a voidp; handle the NFS_SCALEDOWN case by removing the cached server entry and re-querying the server * amd/amfs_toplvl.c (amfs_toplvl_mount): removed ugly if statement, assign mnttype from the fs-specific mf_ops->fs_type instead * amd/amfs_nfsx.c (amfs_nfsx_init): call fs_init() only if it's defined; (amfs_nfsx_remount): removed superfluous check for fmount_fs -- it always exists (amfs_nfsx_umount): removed the hacked am_node -- umounted() now takes an mntfs; call umounted() only if it's defined * amd/amfs_auto.c: removed amfs_auto_umounted and moved its functionality into am_umounted(). (amfs_auto_cont): Linux hack: if we got an EINVAL, mark the mntfs as needing an "NFS scaledown" and retry the operation * amd/amfs_*.c: changed all fmount/fumount functions to mount/umount and made them take an am_node instead of an mntfs. This is a first step towards an amfs/ops API separation. * amd/{amfs,ops}_*.c: changed the umounted() function to take an mntfs instead of an am_node 2000-05-28 Ion Badulescu * amd/amfs_toplvl.c (mount_amfs_toplvl): init error to 0 to shut up gcc * aux/macros/check_hide_mount_type.m4: revert to the 6.0 version which always defines HIDE_MOUNT_TYPE * amd/ops_autofs.c (autofs_mounted): remove MFF_AUTOFS initialization -- now done in init_mntfs() * amd/mntfs.c (init_mntfs): init mf_flags to MFF_AUTOFS if we are mounting an autofs-style map * amd/*.c: use the MFF_AUTOFS flag instead of doing a costly STREQ * amd/amfs_toplvl.c (mount_amfs_toplvl): MTYPE_TYPE is not necessarily a string type, so handle the nfs/autofs separation differently * amd/amfs_auto.c (amfs_auto_bgmount): removed initialization of opt_mount_type (now done in ops_match()) * amd/am_ops.c (ops_match): need to initialize opt_mount_type if it's not initialized yet 2000-05-27 Erez Zadok * libamu/wire.c (getwire_lookup): handle calling irs_gen_acc with one or two arguments (bsdi3 vs. bsdi4) 2000-05-27 Ion Badulescu * libamu/xutil.c (amu_release_controlling_tty): removed an unused variable from the previous patch 2000-05-26 Ion Badulescu * aux/macros/check_autofs_style.m4: fixed substitution for default case * libamu/xutil.c (amu_release_controlling_tty): close standard file descriptors, re-open them as /dev/null * include/am_defs.h: don't try to include both and , it really doesn't work 2000-05-16 Ion Badulescu * hlfsd/stubs.c (nfsproc_lookup_2_svc): added code to update mtime on lookup if MNT2_NFS_OPT_SYMTTL is not defined (copied from getattr). This fixes the problem introduced by the Linux nfsv3 patches. 2000-05-12 Ion Badulescu * Makefile.am (EXTRA_DIST_CONF): added conf/autofs/autofs_linux.h 2000-05-10 Ion Badulescu * amd/ops_autofs.c (autofs_handle_fdset): call autofs_lookup_failed instead of autofs_mount_failed, if the name is not in the map (autofs_umount_{succeeded,failed}): pass the actual mount point, not its parent, as it's needed for clean-up; * amd/autil.c (am_unmounted): notify autofs that the umount succeeded * amd/amfs_link.c (amfs_link_[u]mount): autofs link notification moved elsewhere 2000-05-09 Ion Badulescu * amd/amfs_auto.c (amfs_auto_bgmount): initialize opt_mount_type if necessary; (amfs_auto_mounted): test if opt_mount_type is NULL first (amfs_auto_mount): revert earlier change * amd/ops_autofs.c (autofs_mount_failed): remove autofs directory if mount failed 2000-05-09 Ion Badulescu * amd/ops_autofs.c (autofs_link_mount): use am_link as target * amd/map.c (unmount_mp): release file handle for autofs f/s about to be unmounted; this leak was preventing the unmount altogether * amd/amfs_auto.c (amfs_auto_umount): removed autofs-specific code, was broken (amfs_auto_bgmount): nfs mounts + sublinks is a valid combination, handle it 2000-05-07 Ion Badulescu * Merged changes from stable branch 2000-04-30 Erez Zadok * include/am_defs.h, aux/macros/mount_headers.m4, aux/macros/try_compile_anyfs.m4: include linux/kdev_t.h and linux/list.h before including linux/fs.h, and define __KERNEL__ for those two headers. All of this to get a couple of definitions that are needed in the new struct vfsmount. * aux/configure.in: look for and . * include/am_defs.h, aux/macros/mount_headers.m4: avoid conflicts between linux/in.h. and netinet/in.h (linux-2.3.99-pre6), by defining _LINUX_IN_H so it doesn't get included. 2000-04-03 Erez Zadok * minor new ports: i686-pc-linux-gnu-rh6.2, i386-unknown-freebsdelf3.4, i586-pc-linux-gnu-rh6.2. 2000-04-03 Erez Zadok * aux/acconfig.h: move all #undef macros above @TOP@, so they can be recognized by pickier autoconf. 2000-04-03 Erez Zadok * aux/macros/cache_check_dynamic.m4 (ac_tmp): use correct echo -n or \c. 2000-03-25 Erez Zadok * include/am_defs.h: ditto * aux/macros/{mount_headers,try_compile_anyfs}.m4: force non-inclusion of . Breaks build on newer 2.3 kernels. 2000-02-26 Erez Zadok * doc/am-utils.texi (Amq -w option): document new amq -w option. * amq/amq.8: document new amq -w option. * amq/amq.c: disable last remains of insecure amq -M code. (main): add amq -H option to show usage. (main): new amq -w option, translates getpwd() into an amd path. 2000-02-25 Ion Badulescu * libamu/util.c (get_server_pid): new function * hlfsd/hlfsd.c (main): make use of HIDE_MOUNT_TYPE * conf/transp/transp_sockets.c: removed create_autofs_service * conf/mount/mount_linux.c: added autofs mount options; split mount_linux into two functions, itself and do_mount_linux * aux/macros/check_hide_mount_type.m4: better failover * aux/configure.in: changed version to 6.1a1; added AC_CHECK_AUTOFS_STYLE * aux/aux_conf.h.in: added @am_utils_autofs_style@ * amd/opts.c: added "mount_type" option * amd/ops_autofs.c: ifdef-ed out solaris code; moved all autofs variables in here; split create_autofs_service into sun and linux specific functions * amd/nfs_start.c: removed autofs-specific variables * amd/map.c (get_root_nfs_fh): renamed root_fh to get_root_nfs_fh (get_root_ap): renamed root_ap to get_root_ap * amd/amfs_toplvl.c (amfs_toplvl_ops): replaced amfs_toplvl_mounted with amfs_auto_mounted (mount_amfs_toplvl): moved code around, added autofs handling (amfs_toplvl_mounted): removed * amd/amfs_nfsl.c (amfs_nfsl_ops): removed amfs_auto_fu?mount, replaced with amfs_nfsl_u?mount * amd/amfs_linkx.c (amfs_linkx_ops): removed amfs_auto_fumount, replaced with amfs_link_umount * amd/amfs_link.c (amfs_link_ops): removed amfs_auto_fu?mount, replaced with amfs_link_u?mount * amd/amfs_direct.c (amfs_direct_ops): changed "mounted" function from amfs_toplvl_mounted to amfs_auto_mounted * all: added autofs hooks throughout the code * amd/am_ops.c (vops): autofs_ops doesn't belong in here, removed * README.autofs: linux status update 2000-02-24 Erez Zadok * minor new port: alphaev6-dec-osf5.0 * doc/am-utils.texi (Supported Platforms): hpux-11 supports NFSv3, but only for UDP. * released snapshot am-utils-6.0.4s3 * conf/nfs_prot/nfs_prot_hpux11.h: support NFSv3 in hpux-11. Note that hpux-11 NFSv3 supports UDP only, and trying TCP locks up the kernel! Must set nfs_proto=udp in amd.conf [global]. * aux/config.guess.long: set and export PATH separately. DU5 /bin/sh doesn't like setting it on the command line in a back-tick'ed `script`. 2000-02-24 Ion Badulescu * Makefile.am: removed struct_nfs_mount_data.m4 * aux/macros/struct_nfs_mount_data.m4: deleted * aux/acconfig.h: removed definition for HAVE_NFS_MOUNT_DATA * aux/configure.in: removed check for struct nfs_mount_data 2000-02-24 Ion Badulescu * amd/amfs_auto.c (amfs_auto_bgmount): changed log message to avoid having 'failed' in a message not indicating a failure (amfs_auto_lookuppn): ditto * amd/ops_autofs.c (autofs_bgmount): ditto (autofs_lookuppn): ditto 2000-02-24 Erez Zadok * added .cvsignore files into the CVS repository. * remove files which can be regenerated: .in, configure, some files in aux/, and more. 2000-02-20 Erez Zadok * doc/am-utils.texi (nfs_vers/nfs_proto): description of two parameters was reversed. Reported by Paul Jenner . 2000-02-16 Erez Zadok * released snapshot am-utils-6.0.4s2 * amd/mntfs.c (realloc_mntfs): don't fallback on certain ops such as inherit, error, and toplvl (failover code). * amd/conf.c (gopt_nfs_vers, gopt_nfs_proto): two new (documented) global options in amd.conf: one to set the NFS version globally (i.e., nfs_vers=2), and one to set the NFS protocol globally (i.e., nfs_proto=udp). * amd/mntfs.c (realloc_mntfs): attempt to fix the failover code, so when a matching mount entry failed, try the next one. 2000-02-15 Erez Zadok * amd/amfs_auto.c: a new debug option "readdir" to trace the progress of the browsable_dirs code. * conf/mount/mount_linux.c (mount_linux): ensure that the new linux NFSv3 code works for v2-only machines. 2000-02-14 Erez Zadok * aux/configure.in: cleanup unused dnl entries. * conf/mount/mount_linux.c (parse_opts): typo: check for string equality, not string inequality for pcfs and cdfs. * aux/acconfig.h: look for MNT2_NFS_OPT_INTR as well. * libamu/mount_fs.c (compute_mount_flags): check for INTR and NOINTR options as well (intr was never passed to linux mount syscall). 2000-02-10 Erez Zadok * released snapshot am-utils-6.0.4s1 * aux/GNUmakefile: buildall -k (for maintainers) temporarily now ignores autoconf warnings: "The macro `AC_OUTPUT_COMMANDS' is obsolete". It is harmless but annoying, and will be fixed when autoconf and automake in their respective CVS trees are working and in sync again. * scripts/amd.conf.5: document -D hrtime,xdrtrace * all man pages: update copyright to 2000. * doc/am-utils.texi: update copyright to 2000. Wed Feb 9 14:22:31 2000 Rainer Orth * include/am_utils.h (D_XDRTRACE): Define. (D_TEST): Disable here. * libamu/xutil.c (dbg_opt): Handle it. * doc/am-utils.texi (-D-Option): Document it. * libamu/xdr_func.c: Use it instead of D_TRACE. * include/am_utils.h (D_HRTIME): Define. * doc/am-utils.texi (-D-Option): Document it. * libamu/xutil.c (show_time_host_and_name): Print high-resolution timestamp if available and activated. * aux/configure.in (clock_gettime): Check for it in -lrt and -lposix4. * hlfsd/hlfsd.c (mnttab_file_name): Initialize to MNTTAB_FILE_NAME if defined, even for some systems with in kernel mount tables. 2000-02-08 Ion Badulescu * aux/macros/mount_headers.m4: remove #if 0 around linux/nfs.h to allow compiles against libc5 * aux/macros/check_mnttab_type.m4: avoid detecting nfs3 under linux when the kernel doesn't support it * include/am_compat.h: add workaround for linux efs 2000-02-08 Erez Zadok * aux/configure.in: test for ANSI C compiler (before AC_C_CONST). Comment out unused AC_STRUCT_ST_RDEV (which is obsolete anyway). 2000-02-07 Ion Badulescu * libamu/mount_fs.c (compute_nfs_args): turn on VER3 option for nfs (linux NFSv3). * include/am_defs.h: avoid reinclusion of some header files under linux. * conf/nfs_prot/nfs_prot_linux.h: support NFSv3. * conf/mount/mount_linux.c (mount_linux): support nfs mount (implementation) version 4 for NFSv3. * aux/macros/try_compile_nfs.m4: use AC_MOUNT_HEADERS. * aux/macros/mount_headers.m4: don't include (may need to fix the code on other linux machines). * aux/macros/check_mnttab_type.m4 (ac_safe): ditto. * aux/macros/check_fs_mntent.m4 (ac_safe): check for nfs3 option under linux (depends on ac_cv variable, is that a good idea?) * added NFSv3 support for linux * aux/{configure.in,acconfig.h}: new option ver3 * aux/macros/mount_headers.m4: commented out inclusion of linux/fs.h, it's not needed on rh61 (and actually generates conflicts), we should see if it's still needed on libc5 systems * aux/macros/try_compile_nfs.m4: use AC_MOUNT_HEADERS rather than try to have its own (out of date) list of headers and ifdef's and ... 2000-02-07 Erez Zadok ******************************************************************* *** Released am-utils-6.0.3 *** ******************************************************************* 2000-02-06 Erez Zadok * conf/mount/mount_default.c: dummy empty file to work around a limitation of automake (it looks for LIBBOBJS in aclocal.m4 and processes them even if they are optional, enclosed in if/else). 2000-01-29 Erez Zadok * released snapshot am-utils-6.0.3s5 2000-01-25 Erez Zadok * update to use latest version of autoconf, automake, and libtool. * aux/GNUmakefile (depcomp): "make update" should also update the depcomp script. * Makefile.am (EXTRA_DIST_AUX): include depcomp in distribution. * aux/configure.in: use renamed AC_CHECK_AMU_FS. * aux/macros/check_amu_fs.m4: renamed macro name and file name to say AMU_FS, not AM_FS. * aux/acconfig.h: renamed HAVE_AM_FS_* to HAVE_AMU_FS_* because latest version of autoconf doesn't handle it (bug in 2.14a) * aux/configure.in: require version 2.14 of autoconf. * amd/mapc.c (mapc_reload_map): more fixes from Nick Williams. * doc/am-utils.texi (Automount Filesystem): document type:=auto map browsability option. * amd/mapc.c (make_entry_chain): patch from Steven Danz to allow browsable auto maps. 2000-01-24 Erez Zadok * released snapshot am-utils-6.0.3s4 * amd/mapc.c (mapc_reload_map): fixes to sync maps even if they are set to mapcache:=sync. Fix from Nick Williams . 2000-01-20 Erez Zadok * released snapshot am-utils-6.0.3s3 * minor port to i386-unknown-netbsd1.4.1 * amd/nfs_subr.c (nfsproc_getattr_2_svc): patch from Nick Williams to fix (or reduce the incidence of) stale file handles when doing rapid mounts and umounts in succession such as "ls /vol/foo ; amq -u /vol/foo ; ls /vol/foo" 2000-01-18 Erez Zadok * minor port to i386-pc-bsdi4.1. 2000-01-13 Erez Zadok * libamu/wire.c (getwire_lookup): pass NULL as conf_file (2nd) argument to irs_gen_acc(), which was changed in bsdi 4.1. 2000-01-12 Erez Zadok * amd/get_args.c (get_args): don't use MNTTAB_FILE_NAME for systems with in-kernel mount tables unless this macro is defined (Solaris 8). 2000-01-01 Erez Zadok * ALL: bump copyright year to 2000. 1999-12-16 Erez Zadok * conf/mount/mount_svr4.c (mount_svr4): optionstr exists on solaris 7, but should not be used unless MAX_MNTOPT_STR also exists (solaris 8). * doc/am-utils.texi (opts Option): document new mount option: optionstr. Fri Dec 10 01:31:53 1999 Rainer Orth * conf/trap/trap_svr4.h (MOUNT_TRAP): Pass mount option string to mount_svr4(). (mount_svr4): Adapt prototype. * conf/mount/mount_svr4.c (mount_svr4): Pass them to kernel so they are evaluated and show up in Solaris 8 in-kernel mnttab. * aux/configure.in: Check for new Solaris 8 MS_OPTIONSTR mount(2) option. * aux/acconfig.h (MNT2_GEN_OPT_OPTIONSTR): Provide template. 1999-12-10 Erez Zadok * released snapshot am-utils-6.0.3s2 1999-12-09 Erez Zadok * doc/am-utils.texi (opts Option): document noexec and nomnttab (new to Solaris 8). * Makefile.am (EXTRA_DIST_CONF): include nfs_prot_sunos5_8.h in distribution. * applied fixes from Rainer Orth for Solaris 8. * libamu/wire.c (getwire): increment the cp pointer in the loop body, because the ioctl() inside the "for" loop will overwrite the ifr structure, thus not detecting all of the interfaces. Bug reported and fixed by Amitha Perera . Thu Dec 9 19:09:38 1999 Rainer Orth * conf/mtab/mtab_svr4.c (unlockmnttab, lockmnttab): No-ops if MOUNT_TABLE_ON_FILE. * amd/get_args.c (get_args): Initialize mnttab_file_name even for in-kernel mount table. conf/mtab/mtab_svr4.c (read_mtab) depends on a non-NULL value. * amd/info_ldap.c (get_ldap_timestamp): Don't peek into opaque LDAP structure to get error code, but use it directly. (amu_ldap_search): Likewise. * conf/nfs_prot/nfs_prot_sunos5_7.h: Rip superfluous and wrong ldap support. * conf/nfs_prot/nfs_prot_sunos5_8.h: Likewise. * conf/nfs_prot/nfs_prot_sunos5_8.h: New file, doesn't typedef nfsstat, already in . * aux/macros/check_nfs_prot_headers.m4: Use it for all Solaris versions beyond 7. Allow for micro versions of SunOS 5.[67]. * aux/configure.in: Check for new Solaris 8 Beta Refresh MS_NOMNTTAB mount(2) option. * aux/macros/check_mnttab_location.m4: Use it to test for mntfs-based in-kernel mnttab. * aux/macros/os_cflags.m4: Treat Solaris 8 and higher like 2.6/7. * aux/macros/check_fs_headers.m4: Revert test for duplicate objects. * aux/macros/check_fs_mntent.m4: Likewise * aux/macros/HEADER: Fixed typo. * include/am_defs.h: Likewise. 1999-12-01 Erez Zadok * aux/macros/*.m4: prepare for hpux-12 (assume same as hpux-11) 1999-11-16 Erez Zadok * BUGS: document glibc-2.1 nis file descriptor leak in yp_bind. * amd/info_ldap.c (string2he): updated function which does not corrupt strings when called more than once. Patch from JOHANN.PFEFFERL.JP@germany.agfa.com. 1999-11-15 Erez Zadok * MIRRORS (Asia): two new mirrors in Japan. 1999-11-10 Erez Zadok * doc/am-utils.texi: document new variables for ${uid} and ${gid}. * amd/nfs_subr.c (nfsproc_lookup_2_svc): find the uid/gid of the last lookup from the RPC credentials. * aux/configure.in: upped version-info to 4:0:2 because I've added a new interface to libamu. * libamu/misc_rpc.c (getcreds): moved function from hlfsd to here, so it can be used by amd. * amd/opts.c: new variables ${uid} and ${gid}. 1999-10-15 Erez Zadok * scripts/ctl-amd.in: add "status" command that tells you if amd is running on not (same output as RedHat scripts). Added start_msg and stop_msg targets as they are used on HPUX. reported by Jon Peatfield . 1999-10-13 Erez Zadok * released snapshot am-utils-6.0.3s1 1999-10-12 Erez Zadok * amd/amd.c (main): On AIX you must lower the stack size using ulimit() before calling plock. Otherwise plock will reserve a lot of memory space based on your maximum stack size limit. Since it is not easily possible to tell what should the limit be, I print a warning before calling plock(). See the manual pages for ulimit(1,3,4) on your AIX system. * include/am_defs.h: define default extern for vsnprintf() * aux/configure.in: check for extern definition for vsnprintf() 1999-10-08 Erez Zadok * amd/amfs_auto.c (amfs_auto_bgmount): patch from Nick Williams . SYMPTOMS: 'occasionally' sublinks do not point to the correct location, but to the top level of the mountpoint and an (error-hook) is seen being mounted in the log file. This causes things to Go Wrong(TM). CAUSE: When evaluating two locations which are requested 'practically simultaneously', and the two locations resolve to the same NFS mountpoint (but different sublinks), the later request will be "deferred" and retried after wakeup when the first mount succeeds. To do this, it rewinds the options location string to re-evaluate the location when the mount is retried. However, it shouldn't rewind the options for two reasons: (a) the semantics of the map language say you shouldn't and (b) the NFS mount reference is not reset at the same time, meaning that on the retry it will have an options structure out-of-sync with the mount structure. The "shortcut" code when retrying the mount sees the mount structure is already filled in and does not fully evaluate the options structure.... so if the first location is not the one which ties in with the mountpoint (see ordering in the recreate-by), you're now well messed up. * BUGS: mention aix4.3 plock() bug (memory usage blows up and plock fails) 1999-10-07 Erez Zadok * aux/GNUmakefile: certain files should be copied if they are newer, not also if they are bigger: install-sh, ltconfig, ltmain.sh, mdate-sh, missing, mkinstalldirs, and texinfo.tex. * minor new port: i586-pc-linux-gnu-rh6.1 (RedHat Linux 6.1) 1999-10-05 Erez Zadok * aux/macros/check_nfs_prot_headers.m4: prepare for OSF-5. * aux/macros/check_nfs_fh_dref.m4: prepare for Tru64, aka OSF-5. 1999-09-30 Erez Zadok ******************************************************************* *** Released am-utils-6.0.2 *** ******************************************************************* 1999-09-27 Erez Zadok * conf/mount/mount_linux.c (mount_linux): print the updated mount flags. * doc/am-utils.texi: document $full_os and $vendor. * scripts/amd.conf-sample: examples of $full_os and $vendor. * scripts/amd.conf.5: document $full_os and $vendor. * amd/conf.c: add support for $full_os and $vendor. 1999-09-26 Erez Zadok * doc/am-utils.texi (netgrp Selector Function): don't give examples with old single '=' assignment variable. Use foo:=bar. * amd/amfs_auto.c (amfs_auto_bgmount): corectly indent long comment describing this complex function. * doc/Makefile.am (alldocs): do install-ps last (because distiller is slow) and install-html next to last (because texi2html is also slow). * amd/amd.8: Major fixes to the description of the option -t timeout.retransmit. * doc/am-utils.texi: better description of "trace" debug option. amd -H (not -v) shows log_options and debug_options. Major fixes to the description of amd -t timeout.retransmit, and the amd.conf parameters nfs_retransmit_counter and nfs_retry_interval. * scripts/amd.conf.5: better description of "trace" debug option. amd -H (not -v) shows log_options and debug_options. Major fixes to the description of the parameters nfs_retransmit_counter and nfs_retry_interval. 1999-09-25 Erez Zadok * doc/am-utils.texi (Automount Filesystem): cache:= is not a mount option, but a mount map option. * libamu/xutil.c (switch_to_logfile): log the name of the log file we switched into, after the log file had been [re]opened. 1999-09-24 Erez Zadok * amd/mapc.c (mapc_reload_map): count and show the number of times a map was reloaded. Only reload a map if its modify-time was updated. But amq -f forced a reload no matter what. * amd/amd.h: new flag to struct mnt_map to count number of times a map was reloaded. * amd/mapc.c (mapc_reload_map): attempt to reload the map without losing current data by reloading into a temp copy, and switching the hashes round only if the reload was successful. Patch from Jon Peatfield . (mapc_sync): mapc_reload_map() always succeeds. 1999-09-22 Erez Zadok * amd/info_ldap.c (amu_ldap_rebind): don't busy-loop trying to rebind to an LDAP server forever. Try up to 10 times. * fsinfo/fsi_lex.l (yyerror): rework code that will never happen * released snapshot am-utils-6.0.2s2 * aux/configure.in: bumped library version-info to 3:2:1, since some libamu code got changed. * libamu/xutil.c (real_plog): use vsnprintf, not vsprintf, which is better and more secure. Fix from "David O'Brien" . * aux/configure.in: check for vsnprintf. 1999-09-21 Erez Zadok * aux/macros/linux_headers.m4: use AC_MSG_ERROR. * aux/macros/opt_{cppflags,ldflags,libs,amu_cflags}.m4: the ARG is not optional. Make sure ARG is supplied else flag an error. 1999-09-18 Erez Zadok * minor port i386-unknown-freebsdelf3.3 * released snapshot am-utils-6.0.2s1 1999-09-17 Erez Zadok * aux/configure.in (AC_CHECK_FUNCS): check for getitimer(). * include/am_defs.h: extern definition for getitimer(). * aux/configure.in: use AC_CHECK_EXTERNS. Look for getitimer() extern. * aux/macros/check_extern.m4: define a simple AC_CHECK_EXTERNS that calls AC_CHECK_EXTERN in a loop. This saves repeated code in configure. * aux/macros/type_auth_create_gidlist.m4: AIX 4.x systems use 'int' as the 5th arg to authunix_create(). * aux/macros/type_recvfrom_fromlen.m4: all AIX 4.x systems use a size_t for the 6th arg of recvfrom(). * aux/macros/os_cflags.m4: define _XOPEN_EXTENDED_SOURCE for aix4.x systems. * libamu/mount_fs.c (print_nfs_args): cast some values to int, to avoid gcc -Wall errors. * scripts/expn.in: use sockaddr_in(), not pack() to correctly fill in a struct sockaddr_in. On Solaris x86 hosts, using pack() results in byte-misaligned values. Bug fix from Jeffrey C Honig . * libamu/mount_fs.c (compute_automounter_mount_flags): turn on automntfs (ignore on bsdi-4.1) flag. (compute_automounter_nfs_args): ditto. * aux/acconfig.h: add new flag for automntfs (ignore) * aux/configure.in: check for new automntfs flag (bsdi-4.1). 1999-09-14 Erez Zadok * MIRRORS: added new site in Germany. Updated status of umn.edu and ferginc.com, who may no longer be mirroring am-utils. 1999-09-08 Erez Zadok ******************************************************************* *** Released am-utils-6.0.1 *** ******************************************************************* 1999-09-08 Erez Zadok * aux/macros/mount_headers.m4: bsdi-2.1 needs MAXQUOTAS and struct netexport defined. * aux/macros/try_compile_anyfs.m4: bsdi-2.1 needs MAXQUOTAS and struct netexport defined. 1999-09-07 Erez Zadok * aux/macros/check_field.m4 (ac_upcase_var_name): include so we can detect fields within struct ifaddrs. * libamu/wire.c (getwire): bsdi-2.1 uses a second arg to getifaddrs() and struct ifaddrs has no ifa_next field. * aux/configure.in: check if 'struct ifaddrs' has a field ifa_next. * include/amq_defs.h (AMQ_STRLEN): double size of amq string length to 2048 bytes. * conf/nfs_prot/nfs_prot_netbsd1_4.h: include several more nfs header files and ufs/ufs/ufsmount.h. Bug reported by christos@zoulas.com. * aux/macros/try_compile_anyfs.m4: include . Bug reported by christos@zoulas.com. * aux/macros/mount_headers.m4: include 1999-09-06 Erez Zadok * libamu/xutil.c (expand_error): use strerror if available instead of sys_errlist. Bug reported by christos@zoulas.com. * hlfsd/hlfsd.c (fatal): use strerror if available instead of sys_errlist. * amq/amq.c (show_mi): use strerror if available instead of sys_errlist. * aux/macros/check_nfs_prot_headers.m4: make sure netbsd1.4 nfs_prot header is used for any future (1.5 etc.) netbsd systems. * amq/pawd.c (find_mt): check for type nfsl as well. Fix from "Andrew J. Korty" 1999-08-29 Erez Zadok * doc/am-utils.texi (Supported Platforms): updates for redhat systems. * INSTALL: updates for redhat systems. * libamu/wire.c (getwire_lookup): spell "succeeded" correctly 1999-08-28 Erez Zadok * scripts/ctl-amd.in: sleep 1 second between killing amd and restarting it, because amq may respond that amd is down, where in fact it is still trying to unmount itself after unmapping itself from the portmapper. * aux/config.guess.long: new script to print long version of config.guess output. * buildall (host_alias): use long version of config.guess. 1999-08-27 Erez Zadok * scripts/ctl-{amd,hlfsd}.in: update RH tags for start/stop scripts. 1999-08-24 Erez Zadok * released snapshot am-utils-6.0.1s11 * libamu/xutil.c (expand_error): make sure expanding the string with textual version of errno doesn't overrun the 1024 bytes buffer. (real_plog): null terminate msg, just in case. * amq/amq.c (main): don't getopt -M option and don't process it unless ENABLE_AMQ_MOUNT is on. * amd/amq_svc.c (amq_program_1): all code that relates to amq -M is conditional on #ifdef ENABLE_AMQ_MOUNT. * amd/amq_subr.c: remove amqproc_mount_1_svc() function invoked when amq -M code is disabled. Not taking any chances. 1999-08-23 Erez Zadok * released snapshot am-utils-6.0.1s10 Sun Aug 22 16:18:59 1999 Erez Zadok * libamu/wire.c (getwire_lookup): if getnetbyaddr failed (e.g., on 128.59.16.0), try to shift the network out of zeros (e.g., 128.59.16) and try again. Irix 6.4 requires short network numbers. 1999-08-22 Erez Zadok * libamu/wire.c (getwire_lookup): correctly compute subnet using netmask. * libamu/mount_fs.c (compute_automounter_nfs_args): require that Amd's own NFS mounts use reserved ports (if possible). IP packet security fix from Jeffrey C Honig . * conf/transp/transp_tli.c (create_autofs_service): use correct autofs_port. IP packet security fix from Jeffrey C Honig . * conf/transp/transp_sockets.c (bindnfs_port): remove unnecessary function. IP packet security fix from Jeffrey C Honig . (create_nfs_service): use bind_resv_port() directly. ensure that privileged ports are used. IP packet security fix from Jeffrey C Honig . * amd/nfs_prot_svc.c (nfs_program_2): verify that requests come from reserved ports and from a local IP address. IP packet security fix from Jeffrey C Honig . * amd/amq_subr.c (ok_security): use IPPORT_RESERVED, instead of hard-coded 1024. IP packet security fix from Jeffrey C Honig . (amqproc_mount_1_svc): provide information on the caller making an amq -M request. IP packet security fix from Jeffrey C Honig . * amd/map.c (free_map_if_success): If the program doing an unmount of a program filesystem fails, amd tries to interpret the return code as an errno. Fix from Jeffrey C Honig . * amd/info_nis.c (determine_nis_domain): don't always print warning about NIS domain name not being set, even if NIS is not in use. 1999-08-21 Erez Zadok * amd/info_ldap.c (get_ldap_timestamp): initialize variable err. (amu_ldap_search): initialize variable err. 1999-08-16 Erez Zadok * libamu/wire.c: written using getifaddrs() for BSD systems, contributed by BSDI, Jeffrey C Honig ). 1999-08-15 Erez Zadok * include/am_utils.h (SALLOC): a simple macro to allocate N bytes. * aux/configure.in: check for irs.h and ifaddrs.h. Increase libamu.so --version-info to 3:1:1 since we've changed the source code for the library. Check for getifaddrs() function. 1999-08-14 Erez Zadok * libamu/mount_fs.c (print_nfs_args): print fields namlen and bsize if they exist. * conf/mount/mount_linux.c (mount_linux): set nfs_args_t->namlen and ->bsize fields correctly, if those fields exist. This is a bug in that amd neglected to set these fields, but told the kernel it is mounting the nfs_args_t structure using mount version 3 (which requires both bsize and namlen fields). * aux/configure.in: test for two new nfs_args_t fields (used on newer linux with mount versions 2 and 3): bsize and namlen. * doc/am-utils.texi (netgrpd Selector Function): document new selector function. * amd/opts.c (f_netgrpd): new amd map function netgrpd(ARG) to test if the current host (fully-qualified name) is in the ARG host netgroup. The netgrp() function uses the short form of a host name. Patch from Christophe Kalt . * doc/am-utils.texi (automount2amd): document new script. * scripts/Makefile.am: create, install, and distribute automount2amd perl script and its man page. * scripts/automount2amd.8: new man page for automount2amd. * scripts/automount2amd.in: new file, contributed a in 1993 by Mike Walker . Fixed to use addopts for any automount map options specified. 1999-08-09 Erez Zadok * released snapshot am-utils-6.0.1s9 1999-08-09 Erez Zadok * amd/amfs_auto.c (DOT_DOT_COOKIE): set the NFS cookie of '..' to 1. (amfs_auto_readdir): use DOT_DOT_COOKIE instead of (u_int)~0. (amfs_auto_readdir_browsable): use DOT_DOT_COOKIE instead of (u_int)~0. * amd/mapc.c (make_entry_chain): NFS cookies should be monotonically increasing, because Linux 2.3 expects that, even though it is not in the spec (RFC-1094) for NFS V2. 1999-08-06 Erez Zadok * aux/macros/check_lib_funcs.m4: removed unused macro. * aux/macros/linux_headers.m4: new macro to ensure that linux kernel headers match running kernel version. * aux/acconfig.h: define HOST_HEADER_VERSION so we can check if amd is configured on linux hosts that run one kernel but have headers for a different version. * amd/info_nis.c (nis_isup, nis_search, nis_init): fixes for the logic which uses nis_isup and has_yp_order. Make sure it is used correctly , esp. for NIS+ in NIS-compatibility mode. Bug fix from Peter Breitenlohner . * include/am_defs.h: fix conflicts on linux 2.2 systems with older libc5. Bug fix from Peter Breitenlohner . * scripts/lostaltmail.in: use sockaddr_in(), not pack() to correctly fill in a struct sockaddr_in. On Solaris x86 hosts, using pack() results in byte-misaligned values. 1999-08-02 Erez Zadok * conf/mtab/mtab_aix.c (mnt_dup): add support for nfs3 mounting, as per Dale Talcott . Also use better macros for case statement. * conf/nfs_prot/nfs_prot_sunos5_7.h: don't include ldap structures unless ldap is actually available. * use updated config.guess and config.sub. Use newer automake that fixes problems with distributing optional libamu files (clnt_sperrno.c, hasmntopt.c, strcasecmp.c, strdup.c, strstr.c, and ualarm.c) 1999-07-19 Erez Zadok * minor port i386-unknown-openbsd2.5 1999-07-17 Erez Zadok * minor ports to freebsdelf 3.[0-2] and 4.0 completed * aux/macros/check_nfs_prot_headers.m4: support freebsdelf * aux/macros/check_nfs_socket_connection.m4: support freebsdelf 1999-06-24 Erez Zadok * released snapshot am-utils-6.0.1s8 1999-06-23 Erez Zadok * include/am_defs.h: avoid various header conflicts on RedHat/Linux 6.0 and kernels 2.2.10 or newer. * aux/configure.in: look for (RedHat/Linux 6.0 and kernel 2.2.10) * amd/amfs_program.c (amfs_program_exec): make sure logfp is initialized dynamically to stderr if needed. * libamu/xutil.c (dplog): make sure logfp is initialized dynamically to stderr if needed. (plog): ditto. * amd/amfs_program.c (amfs_program_exec): set logfp to stderr if not initialized. * libamu/xutil.c: don't initialize logfp statically to stderr, because on RedHat/Linux 6.0 (kernel 2.2.10) stderr can no longer be manipulated like a variable. * include/am_defs.h: avoid more conflicts between and on 2.2 linux kernels. include as needed (RedHat/Linux 6.0) 1999-04-20 Erez Zadok * all Makefile.am: use AMU_NFS_PROT_HEADER (not *_HEADERS) * aux/macros/check_nfs_prot_headers.m4 (AMU_NFS_PROT_HEADER): renamed AC_SUBST name from *_HEADERS to *_HEADER so that automake won't attempt to add it to the header files to distribute. 1999-04-19 Erez Zadok * aux/GNUmakefile: invoke aclocal with new --altdir flag. 1999-04-16 Erez Zadok * minor new port: i386-unknown-netbsd1.4 (ALPHA) * aux/macros/check_field.m4: no need to include and because they are also included from MOUNT_HEADERS. Causes multiple inclusion of unprotected headers on netbsd-1.4_ALPHA. 1999-04-15 Erez Zadok * aux/macros/extern_sys_errlist.m4 (pattern): netbsd-1.4_ALPHA's sys_errlist extern doesn't end with []. * aux/macros/check_nfs_prot_headers.m4: netbsd 1.4 support. 1999-04-11 Erez Zadok * newer automake wants texinfo.tex to be in aux/ not doc/ 1999-03-30 Erez Zadok * amd/conf_parse.y: alloca support. * fsinfo/fsi_gram.y: alloca support. * libamu/Makefile.am (libamu_la_LIBADD): compile alloca.o if needed. * aux/configure.in: test for alloca support. Needed because bison generates parsers that use alloca, and hpux9 does have alloca and its /bin/cc doesn't support it builtin (the way gcc does). * libamu/alloca.c: new file, needed on hpux9 with /bin/cc. Taken verbatim from bison-1.25. * include/am_defs.h: fixed typo #errir -> #error * released snapshot am-utils-6.0.1s7 * README.y2k: more information about am-utils' compatibility, from Paul Balyoz . * scripts/lostaltmail.in (Splice_in_resent_headers): ensure Y2K compliant format. Patch from Paul Balyoz * doc/am-utils.texi (Supported Platforms): hpux10.20 could have nfs v.3 support (with some vendor patches), but it is turned off. * aux/macros/os_cflags.m4: use ansi compiler options on hpux. * conf/nfs_prot/nfs_prot_hpux.h: Turn off NFS V.3 support to avoid confusing am-utils. 10.20 with some patches has incomplete support. Patch from Jon Peatfield . 1999-03-24 Erez Zadok * minor port i386-pc-bsdi4.0.1 1999-03-20 Erez Zadok * doc/am-utils.texi (Supported Platforms): add forgotten listing for powerpc-linux. 1999-03-18 Erez Zadok * scripts/amd.conf.5: fix typo. From Jeffrey C Honig . * doc/am-utils.texi: document iso9660 options norrip, gens, and extatt. (opts Option): documented dumbtimr and noauto options. From Jeffrey C Honig . * include/am_compat.h: define default strings for options norrip, gens, and extatt. * amd/ops_cdfs.c (mount_cdfs): support options norrip, gens, and extatt. * aux/macros/mount_headers.m4: also include as needed. * aux/configure.in: check for isofs mount options for bsdi4: norrip, gens, and extatt. Reported by Jeffrey C Honig . * aux/macros/check_mnt2_cdfs_opt.m4: check for ISOFSMNT_* flags (bsdi4). 1999-03-17 Erez Zadok * conf/nfs_prot/nfs_prot_freebsd3.h: ditto. * conf/nfs_prot/nfs_prot_bsdi3.h: include , for bsdi4, as per Jeffrey C Honig . 1999-03-15 Erez Zadok * get latest copies of config.guess, config.sub, ltconfig, and ltmain.sh from libtool-1.2f. * all Makefile.am: don't use continuation lines (using \) for short lists of files. * libamu/Makefile.am (DISTCLEANFILES): make distclean should remove mountutil.c, mtabutil.c, transputil.c, and umount_fs.c. Reported by Jeffrey C Honig . * fixmount/Makefile.am (DISTCLEANFILES): make distclean should remove checkmount.c. Reported by Jeffrey C Honig . * Makefile.am (DISTCLEANFILES): make distclean should remove amu_nfs_prot.h, config.cache.old, and dbgcf.h. Reported by Jeffrey C Honig . 1999-03-13 Erez Zadok * released snapshot am-utils-6.0.1s6 1999-03-12 Erez Zadok * INSTALL: document freebsdelf. * doc/am-utils.texi (Supported Platforms): document freebsdelf. 1999-03-08 Erez Zadok * minor new ports: i386-unknown-freebsdelf3.1 and i386-unknown-freebsdelf4.0 * aux/macros/check_nfs_prot_headers.m4: freebsd4 support. * aux/macros/check_nfs_socket_connection.m4: freebsd4 support. * aux/macros/check_nfs_fh_dref.m4: freebsd4 support. * amd/opts.c (eval_opts): changed log level of "executing negated..." message from USER to INFO, as per Guntram Wolski . 1999-02-17 Erez Zadok * */Makefile.am (LDADD): force linking against an installed libamu.{a,so}. * doc/am-utils.texi (addopts Option): document remopts interaction with addopts. * amd/am_ops.c (ops_match): if addopts are specified, apply them to the value of remopts as well as opts. * amd/ops_nfs.c (mount_nfs_fh): tell users when remopts are used. 1999-02-05 Erez Zadok * released snapshot am-utils-6.0.1s5 * conf/mount/mount_linux.c (mount_linux): set default nfs_args options for ac{reg,dir}{min,man} as per the mount-2.8a package, but only if noac option was not used. 1999-02-05 Erez Zadok * conf/mount/mount_linux.c (mount_linux): print nfs_args again since it was updated. (mount_linux): use 4KB for NFS rsize/wsize on 2.1.0 linux kernels and newer. Bug was found by Neil Conway 1999-02-04 Erez Zadok * released snapshot am-utils-6.0.1s4 1999-02-03 Erez Zadok * amq/amq.c (main): don't list -M as a valid amq option unless configure'd with --enable-amq-mount. Wed Feb 3 18:11:18 1999 Rainer Orth * amd/nfs_start.c (amd_use_autofs): Define. (mount_automounter): Create autofs service listener only if necessary to avoid unnecessary clashes with e.g. automountd. * amd/amd.h (amd_use_autofs): Declare. * amd/conf.c (gopt_mount_type): Set amd_use_autofs. (ropt_mount_type): Likewise. 1999-02-02 Erez Zadok * aux/macros/check_mnt2_nfs_opt.m4:: ditto * aux/macros/check_mnt2_cdfs_opt.m4: ditto * aux/macros/check_mnt2_gen_opt.m4: ditto * aux/macros/check_mnttab_opt.m4: new macro in this file to loop over AC_CHECK_MNTTAB_OPT. Reduces size of configure script a lot. * conf/nfs_prot/nfs_prot_netbsd1_3.h: include nfs/rpcv2.h, nfs/nfs.h and nfs/nfsmount.h if they exist. Patch from christos@zoulas.com (Christos Zoulas). * amd/info_hesiod.c: some forward declarations. Patch from christos@zoulas.com (Christos Zoulas). 1999-01-28 Erez Zadok * libamu/mount_fs.c (compute_nfs_args): don't turn on/off noconn option if it was already in that state. Patch from David Wolfskill . 1999-01-20 Erez Zadok * aux/configure.in: automake nowadays supports LTLIBOBJS (but not LTALLOCA yet). Substitute value of LIBTOOL_DEPS for libtool rebuild make rules. * Makefile.am: new rules to remake libtool (maintainers only) * amd/amfs_toplvl.c (mount_amfs_toplvl): print generic mount flags if -D trace was used. 1999-01-18 Erez Zadok * buildall: all if statements should have an else clause because of Ultrix's /bin/sh. 1999-01-15 Erez Zadok * amq/amq.c: removed dummy variables. * amq/pawd.c: removed dummy variable.s * fixmount/fixmount.c (usage): removed dummy variables. * fsinfo/fsinfo.c: removed dummy variables. * hlfsd/hlfsd.c: removed dummy variables. * wire-test/wire-test.c: removed dummy variables. * mk-amd-map/mk-amd-map.c: removed dummy variables. * doc/texinfo.tex: updates from GNU mirror. * aux/GNUmakefile (../doc/texinfo.tex): new rule to update doc/texinfo.tex from GNU mirror. * released snapshot am-utils-6.0.1s3 * Makefile.am (install-snapshot): better snapshot and new install-snapshot and test-snapshot rules (maintainer). * amd/info_ldap.c (amu_ldap_init): don't run STREQ if one of the args may be NULL. Some dlog() entries were not enclosed in #ifdef DEBUG. Fix from Bill Paul 1999-01-13 Erez Zadok * check for experimental generic 'ignore' mount flag on freebsd3. * Update library -version-info to 3:0:1 (will result in 2.1.0 .so version, which is backwards compatible with older versions.) Only one new interface was added to libamu. * amd/amfs_toplvl.c (mount_amfs_toplvl): add generic mount flags that are specific to automounter mounts. * aux/configure.in: update libamu.so age and revision since a new interface was added to libamu/mount_fs.c (compute_automounter_mount_flags). * libamu/mount_fs.c (compute_automounter_mount_flags): new function to compute generic mount flags that are specific to mount points only. * aux/{configure.in,acconfig.h}: add support for generic mount entry ignore option. * released snapshot am-utils-6.0.1s2 * amd/info_ldap.c (get_ldap_timestamp): dlog format fixes. * libamu/mount_fs.c (print_nfs_args): solaris 2.7 changed format of knc_semantics from u_long to u_int. * aux/macros/check_mount_style.m4: freebsd3 no longer needs a special mount helper. 1999-01-12 Erez Zadok * aux/macros/check_nfs_prot_headers.m4 (AMU_NFS_PROT_HEADERS): amu_nfs_conf.h should always be found in $top_builddir. Tue Jan 12 00:05:42 1999 Rainer Orth * conf/nfs_prot/nfs_prot_sunos5_7.h (MNTTAB_TYPE_AUTOFS): Undefine to avoid wrong reports from show_fstypes. * conf/nfs_prot/nfs_prot_irix5.h (MNTTAB_TYPE_XFS): Likewise. * conf/nfs_prot/nfs_prot_hpux11.h (MNTTAB_TYPE_NFS3): Likewise. Tue Jan 12 00:05:42 1999 Rainer Orth * BUGS (mips-dec-ultrix4.3): Update Ultrix caveats. Tue Jan 12 00:05:42 1999 Rainer Orth * hlfsd/homedir.c (delay): Cast child to long, adapt format. (hlfsd_getpwent): Likewise for pw_uid. * amd/info_nis.c (nis_init): Cast order to unsigned long, adapt format. * conf/transp/transp_tli.c (amu_clnt_create_best_vers): Cast tv_sec to int to match format. (get_nfs_version): Cast nfs_version, NFS_VERSION to int to match formats. * amd/amfs_program.c (amfs_program_exec): Cast ptr difference to long, adapt format. * include/am_defs.h: Handle __attribute__ if available. From GNU fileutils 4.0 lib/errors.h. Mon Jan 11 13:46:44 1999 Rainer Orth * libamu/mount_fs.c (print_nfs_args): Cast sizeof() to int to match format. * hlfsd/stubs.c (nfsproc_getattr_2_svc): Cast uid, gid to long, adapt format. (nfsproc_lookup_2_svc): Likewise. (nfsproc_readlink_2_svc): Likewise for userid, groupid. * hlfsd/nfs_prot_svc.c (nfs_program_2): Cast args to int to match format. * hlfsd/homedir.c (homedir): Cast uid, child to long, adapt format. * amd/info_hesiod.c (hesiod_search): Cast m, pval, tp to unsigned long, adapt format. * amd/ops_nfs.c (find_nfs_fhandle_cache): Cast fh_wchan to unsigned long, adapt format. (got_nfs_fh): Likewise. (prime_nfs_fhandle_cache): Cast fh_nfs_version to int to match format. (call_mountd): Likewise, mnt_version also. (mount_nfs_fh): Likewise. * amd/ops_autofs.c (autofs_program_1): Cast args to int to match format. (autofs_unmount_1_svc): Cast ur->devid, ur_rdevid, ur->next to unsigned long, adapt formats. (autofs_bgmount): Cast opt_fs to unsigned to, adapt format. (autofs_bgmount): Use long format to match arg. (autofs_lookuppn): Removed superfluous arg. * amd/srvr_nfs.c (start_ping): Cast nfs_version to int to match format. (got_portmap): Likewise for port. (recompute_portmap): Likewise for fs->fs_version, mnt_version. (find_nfs_srvr): Likewise for nfs_version. * amd/sched.c (sched_task): Cast wchan to unsigned long, adapt format. * amd/nfs_start.c (checkup): Cast ptr difference to long, next_mem to unsigned long, adapt format. Cast tvv.tv_sec to int to match format. * amd/nfs_prot_svc.c (nfs_program_2): Cast args to int to match format. * amd/map.c (root_fh): Cast pid to long, adapt format. (timeout_mp): Cast time_t to long, adapt format. * amd/clock.c (reschedule_timeouts): Use long format, cast time_t arg. * amd/amfs_host.c (fetch_fhandle): Cast nfs_version to int to match format. (amfs_host_fmount): Likewise. (amfs_host_umounted): Likewise. Removed superfluous arg. * amd/amfs_auto.c (amfs_auto_bgmount): Cast pointer to unsigned long, adapt format. (amfs_auto_bgmount): Use long format, cast time_t arg. (amfs_auto_lookuppn): Removed superfluous arg. * amd/amd.c (main): Cast geteuid() result to long, adapt format. * conf/transp/transp_sockets.c (get_nfs_version): Cast nfs_version to int to match format. * include/am_utils.h: Declare plog, dplog as printf-like. * conf/mount/mount_irix6.c (mount_irix): Print type as char *. Mon Jan 11 13:46:44 1999 Rainer Orth * amd/info_hesiod.c (hesiod_isup): New function. * amd/mapc.c (maptypes): Add it. 1999-01-10 Erez Zadok * released snapshot am-utils-6.0.1s1 1999-01-09 Erez Zadok * ALL: bump copyright year to 1999. Fri Jan 8 15:24:15 1999 Rainer Orth * aux/macros/check_mtype_type.m4: Ultrix uses an int mount type, too. * aux/macros/check_mtype_printf_type.m4: Adapt corresponding printf type. Fri Jan 8 15:24:15 1999 Rainer Orth * aux/acconfig.h: Removed HAVE_AM_FS_AUTOFS, unused. * conf/nfs_prot/nfs_prot_irix6.h: Likewise. * conf/nfs_prot/nfs_prot_sunos5_6.h: Likewise. * conf/nfs_prot/nfs_prot_sunos5_7.h: Likewise. * Makefile.am (EXTRA_DIST_DIRS): Removed, not needed by current automake. Thu Jan 7 02:55:18 1999 Rainer Orth * aux/configure.in (AM_PROG_YACC): Replaced by AC_PROG_YACC, not in current automake. Thu Jan 7 02:55:18 1999 Rainer Orth * doc/am-utils.texi: Added some missing inter-punctation after @xref, or use @pxref/@ref as appropriate. Spotted by makeinfo from texinfo 3.12b. 1999-01-07 Erez Zadok * doc/texinfo.tex: updated off of latest GNU mirror. 1999-01-04 Erez Zadok * doc/am-utils.texi (Supported Platforms): update platforms that support NFS v.3. Nicer postscript printing on double-sided pages. * amd/info_hesiod.c: add extern definition for hesiod_init() 1999-01-01 Erez Zadok ******************************************************************* *** Released am-utils-6.0 *** ******************************************************************* 1998-12-28 Erez Zadok * conf/nfs_prot/nfs_prot_sunos5_7.h: support ldap in solaris 2.7. 1998-12-27 Erez Zadok * conf/nfs_prot/nfs_prot_bsdi3.h: don't use reserved ports on bsdi4 for NFS V3/nfs mounts. 1998-12-26 Erez Zadok * using latest libtool (1.2e + patches), now supporting shared libraries on many more systems. Also using latest autoconf and automake (unreleased GNU CVS'd versions.) * minor new ports: hppa2.0w-hp-hpux11.00, i386-unknown-netbsd1.3.3, mips-sgi-irix6.5. * fsinfo/fsinfo.h (yywrap): define it for systems (osf4) that have /usr/bin/flex but not libfl. 1998-12-24 Erez Zadok * lots of code cleanup, to make sure libamu.so does not use undefined symbols. Some system's shared libraries cannot handle that. 1998-12-23 Erez Zadok * include/am_defs.h: only defined seteuid extern if function also exists and is not superceded by setresuid (hpux). * amd/ops_autofs.c (autofs_bgmount, autofs_lookuppn): put explicit braces to avoid confusion with nested if-then-else clauses. * aux/config.{sub,status}, aux/{ltmain.sh,ltconfig,mkinstalldirs: updated from latest versions. 1998-12-22 Erez Zadok * minor new port: i386-pc-bsdi4.0 * conf/nfs_prot/nfs_prot_bsdi3.h: add missing hesiod header definitions for bsdi4. * {amd,fsinfo}/Makefile.am: force path to .y/.l files, because some make programs (bsdi4) do not support VPATH correctly. 1998-12-16 Erez Zadok * conf/mount/mount_aix.c: minor code cleanup * aux/configure.in: check for extern definition to xdr_groups. 1998-12-15 Erez Zadok * minor new port: powerpc-ibm-aix4.3.1.0 * aux/macros/*.m4: updates for aix 4.3 1998-12-14 Erez Zadok * minor new port: i386-unknown-openbsd2.4 * aux/configure.in: don't check for xfs on openbsd because openbsd-2.4 introduces a new file system named xfs, but different than Irix's XFS. Sigh. * minor new port: i386-unknown-freebsd2.2.8 1998-12-03 Erez Zadok * amd/amfs_nfsl.c (amfs_nfsl_ffserver): use case insensitive host name match. Bug fix from Douglas K. Rand" . 1998-11-20 Erez Zadok * scripts/ctl-amd.in: wait4amd2die runs in the stop action, to avoid race conditions when shutting down systems running amd. * Makefile.am: add a dist-hook to change modes of the directories in the tar file so they are not world writable. * conf/nfs_prot/nfs_prot_freebsd3.h: turned on NFSv3 support, since it is now finally defined in the header files and (hopefully) stable. * amd/srvr_nfs.c (find_nfs_srvr): allow overriding if nfsv2 option is specified in mount options. freebsd patches from David O'Brien. * amq/amq.c (main), fixmount/fixmount.c (main), hlfsd/hlfsd.c (main), fsinfo/fsinfo.c (fsi_get_args), hlfsd/hlfsd.c (main), amd/get_args.c (get_args): posix: use -1 to check for return from getopt() (not EOF), as per posix. * amd/amq_subr.c (xdr_amq_mount_tree_node): patches from "David O'Brien" , from the FreeBSD source tree. Use real variable whose pointer is on the stack for decoding a long int. 1998-11-11 Erez Zadok * scripts/ctl-{amd,hlfsd}.in: include comments useful for redhat's chkconfig utility. 1998-11-10 Erez Zadok * released snapshot am-utils-6.0b2s3 * conf/transp/transp_sockets.c (create_nfs_service): remove C++ style comments. 1998-11-04 Erez Zadok * released snapshot am-utils-6.0b2s2 * created CVS package * amd/nfs_subr.c (nfsproc_lookup_2_svc): try to avoid a race condition between unmounting and re-mounting an entry, by increasing the ttl of a looked up entry before unmounting it. Patch from Mike Mitchell . * All files: spell comments and strings. 1998-11-03 Erez Zadok * aux/configure.in: look for yp_all in libnsl only if yp_all not already found elsewhere (in libc or other default libraries). This is so RedHat 5.1 systems could find yp functions in libnsl, but also so AIX 4.2.1 will NOT include libnsl, because the latter has broken nis functionality that also exists and works ok in libc. 1998-10-29 Erez Zadok * amd/amd.c (main): bug fix: swapped arguments to kill(2). Fix from Danny Rathjens . 1998-10-28 Erez Zadok * released snapshot am-utils-6.0b2s1 1998-10-27 Erez Zadok * aux/macros/*.m4: support bsdi4 as bsdi3. * aux/macros/os_ldflags.m4: enable detection of LDAP on solaris 2.7 (libraries located in /usr/lib/fn). This is off until Sun includes LDAP header information. 1998-10-20 Erez Zadok ******************************************************************* *** Released am-utils-6.0b1 *** ******************************************************************* 1998-10-18 Erez Zadok * mk-amd-map/mk-amd-map.c (main): use perror not strerror. (main): set return type to int if no ndbm maps. * include/am_defs.h: avoid conflicts with in 2.1 kernels. 1998-10-18 Erez Zadok * A.i386-unknown-netbsd1.3.2/amu_nfs_prot.h: trim down and cleanup for netbsd 1.3.2. 1998-10-17 Erez Zadok * aux/configure.in: check for yp_all in libnsl, b/c redhat 5.1 systems put NIS functions there. * mk-amd-map/mk-amd-map.c: patch from "David O'Brien" merged in. Use POSIX -1 return code from getopt(), not EOF. Use .db extentions for systems that use it, instead of .{pag,dir}. 1998-10-15 Erez Zadok * wire-test/wire-test.c, hlfsd/hlfsd.c, fixmount/fixmount.c, amd/amd.c (main): avoid overrunning hostname buffer. Bug fix from "David O'Brien" . * scripts/amd.conf.5: minor typo reported by "David O'Brien" in .TH section of man page. * amd/info_nis.c (am_yp_all): don't leak key-val entries. Patch from Thomas Richter . 1998-10-12 Erez Zadok * doc/am-utils.texi (Program Filesystem): minor typo fixed as per Andreas Stolcke . * minor new ports: sparc64-unknown-linux-gnu, i386-pc-solaris2.7, and sparc-sun-solaris2.7. * conf/mount/mount_freebsd3.c (mount_freebsd3): freebsd 3.0 is now a 4.4lite kernel, and somethings were removed, such as INITMOUNTNAMES. * amd/ops_autofs.c (autofs_lookuppn): don't leak memory while processing /defaults. Free temporary opts. Patch from dsr@mail.lns.cornell.edu (Daniel S. Riley) * amd/amfs_auto.c (amfs_auto_lookuppn): don't leak memory while processing /defaults. Free temporary opts. Patch from dsr@mail.lns.cornell.edu (Daniel S. Riley) * conf/mtab/mtab_osf.c (read_mtab): patch from dsr@mail.lns.cornell.edu (Daniel S. Riley) not to access uninitialized memory on Digital Unix. 1998-10-09 Erez Zadok * aux/macros/{check_mtype_type,check_mtype_printf_type}.m4: most systems now use "char *" as their mount type. 1998-10-08 Erez Zadok * amd/conf.c (gopt_map_type, ropt_map_type): check if map type exists. * amd/mapc.c (mapc_type_exists): function to test if a map of certain type exists. 1998-10-08 Erez Zadok * aux/macros/{mount_headers,try_compile_anyfs,try_compile_nfs}.m4, include/am_defs.h: Avoid a conflict in definitions of ntohl/htonl in RH-5.1 sparc64 between and (2.1 kernels). 1998-09-28 Erez Zadok * aux/macros/func_bad_yp_all.m4 (ac_cv_func_yp_all_clean): RedHat 5.1 systems with glibc glibc-2.0.7-19 or below leak a UDP socket from yp_all(). 1998-09-25 Erez Zadok * conf/mount/mount_linux.c (parse_opts): check for pcfs support only if autoconfigured. 1998-09-18 Erez Zadok * Makefile.am (EXTRA_DIST): distribute README.yk2 file. * README.y2k: explain y2k compliance status of am-utils. 1998-09-16 Erez Zadok * amd/amfs_host.c (fetch_fhandle, amfs_host_fmount, amfs_host_umounted): clnt_sperrno() may return a const. Sat Aug 8 23:28:32 1998 Erez Zadok * aux/configure.in: check for , as per Christos Zoulas. Turned on checking for mount options: async, synchronous, deadthresh, leasterm, nqnfs, and readahead. * amd/info_nis.c: patch from christos@zoulas.com (Christos Zoulas) to include prototype definition for nis_isup(). Sun Jul 19 18:50:10 1998 Erez Zadok * hlfsd/stubs.c (getcreds): force sscanf arg to u_long. Tue Jul 14 20:34:25 1998 Erez Zadok * released snapshot am-utils-6.0a17s1 Wed Jul 8 21:49:15 1998 Erez Zadok * aux/macros/host_macros.m4: all x86 hosts should have $arch be i386, not i[456]86. Tue Jul 7 18:55:09 1998 Erez Zadok * aux/macros/{mount_headers,try_compile_anyfs,try_compile_nfs}.m4, include/am_defs.h: include before because on redhat 5.1, there is a bug (misuse) of headers in (it defines _LINUX_TYPES_H instead of __KERNEL_STRICT_NAMES). * aux/configure.in: check for because it is need for RedHat 5.1. Wed Jun 17 00:05:33 1998 Erez Zadok * scripts/Makefile.am (EXTRA_DIST): have fixrmtab generated from .in as well, so it doesn't get removed by make clean. Tue Jun 16 22:00:15 1998 Erez Zadok * aux/macros/{check_fs_mntent.m4, check_mnttab_type.m4, check_mount_type.m4}: redhat 5.1 puts some modules in /lib/modules/preferred/. Wed May 13 16:33:57 1998 Erez Zadok * amd/ops_autofs.c (mount_autofs): cast pid to long. Tue Apr 28 15:12:36 1998 Rainer Orth * conf/nfs_prot/nfs_prot/nfs_prot_irix6.h, conf/nfs_prot/nfs_prot_sunos5_6.h: Undef MNTTAB_TYPE_AUTOFS too to avoid amd/am_ops.c (show_fstypes) from erroneously claiming support. Fri Apr 24 23:02:11 1998 Rainer Orth * libamu/xutil.c (get_syslog_facility): Don't use LOG_DAEMON unconditionally, may be missing on Ultrix V4.3. Thu Apr 23 20:24:33 1998 Rainer Orth * conf/nfs_prot/nfs_prot_sunos5_4.h (MNTTYPE_CACHEFS): Define, missing from . * conf/mtab/mtab_ultrix.c: Need separate inclusion of without KERNEL defined here. * aux/macros/mount_headers.m4: Need to include , , so autoconfiguration of ufs_args_t, cdfs_args_t fields and cdfs mount options can succeed. * amd/ops_ufs.c (mount_ufs): Removed obsolete comment. * ChangeLog: Fixed confusing linebreaks from ChangeLog imports. Removed purely local (and obsolete) entry. Thu Apr 23 00:22:17 1998 Erez Zadok ******************************************************************* *** Released am-utils-6.0a16 *** ******************************************************************* Wed Apr 22 01:20:39 1998 Erez Zadok * aux/macros/check_mount_style.m4: define freebsd3 mount style. * aux/macros/check_mount_trap.m4: new mount trap for freebsd3. * aux/macros/check_mtype_printf_type.m4, aux/macros/check_mtype_type.m4 (ac_cv_mtype_type,): freebsd3 (as of snapshot 3.0-980311-SNAP) uses char * types for mount(2), not integers, but I'll keep them as integers and do the mapping in conf/mount/mount_freebsd3.c * minor new port to i386-pc-bsdi3.1. * minor new port to i386-unknown-netbsd1.3.1. * amd/opts.c: new option addopts:=ARG, which smartly merges ARG options with whatever the /default ones for a key are. This allows adding or overriding /default options individual keys. * amd/am_ops.c (ops_match): strdup/malloc string assigned to opt_opts because it'll get free()'d upon next use. (merge_opts): new function to merge two sets of options. (ops_match): if addopts option exist, append and merge it to the current default options. Tue Apr 21 12:54:59 1998 Erez Zadok * wire-test/wire-test.c (main): use dynamically allocated returned string with list of interfaces. * amd/get_args.c (get_version_string): allocate enough space for header version string and a list of network interfaces of any length. * libamu/wire.c (print_wires): return dynamically allocated string containing list of networks. Must be dynamic because some sites had potentially dozens of network interfaces. Patch from Matthew Crosby slightly modified. Mon Apr 20 00:37:20 1998 Erez Zadok * conf/nfs_prot/nfs_prot_irix5.h: underfine MNTTYPE_XFS because irix 5.3 does not have full header definitions for it. * fsinfo/fsi_lex.l (yywrap): define yywrap if needed, and undefined it when not needed (similar to amd/conf_tok.l) * hlfsd/hlfsd.h (ROOTID, SLINKID, INVALID): reduced maximum size of these to unsigned short (because uid_t on some linux systems is small). * released snapshot am-utils-6.0a16s10 * doc/am-utils.texi (opts Option): documented resvport mount option. Sun Apr 19 18:17:03 1998 Erez Zadok * doc/am-utils.texi (-D-Option): document behavior of -D info and especially what it does to hesiod (turn on RES_DEBUG). * scripts/amd.conf.5: document info debugging option. * libamu/xutil.c (dbg_opt): parse info debugging option. * include/am_utils.h (D_INFO): define new trace option. * Makefile.am (EXTRA_DIST): include list of official mirrors in distribution. * libamu/wire.c (SIZE): in the simple case, just compute sizeof(struct ifreq). Sun Apr 19 16:30:35 1998 Erez Zadok * amd/amd.c (daemon_mode): set a temporary secure umask(0022) before writing log file and restore it afterwards. Patch from Donald Buczek . * amd/get_args.c (get_args): * doc/am-utils.texi (-F Option), amd/amd.8: mention that amd.conf file specified by -F is always processed last. * amd/amd.c (daemon_mode): do not fclose(stdout) so that the fd won't be reused. Allows startup script to redirect stdout. Patch from Donald Buczek . * libamu/xutil.c (switch_to_logfile): compare logfile name and syslog string with correct length. Patch from Donald Buczek . * amd/restart.c (restart): correctly inherit existing NFS V.3 mounts upon restart. Patch from Donald Buczek . Sat Apr 18 19:01:19 1998 Erez Zadok * using libtool 1.2 and automake 1.3 (with my patches). * aux/macros/opt_am_cflags.m4, */Makefile.in: rename AM_CFLAGS to AMU_CFLAGS to avoid conflicts with automake-1.3. Sun Apr 5 23:09:08 1998 Erez Zadok * converted to using libtool-1.2. Tue Mar 10 16:52:09 1998 Erez Zadok * fsinfo/fsi_analyze.c (fixup_required_mount_info): replaced silly for loop (ITER) which used to run only to initialize the variable dd once and then break; with a simple assignment. * hlfsd/hlfsd.h: cleanup so it compiles with Solaris /opt/SUNWspro/bin/cc, and use gid_t not int. * amd/mapc.c (mapc_sync): don't dereference pointer (so it compiles with Solaris /opt/SUNWspro/bin/cc) Sun Mar 8 15:54:22 1998 Erez Zadok * aux/config.{guess,sub}: used from gcc-2.8.1. Sat Mar 7 15:33:27 1998 Erez Zadok * released snapshot am-utils-6.0a16s9 * INSTALL, doc/am-utils.texi (Supported Platforms): updated names based on new output of new config.guess. * aux/config.{sub,guess}: used newer versions from gcc-2.8.0. * amd/amd.8,doc/am-utils.texi: document correct usage of default /etc/amd.conf file. * fixmount/fixmount.c (inetresport,privsock): use some more portable code from amq/amq.c. * amd/get_args.c (get_args): use default /etc/amd.conf file only if no arguments had been passed to amd. * fixmount/fixmount.c (clnt_create_timeout): use tli/socket code ala amq/amq.c so that fixmount will work on both types of systems. * amq/amq.c (main): do no close tcp socket before running udp try, because we're not sure if it was opened at all. * mips-dec-ultrix* port merged in and cleaned up. * aux/configure.in: up minor shared library revision number, since it has changed enough. * hlfsd/hlfsd.c (main): don't check for overlay mount option here, as it is now done in compute_nfs_args(). Remove ultrix specific code also because it was moved to compute_nfs_args(). * conf/mount/mount_svr4.c: removed DEBUG_MOUNT_SVR4 code, now that we have more generic code in print_nfs_args(). * libamu/mount_fs.c (print_nfs_args): print maxlen of nfs_args.addr, and also syncaddr (which is mostly NULL). Print struct knetconfig from nfs_args->knconf. * aux/macros/mount_headers.m4 (define): do not check for ufs/cdfs headers here, but in try_compile_anyfs.m4. * aux/macros/type_ufs_args.m4: move test for struct ufs_specific (for ultrix) here from its own macro. * aux/macros/type_cdfs_args.m4: move test for struct iso_specific (for ultrix) here from its own macro. * amd/ops_nfs.c (mount_nfs_fh): no need to run code again checking for overlay mount option. Remove code which checks for overlay option, as it is now done in compute_nfs_args(). * libamu/mount_fs.c (compute_mount_flags): move here code which checks for overlay mount option which was in amd/amfs_toplvl.c: mount_amfs_toplvl(). Wed Feb 7 15:35:51 1998 Rainer Orth * The following are Rainer's ChangeLog entries for his ultrix port, added manually. -Erez. * merged Ultrix port with am-utils 6.0 a16s5: amd/ops_afs.c (mount_toplvl) -> amd/amfs_toplvl.c (mount_amfs_toplvl) * include/am_defs.h: include cdfs specific mount headers avoid duplication definition of gt_names[] in (Ultrix) * include/am_compat.h: define several mount options corresponding to mount flags: pgthresh, hard (nfs), defperm, nodefperm, noversion, rrip (cdfs), nocache, quota, sync (generic) removed duplicate MNTTAB_OPT_RO definition * aux/macros/try_compile_anyfs.m4: include Ultrix specific ufs/cdfs mount headers * aux/macros/mount_headers.m4: include several Ultrix/Digital UNIX specific mount headers * aux/macros/check_{fs_mntent, mount_type}.m4: check for GT_* mount types in mount headers (Ultrix) * aux/configure.in: Ultrix/Digital UNIX specific checks: new headers, mount structures and fields, filesystem and mount types, mount flags * aux/acconfig.h: placeholders for new mount options: quota (generic), ro (nfs), defperm, nodefperm, noversion, rrip (cdfs) cdfs, nfs, ufs mount structure fields new ufs, cdfs mount structures * amd/ops_ufs.c (mount_ufs): Ultrix stores generic mount flags in ufs_args.ufs_flags and has ufs specific pgthresh option * amd/ops_cdfs.c (mount_cdfs): handle Ultrix/Digital UNIX specific CDFS mount flags and options * amd/ops_afs.c (mount_toplvl), amd/ops_nfs.c (mount_nfs_fh), hlfsd/hlfsd.c (main): store generic mount flags in nfs_args.gfs_flags, handle separate NFS ro flag * aux/macros/{check_mnt2_cdfs_opt, struct_iso_specific, struct_ufs_specific}.m4: new files; check for Ultrix specific mount structures * conf/trap/trap_ultrix.h: arg 3 to mount(2) is rwflag * aux/macros/type_auth_create_gidlist.m4 (ultrix*): AUTH_CREATE_GIDLIST_TYPE is int (not short == gid_t) from a comment in * include/am_defs.h: #define KERNEL to avoid definition of gt_names[] conf/mtab/mtab_ultrix.c: #include before to force single definition here * libamu/mount_fs.c (compute_nfs_args): Ultrix support for nfs_args.gfs_flags moved to callers store mount options in nap->optstr * include/am_defs.h: fix _am_mntent mnt_{type, opts} field descriptions * aux/macros/mount_headers.m4, aux/macros/try_compile_nfs.m4: include before AMU_NFS_PROTOCOL_HEADER for svc_req definition in prototypes * aux/macros/mount_headers.m4: include before AMU_NFS_PROTOCOL_HEADER: needs it for NFSERR_* definitions * conf/nfs_prot/nfs_prot_ultrix.h: new file * aux/macros/check_nfs_prot_headers.m4: use nfs_prot_ultrix.h * aux/macros/mount_headers.m4, aux/macros/try_compile_nfs.m4, aux/macros/try_compile_rpc.m4, include/am_defs.h: avoid multiple inclusion of Sat Mar 7 13:56:05 1998 Erez Zadok * aux/configure.in: save state of config.cache and confdefs.h (as dbgcf.h) at various points of the configure. * aux/macros/save_state.m4: new macro to save state of configure, esp. useful in long ones. Saves confdefs.h and write $ac_cv_* cache variables that are known so far. * released snapshot am-utils-6.0a16s8 1998-03-06 Erez Zadok * fsinfo/fsi_lex.l,amd/conf_tok.l: define ECHO after undefining it, but only for flex. Fri Mar 6 17:23:17 1998 Erez Zadok * hlfsd/homedir.c (plt_print): change pathname of hlfsd dump file to /usr/tmp/hlfsd.dump.XXXXXX, and use a safe method (if possible) to write the dump file. * doc/am-utils.texi,amd/opts.c: rename all references to nomadic functions to boolean functions, which is what they really are. * aux/configure.in: don't look for strcasecmp in libucb at all, but rather complete it from libamu/strcasecmp.c as needed. Fri Mar 6 03:29:20 1998 Erez Zadok * conf/nfs_prot/nfs_prot_osf4.h: avoid conflicts with Irix's EFS. * libamu/wire.c (getwire): fix for 0.0.0.0 loopback on SunOS 3.X which defines IFF_ROUTE instead of IFF_LOOPBACK. Patch from Tom Schmidt . * released snapshot am-utils-6.0a16s7 * conf/nfs_prot/nfs_prot_hpux11.h: a first working port of amd to hppa1.0-hp-hpux11.00.tgz. Thu Mar 5 21:59:03 1998 Erez Zadok * converted all sources to use mntent field names, and map mnttab field names to mntent's. * include/am_defs.h (mnt_special): map struct mnttab field names to struct mntent field names. * aux/macros/check_mount_trap.m4: hpux11's mount trap style is identical to svr4/solaris2. * aux/macros/check_mount_style.m4: hpux11's mount style is identical to svr4/solaris2. * aux/macros/check_network_transport_type.m4: hpux11 is a TLI system! * aux/macros/check_nfs_sa_dref.m4: hpux11's NFS host address dereferencing style is same as svr4. * aux/macros/check_nfs_fh_dref.m4: hpux11's NFS file fh dereferencing style is same as svr4. * conf/transp/transp_tli.c (create_nfs_service): if failed to getnetconfigent() of ticlts, then try udp (hpux11). * conf/nfs_prot/nfs_prot_hpux11.h: added correct definitions for struct nfs_args, nfs_fh, and NFSMNT_* flags, taken from solaris 2.5.1 (HP used them). * amd/rpc_fwd.c (fwd_init): don't use O_NDELAY for t_open() because hpux11 doesn't like it. if t_open failed, print error based on t_errlist, not sys_errlist. Wed Mar 4 22:01:55 1998 Erez Zadok * doc/am-utils.texi: lots of documentation fixes from Rainer Orth . Sat Feb 28 22:16:35 1998 Erez Zadok * fsinfo/fsi_lex.l: undefine ECHO again, so it doesn't get used later. * include/am_defs.h: defined the extern for ualarm() if it isn't found, regardless if the function isn't found in standard libraries, because otherwise libamu will include it. 1998-02-28 Erez Zadok (per Ron Snyder) * initial port to hpux-11 completed. Compiles cleanly, but probably does not work, because of missing NFS V.2/3 headers. * amd/conf_tok.l: cast yytext to char* when passed to strlen and strdup, for hpux-11's ansi-cc compiler. * include/am_utils.h: renamed all xfree() to XFREE() to avoid conflict with hpux-11's system headers. Also move (voidp) cast from sources to inside the macro itself. Sat Feb 28 13:44:21 1998 Erez Zadok * released snapshot am-utils-6.0a16s6 * amd/info_nis.c (nis_isup): new function to test if NIS is up without hanging amd. Used to ensure that amd does not clear the maps when the expiration period arrived, if the service is down. Otherwise it would be left with empty maps. It is better to stay with possibly old information than none at all. * amd/mapc.c (mapc_sync): check to see if map service is up. Tue Feb 24 02:19:42 1998 Erez Zadok * aux/macros/check_lib2.m4 (AC_CHECK_LIB2): fix macro so it includes auxiliary library only if needed. 1998-02-22 Erez Zadok * amd/conf_tok.l: undefine ECHO again, so it doesn't get used later. Sun Feb 22 01:41:08 1998 Erez Zadok * conf/nfs_prot/nfs_prot_osf2.h: port to alpha-dec-osf2.1 completed. * conf/mtab/mtab_osf.c (mnt_dup): not all OSF have NFS3. Sat Feb 21 19:45:48 1998 Erez Zadok * doc/am-utils.texi (Network Host Filesystem): correct example for type:=host map. * aux/macros/os_cflags.m4: only osf4 should compile with -D_SOCKADDR_LEN. * aux/macros/check_nfs_prot_headers.m4: distinguish between OSF2 and OSF4. * BUGS: include a new file listing known bugs. Sat Feb 21 03:50:48 1998 Erez Zadok * conf/nfs_prot/nfs_prot_linux.h: turn DES off on all linux versions. * aux/macros/type_recvfrom_fromlen.m4: linux alpha should use size_t for recvfrom fromlen arg. Sat Feb 21 03:33:59 1998 Erez Zadok * scripts/ctl-hlfsd.in: turn -D fork so primary process never hangs. Sat Feb 21 02:45:51 1998 Erez Zadok * include/am_defs.h: don't include and , just remaining definitions in Thu Jan 29 00:44:28 1998 Erez Zadok * released snapshot am-utils-6.0a16s5 * conf/mount/mount_irix6.c (mount_irix): pass {u,e,x}fs_args to mount(2). * check for and include it when needed. * conf/mount/{mount_irix5.c,mount_irix6.c} (mount_irix): recognize efs and xfs separately from "ufs". * amd/{ops_xfs.c,ops_efs.c}: new support for irix xfs/efs. * aux/configure.in: look for irix efs and xfs file systems. * scripts/amd.conf.5: new unmount_on_exit option documented. * doc/am-utils.texi (unmount_on_exit): new option documented. * amd/conf.c (gopt_unmount_on_exit): new function to handle new amd.conf option. * amd/map.c (umount_exported): if global amd.conf flag unmount_on_exit is on, then try to unmount all mounted (or restartable) file systems. * amd/amd.c: if print_pid option is on, then normally print it to stdout. If also pid_file is specified, then print the process ID into that file. * amd/get_args.c (get_args): print correct -l option depending if system supports syslog and/or syslog facilities. Patch from Tom Schmidt . * doc/am-utils.texi (opts Option): updates for documentation for new cdfs options defperm, nodefperm, noversion, rrip. * amd/ops_cdfs.c (mount_cdfs): support cdfs options defperm, nodefperm, noversion, rrip. * conf/nfs_prot/nfs_prot_osf.h: need to look at on osf. * aux/macros/{expand_cpp_hex.m4, expand_cpp_int.m4, expand_cpp_string.m4}: use #error to make failed compilations fail faster, rather than have the program fail during a run. * include/am_compat.h: added a few new cdfs options: rrip, noversion, defperm, and nodefperm (used in OSF). Wed Jan 28 20:24:09 1998 Erez Zadok * released snapshot am-utils-6.0a16s4 * doc/am-utils.texi (Global Parameters): update manual for new amd.conf global variable hesiod_base. * scripts/amd.conf.5: update man page for new amd.conf global variable hesiod_base. * amd/get_args.c (get_args): use /etc/amd.conf file if exists by default, else try command line options. Patch from Randall S. Winchester . Wed Jan 28 12:20:56 1998 Erez Zadok * amd/info_hesiod.c (hesiod_search), amd/conf.c (gopt_hesiod_base), amd/amd.h, amd/amd.c (init_global_options): included patch from Randall S. Winchester , to support a hesiod base name in the amd.conf file. * doc/am-utils.texi (pid_file Parameter): document new global amd.conf parameter. * scripts/amd.conf.5: document new global option pid_file. * amd/amd.c (daemon_mode): if cannot open pid_file, continue to run, but print error message. * amd/conf.c (gopt_pid_file), amd/amd.h, amd/amd.c (daemon_mode, init_global_options): Included patch from Randall S. Winchester , to support pid files in the amd.conf file. * amd/get_args.c (get_args): correct usage info on amd -t. * amd/*.c: massive file name and symbol name changes. All amd file systems files and symbols are prefix with amfs_*. Now using real name of file system: amfs_auto instead of afs, amfs_inherit instead of ifs, amfs_linkx instead of sfsx, etc. This will enable clear distinction between amd file system and generic ones like nfs/ufs/pcfs/hsfs. Also, now we can implement true afs (Andrew f/s) and DFS (Distributed f/s). * amd/amfs_union.c: unionfs for amd is always defined, no need to #ifdef it. Mon Jan 26 16:51:38 1998 Erez Zadok * libamu/mount_fs.c (compute_nfs_args): set 'noconn' NFS option on or off, based on the particular quirks of the OS in question. * aux/macros/check_nfs_socket_connection.m4: new macro to set the correct wait of handling un/connected NFS sockets. * scripts/wait4amd.in: use rlogin instead of rsh. * amd/am_ops.c (ops_showfstypes): when showing F/S types in amd -v, always show "nfs3" for NFS V.3. 1998-01-25 Erez Zadok * lots of small fixes for solaris 2.6, since gcc 2.8.0 -Wall gets more picky than 2.7.2.3 did. 1998-01-24 Erez Zadok * include/am_utils.h (dlog): amuDebug macros reduced to shorter forms. Fri Jan 23 18:38:30 1998 Erez Zadok * released snapshot am-utils-6.0a16s3 * include/am_defs.h: on Solaris 2.6, is included in but since stdargs.h is used, and varargs.h must not, fake a definition for varargs. Fri Jan 16 10:16:40 1998 Erez Zadok * README: show how to configure in additional support such as hesiod using various --enable-* flags. Wed Jan 14 15:13:02 1998 Erez Zadok * aux/configure.in: look for strcasecmp(), and replace it if not available. * amd/ops_nfsl.c (nfsl_match): host names should be compared using case insensitive. * amd/opts.c: for each map variable, define if the comparison needs to be done case insensitive. * include/am_utils.h (STRCEQ): a new macro to use strcasecmp(). Patch from Thomas Richter 1998-01-14 Erez Zadok * aux/configure.in: look for "isofs" as a possible mount type for cdfs (RedHat Linux). Wed Jan 14 02:07:05 1998 Erez Zadok * conf/mount/mount_linux.c (parse_opts): don't look for cdfs mount type if not defined. * conf/nfs_prot/nfs_prot_linux.h: don't define __FD_* macros if already defined. * aux/configure.in: look for ext2fs before ufs, b/c some linux have both. Mon Jan 12 15:43:20 1998 Erez Zadok * Makefile.am (snapshot): allow me to install snapshots into the ftp directory. * scripts/ctl-hlfsd.in: don't turn on -D mem by default. * amd/get_args.c (get_args): minor bug in output of amd -H. Mon Jan 12 03:05:06 1998 Erez Zadok ******************************************************************* *** Released am-utils-6.0a15 *** ******************************************************************* Sun Jan 11 15:06:34 1998 Erez Zadok * amd/conf.c (*_browsable_dirs): allow specifying browsable_dirs=full, which will print *all* entries (other than /default), including those with '*' and '/' characters. * amd/info_file.c (MAX_LINE_LEN): up maximum readdir chain length to 1500. * doc/am-utils.texi: fixed reversed documentation for NFS mount options vers and proto. * doc/Makefile.am (install-html): separate target just for installing html files. Another new target "alldocs" is just for installing all files needed for the am-utils home page. * scripts/amd.conf-sample: updated example for log_file. * scripts/amd.conf.5: updated for new way to declare new syslog facility in the log_file option. * amd/amd.8: updated for new way to declare new syslog facility in the -l option. * libamu/xutil.c (get_syslog_facility): allow users to specify the syslog facility as an appended string to the log device. Ex. amd -l syslog:local7 will use LOG_LOCAL7, while the older -l syslog will use the default LOG_DAEMON facility. * amd/get_args.c (get_args): updated new syntax for amd -l syslog:facility. Thu Jan 8 04:05:10 1998 Erez Zadok * aux/macros/host_macros.m4: don't confuse sun3 (sparc) with sun3 (intel). * libamu/wire.c (print_wires): bug fix. Nullify output buffer before appending to it, on systems with two or more network interfaces. * conf/nfs_prot/nfs_prot_sunos5_3.h: add missing definition for the mntent for cachefs. * include/am_defs.h: external definition for strstr() should use const for both arguments. * aux/configure.in: add extern definitions for getwd() if missing. * include/am_defs.h: define the extern for strdup() even if the function does not exist, for it will be filled in by libamu/strdup.c * amq/pawd.c (cluster_server): don't use getccent() if the extern for it isn't there. On hpux 10.20, the function is in libc, but and struct cct_entry do not exist. * aux/configure.in: check for an extern for getccent() b/c some hpux systems don't have it (hpux 10.20). Wed Jan 7 00:09:19 1998 Erez Zadok * doc/am-utils.texi (Amq -T option): manual documentation updates for new amq options -T/-U. * amq/amq.8: updated man page for new amq options -T/-U. * amq/amq.c: two new switches to amq. -U will contact amd using UDP only. -T will use TCP only. Normally amq will try TCP and if that failed, will try UDP. * doc/am-utils.texi (pawd): manual documentation for pawd. * amq/pawd.1: new man page for pawd. Tue Jan 6 04:21:59 1998 Erez Zadok * amq/pawd.c: a new program, Print Automounter Working Directory, to print the proper pathname of the cwd or any other pathname, adjusted for automounter paths, while avoiding mount points. * aux/macros/localconfig.m4: trivial support for am-utils maintainers to adjust some of the configuration of am-utils after it has been auto-configured by putting whatever definitions you wish in a file called localconfig.h, located in the top build directory (the same one where config.h is created for you). * doc/am-utils.texi (Caching Filesystem): updated documents for cachefs file system. * amd/ops_cachefs.c: initial cachefs support, for solaris. type:=cachefs, requires cachedir:=/cache/dir/name to be defined and initialized with cfsadmin -c. $rfs is backdir to be cached from, and $fs is the local mount point of the cachefs. * conf/mount/mount_svr4.c (mount_svr4): support mounting of cachefs file systems. * amd/ops_cdfs.c: cdfs should be named 'cdfs', not whatever the mnttab type is. Mon Jan 5 23:22:49 1998 Erez Zadok * amd/opts.c: added support for new variable $cachedir. * include/am_utils.h: added opt_cachedir field to struct am_opts. Sat Jan 3 01:43:57 1998 Erez Zadok * amd/ops_nfsl.c (nfsl_ffserver, nfsl_match): also check if the local hostname does not match $rhost, and if so, also assume type:=nfs. Fri Jan 2 01:00:40 1998 Erez Zadok * updated all source files to add 1998 as a copyright year. * amd/ops_nfsl.c: new amd meta file system "type:=nfsl". Behaves like type:=linkx if the pathname denoted by $fs exists, and like type:=nfs if it does not. A convenient shortcut for the most popular amd map entry. * amd/amd.c (main): amd should chdir to / before starting, to avoid hanging on other NFS server if started elsewhere. * amd/ops_TEMPLATE.c: added an empty template file for developers who wish to write new amd pseudo file systems. Thu Jan 1 00:27:28 1998 Erez Zadok * hlfsd/homedir.c (plt_init): make function exported, to save on the unnecessary init_homedir() function which was removed. (table_add): don't use xmalloc() when you can use strdup() instead. Thu Jan 1 00:15:58 1998 Erez Zadok * hlfsd/homedir.c (hlfsd_endpwent): Don't actually run this because we will be making more passwd calls afterwards. On Solaris 2.5.1, making getpwent() calls after calling endpwent() results in a memory leak! (and no, even Purify didn't detect it...) Tue Dec 23 18:23:47 1997 Erez Zadok * hlfsd/hlfsd.c (main): Bug fix. Don't try to free() an automatically allocated address. * amd/ops_afs.c (mount_toplvl): Bug fix. Don't try to free() an automatically allocated address. * ALL SOURCES: change every direct call to free() to xfree(), so it can be mapped to the right debugging function as needed. * include/am_utils.h: new free() policy. If debugging memory, call dxfree(), which will print the file name and line number where the free occurred and the pointer address. if only regular debugging, then free() and reset the pointer to NULL so it cannot be used afterwards inadvertently. If not DEBUG at all, then just run free(). Three different #define macros set the right mapping. * libamu/xutil.c (dxfree): renamed function to dxfree(), so it can be called only when debugging the memory. Tue Dec 23 04:24:28 1997 Erez Zadok * wire-test/wire-test.c (main): use xmalloc() not malloc(). * conf/transp/transp_tli.c (get_knetconfig): use xzalloc() not calloc(). * conf/mtab/mtab_mach3.c (convert): use xzalloc() not calloc(). * conf/mount/mount_linux.c (parse_opts): use xmalloc() not malloc(). * amd/info_ldap.c: use xmalloc() not malloc(). * libamu/xutil.c (xzalloc): new function to allocate memory and zero its bytes. * amq/amq.c: amq does not need its own definition of xfree(). * aux/macros/opt_debug.m4: if used --enable-debug=mem, then also look for function malloc_verify() in libmapmalloc.a, and function mallinfo() in libmalloc. * libamu/xutil.c (checkup_mem): do not use mallinfo field uordbytes, because it does not always exist. Rather, compute it from other fields.. * include/am_utils.h: add external definition to xfree() function used when debugging memory references. Mon Dec 22 03:01:30 1997 Erez Zadok * amd/ops_afs.c (afs_readdir_browsable): reduce the number of bytes heuristically computed to be returned to the kernel. Otherwise browsable_dirs fails on OpenBSD 2.2. * amd/mntfs.c (uninit_mntfs): bug fix. Moved freeing of mf_private field to AFTER it gets used. Sat Dec 20 00:51:21 1997 Erez Zadok * amd/ops_host.c (host_umounted): don't use clnt_spcreateerror() on systems that don't support it. * include/am_defs.h: add missing extern definition for free(). * aux/configure.in: check for external definition for free(). * libamu/Makefile.am: add to comment a mention of strstr as an optional function. * libamu/xutil.c (switch_to_logfile): use openlog() options only if they exist. * conf/transp/transp_sockets.c (get_nfs_version): don't use clnt_spcreateerror if it does not exist. * aux/configure.in: check for missing functions clnt_create and clnt_spcreateerror. Check for missing strstr, and complete its code. Check for missing external definition for strstr. * aux/macros/host_macros.m4: normalize sun3* names. * Makefile.am: updates for new sunos3 files distributed. * conf/nfs_prot/nfs_prot_sunos3.h: new file. * conf/fh_dref/fh_dref_sunos3.h: new file. * aux/macros/check_nfs_prot_headers.m4: added sunos3 case. * aux/macros/check_nfs_fh_dref.m4: added sunos3 case. * doc/am-utils.texi (wire Selector Variable): updated manual for adjusted variables wire, network, and netnumber, all using the in_network() function. Fri Dec 19 04:37:36 1997 Erez Zadok * amd/opts.c: allow options to be processed by executing arbitrary functions. Converted wire, network, and netnumber all to use the nomadic function in_network. So from now on they perform a match against all networks, not just primary. * initial port to alpha-unknown-linux-gnu, probably works, but untested yet. * conf/nfs_prot/nfs_prot_linux.h: add special definitions for __FD_* macros which for som strange reason do not get included from on redhat alpha linux. Also turn off usage of because it is incomplete on the same systems. * hlfsd/homedir.c (table_add): cast uid field to int, for comparison. * include/am_defs.h: more coflicts with redhat alpha linux "resolved". * aux/macros/{mount_headers,try_compile_anyfs,try_compile_nfs}.m4: There's a conflict of definitions on redhat alpha linux between and which must be avoided. * aux/configure.in: check for , which is in use on redhat alpha linux. * doc/am-utils.texi (Selectors): added documentation to describe the new "!" (negated) nomadic functions. * amd/opts.c (f_in_network): print debugging info that is correct, rather than saying that any ARG is on a local network. (eval_opts): added support for negating nomadic functions, by prepending "!" to their name. Example, !exists(/foo/bar). Thu Dec 18 20:57:19 1997 Erez Zadok * include/am_compat.h: ensure that all NFS3 systems have the mount table entries (and amd opts switches) "proto" and "vers". * hlfsd/homedir.c (table_add): added some debugging info to try and track down a serious memory leak in hlfsd. 1997-12-18 Erez Zadok * libamu/mount_fs.c (compute_nfs_args): OpenBSD 2.2 requires that you do NOT set the noconn option, and use connected sockets always. So I'm now forced not to set it at all, and have the user specify it as "conn" or "noconn" in their /default entry. Argh... Finally, it looks as if OpenBSD 2.2's NFS 3 implementation may be buggy (TCP hangs with "short receive" kernel errors). I'd better wait until they get it working in their version of the automounter first. So I'm putting the "noconn" option back. Thu Dec 18 02:39:39 1997 Erez Zadok * libamu/mount_fs.c (compute_nfs_args): use maxgrps option and set nfs_args field maxgrouplist accordingly. * include/am_compat.h (MNTTAB_OPT_MAXGROUPS): complete definition for mount table entry for maxgroups based on NFS mount option maxgrp. * aux/configure.in: put back testing for NFS mount option "maxgrps". Added test for mount table entry "maxgroups". * libamu/mount_fs.c (compute_nfs_args): perform more careful tests on nfs_proto, because it could be NULL. * doc/am-utils.texi (Selectors): added example of in_network() selector. * aux/macros/check_hide_mount_type.m4: all hpux versions, including 9.x, should use "ignore" as the mount type to hide from amd. Wed Dec 17 13:09:21 1997 Erez Zadok * include/am_utils.h (NSTREQ): use new macro instead of strncmp() every where in the sources. Wed Dec 17 01:15:01 1997 Erez Zadok * libamu/mount_fs.c (print_nfs_args): if -D trace is on, will print as much info that is given in struct nfs_args as possible. useful for detecting internal flags and options, as well as the file handle used. * scripts/ctl-amd.in: look for amd.conf file in ${prefix}/etc after /etc and before /etc/local. Tue Dec 16 18:51:36 1997 Erez Zadok * aux/configure.in, libamu/Makefile.am: added support for linking with specific versions of libamu. Upped shared library version of libamu to 1 (libamu.so.1.0.0) * include/am_defs.h: added external definition for mkstemp() as needed. * minor new port to i386-unknown-netbsd1.3 (BETA version of netbsd). * aux/config.guess: don't leave a trailing '.' on the system name for NetBSD-1.3_BETA and similarly for OpenBSD. * conf/nfs_prot/nfs_prot_netbsd1_3.h: new header for the slight differences in ypall calling conventions. * mk-amd-map/mk-amd-map.c (main): use mkstemp() whenever possible in preference over mktemp(), b/c it is more secure. * aux/configure.in: check for mkstemp(), a more secure version of mktemp(). Mon Dec 15 02:32:14 1997 Erez Zadok * amd/ops_nfs.c (mount_nfs_fh): Systems that include the mount table "vers" option generally do not set the mnttab entry to "nfs3", but to "nfs" and then they set "vers=3". Setting it to "nfs3" works, but it may break some things like "df -t nfs" and the "quota" program (esp. on Solaris and Irix). So on those systems, set it to "nfs". Sat Dec 13 01:36:27 1997 Erez Zadok * doc/am-utils.texi (Distrib): updates for new ports, location of am-utils' home page, and URL cross references (now supported by my version of texi2html). * aux/macros/check_mtype_type.m4: also use string type for file system mount types under nextstep for mount(2). * aux/macros/check_mtype_printf_type.m4}: nextstep can handle both integer and string types for file system mount types in mount(2), but it is better to use string types. * conf/nfs_prot/nfs_prot_nextstep.h: set emum nfsstat's NFS_OK to 0, not 1! Otherwise, all NFS calls (esp. mount) return errno 1 (EPERM) instead of 0 (OK). Fixes m68k-next-nextstep3 which now works. * conf/nfs_prot/nfs_prot_bsdi2.h: set emum nfsstat's NFS_OK to 0, not 1! Otherwise, all NFS calls (esp. mount) return errno 1 (EPERM) instead of 0 (OK). * libamu/xdr_func.c (xdr_*): add debugging calls that are optioned by -D trace (protocol trace). 1997-12-11 Erez Zadok * A.m68k-next-nextstep3/amu_nfs_prot.h: define missing S_ISDIR macro based on existence on others, and include . Thu Dec 11 14:14:38 1997 Erez Zadok * aux/macros/try_compile_nfs.m4 (AC_TRY_COMPILE): turn off inclusion of which only affects nextstep3, on which this header is broken (it tries to include non-existing headers). Wed Dec 10 16:09:07 1997 Erez Zadok * libamu/mount_fs.c (mnt_flags): support either nfs or generic mount option for grpid. * aux/configure.in: turn back on NFS mount option grpid. Sat Dec 6 04:36:05 1997 Erez Zadok * doc/Makefile.am (install-ps): added target to install postscript file in the am-utils' home page, as well as a few other useful files for the new am-utils Web page. Mon Nov 17 05:22:56 1997 Erez Zadok ******************************************************************* *** Released am-utils-6.0a14 *** ******************************************************************* Sun Nov 16 21:56:16 1997 Erez Zadok * doc/am-utils.texi (Supported Platforms): updated table of new ports. Sat Nov 15 06:36:27 1997 Erez Zadok * libamu/mount_fs.c (compute_automounter_nfs_args): pass mnttab options so that they can be printed in logs as needed. * doc/am-utils.texi (osver Parameter): updated for the correct usage of the -o/-O options. * scripts/amd.conf.5: corrected info for -o/-O options. * amd/amd.8: updated man page for new -O op_sys_name option, and corrected the usage of the -o op_sys_ver option * amd/get_args.c (get_args): added new amd option -O to override OS name. (get_args): updated usage string. Removed old -m option. Added -o and -O options. * conf/nfs_prot/nfs_prot_irix5.h: add definition to FHSIZE in case it is not there. Reportedly, irix 5.2 does not define it. * scripts/lostaltmail.in: removed references to unused $hack variable. * aux/macros/check_nfs_prot_headers.m4: Patch from Chris Metcalf to correctly set the nfs_prot headers for solaris2.5. * doc/am-utils.texi (Distrib): typo in the subscription instructions to amd-dev. Patch from Stefan Vogel . 1997-11-15 Erez Zadok * NFS3 works on powerpc-ibm-aix4.2.1.0. * libamu/mount_fs.c (compute_nfs_args): set fh3 variable to static. Some compilers (gcc from egcs on aix 4.2.1) corrupt the stack of an automatic variable when pointer to it is passed around several times. Fri Nov 14 20:09:28 1997 Erez Zadok * libamu/xutil.c (real_plog): syslog like behavior for normal logging. Will not print repeated strings, only a count "last message repeated N times", but will always print something if message is repeated more than 100 times. * scripts/lostaltmail.in: look for lostaltmail.conf files also in /etc/global, /etc/os, and /etc/local (in that order). Mon Nov 10 03:03:17 1997 Erez Zadok * conf/mount/mount_aix.c (mount_aix3): add support for NFS V.3 mounts. * aux/macros/struct_nfs_args.m4 (AC_TRY_COMPILE_NFS): test for aix42_nfs_args, specially set in conf/nfs_prot/nfs_prot_aix4_2.h * conf/sa_dref/sa_dref_*.h: from now on, the "dst" argument to the NFS_SA_DREF macro is a pointer to the structure that used to be passed to it before. So now I have to dereference the pointer before accessing its values. * hlfsd/hlfsd.c (main): use the new and cleaner compute_nfs_args() and compute_automounter_nfs_args() functions. * amd/ops_nfs.c (mount_nfs_fh): use the new and cleaner compute_nfs_args() and compute_automounter_nfs_args() functions. * amd/ops_afs.c (mount_toplvl): MAJOR CODE REVISION. Use the new and cleaner compute_nfs_args() and compute_automounter_nfs_args() functions. * libamu/mount_fs.c (compute_nfs_args): major code cleanup that relates for struct nfs_args. A new function sets the numerous possible flags and fields of nfs_args_t in an orderly fashion. Code cleaned up, organized, and moved from amd/hlfsd into libamu. This saves on overall size of code. (compute_automounter_nfs_args): A variant of compute_nfs_args() which sets special options/flags that need to be used when NFS mounting an automounter's mount point. Used by hlfsd and amd. * amq/amq.c (get_secure_amd_client): don't print any more "get_secure_amd_client: using TCP, port 12345". It's more annoying than useful a message, even when assumed to be compiled under DEBUG only. Thu Oct 30 14:33:38 1997 Erez Zadok * aux/macros/check_mnttab_type.m4: MAJOR BUG fixed for non-nfs mount table entries. The code used to define the /etc/mnttab name for file systems based on physical media (disk, cdrom, floppy) to the generic name, rather than the OS specific name. For example autoconf searches for all these types of mount table entries for a floppy based file system: vfat pcfs pc msdos msdosfs fat. But if it found any, it hard-coded the mnttab name to "pcfs" rather than the actual name found! Same for ufs, cdfs, pcfs, tmpfs, lofs, nullfs, unionfs, and umapfs. * aux/configure.in: also test for xfs (for newer Irix) when looking for mount type names, numbers, etc of a disk-based ufs. Sun Oct 26 19:32:57 1997 Erez Zadok * amq/amq.c (main): use pmap_ping() to test if remote host is up. This works better on bsdi2 and bsdi3, because their portmapper does not appear to like forwarding operations (it is generaly insecure). Sat Oct 25 04:55:56 1997 Erez Zadok ******************************************************************* *** Released am-utils-6.0a13 *** ******************************************************************* Fri Oct 24 05:04:37 1997 Erez Zadok * conf/nfs_prot/nfs_prot_ncr2.h: added missing definition for struct datum typedef. * conf/nfs_prot/nfs_prot_netbsd.h: corrected typedef for ypall_callback_fxn_t for netbsd. * aux/macros/type_auth_create_gidlist.m4: hpux10.10 uses int for the 5th arg to authunix_create(), while before and after they used gid_t. * conf/transp/transp_tli.c (amu_clnt_create_best_vers): don't use clnt_create_timed() on older Solaris 2.3 systems that did not have it. * conf/nfs_prot/nfs_prot_bsdi2.h: is for kernel only on bsdi2, so do not include it. Fri Oct 24 00:29:42 1997 Erez Zadok * hlfsd/stubs.c (nfsproc_readlink_2_svc): avoid logging repeated messages about resolution of mailboxes based on uid/gid. * scripts/ctl-hlfsd.in: check for alternate password file in ${prefix}/etc/passwd and use it in hlfsd's startup. Thu Oct 23 22:48:50 1997 Erez Zadok * hlfsd/homedir.c (hlfsd_getpwent): added support for -P passwdfile option. If hlfsd is started with -P passwdfile, then the passwdfile is read and parsed just as a standard unix passwd(4) file. Only the username, uid, and homedir fields are read and checked. All the rest are ignored. No NIS/netgroup support! * hlfsd/hlfsd.c (main): check if hlfsd is run as root after parsing command line options, so that usage() can be printed when -h is invoked. Wed Oct 22 00:16:39 1997 Erez Zadok * amd/nfs_start.c (mount_automounter): if autofs service listener fails to initialize it is OK if using a test amd. * amd/opts.c (f_in_network): new nomadic function in_network(arg), which returns TRUE if 'arg' is any one of this host's networks. * libamu/wire.c (getwire): rewritten parts of function, to store all networks names and numbers in the order of the interface (not in reverse). Mon Oct 20 01:59:25 1997 Erez Zadok * aux/configure.in: don't add ops_ufs.o on AIX twice. My code would have worked had it not been due to AIX's buggy /bin/sh. * doc/Makefile.am (EXTRA_DIST): include am-utils.dvi and am-utils.ps in the distribution sources. (html): generate html documentation for http://www.am-utils.org Sun Oct 19 12:35:49 1997 Erez Zadok * conf/nfs_prot/nfs_prot_netbsd.h: override the definition of ypall_callback_fxn_t. The NetBSD team compiles all sources with gcc -Wall -Wmissing-prototypes -Wstrict-prototypes. * amd/info_nis.c: allow for override of ypall_callback_fxn_t function typedef. * libamu/xutil.c (amu_release_controlling_tty): new function to release the controlling tty in a clean and sane manner. No longer using setpgid() b/c it may not work. Uses setsid(), and ioctl() (in order). This new function is used in amd/amd.c and hlfsd/hlfsd.c. Also avoid setpgrp(), because it works on some systems, but on others it is the same as setpgid(). Sat Oct 18 23:42:40 1997 Erez Zadok * aux/acconfig.h: check for nfs mount option 'fsname'. Code for it was in amd/ops_afs.c, amd/ops_nfs.c, and hlfsd/hlfsd.c, but never used, because the configure test for fsname flag wasn't used. This fixed a bug in HPUX 10, where syncer and manual mounts left blank lines in /etc/mnttab. * aux/configure.in: check for nfs mount option 'fsname'. Fri Oct 17 13:30:27 1997 Erez Zadok * amd/ops_afs.c (mount_toplvl): turn on 'ignore' option in nfs mount flags of toplvl mounts. Important esp. for HPUX 10. Now hpux-10 will mount amd's mounts points as 'ignore' (by df). * aux/configure.in: check for NFS mount option 'ignore', useful in HPUX 10. Thu Oct 16 03:28:33 1997 Erez Zadok * aux/macros/check_hide_mount_type.m4: hpux 10 should use "ignore" mount type and not NFS, for the amd mount points. * conf/transp/transp_tli.c (amu_clnt_create_best_vers): don't log an RPC timeout as an error, but just an info message. From Andreas Stolcke * If the NFS server is down or does not support the portmapper call (such as certain Novell NFS servers) we mark it as version 2 and we let the nfs code deal with the case that is down. If when the server comes back up, it can support NFS V.3 and/or TCP, it will use those. From christos@deshaw.com (Christos Zoulas). * hlfsd/homedir.c (plt_print): various compile time cleanups to printfs that take a long, but pass an int to print. From christos@deshaw.com (Christos Zoulas). * aux/macros/func_bad_yp_all.m4 (ac_cv_func_yp_all_clean,): new macro to determine if the OS has a bad yp_all(), based on the host OS name. So far only irix (all versions) have a bad yp_all, so they will use am_yp_all() instead (which is slower as it enumerates manually all of the map's entries). Thu Oct 16 03:14:37 1997 Erez Zadok * amd/info_nis.c (am_yp_all): code for a replacement yp_all that avoids using a file-descriptor leaking yp_all() on some systems like irix. Wed Oct 15 21:52:35 1997 Erez Zadok * fsinfo/fsinfo.h: avoid redefining yywrap incorrectly on DU-4.x systems using /usr/bin/flex. * amd/conf_tok.l (yywrap): avoid redefining yywrap for systems that have a modified GNU flex which does define yywrap (DU-4.x). Fri Sep 26 14:25:29 1997 Erez Zadok * conf/checkmount/checkmount_bsd44.c: include prototype. Fri Sep 26 01:26:24 1997 Erez Zadok ******************************************************************* *** Released am-utils-6.0a12 *** ******************************************************************* Fri Sep 26 00:13:48 1997 Erez Zadok * conf/nfs_prot/nfs_prot_irix6.h: completely turn off all autofs code in irix6 until it can be tested correctly * conf/transp/transp_tli.c (amu_clnt_create_best_vers): time out on clnt_create for 3 seconds, rather than wait for the much longer default. * conf/nfs_prot/nfs_prot_aix4_2.h: port to powerpc-ibm-aix4.2.1.0. Includes NFS3, untested. Thu Sep 25 11:03:11 1997 Erez Zadok * amd/ops_pcfs.c (mount_pcfs): fill in uid/gid fields of pcfs_args_t if they exist. * amd/ops_cdfs.c (mount_cdfs): fill in ssector field of cdfs_args_t if it exists. * new minor ports hppa1.1-hp-hpux10.10, hppa1.1-hp-hpux9.05, hppa1.1-hp-hpux9.07, m68k-hp-hpux9.00, and sparc-sun-sunos4.1.4. Wed Sep 24 00:48:05 1997 Erez Zadok * doc/am-utils.texi (wire-test): updated documentation for the new option. * wire-test/wire-test.8: updated man page for new option. * wire-test/wire-test.c (main): added a test for various combinations of NFS proto/vers to a remote/local host. * aux/macros/try_compile_anyfs.m4 (AC_TRY_COMPILE): include and so that freebsd will correctly set mount options for pcfs and cdfs. * amd/ops_pcfs.c (mount_pcfs): set mask field of pcfs_args to 0777 (if field exists). * aux/macros/try_compile_anyfs.m4 (AC_TRY_COMPILE): include if available. * minor new port: rs6000-ibm-aix4.1.4.0. * libamu/mount_fs.c (mount_fs): fixed bug that caused HPUX not to write the "time" field in /etc/mnttab. * conf/mtab/mtab_file.c (mnt_dup): fixed typo in macro names for detecting mnt_time field of mntent_t. * libamu/mtab.c (mnt_free): fixed typo in macro names for detecting mnt_time field of mntent_t. Tue Sep 23 15:30:03 1997 Erez Zadok * conf/mtab/mtab_file.c (lock): Use flock() in preference over fcntl() to lock the mtab file. Mon Sep 22 23:04:58 1997 Erez Zadok * conf/transp/transp_sockets.c (get_nfs_version): define the try_again goto label only for NFS3. (pmap_ping): assume timeout failure of clnt_stat. * libamu/xdr_func.c (xdr_groupnode, xdr_exportnode): cast to "groups *". Mon Sep 22 20:34:33 1997 Erez Zadok * conf/transp/transp_sockets.c (pmap_ping): patch from Dan Riley to make sure that amd works with more secure portmappers that do not allow forwarding of RPC messages to other services. * */Makefile.am: all source files should also depend on the new include/am_xdr_func.h header. * include/am_xdr_func.h: new file as part of the code cleanup from Christos Zoulas . * Lots of fixes from Christos Zoulas that involved missing prototypes, cleaned up ones, and removal of unused variables. * libamu/xdr_func.c (xdr_mountres3): some code cleanup. A switch statement with only one case is unclean. Mon Sep 22 17:26:38 1997 Erez Zadok * amd/ops_fs.c (mount_fs): initialize mntent_t fields to 0 so that all fields are initialized to zero at first. This way SunOS 4.x and other systems don't get /etc/mtab entries with random integers for the fsck/freq fields. Patch from Andreas Stolcke . Mon Sep 22 00:34:19 1997 Erez Zadok * conf/nfs_prot/nfs_prot_sunos4.h: include so that the important definition for HOSTNAMESZ will be found. * amd/ops_afs.c (mount_toplvl): limit hostname size to HOSTNAMESZ (inside the nfs_args structure) if the system uses that macro. Otherwise systems like SunOS refuse to NFS mount long pathnames and result in ENAMETOOLONG errno's. Wed Sep 17 04:56:11 1997 Erez Zadok * doc/am-utils.texi (Supported Platforms): specify new support for solaris 2.6, and hlfsd running on 2.5.1 too. Wed Sep 17 03:55:02 1997 Erez Zadok * conf/mount/mount_svr4.c (mount_svr4): don't attemt an autofs mount if it is not supported or was turned off. Wed Sep 17 03:19:36 1997 Erez Zadok * conf/nfs_prot/nfs_prot_sunos4.h: fixed so that it will nfs mount again. Apparently at some previous release SunOS 4 supported was broken and all nfs mounts resulted in ESTALE. Wed Sep 17 00:26:25 1997 Erez Zadok * conf/nfs_prot/nfs_prot_sunos5_6.h: nfs protocol headers for solaris 2.6. * aux/macros/check_nfs_prot_headers.m4: added solaris 2.6 nfs protocol header selection. Sat Sep 13 14:31:51 1997 Erez Zadok * conf/transp/transp_tli.c (amu_clnt_create_best_vers): avoid infinite loop. Sun Sep 7 18:23:23 1997 Erez Zadok ******************************************************************* *** Released am-utils-6.0a11 *** ******************************************************************* Fri Sep 5 11:55:10 1997 Erez Zadok * amd/amd.c (main): if plock() succeeded, don't try to display errno message. Patch from Chris Metcalf * hlfsd/homedir.c (table_add): make sure duplicate passwd entries are ignored. Only the first entry should ever be used, because that's how lookup in passwd database works. * conf/transp/transp_sockets.c (get_nfs_version): when determining if a remote host is up or down, use NFS v.2. Fix suggested by Enami Tsugutomo . * conf/transp/transp_tli.c (amu_clnt_create_best_vers): new function to get the best possible NFS version, but also timeout faster than normal defaults, so remote hosts which are down can be detected in a reasonable time. (get_nfs_version): use the new "best" function. Tue Sep 2 00:41:00 1997 Erez Zadok ******************************************************************* *** Released am-utils-6.0a10 *** ******************************************************************* Mon Sep 1 15:39:51 1997 Erez Zadok * conf/transp/transp_tli.c (get_nfs_version): don't use clnt_tp_create_timed() on systems that don'e have it (Solaris 2.4 and earlier). * aux/configure.in: test for existence of clnt_tp_create_timed(), since Solaris 2.4 (and possibly earlier) do not have it. Mon Sep 1 15:23:18 1997 Erez Zadok * amd/ops_autofs.c (autofs_unmount_1_svc): only display rdevid field if it exists (solaris 2.4's autofs does not have it). Mon Sep 1 14:45:09 1997 Erez Zadok * aux/macros/type_auth_create_gidlist.m4: a new test to determine the correct type to the 5th argument of authunix_create(). Mon Sep 1 03:44:32 1997 Erez Zadok * libamu/xdr_func.c (xdr_umntrequest): add test for autofs structure umntrequest, if it has the field rdevid. Seems Solaris 2.4 and earlier didn't have it. Mon Sep 1 01:10:53 1997 Erez Zadok * hlfsd/hlfsd.c (hlfsd_init): moved initialization upwards, so it can be done before primary process forks. (main): bug fix: wait a bit to give child a chance to initialize. Without this, hlfsd got into a busy infinite loop while, never completing the mount. * amd/info_nis.c: patch from Jason Thorpe to make amd works when talking to NIS+ servers in NIS compatibility mode. Mon Sep 1 00:46:56 1997 Erez Zadok * amd/mapc.c (MAX_CHAIN): increased maximum chain size to 1024. Sun Aug 31 20:20:40 1997 Erez Zadok * amd/conf.c (gopt_fully_qualified_hosts): a new function to process another new global variable. * amd/ops_nfs.c (make_nfs_auth): if a new global variable fully_qualified_hosts is on, use FQHN in RPC/NFS authentications. Patch from Chris Metcalf . * amd/conf.c (process_last_regular_map): If the amd.conf file only has a [global] section (pretty useless IMHO), do not try to process a map that does not exist. * scripts/amd.conf.5: fixed typos (repeated 'as' word). * doc/am-utils.texi: MAJOR DOCUMENTATION REVISION COMPLETED!!! * amd/conf.c (reset_cf_map): Bug fix. Reset 'tag' field of cfm structure, so it does not carry over from map entry to another. Sat Aug 30 18:39:21 1997 Erez Zadok * amd/amd.c (main): fixed the meaning of the plock option. A bug caused it to be reversed. Sat Aug 30 15:13:18 1997 Erez Zadok * hlfsd/stubs.c: don't initialize some statics here. They are better initialized in hlfsd_init_filehandles(). Fri Aug 22 14:47:16 1997 Erez Zadok * amd/conf.c (gopt_show_statfs_entries): new function and a global amd.conf key show_statfs_entries. Defaults to 'no'. If 'yes', then all maps flagged as browsable will also show a count of the number of entries (keys) in that map. * amd/nfs_subr.c (count_map_entries): new function to count number of entries in a map. Now used if browsable is turned on in a map, to return a count of available keys in a given map. * hlfsd/stubs.c (eq_fh): use correct memcmp(). BUG fixed! hlfsd confused the file handles for ".", "..", and the symlink, causing mess. * aux/macros/func_bad_memcmp.m4: new test, based on autoconf 2.12, but also defines HAVE_BAD_MEMCMP, so I avoid linkage conflicts with bad memcmp() in libc's (nextstep3). Thu Aug 21 17:38:41 1997 Erez Zadok * aux/configure.in: check if autofs_args_t has a field named addr. Solaris has it for specifying the address of the daemon, but Irix does not. So how does irix tell the kernel the daemon's address? I suspect that it is hardcoded to "localhost" using a "private well-known port" (#define AUTOFS_PORT 2048). * conf/nfs_prot/nfs_prot_linux.h: added missing autofs definitions. * README.autofs: new file listing autofs support notes * very preliminary autofs code working. Call it pre-alpha quality. Sun Aug 17 02:25:09 1997 Erez Zadok * amd/conf.c (ropt_mount_type, gopt_mount_type): don't accept "autofs" if system does not support it. * amd/amd.c (main): log am-utils version string (same as amd -v) at start of run. * conf/transp/transp_sockets.c (get_nfs_version): in order to tell if a remote host is available, try to contact its portmapper and timeout if no answer is received in 3 seconds. Thu Aug 14 16:12:04 1997 Erez Zadok * aux/macros/check_extern.m4 (pattern): use a simpler pattern for match for external function definitions. The function could span multiple lines, so only match the opening parenthesis, not the closing one too. * aux/macros/os_cpp-flags.m4 (ac_cv_os_cppflags,): do NOT turn on posix mode for nextstep3. It is broken. * amd/amd.c (init_global_options): run uname() only if and uname(2) exist. * amd/rpc_fwd.c (fwd_packet): if remote host is down, the forwarding socket is null, so declare this an error. * include/am_utils.h (AM_ERRNO_HOST_DOWN): find best errno to set for when a remote host is down. Try, in order, "host down", "host unreachable", "invalid argument". * amd/ops_nfs.c (discard_fh): don't dereference a null pointer (happens when remote host is down, and fp->fh_fs is NULL). (prime_nfs_fhandle_cache): ditto, and set fs flags to !FSF_VALID and FSF_DOWN. * amd/sched.c: nobody uses "union wait" any more, or so it appears, so clean up that code. * conf/transp/transp_tli.c (get_nfs_version): if remote host is down, time it out faster than default (3 seconds). (get_mount_client): free netconfig entry when done with it. * conf/nfs_prot/nfs_prot_nextstep.h: initial (and somewhat ugly) port to nextstep3 (m68k-next-nextstep3). * fsinfo/Makefile.am (LDADD): needs to link with libamu in case system does not have strdup(). * include/am_defs.h: complete external definition for getlogin() if needed. * conf/transp/transp_tli.c (get_nfs_version): no need to keep static versout variable. * amd/rpc_fwd.c (fwd_packet): if fwdto packet is null, remote server is probably down. Don't use sendto() in that case. * buildall (default): run gmake if found, before trying plain make. GNU make is always preferable. Tue Aug 12 21:23:58 1997 Erez Zadok * aux/macros/host_macros.m4: cleanup of os_version and os overrides. Solaris 2.5.1 for example will come up as solaris2 and 2.5.1, rather than sunos5 and 5.5.1. Both can be overridden in the amd.conf file. Fri Aug 8 14:37:30 1997 Erez Zadok ******************************************************************* *** Released am-utils-6.0a9 *** ******************************************************************* Thu Aug 7 00:52:14 1997 Erez Zadok * conf/nfs_prot/nfs_prot_ncr2.h: new file, for NCR2 (i486-ncr-sysv4.3.03) headers. Needed to complete missing stuff from and . * scripts/amd.conf.5: new map page. * amd/info_hesiod.c: define extern for hesiod_resolve, since bsdi3 does not. * amd/amd.8: updated man page. * amd/get_args.c (get_args): removed defunct -h option to amd. * amq/amq.8: updated man page. * amd/info_nisplus.c (nisplus_search): prototype fixes so Sun SparcCompiler CC won't complain. * amd/info_hesiod.c (hesiod_search): small fixes to compile with hesiod-1.3, as per Rainer Orth . * aux/macros/opt_ldflags.m4: new option added to configure --enable-ldflags, to specify -L option for configuring/compiling. The older one --enable-libs is now to be used only for -l options. * amd/ops_nfs.c (mount_nfs_fh): bug fixed. Should initialize nc_protoname from nfs_proto if available for all TLI systems, not just those that have NFS V3. * amd/info_ldap.c: ldap patches from Leif Johansson , adding two new amd.conf ldap variables: ldap_cache_seconds and ldap_cache_maxmem. * hlfsd/hlfsd.c (main): bug fixed. port number must be wrapped in htons(). Sun Aug 3 17:20:05 1997 Erez Zadok * amd/nfs_start.c (mount_automounter): register amd with the rpc program number that may have been overridden by amd.conf. * libamu/xutil.c (set_amd_program_number, get_amd_program_number): allow storing and retrieving alternate amd program numbers. * amd/conf.c (gopt_portmap_program): new function to parse amd.conf entry portmap_program=1234. * amq/amq.c (main): allow specifying an alternate rpc program number for amd via -P prognum. * new amq RPC to get the process id of the running amd. This is used in ctl-amd to quickly find the pid of the amd that is to be killed. * expanded shared libraries support. Using GNU libtool-1.0, am-utils now builds shared libraries on many platforms that have support for it and proper compilers/linkers. See "INSTALL" file for compatibility chart. Thu Jul 31 13:07:23 1997 Erez Zadok * fsinfo/fsi_lex.l: removed code that was in support of very old versions of flex. No longer needed. Tue Jul 29 12:00:13 1997 Erez Zadok * amd/amd.c (init_global_options): find the kernel architecture from uname() if possible. Mon Jul 28 03:53:59 1997 Erez Zadok * new working port: i386-unknown-openbsd2.1 Fri Jul 25 03:16:31 1997 Erez Zadok * working port: sparc-sun-solaris2.4. Had to fix fhandle_t from structure to actual char[], because the structure was passed to xdr_fhandle as data and not a pointer. Surprisingly, gcc -fpcc-struct-return did not help. * conf/nfs_prot/nfs_prot_sunos5_4.h: special nfs protocol definitions for solaris 2.4 have to be different from 2.3, and different from 2.5. * libamu/xdr_fhstatus.c (xdr_fhstatus): minor code cleanup. Thu Jul 24 16:22:39 1997 Erez Zadok * conf/mount/mount_svr4.c (mount_svr4): use STREQ to compare mount types, not ==. Fix from Christos Zoulas . * mk-amd-map/mk-amd-map.8: man page taken from bsd44. Thu Jul 24 00:01:55 1997 Erez Zadok * conf/mount/mount_linux.c: made the nfs error mapping code into a small function. Wed Jul 23 16:11:49 1997 Erez Zadok * conf/nfs_prot/nfs_prot_linux.h (NFS_ERROR_MAPPING): special error mappings from errno numbers to NFS errors. From Debian Linux. * scripts/am-eject.in (fs): new script (taken from Debian Linux folks) to auto-unmount floppy/cd devices before ejecting them. * fsinfo/wr_exportfs.c (write_exportfs): from Debian folks, pass '5' as second arg to show_area_being_processed. I'm not sure why. * fsinfo/wr_atab.c (write_atab): from Debian folks, pass '5' as second arg to show_area_being_processed. I'm not sure why. * conf/mount/mount_linux.c (parse_opts): as per Debian Linux, ensure that you have a buffer in *xopts to strcat onto. (mount_linux): fixed from Debian folks to ensure that NFS mount sockets are connected only for kernels prior to 1.3.10 (avoids hangs for multi-homed hosts). * amd/mapc.c (make_entry_chain): from Debian folks: don't skip over amd map keys that have a prefix, and include the prefix in the returned readdir(). * amd/info_passwd.c (passwd_init, passwd_search): format enhancements from the Debian Linux folks. They added - var0:=pw-prefix:=anydir - var1:=pw-rhost:=dom3.dom2.dom1 - var2:=pw-user:=user - var3:=pw-home:=/anydir/dom1/dom2/dom3/user * new ports: sparc-sun-solaris2.4 and sparc-sun-sunos4.1.1. * amd/ops_afs.c (afs_retry): patches from Debian Linux. If afs_mount timed out, then explicitly forbid further retries after the timeout. (afs_bgmount): bug fix from Debian Linux. Timeout values (17 and 5) were mistakenly swapped. Wed Jul 23 15:53:25 1997 Erez Zadok * conf/nfs_prot/nfs_prot_sunos5_3.h: turn off non-existent NFS V.3 support for Solaris 2.4 (the header files incorrectly define parts of the NFS V.3 protocol, but the kernel does not support it). Wed Jul 23 00:07:12 1997 Erez Zadok * amd/info_hesiod.c: minor cleanup to use hes_init and hesiod_init for determining if using old or new hesiod libraries, respectively. * amd/ops_nfs.c (mount_nfs_fh): If "noconn" option exists in NFS V.3 then use non-connected sockets (both TCP and UDP). Otherwise they cause hangs of mounts from multi-homed hosts when the return route is not the same as the outgoing route (esp. on NetBSD 1.2.1). If "conn" option was supplied, then don't turn on the "noconn" mount option. Otherwise default to "noconn" mount option. * aux/configure.in: better check for systems that need libgdbm and Tue Jul 22 04:02:05 1997 Erez Zadok * hlfsd/hlfsd.c (main), amd/ops_afs.c (mount_toplvl): ensure that mounts are hidden from df(1) on systems that keep mount tables in kernel, such as osf1. Tue Jul 22 02:26:55 1997 Erez Zadok ******************************************************************* *** Released am-utils-6.0a8 *** ******************************************************************* Mon Jul 21 21:33:19 1997 Erez Zadok * hlfsd/hlfsd.c (main): bug fixed: forgot to set sin_family to AF_INET when hlfsd mounts itself, thus getting an errno "protocol family not supported". Mon Jul 21 20:46:59 1997 Erez Zadok * verified that amd on NetBSD 1.2.1 (i386) works, but the OS itself is flaky. * verified that amd AIX 3 works w/ the new readdir() code. Mon Jul 21 18:59:30 1997 Erez Zadok * amd/mapc.c (maptypes): changed the default map caching type for nis and ndbm maps to "MAPC_ALL", so that all possible entries will be available to amd for browsable_dirs=yes. Mon Jul 21 18:04:16 1997 Erez Zadok * amd/ops_afs.c (afs_readdir, afs_readdir_browsable): split afs_readdir into a browsable version and a non-browsable one. Fixed bugs that resulted in an infinite nfs_readdir loop on the localhost for some operating systems. Sat Jul 19 19:38:38 1997 Erez Zadok * amd/ops_afs.c (afs_readdir): fixed up the browsable code to comply with nfs_readdir specs. It was returning all entries at once, even if there was not enough space in the RPC packet. Now, it sends a reasonably sized chunk, and sets static state to resume it for the next continuation RPC of readdir. * amd/conf.c (set_conf_kv): fixed bug that resulted in the first regular map not getting all of the [global] options defaulted from. Fri Jul 18 00:45:12 1997 Erez Zadok * amq/amq.c (main): fixed so that portmapper "ping" will only fail upon an RPC timeout * scripts/ctl-{amd,hlfsd}.in (killproc): better method to find the amd/hlfsd process to kill. * amd/ops_afs.c (mount_toplvl), hlfsd/hlfsd.c (main): code to determine how to avoid df from seeing amd's toplvl mounts. Moved from libamu/mount_fs.c and include/am_utils.h. Ensure that hlfsd is hidden from df. (mount_toplvl): fixed df types for irix. Thu Jul 17 21:59:45 1997 Erez Zadok * amq/amq.c (main): fixed bug that caused the 5 second timeout for TLI amq using udp to be ignored. (main): if amq cannot contact remote host's portmapper within 5 seconds, timeout and fail faster than the default longer timeout (this is for non-TLI systems). Thu Jul 17 17:08:13 1997 Erez Zadok * amq/amq.c (get_secure_amd_client): if amq cannot contact remote host's portmapper within 5 seconds, timeout and fail faster than the default TLI timeout of over 4 minutes. * amd/am_ops.c (ops_showfstypes): added styles for new bsd44 file systems nullfs, unionfs, and umapfs. (ops_show1): cleanup code and and reuse this function. (vops): empty placeholders for nullfs, unionfs, and umapfs. * amd/ops_{nullfs, unionfs, umapfs}.c: 3 new empty templates for bsd44 style file systems. * fsinfo/fsinfo.8: man page for fsinfo rewritten from bsd44 sources. * amd/conf_tok.l, fsinof/fsi_lex.c: undefine ECHO to avoid conflict with systems that define it in and also define a conflicting one via lex. Newer versions of f/lex are ok. Wed Jul 16 00:17:45 1997 Erez Zadok * amd/ops_nfs.c (mount_nfs_fh): fill in nfs_args' fields acdirmin/max and acregmin/max only if they exist. * aux/configure.in: test for nfs_args fields acdirmin and acregmin. Tue Jul 15 17:24:09 1997 Erez Zadok * aux/configure.in: commented out checking for MNT2_GEN_OPT_* for "nondev" and commented back in checking for "nodev". This was a typo. * include/am_compat.h: more compatibility options: define "ro" mnttab option all the time. Define "overlay" as needed. Added more fillers of mnttab options (as per Daniel S. Riley ), for acdirmax, acdirmin, acregmax, acregmin, noac, grpid, nosuid, and actimo. * libamu/mount_fs.c (mnt_flags): fixed a typo in "ro" option as per dsr@mail.lns.cornell.edu (Daniel S. Riley). Then cleaned up the same code for other options in struct opt_tab. Mon Jul 14 22:36:37 1997 Erez Zadok * amd/get_args.c (get_args): moved amd.conf file parsing to before the switching the default log/debug options. Suggested by dsr@mail.lns.cornell.edu (Daniel S. Riley). * aux/update_build_version: new script to record the build version of amd, along with the rest of the info thet comes up with amd -v. Sun Jul 13 00:30:24 1997 Erez Zadok * aux/macros/os_cflags.m4: new macro, to add additional compilation options (also used during configuration), based on the OS and the compiler. Used for solaris-2.6, osf, and irix6. Fri Jul 11 10:15:11 1997 Erez Zadok * amd/conf_tok.l, conf_parse.y: allow values of keys to include white spaces, if they are double-quoted (key="some value") * amd/info_hesiod.c (hesiod_search): cleanup and minor bug fixes of hesiod from Danny Braniss . Fri Jul 11 02:16:06 1997 Erez Zadok ******************************************************************* *** Released am-utils-6.0a7 *** ******************************************************************* Thu Jul 10 12:19:25 1997 Erez Zadok * include/am_defs.h: fill in extern definition of innetgr() in case system headers don't. * aux/macros/path_prog_lex.m4 aux/configure.in: using macros that will show the full pathname to yacc/bison and f/lex. Some systems have older or bad versions of those and this way the user will know for sure what is being invoked. * tasks: file populated with todo items. * scripts/amd2ldif.in: Script to convert amd maps to plain text LDAP object files. Contributed by Leif Johansson . * aux/config.guess: added recognition for sun3's running 4.2bsd, from Tom Schmidt . Fixed one small typo. * amd/conf.c: several variables that were local to a map, were also added to [global], where they apply to all maps. Each map can then individually override those defaults. Flags affected: browsable_dirs and mount_type. Options affected: map_type, map_options, and search_path. * amd/amd.h: eliminated several global flags each of which took an int, in favor of one global flags variable used as a bit field. * amd/amd.c (init_global_options): moved all global variables into a single struct amu_global_options, so it is easier to add new ones and/or identify existing ones. * amd/get_args.c (get_args): removed unused amd -m option. * amd/conf.c (gopt_cluster): added new amd.conf option for cluster name, same as amd -C. * amd/info_ldap.c: LDAP info map functions from Leif Johansson . * amd/conf.c (gopt_ldap_base, gopt_ldap_hostports): put in global amd.conf options for ldap_base and ldap_hostports. * amd/opts.c (f_netgrp): new amd map function netgrp(ARG) to test if the current host is in the ARG host netgroup. * aux/configure.in: some systems replaced dbm in libc with GNU's libgdbm, so check for libgdbm, but only if dbm_open is not in libc already. This was a recommendation from Tom Schmidt . * conf/nfs_prot/nfs_prot_sunos5_3.h: port to sparc-sun-solaris2.3 completed. Wed Jul 9 18:14:59 1997 Erez Zadok * port to sparc-unknown-netbsd1.2E done, not tested. Includes NFS V.3. Tue Jul 8 17:35:07 1997 Erez Zadok * port to i386-unknown-freebsd3.0 done and working. Includes NFS V.3. * aux/macros/check_nfs_fh_dref.m4: freebsd3 should use file handle dereferencing style similar to freebsd22. * include/am_defs.h: need to include before on freebsd3. * conf/nfs_prot/nfs_prot_freebsd3.h: new protocol header additions for freeBSD 3.0. Tue Jul 8 16:53:41 1997 Erez Zadok * amd/info_nis.c (nis_reload): cast nis' callback function so picky compilers won't complain. * libamu/xdr_mountres3.c (xdr_mountres3): make sure this function gets compiled only if the system has NFS V3 and does not have xdr_mountres3. Tue Jul 8 12:42:03 1997 Erez Zadok * COPYING: put in some legal stuff in this file. Mon Jul 7 19:10:44 1997 Erez Zadok * NFS V3 now works under Irix5, thanks to patches from Andreas Stolcke . * conf/mount/mount_irix5.c: sparate mount_irix.c into an irix5 version and an irix6 version, since irix5's NFS V3 code is broken and hacky. * amd/info_hesiod.c (hs_zone_transfer): minor fixes to buffer sizes for some hesiod queries. Patch from Danny Braniss . Mon Jul 7 19:04:14 1997 Erez Zadok * amd/ops_nfs.c (mount_nfs_fh): fixed NFS V.3 support for bsdi3. Sun Jul 6 14:22:24 1997 Erez Zadok * aux/{configure.in,acconfig.h}: added checks for struct nfs_args's fields proto and sotype (bsdi3). * amd/ops_nfs.c (mount_nfs_fh): added nfsv3 option to nfs_args.flags for bsdi3. Set field proto to 0. Set sotype field to SOCK_STREAM or SOCK_DGRAM. * aux/macros/check_mount_style.m4: add case for bsdi3. * amd/info_hesiod.c: got hesiod support for bsdi3. Sun Jul 6 11:14:47 1997 Erez Zadok * aux/configure.in: look for hesiod on libc (bsdi3) * amd/get_args.c (get_args): reformat usage so it fits in 80 columns. * scripts/ctl-amd.in: changed directory name for optional tftpboot map to /tftpboot/.amd. Sat Jul 5 17:46:45 1997 Erez Zadok ******************************************************************* *** Released am-utils-6.0a6 *** ******************************************************************* Sat Jul 5 03:17:09 1997 Erez Zadok * scripts/ctl-amd.in: include -T tag for tftpboot. * new port: mips-sgi-irix5.3. Compiled with gcc, but NFS V3 code is broken and needs work on the specific nfs_args that irix5 uses for V3 mounts. Sat Jul 5 01:44:25 1997 Erez Zadok * amd/get_args.c (get_args): new options amd -T tag. A map with tag=foo matching the -T tag will be processed. All untagged maps get processed all the time. Fri Jul 4 16:19:26 1997 Erez Zadok * aux/configure.in: need to check for strcasecmp in libucb (ncr2) * aux/macros/check_os_libs.m4: a new macro to set the usage of libnsl and libsocket based on the OS. * libamu/mount_fs.c (mnt_flags): used MNTTAB_OPT_GRPID if it is defined (problem on osf4). * conf/nfs_prot/nfs_prot_irix5.h: new file for irix5 headers. * include/am_defs.h, aux/macros/try_compile_nfs.m4, aux/macros/mount_headers.m4: do include because it failes on irix5. Rather, put in the individual conf/nfs_prot/nfs_prot_*.h headers. * amd/conf.c: AIX3 doesn't like strdup() being passed a constant char*, so cast all strdup()'s args to a non-const char*. * amd/mapc.c (root_newmap): don't try to strdup only a "const char *". Fri Jul 4 15:47:10 1997 Erez Zadok * conf/nfs_prot/nfs_prot_sunos4.h: added rpc/rpc.h and sys/errno.h. Thu Jul 3 17:49:00 1997 Erez Zadok * made sure am-utils compiles, links, and runs properly on Irix 6.2 using "cc -32 -Wl,-woff," * aux/macros/check_lib2.m4: a bug fix version to autoconf 2.12 AC_CHECK_LIB. If OTHER-LIBRARIES are defined and used, then add them to $LIBS. * aux/configure.in: some cleanup of which libraries are needed. Espectially ensure that libnsl is included only on Solaris, where so far it is the only system on which it is absolutely necessary. Also no longer need to include libc explicitly. * amd/amd.c,wire-test/wire-test.c (main): convert IP address to network-long order before printing it. * wire-test/wire-test.c (main): also check and report on the IP address of the local host, since some systems have bad versions of get_myaddress, or ones that conflict with other versions in multiple libraries (SunOS 4 and Irix especially). Wed Jul 2 18:19:02 1997 Erez Zadok * scripts/ctl-amd.in: don't use full pathname so killproc() works better. Also run bsd44 and irix style ps programs. * aux/macros/check_lib_funcs.m4: bug fixed: used to define usage of library no matter if it was found or not. Wed Jul 2 02:11:48 1997 Erez Zadok * aux/macros/check_mnt2_gen_opt.m4: turned back on the checking for M_* macros, but ensure that is not included at all so it won't conflict with other M_* macros. Tue Jul 1 21:16:51 1997 Erez Zadok * conf/mount/mount_irix.c (mount_irix): first arg to mount(2) on irix should be "spec" (host:/path), not the dir of the mnt point. * amd/ops_afs.c (afs_lookuppn): bug in enable_default_selectors fixed. If on, it essentially ignored the setting in a selector-controlled /defaults if there were 2 or more entries in it. Tue Jul 1 12:23:38 1997 Erez Zadok * scripts/ctl-{amd,hlfsd}.in (killproc): if failed to find process using BSD style ps, then try SVR4 style ps. * include/am_utils.h (amuDebug): renamed Debug macro to amuDebug etc., to avoid conflicts with similar named macros in . * aux/configure.in, amd/info_ldap.c, etc.: put in all the autoconf support needed for LDAP. Now the code has to be written mostly in amd/info_ldap.c. * Included additional patches from Andreas Stolcke to support using the best possible combination of NFS version (2,3) and protocol (udp,tcp) for any given host, since it appears that some Irix versions have NFS V3, but do not support TCP. * scripts/ctl-amd.in: updated amd control script to look for and use amd.conf file. Tue Jul 1 00:28:23 1997 Erez Zadok * amd/mapc.c (mapc_create): now, each map in the amd.conf can be initialized off of a different type, or default to cycling through all maps until one of them matches. Mon Jun 30 20:49:13 1997 Erez Zadok * amd/ops_afs.c (afs_readdir): per-map browsing (readdir) done. if browsable_dirs=yes is set in the map section in amd.conf, that map will return all entries back to a readdir(2). Sun Jun 29 16:22:11 1997 Erez Zadok * rudimentary amd.conf file support included. You may even override things like os=sos5, to get "backwards" compatibility with upl102. Sat Jun 28 13:35:02 1997 Erez Zadok * amd/conf.c: new file to process amd.conf file. * amd/get_args.c (get_args): new options -H to print help. * moved enable_default_selectors to be amd.conf controlled, and not compiler controlled. * amd/get_args.c (get_args): new options -F to parse an amd configuration file. Wed Jun 25 23:15:42 1997 Erez Zadok * converted all files that used strcmp() == 0 or != 0 to using the STREQ() macro. Mon Jun 23 22:31:14 1997 Erez Zadok * aux/macros/check_lib_funcs.m4: new M4 macro that can be used to search for any number of functions in any given library. Mon Jun 23 01:04:23 1997 Erez Zadok * amd/mapc.c: Included patch from Leif Johansson to ensure that systems without an RE library can compile. * libamu/mount_fs.c (mount_fs): Included patch from Andreas Stolcke , to ensure that mount options on table are properly delimited by a comma. * amd/ops_nfs.c (mount_nfs_fh): Included patch from Andreas Stolcke , to allow users to override the proto= and vers= mount options. Sun Jun 22 01:00:11 1997 Eric Dana (edana@ncr2.bgs.com) * conf/nfs_prot/nfs_prot_svr4.h: port completed to i486-ncr-sysv4.3.03. Assorted source cleanups done. * include/am_defs.h, aux/macros/mount_headers.m4: don't include mnttab.h if sys/mnttab.h was already included, because on ncr2, they contain conflicting entries for struct mnttab. Sat Jun 21 23:52:15 1997 Eric Dana (edana@ncr2.bgs.com) * aux/macros/check_nfs_prot_headers.m4: added support for ncr2. Fri Jun 20 06:14:17 1997 Erez Zadok * amd/*.c: lots of 64-bit "ugly" ports like casts to long ints. * aux/macros/struct_nfs_fh.m4: check for "struct nfssvcfh" because on DU-4.0 it is better than the next one to be picked (nfsv2fh_t). Wed Jun 18 18:59:49 1997 Erez Zadok * aux/macros/struct_nfs_fh.m4 (AC_TRY_COMPILE_NFS): check for nfsv2fh_t before fhandle_t becasue on bsdi2.1 the former is better. Tue Jun 10 17:06:58 1997 Erez Zadok * amd/rpc_fwd.c (fwd_packet): TLI bug fix. if fwdto socket is NULL, set the maxlen and len fields in netbuf to zero. Wed May 28 22:52:28 1997 Erez Zadok * scripts/fix-amd-map.in (name): replace all matching patterns on line. Sun May 25 19:33:41 1997 Erez Zadok ******************************************************************* *** Released am-utils-6.0a5 *** ******************************************************************* Sun May 25 13:37:24 1997 Erez Zadok * amd/amq_subr.c (amqproc_getvers_1_svc): amq's RPC service procedure now returns the full string that amd -v returns. * amd/get_args.c (get_version_string): new function to return complete version/info string so it could be used more flexibly. * amd/am_ops.c (ops_showamfstypes, ops_showfstypes): put the list of Fs types into a string buffer, rather than a FILE*. * amd/mapc.c (mapc_showtypes): put the list of map types into a string buffer, rather than a FILE*. Sun May 25 01:25:36 1997 Erez Zadok * amd/get_args.c (get_args): amd -v also prints user who built amd, hostname built on, and date of configuration. Sat May 24 13:40:50 1997 Erez Zadok * scripts/lostaltmail.conf-sample: sample lostaltmail configuration file. * scripts/lostaltmail.in: new script lostaltmail used to redeliver "lost" mail that hlfsd redirected to a temp location because the primary home file system of the user was full. * scripts/amd2sun.in: new script amd2sun. Used to convert Sub automount maps to amd maps. * scripts/ctl-hlfsd.in: new script ctl-hlfsd. Used to start, stop, or restart hlfsd. * scripts/expn.1: man page for expn command. * scripts/ctl-amd.in: new script ctl-amd. Used to start, stop, or restart amd. * scripts/expn.in: new script expn. Actually taken from David Muir Sharnoff . Used by hlfsd's mail re-delivery script. * scripts/wait4amd.in: new script wait4amd added. Waits for amd to come up on a host, and then runs a command (rsh $hostname by default). * scripts/Makefile.am: new directory now holds all shell/perl scripts that belong to am-utils. * conf/mount/mount_linux.c (parse_opts): new parser for linux-specific mounts. Handles fs-type specific mount-options correctly. Currently implemented: msdos, iso9660. * amd/ops_pcfs.c (pcfs_ops): don't timeout pcfs mounts by default (fix for linux). * amd/ops_cdfs.c (cdfs_ops): don't timeout cdfs mounts by default (fix for linux). * amd/mapc.c (make_entry_chain): fixed bug that resulted in amd core dumps upon "ls" of a mount point; an invalid pointer was being returned and dereferenced. * port to Linux sparc working! * hlfsd/homedir.c (hlfsd_diskspace): close file descriptor if failed to write test file, or else the fd will leak. Sun May 18 00:42:41 1997 Erez Zadok * amd/info_hesiod.c (hs_strip_our_domain): use strcasecmp() instead of strcmp(). * Port to Digital Unix 4.0 (OSF) done. * hlfsd/hlfsd.c: renamed dirname to dir_name to avoid conflicts with dirname() function in on OSF systems. * fsinfo/fsi_util.c (set_ether_if): take out extern definition of inet_addr(). It should come from instead. * conf/mtab/mtab_osf.c: fixed macros and added NFS V3 specs. * include/am_utils.h: renamed FIRST/LAST to AM_FIRST/AM_LAST to avoid conflicts with DU 4.0 system header. Thu May 15 22:49:12 1997 Erez Zadok * libamu/mount_fs.c (mount_fs): pass along NFS version so I can determine if to include additional options in the mount table file entry (such as proto=tcp, and vers=3). Thu May 15 00:42:12 1997 Erez Zadok * libamu/mount_fs.c (mount_fs): include NFS version number in the mount table options, as well as proto={tcp,udp}. Wed May 14 14:30:19 1997 Erez Zadok * NFS V3 code ported to most other systems, so it compiles for V2 and V3 NFS systems. * NFS VERSION 3 support, first pass. Working for Solaris and using TCP. Sun May 11 01:14:29 1997 Erez Zadok * amq/amq.c: many newline characters were missing from various stderr printfs. Sat May 10 13:09:06 1997 Erez Zadok * conf/nfs_prot/nfs_prot_sunos5.h: protocol defintions for Solaris, which include NFS V3 support. * conf/nfs_prot/nfs_prot_default.h: default NFS protocol headers. * conf/transp/transp_{tli,sockets}.c (get_mount_client): use NFS protocol version while getting a mount client. * amd/ops_nfs.c (mount_nfs_fh): set the mount types, mnttab types, file handle size, and proper file handle based on the correct NFS version number. * conf/mount/mount_svr4.c (mount_svr4): support NFS3 mounts under Solaris and other SVR4 systems. * amd/ops_nfs.c: store NFS file handle version and version specific handle in struct fh_cache. (got_nfs_fh): pick the correct RPC reply based on the NFS version of the server. (prime_nfs_fhandle_cache): figure out the right NFS file handle for a node, but now include NFS protocol version information. (call_mountd): set the correct version for the mount protocol, based on the NFS protocol version. (nfs_init): use the NFS protocol generic structure am_nfs_handle_t. * include/am_utils.h: new structure am_nfs_handle_t to contain all possible versions of NFS file handles. * amd/srvr_nfs.c (start_ping): ping program performs NFS version specific pings. (recompute_portmap): figure out the correct portmap version mount. (nfs_keepalive): call start_ping() with the correct NFS version. (find_nfs_srvr): if mount option "vers=" is given, use it. Get the NFS server version and verify that it is up. * conf/transp/transp_{tli,sockets}.c (get_nfs_version): a new function to find the best NFS version for a particular host. * libamu/amu.h: determine what is the highest version of NFS we should try. * include/am_utils.h (NFS_VERSION3): added definition for NFS V3 protocol number. Added field fs_version to struct fserver, so we can now store the server protocol version. Fri May 9 01:09:45 1997 Erez Zadok * aux/macros/check_field.m4 (AC_MOUNT_HEADERS): map '.' (dot) into underscores too, so I can test for sub-fields. * libamu/wire.c: use test that checks for sub-fields of struct ifreq. Sat May 6 10:20:17 2000 Erez Zadok * port to BSD/OS 3.0 completed! Many xdr_ functions were broken into smaller files. M4 macros fixed to test for existence of file systems using getvfsbyname(). * amd/sched.c (sigchld): signal handler must waitpid() for all possible children. * hlfsd/homedir.c: signal handler must waitpid() for all possible children. * aux/macros/check_restartable_signals.m4: new macro to determine if need to reinstall signal handlers per OS is better than trying to figure these out based on system macros. Fri May 5 19:23:28 2000 Erez Zadok * amd/ops_nfs.c (mount_nfs_fh): set nfs_args_t version number. * amd/ops_afs.c (mount_toplvl): set nfs_args_t version number. * amd/ops_nfs.c (mount_nfs_fh): process nfs mount option resvport (must be supplied for bsdi 3.0) * libamu/wire.c: use HAVE_FIELD_STRUCT_IFREQ_IFR_ADDR (and associated new macro) for determining the right way to compute the size of the interface structure. Fri Apr 11 15:56:13 1997 Erez Zadok * aux/configure.in: need to include libc before libnsl if get_myaddress() is available because on irix libnsl has a buggy get_myaddress(). * include/am_defs.h: make sure REINSTATE_SIGNAL_HANDLER is defined on Irix 6 (an SVR4 variant) Thu Mar 27 02:28:40 1997 Erez Zadok ******************************************************************* *** Released am-utils-6.0a4 *** ******************************************************************* Wed Mar 26 21:15:36 1997 Erez "HWank1" Zadok * amd/amq_subr.c (ok_security): turned off insecure code unless user explicitly runs configure --enable-amq-mount. * hlfsd/hlfsd.c (main): use new protoypes dor create_nfs_service(). * amd/nfs_start.c (mount_automounter): use code that separately creates the NFS and the amq service. Register tcp and udp services for amd. * conf/transp/transp_*.c (create_amq_service): new function to separately create the amq service for amd. Simplified prototypes for create_nfs_service(). Wed Mar 19 20:40:56 1997 Erez Zadok ******************************************************************* *** Released am-utils-6.0a3 *** ******************************************************************* Wed Mar 19 17:49:18 1997 Erez Zadok * new port: rs6000-ibm-aix3.2.5 and rs6000-ibm-aix4.1.5.0. Lots of small changes to support these two. Wed Mar 19 14:33:30 1997 Erez Zadok * conf/umount/umount_default.c (umount_fs): bug: unlock_mntlist() should run if MOUNT_TABLE_ON_FILE, not otherwise. Mon Mar 17 22:02:43 1997 Erez Zadok * hlfsd/hlfsd.c (main): fill in fhsize field if exists (freebsd-2.2). * amd/ops_{nfs,afs}.c (mount_toplvl): fill in fhsize field if exists (freebsd-2.2). Sat Mar 15 19:37:48 1997 Erez "HWank1" Zadok * new port: i386-unknown-freebsd2.2. FreeBSD 2.2 and higher changed the filehandle type in struct nfs_args from nfsv2fh_t to u_char. Sat Mar 14 10:11:03 1997 Erez "HWank1" Zadok * SHARED LIBRARIES: too many changes to list individually. Now, libamu can be built as a shared library, and other programs link with it. Tue Mar 11 22:24:09 1997 Erez "HWank1" Zadok * aux/macros/opt_shared.m4: new macro for setting options for building shared am-utils libraries. Sun Mar 9 19:17:46 1997 Erez Zadok * fixmount/fixrmtab: cleaned up the script. * fixmount/Makefile.am (EXTRA_DIST): adde $(sbin_SCRIPTS) so that fixrmtab gets distributed too. * conf/nfs_prot/nfs_prot_bsdi2.h: added support for MOUNTPROC_DUMP. Added extern for xdr_mountlist(). * aux/configure.in: trimmed down many tests for MNT2_GEN_OPT, MNT2_NFS_OPT, and MNTTAB_OPT that were not referenced anywhere in the sources. Sat Mar 8 00:23:58 1997 Erez Zadok * fixmount/hlfsd ported to bsd44, hpux, and linux systems. * aux/macros/check_fixmount_style.m4: add check for bsd44 systems. * conf/fixmount/fixmount_default.c: use lockf() if flock() is unavailable. * include/am_defs.h: include even if don't have STDC_HEADERS defined (sunos4). (seteuid): define seteuid() to be setresuid() for systems that have but not the other (hpux). * aux/macros/check_extern.m4: test should include . Tue Mar 4 17:16:52 1997 Erez "HWank1" Zadok * lib/xutil.c (debug_option): moved from amd/getargs.c to this more proper file. * include/am_utils.h: put in structure for debug options, for all progams to use. * amd/get_args.c: moved structure for debug options out. Sun Mar 2 00:13:07 1997 Erez "HWank1" Zadok * ported fixmount. * lib/ualarm.c: replacement function for systems that don't have a ualarm(). * ported fsinfo. Sun Mar 1 10:23:34 1997 Erez "HWank1" Zadok * ported mk-amd-map. * buildall: added -K option to buildall, to run mkconf. Fri Feb 28 01:10:25 1997 Erez "HWank1" Zadok ******************************************************************* *** Released am-utils-6.0a2 *** ******************************************************************* Thu Feb 27 13:58:59 1997 Erez "HWank1" Zadok * all *.[hcyl] files: add copyright line. * aux/macros/check_mount_type.m4: test for mount type for linux-like systems, by checking for loadable or statically linked kernel filesystem modules. * aux/macros/check_mnttab_type.m4: test for mount table entry for linux-like systems, by checking for loadable or statically linked kernel filesystem modules. * aux/configure.in: pcfs filesystems can use vfat type (linux) * aux/macros/check_fs_mntent.m4: test for filesystem existence for linux-like systems, by checking for loadable or statically linked kernel filesystem modules. * conf/trap/trap_hpux.h: ugly hack added because of stupide HPUX 9.0 header files. This should be removed when HPUX 9.0 is deemed defunct. * aux/acconfig.h: set an undefined variable for having an extern to clnt_sperrno(). * include/am_defs.h: define extern for clnt_sperrno() if needed. * aux/configure.in: test for extern clnt_sperrno(). * aux/macros/check_nfs_fh_dref.m4: HPUX's NFS fhandle dref is similar to irix. * aux/macros/check_mount_style.m4: use mount helper on HPUX. * aux/macros/check_mtype_type.m4: hpux's mount type is a char*, not integer (but may be mapped to one later). * conf/mount/mount_hpux.c (mount_hpux): HPUX has confusing header files. They have mount(2) and vfsmount(2) which don't take same arguments, and they have string mount types MNTTYPE_* as well as integer types MOUNT_*. So I need this new mount function to map from string types to integer types for the vfsmount() function. * conf/trap/trap_hpux.h (MOUNT_TRAP): instead of calling vfsmount(), call mount_hpux(). Thu Feb 27 03:34:14 1997 Erez "HWank1" Zadok * lib/mount_fs.c (mnt_flags): make sure SYNC option is on only if both MNTTAB_OPT_SYNC and MNT2_GEN_OPT_SYNC are defined. Thu Feb 27 00:26:00 1997 Erez "HWank1" Zadok * conf/nfs_prot/nfs_prot_hpux.h: NFS protocol definitions for hpux. * include/am_defs.h: no need to include rpc/auth.h or rpc/clnt.h. * aux/configure.in: no need to test for rpc/auth.h and rpc/clnt.h. * buildall: added ability to configure using other shells than /bin/sh, on those systems where /bin/sh is buggy or limited (HPUX). * aux/macros/struct_nfs_fh.m4: reinstated the macro but have it defined am_nfs_fh, and also test for plain typedef "nfs_fh". * aux/acconfig.h: #undef am_nfs_fh, which is being defined by a reinstated macro. * aux/configure.in: check for * include/am_defs.h: include (HPUX) if exists. * aux/macros/try_compile_nfs.m4: include (HPUX) if exists. * aux/macros/mount_headers.m4 (define): removed some non-working (on HPUX) code that attempts to recreate the fhandle_t rather than load it up from system headers. Also added some NFS protocol header inclusion. include (HPUX) if exists. Wed Feb 26 00:32:35 1997 Erez "HWank1" Zadok * aux/macros/mount_headers.m4 (define): Use M4 changequote to ensure [] brackets are correctly used. * aux/macros/expand_cpp_{string,hex,int}.m4: encapsulate multi-line M4 inclusions in []. Tue Feb 25 22:19:44 1997 Erez "HWank1" Zadok * conf/mtab/mtab_bsd.c (mnt_dup): use statfs field f_fstypename if it exists. * aux/acconfig.h: HAVE_FIELD_STRUCT_STATFS_F_FSTYPENAME, new config.h macro for field f_fstypename of struct statfs. * aux/configure.in: testing for field f_fstypename field of struct statfs (NetBSD). * aux/acconfig.h: moved all of the "static" definitions out to a fixed file called include/am_defs.h. Added to all */Makefile.am files a dependency on am_defs.h. Created am_defs.h of course, and then added #include to all of the source and header files that required it. Mon Feb 24 01:27:02 1997 Erez Zadok * aux/acconfig.h: two more externals for xdr functions that may be implemented by libamu. * conf/nfs_prot/nfs_prot_bsdi2.h: added missing RPC and XDR definitions. Sun Feb 23 15:25:26 1997 Erez "HWank1" Zadok * buildall (default): added -D option for turning on even stricker developer options. * */Makefile.am: make sure @AMU_NFS_PROT_HEADERS@ is used to determine dependencies on optional NFS protocol headers. * aux/acconfig.h: define and use HAVE_NFS_PROT_HEADERS as needed. * aux/macros/check_nfs_prot_header.m4: new test to determine what NFS protocol headers to use. * conf/nfs_prot/nfs_prot_{irix6,sunos4,bsdi2}.h: new headers to complete missing system headers for NFS protocol definitions. Sun Feb 16 15:58:42 1997 Erez "HWank1" Zadok * amd/ops_nfs.c (mount_nfs_fh): encapsulated some more code in #ifdef's as needed. * amd/ops_afs.c (mount_toplvl): make sure TIMEO/RETRANS code is suitable #ifdef'ed. * include/am_compat.h: a couple more mnttab options (timeo/retrans) setting just in case. * amd/autil.c (host_normalize): make sure hostent->h_name is passed a non-const char *. * conf/mount/mount_linux.c (mount_linux): cleaned up a block of code. * {lib,amq,amd}/*.c (many functions): cast xdr_entry to XDRPROC_T_TYPE. * lib/nfs_prot_svc.c (nfs_program_2): cast xdr_entry to XDRPROC_T_TYPE. * lib/nfs_prot_xdr.c (xdr_entry): cast xdr_entry to XDRPROC_T_TYPE. * lib/wire.c (getwire): Make sure safe assignment from const to none is done. Sat Feb 15 19:38:51 1997 Erez "HWank1" Zadok * aux/macros/expand_cpp_int.m4: new macro for expanding integers. * aux/configure.in: added linux/fs.h support in configure and several M4 macros. * conf/mount/mount_linux.c (mount_linux): use macro instead of "ugly" fixed hex number for mount() arguments. Sat Feb 15 02:09:47 1997 Erez "HWank1" Zadok * amd/info_hesiod.c: removed macro HAVE_HS_ZONE_TRANSFER and turned all of its code always on. That code always seems to compile, as long as you have hesiod and libresolv. * amd/mapc.c: removed macro HAVE_HS_ZONE_TRANSFER and turned all of its code always on. * aux/configure.in: removed superfluous test for hs_zone_transfer function (will never find it because it is an amd-internal function). * amd/mapc.c (maptypes): must used correct new name for am-utils' hesiod initialization function: hesiod_am_init. * amd/info_hesiod.c (hesiod_am_init): renamed hesiod_init to hesiod_am_init so as not to conflict with libhesiod's hesiod_init() function. * aux/configure.in: added test and explicit inclusion of libresolv.a for later resolution of library references with libhesiod. * aux/macros/opt_cppflags.m4: new file. configure/compile C preprocessor flags. * aux/macros/opt_libs.m4: new file. configure/compile library flags. * Makefile.am (EXTRA_DIST_AUX): include two new macros opt_cppflags.m4 and opt_libs.m4. * aux/configure.in: test for libhesiod needs to additional libresolv to link completely. Additional configuration time options added for setting initial CPPFLAGS and LIBS. Tue Feb 10 02:15:40 1997 Erez "HWank1" Zadok ******************************************************************* *** Released am-utils-6.0a1 *** ******************************************************************* Thu Feb 6 02:55:19 1997 Erez "HWank1" Zadok * amd/info_ndbm.c (ndbm_search,ndbm_init): fixed the code so that it works on freebsd, where they map dbm_pagfno a non-existing macro on purpose, to force you to port the code to Berkeley DB. Fri Jan 31 01:35:09 1997 Erez "HWank1" Zadok * amd/ops_afs.c (mount_toplvl): added a sleep(1) right before the actual mount_toplvl, to avoid some possible race conditions. Thu Jan 30 02:31:49 1997 Erez "HWank1" Zadok * amd/rpc_fwd.c: removed all TLI (HAVE_T_OPEN) code. Wed Jan 29 18:25:07 1997 Erez "HWank1" Zadok * lib/wire.c (getwire): removed HAVE_T_OPEN (TLI code) * amd/amd.c (main): fix local address using htonl(). Free up buffers allocated by netdir_*() functions. Wed Jan 22 23:53:24 1997 Erez "HWank1" Zadok * amd/fix-amd-map.in: new script that will convert old-style amd maps to new one. Tue Jan 21 01:18:16 1997 Erez "HWank1" Zadok * FIRST AMD IN AM-UTILS FINALLY WORKS (mounts itself as toplvl, and replies back to simple nfs/link type mount queries). * conf/mtab/mtab_svr4.c: reorganized the code in this file to be easier to read, and fixed a few bugs with un/setting the lock file descriptor. Wed Jan 8 15:27:49 1997 Erez "HWank1" Zadok * amd/sched.c: removed HAS_SVR3_SIGNALS code to handle older signals in Svr3 systems. Only stellix ever used this. * amd/rpc_fwd.c (fwd_reply): removed all code that was triggered by DYNAMIC_BUFFERS, since it was not in use. Tue Jan 7 00:45:59 1997 Erez "HWank1" Zadok * amd/opts.c (eval_opts): removed AMD_COMPAT code. Amd no longer takes '=' sign as old selector. Fix your maps. (deslashify): removed APOLLO code that treated two '//' as one. Sun Jan 5 01:25:09 1997 Erez "HWank1" Zadok * amd/ops_nfsx.c (nfsx_init): removed HARD_NFSX_ERRORS, code which was not used. It made any submount error fail the whole group. * amd/ops_nfs.c (make_nfs_auth): removed code dependent on HAS_NFS_QUALIFIED_NAMES. (mount_nfs_fh): removed macro for NFS_ARGS_NEEDS_PATH, assuming it is never on. So code that was triggered by #ifndef NFS_ARGS_NEEDS_PATH (osf1, aix3, and bsd44 variants) may have to be fixed later. Removed all ULTRIX_HACK code. Ultrix is DEAD! removed all PRESET_AC code, which was only on for Linux to preset the attribute cache values (otherwise they default to zero). (nfs_umounted): revobed KICK_KERNEL code (IRIX systems). Will have to fixed up later. (mount_nfs_fh): removed code that was never included, which attempted to set the port on which amd's nfs mounts on. This isn't supported by the ping algorithm yet. In any case, it is all done in nfs_init(). * amd/srvr_nfs.c (find_nfs_srvr), amd/ops_nfs.c (mount_nfs_fh): removed HAS_TCP_NFS code. The whole use of NFS V.3 with TCP or specially hacked NFS V.2 that uses TCP (BSD 4.4 variants) will have to be addressed later. * amd/nfs_subr.c (nfsproc_getattr_2): removed all code dependent on PRECISE_SYMLINKS. * amd/mapc.c (mapc_meta_search): removed code that depended on HAS_DEPOT. It is known buggy code. The whole DEPOT support needs to be rethought. (mapc_add_kv): ported code to use standard regular expression (regexp) library. * amd/{map.c,ops_sfs.c,ops_ufs.c}: removed all code dependent on FLUSH_KERNEL_NAME_CACHE and the macro itself. Sat Jan 4 15:46:58 1997 Erez "HWank1" Zadok * amd/map.c (exported_ap_alloc): removed all code triggered by SHRINK_EXPORTED_AP and the macro itself. * amd/info_nis.c: removed HAS_NIS_RELOAD macro, and left the code in all the time. Assuming that there is always NIS realod available. (yp_all_fixed): removed code for BROKEN_YP_ALL. If your yp_all() function is broken such that it does not release filedescriptors it created, then you are hosed. Get a fix for yp_all from your vendor or switch operating systems. Tue Dec 31 15:34:36 1996 Erez "HWank1" Zadok * amd/info_hesiod.c: renamed macro HAS_HESIOD_RELOAD to HAVE_HS_ZONE_TRANSFER. Mon Dec 30 17:33:23 1996 Erez "HWank1" Zadok * amd/{nfs,host}_ops.cremoved INFORM_MOUNTD macro, so its code is always included. We should always try to inform the remove mount daemon of mounts we performed. If we want an option for this, it should be a run-time option. * amd/host_ops.c: removed all that optionally did not make the directory mount points for amd. * HOST_EXEC code removed from everywhere. There is no indication that it was used anywhere. If it needs to be used, then a run-time switch should control it. Thu Dec 26 00:06:52 1996 Erez "HWank1" Zadok * amd/*_ops.c: removed all references to mntent_t's fields mnt_freq and mnt_passno, since they are no longe rused (and never have been). * amd/am_ops.c: removed function sunos4_match, which was off anyway. This was one of the places where an '=' sign was allowed as an assignment operator (which is now ':='). * amd/afs_ops.c (afs_bgmount): removed SUNOS4_COMPAT code which was off anyway. This was one of the places where an '=' sign was allowed as an assignment operator (which is now ':='). Tue Dec 24 01:53:52 1996 Erez "HWank1" Zadok * amq/amq.c: ported to am-utils. Working. * conf/mount/mount_svr4.c (mount_svr4): changed mount type on svr4 to be string, as it should be (rather than a string mapped to int and back mapped to string). Sun Dec 22 13:26:05 1996 Erez "HWank1" Zadok * lib/mount_fs.c (mount_fs): removed MNTINFO_PREF code. * lib/umount_fs.c: split this into three files: default, osf, and bsd44, that are in conf/umount/umount_*.c. Thu Dec 19 17:33:46 1996 Erez "HWank1" Zadok * aux/configure.in, aux/aclocal.m4, aux/acconfig.h: added new macro to automatically figure out if an external definition for sys_errlist[] exists. * lib/xutil.c (xfree): removed "#undef free" because it's not needed there. Any system that redefines free() needs help. * conf/mtab/mtab_file.c (REWRITE_MTAB_IN_PLACE): removed code that was dependent on REWRITE_MTAB_IN_PLACE. It does not appear to be in active use anywhere. If added later, it should be a run-time configuration option. * conf/mtab/mtab_mach3.c: removed code that was #ifdef'ed not to be MOUNT_TABLE_ON_FILE, since mach2 always stores its mount tables in a file in /etc. * lib/util.c (str3cat): removed _AIX code. AIX should have a working realloc, or else find a cleaner solution to this. (mkdirs): removed SUNOS4_WORKAROUND code. This was to do a sync() after immediately making directories so that fsck will be able to fix the filesystem in the event of an immediate crash. This was because a bug in UFS which is fixed by now. * lib/hutil.c (domain_strip): removed PARTIAL_DOMAINS triggered code. Does not appear to be on and used anywhere. (dofork): removed MACH3 code, b/c mach3 NFS bugs are fixed by now. * lib/resvport.c: split the binding of reserved ports code to a separate file. A #define (HAVE_T_OPEN) separates the TLI (SVR4) from the BSD code. Thu Dec 19 02:08:35 1996 Erez "HWank1" Zadok * lib/Makefile.am (amu_LIBADD): includs @LIBOBJS@ now, auto-filled in by automake and configure, for optional sources that need to be built as part of libamu.a. * aux/aclocal.m4: Make sure AC_CHECK_MOUNT_STYLE adds mountutil.o to LIBOBJS. * lib/memcmp.c (memcmp): new file added to replace a possible bad implementation of memcmp. Wed Dec 18 22:20:23 1996 Erez "HWank1" Zadok * converted the sources to use memset/memmove/memcmp instead of bzero/bcopy/bcmp. * ran all sources through gnu Indent w/ options specified in aux/amindent. Wed Dec 11 22:19:29 1996 Erez "HWank1" Zadok * At this point the initial generation of config.h via autoconf and some preliminary makefiles via automake is done. I will not begin modifying sources, so it's a good time to document from here. Wed Dec 10 22:19:29 1996 Erez "HWank1" Zadok ******************************************************************* *** Initial ChangeLog Entry *** ******************************************************************* am-utils-6.2+rc20110530/FAQ000066400000000000000000000056561157065440000147000ustar00rootroot00000000000000 Am-utils Frequently Asked Questions Note: we started this FAQ only on March 15, 2005; so it's not long or comprehensive, yet. Amd is much older than that, and so there's a lot of information that's already available in other forms. If this FAQ doesn't answer your questions, see information in the following sources: 1. The Am-utils book: http://www.am-utils.org/docs/amd-book/ 2. The Am-utils user manual, which is part of the distribution and is also available from www.am-utils.org. 3. The www.am-utils.org Web site resources, especially the "am-utils" mailing list (and its archives). 4. In the am-utils distribution (always use the latest ones), see all of the various README files (README, README.autofs, README.ldap, README.osx, and README.y2k). The "BUGS" file also lists useful information about bugs and problems with specific OSs which affect Amd. All of these text files are also available from www.am-utils.org. 5. Some FAQ questions (including newbie questions) are available here: http://www.kernelcorp.com/resources_faqs.html 6. Some problems are known bugs but have not been fixed yet: this are listed in bugzilla in https://bugzilla.am-utils.org/ If you have additions to this FAQ, please let us know at the am-utils list (see www.am-utils.org). Thank you, The Am-utils development team. *** Linux Questions Q1. When I use Amd with Autofs and I restart Amd, how come it cannot remount the Autofs partitions? A1. This is a limitation of the Linux Autofs kernel module (for both autofs v2. and v3). The Linux Autofs does not allow restarting automounted points. There's nothing Amd can do about this. In fact, the same problem exists if you use the userland "automount" daemon instead of Amd. Hopefully Autofs-v4 or the separate effort of Autofs-NG will address this serious problem. Note that Amd itself can restart autofs automounted points just fine on OSs that support it, for example Solaris. Q2. When I use Amd, I get this console message frequently: "mount version older than kernel." Is it a problem? A2. No, it's a harmless warning message that the Linux kernel prints for NFS mounts. The intent was to alert administrators that the kernel has supposedly a different version of the mount(2) code than a userland program used. This happens if you compile Amd against kernel headers that are different than the kernel you're running. If the message really bothers you, then one way to "fix" the problem is to recompile Amd against the same kernel headers as the running kernel. Nevertheless, it is a relatively useless message because as far as we know, the NFS v2 and v3 mount codes have been in perfect sync between the userland and kernel sides, and were "standardized" for years already. This warning message caused more unnecessary worry among administrators than helping alert them to legitimate problems. am-utils-6.2+rc20110530/INSTALL000066400000000000000000000363321157065440000153720ustar00rootroot00000000000000Installation Instructions ************************* Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. Basic Installation ================== Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package. The following more-detailed instructions are generic; see the `README' file for instructions specific to this package. Some packages provide this `INSTALL' file but do not implement all of the features documented below. The lack of an optional feature in a given package is not necessarily a bug. More recommendations for GNU packages can be found in *note Makefile Conventions: (standards)Makefile Conventions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). It can also use an optional file (typically called `config.cache' and enabled with `--cache-file=config.cache' or simply `-C') that saves the results of its tests to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files. If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If you are using the cache, and at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.ac' (or `configure.in') is used to create `configure' by a program called `autoconf'. You need `configure.ac' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. Running `configure' might take a while. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package, generally using the just-built uninstalled binaries. 4. Type `make install' to install the programs and any data files and documentation. When installing into a prefix owned by root, it is recommended that the package be configured and built as a regular user, and only the `make install' phase executed with root privileges. 5. Optionally, type `make installcheck' to repeat any self-tests, but this time using the binaries in their final installed location. This target does not install anything. Running this target as a regular user, particularly if the prior `make install' required root privileges, verifies that the installation completed correctly. 6. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. 7. Often, you can also type `make uninstall' to remove the installed files again. In practice, not all packages have tested that uninstallation works correctly, even though it is required by the GNU Coding Standards. 8. Some packages, particularly those that use Automake, provide `make distcheck', which can by used by developers to test that all other targets like `make install' and `make uninstall' work correctly. This target is generally not run by end users. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. Run `./configure --help' for details on some of the pertinent environment variables. You can give `configure' initial values for configuration parameters by setting variables in the command line or in the environment. Here is an example: ./configure CC=c99 CFLAGS=-g LIBS=-lposix *Note Defining Variables::, for more details. Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you can use GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. This is known as a "VPATH" build. With a non-GNU `make', it is safer to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. On MacOS X 10.5 and later systems, you can create libraries and executables that work on multiple system types--known as "fat" or "universal" binaries--by specifying multiple `-arch' options to the compiler but only a single `-arch' option to the preprocessor. Like this: ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ CPP="gcc -E" CXXCPP="g++ -E" This is not guaranteed to produce working output in all cases, you may have to build one architecture at a time and combine the results using the `lipo' tool if you have problems. Installation Names ================== By default, `make install' installs the package's commands under `/usr/local/bin', include files under `/usr/local/include', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PREFIX', where PREFIX must be an absolute file name. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you pass the option `--exec-prefix=PREFIX' to `configure', the package uses PREFIX as the prefix for installing programs and libraries. Documentation and other data files still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=DIR' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. In general, the default for these options is expressed in terms of `${prefix}', so that specifying just `--prefix' will affect all of the other directory specifications that were not explicitly provided. The most portable way to affect installation locations is to pass the correct locations to `configure'; however, many packages provide one or both of the following shortcuts of passing variable assignments to the `make install' command line to change installation locations without having to reconfigure or recompile. The first method involves providing an override variable for each affected directory. For example, `make install prefix=/alternate/directory' will choose an alternate location for all directory configuration variables that were expressed in terms of `${prefix}'. Any directories that were specified during `configure', but not in terms of `${prefix}', must each be overridden at install time for the entire installation to be relocated. The approach of makefile variable overrides for each directory variable is required by the GNU Coding Standards, and ideally causes no recompilation. However, some platforms have known limitations with the semantics of shared libraries that end up requiring recompilation when using this method, particularly noticeable in packages that use GNU Libtool. The second method involves providing the `DESTDIR' variable. For example, `make install DESTDIR=/alternate/directory' will prepend `/alternate/directory' before all installation names. The approach of `DESTDIR' overrides is not required by the GNU Coding Standards, and does not work on platforms that have drive letters. On the other hand, it does better at avoiding recompilation issues, and works well even when some directory options were not specified in terms of `${prefix}' at `configure' time. Optional Features ================= If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Some packages offer the ability to configure how verbose the execution of `make' will be. For these packages, running `./configure --enable-silent-rules' sets the default to minimal output, which can be overridden with `make V=1'; while running `./configure --disable-silent-rules' sets the default to verbose, which can be overridden with `make V=0'. Particular systems ================== On HP-UX, the default C compiler is not ANSI C compatible. If GNU CC is not installed, it is recommended to use the following options in order to use an ANSI C compiler: ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" and if that doesn't work, install pre-built binaries of GCC for HP-UX. On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot parse its `' header file. The option `-nodtk' can be used as a workaround. If GNU CC is not installed, it is therefore recommended to try ./configure CC="cc" and if that doesn't work, try ./configure CC="cc -nodtk" On Solaris, don't put `/usr/ucb' early in your `PATH'. This directory contains several dysfunctional programs; working variants of these programs are available in `/usr/bin'. So, if you need `/usr/ucb' in your `PATH', put it _after_ `/usr/bin'. On Haiku, software installed for all users goes in `/boot/common', not `/usr/local'. It is recommended to use the following options: ./configure --prefix=/boot/common Specifying the System Type ========================== There may be some features `configure' cannot figure out automatically, but needs to determine by the type of machine the package will run on. Usually, assuming the package is built to be run on the _same_ architectures, `configure' can figure that out, but if it prints a message saying it cannot guess the machine type, give it the `--build=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name which has the form: CPU-COMPANY-SYSTEM where SYSTEM can have one of these forms: OS KERNEL-OS See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the machine type. If you are _building_ compiler tools for cross-compiling, you should use the option `--target=TYPE' to select the type of system they will produce code for. If you want to _use_ a cross compiler, that generates code for a platform different from the build platform, you should specify the "host" platform (i.e., that on which the generated programs will eventually be run) with `--host=TYPE'. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Defining Variables ================== Variables not defined in a site shell script can be set in the environment passed to `configure'. However, some packages may run configure again during the build, and the customized values of these variables may be lost. In order to avoid this problem, you should set them in the `configure' command line, using `VAR=value'. For example: ./configure CC=/usr/local2/bin/gcc causes the specified `gcc' to be used as the C compiler (unless it is overridden in the site shell script). Unfortunately, this technique does not work for `CONFIG_SHELL' due to an Autoconf bug. Until the bug is fixed you can use this workaround: CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash `configure' Invocation ====================== `configure' recognizes the following options to control how it operates. `--help' `-h' Print a summary of all of the options to `configure', and exit. `--help=short' `--help=recursive' Print a summary of the options unique to this package's `configure', and exit. The `short' variant lists options used only in the top level, while the `recursive' variant lists options also present in any nested packages. `--version' `-V' Print the version of Autoconf used to generate the `configure' script, and exit. `--cache-file=FILE' Enable the cache: use and save the results of the tests in FILE, traditionally `config.cache'. FILE defaults to `/dev/null' to disable caching. `--config-cache' `-C' Alias for `--cache-file=config.cache'. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--prefix=DIR' Use DIR as the installation prefix. *note Installation Names:: for more details, including other options available for fine-tuning the installation locations. `--no-create' `-n' Run the configure checks, but stop before creating any output files. `configure' also accepts some other, not widely useful, options. Run `configure --help' for more details. am-utils-6.2+rc20110530/INSTALL.am-utils000066400000000000000000000122241157065440000171160ustar00rootroot00000000000000 am-utils 6.1 compatibility list For each system, list if it autoconfigures, compiles, or runs. Fill in email id of person who confirms the fact. A missing entry means unverified. A 'no' or 'X' means verified broken or nonexistent (static library). SYSTEM CONFIG COMPILE RUN SHLIB AUTOFS ========================= ======= ======= ======= ======= ====== alpha-dec-osf4.0f ro ro ro - - alpha-dec-osf5.1 ro ro ro - - alpha-unknown-linux-gentoo1.4.16 ezk ezk ezk ezk - alphaev56-dec-osf4.0f ezk ezk ezk ezk - i386-apple-darwin6.0 ezk ezk ezk ezk - i386-pc-bsdi2.1 ion ion ion ion[X] ion[X] i386-pc-linux-deb3.0 ezk ezk ezk ezk - i386-pc-linux-deb3.1 ezk ezk ezk ezk - i386-pc-linux-fc1 ezk ezk ezk ezk - i386-pc-linux-fc2 ezk ezk ezk ezk - i386-pc-linux-fc3 ezk ezk ezk ezk - i386-pc-linux-fc4 ezk ezk ezk ezk - i386-pc-linux-gentoo1.4.16 ezk ezk ezk ezk - i386-pc-linux-rh6.2 ion ion ion ion ion i386-pc-linux-rh7.1 ion ion ion ion ion i386-pc-linux-rh7.2 ion ion ion ion ion i386-pc-linux-rh7.3 ion ion ion ion ion i386-pc-linux-rh8.0 ezk ezk ezk ezk - i386-pc-linux-rh9 ion ion ion ion ion i386-pc-linux-rhel3 ezk ezk ezk ezk - i386-pc-linux-rhel4 ezk ezk ezk ezk - i386-pc-linux-suse8.2 ezk ezk ezk ezk - i386-pc-linux-suse9.1 ezk ezk ezk ezk - i386-pc-linux-suse9.2 ezk ezk ezk ezk - i386-pc-linux-suse9.3 ezk ezk ezk ezk - i386-pc-solaris2.10 ro ro ro - - i386-pc-solaris2.9 ro ro ro - - i386-unknown-freebsd4.10 ezk ezk ezk ezk - i386-unknown-freebsd4.11 ezk ezk ezk ezk - i386-unknown-freebsd4.8 ezk ezk ezk ezk - i386-unknown-freebsd4.9 ezk ezk ezk ezk - i386-unknown-freebsd5.0 ezk ezk - ezk - i386-unknown-freebsd5.1 ezk ezk ezk ezk - i386-unknown-freebsd5.2 ezk ezk ezk ezk - i386-unknown-freebsd5.2.1 ezk ezk ezk ezk - i386-unknown-freebsd5.3 ezk ezk ezk ezk - i386-unknown-freebsd5.4 ezk ezk ezk ezk - i386-unknown-freebsd6 (BETA5) ezk ezk ezk ezk - i386-unknown-netbsd1.6A ezk ezk ezk ezk - i386-unknown-netbsdelf1.6.1 ezk ezk ezk ezk - i386-unknown-netbsdelf1.6.2 ezk ezk ezk ezk - i386-unknown-netbsdelf2.0 ezk ezk ezk ezk - i386-unknown-netbsdelf2.0.2 ezk ezk ezk ezk - i386-unknown-netbsdelf3.0 ezk ezk ezk ezk - i386-unknown-openbsd3.3 ezk ezk ezk ezk - i386-unknown-openbsd3.6 ezk ezk ezk ezk - i386-unknown-openbsd3.7 ezk ezk ezk ezk - i686-apple-darwin6.6 ezk ezk ezk ezk - ia64-hp-hpux11.20 ezk ezk ezk ezk - ia64-unknown-linux-rh2.1AS ezk ezk - ezk - ia64-unknown-linux-rh2.1AW ezk ezk ezk ezk - ia64-unknown-linux-rhel4 ezk ezk ezk ezk - mips-sgi-irix6.2 ro ro ro - -[3] mips-sgi-irix6.5 ro ro ro - -[3] mips-unknown-linux-gentoo1.4.16 ezk ezk ezk ezk - mipsel-unknown-linux-rhPS2 ezk ezk ezk ezk - powerpc-apple-darwin7.6.0 ezk ezk ezk ezk - powerpc-apple-darwin7.7.0 ezk ezk ezk ezk - powerpc-apple-darwin7.8.0 ezk ezk ezk ezk - powerpc-apple-darwin7.9.0 ezk ezk ezk ezk - powerpc-apple-darwin8.2.0 ezk ezk ezk ezk - powerpc-ibm-aix5.1.0.0 ion ion ion ion[X] ion[1,2] powerpc-ibm-aix5.2.0.0 ezk ezk ezk ezk - powerpc-ibm-aix5.3.0.0 ezk ezk ezk ezk - powerpc-unknown-linux-yellowdog2.3 ezk ezk ezk ezk - sparc-sun-solaris2.10 ro ro ro - - sparc-sun-solaris2.5.1 ion ion ion ion ion[1] sparc-sun-solaris2.6 ion ion ion ion ion sparc-sun-solaris2.7 ion ion ion ion ion sparc-sun-solaris2.8 ion ion ion ion ion sparc-sun-solaris2.9 ro ro ro - - sparc-unknown-linux-rh62 ion ion ion ion ion sparc64-unknown-linux-aurora10 ion ion ion ion ion sparc64-unknown-linux-deb3.0 ezk ezk ezk ezk - sparc64-unknown-linux-gentoo1.4.16 ezk ezk ezk ezk - sparc64-unknown-linux-rh62 ion ion ion ion ion sparc64-unknown-linux-suse7.3 ezk ezk - ezk - x86_64-unknown-linux-rh2.9.5AS ezk ezk ezk ezk - x86_64-unknown-linux-rh3.0.0AS ion ion ion ion ion EMAIL ID LEGEND: bking: Bevis R W King dsr: Dan Riley ezk: Erez Zadok finkel: Raphael Finkel ion: Ion Badulescu jose: Jose Nazario nrh: Nick Hall ro: Rainer Orth stolke: Andreas Stolcke wpaul: Bill Paul FOOTNOTES: [1] Due to limitations in the Sun autofs v1 implementation, some amd features cannot be properly supported. More precisely, trying to access a link mount pointing to another amd entry will result in failure and/or deadlock. Ordinary nfs and link mounts work well, however. [2] AIX autofs appears to be a variant of the Sun autofs v1 protocol, but IBM don't provide any sort of documentation or even header files from it. It is currently unsupported; we may add some experimental support for it at some point, though it won't be pretty. Assistance from IBM-ers would be highly appreciated, hint hint. [3] IRIX 6 autofs uses the Sun autofs v1 protocol, too. The header files are part of the onc3_eoe.sw.autofs (IRIX 6.2) or nfs.sw.autofs (IRIX 6.5) package, which may not be installed. The autofs code is known to compile, but hasn't been run yet. SGI's autofsd uses a barely documented system call, syssgi(SGI_AUTOFS_SYS, ...), which may be required to get working autofs support. Additional help from SGI would be highly appreciated. Erez & Ion am-utils-6.2+rc20110530/LSM.am-utils000066400000000000000000000013211157065440000164370ustar00rootroot00000000000000Begin3 Title: am-utils Version: 6.0.1 Entered-date: 08SEP99 Description: BSD Automounter Utilities Replaces the old amd-upl102. Offers NFS V3 support, many new features, and numerous ports. The home page for am-utils is in http://www.am-utils.org Keywords: amd amq hlfsd fsinfo wire-test fixmount mk-amd-map automount Author: ezk AT cs.columbia.edu (Erez Zadok) Maintained-by: ezk AT cs.columbia.edu (Erez Zadok) Primary-site: shekel.mcl.cs.columbia.edu /pub/am-utils 1.3MB am-utils-6.0.1.tar.gz 1.3MB am-utils.tar.gz 1.3MB am-utils-snapshot.tar.gz Alternate-site: http://www.am-utils.org/mirrors.html Original-site: ftp.cs.columbia.edu /pub/amd Platforms: all modern Unix systems Copying-policy: BSD End am-utils-6.2+rc20110530/MIRRORS.html000066400000000000000000000053501157065440000163600ustar00rootroot00000000000000 Am-Utils 6.x Mirror Sites

Am-Utils 6.x Software Mirror Sites

Note: in case of any problems accessing the individual FTP sites, please contact their respective maintainers. If you wish to be added to the official mirror list, please send mail to "am-utils-developers AT am-utils.org" with the full URL, maintainer's email, and geographical location.

North America

Europe

Asia


Last updated: 2006-11-27 am-utils-6.2+rc20110530/MIRRORS.txt000066400000000000000000000036021157065440000162310ustar00rootroot00000000000000 AM-UTILS-6.x MIRRORS Note: in case of any problems accessing the individual FTP sites, please contact their respective maintainers. If you wish to be added to the official mirror list, please send mail to am-utils-developers AT am-utils.org with the full URL, maintainer's email, and geographical location. U.S.A: New York (Stony Brook, Primary Site): ftp://ftp.am-utils.org/pub/am-utils Maintainer: ezk AT am-utils.org Minnesota: ftp://ftp.cs.umn.edu/pub/am-utils Maintainer: dokas AT cs.umn.edu #Avoid for now: empty directory # Virginia (Newport News): # ftp://ftp.ferginc.com/pub/unix/am-utils # Maintainer: Branson.Matheson AT FergInc.com #server gone? (Jan 5, 2004) # Ohio (Kent State University): # ftp://info.mcs.kent.edu/pub/am-utils # Maintainer: root AT mcs.kent.edu Florida (University of Florida) ftp://ftp.cise.ufl.edu/pub/mirrors/am-utils Maintainer: mirror AT cise.ufl.edu Europe: Germany: ftp://ftp.fu-berlin.de/unix/network/am-utils Maintainer: ftp-adm AT ftp.fu-berlin.de Germany: ftp://ftp.tu-darmstadt.de/pub/networking/filesystems/am-utils/ Maintainer: networking AT ftp.tu-darmstadt.de Sweden: ftp://ftp.sunet.se/pub/unix/admin/am-utils Maintainer: archive AT ftp.sunet.se # not responding (Jan 5, 2004) # Sweden (Stockholm University, Math Depat): # ftp://mirror.matematik.su.se/pub/am-utils # Maintainer: leifj AT matematik.su.se UK: ftp://sunsite.org.uk/package/am-utils Maintainer: lmjm AT icparc.ic.ac.uk Asia: Japan: ftp://ftp.u-aizu.ac.jp/pub/net/amd/am-utils Maintainer: ftp-admin AT u-aizu.ac.jp Japan: ftp://core.ring.gr.jp/pub/net/am-utils/ Maintainer: ftpadmin AT ring.gr.jp Japan: ftp://ftp.ring.gr.jp/pub/net/am-utils/ Maintainer: ftpadmin AT ring.gr.jp # gone? (Jan 5, 2004) # Australia: # Melbourne: # ftp://ftp.sage-au.org.au/pub/network/filesystem/am-utils # Maintainer: mirror AT ftp.sage-au.org.au am-utils-6.2+rc20110530/Makefile.am000066400000000000000000000232421157065440000163710ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in # Package: am-utils # Level: Top level Makefile # Author: Erez Zadok @SET_MAKE@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = \ libamu \ amd \ amq \ \ fixmount \ fsinfo \ hlfsd \ mk-amd-map \ wire-test \ \ scripts \ doc # temporary tests override SUBDIRS #SUBDIRS = lib wire-test amq amd # additional files to add to the distribution tar file # m4/aclocal EXTRA_DIST_M4 = \ vers.m4 \ \ m4/GNUmakefile \ m4/amdgrep \ m4/amindent \ m4/autopat \ m4/chop-aclocal.pl \ m4/copy-if-newbig \ m4/mk-aclocal \ m4/mkconf \ m4/rmtspc \ m4/update_build_version \ \ m4/macros/HEADER \ m4/macros/TRAILER \ m4/macros/c_void_p.m4 \ m4/macros/cache_check_dynamic.m4 \ m4/macros/check_amu_fs.m4 \ m4/macros/check_autofs_style.m4 \ m4/macros/check_checkmount_style.m4 \ m4/macros/check_extern.m4 \ m4/macros/check_extern_ldap.m4 \ m4/macros/check_fhandle.m4 \ m4/macros/check_field.m4 \ m4/macros/check_fs_headers.m4 \ m4/macros/check_fs_mntent.m4 \ m4/macros/check_gnu_getopt.m4 \ m4/macros/check_hide_mount_type.m4 \ m4/macros/check_lib2.m4 \ m4/macros/check_libwrap_severity.m4 \ m4/macros/check_map_funcs.m4 \ m4/macros/check_mnt2_cdfs_opt.m4 \ m4/macros/check_mnt2_gen_opt.m4 \ m4/macros/check_mnt2_nfs_opt.m4 \ m4/macros/check_mnt2_pcfs_opt.m4 \ m4/macros/check_mnttab_file_name.m4 \ m4/macros/check_mnttab_location.m4 \ m4/macros/check_mnttab_opt.m4 \ m4/macros/check_mnttab_style.m4 \ m4/macros/check_mnttab_type.m4 \ m4/macros/check_mount_style.m4 \ m4/macros/check_mount_trap.m4 \ m4/macros/check_mount_type.m4 \ m4/macros/check_mtype_printf_type.m4 \ m4/macros/check_mtype_type.m4 \ m4/macros/check_network_transport_type.m4 \ m4/macros/check_nfs_fh_dref.m4 \ m4/macros/check_nfs_hn_dref.m4 \ m4/macros/check_nfs_prot_headers.m4 \ m4/macros/check_nfs_sa_dref.m4 \ m4/macros/check_nfs_socket_connection.m4 \ m4/macros/check_os_libs.m4 \ m4/macros/check_restartable_signal_handler.m4 \ m4/macros/check_umount_style.m4 \ m4/macros/check_unmount_args.m4 \ m4/macros/check_unmount_call.m4 \ m4/macros/check_varargs_macros.m4 \ m4/macros/expand_cpp_hex.m4 \ m4/macros/expand_cpp_int.m4 \ m4/macros/expand_cpp_string.m4 \ m4/macros/expand_run_string.m4 \ m4/macros/extern_optarg.m4 \ m4/macros/extern_sys_errlist.m4 \ m4/macros/field_mntent_t_mnt_time_string.m4 \ m4/macros/func_bad_hasmntopt.m4 \ m4/macros/func_bad_memcmp.m4 \ m4/macros/func_bad_yp_all.m4 \ m4/macros/header_templates.m4 \ m4/macros/host_macros.m4 \ m4/macros/libtool.m4 \ m4/macros/linux_headers.m4 \ m4/macros/localconfig.m4 \ m4/macros/mount_headers.m4 \ m4/macros/opt_amu_cflags.m4 \ m4/macros/opt_cppflags.m4 \ m4/macros/opt_debug.m4 \ m4/macros/opt_ldflags.m4 \ m4/macros/opt_libs.m4 \ m4/macros/os_cflags.m4 \ m4/macros/os_cppflags.m4 \ m4/macros/os_ldflags.m4 \ m4/macros/package_bugreport.m4 \ m4/macros/package_name.m4 \ m4/macros/package_version.m4 \ m4/macros/prog_lex.m4 \ m4/macros/prog_yacc.m4 \ m4/macros/save_state.m4 \ m4/macros/struct_field_nfs_fh.m4 \ m4/macros/struct_mntent.m4 \ m4/macros/struct_mnttab.m4 \ m4/macros/struct_nfs_args.m4 \ m4/macros/struct_nfs_fh.m4 \ m4/macros/struct_nfs_fh3.m4 \ m4/macros/struct_nfs_gfs_mount.m4 \ m4/macros/try_compile_anyfs.m4 \ m4/macros/try_compile_nfs.m4 \ m4/macros/try_compile_rpc.m4 \ m4/macros/type_auth_create_gidlist.m4 \ m4/macros/type_autofs_args.m4 \ m4/macros/type_cachefs_args.m4 \ m4/macros/type_cdfs_args.m4 \ m4/macros/type_udf_args.m4 \ m4/macros/type_efs_args.m4 \ m4/macros/type_lofs_args.m4 \ m4/macros/type_mfs_args.m4 \ m4/macros/type_pcfs_args.m4 \ m4/macros/type_pte_t.m4 \ m4/macros/type_recvfrom_fromlen.m4 \ m4/macros/type_rfs_args.m4 \ m4/macros/type_rpcvers_t.m4 \ m4/macros/type_svc_in_arg.m4 \ m4/macros/type_time_t.m4 \ m4/macros/type_tmpfs_args.m4 \ m4/macros/type_ufs_args.m4 \ m4/macros/type_xdrproc_t.m4 \ m4/macros/type_xfs_args.m4 \ m4/macros/type_yp_order_outorder.m4 \ m4/macros/with_addon.m4 EXTRA_DIST_CONF = \ conf/autofs/autofs_default.h \ conf/autofs/autofs_default.c \ conf/autofs/autofs_linux.h \ conf/autofs/autofs_linux.c \ conf/autofs/autofs_solaris_v1.h \ conf/autofs/autofs_solaris_v1.c \ conf/autofs/autofs_solaris_v2_v3.h \ conf/autofs/autofs_solaris_v2_v3.c \ \ conf/checkmount/checkmount_aix.c \ conf/checkmount/checkmount_bsd44.c \ conf/checkmount/checkmount_default.c \ conf/checkmount/checkmount_osf.c \ conf/checkmount/checkmount_svr4.c \ conf/checkmount/checkmount_ultrix.c \ \ conf/fh_dref/fh_dref_aix3.h \ conf/fh_dref/fh_dref_aix42.h \ conf/fh_dref/fh_dref_bsd44.h \ conf/fh_dref/fh_dref_default.h \ conf/fh_dref/fh_dref_freebsd22.h \ conf/fh_dref/fh_dref_hpux.h \ conf/fh_dref/fh_dref_irix.h \ conf/fh_dref/fh_dref_isc3.h \ conf/fh_dref/fh_dref_linux.h \ conf/fh_dref/fh_dref_nextstep.h \ conf/fh_dref/fh_dref_osf2.h \ conf/fh_dref/fh_dref_osf4.h \ conf/fh_dref/fh_dref_sunos3.h \ conf/fh_dref/fh_dref_sunos4.h \ conf/fh_dref/fh_dref_svr4.h \ \ conf/hn_dref/hn_dref_default.h \ conf/hn_dref/hn_dref_isc3.h \ conf/hn_dref/hn_dref_linux.h \ \ conf/mount/mount_aix.c \ conf/mount/mount_aix3.c \ conf/mount/mount_bsdi3.c \ conf/mount/mount_default.c \ conf/mount/mount_hpux.c \ conf/mount/mount_irix5.c \ conf/mount/mount_irix6.c \ conf/mount/mount_isc3.c \ conf/mount/mount_linux.c \ conf/mount/mount_mach3.c \ conf/mount/mount_stellix.c \ conf/mount/mount_svr4.c \ \ conf/mtab/mtab_aix.c \ conf/mtab/mtab_bsd.c \ conf/mtab/mtab_file.c \ conf/mtab/mtab_isc3.c \ conf/mtab/mtab_linux.c \ conf/mtab/mtab_mach3.c \ conf/mtab/mtab_osf.c \ conf/mtab/mtab_svr4.c \ conf/mtab/mtab_ultrix.c \ \ conf/nfs_prot/nfs_prot_aix3.h \ conf/nfs_prot/nfs_prot_aix4.h \ conf/nfs_prot/nfs_prot_aix4_2.h \ conf/nfs_prot/nfs_prot_aix4_3.h \ conf/nfs_prot/nfs_prot_aix5_1.h \ conf/nfs_prot/nfs_prot_aix5_2.h \ conf/nfs_prot/nfs_prot_bsdi2.h \ conf/nfs_prot/nfs_prot_bsdi3.h \ conf/nfs_prot/nfs_prot_darwin.h \ conf/nfs_prot/nfs_prot_default.h \ conf/nfs_prot/nfs_prot_freebsd2.h \ conf/nfs_prot/nfs_prot_freebsd3.h \ conf/nfs_prot/nfs_prot_hpux.h \ conf/nfs_prot/nfs_prot_hpux11.h \ conf/nfs_prot/nfs_prot_irix5.h \ conf/nfs_prot/nfs_prot_irix6.h \ conf/nfs_prot/nfs_prot_linux.h \ conf/nfs_prot/nfs_prot_ncr2.h \ conf/nfs_prot/nfs_prot_nextstep.h \ conf/nfs_prot/nfs_prot_netbsd.h \ conf/nfs_prot/nfs_prot_netbsd1_3.h \ conf/nfs_prot/nfs_prot_netbsd1_4.h \ conf/nfs_prot/nfs_prot_openbsd.h \ conf/nfs_prot/nfs_prot_osf2.h \ conf/nfs_prot/nfs_prot_osf4.h \ conf/nfs_prot/nfs_prot_osf5.h \ conf/nfs_prot/nfs_prot_sunos3.h \ conf/nfs_prot/nfs_prot_sunos4.h \ conf/nfs_prot/nfs_prot_sunos5_3.h \ conf/nfs_prot/nfs_prot_sunos5_4.h \ conf/nfs_prot/nfs_prot_sunos5_5.h \ conf/nfs_prot/nfs_prot_sunos5_6.h \ conf/nfs_prot/nfs_prot_sunos5_7.h \ conf/nfs_prot/nfs_prot_sunos5_8.h \ conf/nfs_prot/nfs_prot_svr4.h \ conf/nfs_prot/nfs_prot_ultrix.h \ \ conf/sa_dref/sa_dref_386bsd.h \ conf/sa_dref/sa_dref_aix3.h \ conf/sa_dref/sa_dref_aoi.h \ conf/sa_dref/sa_dref_bsd44.h \ conf/sa_dref/sa_dref_default.h \ conf/sa_dref/sa_dref_isc3.h \ conf/sa_dref/sa_dref_linux.h \ conf/sa_dref/sa_dref_svr4.h \ \ conf/transp/transp_sockets.c \ conf/transp/transp_tli.c \ \ conf/trap/trap_aix3.h \ conf/trap/trap_aux.h \ conf/trap/trap_default.h \ conf/trap/trap_dgux.h \ conf/trap/trap_hcx.h \ conf/trap/trap_hpux.h \ conf/trap/trap_irix.h \ conf/trap/trap_isc3.h \ conf/trap/trap_linux.h \ conf/trap/trap_mach3.h \ conf/trap/trap_netbsd.h \ conf/trap/trap_news4.h \ conf/trap/trap_rtu6.h \ conf/trap/trap_stellix.h \ conf/trap/trap_svr4.h \ conf/trap/trap_ultrix.h \ \ conf/umount/umount_aix.c \ conf/umount/umount_bsd44.c \ conf/umount/umount_default.c \ conf/umount/umount_linux.c \ conf/umount/umount_osf.c EXTRA_DIST_INCLUDE = \ include/am_compat.h \ include/am_utils.h \ include/am_xdr_func.h \ include/am_defs.h \ include/amq_defs.h \ include/mount_headers1.h \ include/mount_headers2.h EXTRA_DIST = \ $(EXTRA_DIST_M4) \ $(EXTRA_DIST_CONF) \ $(EXTRA_DIST_INCLUDE) \ \ BUGS \ FAQ \ LSM.am-utils \ MIRRORS.txt \ MIRRORS.html \ README.attrcache \ README.autofs \ README.ldap \ README.osx \ README.sun2amd \ README.y2k \ bootstrap \ buildall \ config.guess.long \ depcomp \ ldap.schema \ ldap-id.ms \ ldap-id.txt \ stamp-h.in \ tasks DISTCLEANFILES = amu_nfs_prot.h amu_autofs_prot.h config.cache.old dbgcf.h CLEANFILES = dbgcf.h ############################################################################## # Personal maintainer rules by Erez Zadok # update possibly new versions of autoconf/automake/libtool files update: (cd $(top_srcdir) && ${MAKE} ${MFLAGS} -f ./m4/GNUmakefile update) ${MAKE} ${MFLAGS} libtool # remake libtool libtool: $(LIBTOOL_DEPS) $(SHELL) ./config.status --recheck # make a snapshots and put them in the ftp snapshots directory FTPTOP=/var/ftp/pub/am-utils snapshot: dist install-snapshot install-snapshot: snap=`/bin/ls -1 am-utils*.tar.gz` && \ echo COPYING SNAPSHOTS: $$snap && \ cp -pu $$snap $(FTPTOP)/snapshots && \ rm -f $(FTPTOP)/am-utils-6.1-snapshot.tar.gz && \ ln -s snapshots/$$snap $(FTPTOP)/am-utils-6.1-snapshot.tar.gz && \ (cd $(FTPTOP) && ${MAKE} ${MFLAGS}) && \ (cd $(FTPTOP)/snapshots && ${MAKE} ${MFLAGS}) test-snapshot: dist mv -f am-utils*.tar.gz /var/ftp/private/ezk # dist hook: change directory modes so they are not world writable dist-hook: @echo "Protecting distribution directories..." chmod -R go-w $(distdir) am-utils-6.2+rc20110530/NEWS000066400000000000000000001630541157065440000150420ustar00rootroot00000000000000*** Notes specific to am-utils version 6.2-rc1 - Changes to work with Linux-2.6.x and NetBSD-5.x - Many bug fixes, see ChangeLog - Add synchronous unmount code for amq -uu - Empty variable assignments, now unset the variable value. - Add TMPFS and UDF filesystem support. - Allow a comma-separated list of LDAP servers for failover - Share LDAP connections between different maps to save resources *** Notes specific to am-utils version 6.2a3 - minor new ports: i386-apple-darwin8.8.1 i386-pc-linux-centos4.4 (RHEL4 clone) i386-pc-linux-fc6 (Fedora Core 6) i386-pc-solaris2.11-nexentaos (GNU/OpenSolaris) ia64-hp-hpux11.23 (gcc and cc) powerpc-apple-darwin8.7.0 - Bugs fixed: * reduce annoying warnings from xstrlcpy when expanding options. * translate '*' Sun maps correctly with "${key}" *** Notes specific to am-utils version 6.2a2 New amd.conf global parameter: nfs_allow_any_interface. By default it is set to 'no' which means that Amd accepts local NFS packets only from 127.0.0.1. If set to 'yes' then Amd will accept local NFS packets from any local interface; this is useful on hosts that may have multiple interfaces where the system is forced to send all outgoing packets (even those bound to the same host) via an address other than 127.0.0.1. Add support for specifying the host to match in the mount selectors netgrp and netgrpd. Now one can use either netgrp() or netgrp(,). Support new mount options for type:=pcfs mounts: longname, nowin95, shortname, user=N, group=N, mask=N, and dirmask=N. Two new amd.conf [global] parameters: nfs_retry_interval_toplvl and nfs_retransmit_counter_toplvl. They are similar to nfs_retry_interval and nfs_retransmit_counter, and allow you to set the "timeo" and "retrans" NFS mount parameters, respectively, but ONLY for Amd's top-level mounts (which are NFSv2/UDP currently). This is useful because on some systems you may wish to set these parameters differently than the OS default, so as to better tune Amd's responsiveness under heavy scheduler loads. - minor new ports: i386-pc-linux-fc5 (Fedora Core 5) i386-pc-linux-suse10.1 (beta 8) i386-unknown-freebsd6.0 (RELEASE) i386-unknown-freebsd6.1 (RELEASE) i386-unknown-netbsdelf2.1 i386-unknown-netbsdelf3.0 (RELEASE) i386-unknown-openbsd3.8 i386-unknown-openbsd3.9 powerpc-apple-darwin8.5.0 powerpc-apple-darwin8.6.0 - Bugs fixed: * one serious memory leak in amfs_generic (caught by Coverity) * assorted potential (but rare) NULL pointer dereferences (Coverity) * correctly print nfs_args->addr info (sin_family/port/addr) * pawd should resolve path repeatedly until no more to do * handle old-style filehandles correctly (for mount points longer than 28 chars) * use-after-free bug in amfs_lookup_mntfs (Coverity) * don't turn off attribute cache for regular NFS mounts (improves performance) * detect G/DBM support via gdbm_compat library (Debian) * detect NDBM support in libc (FreeBSD 6) *** Notes specific to am-utils version 6.2a1 MAJOR BUG FIXES: Synchronize Amd's view of its file systems with the kernel's NFS client-side DNLC/dcache. Amd changes its view when it reloads maps (automatically or via "amq -f") because new map entries could be added, old one removed, or existing ones changed. Amd also changes its view when a simple entry has expired and was flushed, or was forced out via "amq -u". Amd was not updating the mtime of its parent directory (often the amd automount point): this resulted in the kernel re-using cached entries, which are now possibly stale. Many users had seen this problem in the form of occasional ESTALE errors, or dangling/broken automounted symlinks, especially on systems under heavy use. To tell the kernel to ignore (flush) its old entries for an directory, the mtime of the directory must be updated (monotonically incremented). Amd was indeed doing so in several places, but unfortunately it was using time(2) which only provides a one-second resolution clock: this was fine a decade ago, but not good enough on today's fast systems; using only a one-second resolution clock meant that on busy systems that invoke Amd many times a second, some rapidly changing entries do not get flushed from the kernel, and the kernel thus uses stale entries. The solution to all of these was to rework the whole clock timer updates to use gettimeofday(), using a micro-second resolution timer, and to use that time whenever Amd needs to update an mtime/atime/ctime of any node. Finally, we now update the mtime in places that were never updated before (when a whole map is flushed or a single entry times out). Warning: some OSs, we discovered, are incapable of turning off their NFS attribute cache entirely. This means that Amd cannot work fully reliability on these systems, not under heavy load. This is documented in detail in the README.attrcache file included with this distribution. Include test-attrcache script to test the NFS attribute cache behavior using Amd. Tell syslog not to log automatically to /dev/console; it's unfriendly. If user really wants to, they can set it in /etc/syslog.conf. Moved pawd's path-matching functionality into Amd, where it can be done a lot more efficiently (we no longer need to construct and send the whole mounted tree, only to match small parts of it). This will lessen the CPU and network load on systems that use pawd heavily, and also minimize the chance that we exceed default or hard-coded UDP/TCP RPC packet sizes. Changed slightly how Amd behaves when you try to change log_options after Amd started (options can be turned on/off via "amq -x ARG"). It used to be that Amd won't let you turn off options which were on when Amd started. That limited users' ability to reduce Amd's logging levels to a minimum. Now, Amd will allow you to turn on/off any option, other than the two options "fatal" and "error." Both are on by default and considered mandatory. These two don't produce a lot of log messages, so your logs will remain small, but they are important to keep on, so Amd can report serious problems (including errors relating to incorrectly setting other log options). Amd now understands a new log_option called "defaults" which is synonymous with "fatal,error,user,warning,info" (and is also what logging happens by default). Amd now understands a new debug_option called "defaults" which is synonymous with "all,nohrtime,nomtab,noxdrtrace". Changed the misleading inverted logic of certain debug_options: 1. "xdrtrace" is included in "all" because "all" (as the name implies), should be *all* options, not just a subset. If you want the old behavior of "all" then use "defaults" (all only adds "xdrtrace" which can be chatty on some systems). 2. Certain debug options are hereby declared immutable: they may not be changed by "amq -D" after Amd starts, because it doesn't make much sense to change them after Amd starts, and it could really mess up Amd. These immutable flags are currently "daemon," "fork," "amq," and "mtab." 3. the debug option "daemon" *will* cause Amd to daemonize. Before, it was causing Amd NOT to daemonize. This was greatly confusing, especially since the code, documentation, and comments often conflicted with each other. If you don't want Amd to daemonize, which is useful for debugging it, then use the debug option "nodaemon" -- it makes a lot more sense. 4. Similarly, the "fork" option *will* cause Hlfsd to fork. Use "nofork" if you don't want Hlfsd to fork. This option is only applicable to Hlfsd. 5. Similarly, the "amq" option, which is now on by default, will cause Amd to register itself with the RPC portmapper (for Amq), as is done normally. If you don't want Amd to register with the portmapper, use "noamq" -- this naming convention makes more sense. This was also confusingly documented and coded in places. Note: unfortunately, these changes to the "daemon," "fork," and "amq" debug options may be incompatible with people's previous use of Amd. Some of you may have to update your amd.conf slightly or your startup options (if they're hard-coded in your amd startup script). Sorry, but we have to fix those old problems sooner or later. However, if you never set any debug_options, or you used to "all," then you won't be affected by the change in meaning of these three flags. - minor new ports: i386-pc-linux-deb3.1 i386-unknown-netbsdelf3.0 (BETA) powerpc-apple-darwin8.2.0 - Bugs fixed: * abort with an error if yacc/lex programs not found * properly turn off the attrcache in freebsd and openbsd * can turn off attrcache on netbsd, but need kernel patch, see README.attrcache * pawd goes into an infinite loop on type:=auto * consistent search for file system mnttab/mount names * convert all sprintf to safer xsnprintf * convert all strcat to safer xstrlcat * convert all strcpy to safer xstrlcpy * fix three buffer overruns in expand_op (amd/opts.c) * pawd was trying UDP only, now try TCP if UDP failed *** Notes specific to am-utils version 6.1.1 New amd.conf global parameter: forced_unmounts (default to "no"). If set to "yes," and the client OS supports forced or lazy unmounts, then Amd will attempt to use them if it gets any of three serious error conditions when trying to unmount an existing mount point or mount on top of one: EIO, ESTALE, or EBUSY. This could be useful to recover from serious conditions such as hardware failure of mounted disks, or NFS servers which are down permanently, were migrated, or changed their IP address. Only "type:=toplvl" mounts hung with EBUSY are forcibly unmounted using this option: this is useful to ensure that a new Amd can mount itself even if a previous Amd died and left its mount points hung, or to force Amd to shutdown cleanly, even if some processes (i.e., user shells) have their CWD on Amd's own mount point. This functionality is available for Linux, BSD44 systems, Solaris, OSF/1, and partially for AIX. New amd.conf global parameter: truncate_log (default to "no"). If set to "yes", then Amd will truncate the log file (if it's a regular file) on startup. This could be useful when conducting extensive testing on Amd maps (or Amd itself) and you don't want to see log data from a previous run in the same file. - minor new ports: i386-pc-linux-fc4 i386-pc-linux-suse9.3 i386-pc-linuxoldld-deb3.1 - bugs fixed: * safer mtab handling for Linux (locks + handles /proc/mounts) * small compile problems on Solaris 6 (rpcvers_t) * small compile problems on HPUX 10 (h_errno) * possibly missing definition of INADDR_NONE in wire.c * extern for sleep(3) may be missing on older gcc systems * updated nfs_args structure on aix4. * possible running off end of exported_ap[] array. * buffer overflow in pawd. * aix4 clean build. * use strlcat/snprintf in a few places for safety. * recover from IP address change of a down NFS server * don't discard restarted mntfs that was used. *** Notes specific to am-utils version 6.1 - bugs fixed: * set timeo/retrans for type:=nfs only if user asked Also, if you want to know what's new in 6.1 compared to 6.0.x, it's EVERYTHING below this line, up to "6.0.4." Yes, that's a lot of stuff. *** Notes specific to am-utils version 6.1-rc7 Remove alloca from am-utils, and rewrite code that used it. Assorted minor code cleanups. - minor new ports: alpha-unknown-linux-gentoo1.4.16 alphaev56-dec-osf4.0f (using both cc and gcc) mips-sgi-irix6.5 (using both cc and gcc) mips-unknown-linux-gentoo1.4.16 sparc64-unknown-linux-gentoo1.4.16 - bugs fixed: * getwire() detects networks correctly on OSF/1 *** Notes specific to am-utils version 6.1-rc6 - minor new ports: i386-pc-linux-deb3.0 i386-pc-linux-gentoo1.4.16 i386-pc-linux-suse9.2 i386-unknown-freebsd5.4 i386-unknown-netbsdelf2.0.2 i386-unknown-openbsd3.7 powerpc-unknown-linux-yellowdog2.3 - bugs fixed: * minor compile error of nfs_subr.c on some systems. * AIX 5.2/5.3 PPC compile fixes. *** Notes specific to am-utils version 6.1-rc5 For NetBSD systems, $os used to say "netbsdelf1" or "netbsdelf2." Now it just says "netbsd." - minor new ports: powerpc-apple-darwin7.9.0 - bugs fixed: * silly (but nasty) null pointer dereferencing * improved fix for '-opts' syntax for resetting map options *** Notes specific to am-utils version 6.1-rc4 - bugs fixed: * check for "macosx" in M4 macros properly * minor memory leaks (thanks to Valgrind) *** Notes specific to am-utils version 6.1-rc3 Minor fix to configure.in. Reran bootstrap to get a working configure script that indeed checks for certain Linux nfs/autofs headers. *** Notes specific to am-utils version 6.1-rc2 New amd.conf global parameter: normalize_slashes (default to "yes"). If set to "no," then Amd will not condense repeated slashes or remove trailing ones from strings representing pathnames. This is sometimes useful with SMB mounts, which often require multiple slash characters in pathnames. Using a custom version of strlcpy instead of strncpy (but only where it makes sense), to minimize string overflow changes. Audited all use of strncpy/strlcpy to ensure safety. On Apple machines, use "powerpc" for $arch, instead of "Power Macintosh". Also, use sw_vers to find out more appropriate OS name (macosx) and OS version (10.3.x) than uname(3) reports. - minor new ports: powerpc64-unknown-linux-rhel4 powerpc64-unknown-linux-sles9 - bugs fixed: * pawd handles all file systems * fix double-free in type:=nfsx * timeo and retrans shouldn't be set for type:=toplvl * fix inconsistency in handling filehandle generation number * document proper use of hosts.allow (don't spawn) * single dash '-' map entry now resets the defaults *** Notes specific to am-utils version 6.1-rc1 - minor new ports: i386-pc-linux-fc2 (Fedora Core 2). i386-pc-linux-fc3 (Fedora Core 3). i386-pc-linux-rhel3 i386-pc-linux-rhel4 i386-pc-linux-suse8.2 i386-pc-linux-suse9.1 i386-pc-solaris2.10 i386-unknown-freebsd4.8 i386-unknown-freebsd4.9 i386-unknown-freebsd4.10 i386-unknown-freebsd4.11 i386-unknown-freebsd5.1 (5.1-RELEASE) i386-unknown-freebsd5.2 (5.2-RELEASE) i386-unknown-freebsd5.2.1 (5.2.1-RELEASE) i386-unknown-freebsd5.3 (5.3-RELEASE) i386-unknown-freebsd6.0 (6.0-CURRENT-SNAP001) i386-unknown-netbsdelf1.6.1 i386-unknown-netbsdelf2.0 i386-unknown-openbsd3.6 ia64-hp-hpux11.20 ia64-unknown-linux-rhel4 mipsel-unknown-linux-rhPS2 (Linux on Sony PlayStation 2) powerpc-apple-darwin7.6.0 powerpc-apple-darwin7.7.0 powerpc-apple-darwin7.8.0 powerpc-ibm-aix5.2.0.0 powerpc-ibm-aix5.3.0.0 sparc-sun-solaris2.10 sparc64-unknown-linux-deb3.0 x86_64-unknown-linux-rh2.9.5AS - support for executable maps ala Sun automounter. Set map_type=exec in amd.conf, and map_name to a program/script that takes a key as argv[1], and returns key-value pair on stdout. See also exec_map_timeout [global] parameter which defines how many seconds (default 10 sec) Amd will wait for an executable map program to return output before timing out. See am-utils manual for full details. - new amd.conf parameter "nfs_allow_insecure_port". Used to work around bugs in certain kernels, which cause them to try and talk to amd from unprivileged ports. - new amd.conf parameter: localhost_address. Used to override the localhost (often 127.0.0.1) address Amd uses to connect to for the local NFS server and RPC server. - new amd.conf [global] parameter: domain_strip (default "yes"). If set to "no," Amd won't strip domain names from host names, which is useful if your Amd maps are served by multiple domains and you want to tell from the logs which exact host did what. - new amd.conf [global] parameter: auto_attrcache (default to 0). Sets Amd's own NFS attribute-cache timeout in seconds. A value of 0 turns off attribute caching, meaning that Amd will be consulted via a kernel-RPC each time someone stat's the mount point (which could be abused as a denial-of-service attack). If you're concerned, set this to something greater than zero (a value of 1 second is currently recommended). Warning: if you set this option to any non-zero value, especially a large value, and you get ESTALE errors on your particular OS, then set this value back to 0 seconds. - four new amd.conf [global] parameters, similar to nfs_retry_interval and nfs_retransmit_counter, which allow you to set the "timeo" and "retrans" NFS mount parameters, respectively. Now you can set those parameters globally and separately for UDP vs. TCP, using any of these: nfs_retry_interval_udp, nfs_retransmit_counter_udp nfs_retry_interval_tcp, and nfs_retransmit_counter_tcp. - new amd.conf [global] parameter: preferred_amq_port. Allows you to select the UDP+TCP port that Amd's amq service will use with the RPC portmapper. Useful with firewalls and NAT'ed environments. - new amd.conf option "debug_mtab_file". Allows user to define the mtab file during debug-mtab mode. The default path is "/tmp/mtab". - new function selector xhost(ARG) which will match ARG against the current host name. This works even if ARG is a CNAME (unlike the host==ARG selector). - support restarting the automounter's own mount points (only over NFS, for now). - fully support WebNFS as per RFC 2054. It now tries v3/TCP first, falling back to v2/UDP if this doesn't work. The "webnfs" pseudo-mount options has been renamed (again) to "public" to match Solaris 2. - restructured the restarting of already-mounted filesystems, in the process also fixing a problem with restarting nfsx components. - support escaped slashes, needed for SMB mounts. Use '\\\/\\\/' in a string to get a double slash. - amd -v now prints domain, host, and hostd values: foo, example.com, and foo.example.com, respectively. - On Linux, if umount(2) failed with EIO or ESTALE, try the new umount2(2) system call with MNT_FORCE+MNT_DETACH. This could be quite helpful to unmounting hung mount points that otherwise cannot be fixed without a reboot. - The ping=N mount option now works. N defaults to 30 seconds for all NFS servers. It can now be set to any value for each server separately. Setting it to a large value can reduce the amount of NFS_NULL chatter on your network considerably, especially in large sites. Setting this to -1 will turn off pings for that server (useful in NFS-HA setups). Setting N to 0 will pick the default ping value in Amd (currently 30 seconds). Note that if you have multiple Amd entries using the same file server, and each entry sets a different value of N, then each time Amd mounts a new entry, the ping value will be re-evaluated (and updated, turned off, or turned back on as needed). Note that NFS_NULL pings are sent for both UDP and TCP mounts, because even a hung TCP mount can cause user processes to hang. - file system inheritance code restructured, so it's no longer a pseudo file system, but actually integrated into Amd (as it should have been). - for type:=program, the "umount" program doesn't have to be defined; it'll default to "unmount ${fs}". - "amd -v" now prints the distribution name if it's known (e.g., rh9, fc3, suse8, etc.). - bugs fixed: * various memory management problems (leaks, etc) * fixed nfsx support * fixed a race involving late replies to network queries which arrive after the file system has already been mounted * recognize pcfs_args_t fields in FreeBSD 5 * recognize other mount types in pawd: host, linkx, and nfsx * allow exactly one of umount and unmount in type:=program * race condition between calls to mntctl() on AIX * plock/mlockall wasn't inherited by fork(); moved after daemonizing. * fix inconsistency between Socket and TLI RPC timeouts. * don't warn when couldn't rmdir a dir with a readonly ancestor. * avoid hangs of amd in ctl-amd (must chdir to /) * workaround occasional daemonizing problems (parent won't die) * don't hang on exit if debug_options=mtab was used * utimeout=N mount option works with non-nfs types (ufs, pcfs, etc.) * SEGV (null pointer deref) in type:=program and type:=cachefs * unmount_on_exit of type:=program caused amd to hang * match amd2ldif output with ldap.schema *** Notes specific to am-utils version 6.1b4 - minor new ports: i686-apple-darwin6.6 - speed up the recovery of inherited (restarted) filesystems by using the proper waiting channels - added support for mounting webnfs filesystems, see entry below. It doesn't do any probing currently, so it will default to v2/UDP unless another version and/or protocol are explicitly specified. - pseudo-mount option "ignore_portmapper" renamed to "webnfs" - bugs fixed: * properly time out autofs filesystems on Linux * link mounts with relative targets weren't working on autofs * the link side of the nfsl file system wasn't working on autofs * umount code was accidentally turning all symlinks into directories during attempted umounts, causing stale filehandles * various minor build fixes for "impossible" configurations * prevent ldap code from dereferencing a null pointer *** Notes specific to am-utils version 6.1b3 - new amd.conf option autofs_use_lofs, set by default to "yes". "yes" means using in-place mounts (lofs, bind mounts, etc.), thus utilizing one of Autofs's main advantages. "no" means using symlinks instead, which has the "/bin/pwd" problem and certain efficiency issues on Solaris 2.6+ and is also not supported on Solaris Autofs v1 and derivatives; however, the autofs code that uses symlinks is simpler and more thoroughly tested. - new amd.conf option map_default (can be used in [global] and overwritten in the per-map section). This will overwrite the /defaults entry of the map itself, to allow people to set defaults in amd.conf (useful when you cannot control your amd maps, or you'd rather not modify them globally). - for type:=program, you can use either unmount:=XXX or umount:=XXX (but not both). This new 'unmount' name is an alias for convenience. - fixed the "multiple matching sub-entries in a map entry" semantics to try mounting those sub-entries one by one, until either one succeeds or all fail. The old semantics of trying to mount everything in parallel and use the one that mounted fastest hasn't worked in a long time; in fact, 6.0 currently simply ignores all but the first matching sub-entry. - made amd fail much faster (instantly, in fact) if the remote server doesn't have a functional portmapper or NFS service. Also reduced the total timeout to 3 seconds for a completely downed server. - new pseudo-mount option "ignore_portmapper"; not very useful currently, will make more sense when we also accept hard-coded ports for mountd and nfsd. - amd will no longer query the portmapper for all possible NFS versions and protocols if the user requested to use specific ones. - increased the major number for the library, so that 6.0 and 6.1 can't share libraries anymore. - support tcpd/libwrap tcpwrappers. If your system supports libwrap, then you can use /etc/hosts.allow and /etc/hosts.deny to control remote Amq access to Amd. The new amd.conf parameter use_tcpwrappers is set to "yes" by default. - support NULL entries in Hesiod maps, if they start with a ".". - code reorganization - documentation cleanup, corrections, and general updates. Better references to all man pages. Support newer texi2html. Proper building of DVI and PSI files. Allow building of am-utils manual in one long Web page. - minor new ports: ia64-unknown-linux-rh2.1AS (Red Hat Itanium Advanced Server) i386-unknown-freebsd5.0 (5.0-RELEASE) sparc64-unknown-linux-suse7.3 i386-unknown-netbsdelf1.6.1 i386-unknown-openbsd3.3 i386-pc-solaris2.9 - bugs fixed: * autofs mode on Linux was segfaulting on a silly error (and noone complained, which proves that I'm probably the only one testing these beta releases, tsk tsk). * fixed handling of host entries over autofs. * fixed handling of nfsl entries over autofs. * the matching in find_mntfs() was causing problems for inherited filesystems, so make an exception for them. Tighten the matching even more, to take into account the f/s type as well. * recognize xlatecookie mnttab option on netbsd * document Solaris lex bug (use flex) * document AIX 5.x NFS bug (need patch) * document Solaris 8 autofs version change (need to fix system header file) * ensure lex doesn't run out of output slots * support GNU flex-2.5.31+ * force version.texi to be rebuilt unconditionally * mk-amd-map open db file exclusively (security) * turn off maintainer-only rules in distros * don't core dump if log_file is NULL (Solaris) * don't include malloc.h if stdlib.h exists * recognize file system failures (EIO) upon reading file maps *** Notes specific to am-utils version 6.1b2 - new mount flag "softlookup", which determines how amd will respond to lookups of NFS shares already mounted (return a valid symlink or return EIO). The default, if "softlookup" is not specified, depends on whether the mount is "soft" or "hard". - return EIO instead of ENOENT if amd thinks the server is down; this allows well-written applications to sleep and retry the operation. - minor new ports: i386-apple-darwin6.0 i386-pc-linux-rh8.0 ia64-unknown-linux-rh2.1AW sparc-sun-solaris2.9 - automatic support for loop mounts on Linux (deprecates the "loop" mount option) - new amd.conf parameter ldap_proto_version (default 2) for setting the LDAP protocol version to use. - bugs fixed: * redundancy mode (multiple servers for the same share) wasn't working * non-autofs mode had some rather nasty hangs on downed file servers * double-free'ing problem in assign_error_mntfs and free_continuation * free'ing non-malloc'ed memory in amfs_auto_mount * late server ping replies were not ignored * amfs_auto_lookup_mntfs wasn't propagating errors up to callers * autofs-v4 on Solaris 9 works * handle std{in,out,err} correctly when releasing controlling tty (for real this time) * don't cast pointers between enum_t and u_long, it doesn't work on 64-bit big-endian platforms * fix compile problem with mlockall() on Darwin *** Notes specific to am-utils version 6.1b1 - Major Autofs work Partial support for Sun Autofs v1 Documented known problems with Sun Autofs v1 (possible deadlocks) Fixes for Sun Autofs v2/v3 Preliminary support for Sun Autofs v4 (Solaris 9) Kernel-based expirations for Linux Autofs - Minor new ports: powerpc-ibm-aix5.1.0.0 i386-unknown-netbsd1.6A - Work around IBM's NFSv3 ABI change in aix4.3 - trivial regression test suite started: run "make check" on a built am-utils to execute tests. Currently only one test which checks to see if "amd -v" executes correctly. - new command line option "amd -A arch" to overwrite the value of $arch. - bugs fixed: * Linux loop mounts of ISO images * assorted LDAP fixes * strerror not found on some systems * small fixes for hpux9 and aix43 * exclude ldap/hesiod support unless both libraries+headers exist * fully support "xlatecookie" mount option * security: if -D noamq option, don't listen on socket. *** Notes specific to am-utils version 6.1a5: - browsable_dirs support for Solaris autofs, *without* mount storms! - new amd.conf global parameter: map_reload_interval (default 1 hour). Determines how often Amd checks to see if maps have changed at the source (and then reloading only those that have changed). - "amd -v" now lists bug-reporting address. - assorted code cleanups and porting to use latest versions of GNU Autotools. - opts:=loop works for type:=cdfs, for mounting ISO-9660 files on Linux. - bugs fixed: * fixed sublink support in Linux autofs (broken in a4) * hlfsd takes uid 0's home from root's passwd entry instead of defaulting to '/' * (not really our bug) Linux ignores the microseconds field in mtime, so hlfsd and amd need to increment the seconds field all the time to prevent symlink caching * generic map parsing bug which was rejecting a numerical mount option if it was the last option in the string. * file descriptor leak in Linux autofs. * "nolock" is an NFS mount option, not a generic one. * use mlockall(2) on systems that have it, for plock=yes. Now pinning Amd's pages in memory works on Linux. * ctl-amd/ctl-hlfsd correctly refer to @sysconfdir@ for alternate location of configuration files. *** Notes specific to am-utils version 6.1a4: - full autofs support for Solaris 2.[67], including symlinks, sublinks and direct mounts - fixed mount/umount deadlock in Linux autofs - fixed sublinks in Linux autofs - support for network/netmask pairs in the in_network() selector - support disabling LDAP and Hesiod support using configure - forward-ported all the fixes from the stable branch (MacOS X support, minor Linux fixes) - bind-mount support for type==link and type==lofs with Linux 2.4+ - FiST lofs support under Linux (also in 6.0.6s2) *** Notes specific to am-utils version 6.1a3: - various things from the 6.0 branch: compile fixes for Linux 2.4-ac and 2.2.19pre+ Darwin/Rhapsody/OS X support much reduced configure script (works around a bug in Darwin's cpp) *** Notes specific to am-utils version 6.1a2: - working autofs support for Solaris 2.[67], but incomplete - forward-ported all the changes up to 6.0.5s2 - removed support for amq -M - known bugs nfsx support is broken linux NFS codes fixes NFS cache aliasing fixes lots of stuff ported from 6.0 branch *** Notes specific to am-utils version 6.1a1: - working autofs (v3 and v4) support for Linux! - forward-ported all the changes in 6.0.4s4 - bugs fixed client-side fail-over to NFSv2/UDP - known bugs autofs v3 will probably break with host maps *** Notes specific to am-utils version 6.0.4: - NFSv3 support for Linux and HPUX-11 - new amd.conf [global] options: nfs_vers: force all NFS mounts to version 2 or 3 nfs_proto: force all NFS mounts to udp or tcp - new debug_options (amd -D): hrtime: turns on high-resolution timer if available readdir: traces browsable_dirs code xdrtrace: traces XDR routines (trace: only traces NFS and RPC) - new amq options: -H: shows usage -w: translate getpwd() into an Amd path - new map syntax: ${dollar}: to include a literal '$' in assignments - new "opts:=" options: ver3: turns on NFS version 3 on some systems (linux) - updated or minor new ports: alpha-dec-osf4.0f alphaev6-dec-osf5.0 i386-pc-linux-rh6.2 i386-unknown-freebsd3.4 - bugs fixed: symlink mtime fixes to avoid u/mount race conditions update amq -s failed umounts count correctly linux compiles even if efs is available linux works with mount(2) option "intr" linux works with pcfs and cdfs handle std{in,out,err} correctly when releasing controlling tty browsable_readdir works on 64-bit kernel architectures irs/wire routines compile for bsdi{2,3,4} *** Notes specific to am-utils version 6.0.3: - updated or minor new ports: hppa1.0-hp-hpux11.00 i386-pc-bsdi4.1 i386-unknown-netbsd1.4.1 sparc-sun-solaris2.8 i*86-pc-linux-gnu-rh6.1 (some preparations for Compaq Tru64) - new variables ${uid} and ${gid}, return the numeric UID/GID of the user (not root) who invokes an amd pathname. Similar to what hlfsd does. - automake now uses automatic dependency tracking - new mount options: optionstr, noexec, nomnttab - maps of type:=auto are now browsable (using map option "browsable") - ctl-amd has "status" argument (same as RedHat) - bugs fixed: document buggy AIX 4.3 plock() behavior fixes to stale file handle on symlinks reduce race conditions upon rapid umount/mount sequences use vsnprintf, more secure than vsprintf more assorted and smaller bugs *** Notes specific to am-utils version 6.0.2: - safe map reloads: when a map needs to be reloaded, it is reloaded into a temporary copy first. Only if the reload was completely successful, Amd discards the old map and uses the new one. Otherwise Amd continues to use the old maps. This should help a lot with transient NIS problems. - amq -f now also forces a (safe) map reload, but only if the timestamp on the maps was updated. - two new selector variables: ${vendor} and ${full_os}, which are the same as the output seen in "amd -v". - documentation fixes and updates - updated or minor new ports: i386-unknown-freebsdelf3.3 - support 'ignore' flags (automntfs) in bsdi-4.1 - bugs fixed: expn.pl uses correct sockaddr_in() not, pack() make sure configure --enable-*args take an argument don't busy-loop trying to rebind to ldap servers use vsnprintf, not vsprintf (security) *** Notes specific to am-utils version 6.0.1: - updated or minor new ports: i386-pc-bsdi4.0.1 i386-unknown-freebsdelf3.0 i386-unknown-freebsdelf3.1 i386-unknown-freebsdelf3.2 i386-unknown-freebsdelf4.0 i386-unknown-netbsd1.4 i386-unknown-openbsd2.5 powerpc-unknown-linux-gnu - automount2amd added, a new script to convert Sun automount maps to Amd maps - new map function netgrpd(ARG), same as netgrp() but matches FQHN - 'ignore' is a generic mount option - hesiod info service isup() function to check if service is up - more Y2K fixes (see README.y2k for the full story) - using alloca.c on systems that don't have it (hpux9 with /bin/cc) - configure script reduced in size by using M4/sh loops instead of repeated entries - documentation updates - too many bugs fixed to list here: 'addopts' option works with 'remopts' as well as 'opts' AIX can perform NFS V.3 mounts explicitly NIS is_up fixed, especially for NIS+ running in compatibility mode amd -v incorrectly listing file systems that don't really work amd's own mounts use reserved ports if possible browsable directories works for Linux 2.3 (NFS cookies) bsd44 systems check for isofs flags bsd44 systems check for new options: norrio, gens, and extatt buildall works better on Ultrix's /bin/sh compile and build on Linux kernels 2.2 and newer compile and build on RedHat Linux 6.0 (glibc 2.1) compile and build on Solaris 7 (with or without vendor LDAP) completely eliminate all of amd's amq -M code, when not enabled correctly interpret failure code of unmount of type:=program don't create autofs listener service unless used don't list or process amq's -M option unless feature was turned on don't turn on/off noconn option if it was already in that state ldap info service: don't strcmp null strings lostaltmail correctly sets struct sockaddr_in make sure Linux systems have configured kernel headers test for bsize/namlen fields in nfs_args (linux mount versions 2/3) turn off broken NFS V.3 support for HPUX use getifaddrs() on bsd44 systems makes wire.c more reliable use matching NFS rsize/wsize on Linux 2.0 and 2.[123] kernels. verify that RPC requests come from reserved, privileged local ports warn when Linux kernel headers mismatch with running kernel pawd works for type:=nfsl too *** Notes specific to am-utils version 6.0: - updated or minor new ports: hppa2.0w-hp-hpux11.00, i386-pc-bsdi4.0 i386-unknown-freebsd2.2.8 i386-unknown-netbsd1.3.3 i386-unknown-openbsd2.4 mips-sgi-irix6.5 powerpc-ibm-aix4.3.1.0 i386-unknown-freebsd3.0 now supports nfs v.3 - ctl-amd and ctl-hlfsd now compatible with RedHat's chkconfig utility - ctl-amd stop will now wait until amd is down - libamu.so completely self contained --- does not export any symbols which must be defined by the process linking with it. This is so shared libraries could be supported on systems that have restrictive shared libraries. - use latest autoconf, automake, and libtool (off of cygnus' CVS server) to support shared libraries on many more platforms. - posix code cleanups - bugs fixed: case insensitive host match in type:=nfsl correct swapped args to kill(2) try to avoid a race condition b/t mounting and unmounting yp_all support is found in libnsl in RH-5.1 systems *** Notes specific to am-utils version 6.0b1: - updated or minor new ports: - *-pc-linux-gnu (glibc2 systems such as RedHat 5.1) - sparc-sun-solaris2.7 - i386-pc-solaris2.7 - i386-unknown-freebsd3.0 (official release, post 4.4lite port) - sparc64-unknown-linux-gnu (RH 5.1 on Sun Sparc Ultra) - bugs fixed: - major memory leak in processing of /defaults - core dump if map_type given in amd.conf doesn't exist - memory leak in replacement yp_all - don't access uninitialized memory in DU 4.0 - other smaller bugs, see ChangeLog *** Notes specific to am-utils version 6.0a16: - new ports: hppa1.0-hp-hpux11.00 (works, not NFS V.3 due to missing headers) mips-dec-ultrix4.3 (working, unverified) - new minor ports: i386-pc-bsdi3.1 i386-unknown-netbsd1.3.1 alpha-dec-osf2.1 - new options addopt:=ARG will "smartly" add and override options specified in opts:= - new amd.conf options: pid_file: specifies the file to store the PID hesiod_base: specifies the base for the Hesiod service unmount_on_exit: if 'yes' will attempt to unmount all file systems when amd exits. - amd.conf file is parsed after all other command line options. If no options specified at all, then use /etc/amd.conf by default. - some variables' values are now compared case-insensitive as per specs, such as host names, domain names, and more. - NIS service uses a new isup() function to detect if the service is up before using it. Used to ensure amd doesn't clear the existing maps before reloading them, unless the remote info service is working. - new cdfs mount options: rrip, noversion, defperm, nodefperm (OSF) - support efs/xfs separately on irix - new -D info trace option to turn on info specific debugging, such as RES_DEBUG for hesiod services. - document updates and fixes - new file MIRRORS lists official mirror sites (also in am-utils home page) - new file BUGS lists known amd/OS bugs - source restructuring: rename all Amd file-systems' sources to amfs_ARG.c such that it matches the type:=ARG as well. Free names afs/dfs for Andrew F/S and Distributed F/S. - checkpoint config.guess several times during the long configure, so that if it is aborted midway, the bulk of the features discovered will be re-read from the config.cache file. - more systems support shared libraries (libtool 1.2) - using automake 1.3 + more fixes - bugs fixed: use dynamic buffer for list of interfaces, not fixed size output of amd -H duplicated if >2 interfaces -D mem for hlfsd not on by default (so it will daemonize) linux looks for ext2fs before ufs CDFS looks for 'isofs' mount type as well compile on Solaris 2.6 with /opt/SUNWspro/bin/cc various additional fixes which gcc 2.8.x reported print syslog help string based on what's supported correctly ignore loopback interface on SunOS 3.x don't use -lucb for strcasecmp hlfsd's dump file securely written in /usr/tmp/hlfsd.dump.XXXXXX inherit NFS V.3 mounts correctly write pid file securely *** Notes specific to am-utils version 6.0a15: - new ports: alpha-unknown-linux-gnu: works i386-unknown-netbsd1.3: fully working *-sun-sunos3: compiles, not tested - updated ports: m68k-next-nextstep3: cleaner compile, works. - new file system type nfsl (NFS Link). Uses nfs if file system is remote, and link if it is local (based on if $rhost equals the host name). - support for Solaris cachefs. Requires setting fs, rfs, and a new variable cachedir. See documentation for explanation, examples, and caveats. - support negated selector functions such as !exists(/foo/bar) - wire, network, netnumber, in_network() selectors now match against all locally attached networks (by either name or number), not just the first two interfaces. - new program pawd (and man page for it) --- Print Automounter Working Directory, to print the proper pathname of the cwd or any other pathname, adjusted for automounter paths, while avoiding mount points. - two new switches to amq: -U will force using UDP only; -T will force using only TCP to communicate with amd. If neither (or both) are specified, amq will try TCP first, and if that failed, will try UDP. - support syslog facilities, using "amd -l syslog:facility". Old behavior when using only -l syslog is to use the LOG_DAEMON facility. - you may specify browsable_dirs=full, to get a listing of all entries (other than /default), including those with '*' wildcard and '/' characters. - amd -D trace now also includes as much of struct nfs_args as can be displayed. Useful in figuring out what the kernel really gets during a mount(2), as opposed to what the /etc/mnttab file says. -D trace also traces the xdr_* functions. - support for versions of shared libamu version. upped version from 0.0.0 to 1.0.0. each am-utils release that will change the library will also update its version. - amd/ops_TEMPLATE.c: a new template file for those brave enough to try and implement a new amd file system. Includes comments and other info useful for developers. - if localconfig.h exists in the current directory during the run of configure, it is included in all am-utils sources. This allows courageous developers to make certain modifications during compilations, and especially turn off undesired features (not very recommended). - documentation types and updates for all new features, ports, etc. - bugs fixed: support NFS mount options grpid and maxgrps nextstep: set NFS success code to 0 (NFS_OK), not 1 (EPERM) bsdi2: set NFS success code to 0 (NFS_OK), not 1 (EPERM) set NFS V.3 mount table names to "nfs" if vers/proto exist use mkstemp() if possible (more secure) ctl-amd looks for amd.conf in ${prefix}/etc after /etc hpux: use "ignore" mount table type openbsd2.2: turn off "noconn" mount option, so only connected used fixed memory leak in hlfsd (don't setpwent after endpwent) all NFS3 systems should have proto/vers mount/amd options DEBUG_MEM compiles and prints something more useful uninit_mntfs(): free() mf_private *after* it is used browsable_readdir: fewer bytes sent back to kernel for each chunk mount_toplvl: don't free() an automatic variable! amd should chdir() to / before daemonzing (for core dumps etc) cdfs should be called 'cdfs' not whatever the mnttab type is amd -v: don't print "FS:" list twice when >=2 net interfaces *** Notes specific to am-utils version 6.0a14: - updated ports: powerpc-ibm-aix4.2.1.0: NFS V.3 works - minor new ports: sparc-sun-sunos4.1.3C m68k-sun-sunos4.1.1 (sun3) mips-sgi-irix5.2 - new option to amd, -O ARG, will override the operating systems *name* with ARG. Corrected documentation for amd -o ARG --- it overrides the operating system *version* and not the name as the docs incorrectly stated. - logging now behave more like syslog: will not print repeated strings, but rather a count such as "last message repeated N times". (N will not exceed 100.) - restructured the code which deals with the numerous possible fields and flags that are set in struct nfs_args. That code was moved to libamu as the functions compute_nfs_args() and compute_automounter_nfs_args(). - bugs fixed: mnttab name ufs/cdfs/pcfs/etc filesystems corrected use pmap_ping for amq (a must for secure portmappers, bsdi2/3) test for xfs (irix) as a disk-based file system set correct nfs_prot headers for Solaris 2.5 removed stale code from lostaltmail.in lostaltmail will look for conf file in multiple locations assorted documentation corrections amq does not print "get_secure_amd_client" if run as root *** Notes specific to am-utils version 6.0a13: - new in_network(ARG) nomadic selector, true if ARG is the name (or number) of any of this host's network interfaces. - removed variables primnetname, primnetnum, subsnetname, and subsnetnum. (Kept "wire" and its alias "network", and "netnumber".) - include am-utils.dvi and am-utils.ps in distribution. - hlfsd supports new option -P ARG, for reading password map off of file ARG. Allows you to use the hlfs redirector using paths other than user's home directories. - use a replacement yp_all for some systems (irix) known to have a broken one which leaks a file descriptor each time called. - if remote NFS server is down or does not support portmap, downgrade machine to NFS V.2 and retry again later. - bugs: don't redefine yywrap on systems using a modified flex use correct "ignore" mnttab/mount option on hpux for df(1) use nfs_args' fsname field (hpux) to avoid syncer/mount(1) problems don't add ops_ufs.o twice to Makefile's $(OBJS) don't fail if autofs listener fails to initialize hlfsd should test if run as root after usage() and getopt - minor code cleanups for netbsd - html docs now in http://www.am-utils.org - added README file in binaries ftp directory *** Notes specific to am-utils version 6.0a12: - minor or updated/broken ports fixed: hppa1.1-hp-hpux10.10: compiles, untested (probably works). hppa1.1-hp-hpux9.05: compiles, untested (probably works). hppa1.1-hp-hpux9.07: compiles, untested (probably works). m68k-hp-hpux9.00: compiles, untested (probably works). rs6000-ibm-aix4.1.4.0: compiles, untested. sparc-sun-solaris2.6: works w/ NFS V.3. sparc-sun-sunos4.1.4: compiles, untested (probably works). - new ports: powerpc-ibm-aix4.2.1.0: compiles w/ NFS V.3, untested. - wire-test also checks for combinations of NFS protocol/version from the client to a remote (or local) host. - conf/mtab/mtab_file.c: use flock() to lock the file, and fcntl() if flock() is not available. (Used to prefer fcntl() over flock().) - bug fixes: tli get_nfs_version() gets into an infinite loop tli get_nfs_version() should time out faster sockets get_nfs_version() should work w/ secure portmappers ESTALE returned for NFS mounts for SunOS 4.x fixed do not exceed HOSTNAMESZ for nfs_args.hostname (get ENAMETOOLONG) properly initialize some mntent_t fields (fsck, freq, mnt_time) properly initialize some pcfs_args fields (mask, uid, gid) properly initialize some cdfs_args fields (ssector) *** Notes specific to am-utils version 6.0a11: - bug fixes: amd could not NFS mount v.2 servers from v.3 clients hlfsd will only use first occurrence of home dir for same uid *** Notes specific to am-utils version 6.0a10: - MAJOR DOCUMENTATION UPDATE! (first time in 6 years) - new ports: m68k-next-nextstep3: configures, compiles, not tested. - preliminary autofs support. See README.autofs for details. - new amd.conf [global] yes/no keywords: show_statfs_entries: shows number of entries for df(1) fully_qualified_hosts: use FQHN for NFS/RPC authentication - detect down remote hosts faster - log output of "amd -v" at startup - removed $osver override for solaris: now it is 2.5.1, not 5.5.1 - buildall will use gmake first if available - bugs fixed: amd core dumped when remote host was down allow up to 1024 entries back from readdir() amd.conf works even if only [global] option defined avoid using bad memcmp() implementations fixed meaning of plock [global] option (was reversed) hlfsd infinite loop unless compiled with --enable-debug NIS code works with NIS+ servers in NIS compatibility mode reset tag fields in amd.conf so they don't carry to other entries *** Notes specific to am-utils version 6.0a9: - new ports: sparc-sun-solaris2.4: configures/compiles, and runs (no NFS V3) i386-unknown-openbsd2.1: configures/compiles, runs (NFS V3) - updated ports: i486-ncr-sysv4.3.03: configures/compiles, not tested - Multiple amd support: new amd.conf [global] key "portmap_program" can be used to specify an alternate RPC program number for amd to un/register. Allowed numbers range from 300019 to 300029. A matching new option for amq: -P prognum, will use an alternate program number to contact. - man pages: amd.conf.5 new mk-amd-map.8 new amd.8 updated amq.8 updated (other man pages required minor updates) - shared libraries support expanded. Using GNU libtool-1.0. You can build a shared version of libamu, and link with it accordingly, by specifying --enable-shared to configure. Default is --enable-static --disable-shared, and you can mix and match. See "INSTALL" file for listing of systems on which shared libraries seem to build and work fine. - new option: amq -p, will return the PID of the running amd (local or remote). Uses a new RPC message. Useful especially in "ctl-amd stop". - new configure script options --enable-ldflags, for specifying -L flags. The older --enable-libs is to be used only for -l options. - two new LDAP map options for amd.conf: ldap_cache_seconds and ldap_cache_maxmem. - new script, am-eject from Debian linux's version of amd-upl102. - additional passwd map support using var[0-3], from Debian folks. - hesiod code cleanup. works for hesiod 1.3 as well as 3.0. - removed defunct -h option from amd. - started using automake-1.2. This fixed several bugs that caused some versions of yacc/lex and non-GNU make to fail. - bug fixes: amd/hlfsd mounts should be hidden from df(1) use "noconn" option for nfs mounts (multi-homed hosts) don't use connected sockets on linux before 1.3.10 (from Debian) better checks for [gn]dbm forbid excessive retries after timeouts (from Debian) readdir(): don't skip over map entries with prefix, and include it more assorted linux fixes from Debian folks lofs mount on svr4 was broken find default value of $karch from uname() not $arch hlfsd failed to mount itself on some little-endians *** Notes specific to am-utils version 6.0a8: - new ports: i386-unknown-netbsd1.2.1: configures/compiles (with NFS V.3), works, but some OS stability problems exist. - updated ports: hppa1.1-hp-hpux9.01: now tested and working rs6000-ibm-aix3.2 and rs6000-ibm-aix3.2.5: now tested and working - fixed browsable directories (readdir) code. - better methods to find amd/hlfsd pid to kill in ctl-{amd,hlfsd} - "ignore/auto" mount types fixed for irix, sunos, and others, so "df" does not show amd mounts by default (but GNU df -a does). - each time amd is built, a new "build" version is incremented. See amd -v. - man page for fsinfo added - empty fillers for new file (bsd44) systems: nullfs, unionfs, umapfs. - when amd is not running, or portmapper is down, make amq timeout faster (5 sec) than system default, usually 4-5 minutes. - bug fixes: hlfsd mount got "protocol not supported" first regular map in amd.conf didn't inherit global options make "bad" versions of lex still work with amd/conf_parse.l check for 'nodev' option, not 'nondev' typo in "ro" option, and fillers to ac{reg,dir}{min,max} and others amd.conf parsing done before switching default log/debug options allow doubly-quoted values in amd.conf hesiod-reload code cleanup - assorted code cleanup *** Notes specific to am-utils version 6.0a7: - new ports: i386-unknown-freebsd3.0: fully functional with NFS V.3 sparc-sun-solaris2.3: fully functional (should work for 2.4) sparc-unknown-netbsd1.2E: configures/compiles (with NFS V.3), untested - updated ports: i386-pc-bsdi3.0: NFS V.3 works look for hesiod in libc mips-sgi-irix5.3: fully functional with NFS V.3 - LDAP support! New [global] amd.conf options ldap_base and ldap_hostports. Also includes a new script amd2ldif to convert amd maps into plain text LDAP object files. - the following amd.conf variables: browsable_dirs, map_options, map_type, mount_type, and search_path --- can now be specified in [global] as well as the map entry itself. That way you can declare them only once in [global], and override them as needed per map. - option "cluster" added to [global] (HPUX clusters ala "amd -C"). - assorted info_hesiod map fixes and cleanup. removed HESIOD_RELOAD code. - added netgrp(name) function to amd map syntax to see if current host is in the netgroup. - removed unused option "amd -m". - filled in "tasks" file with todo items. - filled "COPYING" file with legal stuff. - cleanup: all global variables are now in one big structure (struct amu_global_options) that's easy to identify and enhance. Also migrated several flags that used be an integer each into one unsigned integer that's used as a bit-flag. - big fixes: xdr_mountres3 should compile only if has NFS V3 lex/yacc macros show full pathname (to tell if correct one runs) misc fixes/cleanup *** Notes specific to am-utils version 6.0a6: - amd configuration file! See scripts/amd.conf-sample for help and some explanation. This new conf file allows for the following new features: default selectors can be turned on/off globally. browsable_dirs/readdir() support can be turned on per map. search paths for file type maps. can force the map type to file, nis, ndbm, etc. rather than default to looking at all of them. tag each map for "amd -T tag", useful for grouping maps. can override $os and others (so if you don't like "sunos5" default naming, set os=sos5 and it will work with your old maps). and more goodies... - enable-default-selectors: No longer turned on by the configure script or optionally compiled. Code made dynamic and can be turned on or off from the amd.conf file. This code is off by default, and must be turned on by amd.conf's [global] section. - new ports: mips-sgi-irix5.3: configure/compile, not tested i486-ncr-sysv4.3.03: configure/compile, not tested - updated ports: alpha-dec-osf4.0: major code redone sparc-sun-sunos4.1.3: fixed and working mips-sgi-irix6.2: tested with gcc and "cc -32 -Wl,-woff,84" mips-sgi-irix6.4: tested with gcc and "cc -32 -Wl,-woff,84" - better NFS3 port, including more support for proto= and vers=, and automatic determination of proto/vers combination. - conf/nfs_prot/nfs_prot_*.h: all of the NFS protocol header files had to be redone, because of the osf4 port. OSF used very different names for these, and they conflicted with am-utils'. The only solution was to more or less conform to OSF4's naming, and change all the others. - ctl-amd script: improved to look for amd.conf in $prefix/etc and /etc better methods for finding the pid of amd to kill - autoconf support for LDAP. amd/info_ldap.c needs to be written. - wire-test also reports the local IP address. Some systems have multiple, buggy version of get_myaddress(), esp. SunOS and Irix. Note that Solaris x86 has a buggy htonl(). - amd -H prints usage. - bugs fixed: minor TLI problem in fwd_socket mount options properly comma delimited LIBS is set only to the right set of libraries to include selectors-on-default code ignored last selector ent in /defaults assorted code cleanups *** Notes specific to am-utils version 6.0a5: - NFS Version 3 support!!! Works on Solaris 2.5.1. Minimal testing done on Irix 6. Compiles cleanly on DU-4.0 but no tests performed. Will fall back to V2 mounts when V3 is not available. Will also use TCP if possible, UDP otherwise. - Ports to new platforms: alpha-dec-osf4.0 (not tested) i386-pc-bsdi3.0 (tested and working) i386-unknown-freebsd2.2.1 (tested and working) sparc-unknown-linux-gnu (tested and working) - New scripts added: amd2sun: convert amd maps to Sun automount maps ctl-amd: script to start/stop/restart amd ctl-hlfsd: script to start/stop/restart hlfsd expn: expand mail alias (used by hlfsd) lostaltmail: redeliver "lost" mail redirected by hlfsd lostaltmail.conf-sample: sample conf file for lostaltmail wait4amd: run a command once amd is up on a host wait4amd2die: wait for an amd process to die before returning - "amd -v" now includes more info and "amq -v" lists all of it. - new parser for linux specific mount options. - Main bugs fixed: "new toplvl readdir" bug caused amd to dump core handler for SIGCHLD didn't check for all possible children hlfsd leaking file descriptors when home file system was full cdfs/pcfs mounts should not timeout by default hesiod domain names should be compared in case-insensitive manner several printfs in amq were missing \n *** Notes specific to am-utils version 6.0a4: - amd services both TCP and UDP amq requests. This will help because of the limited UDP message size. - "amq -M" code is disabled by default because it is insecure. It is rarely used. Users who wish to use it should run "configure --enable-amq-mount". *** Notes specific to am-utils version 6.0a3: - New tested ports (configures, compiles, and runs): i386-unknown-freebsd2.2 - New ports (configures and compiles correctly, not tested): rs6000-ibm-aix3.2.5 rs6000-ibm-aix4.1.5.0 - More am-utils programs ported to all existing platforms: hlfsd, fsinfo, mk-amd-map, and fixmount. - Shared libraries: a new configure option --enable-shared will build a shared libamu.so, link applications with it, and use it. Reduces binary sizes by 20-30%. This is the first step towards loadable modules, as many changes had to be done to be able to compile and use PIC code. This is code that obviously needs to be generalized to be able to build shared libraries on many other platforms. It was only tested on Solaris 5.5.1. - the file INSTALL contains the latest compatibility table of which platforms am-utils configures, compiles and runs on. - Trimmed down the size of the configure script. Some tests that are not used anywhere were removed. *** Notes specific to am-utils version 6.0a2: - New ports (configures and compiles correctly, not tested): i386-pc-bsdi2.1 hppa1.1-hp-hpux9.01 hppa1.1-hp-hpux10.20 - new configure options: --enable-cppflags[=ARG] configure/compile with ARG (-I) preprocessor flags --enable-libs[=ARG] configure/compile with ARG (-L/-l) library flags - file system, mount table entries, and mount type tests can now look in /lib/modules and /proc/filesystems for statically/dyadically loadable kernel modules (linux) - prefer vfat over msdos/pc/etc file system for PCFS. - moved all fixed headers to include/am_defs. Left only #define/#undef entries in aux/acconfig.h. - make more sense of systems that have full, partial, or no NFS protocol headers. - minor fixes for NetBSD (untested platform). - hesiod map fixed. - buildall -D: new option to run even stricter developer options. - lots of other bugs fixed (see ChangeLog). *** Notes specific to am-utils version 6.0a1: I have it configure and build correctly for the following systems: i386-pc-solaris2.5.1 i386-unknown-freebsd2.1.0 mips-sgi-irix6.2 sparc-sun-solaris2.5.1 sparc-sun-sunos4.1.3 Amq, wire-test, and "amd -v" work on all of the above. A real running amd was only tested and confirmed working on i386-pc-solaris2.5.1 sparc-sun-solaris2.5.1 Many things are still missing: options, features, etc. But for now, let's concentrate on getting the basic functionality working on the more popular systems. am-utils-6.2+rc20110530/README000066400000000000000000000075111157065440000152160ustar00rootroot00000000000000This is the official version of am-utils. See the file NEWS for news on this and previous releases. *** General Notes to alpha/beta testers: [A] as alpha/beta testers, I expect you to be able to find certain things on your own (especially look at the sources to figure out how things work). [B] if you intend to modify any files, first find out if the file you want to modify gets autogenerated from some other place. If so, modify it at the source. You can adjust some of the configuration of am-utils after it has been auto-configured by putting whatever definitions you wish in a file called localconfig.h, located in the top build directory (the same one where config.h is created for you). [C] there are several ways you can build am-utils: (1) run the buildall script as follows: ./buildall This would build all the applications inside a special directory relative to the root of the source tree, called A., where the <> part is filled in by GNU's config.guess script. This is the preferred method, for it will separate the build from the sources, and allow you to run buildall for multiple architectures concurrently. You can run "buildall -h" to see what options it takes. (2) run the configure script such as: ./configure and then run make This would configure amd in the directory you've run the configure script in, and the built it there. Run "make install" to install all the necessary files. Note that this is good for building only one version of amd on one architecture! Don't try this for multiple architectures. If you must, then after doing one such build, run "make distclean" and then reconfigure for another architecture. (3) run the configure script for build in a different location. Let's say that /src/am-utils-6.0 is where you unpacked the sources. So you could mkdir /src/build/sunos5 cd /src/build/sunos5 /src/am-utils-6.0/configure --srcdir=/src/am-utils-6.0 make This is a manual method that will let you build in any directory outside the am-utils source tree. It requires that your "make" program understand VPATH. This can be used multiple times to build am-utils concurrently in multiple (but different) directories. In fact, the buildall script described above does precisely that, using the A.* subdirectories. (4) If you need to configure am-utils with extra libraries and/or headers, for example to add hesiod support, do so as follows: configure --enable-libs="-lhesiod -lresolv" \ --enable-ldflags="-L/usr/local/hesiod/lib" \ --enable-cppflags="-I/usr/local/hesiod/include" [D] If you modify any of the *.[chyl] sources in the directories amd, amq, hlfsd, lib, etc, all you need to do to get a new version of am-utils is run make. If you modify any of the files in the m4/ or conf/ directories, or any *.in or *.am file, then you must rebuild the configure script, Makefile.in files, aclocal.m4, etc. The best way to do so is to run ./bootstrap or ./buildall -K To be a developer and be able to run "bootstrap", you must have autoconf-2.50, automake-1.5, and libtool 1.4 installed on your system (or later versions thereof). You no longer need to get my special version of automake. Contact me if you'd like to be a maintainer and get access to the CVS server. After you've remade the basic configuration files you must rerun the buildall script to rerun configure and then remake the binaries. Modifying M4 macros may not be very intuitive to anyone that has not done so before. Let me know if you are having any problems with them. I fully expect, at least initially, to have to be the sole developers of the M4 macros and let others concentrate on C sources. [E] Report all bugs via Bugzilla or the am-utils list (see www.am-utils.org). Avoid reporting to my personal email address. It is important to involve the whole list in bug fixes etc. Good luck. Erez Zadok, Maintainer, am-utils. am-utils-6.2+rc20110530/README.attrcache000066400000000000000000000146631157065440000171610ustar00rootroot00000000000000 NFS Attribute Caching OS Problems and Amd Last updated September 18, 2005 * Summary: Some OSs don't seem to have a way to turn off the NFS attribute cache, which breaks the Amd automounter so badly that it is not recommend using Amd on such OS for heavy use, not until this is fixed. * Details: Amd is a user-level NFSv2 server that manages automounts of all other file systems. The kernel contacts Amd via RPCs, and Amd in turn performs the actual mounts, and then responds back to the kernel's RPCs. Every kernel caches attributes of files, in a cache called the Directory Name Lookup Cache (DNLC), or a Directory Cache (dcache). Amd manages its namespace in the user level, but the kernel caches names itself. So the two must coordinate to ensure that both namespaces are in sync. If the kernel uses a cached entry from the DNLC, without consulting Amd, users may see corruption of the automounter namespace (symlinks pointing to the wrong places, ESTALE errors, and more). For example, suppose Amd timed out an entry and removed the entry from Amd's namespace. Amd has to tell the kernel to purge its corresponding DNLC entry too. The way Amd often does that is by incrementing the last modification time (mtime) of the parent directory. This is the most common method for kernels to check if their DNLC entries are stale: if the parent directory mtime is newer, the kernel will discard all cached entries for that directory, and will re-issue lookup methods. Those lookups will result in NFS_GETATTR/NFS_LOOKUP calls sent from the kernel down to Amd, and Amd can then properly inform the kernel of the new state of automounted entries. In order to ensure that Amd is "in charge" of its namespace without interference from the kernel, Amd will try to turn off the NFS attribute cache. It does so by using the NFSMNT_NOAC flag, if it exists, or by setting various "cache timeout" fields in struct nfs_args to 0 (acregmin, acregmax, acdirmin, or acdirmax). We have released a major new version of am-utils, version 6.1, in June 2005. Since then, a lot of people have experimented with Amd, in anticipation of migrating from the very old am-utils 6.0 to the new 6.1. For a couple of months since the release of 6.1, we have received reports of problems with Amd, especially under heavy use. Users reported getting ESTALE errors from time to time, or seeing automounted entries whose symlinks don't point to where it should be. After much debugging, we traced it to a few places in Amd where it wasn't updating the parent directory mtime as it should have; in some places where Amd was indeed updating the mtime, it was using a resolution of only 1 second, which was not fine enough under heavy load. We fixed this problem and switched to using a microsecond resolution mtime. After fixing this in Amd, we went on to verify that things work for other OSs. When we got to test certain BSDs, we found out that they always cache directory entries, and there is no way to turn it off completely. Specifically, if we set the ac{reg,dir}{min,max} fields in struct nfs_args all to zero, the kernel seems to cache the entries for a default number of seconds (something like 5-30 seconds). On some OSs, setting these four fields to 0 turns off the attribute cache, but not on some BSDs. We were able to verify this using Amd and a script that exercises the interaction of the kernel's attrcache and Amd. (If you're interested, the script can be made available.) We then experimented by setting the ac{reg,dir}{min,max} fields in struct nfs_args all to 1, the smallest non-zero value we could. When we ran the Amd exercising script, we found that the value of 1 reduced the race between the DNLC and Amd, and the script took a little longer to run before it detected an incoherency. That makes sense: the smaller the DNLC cache interval is, the shorter the window of vulnerability is. (BTW, the man pages on some OSs say that the ac{reg,dir}{min,max} fields use a 1 second resolution, but experimentation indicated it was in 0.1 second units.) Clearly, setting the ac{reg,dir}{min,max} fields to 0 is worse than setting it to 1 on those OSs that don't have a way to turn off the attribute cache. So the current workaround I've implemented in am-utils is to create a configuration parameter called "broken_attrcache" which, if turned on, will set these nfs_args fields to 1 instead of 0. I wish I didn't have to create such ugly workaround features in Amd, but I've got no choice. The near term solution is for every OS to support a true 'noac' flag, which can be added fairly easily. This'd make Amd work reliably. The long term solution is to implement Autofs support for all OSs and to support it in Amd. Currently, Amd supports autofs on Solaris and Linux; FreeBSD is next. Still, we found that even with autofs support, many sysadmins still prefer to use the good 'ol non-autofs mode. * Confirmed Status This is the confirmed status of various OSs' vulnerability to this attribute cache bug. We are slowly checking the status of other OSs. The status of any OS not listed is unknown as of the date at the top of this file. ** Not Vulnerable (support a proper "noac" flag): Sun Solaris 8 and 9 (10 probably works fine) Linux: 2.6.11 kernel (2.4.latest probably works fine) FreeBSD 5.4 and 6.0-SNAP001 (older versions probably work fine) OpenBSD 3.7 (older versions probably work fine) ** Vulnerable (don't support a proper "noac" flag natively): NetBSD 2.0.2 (older versions are also probably affected) Note: NetBSD has promised to support a noac flag hopefully after 2.1.0 is released (maybe in 3.0 or 2.2). In the mean time, you can apply one of these two kernel patchs to support a 'noac' flag in NetBSD 2.x or 3.x: ftp://ftp.netbsd.org/pub/NetBSD/misc/christos/2x.nfs.noac.diff ftp://ftp.netbsd.org/pub/NetBSD/misc/christos/3x.nfs.noac.diff After applying this patch and rebuilding your kernel, reboot with the new kernel. Then copy the new nfs.h and nfsmount.h from /sys/nfs/ to /usr/include/nfs/, and finally rebuild am-utils from scratch. ** Testing When you build am-utils, a script named scripts/test-attrcache is built, which can be used to test the NFS attribute cache behavior of the current OS. You can run this script as root as follows: # make install # cd scripts # sh test-attrcache If you run this script on an OS whose status is known (and not listed above), please report it to us via Bugzilla or the am-utils mailing list (see www.am-utils.org), so we can record it in this file. Sincerely, Erez. am-utils-6.2+rc20110530/README.autofs000066400000000000000000000173771157065440000165310ustar00rootroot00000000000000# This file is README.autofs # am-utils-6.1 # Erez Zadok a.k.a. "Darth Autoconf" # # modified by # Ion Badulescu a.k.a. "The Autofs Master" ** General notes about the autofs support in am-utils - The autofs code in am-utils is gamma quality for Linux, beta quality for Solaris 2.5+ and non-working for all the other systems. - Link, lofs, ufs, nfs, nfsl, and auto mounts were tested and work properly; the others should work, but were not tested. * Caveats: - [this applies to Solaris/IRIX 6/HP-UX/AIX] Amd acts as *both* automountd and automount. There's no way to distinguish between the two. When amd starts, it first registers itself as an autofs server (automountd's job), then parses its own maps, and decides which autofs-type mounts to make (automount's job). After the autofs mounts are made, amd listens for requests from the kernel-based autofs, and acts upon them. Since there can be only one autofs listener on a system, this means that automountd and amd cannot run at the same time; nor can two amd's run at the same time if they are both using autofs mounts. - Linux support is available and fairly stable. Solaris 2.5+ support is newer and less tested, but seems pretty stable as well. IRIX 6 and HP-UX autofs support will probably be very easy once we get Solaris 2.5 to work, as they use the same protocol and almost identical data structures. AIX seems to be using the Solaris 2.5 protocol as well, but they don't provide any headers or documentation so getting autofs to work will be tricky at best. - Killing amd can become a problem if there are active mounts. Since mounts are done "in place", we can't just unmount our mount points and go away. For now, amd simply tells the kernel that it is dying; we need to think this further. It would be nice to "take over" the old mountpoints, there is support for this in Solaris (due to is RPC nature) and is easy to add to the Linux kernel (an ioctl on the mountpoint). - The Solaris 2.5 implementation of the autofs v1 protocol is NON-REENTRANT, and ignoring this limitation results in a DEADLOCK between the kernel and the daemon. This is a serious problem, although only for the lofs and link mount types. In other words, suppose the daemon is trying a lofs/link mount whose destination crosses another autofs mountpoint. If that mountpoint is not yet mounted, it will trigger another autofs lookup which will deadlock inside the kernel -- because the kernel is waiting for the previous request to return. This is not even something specific to amd, Sun's own automountd has the exact same problem. Ctrl-C breaks the deadlock, so it's not fatal, but the lofs/link entry is in effect unusable. - Solaris 2.8 (at least) doesn't like getting to get out-of-order replies to mount requests, and ignores the late ones. It's only a minor annoyance (read delay), because the RPC is retried by the kernel and it succeeds the second time around. * Solaris: - Amd w/ autofs mounts will fight over the listener port with Sun's automountd, so running both simultaneously is a really bad idea. - Browsable_dirs is possible and implemented for Solaris 2.6+. - Direct mounts are implemented and work correctly. - Host maps are implemented and work correctly. - On Solaris 2.6+, symlinks over autofs are inefficient. The kernel seems to time them out immediately after receiving them, so each access to a symlink causes a call to userspace. Needless to say, this negates the whole point of using autofs. Automountd seems to always use lofs mounts instead of symlinks, we do the same unless the admin requests "autofs_use_lofs = no" in amd.conf. - Solaris 2.5/2.5.1 do not support symlinks over autofs, so links are always mounted as lofs mounts, subject to the limitation described in the caveats section above. - Restarting autofs mounts is possible, but not yet implemented. * Linux: - Amd should work fine even when the Linux automounter is running, the mechanism being used prevents any kind of (evil) interaction between them. - Browsing is not available if autofs support is used, due to limitations in the kernel<->daemon protocol used by Linux 2.2 and 2.4. Only already-mounted nodes will appear in the autofs directory, and this is implemented entirely in the kernel. - Host maps are supported with all autofs versions. - Direct maps cannot be supported since there is no kernel support for them; we might be able to get something eventually, but don't hold your breath. If anything, we may do it using a regular NFS mountpoint and bind-mount on top of it. - Inherit doesn't make much sense because we can't restart a hung autofs mount point, due to kernel limitations. This needs to be fixed in the Linux kernel; it's not particularly difficult, and we might provide a patch at some point. - Link (and lofs) mounts will use the new bind-mount support in Linux 2.4+. No more symlinks! And /bin/pwd works great too. - Auto maps are actually mounted as a separate autofs filesystem. Since each autofs filesystem consumes 2 file descriptors, and amd has at most 1024 file descriptors available, there can be at most 512 of them mounted at the same time. Because of this, extensive use of auto maps is discouraged when using autofs on Linux. * amd.conf requirements: To tell amd to use an autofs-style mount point and mounts for a map, add mount_type = autofs either to the global section, or to the sections of the individual maps you selected. Mixing autofs and normal amd mount points in the same amd.conf file *does* work. * Map changes: No changes are necessary. If a map is marked as autofs in amd.conf, mounts are done "in place" and the "fs" parameter is ignored most of the time. * Todo: We are looking for volunteers to improve the autofs code! (1) These fixes are needed: - sublinks are broken - when the mount type is 'link', transparently translate it into a loopback file system mount (lofs), that would mount in place, rather than supply a symlink, at least on systems whose autofs doesn't support symlinks. Linux does support symlinks, Solaris 2.6+ does too, but Solaris 2.5/2.5.1 doesn't and neither does IRIX 6. Moreover, Sun's automountd always uses lofs for link mounts, even on 2.6+, because symlinks are not cached in the kernel and thus are not particularly efficient. [done] - complain if certain incompatible options (autofs and ...) are used. Direct maps on Linux is one such case of incompatible options. Browsable_dirs on Linux is another such case. - if amd is killed or dies, the autofs mounts will remain intact as required (your system is _not_ hung, yay!). However, if you restart amd, it will not correctly 'restart' the autofs mounts as the Sun automounter does. Rather, it might cause another mount to happen, which leaves your /etc/mnttab cluttered with older mounts entries which cannot be unmounted. It might also just pretend everything is ok, when in fact it isn't. (2) Code expansion: - [Solaris only] implement the sockets version of amu_get_autofs_address() and create_autofs_service(), in conf/transp/transp_sockets.c. Not sure if it's necessary, Solaris it still biased towards TLI/STREAMS in userspace. [mostly done, untested, might be used on AIX 5.x+ and IRIX 6] - Implement the restarting of autofs mount points. This is already doable on Solaris; on Linux, the kernel needs to be patched to allow it. (3) Testing and porting to other systems: - nothing has been tested on IRIX 6, which reportedly has a similarly functioning autofs to Solaris 2.5. The code compiles, but has not been run yet and is most likely broken. - support for Linux autofs is stable, we need testers! - support for Solaris 2.6+ is pretty stable, so we need testers for it, too! - we did not test any version of Solaris on x86. It will probably work, but you have been warned. Testers are welcome. am-utils-6.2+rc20110530/README.ldap000066400000000000000000000030621157065440000161320ustar00rootroot00000000000000LDAP support for am-utils was originally done by Leif Johansson . He no longer maintains it. The current LDAP support for am-utils is for LDAPv2 only. Reportedly, LDAPv3 mostly works. Volunteers and patches are welcome. The IANA has assigned the following Private Enterprise Number to: 10180 Am-utils Organization Erez Zadok ezk AT am-utils.org There are three files in this directory that relate to LDAP: ldap.schema: This is the most current schema. ldap-id.txt: This is an experimental schema for amd mount maps in LDAP. Since LDAP isn't maintained now, this code may not match with either the current ldap_info.c code or with Amd mount maps in general. The schema is written in the form of an internet-draft but it has not been published as such. We need volunteers who know and use LDAP to clean it up and further its process of submission. ldap-id.ms: This is the NROFF source of the draft. To generate the text from it, run "nroff -ms ldap-id.ms > ldap-id.txt" Erez. ------- Forwarded Message From: "IANA Private Enterprise Number" To: "Erez Zadok" Subject: RE: Application for Enterprise-number (10180) Date: Sun, 15 Jul 2001 14:43:45 -0700 Dear Erez, The IANA has assigned the following Private Enterprise Number to: 10180 Am-utils Organization Erez Zadok ezk AT am-utils.org Please notify the IANA if there is a change in your contact or company information. Thank you, Bill Huang IANA - Private Enterprise Numbers ------- End of Forwarded Message am-utils-6.2+rc20110530/README.osx000066400000000000000000000031701157065440000160230ustar00rootroot00000000000000Here some unconfirmed instructions for how to setup Amd on a MAC OS-X machine. Please direct all comments about this information, as well fixes, updates, and corrections to the am-utils mailing list (see www.am-utils.org). Thanks, Erez. --cut--here----cut--here----cut--here----cut--here----cut--here----cut--here-- Date: Fri, 28 Jan 2005 06:53:50 -0800 From: Kevin Layer The stock amd didn't work for us in Mac OS X 10.3. Here's how we installed am-utils-6.1-20031025: ./configure --prefix=/usr make make install Create /System/Library/StartupItems/AMD with the files: AMD Resources/ -- copy from other directories in .. StartupParameters.plist Then, make sure that AMDSERVER=-YES- is added to /etc/hostconfig. ******************* the file AMD: #!/bin/sh ## # Start AMD ## . /etc/rc.common if [ "${AMDSERVER:=-NO-}" = "-YES-" ]; then ConsoleMessage "Starting AMD server" if [ ! -f /etc/amd.conf -a -r /etc/amd.conf.template ]; then cp /etc/amd.conf.template /etc/amd.conf fi if [ ! -f /etc/amd.map -a -r /etc/amd.map.template ]; then cp /etc/amd.map.template /etc/amd.map fi /usr/sbin/amd fi ******************* the file StartupParameters.plist: { Description = "AMD server"; Provides = ("AMD"); Requires = ("Resolver"); OrderPreference = "None"; Messages = { start = "Starting AMD server"; stop = "Stopping AMD server"; }; } ******************* With the beta's of 10.4 (64-bit) we're having issues with realpath() and amd mounted directories, but hopefully this is just a bug that they'll fix. -- Kevin Layer http://www.franz.com/ am-utils-6.2+rc20110530/README.release000066400000000000000000000011271157065440000166320ustar00rootroot00000000000000- update vers.m4 to the new version you want to release: then rerun ./bootstrap - update NEWS w/ appropriate items - might have to commit/push at this point, not sure - ./configure ; make ; make check - make distcheck: that should generate a tar.gz w/ version number to drop into the ftp/http server - if you haven't committed your files and pushed them yet, now's the time - I also like to tag the current trunk: git tag -a am-utils-X_Y[abc]Z or git tag -a am-utils-X_Y_rcZ - email announcement to am-utils-announce@am-utils.org (look for "standard" announcements I made in the past) am-utils-6.2+rc20110530/README.sun2amd000066400000000000000000000104261157065440000165650ustar00rootroot00000000000000 Sun-style Automounter Syntax Support in Amd Last updated: October 10, 2005 * Summary The goal of this effort is to provide a drop in replacement for the Sun automounter. This is implemented in two ways. (1) A new parser built into Amd. (2) a standalone sun2amd Unix filter tool that can convert Sun-style maps to Amd maps. Support for Sun-style maps in Amd (including this document) is a work-in-progress. This feature as a whole has not been throughly tested and is "alpha" quality as of the date posted at the top of this document. * Status Currently sun2amd supports most of the basic syntax features of Sun maps. However, support for Sun auto.master maps does not yet exists at any level. Below is a list of supported and not-yet supported features. 1. Supported Sun map features: - Simple map entry format: [mount_options] location ... locations take the form of host:pathname - Map Key Substitution: :/tmp/& the & expands to - Wildcard Key: * :/tmp This is is a catch-all entry. - Variable Substitution: $ARCH, $CPU, $HOST, $OSNAME, $OSREL, $OSVERS, $NATISA - Multiple Mount format: [mount_options] [mountpoint] [mount-options locations...]... ex. pluto -ro /tmp1 host1:/tmp1 /tmp2 host2:/tmp2 - HSFS file-system (cdrom): -fstype=hsfs,ro :/dev/cdrom 2. Not-yet supported Sun map features: - Replicated File Systems: ,...: This is a feature of Solaris that allows a user to specify a set of hosts to appear as one in a map entry. When a host does not respond the kernel will switch to an alternate server. Amd will supports the syntax for replicated file systems by creating multiple hosts, however, Amd will not perform any kind of fail over. - CacheFS (although Amd supports type:=cachefs, sun2amd doesn't yet parse it). - AutoFS (although Amd supports Autofs mounts and type:=auto, sun2amd may not parse it fully). - Included maps: + This will include the contents of a map into another map. - Sun master maps: auto.master Amd still relies and amd.conf. Any feature in auto.master must be duplicated using Amd equivalent features in amd.conf. - /net mount point: The automounter is suppose to dynamically create map entries under this mount point corresponding to NFS server(s) exported file systems. While this isn't parser by sun2amd, Amd does support host maps (type:=host). - Federated Naming Service (FNS) (-xfn): A naming server that wraps a number of other naming service under one interface. - "-null" map option: A way to cancel maps in the auto.master file. - nsswitch.conf: This file provides a way to specify what lookup service to use for a number of systems including Sun's automounter. In amd lookup services for map files are define in the amd.conf file. * Setup To enable Sun-style maps in Amd, set "sun_map_syntax = yes" in your amd.conf file. When this flag is set in [global], all maps read by Amd are assumed to be Sun style maps. You can set this on a per map basis, thus mixing Sun-style and Amd-style maps. For more information about amd.conf please see the Amd documentation. Example: # file: amd.conf ################ [ global ] sun_map_syntax = yes [ /home ] map_name = /etc/amd.sun_map map_type = file * sun2amd command line utility In addition to build-in Amd support there also exists the sun2amd command line utility that converts Sun maps to Amd maps. This can be useful in migrating one or more Sun maps to the Amd syntax in one step. Example usage: $ sun2amd -i sun_map -o amd_map This line tells sun2amd to read the file sun_map and redirect its output to a file called amd_map. By default sun2amd reads from stdin and writes to stdout (i.e., traditional Unix filter). * FAQ Q1: I know "/net" is not supported, but how can I achieve the same functionality with Amd? A1: In short, you must create the '/net' entry as a Amd entry of type host by hand. Below is an example of how to do this. See the Amd documentation on type autofs for more information. Example: # file: amd.conf ################ [ /net ] map_name = /etc/amd.net # file: /etc/amd.net ############### /defaults fs:=${autodir}/${rhost}/root/${rfs} * rhost:=${key};type:=host;rfs:=/ (more FAQ entries to come...) am-utils-6.2+rc20110530/README.y2k000066400000000000000000000021771157065440000157250ustar00rootroot00000000000000 AM-UTILS YEAR-2000 COMPLIANCE Most likely am-utils is y2k compliant. I do not know for sure because I have not certified am-utils myself, nor do I have the time for it. I do not think that amd will be affected by y2k at all, because it does not do anything with dates other than print the date on the log file, in whatever format is provided by your os/libc --- especially the ctime(3) call. However, on Friday, September 18th 1998, Matthew Crosby reported that they evaluated 6.0a16 and found it to be compliant. On March 26, 1999, Paul Balyoz submitted a patch to lostaltmail which makes it print Y2K compliant dates. He used a code scanner and manually "eyeballed" the code and could not find any more problems. Paul's patch is included in am-utils-6.0.1s7 and newer versions. Paul also said that other 2-digit years used in am-utils are "harmless." NOTE: NONE OF THE PERSONS MENTIONED HERE, AUTHOR INCLUDED, ARE WILLING TO CERTIFY AM-UTILS AS Y2K COMPLIANT. USE AT YOUR OWN RISK. --- Erez Zadok. Maintainer, am-utils package and am-utils list. WWW: http://www.am-utils.org am-utils-6.2+rc20110530/amd/000077500000000000000000000000001157065440000150735ustar00rootroot00000000000000am-utils-6.2+rc20110530/amd/.cvsignore000066400000000000000000000000141157065440000170660ustar00rootroot00000000000000Makefile.in am-utils-6.2+rc20110530/amd/Makefile.am000066400000000000000000000102461157065440000171320ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in # Package: am-utils # Level: Makefile for amd/ directory # Author: Erez Zadok # no need for libaminfo to be yet another dynamic library noinst_LIBRARIES = libaminfo.a sbin_PROGRAMS = amd sun2amd # man pages man_MANS = amd.8 sun2amd.8 # test scripts TESTS = test1.sh # headers this depends on, not to be installed noinst_HEADERS = amd.h sun_map.h # sources which get auto-built (from yacc/lex) BUILT_SOURCES = \ conf_parse.c conf_parse.h conf_tok.c \ sun_map_parse.c sun_map_parse.h sun_map_tok.c AM_YFLAGS = -d ############################################################################## # *.y must be listed before *.l, because of a bug in automake-1.2 # which will not generate the .h needs for the lex file from the yacc file. # I took out the conf .y/.l files b/c of bad interaction between bsd44 make # and automake-1.2 rules. libaminfo_a_SOURCES = \ sun_map_parse.y \ sun_map_tok.l \ sun_map.c # the complete list of all optional sources for libaminfo EXTRA_libaminfo_a_SOURCES = \ info_file.c \ info_exec.c \ info_hesiod.c \ info_ldap.c \ info_ndbm.c \ info_nis.c \ info_nisplus.c \ info_passwd.c \ info_sun.c \ info_union.c # AMD_INFO_OBJS: a list of info_*.o objects added, depending on which map # types this system supports. EXTRA_libaminfo_a_OBJECTS = @AMD_INFO_OBJS@ libaminfo_a_LIBADD = @AMD_INFO_OBJS@ libaminfo_a_DEPENDENCIES = @AMD_INFO_OBJS@ ############################################################################## # sources needed: note .y and .l files have to be first # get_args.c is handled separately amd_SOURCES = \ conf_parse.y \ conf_tok.l \ \ am_ops.c \ amd.c \ amfs_auto.c \ amfs_direct.c \ amfs_error.c \ amfs_generic.c \ amfs_host.c \ amfs_link.c \ amfs_linkx.c \ amfs_nfsl.c \ amfs_nfsx.c \ amfs_program.c \ amfs_root.c \ amfs_toplvl.c \ amfs_union.c \ amq_subr.c \ amq_svc.c \ autil.c \ clock.c \ conf.c \ map.c \ mapc.c \ mntfs.c \ nfs_prot_svc.c \ nfs_start.c \ nfs_subr.c \ opts.c \ readdir.c \ restart.c \ rpc_fwd.c \ sched.c \ srvr_amfs_auto.c \ srvr_nfs.c # the complete list of all optional sources for amd EXTRA_amd_SOURCES = \ ops_cachefs.c \ ops_cdfs.c \ ops_efs.c \ ops_lofs.c \ ops_mfs.c \ ops_nfs.c \ ops_nfs3.c \ ops_nullfs.c \ ops_pcfs.c \ ops_tfs.c \ ops_tmpfs.c \ ops_udf.c \ ops_ufs.c \ ops_umapfs.c \ ops_unionfs.c \ ops_xfs.c \ \ get_args.c # AMD_FS_OBJS: a list of ops_*.o objects added, depending on which # filesystem types this system supports. EXTRA_amd_OBJECTS = @AMD_FS_OBJS@ amd_LDADD = $(EXTRA_amd_OBJECTS) get_args.o libaminfo.a ../libamu/libamu.la ############################################################################## sun2amd_SOURCES = \ sun2amd.c sun2amd_LDADD = libaminfo.a ../libamu/libamu.la ############################################################################## # must manually add f/lex library to LIBS, and not to LDADD. ##LIBS = @LIBS@ @LEXLIB@ @WRAPLIB@ # f/lex libraries are incomatible with multiple scanners: don't include LIBS = @LIBS@ @WRAPLIB@ # additional files to distribute and clean EXTRA_DIST = ops_TEMPLATE.c $(man_MANS) $(TESTS) CLEANFILES = $(BUILT_SOURCES) DISTCLEANFILES = build_version.h ops_autofs.c # do not distribute files that should be generated by lex/yacc locally dist-hook: (cd $(distdir) && rm -f $(BUILT_SOURCES)) INCLUDES = -I$(top_srcdir)/include # allow users to add their own flags via "configure --enable-am-flags=ARG" AMU_CFLAGS = @AMU_CFLAGS@ AM_CFLAGS = @CFLAGS@ $(AMU_CFLAGS) # dependencies $(PROGRAMS): $(LDADD) get_args.o: build_version.h $(amd_OBJECTS) $(EXTRA_amd_OBJECTS) $(sun2amd_OBJECTS) $(libaminfo_a_OBJECTS) $(EXTRA_libaminfo_a_OBJECTS): \ ../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@ \ @AMU_AUTOFS_PROT_HEADER@ \ $(noinst_HEADERS) # auto-generate build number build_version.h: $(amd_OBJECTS) $(EXTRA_amd_OBJECTS) $(libaminfo_a_OBJECTS) $(EXTRA_libaminfo_a_OBJECTS) get_args.c $(top_srcdir)/m4/update_build_version am-utils-6.2+rc20110530/amd/am_ops.c000066400000000000000000000327061157065440000165250ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/am_ops.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * The order of these entries matters, since lookups in this table are done * on a first-match basis. The entries below are a mixture of native * filesystems supported by the OS (HAVE_FS_FOO), and some meta-filesystems * supported by amd (HAVE_AMU_FS_FOO). The order is set here in expected * match-hit such that more popular filesystems are listed first (nfs is the * most popular, followed by a symlink F/S) */ static am_ops *vops[] = { #ifdef HAVE_FS_NFS &nfs_ops, /* network F/S (version 2) */ #endif /* HAVE_FS_NFS */ #ifdef HAVE_AMU_FS_LINK &amfs_link_ops, /* symlink F/S */ #endif /* HAVE_AMU_FS_LINK */ /* * Other amd-supported meta-filesystems. */ #ifdef HAVE_AMU_FS_NFSX &amfs_nfsx_ops, /* multiple-nfs F/S */ #endif /* HAVE_AMU_FS_NFSX */ #ifdef HAVE_AMU_FS_NFSL &amfs_nfsl_ops, /* NFS with local link existence check */ #endif /* HAVE_AMU_FS_NFSL */ #ifdef HAVE_AMU_FS_HOST &amfs_host_ops, /* multiple exported nfs F/S */ #endif /* HAVE_AMU_FS_HOST */ #ifdef HAVE_AMU_FS_LINKX &amfs_linkx_ops, /* symlink F/S with link target verify */ #endif /* HAVE_AMU_FS_LINKX */ #ifdef HAVE_AMU_FS_PROGRAM &amfs_program_ops, /* program F/S */ #endif /* HAVE_AMU_FS_PROGRAM */ #ifdef HAVE_AMU_FS_UNION &amfs_union_ops, /* union F/S */ #endif /* HAVE_AMU_FS_UNION */ /* * A few more native filesystems. */ #ifdef HAVE_FS_UFS &ufs_ops, /* Unix F/S */ #endif /* HAVE_FS_UFS */ #ifdef HAVE_FS_XFS &xfs_ops, /* Unix (irix) F/S */ #endif /* HAVE_FS_XFS */ #ifdef HAVE_FS_EFS &efs_ops, /* Unix (irix) F/S */ #endif /* HAVE_FS_EFS */ #ifdef HAVE_FS_LOFS &lofs_ops, /* loopback F/S */ #endif /* HAVE_FS_LOFS */ #ifdef HAVE_FS_CDFS &cdfs_ops, /* CDROM/HSFS/ISO9960 F/S */ #endif /* HAVE_FS_CDFS */ #ifdef HAVE_FS_PCFS &pcfs_ops, /* Floppy/MSDOS F/S */ #endif /* HAVE_FS_PCFS */ #ifdef HAVE_FS_CACHEFS &cachefs_ops, /* caching F/S */ #endif /* HAVE_FS_CACHEFS */ #ifdef HAVE_FS_TMPFS &tmpfs_ops, /* /tmp (in memory) F/S */ #endif /* HAVE_FS_TMPFS */ #ifdef HAVE_FS_NULLFS /* FILL IN */ /* null (loopback) F/S */ #endif /* HAVE_FS_NULLFS */ #ifdef HAVE_FS_UNIONFS /* FILL IN */ /* union (bsd44) F/S */ #endif /* HAVE_FS_UNIONFS */ #ifdef HAVE_FS_UMAPFS /* FILL IN */ /* uid/gid mapping F/S */ #endif /* HAVE_FS_UMAPFS */ #ifdef HAVE_FS_UDF &udf_ops, /* UDF F/S */ #endif /* HAVE_FS_UDF */ /* * These 4 should be last, in the order: * (1) amfs_auto * (2) amfs_direct * (3) amfs_toplvl * (4) amfs_error */ #ifdef HAVE_AMU_FS_AUTO &amfs_auto_ops, /* Automounter F/S */ #endif /* HAVE_AMU_FS_AUTO */ #ifdef HAVE_AMU_FS_DIRECT &amfs_direct_ops, /* direct-mount F/S */ #endif /* HAVE_AMU_FS_DIRECT */ #ifdef HAVE_AMU_FS_TOPLVL &amfs_toplvl_ops, /* top-level mount F/S */ #endif /* HAVE_AMU_FS_TOPLVL */ #ifdef HAVE_AMU_FS_ERROR &amfs_error_ops, /* error F/S */ #endif /* HAVE_AMU_FS_ERROR */ 0 }; void ops_showamfstypes(char *buf, size_t l) { struct am_ops **ap; int linesize = 0; buf[0] = '\0'; for (ap = vops; *ap; ap++) { xstrlcat(buf, (*ap)->fs_type, l); if (ap[1]) xstrlcat(buf, ", ", l); linesize += strlen((*ap)->fs_type) + 2; if (linesize > 62) { linesize = 0; xstrlcat(buf, "\n ", l); } } } static void ops_show1(char *buf, size_t l, int *linesizep, const char *name) { xstrlcat(buf, name, l); xstrlcat(buf, ", ", l); *linesizep += strlen(name) + 2; if (*linesizep > 60) { xstrlcat(buf, "\t\n", l); *linesizep = 0; } } void ops_showfstypes(char *buf, size_t l) { int linesize = 0; buf[0] = '\0'; #ifdef MNTTAB_TYPE_AUTOFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_AUTOFS); #endif /* MNTTAB_TYPE_AUTOFS */ #ifdef MNTTAB_TYPE_CACHEFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_CACHEFS); #endif /* MNTTAB_TYPE_CACHEFS */ #ifdef MNTTAB_TYPE_CDFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_CDFS); #endif /* MNTTAB_TYPE_CDFS */ #ifdef MNTTAB_TYPE_CFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_CFS); #endif /* MNTTAB_TYPE_CFS */ #ifdef MNTTAB_TYPE_LOFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_LOFS); #endif /* MNTTAB_TYPE_LOFS */ #ifdef MNTTAB_TYPE_EFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_EFS); #endif /* MNTTAB_TYPE_EFS */ #ifdef MNTTAB_TYPE_MFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_MFS); #endif /* MNTTAB_TYPE_MFS */ #ifdef MNTTAB_TYPE_NFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_NFS); #endif /* MNTTAB_TYPE_NFS */ #ifdef MNTTAB_TYPE_NFS3 ops_show1(buf, l, &linesize, "nfs3"); /* always hard-code as nfs3 */ #endif /* MNTTAB_TYPE_NFS3 */ #ifdef MNTTAB_TYPE_NULLFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_NULLFS); #endif /* MNTTAB_TYPE_NULLFS */ #ifdef MNTTAB_TYPE_PCFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_PCFS); #endif /* MNTTAB_TYPE_PCFS */ #ifdef MNTTAB_TYPE_TFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_TFS); #endif /* MNTTAB_TYPE_TFS */ #ifdef MNTTAB_TYPE_TMPFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_TMPFS); #endif /* MNTTAB_TYPE_TMPFS */ #ifdef MNTTAB_TYPE_UFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_UFS); #endif /* MNTTAB_TYPE_UFS */ #ifdef MNTTAB_TYPE_UMAPFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_UMAPFS); #endif /* MNTTAB_TYPE_UMAPFS */ #ifdef MNTTAB_TYPE_UNIONFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_UNIONFS); #endif /* MNTTAB_TYPE_UNIONFS */ #ifdef MNTTAB_TYPE_XFS ops_show1(buf, l, &linesize, MNTTAB_TYPE_XFS); #endif /* MNTTAB_TYPE_XFS */ /* terminate with a period, newline, and NULL */ if (buf[strlen(buf)-1] == '\n') buf[strlen(buf) - 4] = '\0'; else buf[strlen(buf) - 2] = '\0'; xstrlcat(buf, ".\n", l); } /* * return string option which is the reverse of opt. * nosuid -> suid * quota -> noquota * ro -> rw * etc. * may return pointer to static buffer or subpointer within opt. */ static char * reverse_option(const char *opt) { static char buf[80]; /* sanity check */ if (!opt) return NULL; /* check special cases */ /* XXX: if this gets too long, rewrite the code more flexibly */ if (STREQ(opt, "ro")) return "rw"; if (STREQ(opt, "rw")) return "ro"; if (STREQ(opt, "bg")) return "fg"; if (STREQ(opt, "fg")) return "bg"; if (STREQ(opt, "soft")) return "hard"; if (STREQ(opt, "hard")) return "soft"; /* check if string starts with 'no' and chop it */ if (NSTREQ(opt, "no", 2)) { xstrlcpy(buf, &opt[2], sizeof(buf)); } else { /* finally return a string prepended with 'no' */ xstrlcpy(buf, "no", sizeof(buf)); xstrlcat(buf, opt, sizeof(buf)); } return buf; } /* * start with an empty string. for each opts1 option that is not * in opts2, add it to the string (make sure the reverse of it * isn't in either). finally add opts2. return new string. * Both opts1 and opts2 must not be null! * Caller must eventually free the string being returned. */ static char * merge_opts(const char *opts1, const char *opts2) { mntent_t mnt2; /* place holder for opts2 */ char *newstr; /* new string to return (malloc'ed) */ char *tmpstr; /* temp */ char *eq; /* pointer to whatever follows '=' within temp */ char oneopt[80]; /* one option w/o value if any */ char *revoneopt; /* reverse of oneopt */ size_t len = strlen(opts1) + strlen(opts2) + 2; /* space for "," and NULL */ char *s1 = strdup(opts1); /* copy of opts1 to munge */ /* initialization */ mnt2.mnt_opts = (char *) opts2; newstr = xmalloc(len); newstr[0] = '\0'; for (tmpstr = strtok(s1, ","); tmpstr; tmpstr = strtok(NULL, ",")) { /* copy option to temp buffer */ xstrlcpy(oneopt, tmpstr, sizeof(oneopt)); /* if option has a value such as rsize=1024, chop the value part */ if ((eq = strchr(oneopt, '='))) *eq = '\0'; /* find reverse option of oneopt */ revoneopt = reverse_option(oneopt); /* if option orits reverse exist in opts2, ignore it */ if (amu_hasmntopt(&mnt2, oneopt) || amu_hasmntopt(&mnt2, revoneopt)) continue; /* add option to returned string */ if (newstr[0]) { xstrlcat(newstr, ",", len); xstrlcat(newstr, tmpstr, len); } else { xstrlcpy(newstr, tmpstr, len); } } /* finally, append opts2 itself */ if (newstr[0]) { xstrlcat(newstr, ",", len); xstrlcat(newstr, opts2, len); } else { xstrlcpy(newstr, opts2, len); } XFREE(s1); return newstr; } am_ops * ops_search(char *type) { am_ops **vp; am_ops *rop = NULL; for (vp = vops; (rop = *vp); vp++) if (STREQ(rop->fs_type, type)) break; return rop; } am_ops * ops_match(am_opts *fo, char *key, char *g_key, char *path, char *keym, char *map) { am_ops *rop = NULL; char *link_dir; /* * First crack the global opts and the local opts */ if (!eval_fs_opts(fo, key, g_key, path, keym, map)) { rop = &amfs_error_ops; } else if (fo->opt_type == 0) { plog(XLOG_USER, "No fs type specified (key = \"%s\", map = \"%s\")", keym, map); rop = &amfs_error_ops; } else { /* * Next find the correct filesystem type */ rop = ops_search(fo->opt_type); if (!rop) { plog(XLOG_USER, "fs type \"%s\" not recognized", fo->opt_type); rop = &amfs_error_ops; } } /* * Make sure we have a default mount option. * Otherwise skip past any leading '-'. */ if (fo->opt_opts == 0) fo->opt_opts = strdup("rw,defaults"); else if (*fo->opt_opts == '-') { /* * We cannot simply do fo->opt_opts++ here since the opts * module will try to free the pointer fo->opt_opts later. * So just reallocate the thing -- stolcke 11/11/94 */ char *old = fo->opt_opts; fo->opt_opts = strdup(old + 1); XFREE(old); } /* * If addopts option was used, then append it to the * current options and remote mount options. */ if (fo->opt_addopts) { if (STREQ(fo->opt_opts, fo->opt_remopts)) { /* optimize things for the common case where opts==remopts */ char *mergedstr; mergedstr = merge_opts(fo->opt_opts, fo->opt_addopts); plog(XLOG_INFO, "merge rem/opts \"%s\" add \"%s\" => \"%s\"", fo->opt_opts, fo->opt_addopts, mergedstr); XFREE(fo->opt_opts); XFREE(fo->opt_remopts); fo->opt_opts = mergedstr; fo->opt_remopts = strdup(mergedstr); } else { char *mergedstr, *remmergedstr; mergedstr = merge_opts(fo->opt_opts, fo->opt_addopts); plog(XLOG_INFO, "merge opts \"%s\" add \"%s\" => \"%s\"", fo->opt_opts, fo->opt_addopts, mergedstr); XFREE(fo->opt_opts); fo->opt_opts = mergedstr; remmergedstr = merge_opts(fo->opt_remopts, fo->opt_addopts); plog(XLOG_INFO, "merge remopts \"%s\" add \"%s\" => \"%s\"", fo->opt_remopts, fo->opt_addopts, remmergedstr); XFREE(fo->opt_remopts); fo->opt_remopts = remmergedstr; } } /* * Initialize opt_mount_type to "nfs", if it's not initialized already */ if (!fo->opt_mount_type) fo->opt_mount_type = "nfs"; /* Normalize the sublink and make it absolute */ link_dir = fo->opt_sublink; if (link_dir && link_dir[0] && link_dir[0] != '/') { link_dir = str3cat((char *) NULL, fo->opt_fs, "/", link_dir); normalize_slash(link_dir); XFREE(fo->opt_sublink); fo->opt_sublink = link_dir; } /* * Check the filesystem is happy */ if (fo->fs_mtab) XFREE(fo->fs_mtab); fo->fs_mtab = rop->fs_match(fo); if (fo->fs_mtab) return rop; /* * Return error file system */ fo->fs_mtab = amfs_error_ops.fs_match(fo); return &amfs_error_ops; } am-utils-6.2+rc20110530/amd/amd.8000066400000000000000000000247311157065440000157340ustar00rootroot00000000000000.\" .\" Copyright (c) 1997-2011 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. .\" 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. 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 .\" 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/amd/amd.8 .\" .TH AMD 8 "3 November 1989" .SH NAME amd \- automatically mount file systems .SH SYNOPSIS .B amd .B \-H .br .B amd [ .BI \-F " conf_file" ] .br .B amd [ .B \-nprvHS ] [ .BI \-a " mount_point" ] [ .BI \-c " duration" ] [ .BI \-d " domain" ] [ .BI \-k " kernel-arch" ] [ .BI \-l " logfile" ] [ .BI \-o " op_sys_ver" ] [ .BI \-t " interval.interval" ] [ .BI \-w " interval" ] [ .BI \-x " log-option" ] [ .BI \-y " YP-domain" ] [ .BI \-A " arch" ] [ .BI \-C " cluster-name" ] [ .BI \-D " option" ] [ .BI \-F " conf_file" ] [ .BI \-O " op_sys_name" ] [ .BI \-T " tag" ] [ .I directory .I mapname .RI [ " \-map-options " ] ] .\|.\|. .SH DESCRIPTION .B Amd is a daemon that automatically mounts filesystems whenever a file or directory within that filesystem is accessed. Filesystems are automatically unmounted when they appear to have become quiescent. .LP .B Amd operates by attaching itself as an .SM NFS server to each of the specified .IB directories . Lookups within the specified directories are handled by .BR amd , which uses the map defined by .I mapname to determine how to resolve the lookup. Generally, this will be a host name, some filesystem information and some mount options for the given filesystem. .LP In the first form depicted above, .B amd will print a short help string. In the second form, if no options are specified, or the .B -F is used, .B amd will read configuration parameters from the file .I conf_file which defaults to .BR /etc/amd.conf . The last form is described below. .SH OPTIONS .\"*******************************************************" .TP .BI \-a " temporary-directory" Specify an alternative location for the real mount points. The default is .BR /a . .TP .BI \-c " duration" Specify a .IR duration , in seconds, that a looked up name remains cached when not in use. The default is 5 minutes. .TP .BI \-d " domain" Specify the local domain name. If this option is not given the domain name is determined from the hostname. .TP .BI \-k " kernel-arch" Specifies the kernel architecture. This is used solely to set the ${karch} selector. .TP .BI \-l " logfile" Specify a logfile in which to record mount and unmount events. If .I logfile is the string .B syslog then the log messages will be sent to the system log daemon by .IR syslog (3). The default syslog facility used is LOG_DAEMON. If you wish to change it, append its name to the log file name, delimited by a single colon. For example, if .I logfile is the string .B syslog:local7 then .B Amd will log messages via .IR syslog (3) using the LOG_LOCAL7 facility (if it exists on the system). .TP .B \-n Normalize hostnames. The name refereed to by ${rhost} is normalized relative to the host database before being used. The effect is to translate aliases into ``official'' names. .TP .BI \-o " op_sys_ver" Override the compiled-in version number of the operating system. Useful when the built in version is not desired for backward compatibility reasons. For example, if the build in version is ``2.5.1'', you can override it to ``5.5.1'', and use older maps that were written with the latter in mind. .TP .B \-p Print PID. Outputs the process-id of .B amd to standard output where it can be saved into a file. .TP .B \-r Restart existing mounts. .B Amd will scan the mount file table to determine which filesystems are currently mounted. Whenever one of these would have been auto-mounted, .B amd .I inherits it. .TP .BI \-t " timeout.retransmit" Specify the NFS timeout .IR interval , in tenths of a second, between NFS/RPC retries (for UDP only). The default is 0.8 seconds. The second value alters the retransmit counter, which defaults to 11 retransmissions. Both of these values are used by the kernel to communicate with amd. Useful defaults are supplied if either or both values are missing. Amd relies on the kernel RPC retransmit mechanism to trigger mount retries. The values of these parameters change the overall retry interval. Too long an interval gives poor interactive response; too short an interval causes excessive retries. .TP .B \-v Version. Displays version and configuration information on standard error. .TP .BI \-w " interval" Specify an .IR interval , in seconds, between attempts to dismount filesystems that have exceeded their cached times. The default is 2 minutes. .TP .BI \-x " options" Specify run-time logging options. The options are a comma separated list chosen from: fatal, error, user, warn, info, map, stats, defaults, and all. Note that "fatal" and "error" are mandatory and cannot be turned off. .TP .BI \-y " domain" Specify an alternative NIS domain from which to fetch the NIS maps. The default is the system domain name. This option is ignored if NIS support is not available. .TP .BI \-A " arch" Specifies the OS architecture. This is used solely to set the ${arch} selector. .TP .BI \-C " cluster-name" Specify an alternative HP-UX cluster name to use. .TP .BI \-D " option" Select from a variety of debug options. Prefixing an option with the strings .B no reverses the effect of that option. Options are cumulative. The most useful option is .BR all . Since .I \-D is only used for debugging other options are not documented here: the current supported set of options is listed by the \-v option and a fuller description is available in the program source. .TP .BI \-F " conf_file" Specify an amd configuration file to use. See .BR amd.conf (5) for description of this file's format. This configuration file is used to specify any options in lieu of typing many of them on the command line. The .I amd.conf file includes directives for every command line option amd has, and many more that are only available via the configuration file facility. The configuration file specified by this option is processed after all other options had been processed, regardless of the actual location of this option on the command line. .TP .B \-H Print help and usage string. .TP .BI \-O " op_sys_name" Override the compiled-in name of the operating system. Useful when the built in name is not desired for backward compatibility reasons. For example, if the build in name is ``sunos5'', you can override it to ``sos5'', and use older maps which were written with the latter in mind. .TP .B \-S Do not lock the running executable pages of amd into memory. To improve amd's performance, systems that support the .BR plock (3) call, could lock the amd process into memory. This way there is less chance the operating system will schedule, page out, and swap the amd process as needed. This tends improves amd's performance, at the cost of reserving the memory used by the amd process (making it unavailable for other processes). If this behavior is not desired, use the .B \-S option. .TP .BI \-T " tag" Specify a tag to use with .BR amd.conf (5). All map entries tagged with .I tag will be processed. Map entries that are not tagged are always processed. Map entries that are tagged with a tag other than .I tag will not be processed. .SH FILES .TP 5 .B /a directory under which filesystems are dynamically mounted .TP 5 .B /etc/amd.conf default configuration file .SH CAVEATS Some care may be required when creating a mount map. .LP Symbolic links on an NFS filesystem can be incredibly inefficient. In most implementations of NFS, their interpolations are not cached by the kernel and each time a symlink is encountered during a .I lookuppn translation it costs an RPC call to the NFS server. It would appear that a large improvement in real-time performance could be gained by adding a cache somewhere. Replacing symlinks with a suitable incarnation of the auto-mounter results in a large real-time speedup, but also causes a large number of process context switches. .LP A weird imagination is most useful to gain full advantage of all the features. .SH "SEE ALSO" .BR amq (8), .BR domainname (1), .BR hostname (1), .BR syslog (3). .BR amd.conf (5), .BR mtab (5), .BR automount (8), .BR mount (8), .BR umount (8), .LP ``am-utils'' .BR info (1) entry. .LP .I "Linux NFS and Automounter Administration" by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). .LP .I http://www.am-utils.org .LP .I "Amd \- The 4.4 BSD Automounter" .SH AUTHORS Jan-Simon Pendry , Department of Computing, Imperial College, London, UK. .P Erez Zadok , Computer Science Department, Stony Brook University, Stony Brook, New York, USA. .P Other authors and contributors to am-utils are listed in the .B AUTHORS file distributed with am-utils. am-utils-6.2+rc20110530/amd/amd.c000066400000000000000000000364121157065440000160060ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/amd.c * */ /* * Automounter */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include struct amu_global_options gopt; /* where global options are stored */ char pid_fsname[SIZEOF_PID_FSNAME]; /* "kiska.southseas.nz:(pid%d)" */ char *hostdomain = "unknown.domain"; #define SIZEOF_HOSTD (2 * MAXHOSTNAMELEN + 1) /* Host+domain */ char hostd[SIZEOF_HOSTD]; /* Host+domain */ char *endian = ARCH_ENDIAN; /* Big or Little endian */ char *cpu = HOST_CPU; /* CPU type */ char *PrimNetName; /* name of primary network */ char *PrimNetNum; /* number of primary network */ int immediate_abort; /* Should close-down unmounts be retried */ int orig_umask = 022; int select_intr_valid; jmp_buf select_intr; struct amd_stats amd_stats; /* Server statistics */ struct in_addr myipaddr; /* (An) IP address of this host */ time_t do_mapc_reload = 0; /* mapc_reload() call required? */ #ifdef HAVE_FS_AUTOFS int amd_use_autofs = 0; #endif /* HAVE_FS_AUTOFS */ #ifdef HAVE_SIGACTION sigset_t masked_sigs; #endif /* HAVE_SIGACTION */ /* * Signal handler: * SIGINT - tells amd to do a full shutdown, including unmounting all * filesystem. * SIGTERM - tells amd to shutdown now. Just unmounts the automount nodes. */ static RETSIGTYPE sigterm(int sig) { #ifdef REINSTALL_SIGNAL_HANDLER signal(sig, sigterm); #endif /* REINSTALL_SIGNAL_HANDLER */ switch (sig) { case SIGINT: immediate_abort = 15; break; case SIGTERM: immediate_abort = -1; /* fall through... */ default: plog(XLOG_WARNING, "WARNING: automounter going down on signal %d", sig); break; } if (select_intr_valid) longjmp(select_intr, sig); } /* * Hook for cache reload. * When a SIGHUP arrives it schedules a call to mapc_reload */ static RETSIGTYPE sighup(int sig) { #ifdef REINSTALL_SIGNAL_HANDLER signal(sig, sighup); #endif /* REINSTALL_SIGNAL_HANDLER */ if (sig != SIGHUP) dlog("spurious call to sighup"); /* * Force a reload by zero'ing the timer */ if (amd_state == Run) do_mapc_reload = 0; } static RETSIGTYPE parent_exit(int sig) { /* * This signal handler is called during Amd initialization. The parent * forks a child to do all the hard automounting work, and waits for a * SIGQUIT signal from the child. When the parent gets the signal it's * supposed to call this handler and exit(3), thus completing the * daemonizing process. Alas, on some systems, especially Linux 2.4/2.6 * with Glibc, exit(3) doesn't always terminate the parent process. * Worse, the parent process now refuses to accept any more SIGQUIT * signals -- they are blocked. What's really annoying is that this * doesn't happen all the time, suggesting a race condition somewhere. * (This happens even if I change the logic to use another signal.) I * traced this to something which exit(3) does in addition to exiting the * process, probably some atexit() stuff or other side-effects related to * signal handling. Either way, since at this stage the parent process * just needs to terminate, I'm simply calling _exit(2). Note also that * the OpenGroup doesn't list exit(3) as a recommended "Base Interface" * but they do list _exit(2) as one. This fix seems to work reliably all * the time. -Erez (2/27/2005) */ _exit(0); } static int daemon_mode(void) { int bgpid; #ifdef HAVE_SIGACTION struct sigaction sa, osa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = parent_exit; sa.sa_flags = 0; sigemptyset(&(sa.sa_mask)); sigaddset(&(sa.sa_mask), SIGQUIT); sigaction(SIGQUIT, &sa, &osa); #else /* not HAVE_SIGACTION */ signal(SIGQUIT, parent_exit); #endif /* not HAVE_SIGACTION */ bgpid = background(); if (bgpid != 0) { /* * Now wait for the automount points to * complete. */ for (;;) pause(); /* should never reach here */ } #ifdef HAVE_SIGACTION sigaction(SIGQUIT, &osa, NULL); #else /* not HAVE_SIGACTION */ signal(SIGQUIT, SIG_DFL); #endif /* not HAVE_SIGACTION */ /* * Record our pid to make it easier to kill the correct amd. */ if (gopt.flags & CFM_PRINT_PID) { if (STREQ(gopt.pid_file, "/dev/stdout")) { printf("%ld\n", (long) am_mypid); /* flush stdout, just in case */ fflush(stdout); } else { FILE *f; mode_t prev_umask = umask(0022); /* set secure temporary umask */ f = fopen(gopt.pid_file, "w"); if (f) { fprintf(f, "%ld\n", (long) am_mypid); (void) fclose(f); } else { fprintf(stderr, "cannot open %s (errno=%d)\n", gopt.pid_file, errno); } umask(prev_umask); /* restore umask */ } } /* * Pretend we are in the foreground again */ foreground = 1; /* * Dissociate from the controlling terminal */ amu_release_controlling_tty(); return getppid(); } /* * Initialize global options structure. */ static void init_global_options(void) { #if defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME) static struct utsname un; #endif /* defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME) */ int i; memset(&gopt, 0, sizeof(struct amu_global_options)); /* name of current architecture */ gopt.arch = HOST_ARCH; /* automounter temp dir */ gopt.auto_dir = "/a"; /* toplevel attribute cache timeout */ gopt.auto_attrcache = 0; /* cluster name */ gopt.cluster = NULL; /* executable map timeout */ gopt.exec_map_timeout = AMFS_EXEC_MAP_TIMEOUT; /* * kernel architecture: this you must get from uname() if possible. */ #if defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME) if (uname(&un) >= 0) gopt.karch = un.machine; else #endif /* defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME) */ gopt.karch = HOST_ARCH; /* amd log file */ gopt.logfile = NULL; /* operating system name */ gopt.op_sys = HOST_OS_NAME; /* OS version */ gopt.op_sys_ver = HOST_OS_VERSION; /* full OS name and version */ gopt.op_sys_full = HOST_OS; /* OS version */ gopt.op_sys_vendor = HOST_VENDOR; /* pid file */ gopt.pid_file = "/dev/stdout"; /* local domain */ gopt.sub_domain = NULL; /* reset NFS (and toplvl) retransmit counter and retry interval */ for (i=0; i= sizeof(u_int)); assert(sizeof(int) >= 4); /* * Set processing status. */ amd_state = Start; /* * Determine program name */ if (argv[0]) { progname = strrchr(argv[0], '/'); if (progname && progname[1]) progname++; else progname = argv[0]; } if (!progname) progname = "amd"; am_set_progname(progname); /* * Initialize process id. This is kept * cached since it is used for generating * and using file handles. */ am_set_mypid(); /* * Get local machine name */ if (gethostname(hostname, sizeof(hostname)) < 0) { plog(XLOG_FATAL, "gethostname: %m"); going_down(1); } hostname[sizeof(hostname) - 1] = '\0'; /* * Check it makes sense */ if (!*hostname) { plog(XLOG_FATAL, "host name is not set"); going_down(1); } /* * Initialize global options structure. */ init_global_options(); /* * Partially initialize hostd[]. This * is completed in get_args(). */ if ((domdot = strchr(hostname, '.'))) { /* * Hostname already contains domainname. * Split out hostname and domainname * components */ *domdot++ = '\0'; hostdomain = domdot; } xstrlcpy(hostd, hostname, sizeof(hostd)); am_set_hostname(hostname); /* * Setup signal handlers */ /* SIGINT: trap interrupts for shutdowns */ setup_sighandler(SIGINT, sigterm); /* SIGTERM: trap terminate so we can shutdown cleanly (some chance) */ setup_sighandler(SIGTERM, sigterm); /* SIGHUP: hangups tell us to reload the cache */ setup_sighandler(SIGHUP, sighup); /* * SIGCHLD: trap Death-of-a-child. These allow us to pick up the exit * status of backgrounded mounts. See "sched.c". */ setup_sighandler(SIGCHLD, sigchld); #ifdef HAVE_SIGACTION /* construct global "masked_sigs" used in nfs_start.c */ sigemptyset(&masked_sigs); sigaddset(&masked_sigs, SIGINT); sigaddset(&masked_sigs, SIGTERM); sigaddset(&masked_sigs, SIGHUP); sigaddset(&masked_sigs, SIGCHLD); #endif /* HAVE_SIGACTION */ /* * Fix-up any umask problems. Most systems default * to 002 which is not too convenient for our purposes */ orig_umask = umask(0); /* * Figure out primary network name */ getwire(&PrimNetName, &PrimNetNum); /* * Determine command-line arguments. * (Also initialize amd.conf parameters, maps, and more.) */ get_args(argc, argv); /* * Log version information. */ vertmp = get_version_string(); verstr = strtok(vertmp, "\n"); plog(XLOG_INFO, "AM-UTILS VERSION INFORMATION:"); while (verstr) { plog(XLOG_INFO, "%s", verstr); verstr = strtok(NULL, "\n"); } XFREE(vertmp); /* * Get our own IP address so that we can mount the automounter. We pass * localhost_address which could be used as the default localhost * name/address in amu_get_myaddress(). */ amu_get_myaddress(&myipaddr, gopt.localhost_address); plog(XLOG_INFO, "My ip addr is %s", inet_ntoa(myipaddr)); /* avoid hanging on other NFS servers if started elsewhere */ if (chdir("/") < 0) plog(XLOG_INFO, "cannot chdir to /: %m"); /* * Now check we are root. */ if (geteuid() != 0) { plog(XLOG_FATAL, "Must be root to mount filesystems (euid = %ld)", (long) geteuid()); going_down(1); } #ifdef HAVE_MAP_NIS /* * If the domain was specified then bind it here * to circumvent any default bindings that may * be done in the C library. */ if (gopt.nis_domain && yp_bind(gopt.nis_domain)) { plog(XLOG_FATAL, "Can't bind to NIS domain \"%s\"", gopt.nis_domain); going_down(1); } #endif /* HAVE_MAP_NIS */ if (amuDebug(D_DAEMON)) ppid = daemon_mode(); /* * Lock process text and data segment in memory. */ if (gopt.flags & CFM_PROCESS_LOCK) { do_memory_locking(); } do_mapc_reload = clocktime(NULL) + gopt.map_reload_interval; /* * Register automounter with system. */ error = mount_automounter(ppid); if (error && ppid) kill(ppid, SIGALRM); #ifdef HAVE_FS_AUTOFS /* * XXX this should be part of going_down(), but I can't move it there * because it would be calling non-library code from the library... ugh */ if (amd_use_autofs) destroy_autofs_service(); #endif /* HAVE_FS_AUTOFS */ going_down(error); abort(); return 1; /* should never get here */ } am-utils-6.2+rc20110530/amd/amd.h000066400000000000000000001001771157065440000160130ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amd.h * */ #ifndef _AMD_H #define _AMD_H /* * MACROS: */ /* * Define a default debug mtab path for systems * that support mtab on file. */ #ifdef MOUNT_TABLE_ON_FILE # define DEBUG_MNTTAB_FILE "/tmp/mtab" #endif /* MOUNT_TABLE_ON_FILE */ /* Max line length that info services can handle */ #define INFO_MAX_LINE_LEN 1500 /* options for amd.conf */ #define CFM_BROWSABLE_DIRS 0x00000001 #define CFM_MOUNT_TYPE_AUTOFS 0x00000002 /* use kernel autofs support */ #define CFM_SELECTORS_IN_DEFAULTS 0x00000004 #define CFM_NORMALIZE_HOSTNAMES 0x00000008 #define CFM_PROCESS_LOCK 0x00000010 #define CFM_PRINT_PID 0x00000020 #define CFM_RESTART_EXISTING_MOUNTS 0x00000040 #define CFM_SHOW_STATFS_ENTRIES 0x00000080 #define CFM_FULLY_QUALIFIED_HOSTS 0x00000100 #define CFM_BROWSABLE_DIRS_FULL 0x00000200 /* allow '/' in readdir() */ #define CFM_UNMOUNT_ON_EXIT 0x00000400 /* when amd finishing */ #define CFM_USE_TCPWRAPPERS 0x00000800 #define CFM_AUTOFS_USE_LOFS 0x00001000 #define CFM_NFS_INSECURE_PORT 0x00002000 #define CFM_DOMAIN_STRIP 0x00004000 #define CFM_NORMALIZE_SLASHES 0x00008000 /* normalize slashes? */ #define CFM_FORCED_UNMOUNTS 0x00010000 /* forced unmounts? */ #define CFM_TRUNCATE_LOG 0x00020000 /* truncate log file? */ #define CFM_SUN_MAP_SYNTAX 0x00040000 /* Sun map syntax? */ #define CFM_NFS_ANY_INTERFACE 0x00080000 /* all interfaces are acceptable */ /* defaults global flags: plock, tcpwrappers, and autofs/lofs */ #define CFM_DEFAULT_FLAGS (CFM_PROCESS_LOCK|CFM_USE_TCPWRAPPERS|CFM_AUTOFS_USE_LOFS|CFM_DOMAIN_STRIP|CFM_NORMALIZE_SLASHES) /* * macro definitions for automounter vfs/vnode operations. */ #define VLOOK_CREATE 0x1 #define VLOOK_DELETE 0x2 #define VLOOK_LOOKUP 0x3 /* * macro definitions for automounter vfs capabilities */ #define FS_DIRECTORY 0x0001 /* This looks like a dir, not a link */ #define FS_MBACKGROUND 0x0002 /* Should background this mount */ #define FS_NOTIMEOUT 0x0004 /* Don't bother with timeouts */ #define FS_MKMNT 0x0008 /* Need to make the mount point */ #define FS_UBACKGROUND 0x0010 /* Unmount in background */ #define FS_BACKGROUND (FS_MBACKGROUND|FS_UBACKGROUND) #define FS_DISCARD 0x0020 /* Discard immediately on last reference */ #define FS_AMQINFO 0x0040 /* Amq is interested in this fs type */ #define FS_AUTOFS 0x0080 /* This filesystem can be an autofs f/s */ #define FS_DIRECT 0x0100 /* Direct mount */ #define FS_ON_AUTOFS 0x0200 /* This filesystem can be mounted directly onto an autofs mountpoint */ /* * macros for struct am_node (map of auto-mount points). */ #define AMF_NOTIMEOUT 0x0001 /* This node never times out */ #define AMF_ROOT 0x0002 /* This is a root node */ #define AMF_AUTOFS 0x0004 /* This node is part of an autofs filesystem */ #define AMF_REMOUNT 0x0008 /* This node needs to be remounted */ #define AMF_SOFTLOOKUP 0x0010 /* This node returns EIO if server is down */ /* * macros for struct mntfs (list of mounted filesystems) */ #define MFF_MOUNTED 0x0001 /* Node is mounted */ #define MFF_MOUNTING 0x0002 /* Mount is in progress */ #define MFF_UNMOUNTING 0x0004 /* Unmount is in progress */ #define MFF_RESTART 0x0008 /* Restarted node */ #define MFF_MKMNT 0x0010 /* Delete this node's am_mount */ #define MFF_ERROR 0x0020 /* This node failed to mount */ #define MFF_LOGDOWN 0x0040 /* Logged that this mount is down */ #define MFF_RSTKEEP 0x0080 /* Don't timeout this filesystem - restarted */ #define MFF_WANTTIMO 0x0100 /* Need a timeout call when not busy */ #define MFF_NFSLINK 0x0200 /* nfsl type, and deemed a link */ #define MFF_IS_AUTOFS 0x0400 /* this filesystem is of type autofs */ #define MFF_NFS_SCALEDOWN 0x0800 /* the mount failed, retry with v2/UDP */ #define MFF_ON_AUTOFS 0x1000 /* autofs has a lofs/link to this f/s */ #define MFF_WEBNFS 0x2000 /* use public filehandle */ /* * macros for struct fserver. */ #define FSF_VALID 0x0001 /* Valid information available */ #define FSF_DOWN 0x0002 /* This fileserver is thought to be down */ #define FSF_ERROR 0x0004 /* Permanent error has occurred */ #define FSF_WANT 0x0008 /* Want a wakeup call */ #define FSF_PINGING 0x0010 /* Already doing pings */ #define FSF_WEBNFS 0x0020 /* Don't try to contact portmapper */ #define FSF_PING_UNINIT 0x0040 /* ping values have not been initilized */ #define FSF_FORCE_UNMOUNT 0x0080 /* force umount of this fserver */ #define FSRV_ERROR(fs) ((fs) && (((fs)->fs_flags & FSF_ERROR) == FSF_ERROR)) #define FSRV_ISDOWN(fs) ((fs) && (((fs)->fs_flags & (FSF_DOWN|FSF_VALID)) == (FSF_DOWN|FSF_VALID))) #define FSRV_ISUP(fs) (!(fs) || (((fs)->fs_flags & (FSF_DOWN|FSF_VALID)) == (FSF_VALID))) /* some systems (SunOS 4.x) neglect to define the mount null message */ #ifndef MOUNTPROC_NULL # define MOUNTPROC_NULL ((u_long)(0)) #endif /* not MOUNTPROC_NULL */ /* * Error to return if remote host is not available. * Try, in order, "host down", "host unreachable", "invalid argument". */ #ifdef EHOSTDOWN # define AM_ERRNO_HOST_DOWN EHOSTDOWN #else /* not EHOSTDOWN */ # ifdef EHOSTUNREACH # define AM_ERRNO_HOST_DOWN EHOSTUNREACH # else /* not EHOSTUNREACH */ # define AM_ERRNO_HOST_DOWN EINVAL # endif /* not EHOSTUNREACH */ #endif /* not EHOSTDOWN */ /* Hash table size */ #define NKVHASH (1 << 2) /* Power of two */ /* Max entries to return in one call */ #define MAX_READDIR_ENTRIES 16 /* * default amfs_auto retrans - 1/10th seconds */ #define AMFS_AUTO_RETRANS(x) ((ALLOWED_MOUNT_TIME*10+5*gopt.amfs_auto_timeo[(x)])/gopt.amfs_auto_timeo[(x)] * 2) /* * The following values can be tuned... */ #define AM_TTL (300) /* Default cache period (5 min) */ #define AM_TTL_W (120) /* Default unmount interval (2 min) */ #define AM_PINGER 30 /* NFS ping interval for live systems */ #define AMFS_AUTO_TIMEO 8 /* Default amfs_auto timeout - .8s */ #define AMFS_EXEC_MAP_TIMEOUT 10 /* default 10sec exec map timeout */ /* interval between forced retries of a mount */ #define RETRY_INTERVAL 2 #ifndef ROOT_MAP # define ROOT_MAP "\"root\"" #endif /* not ROOT_MAP */ #define ereturn(x) do { *error_return = x; return 0; } while (0) #define NEVER (time_t) 0 #if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) # define AMD_SERVICE_NAME "amd" /* for tcpwrappers */ #endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) */ /* * TYPEDEFS: */ typedef struct cf_map cf_map_t; typedef struct kv kv; typedef struct am_node am_node; typedef struct mntfs mntfs; typedef struct am_loc am_loc; typedef struct am_opts am_opts; typedef struct am_ops am_ops; typedef struct am_stats am_stats; typedef struct fserver fserver; typedef voidp wchan_t; typedef voidp opaque_t; /* * Cache map operations */ typedef void add_fn(mnt_map *, char *, char *); typedef int init_fn(mnt_map *, char *, time_t *); typedef int mtime_fn(mnt_map *, char *, time_t *); typedef int isup_fn(mnt_map *, char *); typedef int reload_fn(mnt_map *, char *, add_fn *); typedef int search_fn(mnt_map *, char *, char *, char **, time_t *); typedef int task_fun(opaque_t); typedef void cb_fun(int, int, opaque_t); typedef void fwd_fun(voidp, int, struct sockaddr_in *, struct sockaddr_in *, opaque_t, int); typedef int key_fun(char *, opaque_t); typedef void callout_fun(opaque_t); /* * automounter vfs/vnode operations. */ typedef char *(*vfs_match) (am_opts *); typedef int (*vfs_init) (mntfs *); typedef int (*vmount_fs) (am_node *, mntfs *); typedef int (*vumount_fs) (am_node *, mntfs *); typedef am_node *(*vlookup_child) (am_node *, char *, int *, int); typedef am_node *(*vmount_child) (am_node *, int *); typedef int (*vreaddir) (am_node *, nfscookie, nfsdirlist *, nfsentry *, u_int); typedef am_node *(*vreadlink) (am_node *, int *); typedef void (*vmounted) (mntfs *); typedef void (*vumounted) (mntfs *); typedef fserver *(*vffserver) (mntfs *); typedef wchan_t (*vget_wchan) (mntfs *); /* * STRUCTURES: */ /* global amd options that are manipulated by conf.c */ struct amu_global_options { char *arch; /* name of current architecture */ char *auto_dir; /* automounter temp dir */ int auto_attrcache; /* attribute cache timeout for auto dirs */ char *cluster; /* cluster name */ char *karch; /* kernel architecture */ char *logfile; /* amd log file */ char *op_sys; /* operating system name ${os} */ char *op_sys_ver; /* OS version ${osver} */ char *op_sys_full; /* full OS name ${full_os} */ char *op_sys_vendor; /* name of OS vendor ${vendor} */ char *pid_file; /* PID file */ char *sub_domain; /* local domain */ char *localhost_address; /* localhost address (NULL means use 127.0.0.1) */ char *map_defaults; /* global map /default options */ char *map_options; /* global map options */ int map_reload_interval; /* map reload interval */ char *map_type; /* global map type */ char *search_path; /* search path for maps */ char *mount_type; /* mount type for map */ char *debug_mtab_file; /* path for the mtab file during debug mode */ u_int flags; /* various CFM_* flags */ #define AMU_TYPE_NONE -1 /* for amfs_auto_{timeo,retrans,toplvl} */ #define AMU_TYPE_UDP 0 /* for amfs_auto_{timeo,retrans,toplvl} */ #define AMU_TYPE_TCP 1 /* for amfs_auto_{timeo,retrans,toplvl} */ /* * Note: toplvl is only UDP, but we want to separate it from regular * NFS mounts which Amd makes, because the toplvl mount is a localhost * mount for which different timeo/retrans parameters may be desired. */ #define AMU_TYPE_TOPLVL 2 /* for amfs_auto_{timeo,retrans,toplvl} */ #define AMU_TYPE_MAX 3 /* for amfs_auto_{timeo,retrans,toplvl} */ int amfs_auto_retrans[AMU_TYPE_MAX]; /* NFS retransmit counter */ int amfs_auto_timeo[AMU_TYPE_MAX]; /* NFS retry interval */ int am_timeo; /* cache duration */ int am_timeo_w; /* dismount interval */ u_long portmap_program; /* amd RPC program number */ u_short preferred_amq_port; /* preferred amq service RPC port number (0 means "any") */ #ifdef HAVE_MAP_HESIOD char *hesiod_base; /* Hesiod rhs */ #endif /* HAVE_MAP_HESIOD */ #ifdef HAVE_MAP_LDAP char *ldap_base; /* LDAP base */ char *ldap_hostports; /* LDAP host ports */ long ldap_cache_seconds; /* LDAP internal cache - keep seconds */ long ldap_cache_maxmem; /* LDAP internal cache - max memory (bytes) */ long ldap_proto_version; /* LDAP protocol version */ #endif /* HAVE_MAP_LDAP */ #ifdef HAVE_MAP_NIS char *nis_domain; /* YP domain name */ #endif /* HAVE_MAP_NIS */ char *nfs_proto; /* NFS protocol (NULL, udp, tcp) */ int nfs_vers; /* NFS version (0, 2, 3, 4) */ u_int exec_map_timeout; /* timeout (seconds) for executable maps */ }; /* if you add anything here, update conf.c:reset_cf_map() */ struct cf_map { char *cfm_dir; /* /home, /u, /src */ char *cfm_name; /* amd.home, /etc/amd.home ... */ char *cfm_type; /* file, hesiod, ndbm, nis ... */ char *cfm_defaults; /* map /defaults options in amd.conf */ char *cfm_opts; /* -cache:=all, etc. */ char *cfm_search_path; /* /etc/local:/etc/amdmaps:/misc/yp */ char *cfm_tag; /* optional map tag for amd -T */ u_int cfm_flags; /* browsable_dirs? mount_type? */ struct cf_map *cfm_next; /* pointer to next in list (if any) */ }; /* * Key-value pair */ struct kv { kv *next; char *key; #ifdef HAVE_REGEXEC regex_t re; /* store the regexp from regcomp() */ #endif /* HAVE_REGEXEC */ char *val; }; struct mnt_map { qelem hdr; int refc; /* Reference count */ short flags; /* Allocation flags */ short alloc; /* Allocation mode */ time_t modify; /* Modify time of map */ u_int reloads; /* Number of times map was reloaded */ char *map_name; /* Name of this map */ char *wildcard; /* Wildcard value */ reload_fn *reload; /* Function to be used for reloads */ isup_fn *isup; /* Is service up or not? (1=up, 0=down) */ search_fn *search; /* Function to be used for searching */ mtime_fn *mtime; /* Modify time function */ kv *kvhash[NKVHASH]; /* Cached data */ cf_map_t *cfm; /* pointer to per-map amd.conf opts, if any */ void *map_data; /* Map data black box */ }; /* * Options */ struct am_opts { char *fs_glob; /* Smashed copy of global options */ char *fs_local; /* Expanded copy of local options */ char *fs_mtab; /* Mount table entry */ /* Other options ... */ char *opt_dev; char *opt_delay; char *opt_dir; char *opt_fs; char *opt_group; char *opt_mount; char *opt_opts; char *opt_remopts; char *opt_pref; char *opt_cache; char *opt_rfs; char *opt_rhost; char *opt_sublink; char *opt_type; char *opt_mount_type; /* "nfs" or "autofs" */ char *opt_unmount; char *opt_umount; /* an "alias" for opt_unmount (type:=program) */ char *opt_user; char *opt_maptype; /* map type: file, nis, hesiod, etc. */ char *opt_cachedir; /* cache directory */ char *opt_addopts; /* options to add to opt_opts */ }; struct am_ops { char *fs_type; /* type of filesystems e.g. "nfsx" */ vfs_match fs_match; /* fxn: match */ vfs_init fs_init; /* fxn: initialization */ vmount_fs mount_fs; /* fxn: mount my own vnode */ vumount_fs umount_fs; /* fxn: unmount my own vnode */ vlookup_child lookup_child; /* fxn: lookup path-name */ vmount_child mount_child; /* fxn: mount path-name */ vreaddir readdir; /* fxn: read directory */ vreadlink readlink; /* fxn: read link */ vmounted mounted; /* fxn: after-mount extra actions */ vumounted umounted; /* fxn: after-umount extra actions */ vffserver ffserver; /* fxn: find a file server */ vget_wchan get_wchan; /* fxn: get the waiting channel */ int nfs_fs_flags; /* filesystem flags FS_* for nfs mounts */ #ifdef HAVE_FS_AUTOFS int autofs_fs_flags;/* filesystem flags FS_* for autofs mounts */ #endif /* HAVE_FS_AUTOFS */ }; /* * List of mounted filesystems */ struct mntfs { qelem mf_q; /* List of mounted filesystems */ am_ops *mf_ops; /* Operations on this mountpoint */ am_opts *mf_fo; /* File opts */ char *mf_mount; /* "/a/kiska/home/kiska" */ char *mf_info; /* Mount info */ char *mf_auto; /* Mount info */ char *mf_mopts; /* FS mount opts */ char *mf_remopts; /* Remote FS mount opts */ char *mf_loopdev; /* loop device name for /dev/loop mounts */ fserver *mf_server; /* File server */ int mf_fsflags; /* Flags FS_* copied from mf_ops->*_fs_flags */ int mf_flags; /* Flags MFF_* */ int mf_error; /* Error code from background mount */ int mf_refc; /* Number of references to this node */ int mf_cid; /* Callout id */ void (*mf_prfree) (opaque_t); /* Free private space */ opaque_t mf_private; /* Private - per-fs data */ }; /* * Locations: bindings between keys and mntfs */ struct am_loc { am_opts *al_fo; mntfs *al_mnt; int al_refc; }; /* * List of fileservers */ struct fserver { qelem fs_q; /* List of fileservers */ int fs_refc; /* Number of references to this server */ char *fs_host; /* Normalized hostname of server */ struct sockaddr_in *fs_ip; /* Network address of server */ int fs_cid; /* Callout id */ int fs_pinger; /* Ping (keepalive) interval */ int fs_flags; /* Flags */ char *fs_type; /* File server type */ u_long fs_version; /* NFS version of server (2, 3, etc.)*/ char *fs_proto; /* NFS protocol of server (tcp, udp, etc.) */ opaque_t fs_private; /* Private data */ void (*fs_prfree) (opaque_t); /* Free private data */ }; /* * Per-mountpoint statistics */ struct am_stats { time_t s_mtime; /* Mount time */ u_short s_uid; /* Uid of mounter */ int s_getattr; /* Count of getattrs */ int s_lookup; /* Count of lookups */ int s_readdir; /* Count of readdirs */ int s_readlink; /* Count of readlinks */ int s_statfs; /* Count of statfs */ }; /* * System statistics */ struct amd_stats { int d_drops; /* Dropped requests */ int d_stale; /* Stale NFS handles */ int d_mok; /* Successful mounts */ int d_merr; /* Failed mounts */ int d_uerr; /* Failed unmounts */ }; extern struct amd_stats amd_stats; /* * Map of auto-mount points. */ struct am_node { int am_mapno; /* Map number */ am_loc *am_al; /* Mounted filesystem */ am_loc **am_alarray; /* Filesystem sources to try to mount */ char *am_name; /* "kiska": name of this node */ char *am_path; /* "/home/kiska": path of this node's mount point */ char *am_link; /* "/a/kiska/home/kiska/this/that": link to sub-dir */ am_node *am_parent; /* Parent of this node */ am_node *am_ysib; /* Younger sibling of this node */ am_node *am_osib; /* Older sibling of this node */ am_node *am_child; /* First child of this node */ nfsattrstat am_attr; /* File attributes */ #define am_fattr am_attr.ns_u.ns_attr_u int am_flags; /* Boolean flags AMF_* */ int am_error; /* Specific mount error */ time_t am_ttl; /* Time to live */ int am_timeo_w; /* Dismount wait interval */ int am_timeo; /* Cache timeout interval */ u_int am_gen; /* Generation number */ char *am_pref; /* Mount info prefix */ am_stats am_stats; /* Statistics gathering */ SVCXPRT *am_transp; /* Info for quick reply */ dev_t am_dev; /* Device number */ dev_t am_rdev; /* Remote/real device number */ #ifdef HAVE_FS_AUTOFS autofs_fh_t *am_autofs_fh; time_t am_autofs_ttl; /* Time to expire autofs nodes */ #endif /* HAVE_FS_AUTOFS */ int am_fd[2]; /* parent child pipe fd's for sync umount */ }; /* * EXTERNALS: */ /* * Amq server global functions */ extern amq_mount_info_list *amqproc_getmntfs_1_svc(voidp argp, struct svc_req *rqstp); extern amq_mount_stats *amqproc_stats_1_svc(voidp argp, struct svc_req *rqstp); extern amq_mount_tree_list *amqproc_export_1_svc(voidp argp, struct svc_req *rqstp); extern amq_mount_tree_p *amqproc_mnttree_1_svc(voidp argp, struct svc_req *rqstp); extern amq_string *amqproc_getvers_1_svc(voidp argp, struct svc_req *rqstp); extern amq_string *amqproc_pawd_1_svc(voidp argp, struct svc_req *rqstp); extern int *amqproc_getpid_1_svc(voidp argp, struct svc_req *rqstp); extern int *amqproc_mount_1_svc(voidp argp, struct svc_req *rqstp); extern int *amqproc_setopt_1_svc(voidp argp, struct svc_req *rqstp); extern voidp amqproc_null_1_svc(voidp argp, struct svc_req *rqstp); extern int *amqproc_umnt_1_svc(voidp argp, struct svc_req *rqstp); extern int *amqproc_sync_umnt_1_svc_parent(voidp argp, struct svc_req *rqstp); extern amq_sync_umnt *amqproc_sync_umnt_1_svc_child(voidp argp, struct svc_req *rqstp); extern amq_sync_umnt *amqproc_sync_umnt_1_svc_async(voidp argp, struct svc_req *rqstp); /* other external definitions */ extern am_nfs_fh *get_root_nfs_fh(char *dir); extern am_node *find_ap(char *); extern am_node *get_ap_child(am_node *, char *); extern bool_t xdr_amq_mount_info_qelem(XDR *xdrs, qelem *qhead); extern fserver *find_nfs_srvr(mntfs *mf); extern int mount_nfs_fh(am_nfs_handle_t *fhp, char *mntdir, char *fs_name, mntfs *mf); extern int process_all_regular_maps(void); extern cf_map_t *find_cf_map(const char *name); extern int set_conf_kv(const char *section, const char *k, const char *v); extern int mount_node(opaque_t arg); extern int unmount_mp(am_node *mp); extern int conf_parse(void); /* "yyparse" renamed */ extern FILE *conf_in; /* "yyin" renamed */ extern void amfs_mkcacheref(mntfs *mf); extern int amfs_mount(am_node *mp, mntfs *mf, char *opts); extern void assign_error_mntfs(am_node *mp); extern am_node *next_nonerror_node(am_node *xp); extern void flush_srvr_nfs_cache(fserver *fs); extern void am_mounted(am_node *); extern void mf_mounted(mntfs *mf, bool_t call_free_opts); extern void am_unmounted(am_node *); extern am_node *get_exported_ap(int index); extern am_node *get_first_exported_ap(int *index); extern am_node *get_next_exported_ap(int *index); extern am_node *path_to_exported_ap(char *path); extern am_node *exported_ap_alloc(void); extern am_node *find_mf(mntfs *); extern am_node *next_map(int *); extern am_ops *ops_match(am_opts *, char *, char *, char *, char *, char *); extern am_ops *ops_search(char *); extern fserver *dup_srvr(fserver *); extern void srvrlog(fserver *, char *); extern int get_mountd_port(fserver *, u_short *, wchan_t); extern void flush_nfs_fhandle_cache(fserver *); extern mntfs *dup_mntfs(mntfs *); extern am_loc *dup_loc(am_loc *); extern mntfs *find_mntfs(am_ops *, am_opts *, char *, char *, char *, char *, char *); extern mntfs *locate_mntfs(am_ops *, am_opts *, char *, char *, char *, char *, char *); extern am_loc *new_loc(void); extern mntfs *new_mntfs(void); extern mntfs *realloc_mntfs(mntfs *, am_ops *, am_opts *, char *, char *, char *, char *, char *); extern void flush_mntfs(void); extern void free_mntfs(voidp); extern void free_loc(voidp); extern void amq_program_1(struct svc_req *rqstp, SVCXPRT *transp); extern int background(void); extern void deslashify(char *); extern void do_task_notify(void); extern int eval_fs_opts(am_opts *, char *, char *, char *, char *, char *); extern int file_read_line(char *, int, FILE *); extern void forcibly_timeout_mp(am_node *); extern void free_map(am_node *); extern void free_opts(am_opts *); extern am_opts *copy_opts(am_opts *); extern void free_srvr(fserver *); extern int fwd_init(void); extern int fwd_packet(int, char *, int, struct sockaddr_in *, struct sockaddr_in *, opaque_t, fwd_fun *); extern void fwd_reply(void); extern void get_args(int argc, char *argv[]); extern wchan_t get_mntfs_wchan(mntfs *mf); extern void host_normalize(char **); extern void init_map(am_node *, char *); extern void ins_que(qelem *, qelem *); extern void insert_am(am_node *, am_node *); extern int make_nfs_auth(void); extern void make_root_node(void); extern void map_flush_srvr(fserver *); extern void mapc_add_kv(mnt_map *, char *, char *); extern mnt_map *mapc_find(char *, char *, const char *, const char *); extern void mapc_free(opaque_t); extern int mapc_keyiter(mnt_map *, key_fun, opaque_t); extern void mapc_reload(void); extern int mapc_search(mnt_map *, char *, char **); extern void mapc_showtypes(char *buf, size_t l); extern int mapc_type_exists(const char *type); extern void mk_fattr(nfsfattr *, nfsftype); extern int mount_auto_node(char *, opaque_t); extern int mount_automounter(int); extern int mount_exported(void); extern void mp_to_fh(am_node *, am_nfs_fh *); extern void new_ttl(am_node *); extern void nfs_quick_reply(am_node *mp, int error); extern void normalize_slash(char *); extern void notify_child(am_node *, au_etype, int, int); extern void ops_showamfstypes(char *buf, size_t l); extern void ops_showfstypes(char *outbuf, size_t l); extern void rem_que(qelem *); extern void reschedule_timeout_mp(void); extern void restart(void); extern void restart_automounter_nodes(void); extern int root_keyiter(key_fun *, opaque_t); extern void root_newmap(const char *, const char *, const char *, const cf_map_t *); extern void run_task(task_fun *, opaque_t, cb_fun *, opaque_t); extern void sched_task(cb_fun *, opaque_t, wchan_t); extern int softclock(void); extern int timeout(u_int, void (*fn)(opaque_t), opaque_t); extern void timeout_mp(opaque_t); extern void untimeout(int); extern void umount_exported(void); extern int valid_key(char *); extern void wakeup(wchan_t); extern void wakeup_srvr(fserver *); extern void wakeup_task(int, int, wchan_t); #define SIZEOF_PID_FSNAME (16 + MAXHOSTNAMELEN) extern char pid_fsname[SIZEOF_PID_FSNAME]; /* "kiska.southseas.nz:(pid%d)" */ #define SIZEOF_HOSTD (2 * MAXHOSTNAMELEN + 1) extern char hostd[SIZEOF_HOSTD]; /* Host+domain */ #define SIZEOF_OPTS 256 /* used for char opts[] and preopts[] */ /* * Global variables. */ extern SVCXPRT *current_transp; /* For nfs_quick_reply() */ extern char *conf_tag; #define SIZEOF_UID_STR 12 #define SIZEOF_GID_STR 12 extern char *opt_gid, gid_str[SIZEOF_GID_STR]; extern char *opt_uid, uid_str[SIZEOF_UID_STR]; extern int NumChildren; extern int fwd_sock; extern int select_intr_valid; extern int immediate_abort; /* Should close-down unmounts be retried */ extern int usage; extern int use_conf_file; /* use amd configuration file */ extern int task_notify_todo; /* Task notifier needs running */ extern jmp_buf select_intr; extern qelem mfhead; extern struct amu_global_options gopt; /* where global options are stored */ extern time_t do_mapc_reload; /* Flush & reload mount map cache */ extern time_t next_softclock; /* Time to call softclock() */ #ifdef HAVE_SIGACTION extern sigset_t masked_sigs; #endif /* HAVE_SIGACTION */ #if defined(HAVE_AMU_FS_LINK) || defined(HAVE_AMU_FS_LINKX) extern char *amfs_link_match(am_opts *fo); #endif /* defined(HAVE_AMU_FS_LINK) || defined(HAVE_AMU_FS_LINKX) */ #ifdef HAVE_FS_AUTOFS extern int amd_use_autofs; extern int autofs_get_fh(am_node *mp); extern void autofs_release_fh(am_node *mp); extern void autofs_get_mp(am_node *mp); extern void autofs_release_mp(am_node *mp); extern void autofs_add_fdset(fd_set *readfds); extern int autofs_handle_fdset(fd_set *readfds, int nsel); extern void autofs_mounted(am_node *mp); extern void autofs_mount_succeeded(am_node *mp); extern void autofs_mount_failed(am_node *mp); extern int autofs_umount_succeeded(am_node *mp); extern int autofs_umount_failed(am_node *mp); extern int autofs_mount_fs(am_node *mp, mntfs *mf); extern int autofs_umount_fs(am_node *mp, mntfs *mf); extern void autofs_get_opts(char *opts, size_t l, autofs_fh_t *fh); extern int autofs_compute_mount_flags(mntent_t *); extern void autofs_timeout_mp(am_node *); extern int create_autofs_service(void); extern int destroy_autofs_service(void); #endif /* HAVE_FS_AUTOFS */ /**************************************************************************/ /*** Generic file-system types, implemented as part of the native O/S. ***/ /**************************************************************************/ /* * Loopback File System * Many systems can't support this, and in any case most of the * functionality is available with Symlink FS. */ #ifdef HAVE_FS_LOFS extern am_ops lofs_ops; extern int mount_lofs(char *mntdir, char *fs_name, char *opts, int on_autofs); #endif /* HAVE_FS_LOFS */ /* * CD-ROM File System (CD-ROM) * (HSFS: High Sierra F/S on some machines) * Many systems can't support this, and in any case most of the * functionality is available with program FS. */ #ifdef HAVE_FS_CDFS extern am_ops cdfs_ops; #endif /* HAVE_FS_CDFS */ /* * PC File System (MS-DOS) * Many systems can't support this, and in any case most of the * functionality is available with program FS. */ #ifdef HAVE_FS_PCFS extern am_ops pcfs_ops; #endif /* HAVE_FS_PCFS */ /* * UDF File System * Many systems can't support this, and in any case most of the * functionality is available with program FS. */ #ifdef HAVE_FS_UDF extern am_ops udf_ops; #endif /* HAVE_FS_UDF */ /* * Caching File System (Solaris) */ #ifdef HAVE_FS_CACHEFS extern am_ops cachefs_ops; #endif /* HAVE_FS_CACHEFS */ /* * In memory /tmp filesystem (Linux, NetBSD) */ #ifdef HAVE_FS_TMPFS extern am_ops tmpfs_ops; #endif /* HAVE_FS_TMPFS */ /* * Network File System * Good, slow, NFS V.2. */ #ifdef HAVE_FS_NFS extern am_ops nfs_ops; /* NFS */ extern fserver *find_nfs_srvr (mntfs *); extern qelem nfs_srvr_list; #endif /* HAVE_FS_NFS */ /* * Un*x File System * Normal local disk file system. */ #ifdef HAVE_FS_UFS extern am_ops ufs_ops; /* Un*x file system */ #endif /* HAVE_FS_UFS */ /* Unix file system (irix) */ #ifdef HAVE_FS_XFS extern am_ops xfs_ops; /* Un*x file system */ #endif /* HAVE_FS_XFS */ /* Unix file system (irix) */ #ifdef HAVE_FS_EFS extern am_ops efs_ops; /* Un*x file system */ #endif /* HAVE_FS_EFS */ /**************************************************************************/ /*** Automounter file-system types, implemented by amd. ***/ /**************************************************************************/ /* * Root AMD File System */ extern am_ops amfs_root_ops; /* Root file system */ /* * Generic amfs helper methods */ extern am_node *amfs_generic_lookup_child(am_node *mp, char *fname, int *error_return, int op); extern am_node *amfs_generic_mount_child(am_node *ap, int *error_return); extern int amfs_generic_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, u_int count); extern int amfs_generic_umount(am_node *mp, mntfs *mf); extern void amfs_generic_mounted(mntfs *mf); extern char *amfs_generic_match(am_opts *fo); extern fserver *amfs_generic_find_srvr(mntfs *); /* * Automount File System */ #ifdef HAVE_AMU_FS_AUTO extern am_ops amfs_auto_ops; /* Automount file system (this!) */ #endif /* HAVE_AMU_FS_AUTO */ /* * Toplvl Automount File System */ #ifdef HAVE_AMU_FS_TOPLVL extern am_ops amfs_toplvl_ops; /* Toplvl Automount file system */ extern int amfs_toplvl_mount(am_node *mp, mntfs *mf); extern int amfs_toplvl_umount(am_node *mp, mntfs *mf); #endif /* HAVE_AMU_FS_TOPLVL */ /* * Direct Automount File System */ #ifdef HAVE_AMU_FS_DIRECT extern am_ops amfs_direct_ops; /* Direct Automount file system (this too) */ #endif /* HAVE_AMU_FS_DIRECT */ /* * Error File System */ #ifdef HAVE_AMU_FS_ERROR extern am_ops amfs_error_ops; /* Error file system */ extern am_node *amfs_error_lookup_child(am_node *mp, char *fname, int *error_return, int op); extern am_node *amfs_error_mount_child(am_node *ap, int *error_return); extern int amfs_error_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, u_int count); #endif /* HAVE_AMU_FS_ERROR */ /* * NFS mounts with local existence check. */ #ifdef HAVE_AMU_FS_NFSL extern am_ops amfs_nfsl_ops; /* NFSL */ #endif /* HAVE_AMU_FS_NFSL */ /* * Multi-nfs mounts. */ #ifdef HAVE_AMU_FS_NFSX extern am_ops amfs_nfsx_ops; /* NFSX */ #endif /* HAVE_AMU_FS_NFSX */ /* * NFS host - a whole tree. */ #ifdef HAVE_AMU_FS_HOST extern am_ops amfs_host_ops; /* NFS host */ #endif /* HAVE_AMU_FS_HOST */ /* * Program File System * This is useful for things like RVD. */ #ifdef HAVE_AMU_FS_PROGRAM extern am_ops amfs_program_ops; /* Program File System */ #endif /* HAVE_AMU_FS_PROGRAM */ /* * Symbolic-link file system. * A "filesystem" which is just a symbol link. */ #ifdef HAVE_AMU_FS_LINK extern am_ops amfs_link_ops; /* Symlink FS */ #endif /* HAVE_AMU_FS_LINK */ /* * Symbolic-link file system, which also checks that the target of * the symlink exists. * A "filesystem" which is just a symbol link. */ #ifdef HAVE_AMU_FS_LINKX extern am_ops amfs_linkx_ops; /* Symlink FS with existence check */ #endif /* HAVE_AMU_FS_LINKX */ /* * Union file system */ #ifdef HAVE_AMU_FS_UNION extern am_ops amfs_union_ops; /* Union FS */ #endif /* HAVE_AMU_FS_UNION */ #endif /* not _AMD_H */ am-utils-6.2+rc20110530/amd/amfs_auto.c000066400000000000000000000133661157065440000172260ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amfs_auto.c * */ /* * Automount file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /**************************************************************************** *** MACROS *** ****************************************************************************/ /**************************************************************************** *** STRUCTURES *** ****************************************************************************/ /**************************************************************************** *** FORWARD DEFINITIONS *** ****************************************************************************/ static int amfs_auto_mount(am_node *mp, mntfs *mf); /**************************************************************************** *** OPS STRUCTURES *** ****************************************************************************/ am_ops amfs_auto_ops = { "auto", amfs_generic_match, 0, /* amfs_auto_init */ amfs_auto_mount, amfs_generic_umount, amfs_generic_lookup_child, amfs_generic_mount_child, amfs_generic_readdir, 0, /* amfs_auto_readlink */ amfs_generic_mounted, 0, /* amfs_auto_umounted */ amfs_generic_find_srvr, 0, /* amfs_auto_get_wchan */ FS_AMQINFO | FS_DIRECTORY, #ifdef HAVE_FS_AUTOFS AUTOFS_AUTO_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /**************************************************************************** *** FUNCTIONS *** ****************************************************************************/ /* * Mount a sub-mount */ static int amfs_auto_mount(am_node *mp, mntfs *mf) { /* * Pseudo-directories are used to provide some structure * to the automounted directories instead * of putting them all in the top-level automount directory. * * Here, just increment the parent's link count. */ mp->am_parent->am_fattr.na_nlink++; /* * Info field of . means use parent's info field. * Historical - not documented. */ if (mf->mf_info[0] == '.' && mf->mf_info[1] == '\0') mf->mf_info = strealloc(mf->mf_info, mp->am_parent->am_al->al_mnt->mf_info); /* * Compute prefix: * * If there is an option prefix then use that else * If the parent had a prefix then use that with name * of this node appended else * Use the name of this node. * * That means if you want no prefix you must say so * in the map. */ if (mf->mf_fo->opt_pref) { /* allow pref:=null to set a real null prefix */ if (STREQ(mf->mf_fo->opt_pref, "null")) { mp->am_pref = strdup(""); } else { /* * the prefix specified as an option */ mp->am_pref = strdup(mf->mf_fo->opt_pref); } } else { /* * else the parent's prefix * followed by the name * followed by / */ char *ppref = mp->am_parent->am_pref; if (ppref == 0) ppref = ""; mp->am_pref = str3cat((char *) NULL, ppref, mp->am_name, "/"); } #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS) { char opts[SIZEOF_OPTS]; int error; autofs_get_opts(opts, sizeof(opts), mp->am_autofs_fh); /* now do the mount */ error = amfs_mount(mp, mf, opts); if (error) { errno = error; plog(XLOG_FATAL, "amfs_auto_mount: amfs_mount failed: %m"); return error; } } #endif /* HAVE_FS_AUTOFS */ /* * Attach a map cache */ amfs_mkcacheref(mf); return 0; } am-utils-6.2+rc20110530/amd/amfs_direct.c000066400000000000000000000100331157065440000175140ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amfs_direct.c * */ /* * Direct file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /**************************************************************************** *** FORWARD DEFINITIONS *** ****************************************************************************/ static am_node *amfs_direct_readlink(am_node *mp, int *error_return); /**************************************************************************** *** OPS STRUCTURES *** ****************************************************************************/ am_ops amfs_direct_ops = { "direct", amfs_generic_match, 0, /* amfs_direct_init */ amfs_toplvl_mount, amfs_toplvl_umount, amfs_generic_lookup_child, amfs_generic_mount_child, amfs_error_readdir, amfs_direct_readlink, amfs_generic_mounted, 0, /* amfs_direct_umounted */ amfs_generic_find_srvr, 0, /* amfs_direct_get_wchan */ FS_DIRECT | FS_MKMNT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO, #ifdef HAVE_FS_AUTOFS AUTOFS_DIRECT_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /**************************************************************************** *** FUNCTIONS *** ****************************************************************************/ static am_node * amfs_direct_readlink(am_node *mp, int *error_return) { am_node *xp; int rc = 0; xp = next_nonerror_node(mp->am_child); if (!xp) { if (!mp->am_al->al_mnt->mf_private) amfs_mkcacheref(mp->am_al->al_mnt); xp = amfs_generic_lookup_child(mp, mp->am_path + 1, &rc, VLOOK_CREATE); if (xp && rc < 0) xp = amfs_generic_mount_child(xp, &rc); } if (xp) { new_ttl(xp); /* (7/12/89) from Rein Tollevik */ return xp; } if (amd_state == Finishing) rc = ENOENT; *error_return = rc; return 0; } am-utils-6.2+rc20110530/amd/amfs_error.c000066400000000000000000000100751157065440000174010ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/amfs_error.c * */ /* * Error file system. * This is used as a last resort catchall if * nothing else worked. EFS just returns lots * of error codes, except for unmount which * always works of course. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include static char *amfs_error_match(am_opts *fo); static int amfs_error_mount(am_node *am, mntfs *mf); static int amfs_error_umount(am_node *am, mntfs *mf); /* * Ops structure */ am_ops amfs_error_ops = { "error", amfs_error_match, 0, /* amfs_error_init */ amfs_error_mount, amfs_error_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* amfs_error_readlink */ 0, /* amfs_error_mounted */ 0, /* amfs_error_umounted */ amfs_generic_find_srvr, 0, /* amfs_error_get_wchan */ FS_DISCARD, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_ERROR_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * EFS file system always matches */ static char * amfs_error_match(am_opts *fo) { return strdup("(error-hook)"); } static int amfs_error_mount(am_node *am, mntfs *mf) { return ENOENT; } static int amfs_error_umount(am_node *am, mntfs *mf) { /* * Always succeed */ return 0; } /* * EFS interface to RPC lookup() routine. * Should never get here in the automounter. * If we do then just give an error. */ am_node * amfs_error_lookup_child(am_node *mp, char *fname, int *error_return, int op) { *error_return = ESTALE; return 0; } /* * EFS interface to RPC lookup() routine. * Should never get here in the automounter. * If we do then just give an error. */ am_node * amfs_error_mount_child(am_node *ap, int *error_return) { *error_return = ESTALE; return 0; } /* * EFS interface to RPC readdir() routine. * Should never get here in the automounter. * If we do then just give an error. */ int amfs_error_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, u_int count) { return ESTALE; } am-utils-6.2+rc20110530/amd/amfs_generic.c000066400000000000000000001033611157065440000176650ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amfs_generic.c * */ /* * generic functions used by amfs filesystems, ripped out of amfs_auto.c. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /**************************************************************************** *** MACROS *** ****************************************************************************/ #define IN_PROGRESS(cp) ((cp)->mp->am_al->al_mnt->mf_flags & MFF_MOUNTING) /**************************************************************************** *** STRUCTURES *** ****************************************************************************/ /* * Mounting a file system may take a significant period of time. The * problem is that if this is done in the main process thread then the * entire automounter could be blocked, possibly hanging lots of processes * on the system. Instead we use a continuation scheme to allow mounts to * be attempted in a sub-process. When the sub-process exits we pick up the * exit status (by convention a UN*X error number) and continue in a * notifier. The notifier gets handed a data structure and can then * determine whether the mount was successful or not. If not, it updates * the data structure and tries again until there are no more ways to try * the mount, or some other permanent error occurs. In the mean time no RPC * reply is sent, even after the mount is successful. We rely on the RPC * retry mechanism to resend the lookup request which can then be handled. */ struct continuation { am_node *mp; /* Node we are trying to mount */ int retry; /* Try again? */ time_t start; /* Time we started this mount */ int callout; /* Callout identifier */ am_loc **al; /* Current location */ }; /**************************************************************************** *** FORWARD DEFINITIONS *** ****************************************************************************/ static am_node *amfs_lookup_node(am_node *mp, char *fname, int *error_return); static am_loc *amfs_lookup_one_location(am_node *new_mp, mntfs *mf, char *ivec, char *def_opts, char *pfname); static am_loc **amfs_lookup_loc(am_node *new_mp, int *error_return); static void amfs_cont(int rc, int term, opaque_t arg); static void amfs_retry(int rc, int term, opaque_t arg); static void free_continuation(struct continuation *cp); static int amfs_bgmount(struct continuation *cp); static char *amfs_parse_defaults(am_node *mp, mntfs *mf, char *def_opts); /**************************************************************************** *** FUNCTIONS *** ****************************************************************************/ static am_node * amfs_lookup_node(am_node *mp, char *fname, int *error_return) { am_node *new_mp; int error = 0; /* Error so far */ int in_progress = 0; /* # of (un)mount in progress */ mntfs *mf; char *expanded_fname = NULL; dlog("in amfs_lookup_node"); /* * If the server is shutting down * then don't return information * about the mount point. */ if (amd_state == Finishing) { if (mp->am_al == NULL || mp->am_al->al_mnt == NULL || mp->am_al->al_mnt->mf_fsflags & FS_DIRECT) { dlog("%s mount ignored - going down", fname); } else { dlog("%s/%s mount ignored - going down", mp->am_path, fname); } ereturn(ENOENT); } /* * Handle special case of "." and ".." */ if (fname[0] == '.') { if (fname[1] == '\0') return mp; /* "." is the current node */ if (fname[1] == '.' && fname[2] == '\0') { if (mp->am_parent) { dlog(".. in %s gives %s", mp->am_path, mp->am_parent->am_path); return mp->am_parent; /* ".." is the parent node */ } ereturn(ESTALE); } } /* * Check for valid key name. * If it is invalid then pretend it doesn't exist. */ if (!valid_key(fname)) { plog(XLOG_WARNING, "Key \"%s\" contains a disallowed character", fname); ereturn(ENOENT); } /* * Expand key name. * expanded_fname is now a private copy. */ expanded_fname = expand_selectors(fname); /* * Search children of this node */ for (new_mp = mp->am_child; new_mp; new_mp = new_mp->am_osib) { if (FSTREQ(new_mp->am_name, expanded_fname)) { if (new_mp->am_error) { error = new_mp->am_error; continue; } /* * If the error code is undefined then it must be * in progress. */ mf = new_mp->am_al->al_mnt; if (mf->mf_error < 0) goto in_progrss; /* * If there was a previous error with this node * then return that error code. */ if (mf->mf_flags & MFF_ERROR) { error = mf->mf_error; continue; } if (!(mf->mf_flags & MFF_MOUNTED) || (mf->mf_flags & MFF_UNMOUNTING)) { in_progrss: /* * If the fs is not mounted or it is unmounting then there * is a background (un)mount in progress. In this case * we just drop the RPC request (return nil) and * wait for a retry, by which time the (un)mount may * have completed. */ dlog("ignoring mount of %s in %s -- %smounting in progress, flags %x", expanded_fname, mf->mf_mount, (mf->mf_flags & MFF_UNMOUNTING) ? "un" : "", mf->mf_flags); in_progress++; if (mf->mf_flags & MFF_UNMOUNTING) { dlog("will remount later"); new_mp->am_flags |= AMF_REMOUNT; } continue; } /* * Otherwise we have a hit: return the current mount point. */ dlog("matched %s in %s", expanded_fname, new_mp->am_path); XFREE(expanded_fname); return new_mp; } } if (in_progress) { dlog("Waiting while %d mount(s) in progress", in_progress); XFREE(expanded_fname); ereturn(-1); } /* * If an error occurred then return it. */ if (error) { dlog("Returning error: %s", strerror(error)); XFREE(expanded_fname); ereturn(error); } /* * If the server is going down then just return, * don't try to mount any more file systems */ if ((int) amd_state >= (int) Finishing) { dlog("not found - server going down anyway"); ereturn(ENOENT); } /* * Allocate a new map */ new_mp = get_ap_child(mp, expanded_fname); XFREE(expanded_fname); if (new_mp == NULL) ereturn(ENOSPC); *error_return = -1; return new_mp; } static am_loc * amfs_lookup_one_location(am_node *new_mp, mntfs *mf, char *ivec, char *def_opts, char *pfname) { am_ops *p; am_opts *fs_opts; am_loc *new_al; mntfs *new_mf; char *mp_dir = NULL; #ifdef HAVE_FS_AUTOFS int on_autofs = 1; #endif /* HAVE_FS_AUTOFS */ /* match the operators */ /* * although we alloc the fs_opts here, the pointer is 'owned' by the am_loc and will * be free'd on destruction of the am_loc. If we don't allocate a loc, then we need * to free this. */ fs_opts = CALLOC(am_opts); p = ops_match(fs_opts, ivec, def_opts, new_mp->am_path, pfname, mf->mf_info); #ifdef HAVE_FS_AUTOFS /* XXX: this should be factored out into an autofs-specific function */ if (new_mp->am_flags & AMF_AUTOFS) { /* ignore user-provided fs if we're using autofs */ if (fs_opts->opt_sublink && fs_opts->opt_sublink[0]) { /* * For sublinks we need to use a hack with autofs: * mount the filesystem on the original opt_fs (which is NOT an * autofs mountpoint) and symlink (or lofs-mount) to it from * the autofs mountpoint. */ on_autofs = 0; mp_dir = fs_opts->opt_fs; } else { if (p->autofs_fs_flags & FS_ON_AUTOFS) { mp_dir = new_mp->am_path; } else { mp_dir = fs_opts->opt_fs; on_autofs = 0; } } } else #endif /* HAVE_FS_AUTOFS */ mp_dir = fs_opts->opt_fs; /* * Find or allocate a filesystem for this node. * we search for a matching backend share, since * we will construct our own al_loc to handle * any customisations for this usage. */ new_mf = find_mntfs(p, fs_opts, mp_dir, fs_opts->fs_mtab, def_opts, fs_opts->opt_opts, fs_opts->opt_remopts); /* * See whether this is a real filesystem */ p = new_mf->mf_ops; if (p == &amfs_error_ops) { plog(XLOG_MAP, "Map entry %s for %s did not match", ivec, new_mp->am_path); free_mntfs(new_mf); free_opts(fs_opts); XFREE(fs_opts); return NULL; } dlog("Got a hit with %s", p->fs_type); new_al = new_loc(); free_mntfs(new_al->al_mnt); new_al->al_mnt = new_mf; new_al->al_fo = fs_opts; /* now the loc is in charge of free'ing this mem */ #ifdef HAVE_FS_AUTOFS if (new_mp->am_flags & AMF_AUTOFS && on_autofs) { new_mf->mf_flags |= MFF_ON_AUTOFS; new_mf->mf_fsflags = new_mf->mf_ops->autofs_fs_flags; } /* * A new filesystem is an autofs filesystems if: * 1. it claims it can be one (has the FS_AUTOFS flag) * 2. autofs is enabled system-wide * 3. either has an autofs parent, * or it is explicitly requested to be autofs. */ if (new_mf->mf_ops->autofs_fs_flags & FS_AUTOFS && amd_use_autofs && ((mf->mf_flags & MFF_IS_AUTOFS) || (new_mf->mf_fo && new_mf->mf_fo->opt_mount_type && STREQ(new_mf->mf_fo->opt_mount_type, "autofs")))) new_mf->mf_flags |= MFF_IS_AUTOFS; #endif /* HAVE_FS_AUTOFS */ return new_al; } static am_loc ** amfs_lookup_loc(am_node *new_mp, int *error_return) { am_node *mp; char *info; /* Mount info - where to get the file system */ char **ivecs, **cur_ivec; /* Split version of info */ int num_ivecs; char *orig_def_opts; /* Original Automount options */ char *def_opts; /* Automount options */ int error = 0; /* Error so far */ char path_name[MAXPATHLEN]; /* General path name buffer */ char *pfname; /* Path for database lookup */ mntfs* mf; /* The mntfs for the map of our parent */ am_loc **al_array; /* the generated list of locations */ int count; dlog("in amfs_lookup_loc"); mp = new_mp->am_parent; /* * If we get here then this is a reference to an, * as yet, unknown name so we need to search the mount * map for it. */ if (mp->am_pref) { if (strlen(mp->am_pref) + strlen(new_mp->am_name) >= sizeof(path_name)) ereturn(ENAMETOOLONG); xsnprintf(path_name, sizeof(path_name), "%s%s", mp->am_pref, new_mp->am_name); pfname = path_name; } else { pfname = new_mp->am_name; } mf = mp->am_al->al_mnt; dlog("will search map info in %s to find %s", mf->mf_info, pfname); /* * Consult the oracle for some mount information. * info is malloc'ed and belongs to this routine. * It ends up being free'd in free_continuation(). * * Note that this may return -1 indicating that information * is not yet available. */ error = mapc_search((mnt_map *) mf->mf_private, pfname, &info); if (error) { if (error > 0) plog(XLOG_MAP, "No map entry for %s", pfname); else plog(XLOG_MAP, "Waiting on map entry for %s", pfname); ereturn(error); } dlog("mount info is %s", info); /* * Split info into an argument vector. * The vector is malloc'ed and belongs to * this routine. It is free'd further down. * * Note: the vector pointers point into info, so don't free it! */ ivecs = strsplit(info, ' ', '\"'); if (mf->mf_auto) def_opts = mf->mf_auto; else def_opts = ""; orig_def_opts = amfs_parse_defaults(mp, mf, strdup(def_opts)); def_opts = strdup(orig_def_opts); /* first build our defaults */ num_ivecs = 0; for (cur_ivec = ivecs; *cur_ivec; cur_ivec++) { if (**cur_ivec == '-') { /* * Pick up new defaults */ char *new_def_opts = str3cat(NULL, def_opts, ";", *cur_ivec + 1); XFREE(def_opts); def_opts = new_def_opts; dlog("Setting def_opts to \"%s\"", def_opts); continue; } else num_ivecs++; } al_array = calloc(num_ivecs + 1, sizeof(am_loc *)); /* construct the array of struct locations for this key */ for (count = 0, cur_ivec = ivecs; *cur_ivec; cur_ivec++) { am_loc *new_al; if (**cur_ivec == '-') { XFREE(def_opts); if ((*cur_ivec)[1] == '\0') { /* * If we have a single dash '-' than we need to reset the * default options. */ def_opts = strdup(orig_def_opts); dlog("Resetting the default options, a single dash '-' was found."); } else { /* append options to /default options */ def_opts = str3cat((char *) NULL, orig_def_opts, ";", *cur_ivec + 1); dlog("Resetting def_opts to \"%s\"", def_opts); } continue; } /* * If a loc has already been found, and we find * a cut then don't try any more locations. * * XXX: we do not know when the "/" was added as an equivalent for "||". * It's undocumented, it might go away at any time. Caveat emptor. */ if (STREQ(*cur_ivec, "/") || STREQ(*cur_ivec, "||")) { if (count > 0) { dlog("Cut: not trying any more locations for %s", pfname); break; } continue; } new_al = amfs_lookup_one_location(new_mp, mf, *cur_ivec, def_opts, pfname); if (new_al == NULL) continue; al_array[count++] = new_al; } /* We're done with ivecs */ XFREE(ivecs); XFREE(info); XFREE(orig_def_opts); XFREE(def_opts); if (count == 0) { /* no match */ XFREE(al_array); ereturn(ENOENT); } return al_array; } /* * The continuation function. This is called by * the task notifier when a background mount attempt * completes. */ static void amfs_cont(int rc, int term, opaque_t arg) { struct continuation *cp = (struct continuation *) arg; am_node *mp = cp->mp; mntfs *mf = mp->am_al->al_mnt; dlog("amfs_cont: '%s'", mp->am_path); /* * Definitely not trying to mount at the moment */ mf->mf_flags &= ~MFF_MOUNTING; /* * While we are mounting - try to avoid race conditions */ new_ttl(mp); /* * Wakeup anything waiting for this mount */ wakeup(get_mntfs_wchan(mf)); /* * Check for termination signal or exit status... */ if (rc || term) { #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS && !(mf->mf_flags & MFF_MOUNTED)) autofs_release_fh(mp); #endif /* HAVE_FS_AUTOFS */ if (term) { /* * Not sure what to do for an error code. */ mf->mf_error = EIO; /* XXX ? */ mf->mf_flags |= MFF_ERROR; plog(XLOG_ERROR, "mount for %s got signal %d", mp->am_path, term); } else { /* * Check for exit status... */ #ifdef __linux__ /* * HACK ALERT! * * On Linux (and maybe not only) it's possible to run * an amd which "knows" how to mount certain combinations * of nfs_proto/nfs_version which the kernel doesn't grok. * So if we got an EINVAL and we have a server that's not * using NFSv2/UDP, try again with NFSv2/UDP. * * Too bad that there is no way to dynamically determine * what combinations the _client_ supports, as opposed to * what the _server_ supports... */ if (rc == EINVAL && mf->mf_server && (mf->mf_server->fs_version != 2 || !STREQ(mf->mf_server->fs_proto, "udp"))) mf->mf_flags |= MFF_NFS_SCALEDOWN; else #endif /* __linux__ */ { mf->mf_error = rc; mf->mf_flags |= MFF_ERROR; errno = rc; /* XXX */ if (!STREQ(mp->am_al->al_mnt->mf_ops->fs_type, "linkx")) plog(XLOG_ERROR, "%s: mount (amfs_cont): %m", mp->am_path); } } if (!(mf->mf_flags & MFF_NFS_SCALEDOWN)) { /* * If we get here then that attempt didn't work, so * move the info vector pointer along by one and * call the background mount routine again */ amd_stats.d_merr++; cp->al++; } amfs_bgmount(cp); if (mp->am_error > 0) assign_error_mntfs(mp); } else { /* * The mount worked. */ dlog("Mounting %s returned success", cp->mp->am_path); am_mounted(cp->mp); free_continuation(cp); } reschedule_timeout_mp(); } /* * Retry a mount */ static void amfs_retry(int rc, int term, opaque_t arg) { struct continuation *cp = (struct continuation *) arg; am_node *mp = cp->mp; int error = 0; dlog("Commencing retry for mount of %s", mp->am_path); new_ttl(mp); if ((cp->start + ALLOWED_MOUNT_TIME) < clocktime(NULL)) { /* * The entire mount has timed out. Set the error code and skip past all * the mntfs's so that amfs_bgmount will not have any more * ways to try the mount, thus causing an error. */ plog(XLOG_INFO, "mount of \"%s\" has timed out", mp->am_path); error = ETIMEDOUT; while (*cp->al) cp->al++; /* explicitly forbid further retries after timeout */ cp->retry = FALSE; } if (error || !IN_PROGRESS(cp)) error = amfs_bgmount(cp); else /* Normally it's amfs_bgmount() which frees the continuation. However, if * the mount is already in progress and we're in amfs_retry() for another * node we don't try mounting the filesystem once again. Still, we have * to free the continuation as we won't get called again and thus would * leak the continuation structure and our am_loc references. */ free_continuation(cp); reschedule_timeout_mp(); } /* * Discard an old continuation */ static void free_continuation(struct continuation *cp) { am_loc **alp; dlog("free_continuation"); if (cp->callout) untimeout(cp->callout); /* * we must free the mntfs's in the list. * so free all of them if there was an error, */ for (alp = cp->mp->am_alarray; *alp; alp++) { free_loc(*alp); } XFREE(cp->mp->am_alarray); cp->mp->am_alarray = 0; XFREE(cp); } /* * Pick a file system to try mounting and * do that in the background if necessary * For each location: discard previous mount location if required fetch next mount location if the filesystem failed to be mounted then this_error = error from filesystem goto failed if the filesystem is mounting or unmounting then goto retry; if the fileserver is down then this_error = EIO continue; if the filesystem is already mounted break fi this_error = initialize mount point if no error on this mount and mount is delayed then this_error = -1 fi if this_error < 0 then retry = true fi if no error on this mount then if mount in background then run mount in background return -1 else this_error = mount in foreground fi fi if an error occurred on this mount then update stats save error in mount point fi endfor */ static int amfs_bgmount(struct continuation *cp) { am_node *mp = cp->mp; am_loc *loc; mntfs *mf; int this_error = -1; /* Per-mount error */ int hard_error = -1; /* Cumulative per-node error */ if (mp->am_al) free_loc(mp->am_al); /* * Try to mount each location. * At the end: * hard_error == 0 indicates something was mounted. * hard_error > 0 indicates everything failed with a hard error * hard_error < 0 indicates nothing could be mounted now */ for (mp->am_al = *cp->al; *cp->al; cp->al++, mp->am_al = *cp->al) { am_ops *p; loc = dup_loc(mp->am_al); mf = loc->al_mnt; p = mf->mf_ops; if (hard_error < 0) hard_error = this_error; this_error = 0; if (mf->mf_error > 0) { this_error = mf->mf_error; goto failed; } if (mf->mf_flags & (MFF_MOUNTING | MFF_UNMOUNTING)) { /* * Still mounting - retry later */ dlog("mount of \"%s\" already pending", mf->mf_info); goto retry; } if (FSRV_ISDOWN(mf->mf_server)) { /* * Would just mount from the same place * as a hung mount - so give up */ dlog("%s is already hung - giving up", mf->mf_server->fs_host); this_error = EIO; goto failed; } if (mp->am_link) { XFREE(mp->am_link); mp->am_link = NULL; } if (loc->al_fo && loc->al_fo->opt_sublink && loc->al_fo->opt_sublink[0]) mp->am_link = strdup(loc->al_fo->opt_sublink); /* * Will usually need to play around with the mount nodes * file attribute structure. This must be done here. * Try and get things initialized, even if the fileserver * is not known to be up. In the common case this will * progress things faster. */ /* * Fill in attribute fields. */ if (mf->mf_fsflags & FS_DIRECTORY) mk_fattr(&mp->am_fattr, NFDIR); else mk_fattr(&mp->am_fattr, NFLNK); if (mf->mf_flags & MFF_MOUNTED) { dlog("duplicate mount of \"%s\" ...", mf->mf_info); /* * Skip initial processing of the mountpoint if already mounted. * This could happen if we have multiple sublinks into the same f/s, * or if we are restarting an already-mounted filesystem. */ goto already_mounted; } if (mf->mf_fo && mf->mf_fo->fs_mtab) { plog(XLOG_MAP, "Trying mount of %s on %s fstype %s mount_type %s", mf->mf_fo->fs_mtab, mf->mf_mount, p->fs_type, mp->am_flags & AMF_AUTOFS ? "autofs" : "non-autofs"); } if (p->fs_init && !(mf->mf_flags & MFF_RESTART)) this_error = p->fs_init(mf); if (this_error > 0) goto failed; if (this_error < 0) goto retry; if (loc->al_fo && loc->al_fo->opt_delay) { /* * If there is a delay timer on the location * then don't try to mount if the timer * has not expired. */ int i = atoi(loc->al_fo->opt_delay); time_t now = clocktime(NULL); if (i > 0 && now < (cp->start + i)) { dlog("Mount of %s delayed by %lds", mf->mf_mount, (long) (i - now + cp->start)); goto retry; } } /* * If the directory is not yet made and it needs to be made, then make it! */ if (!(mf->mf_flags & MFF_MKMNT) && mf->mf_fsflags & FS_MKMNT) { plog(XLOG_INFO, "creating mountpoint directory '%s'", mf->mf_mount); this_error = mkdirs(mf->mf_mount, 0555); if (this_error) { plog(XLOG_ERROR, "mkdirs failed: %s", strerror(this_error)); goto failed; } mf->mf_flags |= MFF_MKMNT; } #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS) if ((this_error = autofs_get_fh(mp))) goto failed; #endif /* HAVE_FS_AUTOFS */ already_mounted: mf->mf_flags |= MFF_MOUNTING; if (mf->mf_fsflags & FS_MBACKGROUND) { dlog("backgrounding mount of \"%s\"", mf->mf_mount); if (cp->callout) { untimeout(cp->callout); cp->callout = 0; } /* actually run the task, backgrounding as necessary */ run_task(mount_node, (opaque_t) mp, amfs_cont, (opaque_t) cp); return -1; } else { dlog("foreground mount of \"%s\" ...", mf->mf_mount); this_error = mount_node((opaque_t) mp); } mf->mf_flags &= ~MFF_MOUNTING; if (this_error > 0) goto failed; if (this_error == 0) { am_mounted(mp); break; /* Success */ } retry: if (!cp->retry) continue; dlog("will retry ...\n"); /* * Arrange that amfs_bgmount is called * after anything else happens. */ dlog("Arranging to retry mount of %s", mp->am_path); sched_task(amfs_retry, (opaque_t) cp, get_mntfs_wchan(mf)); if (cp->callout) untimeout(cp->callout); cp->callout = timeout(RETRY_INTERVAL, wakeup, (opaque_t) get_mntfs_wchan(mf)); mp->am_ttl = clocktime(NULL) + RETRY_INTERVAL; /* * Not done yet - so don't return anything */ return -1; failed: if (!FSRV_ISDOWN(mf->mf_server)) { /* mark the mount as failed unless the server is down */ amd_stats.d_merr++; mf->mf_error = this_error; mf->mf_flags |= MFF_ERROR; #ifdef HAVE_FS_AUTOFS if (mp->am_autofs_fh) autofs_release_fh(mp); #endif /* HAVE_FS_AUTOFS */ if (mf->mf_flags & MFF_MKMNT) { rmdirs(mf->mf_mount); mf->mf_flags &= ~MFF_MKMNT; } } /* * Wakeup anything waiting for this mount */ wakeup(get_mntfs_wchan(mf)); free_loc(loc); /* continue */ } /* * If we get here, then either the mount succeeded or * there is no more mount information available. */ if (this_error) { if (mp->am_al) free_loc(mp->am_al); mp->am_al = loc = new_loc(); mf = loc->al_mnt; #ifdef HAVE_FS_AUTOFS if (mp->am_flags & AMF_AUTOFS) autofs_mount_failed(mp); else #endif /* HAVE_FS_AUTOFS */ nfs_quick_reply(mp, this_error); if (hard_error <= 0) hard_error = this_error; if (hard_error < 0) hard_error = ETIMEDOUT; /* * Set a small(ish) timeout on an error node if * the error was not a time out. */ switch (hard_error) { case ETIMEDOUT: case EWOULDBLOCK: case EIO: mp->am_timeo = 17; break; default: mp->am_timeo = 5; break; } new_ttl(mp); } else { mf = loc->al_mnt; /* * Wakeup anything waiting for this mount */ wakeup(get_mntfs_wchan(mf)); hard_error = 0; } /* * Make sure that the error value in the mntfs has a * reasonable value. */ if (mf->mf_error < 0) { mf->mf_error = hard_error; if (hard_error) mf->mf_flags |= MFF_ERROR; } /* * In any case we don't need the continuation any more */ free_continuation(cp); return hard_error; } static char * amfs_parse_defaults(am_node *mp, mntfs *mf, char *def_opts) { char *dflts; char *dfl; char **rvec = NULL; struct mnt_map *mm = (mnt_map *) mf->mf_private; dlog("determining /defaults entry value"); /* * Find out if amd.conf overrode any map-specific /defaults. */ if (mm->cfm && mm->cfm->cfm_defaults) { dlog("map %s map_defaults override: %s", mf->mf_mount, mm->cfm->cfm_defaults); dflts = strdup(mm->cfm->cfm_defaults); } else if (mapc_search(mm, "/defaults", &dflts) == 0) { dlog("/defaults gave %s", dflts); } else { return def_opts; /* if nothing found */ } /* trim leading '-' in case thee's one */ if (*dflts == '-') dfl = dflts + 1; else dfl = dflts; /* * Chop the defaults up */ rvec = strsplit(dfl, ' ', '\"'); if (gopt.flags & CFM_SELECTORS_IN_DEFAULTS) { /* * Pick whichever first entry matched the list of selectors. * Strip the selectors from the string, and assign to dfl the * rest of the string. */ if (rvec) { am_opts ap; am_ops *pt; char **sp = rvec; while (*sp) { /* loop until you find something, if any */ memset((char *) &ap, 0, sizeof(am_opts)); /* * This next routine cause many spurious "expansion of ... is" * messages, which are ignored, b/c all we need out of this * routine is to match selectors. These spurious messages may * be wrong, esp. if they try to expand ${key} b/c it will * get expanded to "/defaults" */ pt = ops_match(&ap, *sp, "", mp->am_path, "/defaults", mp->am_parent->am_al->al_mnt->mf_info); free_opts(&ap); /* don't leak */ if (pt == &amfs_error_ops) { plog(XLOG_MAP, "did not match defaults for \"%s\"", *sp); } else { dfl = strip_selectors(*sp, "/defaults"); plog(XLOG_MAP, "matched default selectors \"%s\"", dfl); break; } ++sp; } } } else { /* not selectors_in_defaults */ /* * Extract first value */ dfl = rvec[0]; } /* * If there were any values at all... */ if (dfl) { /* * Log error if there were other values */ if (!(gopt.flags & CFM_SELECTORS_IN_DEFAULTS) && rvec[1]) { dlog("/defaults chopped into %s", dfl); plog(XLOG_USER, "More than a single value for /defaults in %s", mf->mf_info); } /* * Prepend to existing defaults if they exist, * otherwise just use these defaults. */ if (*def_opts && *dfl) { size_t l = strlen(def_opts) + strlen(dfl) + 2; char *nopts = (char *) xmalloc(l); xsnprintf(nopts, l, "%s;%s", dfl, def_opts); XFREE(def_opts); def_opts = nopts; } else if (*dfl) { def_opts = strealloc(def_opts, dfl); } } XFREE(dflts); /* don't need info vector any more */ if (rvec) XFREE(rvec); return def_opts; } am_node * amfs_generic_mount_child(am_node *new_mp, int *error_return) { int error; struct continuation *cp; /* Continuation structure if need to mount */ dlog("in amfs_generic_mount_child"); *error_return = error = 0; /* Error so far */ /* we have an errorfs attached to the am_node, free it */ if (new_mp->am_al) free_loc(new_mp->am_al); new_mp->am_al = NULL; /* * Construct a continuation */ cp = ALLOC(struct continuation); cp->callout = 0; cp->mp = new_mp; cp->retry = TRUE; cp->start = clocktime(NULL); cp->al = new_mp->am_alarray; /* * Try and mount the file system. If this succeeds immediately (possible * for a ufs file system) then return the attributes, otherwise just * return an error. */ error = amfs_bgmount(cp); reschedule_timeout_mp(); if (!error) return new_mp; /* * Code for quick reply. If current_transp is set, then it's the * transp that's been passed down from nfs_program_2() or from * autofs_program_[123](). * If new_mp->am_transp is not already set, set it by copying in * current_transp. Once am_transp is set, nfs_quick_reply() and * autofs_mount_succeeded() can use it to send a reply to the * client that requested this mount. */ if (current_transp && !new_mp->am_transp) { dlog("Saving RPC transport for %s", new_mp->am_path); new_mp->am_transp = (SVCXPRT *) xmalloc(sizeof(SVCXPRT)); *(new_mp->am_transp) = *current_transp; } if (error && new_mp->am_al && new_mp->am_al->al_mnt && (new_mp->am_al->al_mnt->mf_ops == &amfs_error_ops)) new_mp->am_error = error; if (new_mp->am_error > 0) assign_error_mntfs(new_mp); ereturn(error); } /* * Automount interface to RPC lookup routine * Find the corresponding entry and return * the file handle for it. */ am_node * amfs_generic_lookup_child(am_node *mp, char *fname, int *error_return, int op) { am_node *new_mp; am_loc **al_array; int mp_error; dlog("in amfs_generic_lookup_child"); *error_return = 0; new_mp = amfs_lookup_node(mp, fname, error_return); /* return if we got an error */ if (!new_mp || *error_return > 0) return new_mp; /* also return if it's already mounted and known to be up */ if (*error_return == 0 && FSRV_ISUP(new_mp->am_al->al_mnt->mf_server)) return new_mp; switch (op) { case VLOOK_DELETE: /* * If doing a delete then don't create again! */ ereturn(ENOENT); case VLOOK_LOOKUP: return new_mp; } /* save error_return */ mp_error = *error_return; al_array = amfs_lookup_loc(new_mp, error_return); if (!al_array) { new_mp->am_error = new_mp->am_al->al_mnt->mf_error = *error_return; free_map(new_mp); return NULL; } /* store the array inside the am_node */ new_mp->am_alarray = al_array; /* * Note: while it might seem like a good idea to prioritize * the list of mntfs's we got here, it probably isn't. * It would ignore the ordering of entries specified by the user, * which is counterintuitive and confusing. */ return new_mp; } void amfs_generic_mounted(mntfs *mf) { amfs_mkcacheref(mf); } /* * Unmount an automount sub-node */ int amfs_generic_umount(am_node *mp, mntfs *mf) { int error = 0; #ifdef HAVE_FS_AUTOFS int unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; if (mf->mf_flags & MFF_IS_AUTOFS) error = UMOUNT_FS(mp->am_path, mnttab_file_name, unmount_flags); #endif /* HAVE_FS_AUTOFS */ return error; } char * amfs_generic_match(am_opts *fo) { char *p; if (!fo->opt_rfs) { plog(XLOG_USER, "amfs_generic_match: no mount point named (rfs:=)"); return 0; } if (!fo->opt_fs) { plog(XLOG_USER, "amfs_generic_match: no map named (fs:=)"); return 0; } /* * Swap round fs:= and rfs:= options * ... historical (jsp) */ p = fo->opt_rfs; fo->opt_rfs = fo->opt_fs; fo->opt_fs = p; /* * mtab entry turns out to be the name of the mount map */ return strdup(fo->opt_rfs ? fo->opt_rfs : "."); } am-utils-6.2+rc20110530/amd/amfs_host.c000066400000000000000000000445651157065440000172400ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amfs_host.c * */ /* * NFS host file system. * Mounts all exported filesystems from a given host. * This has now degenerated into a mess but will not * be rewritten. Amd 6 will support the abstractions * needed to make this work correctly. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include static char *amfs_host_match(am_opts *fo); static int amfs_host_init(mntfs *mf); static int amfs_host_mount(am_node *am, mntfs *mf); static int amfs_host_umount(am_node *am, mntfs *mf); static void amfs_host_umounted(mntfs *mf); /* * Ops structure */ am_ops amfs_host_ops = { "host", amfs_host_match, amfs_host_init, amfs_host_mount, amfs_host_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* amfs_host_readlink */ 0, /* amfs_host_mounted */ amfs_host_umounted, find_nfs_srvr, 0, /* amfs_host_get_wchan */ FS_MKMNT | FS_BACKGROUND | FS_AMQINFO, #ifdef HAVE_FS_AUTOFS AUTOFS_HOST_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * Determine the mount point: * * The next change we put in to better handle PCs. This is a bit * disgusting, so you'd better sit down. We change the make_mntpt function * to look for exported file systems without a leading '/'. If they don't * have a leading '/', we add one. If the export is 'a:' through 'z:' * (without a leading slash), we change it to 'a%' (or b% or z%). This * allows the entire PC disk to be mounted. */ static void make_mntpt(char *mntpt, size_t l, const exports ex, const char *mf_mount) { if (ex->ex_dir[0] == '/') { if (ex->ex_dir[1] == 0) xstrlcpy(mntpt, mf_mount, l); else xsnprintf(mntpt, l, "%s%s", mf_mount, ex->ex_dir); } else if (ex->ex_dir[0] >= 'a' && ex->ex_dir[0] <= 'z' && ex->ex_dir[1] == ':' && ex->ex_dir[2] == '/' && ex->ex_dir[3] == 0) xsnprintf(mntpt, l, "%s/%c%%", mf_mount, ex->ex_dir[0]); else xsnprintf(mntpt, l, "%s/%s", mf_mount, ex->ex_dir); } /* * Execute needs the same as NFS plus a helper command */ static char * amfs_host_match(am_opts *fo) { extern am_ops nfs_ops; /* * Make sure rfs is specified to keep nfs_match happy... */ if (!fo->opt_rfs) fo->opt_rfs = "/"; return (*nfs_ops.fs_match) (fo); } static int amfs_host_init(mntfs *mf) { u_short mountd_port; if (strchr(mf->mf_info, ':') == 0) return ENOENT; /* * This is primarily to schedule a wakeup so that as soon * as our fileserver is ready, we can continue setting up * the host filesystem. If we don't do this, the standard * amfs_auto code will set up a fileserver structure, but it will * have to wait for another nfs request from the client to come * in before finishing. Our way is faster since we don't have * to wait for the client to resend its request (which could * take a second or two). */ /* * First, we find the fileserver for this mntfs and then call * get_mountd_port with our mntfs passed as the wait channel. * get_mountd_port will check some things and then schedule * it so that when the fileserver is ready, a wakeup is done * on this mntfs. amfs_cont() is already sleeping on this mntfs * so as soon as that wakeup happens amfs_cont() is called and * this mount is retried. */ if (mf->mf_server) /* * We don't really care if there's an error returned. * Since this is just to help speed things along, the * error will get handled properly elsewhere. */ get_mountd_port(mf->mf_server, &mountd_port, get_mntfs_wchan(mf)); return 0; } static int do_mount(am_nfs_handle_t *fhp, char *mntdir, char *fs_name, mntfs *mf) { struct stat stb; dlog("amfs_host: mounting fs %s on %s\n", fs_name, mntdir); (void) mkdirs(mntdir, 0555); if (stat(mntdir, &stb) < 0 || (stb.st_mode & S_IFMT) != S_IFDIR) { plog(XLOG_ERROR, "No mount point for %s - skipping", mntdir); return ENOENT; } return mount_nfs_fh(fhp, mntdir, fs_name, mf); } static int sortfun(const voidp x, const voidp y) { exports *a = (exports *) x; exports *b = (exports *) y; return strcmp((*a)->ex_dir, (*b)->ex_dir); } /* * Get filehandle */ static int fetch_fhandle(CLIENT *client, char *dir, am_nfs_handle_t *fhp, u_long nfs_version) { struct timeval tv; enum clnt_stat clnt_stat; struct fhstatus res; #ifdef HAVE_FS_NFS3 struct am_mountres3 res3; #endif /* HAVE_FS_NFS3 */ /* * Pick a number, any number... */ tv.tv_sec = 20; tv.tv_usec = 0; dlog("Fetching fhandle for %s", dir); /* * Call the mount daemon on the remote host to * get the filehandle. Use NFS version specific call. */ plog(XLOG_INFO, "fetch_fhandle: NFS version %d", (int) nfs_version); #ifdef HAVE_FS_NFS3 if (nfs_version == NFS_VERSION3) { memset((char *) &res3, 0, sizeof(res3)); clnt_stat = clnt_call(client, MOUNTPROC_MNT, (XDRPROC_T_TYPE) xdr_dirpath, (SVC_IN_ARG_TYPE) &dir, (XDRPROC_T_TYPE) xdr_am_mountres3, (SVC_IN_ARG_TYPE) &res3, tv); if (clnt_stat != RPC_SUCCESS) { plog(XLOG_ERROR, "mountd rpc failed: %s", clnt_sperrno(clnt_stat)); return EIO; } /* Check the status of the filehandle */ if ((errno = res3.fhs_status)) { dlog("fhandle fetch for mount version 3 failed: %m"); return errno; } memset((voidp) &fhp->v3, 0, sizeof(am_nfs_fh3)); fhp->v3.am_fh3_length = res3.mountres3_u.mountinfo.fhandle.fhandle3_len; memmove(fhp->v3.am_fh3_data, res3.mountres3_u.mountinfo.fhandle.fhandle3_val, fhp->v3.am_fh3_length); } else { /* not NFS_VERSION3 mount */ #endif /* HAVE_FS_NFS3 */ clnt_stat = clnt_call(client, MOUNTPROC_MNT, (XDRPROC_T_TYPE) xdr_dirpath, (SVC_IN_ARG_TYPE) &dir, (XDRPROC_T_TYPE) xdr_fhstatus, (SVC_IN_ARG_TYPE) &res, tv); if (clnt_stat != RPC_SUCCESS) { plog(XLOG_ERROR, "mountd rpc failed: %s", clnt_sperrno(clnt_stat)); return EIO; } /* Check status of filehandle */ if (res.fhs_status) { errno = res.fhs_status; dlog("fhandle fetch for mount version 1 failed: %m"); return errno; } memmove(&fhp->v2, &res.fhs_fh, NFS_FHSIZE); #ifdef HAVE_FS_NFS3 } /* end of "if (nfs_version == NFS_VERSION3)" statement */ #endif /* HAVE_FS_NFS3 */ /* all is well */ return 0; } /* * Scan mount table to see if something already mounted */ static int already_mounted(mntlist *mlist, char *dir) { mntlist *ml; for (ml = mlist; ml; ml = ml->mnext) if (STREQ(ml->mnt->mnt_dir, dir)) return 1; return 0; } static int amfs_host_mount(am_node *am, mntfs *mf) { struct timeval tv2; CLIENT *client; enum clnt_stat clnt_stat; int n_export; int j, k; exports exlist = 0, ex; exports *ep = NULL; am_nfs_handle_t *fp = NULL; char *host; int error = 0; struct sockaddr_in sin; int sock = RPC_ANYSOCK; int ok = FALSE; mntlist *mlist; char fs_name[MAXPATHLEN], *rfs_dir; char mntpt[MAXPATHLEN]; struct timeval tv; u_long mnt_version; /* * WebNFS servers don't necessarily run mountd. */ if (mf->mf_flags & MFF_WEBNFS) { plog(XLOG_ERROR, "amfs_host_mount: cannot support WebNFS"); return EIO; } /* * Read the mount list */ mlist = read_mtab(mf->mf_mount, mnttab_file_name); #ifdef MOUNT_TABLE_ON_FILE /* * Unlock the mount list */ unlock_mntlist(); #endif /* MOUNT_TABLE_ON_FILE */ /* * Take a copy of the server hostname, address, and nfs version * to mount version conversion. */ host = mf->mf_server->fs_host; sin = *mf->mf_server->fs_ip; plog(XLOG_INFO, "amfs_host_mount: NFS version %d", (int) mf->mf_server->fs_version); #ifdef HAVE_FS_NFS3 if (mf->mf_server->fs_version == NFS_VERSION3) mnt_version = AM_MOUNTVERS3; else #endif /* HAVE_FS_NFS3 */ mnt_version = MOUNTVERS; /* * The original 10 second per try timeout is WAY too large, especially * if we're only waiting 10 or 20 seconds max for the response. * That would mean we'd try only once in 10 seconds, and we could * lose the transmit or receive packet, and never try again. * A 2-second per try timeout here is much more reasonable. * 09/28/92 Mike Mitchell, mcm@unx.sas.com */ tv.tv_sec = 2; tv.tv_usec = 0; /* * Create a client attached to mountd */ client = get_mount_client(host, &sin, &tv, &sock, mnt_version); if (client == NULL) { #ifdef HAVE_CLNT_SPCREATEERROR plog(XLOG_ERROR, "get_mount_client failed for %s: %s", host, clnt_spcreateerror("")); #else /* not HAVE_CLNT_SPCREATEERROR */ plog(XLOG_ERROR, "get_mount_client failed for %s", host); #endif /* not HAVE_CLNT_SPCREATEERROR */ error = EIO; goto out; } if (!nfs_auth) { error = make_nfs_auth(); if (error) goto out; } client->cl_auth = nfs_auth; dlog("Fetching export list from %s", host); /* * Fetch the export list */ tv2.tv_sec = 10; tv2.tv_usec = 0; clnt_stat = clnt_call(client, MOUNTPROC_EXPORT, (XDRPROC_T_TYPE) xdr_void, 0, (XDRPROC_T_TYPE) xdr_exports, (SVC_IN_ARG_TYPE) & exlist, tv2); if (clnt_stat != RPC_SUCCESS) { const char *msg = clnt_sperrno(clnt_stat); plog(XLOG_ERROR, "host_mount rpc failed: %s", msg); /* clnt_perror(client, "rpc"); */ error = EIO; goto out; } /* * Figure out how many exports were returned */ for (n_export = 0, ex = exlist; ex; ex = ex->ex_next) { n_export++; } /* * Allocate an array of pointers into the list * so that they can be sorted. If the filesystem * is already mounted then ignore it. */ ep = (exports *) xmalloc(n_export * sizeof(exports)); for (j = 0, ex = exlist; ex; ex = ex->ex_next) { make_mntpt(mntpt, sizeof(mntpt), ex, mf->mf_mount); if (already_mounted(mlist, mntpt)) /* we have at least one mounted f/s, so don't fail the mount */ ok = TRUE; else ep[j++] = ex; } n_export = j; /* * Sort into order. * This way the mounts are done in order down the tree, * instead of any random order returned by the mount * daemon (the protocol doesn't specify...). */ qsort(ep, n_export, sizeof(exports), sortfun); /* * Allocate an array of filehandles */ fp = (am_nfs_handle_t *) xmalloc(n_export * sizeof(am_nfs_handle_t)); /* * Try to obtain filehandles for each directory. * If a fetch fails then just zero out the array * reference but discard the error. */ for (j = k = 0; j < n_export; j++) { /* Check and avoid a duplicated export entry */ if (j > k && ep[k] && STREQ(ep[j]->ex_dir, ep[k]->ex_dir)) { dlog("avoiding dup fhandle requested for %s", ep[j]->ex_dir); ep[j] = NULL; } else { k = j; error = fetch_fhandle(client, ep[j]->ex_dir, &fp[j], mf->mf_server->fs_version); if (error) ep[j] = NULL; } } /* * Mount each filesystem for which we have a filehandle. * If any of the mounts succeed then mark "ok" and return * error code 0 at the end. If they all fail then return * the last error code. */ xstrlcpy(fs_name, mf->mf_info, sizeof(fs_name)); if ((rfs_dir = strchr(fs_name, ':')) == (char *) NULL) { plog(XLOG_FATAL, "amfs_host_mount: mf_info has no colon"); error = EINVAL; goto out; } ++rfs_dir; for (j = 0; j < n_export; j++) { ex = ep[j]; if (ex) { /* * Note: the sizeof space left in rfs_dir is what's left in fs_name * after strchr() above returned a pointer _inside_ fs_name. The * calculation below also takes into account that rfs_dir was * incremented by the ++ above. */ xstrlcpy(rfs_dir, ex->ex_dir, sizeof(fs_name) - (rfs_dir - fs_name)); make_mntpt(mntpt, sizeof(mntpt), ex, mf->mf_mount); if (do_mount(&fp[j], mntpt, fs_name, mf) == 0) ok = TRUE; } } /* * Clean up and exit */ out: discard_mntlist(mlist); if (ep) XFREE(ep); if (fp) XFREE(fp); if (sock != RPC_ANYSOCK) (void) amu_close(sock); if (client) clnt_destroy(client); if (exlist) xdr_pri_free((XDRPROC_T_TYPE) xdr_exports, (caddr_t) &exlist); if (ok) return 0; return error; } /* * Return true if pref is a directory prefix of dir. * * XXX TODO: * Does not work if pref is "/". */ static int directory_prefix(char *pref, char *dir) { int len = strlen(pref); if (!NSTREQ(pref, dir, len)) return FALSE; if (dir[len] == '/' || dir[len] == '\0') return TRUE; return FALSE; } /* * Unmount a mount tree */ static int amfs_host_umount(am_node *am, mntfs *mf) { mntlist *ml, *mprev; int unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; int xerror = 0; /* * Read the mount list */ mntlist *mlist = read_mtab(mf->mf_mount, mnttab_file_name); #ifdef MOUNT_TABLE_ON_FILE /* * Unlock the mount list */ unlock_mntlist(); #endif /* MOUNT_TABLE_ON_FILE */ /* * Reverse list... */ ml = mlist; mprev = NULL; while (ml) { mntlist *ml2 = ml->mnext; ml->mnext = mprev; mprev = ml; ml = ml2; } mlist = mprev; /* * Unmount all filesystems... */ for (ml = mlist; ml && !xerror; ml = ml->mnext) { char *dir = ml->mnt->mnt_dir; if (directory_prefix(mf->mf_mount, dir)) { int error; dlog("amfs_host: unmounts %s", dir); /* * Unmount "dir" */ error = UMOUNT_FS(dir, mnttab_file_name, unmount_flags); /* * Keep track of errors */ if (error) { /* * If we have not already set xerror and error is not ENOENT, * then set xerror equal to error and log it. * 'xerror' is the return value for this function. * * We do not want to pass ENOENT as an error because if the * directory does not exists our work is done anyway. */ if (!xerror && error != ENOENT) xerror = error; if (error != EBUSY) { errno = error; plog(XLOG_ERROR, "Tree unmount of %s failed: %m", ml->mnt->mnt_dir); } } else { (void) rmdirs(dir); } } } /* * Throw away mount list */ discard_mntlist(mlist); /* * Try to remount, except when we are shutting down. */ if (xerror && amd_state != Finishing) { xerror = amfs_host_mount(am, mf); if (!xerror) { /* * Don't log this - it's usually too verbose plog(XLOG_INFO, "Remounted host %s", mf->mf_info); */ xerror = EBUSY; } } return xerror; } /* * Tell mountd we're done. * This is not quite right, because we may still * have other filesystems mounted, but the existing * mountd protocol is badly broken anyway. */ static void amfs_host_umounted(mntfs *mf) { char *host; CLIENT *client; enum clnt_stat clnt_stat; struct sockaddr_in sin; int sock = RPC_ANYSOCK; struct timeval tv; u_long mnt_version; if (mf->mf_error || mf->mf_refc > 1 || !mf->mf_server) return; /* * WebNFS servers shouldn't ever get here. */ if (mf->mf_flags & MFF_WEBNFS) { plog(XLOG_ERROR, "amfs_host_umounted: cannot support WebNFS"); return; } /* * Take a copy of the server hostname, address, and NFS version * to mount version conversion. */ host = mf->mf_server->fs_host; sin = *mf->mf_server->fs_ip; plog(XLOG_INFO, "amfs_host_umounted: NFS version %d", (int) mf->mf_server->fs_version); #ifdef HAVE_FS_NFS3 if (mf->mf_server->fs_version == NFS_VERSION3) mnt_version = AM_MOUNTVERS3; else #endif /* HAVE_FS_NFS3 */ mnt_version = MOUNTVERS; /* * Create a client attached to mountd */ tv.tv_sec = 10; tv.tv_usec = 0; client = get_mount_client(host, &sin, &tv, &sock, mnt_version); if (client == NULL) { #ifdef HAVE_CLNT_SPCREATEERROR plog(XLOG_ERROR, "get_mount_client failed for %s: %s", host, clnt_spcreateerror("")); #else /* not HAVE_CLNT_SPCREATEERROR */ plog(XLOG_ERROR, "get_mount_client failed for %s", host); #endif /* not HAVE_CLNT_SPCREATEERROR */ goto out; } if (!nfs_auth) { if (make_nfs_auth()) goto out; } client->cl_auth = nfs_auth; dlog("Unmounting all from %s", host); clnt_stat = clnt_call(client, MOUNTPROC_UMNTALL, (XDRPROC_T_TYPE) xdr_void, 0, (XDRPROC_T_TYPE) xdr_void, 0, tv); if (clnt_stat != RPC_SUCCESS && clnt_stat != RPC_SYSTEMERROR) { /* RPC_SYSTEMERROR seems to be returned for no good reason ... */ const char *msg = clnt_sperrno(clnt_stat); plog(XLOG_ERROR, "unmount all from %s rpc failed: %s", host, msg); goto out; } out: if (sock != RPC_ANYSOCK) (void) amu_close(sock); if (client) clnt_destroy(client); } am-utils-6.2+rc20110530/amd/amfs_link.c000066400000000000000000000100171157065440000172010ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amfs_link.c * */ /* * Symbol-link file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward declarations */ static int amfs_link_mount(am_node *mp, mntfs *mf); static int amfs_link_umount(am_node *mp, mntfs *mf); /* * Ops structures */ am_ops amfs_link_ops = { "link", amfs_link_match, 0, /* amfs_link_init */ amfs_link_mount, amfs_link_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* amfs_link_readlink */ 0, /* amfs_link_mounted */ 0, /* amfs_link_umounted */ amfs_generic_find_srvr, 0, /* nfs_fs_flags */ 0, /* amfs_link_get_wchan */ #ifdef HAVE_FS_AUTOFS AUTOFS_LINK_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * SFS needs a link. */ char * amfs_link_match(am_opts *fo) { if (!fo->opt_fs) { plog(XLOG_USER, "link: no fs specified"); return 0; } /* * If the link target points to another mount point, then we could * end up with an unpleasant situation, where the link f/s simply * "assumes" the mntfs of that mount point. * * For example, if the link points to /usr, and /usr is a real ufs * filesystem, then the link f/s will use the inherited ufs mntfs, * and the end result will be that it will become unmountable. * * To prevent this, we use a hack: we prepend a dot ('.') to opt_fs if * its original value was an absolute path, so that it will never match * any other mntfs. * * XXX: a less hacky solution should be used... */ if (fo->opt_fs[0] == '/') { char *link_hack = str3cat(NULL, ".", fo->opt_fs, ""); if (fo->opt_sublink == NULL || fo->opt_sublink[0] == '\0') fo->opt_sublink = strdup(fo->opt_fs); XFREE(fo->opt_fs); fo->opt_fs = link_hack; } return strdup(fo->opt_fs); } static int amfs_link_mount(am_node *mp, mntfs *mf) { return 0; } static int amfs_link_umount(am_node *mp, mntfs *mf) { return 0; } am-utils-6.2+rc20110530/amd/amfs_linkx.c000066400000000000000000000066171157065440000174040ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amfs_linkx.c * */ /* * Symbol-link file system, with test that the target of the link exists. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward declarations */ static int amfs_linkx_mount(am_node *mp, mntfs *mf); static int amfs_linkx_umount(am_node *mp, mntfs *mf); /* * linkx operations */ struct am_ops amfs_linkx_ops = { "linkx", amfs_link_match, 0, /* amfs_linkx_init */ amfs_linkx_mount, amfs_linkx_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* amfs_linkx_readlink */ 0, /* amfs_linkx_mounted */ 0, /* amfs_linkx_umounted */ amfs_generic_find_srvr, 0, /* amfs_linkx_get_wchan */ FS_MBACKGROUND, #ifdef HAVE_FS_AUTOFS AUTOFS_LINKX_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; static int amfs_linkx_mount(am_node *mp, mntfs *mf) { /* * Check for existence of target. */ struct stat stb; char *ln; if (mp->am_link) ln = mp->am_link; else /* should never occur */ ln = mf->mf_mount; /* * Use lstat, not stat, since we don't * want to know if the ultimate target of * a symlink chain exists, just the first. */ if (lstat(ln, &stb) < 0) return errno; return 0; } static int amfs_linkx_umount(am_node *mp, mntfs *mf) { return 0; } am-utils-6.2+rc20110530/amd/amfs_nfsl.c000066400000000000000000000150001157065440000172030ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amfs_nfsl.c * */ /* * NFSL: Network file system with local existence check. If the local * path denoted by $rfs exists, it behaves as type:=link. * * Example: * pkg type:=nfsl;rhost:=jonny;rfs:=/n/johnny/src/pkg;fs:=${rfs} */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward declarations */ static char *amfs_nfsl_match(am_opts *fo); static int amfs_nfsl_init(mntfs *mf); static int amfs_nfsl_mount(am_node *mp, mntfs *mf); static int amfs_nfsl_umount(am_node *mp, mntfs *mf); static void amfs_nfsl_umounted(mntfs *mf); static fserver *amfs_nfsl_ffserver(mntfs *mf); /* * NFS-Link operations */ am_ops amfs_nfsl_ops = { "nfsl", amfs_nfsl_match, amfs_nfsl_init, amfs_nfsl_mount, amfs_nfsl_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* amfs_nfsl_readlink */ 0, /* amfs_nfsl_mounted */ amfs_nfsl_umounted, amfs_nfsl_ffserver, 0, /* amfs_nfsl_get_wchan */ FS_MKMNT | FS_BACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_NFSL_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * Check that f/s has all needed fields. * Returns: matched string if found, NULL otherwise. */ static char * amfs_nfsl_match(am_opts *fo) { char *cp; char *ho = fo->opt_rhost; char *retval; struct stat stb; if (fo->opt_sublink && fo->opt_sublink[0]) cp = fo->opt_sublink; else cp = fo->opt_fs; if (!cp || !ho) { plog(XLOG_USER, "amfs_nfsl: host $fs and $rhost must be specified"); return NULL; } /* * If this host is not the same as $rhost, or if link does not exist, * call nfs_ops.fs_match(). * If link value exists (or same host), call amfs_link_ops.fs_match(). */ if (!STRCEQ(ho, am_get_hostname())) { plog(XLOG_INFO, "amfs_nfsl: \"%s\" is not local host, using type:=nfs", ho); retval = nfs_ops.fs_match(fo); } else if (lstat(cp, &stb) < 0) { plog(XLOG_INFO, "amfs_nfsl: \"%s\" does not exist, using type:=nfs", cp); retval = nfs_ops.fs_match(fo); } else { plog(XLOG_INFO, "amfs_nfsl: \"%s\" exists, using type:=link", cp); retval = amfs_link_ops.fs_match(fo); } return retval; } /* * Initialize. * Returns: 0 if OK, non-zero (errno) if failed. */ static int amfs_nfsl_init(mntfs *mf) { int ret = 0; if (mf->mf_flags & MFF_NFSLINK) { if (amfs_link_ops.fs_init) ret = amfs_link_ops.fs_init(mf); } else { if (nfs_ops.fs_init) ret = nfs_ops.fs_init(mf); } return ret; } /* * Mount vfs. * Returns: 0 if OK, non-zero (errno) if failed. */ static int amfs_nfsl_mount(am_node *mp, mntfs *mf) { int ret = 0; if (mf->mf_flags & MFF_NFSLINK) { if (amfs_link_ops.mount_fs) ret = amfs_link_ops.mount_fs(mp, mf); } else { if (nfs_ops.mount_fs) ret = nfs_ops.mount_fs(mp, mf); } return ret; } /* * Unmount VFS. * Returns: 0 if OK, non-zero (errno) if failed. */ static int amfs_nfsl_umount(am_node *mp, mntfs *mf) { int ret = 0; if (mf->mf_flags & MFF_NFSLINK) { if (amfs_link_ops.umount_fs) ret = amfs_link_ops.umount_fs(mp, mf); } else { if (nfs_ops.umount_fs) ret = nfs_ops.umount_fs(mp, mf); } return ret; } /* * Async unmount callback function. * After the base umount() succeeds, we may want to take extra actions, * such as informing remote mount daemons that we've unmounted them. * See amfs_auto_umounted(), host_umounted(), nfs_umounted(). */ static void amfs_nfsl_umounted(mntfs *mf) { if (mf->mf_flags & MFF_NFSLINK) { if (amfs_link_ops.umounted) amfs_link_ops.umounted(mf); } else { if (nfs_ops.umounted) nfs_ops.umounted(mf); } } /* * Find a file server. * Returns: fserver of found server, or NULL if not found. */ static fserver * amfs_nfsl_ffserver(mntfs *mf) { char *cp; char *ho = mf->mf_fo->opt_rhost; struct stat stb; if (mf->mf_fo->opt_sublink && mf->mf_fo->opt_sublink[0]) cp = mf->mf_fo->opt_sublink; else cp = mf->mf_fo->opt_fs; /* * If this host is not the same as $rhost, or if link does not exist, * call amfs_link_ops.ffserver(). * If link value exists (or same host), then call ops_nfs.ffserver(). */ if (!STRCEQ(ho, am_get_hostname()) || lstat(cp, &stb) < 0) { return nfs_ops.ffserver(mf); } else { mf->mf_flags |= MFF_NFSLINK; /* remove the FS_MKMNT flag, we don't want amd touching the mountpoint */ mf->mf_fsflags &= ~FS_MKMNT; return amfs_link_ops.ffserver(mf); } } am-utils-6.2+rc20110530/amd/amfs_nfsx.c000066400000000000000000000306051157065440000172270ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amfs_nfsx.c * */ /* * NFS hierarchical mounts * * TODO: Re-implement. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * The rfs field contains a list of mounts to be done from * the remote host. */ typedef struct amfs_nfsx_mnt { mntfs *n_mnt; int n_error; } amfs_nfsx_mnt; struct amfs_nfsx { int nx_c; /* Number of elements in nx_v */ amfs_nfsx_mnt *nx_v; /* Underlying mounts */ amfs_nfsx_mnt *nx_try; am_node *nx_mp; }; /* forward definitions */ static char *amfs_nfsx_match(am_opts *fo); static int amfs_nfsx_mount(am_node *am, mntfs *mf); static int amfs_nfsx_umount(am_node *am, mntfs *mf); static int amfs_nfsx_init(mntfs *mf); /* * Ops structure */ am_ops amfs_nfsx_ops = { "nfsx", amfs_nfsx_match, amfs_nfsx_init, amfs_nfsx_mount, amfs_nfsx_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* amfs_nfsx_readlink */ 0, /* amfs_nfsx_mounted */ 0, /* amfs_nfsx_umounted */ find_nfs_srvr, /* XXX */ 0, /* amfs_nfsx_get_wchan */ /* FS_UBACKGROUND| */ FS_AMQINFO, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_NFSX_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; static char * amfs_nfsx_match(am_opts *fo) { char *xmtab; char *ptr; int len; if (!fo->opt_rfs) { plog(XLOG_USER, "amfs_nfsx: no remote filesystem specified"); return FALSE; } if (!fo->opt_rhost) { plog(XLOG_USER, "amfs_nfsx: no remote host specified"); return FALSE; } /* set default sublink */ if (fo->opt_sublink == NULL || fo->opt_sublink[0] == '\0') { ptr = strchr(fo->opt_rfs, ','); if (ptr && ptr > (fo->opt_rfs + 1)) fo->opt_sublink = strnsave(fo->opt_rfs + 1, ptr - fo->opt_rfs - 1); } /* * Remove trailing ",..." from ${fs} * After deslashifying, overwrite the end of ${fs} with "/" * to make sure it is unique. */ if ((ptr = strchr(fo->opt_fs, ','))) *ptr = '\0'; deslashify(fo->opt_fs); /* * Bump string length to allow trailing / */ len = strlen(fo->opt_fs); fo->opt_fs = xrealloc(fo->opt_fs, len + 1 + 1); ptr = fo->opt_fs + len; /* * Make unique... */ *ptr++ = '/'; *ptr = '\0'; /* * Determine magic cookie to put in mtab */ xmtab = str3cat((char *) NULL, fo->opt_rhost, ":", fo->opt_rfs); dlog("NFSX: mounting remote server \"%s\", remote fs \"%s\" on \"%s\"", fo->opt_rhost, fo->opt_rfs, fo->opt_fs); return xmtab; } static void amfs_nfsx_prfree(opaque_t vp) { struct amfs_nfsx *nx = (struct amfs_nfsx *) vp; int i; for (i = 0; i < nx->nx_c; i++) { mntfs *m = nx->nx_v[i].n_mnt; if (m) free_mntfs(m); } XFREE(nx->nx_v); XFREE(nx); } static int amfs_nfsx_init(mntfs *mf) { /* * mf_info has the form: * host:/prefix/path,sub,sub,sub */ int i; int glob_error; struct amfs_nfsx *nx; int asked_for_wakeup = 0; nx = (struct amfs_nfsx *) mf->mf_private; if (nx == 0) { char **ivec; char *info = NULL; char *host; char *pref; int error = 0; info = strdup(mf->mf_info); host = strchr(info, ':'); if (!host) { error = EINVAL; goto errexit; } pref = host + 1; host = info; /* * Split the prefix off from the suffices */ ivec = strsplit(pref, ',', '\''); /* * Count array size */ for (i = 0; ivec[i]; i++) /* nothing */; nx = ALLOC(struct amfs_nfsx); mf->mf_private = (opaque_t) nx; mf->mf_prfree = amfs_nfsx_prfree; nx->nx_c = i - 1; /* i-1 because we don't want the prefix */ nx->nx_v = (amfs_nfsx_mnt *) xmalloc(nx->nx_c * sizeof(amfs_nfsx_mnt)); nx->nx_mp = NULL; { char *mp = NULL; char *xinfo = NULL; char *fs = mf->mf_fo->opt_fs; char *rfs = NULL; for (i = 0; i < nx->nx_c; i++) { char *path = ivec[i + 1]; rfs = str3cat(rfs, pref, "/", path); /* * Determine the mount point. * If this is the root, then don't remove * the trailing slash to avoid mntfs name clashes. */ mp = str3cat(mp, fs, "/", rfs); normalize_slash(mp); deslashify(mp); /* * Determine the mount info */ xinfo = str3cat(xinfo, host, *path == '/' ? "" : "/", path); normalize_slash(xinfo); if (pref[1] != '\0') deslashify(xinfo); dlog("amfs_nfsx: init mount for %s on %s", xinfo, mp); nx->nx_v[i].n_error = -1; nx->nx_v[i].n_mnt = find_mntfs(&nfs_ops, mf->mf_fo, mp, xinfo, "", mf->mf_mopts, mf->mf_remopts); /* propagate the on_autofs flag */ nx->nx_v[i].n_mnt->mf_flags |= mf->mf_flags & MFF_ON_AUTOFS; } if (rfs) XFREE(rfs); if (mp) XFREE(mp); if (xinfo) XFREE(xinfo); } XFREE(ivec); errexit: if (info) XFREE(info); if (error) return error; } /* * Iterate through the mntfs's and call * the underlying init routine on each */ glob_error = 0; for (i = 0; i < nx->nx_c; i++) { amfs_nfsx_mnt *n = &nx->nx_v[i]; mntfs *m = n->n_mnt; int error = 0; if (m->mf_ops->fs_init && !(mf->mf_flags & MFF_RESTART)) error = m->mf_ops->fs_init(m); /* * if you just "return error" here, you will have made a failure * in any submounts to fail the whole group. There was old unused code * here before. */ if (error > 0) n->n_error = error; else if (error < 0) { glob_error = -1; if (!asked_for_wakeup) { asked_for_wakeup = 1; sched_task(wakeup_task, (opaque_t) mf, get_mntfs_wchan(m)); } } } return glob_error; } static void amfs_nfsx_cont(int rc, int term, opaque_t arg) { mntfs *mf = (mntfs *) arg; struct amfs_nfsx *nx = (struct amfs_nfsx *) mf->mf_private; am_node *mp = nx->nx_mp; amfs_nfsx_mnt *n = nx->nx_try; n->n_mnt->mf_flags &= ~(MFF_ERROR | MFF_MOUNTING); mf->mf_flags &= ~MFF_ERROR; /* * Wakeup anything waiting for this mount */ wakeup(get_mntfs_wchan(n->n_mnt)); if (rc || term) { if (term) { /* * Not sure what to do for an error code. */ plog(XLOG_ERROR, "mount for %s got signal %d", n->n_mnt->mf_mount, term); n->n_error = EIO; } else { /* * Check for exit status */ errno = rc; /* XXX */ plog(XLOG_ERROR, "%s: mount (amfs_nfsx_cont): %m", n->n_mnt->mf_mount); n->n_error = rc; } free_mntfs(n->n_mnt); n->n_mnt = new_mntfs(); n->n_mnt->mf_error = n->n_error; n->n_mnt->mf_flags |= MFF_ERROR; } else { /* * The mount worked. */ mf_mounted(n->n_mnt, FALSE); /* FALSE => don't free the n_mnt->am_opts */ n->n_error = 0; } /* * Do the remaining bits */ if (amfs_nfsx_mount(mp, mf) >= 0) wakeup(get_mntfs_wchan(mf)); } static int try_amfs_nfsx_mount(opaque_t mv) { mntfs *mf = (mntfs *) mv; struct amfs_nfsx *nx = (struct amfs_nfsx *) mf->mf_private; am_node *mp = nx->nx_mp; int error; error = mf->mf_ops->mount_fs(mp, mf); return error; } static int amfs_nfsx_remount(am_node *am, mntfs *mf, int fg) { struct amfs_nfsx *nx = (struct amfs_nfsx *) mf->mf_private; amfs_nfsx_mnt *n; int glob_error = -1; /* Save the am_node pointer for later use */ nx->nx_mp = am; /* * Iterate through the mntfs's and mount each filesystem * which is not yet mounted. */ for (n = nx->nx_v; n < nx->nx_v + nx->nx_c; n++) { mntfs *m = n->n_mnt; if (m->mf_flags & MFF_MOUNTING) break; if (m->mf_flags & MFF_MOUNTED) { mf_mounted(m, FALSE); /* FALSE => don't free the m->am_opts */ n->n_error = glob_error = 0; continue; } if (n->n_error < 0) { /* Create the mountpoint, if and as required */ if (!(m->mf_flags & MFF_MKMNT) && m->mf_fsflags & FS_MKMNT) { if (!mkdirs(m->mf_mount, 0555)) m->mf_flags |= MFF_MKMNT; } dlog("calling underlying mount on %s", m->mf_mount); if (!fg && foreground && (m->mf_fsflags & FS_MBACKGROUND)) { m->mf_flags |= MFF_MOUNTING; dlog("backgrounding mount of \"%s\"", m->mf_info); nx->nx_try = n; run_task(try_amfs_nfsx_mount, (opaque_t) m, amfs_nfsx_cont, (opaque_t) mf); n->n_error = -1; return -1; } else { dlog("foreground mount of \"%s\" ...", mf->mf_info); n->n_error = m->mf_ops->mount_fs(am, m); } if (n->n_error > 0) dlog("underlying fmount of %s failed: %s", m->mf_mount, strerror(n->n_error)); if (n->n_error == 0) { glob_error = 0; } else if (glob_error < 0) { glob_error = n->n_error; } } } return glob_error < 0 ? 0 : glob_error; } static int amfs_nfsx_mount(am_node *am, mntfs *mf) { return amfs_nfsx_remount(am, mf, FALSE); } /* * Unmount an NFS hierarchy. * Note that this is called in the foreground * and so may hang under extremely rare conditions. */ static int amfs_nfsx_umount(am_node *am, mntfs *mf) { struct amfs_nfsx *nx = (struct amfs_nfsx *) mf->mf_private; amfs_nfsx_mnt *n; int glob_error = 0; /* * Iterate in reverse through the mntfs's and unmount each filesystem * which is mounted. */ for (n = nx->nx_v + nx->nx_c - 1; n >= nx->nx_v; --n) { mntfs *m = n->n_mnt; /* * If this node has not been messed with * and there has been no error so far * then try and unmount. * If an error had occurred then zero * the error code so that the remount * only tries to unmount those nodes * which had been successfully unmounted. */ if (n->n_error == 0) { dlog("calling underlying fumount on %s", m->mf_mount); n->n_error = m->mf_ops->umount_fs(am, m); if (n->n_error) { glob_error = n->n_error; n->n_error = 0; } else { /* * Make sure remount gets this node */ n->n_error = -1; } } } /* * If any unmounts failed then remount the * whole lot... */ if (glob_error) { glob_error = amfs_nfsx_remount(am, mf, TRUE); if (glob_error) { errno = glob_error; /* XXX */ plog(XLOG_USER, "amfs_nfsx: remount of %s failed: %m", mf->mf_mount); } glob_error = EBUSY; } else { /* * Remove all the mount points */ for (n = nx->nx_v; n < nx->nx_v + nx->nx_c; n++) { mntfs *m = n->n_mnt; dlog("calling underlying umounted on %s", m->mf_mount); if (m->mf_ops->umounted) m->mf_ops->umounted(m); if (n->n_error < 0) { if (m->mf_fsflags & FS_MKMNT) { (void) rmdirs(m->mf_mount); m->mf_flags &= ~MFF_MKMNT; } } free_mntfs(m); n->n_mnt = NULL; n->n_error = -1; } } return glob_error; } am-utils-6.2+rc20110530/amd/amfs_program.c000066400000000000000000000126261157065440000177230ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/amfs_program.c * */ /* * Program file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward definitions */ static char *amfs_program_match(am_opts *fo); static int amfs_program_mount(am_node *am, mntfs *mf); static int amfs_program_umount(am_node *am, mntfs *mf); static int amfs_program_init(mntfs *mf); /* * Ops structure */ am_ops amfs_program_ops = { "program", amfs_program_match, amfs_program_init, amfs_program_mount, amfs_program_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* amfs_program_readlink */ 0, /* amfs_program_mounted */ 0, /* amfs_program_umounted */ amfs_generic_find_srvr, 0, /* amfs_program_get_wchan */ FS_MKMNT | FS_BACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_PROGRAM_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * Execute needs a mount and unmount command. */ static char * amfs_program_match(am_opts *fo) { char *prog; if (fo->opt_unmount && fo->opt_umount) { plog(XLOG_ERROR, "program: cannot specify both unmount and umount options"); return 0; } if (!fo->opt_mount) { plog(XLOG_ERROR, "program: must specify mount command"); return 0; } if (!fo->opt_unmount && !fo->opt_umount) { fo->opt_unmount = str3cat(NULL, UNMOUNT_PROGRAM, " umount ", fo->opt_fs); plog(XLOG_INFO, "program: un/umount not specified; using default \"%s\"", fo->opt_unmount); } prog = strchr(fo->opt_mount, ' '); return strdup(prog ? prog + 1 : fo->opt_mount); } static int amfs_program_init(mntfs *mf) { /* check if already saved value */ if (mf->mf_private != NULL) return 0; /* save unmount (or umount) command */ if (mf->mf_fo->opt_unmount != NULL) mf->mf_private = (opaque_t) strdup(mf->mf_fo->opt_unmount); else mf->mf_private = (opaque_t) strdup(mf->mf_fo->opt_umount); mf->mf_prfree = (void (*)(opaque_t)) free; return 0; } static int amfs_program_exec(char *info) { char **xivec; int error; /* * Split copy of command info string */ info = strdup(info); if (info == 0) return ENOBUFS; xivec = strsplit(info, ' ', '\''); /* * Put stdout to stderr */ (void) fclose(stdout); if (!logfp) logfp = stderr; /* initialize before possible first use */ if (dup(fileno(logfp)) == -1) return errno; if (fileno(logfp) != fileno(stderr)) { (void) fclose(stderr); if (dup(fileno(logfp)) == -1) return errno; } /* * Try the exec */ if (amuDebug(D_FULL)) { char **cp = xivec; plog(XLOG_DEBUG, "executing (un)mount command..."); while (*cp) { plog(XLOG_DEBUG, "arg[%ld] = '%s'", (long) (cp - xivec), *cp); cp++; } } if (xivec[0] == 0 || xivec[1] == 0) { errno = EINVAL; plog(XLOG_USER, "1st/2nd args missing to (un)mount program"); } else { (void) execv(xivec[0], xivec + 1); } /* * Save error number */ error = errno; plog(XLOG_ERROR, "exec failed: %m"); /* * Free allocate memory */ XFREE(info); XFREE(xivec); /* * Return error */ return error; } static int amfs_program_mount(am_node *am, mntfs *mf) { return amfs_program_exec(mf->mf_fo->opt_mount); } static int amfs_program_umount(am_node *am, mntfs *mf) { return amfs_program_exec((char *) mf->mf_private); } am-utils-6.2+rc20110530/amd/amfs_root.c000066400000000000000000000073361157065440000172410ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amfs_root.c * */ /* * Root file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /**************************************************************************** *** FORWARD DEFINITIONS *** ****************************************************************************/ static int amfs_root_mount(am_node *mp, mntfs *mf); /**************************************************************************** *** OPS STRUCTURES *** ****************************************************************************/ am_ops amfs_root_ops = { "root", 0, /* amfs_root_match */ 0, /* amfs_root_init */ amfs_root_mount, amfs_generic_umount, amfs_generic_lookup_child, amfs_generic_mount_child, amfs_generic_readdir, 0, /* amfs_root_readlink */ 0, /* amfs_root_mounted */ 0, /* amfs_root_umounted */ amfs_generic_find_srvr, 0, /* amfs_root_get_wchan */ FS_NOTIMEOUT | FS_AMQINFO | FS_DIRECTORY, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_ROOT_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /**************************************************************************** *** FUNCTIONS *** ****************************************************************************/ /* * Mount the root... */ static int amfs_root_mount(am_node *mp, mntfs *mf) { mf->mf_mount = strealloc(mf->mf_mount, pid_fsname); mf->mf_private = (opaque_t) mapc_find(mf->mf_info, "", NULL, NULL); mf->mf_prfree = mapc_free; return 0; } am-utils-6.2+rc20110530/amd/amfs_toplvl.c000066400000000000000000000257401157065440000175750ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amfs_toplvl.c * */ /* * Top-level file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /**************************************************************************** *** FORWARD DEFINITIONS *** ****************************************************************************/ static int amfs_toplvl_init(mntfs *mf); /**************************************************************************** *** OPS STRUCTURES *** ****************************************************************************/ am_ops amfs_toplvl_ops = { "toplvl", amfs_generic_match, amfs_toplvl_init, /* amfs_toplvl_init */ amfs_toplvl_mount, amfs_toplvl_umount, amfs_generic_lookup_child, amfs_generic_mount_child, amfs_generic_readdir, 0, /* amfs_toplvl_readlink */ amfs_generic_mounted, 0, /* amfs_toplvl_umounted */ amfs_generic_find_srvr, 0, /* amfs_toplvl_get_wchan */ FS_MKMNT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_TOPLVL_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /**************************************************************************** *** FUNCTIONS *** ****************************************************************************/ static void set_auto_attrcache_timeout(char *preopts, char *opts, size_t l) { #ifdef MNTTAB_OPT_NOAC /* * Don't cache attributes - they are changing under the kernel's feet. * For example, IRIX5.2 will dispense with nfs lookup calls and hand stale * filehandles to getattr unless we disable attribute caching on the * automount points. */ if (gopt.auto_attrcache == 0) { xsnprintf(preopts, l, ",%s", MNTTAB_OPT_NOAC); xstrlcat(opts, preopts, l); } #endif /* MNTTAB_OPT_NOAC */ /* * XXX: note that setting these to 0 in the past resulted in an error on * some systems, which is why it's better to use "noac" if possible. For * now, we're setting everything possible, but if this will cause trouble, * then we'll have to condition the remainder of this on OPT_NOAC. */ #ifdef MNTTAB_OPT_ACTIMEO xsnprintf(preopts, l, ",%s=%d", MNTTAB_OPT_ACTIMEO, gopt.auto_attrcache); xstrlcat(opts, preopts, l); #else /* MNTTAB_OPT_ACTIMEO */ # ifdef MNTTAB_OPT_ACDIRMIN xsnprintf(preopts, l, ",%s=%d", MNTTAB_OPT_ACTDIRMIN, gopt.auto_attrcache); xstrlcat(opts, preopts, l); # endif /* MNTTAB_OPT_ACDIRMIN */ # ifdef MNTTAB_OPT_ACDIRMAX xsnprintf(preopts, l, ",%s=%d", MNTTAB_OPT_ACTDIRMAX, gopt.auto_attrcache); xstrlcat(opts, preopts, l); # endif /* MNTTAB_OPT_ACDIRMAX */ # ifdef MNTTAB_OPT_ACREGMIN xsnprintf(preopts, l, ",%s=%d", MNTTAB_OPT_ACTREGMIN, gopt.auto_attrcache); xstrlcat(opts, preopts, l); # endif /* MNTTAB_OPT_ACREGMIN */ # ifdef MNTTAB_OPT_ACREGMAX xsnprintf(preopts, l, ",%s=%d", MNTTAB_OPT_ACTREGMAX, gopt.auto_attrcache); xstrlcat(opts, preopts, l); # endif /* MNTTAB_OPT_ACREGMAX */ #endif /* MNTTAB_OPT_ACTIMEO */ } /* * Initialize a top-level mount. In our case, if the user asked for * forced_unmounts, and the OS supports it, then we try forced/lazy unmounts * on any previous toplvl mounts. This is useful if a previous Amd died and * left behind toplvl mount points (this Amd will clean them up). * * WARNING: Don't use forced/lazy unmounts if you have another valid Amd * running, because this code WILL force those valid toplvl mount points to * be detached as well! */ static int amfs_toplvl_init(mntfs *mf) { int error = 0; #if (defined(MNT2_GEN_OPT_FORCE) || defined(MNT2_GEN_OPT_DETACH)) && (defined(HAVE_UVMOUNT) || defined(HAVE_UMOUNT2)) if (gopt.flags & CFM_FORCED_UNMOUNTS) { plog(XLOG_INFO, "amfs_toplvl_init: trying forced/lazy unmount of %s", mf->mf_mount); error = umount2_fs(mf->mf_mount, AMU_UMOUNT_FORCE | AMU_UMOUNT_DETACH); if (error) plog(XLOG_INFO, "amfs_toplvl_init: forced/lazy unmount failed: %m"); else dlog("amfs_toplvl_init: forced/lazy unmount succeeded"); } #endif /* (MNT2_GEN_OPT_FORCE || MNT2_GEN_OPT_DETACH) && (HAVE_UVMOUNT || HAVE_UMOUNT2) */ return error; } /* * Mount the top-level */ int amfs_toplvl_mount(am_node *mp, mntfs *mf) { struct stat stb; char opts[SIZEOF_OPTS], preopts[SIZEOF_OPTS], toplvl_opts[40]; int error; /* * Mounting the automounter. * Make sure the mount directory exists, construct * the mount options and call the mount_amfs_toplvl routine. */ if (stat(mp->am_path, &stb) < 0) { return errno; } else if ((stb.st_mode & S_IFMT) != S_IFDIR) { plog(XLOG_WARNING, "%s is not a directory", mp->am_path); return ENOTDIR; } /* * Construct some mount options: * * Tack on magic map= option in mtab to emulate * SunOS automounter behavior. */ #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS) { autofs_get_opts(opts, sizeof(opts), mp->am_autofs_fh); } else #endif /* HAVE_FS_AUTOFS */ { preopts[0] = '\0'; #ifdef MNTTAB_OPT_INTR xstrlcat(preopts, MNTTAB_OPT_INTR, sizeof(preopts)); xstrlcat(preopts, ",", sizeof(preopts)); #endif /* MNTTAB_OPT_INTR */ #ifdef MNTTAB_OPT_IGNORE xstrlcat(preopts, MNTTAB_OPT_IGNORE, sizeof(preopts)); xstrlcat(preopts, ",", sizeof(preopts)); #endif /* MNTTAB_OPT_IGNORE */ /* write most of the initial options + preopts */ xsnprintf(opts, sizeof(opts), "%s%s,%s=%d,%s,map=%s", preopts, MNTTAB_OPT_RW, MNTTAB_OPT_PORT, nfs_port, mf->mf_ops->fs_type, mf->mf_info); /* process toplvl timeo/retrans options, if any */ if (gopt.amfs_auto_timeo[AMU_TYPE_TOPLVL] > 0) { xsnprintf(toplvl_opts, sizeof(toplvl_opts), ",%s=%d", MNTTAB_OPT_TIMEO, gopt.amfs_auto_timeo[AMU_TYPE_TOPLVL]); xstrlcat(opts, toplvl_opts, sizeof(opts)); } if (gopt.amfs_auto_retrans[AMU_TYPE_TOPLVL] > 0) { xsnprintf(toplvl_opts, sizeof(toplvl_opts), ",%s=%d", MNTTAB_OPT_RETRANS, gopt.amfs_auto_retrans[AMU_TYPE_TOPLVL]); xstrlcat(opts, toplvl_opts, sizeof(opts)); } #ifdef MNTTAB_OPT_NOLOCK xstrlcat(opts, ",", sizeof(opts)); xstrlcat(opts, MNTTAB_OPT_NOLOCK, sizeof(opts)); #endif /* MNTTAB_OPT_NOLOCK */ #ifdef MNTTAB_OPT_NOAC if (gopt.auto_attrcache == 0) { xstrlcat(opts, ",", sizeof(opts)); xstrlcat(opts, MNTTAB_OPT_NOAC, sizeof(opts)); } else #endif /* MNTTAB_OPT_NOAC */ set_auto_attrcache_timeout(preopts, opts, sizeof(preopts)); } /* now do the mount */ error = amfs_mount(mp, mf, opts); if (error) { errno = error; plog(XLOG_FATAL, "amfs_toplvl_mount: amfs_mount failed: %m"); return error; } return 0; } /* * Unmount a top-level automount node */ int amfs_toplvl_umount(am_node *mp, mntfs *mf) { struct stat stb; int unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; int error; int count = 0; /* how many times did we try to unmount? */ again: /* * The lstat is needed if this mount is type=direct. * When that happens, the kernel cache gets confused * between the underlying type (dir) and the mounted * type (link) and so needs to be re-synced before * the unmount. This is all because the unmount system * call follows links and so can't actually unmount * a link (stupid!). It was noted that doing an ls -ld * of the mount point to see why things were not working * actually fixed the problem - so simulate an ls -ld here. */ if (lstat(mp->am_path, &stb) < 0) { error = errno; dlog("lstat(%s): %m", mp->am_path); goto out; } if ((stb.st_mode & S_IFMT) != S_IFDIR) { plog(XLOG_ERROR, "amfs_toplvl_umount: %s is not a directory, aborting.", mp->am_path); error = ENOTDIR; goto out; } error = UMOUNT_FS(mp->am_path, mnttab_file_name, unmount_flags); if (error == EBUSY) { #ifdef HAVE_FS_AUTOFS /* * autofs mounts are "in place", so it is possible * that we can't just unmount our mount points and go away. * If that's the case, just give up. */ if (mf->mf_flags & MFF_IS_AUTOFS) return error; #endif /* HAVE_FS_AUTOFS */ plog(XLOG_WARNING, "amfs_toplvl_unmount retrying %s in 1s", mp->am_path); count++; sleep(1); /* * If user wants forced/lazy unmount semantics, then set those flags, * but only after we've tried normal lstat/umount a few times -- * otherwise forced unmounts may hang this very same Amd (by preventing * it from achieving a clean unmount). */ if (gopt.flags & CFM_FORCED_UNMOUNTS) { if (count == 5) { /* after 5 seconds, try MNT_FORCE */ dlog("enabling forced unmounts for toplvl node %s", mp->am_path); unmount_flags |= AMU_UMOUNT_FORCE; } if (count == 10) { /* after 10 seconds, try MNT_DETACH */ dlog("enabling detached unmounts for toplvl node %s", mp->am_path); unmount_flags |= AMU_UMOUNT_DETACH; } } goto again; } out: return error; } am-utils-6.2+rc20110530/amd/amfs_union.c000066400000000000000000000105341157065440000174000ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amfs_union.c * */ /* * Union automounter file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /**************************************************************************** *** FORWARD DEFINITIONS *** ****************************************************************************/ static int create_amfs_union_node(char *dir, opaque_t arg); static void amfs_union_mounted(mntfs *mf); /**************************************************************************** *** OPS STRUCTURES *** ****************************************************************************/ am_ops amfs_union_ops = { "union", amfs_generic_match, 0, /* amfs_union_init */ amfs_toplvl_mount, amfs_toplvl_umount, amfs_generic_lookup_child, amfs_generic_mount_child, amfs_generic_readdir, 0, /* amfs_union_readlink */ amfs_union_mounted, 0, /* amfs_union_umounted */ amfs_generic_find_srvr, 0, /* amfs_union_get_wchan */ FS_MKMNT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY, #ifdef HAVE_FS_AUTOFS AUTOFS_UNION_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * Create a reference to a union'ed entry * XXX: this function may not be used anywhere... */ static int create_amfs_union_node(char *dir, opaque_t arg) { if (!STREQ(dir, "/defaults")) { int error = 0; am_node *am; am = amfs_generic_lookup_child(arg, dir, &error, VLOOK_CREATE); if (am && error < 0) am = amfs_generic_mount_child(am, &error); if (error > 0) { errno = error; /* XXX */ plog(XLOG_ERROR, "unionfs: could not mount %s: %m", dir); } return error; } return 0; } static void amfs_union_mounted(mntfs *mf) { int index; am_node *mp; amfs_mkcacheref(mf); /* * Having made the union mount point, * populate all the entries... */ for (mp = get_first_exported_ap(&index); mp; mp = get_next_exported_ap(&index)) { if (mp->am_al->al_mnt == mf) { /* return value from create_amfs_union_node is ignored by mapc_keyiter */ (void) mapc_keyiter((mnt_map *) mp->am_al->al_mnt->mf_private, create_amfs_union_node, mp); break; } } } am-utils-6.2+rc20110530/amd/amq_subr.c000066400000000000000000000300121157065440000170440ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amq_subr.c * */ /* * Auxiliary routines for amq tool */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward definitions */ bool_t xdr_amq_mount_tree_node(XDR *xdrs, amq_mount_tree *objp); bool_t xdr_amq_mount_subtree(XDR *xdrs, amq_mount_tree *objp); voidp amqproc_null_1_svc(voidp argp, struct svc_req *rqstp) { static char res; return (voidp) &res; } /* * Return a sub-tree of mounts */ amq_mount_tree_p * amqproc_mnttree_1_svc(voidp argp, struct svc_req *rqstp) { static am_node *mp; mp = find_ap(*(char **) argp); return (amq_mount_tree_p *) ((void *)&mp); } /* * Unmount a single node */ int * amqproc_umnt_1_svc(voidp argp, struct svc_req *rqstp) { static int res = AMQ_UMNT_OK; am_node *mp = find_ap(*(char **) argp); if (mp) forcibly_timeout_mp(mp); return &res; } /* * Synchronously unmount a single node - parent side. */ int * amqproc_sync_umnt_1_svc_parent(voidp argp, struct svc_req *rqstp) { amqproc_umnt_1_svc(argp, rqstp); return NULL; } /* * Synchronously unmount a single node - child side. */ amq_sync_umnt * amqproc_sync_umnt_1_svc_child(voidp argp, struct svc_req *rqstp) { static amq_sync_umnt rv; amq_sync_umnt buf; ssize_t n; am_node *mp = find_ap(*(char **) argp); memset(&rv, 0, sizeof(rv)); rv.au_etype = AMQ_UMNT_READ; if (mp && mp->am_fd[0] >= 0) { n = read(mp->am_fd[0], &buf, sizeof(buf)); if (n == sizeof(buf)) rv = buf; } return &rv; } /* * Synchronously unmount a single node - use if we can't fork (asynchronous). */ amq_sync_umnt * amqproc_sync_umnt_1_svc_async(voidp argp, struct svc_req *rqstp) { static amq_sync_umnt rv; memset(&rv, 0, sizeof(rv)); rv.au_etype = AMQ_UMNT_FORK; rv.au_errno = errno; amqproc_umnt_1_svc(argp, rqstp); return &rv; } /* * Return global statistics */ amq_mount_stats * amqproc_stats_1_svc(voidp argp, struct svc_req *rqstp) { return (amq_mount_stats *) ((void *)&amd_stats); } /* * Return the entire tree of mount nodes */ amq_mount_tree_list * amqproc_export_1_svc(voidp argp, struct svc_req *rqstp) { static amq_mount_tree_list aml; static am_node *mp; mp = get_exported_ap(0); aml.amq_mount_tree_list_val = (amq_mount_tree_p *) ((void *) &mp); aml.amq_mount_tree_list_len = 1; /* XXX */ return &aml; } int * amqproc_setopt_1_svc(voidp argp, struct svc_req *rqstp) { static int rc; amq_setopt *opt = (amq_setopt *) argp; rc = 0; switch (opt->as_opt) { case AMOPT_DEBUG: if (debug_option(opt->as_str)) rc = EINVAL; break; case AMOPT_LOGFILE: if (gopt.logfile && opt->as_str && STREQ(gopt.logfile, opt->as_str)) { if (switch_to_logfile(opt->as_str, orig_umask, 0)) rc = EINVAL; } else { rc = EACCES; } break; case AMOPT_XLOG: if (switch_option(opt->as_str)) rc = EINVAL; break; case AMOPT_FLUSHMAPC: if (amd_state == Run) { plog(XLOG_INFO, "amq says flush cache"); do_mapc_reload = 0; flush_nfs_fhandle_cache((fserver *) NULL); flush_srvr_nfs_cache((fserver *) NULL); } break; } return &rc; } amq_mount_info_list * amqproc_getmntfs_1_svc(voidp argp, struct svc_req *rqstp) { return (amq_mount_info_list *) ((void *)&mfhead); /* XXX */ } amq_string * amqproc_getvers_1_svc(voidp argp, struct svc_req *rqstp) { static amq_string res; res = get_version_string(); return &res; } /* get PID of remote amd */ int * amqproc_getpid_1_svc(voidp argp, struct svc_req *rqstp) { static int res; res = getpid(); return &res; } /* * Process PAWD string of remote pawd tool. * * We repeat the resolution of the string until the resolved string resolves * to itself. This ensures that we follow path resolutions through all * possible Amd mount points until we reach some sort of convergence. To * prevent possible infinite loops, we break out of this loop if the strings * do not converge after MAX_PAWD_TRIES times. */ amq_string * amqproc_pawd_1_svc(voidp argp, struct svc_req *rqstp) { static amq_string res; #define MAX_PAWD_TRIES 10 int index, len, maxagain = MAX_PAWD_TRIES; am_node *mp; char *mountpoint; char *dir = *(char **) argp; static char tmp_buf[MAXPATHLEN]; char prev_buf[MAXPATHLEN]; tmp_buf[0] = prev_buf[0] = '\0'; /* default is empty string: no match */ do { for (mp = get_first_exported_ap(&index); mp; mp = get_next_exported_ap(&index)) { if (STREQ(mp->am_al->al_mnt->mf_ops->fs_type, "toplvl")) continue; if (STREQ(mp->am_al->al_mnt->mf_ops->fs_type, "auto")) continue; mountpoint = (mp->am_link ? mp->am_link : mp->am_al->al_mnt->mf_mount); len = strlen(mountpoint); if (len == 0) continue; if (!NSTREQ(mountpoint, dir, len)) continue; if (dir[len] != '\0' && dir[len] != '/') continue; xstrlcpy(tmp_buf, mp->am_path, sizeof(tmp_buf)); xstrlcat(tmp_buf, &dir[len], sizeof(tmp_buf)); break; } /* end of "for" loop */ /* once tmp_buf and prev_buf are equal, break out of "do" loop */ if (STREQ(tmp_buf, prev_buf)) break; else xstrlcpy(prev_buf, tmp_buf, sizeof(prev_buf)); } while (--maxagain); /* check if we couldn't resolve the string after MAX_PAWD_TRIES times */ if (maxagain <= 0) plog(XLOG_WARNING, "path \"%s\" did not resolve after %d tries", tmp_buf, MAX_PAWD_TRIES); res = tmp_buf; return &res; } /* * XDR routines. */ bool_t xdr_amq_setopt(XDR *xdrs, amq_setopt *objp) { if (!xdr_enum(xdrs, (enum_t *) ((voidp) &objp->as_opt))) { return (FALSE); } if (!xdr_string(xdrs, &objp->as_str, AMQ_STRLEN)) { return (FALSE); } return (TRUE); } /* * More XDR routines - Should be used for OUTPUT ONLY. */ bool_t xdr_amq_mount_tree_node(XDR *xdrs, amq_mount_tree *objp) { am_node *mp = (am_node *) objp; long mtime; if (!xdr_amq_string(xdrs, &mp->am_al->al_mnt->mf_info)) { return (FALSE); } if (!xdr_amq_string(xdrs, &mp->am_path)) { return (FALSE); } if (!xdr_amq_string(xdrs, mp->am_link ? &mp->am_link : &mp->am_al->al_mnt->mf_mount)) { return (FALSE); } if (!xdr_amq_string(xdrs, &mp->am_al->al_mnt->mf_ops->fs_type)) { return (FALSE); } mtime = mp->am_stats.s_mtime; if (!xdr_long(xdrs, &mtime)) { return (FALSE); } if (!xdr_u_short(xdrs, &mp->am_stats.s_uid)) { return (FALSE); } if (!xdr_int(xdrs, &mp->am_stats.s_getattr)) { return (FALSE); } if (!xdr_int(xdrs, &mp->am_stats.s_lookup)) { return (FALSE); } if (!xdr_int(xdrs, &mp->am_stats.s_readdir)) { return (FALSE); } if (!xdr_int(xdrs, &mp->am_stats.s_readlink)) { return (FALSE); } if (!xdr_int(xdrs, &mp->am_stats.s_statfs)) { return (FALSE); } return (TRUE); } bool_t xdr_amq_mount_subtree(XDR *xdrs, amq_mount_tree *objp) { am_node *mp = (am_node *) objp; if (!xdr_amq_mount_tree_node(xdrs, objp)) { return (FALSE); } if (!xdr_pointer(xdrs, (char **) ((voidp) &mp->am_osib), sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { return (FALSE); } if (!xdr_pointer(xdrs, (char **) ((voidp) &mp->am_child), sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { return (FALSE); } return (TRUE); } bool_t xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp) { am_node *mp = (am_node *) objp; am_node *mnil = NULL; if (!xdr_amq_mount_tree_node(xdrs, objp)) { return (FALSE); } if (!xdr_pointer(xdrs, (char **) ((voidp) &mnil), sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { return (FALSE); } if (!xdr_pointer(xdrs, (char **) ((voidp) &mp->am_child), sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_subtree)) { return (FALSE); } return (TRUE); } bool_t xdr_amq_mount_tree_p(XDR *xdrs, amq_mount_tree_p *objp) { if (!xdr_pointer(xdrs, (char **) objp, sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_tree)) { return (FALSE); } return (TRUE); } bool_t xdr_amq_mount_stats(XDR *xdrs, amq_mount_stats *objp) { if (!xdr_int(xdrs, &objp->as_drops)) { return (FALSE); } if (!xdr_int(xdrs, &objp->as_stale)) { return (FALSE); } if (!xdr_int(xdrs, &objp->as_mok)) { return (FALSE); } if (!xdr_int(xdrs, &objp->as_merr)) { return (FALSE); } if (!xdr_int(xdrs, &objp->as_uerr)) { return (FALSE); } return (TRUE); } bool_t xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp) { if (!xdr_array(xdrs, (char **) ((voidp) &objp->amq_mount_tree_list_val), (u_int *) &objp->amq_mount_tree_list_len, ~0, sizeof(amq_mount_tree_p), (XDRPROC_T_TYPE) xdr_amq_mount_tree_p)) { return (FALSE); } return (TRUE); } /* * Compute length of list */ bool_t xdr_amq_mount_info_qelem(XDR *xdrs, qelem *qhead) { mntfs *mf; u_int len = 0; for (mf = AM_LAST(mntfs, qhead); mf != HEAD(mntfs, qhead); mf = PREV(mntfs, mf)) { if (!(mf->mf_fsflags & FS_AMQINFO)) continue; len++; } xdr_u_int(xdrs, &len); /* * Send individual data items */ for (mf = AM_LAST(mntfs, qhead); mf != HEAD(mntfs, qhead); mf = PREV(mntfs, mf)) { int up; if (!(mf->mf_fsflags & FS_AMQINFO)) continue; if (!xdr_amq_string(xdrs, &mf->mf_ops->fs_type)) { return (FALSE); } if (!xdr_amq_string(xdrs, &mf->mf_mount)) { return (FALSE); } if (!xdr_amq_string(xdrs, &mf->mf_info)) { return (FALSE); } if (!xdr_amq_string(xdrs, &mf->mf_server->fs_host)) { return (FALSE); } if (!xdr_int(xdrs, &mf->mf_error)) { return (FALSE); } if (!xdr_int(xdrs, &mf->mf_refc)) { return (FALSE); } if (FSRV_ERROR(mf->mf_server) || FSRV_ISDOWN(mf->mf_server)) up = 0; else if (FSRV_ISUP(mf->mf_server)) up = 1; else up = -1; if (!xdr_int(xdrs, &up)) { return (FALSE); } } return (TRUE); } bool_t xdr_pri_free(XDRPROC_T_TYPE xdr_args, caddr_t args_ptr) { XDR xdr; xdr.x_op = XDR_FREE; return ((*xdr_args) (&xdr, (caddr_t *) args_ptr)); } am-utils-6.2+rc20110530/amd/amq_svc.c000066400000000000000000000223061157065440000166730ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/amq_svc.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* typedefs */ typedef char *(*amqsvcproc_t)(voidp, struct svc_req *); #if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) # ifdef NEED_LIBWRAP_SEVERITY_VARIABLES /* * Some systems that define libwrap already define these two variables * in libwrap, while others don't: so I need to know precisely iff * to define these two severity variables. */ int allow_severity=0, deny_severity=0, rfc931_timeout=0; # endif /* NEED_LIBWRAP_SEVERITY_VARIABLES */ /* * check if remote amq is authorized to access this amd. * Returns: 1=allowed, 0=denied. */ static int amqsvc_is_client_allowed(const struct sockaddr_in *addr, char *remote) { struct hostent *h; char *name = NULL, **ad; int ret = 0; /* default is 0==denied */ /* Check IP address */ if (hosts_ctl(AMD_SERVICE_NAME, "", remote, "")) { ret = 1; goto out; } /* Get address */ if (!(h = gethostbyaddr((const char *)&(addr->sin_addr), sizeof(addr->sin_addr), AF_INET))) goto out; if (!(name = strdup(h->h_name))) goto out; /* Paranoia check */ if (!(h = gethostbyname(name))) goto out; for (ad = h->h_addr_list; *ad; ad++) if (!memcmp(*ad, &(addr->sin_addr), h->h_length)) break; if (!*ad) goto out; if (hosts_ctl(AMD_SERVICE_NAME, "", h->h_name, "")) { return 1; goto out; } /* Check aliases */ for (ad = h->h_aliases; *ad; ad++) if (hosts_ctl(AMD_SERVICE_NAME, "", *ad, "")) { return 1; goto out; } out: if (name) XFREE(name); return ret; } #endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) */ /* * Prepare the parent and child: * 1) Setup IPC pipe. * 2) Set signal masks. * 3) Fork by calling background() so that NumChildren is updated. */ static int amq_fork(opaque_t argp) { #ifdef HAVE_SIGACTION sigset_t new, mask; #else /* not HAVE_SIGACTION */ int mask; #endif /* not HAVE_SIGACTION */ am_node *mp; pid_t pid; mp = find_ap(*(char **) argp); if (mp == NULL) { errno = 0; return -1; } if (pipe(mp->am_fd) == -1) { mp->am_fd[0] = -1; mp->am_fd[1] = -1; return -1; } #ifdef HAVE_SIGACTION sigemptyset(&new); /* initialize signal set we wish to block */ sigaddset(&new, SIGHUP); sigaddset(&new, SIGINT); sigaddset(&new, SIGQUIT); sigaddset(&new, SIGCHLD); sigprocmask(SIG_BLOCK, &new, &mask); #else /* not HAVE_SIGACTION */ mask = sigmask(SIGHUP) | sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGCHLD); mask = sigblock(mask); #endif /* not HAVE_SIGACTION */ switch ((pid = background())) { case -1: /* error */ dlog("amq_fork failed"); return -1; case 0: /* child */ close(mp->am_fd[1]); /* close output end of pipe */ mp->am_fd[1] = -1; return 0; default: /* parent */ close(mp->am_fd[0]); /* close input end of pipe */ mp->am_fd[0] = -1; #ifdef HAVE_SIGACTION sigprocmask(SIG_SETMASK, &mask, NULL); #else /* not HAVE_SIGACTION */ sigsetmask(mask); #endif /* not HAVE_SIGACTION */ return pid; } } void amq_program_1(struct svc_req *rqstp, SVCXPRT *transp) { union { amq_string amqproc_mnttree_1_arg; amq_string amqproc_umnt_1_arg; amq_setopt amqproc_setopt_1_arg; } argument; char *result; xdrproc_t xdr_argument, xdr_result; amqsvcproc_t local; amqsvcproc_t child; amqsvcproc_t parent; pid_t pid; #if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) if (gopt.flags & CFM_USE_TCPWRAPPERS) { struct sockaddr_in *remote_addr = svc_getcaller(rqstp->rq_xprt); char *remote_hostname = inet_ntoa(remote_addr->sin_addr); if (!amqsvc_is_client_allowed(remote_addr, remote_hostname)) { plog(XLOG_WARNING, "Amd denied remote amq service to %s", remote_hostname); svcerr_auth(transp, AUTH_FAILED); return; } else { dlog("Amd allowed remote amq service to %s", remote_hostname); } } #endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) */ local = NULL; child = NULL; parent = NULL; switch (rqstp->rq_proc) { case AMQPROC_NULL: xdr_argument = (xdrproc_t) xdr_void; xdr_result = (xdrproc_t) xdr_void; local = (amqsvcproc_t) amqproc_null_1_svc; break; case AMQPROC_MNTTREE: xdr_argument = (xdrproc_t) xdr_amq_string; xdr_result = (xdrproc_t) xdr_amq_mount_tree_p; local = (amqsvcproc_t) amqproc_mnttree_1_svc; break; case AMQPROC_UMNT: xdr_argument = (xdrproc_t) xdr_amq_string; xdr_result = (xdrproc_t) xdr_void; local = (amqsvcproc_t) amqproc_umnt_1_svc; break; case AMQPROC_STATS: xdr_argument = (xdrproc_t) xdr_void; xdr_result = (xdrproc_t) xdr_amq_mount_stats; local = (amqsvcproc_t) amqproc_stats_1_svc; break; case AMQPROC_EXPORT: xdr_argument = (xdrproc_t) xdr_void; xdr_result = (xdrproc_t) xdr_amq_mount_tree_list; local = (amqsvcproc_t) amqproc_export_1_svc; break; case AMQPROC_SETOPT: xdr_argument = (xdrproc_t) xdr_amq_setopt; xdr_result = (xdrproc_t) xdr_int; local = (amqsvcproc_t) amqproc_setopt_1_svc; break; case AMQPROC_GETMNTFS: xdr_argument = (xdrproc_t) xdr_void; xdr_result = (xdrproc_t) xdr_amq_mount_info_qelem; local = (amqsvcproc_t) amqproc_getmntfs_1_svc; break; case AMQPROC_GETVERS: xdr_argument = (xdrproc_t) xdr_void; xdr_result = (xdrproc_t) xdr_amq_string; local = (amqsvcproc_t) amqproc_getvers_1_svc; break; case AMQPROC_GETPID: xdr_argument = (xdrproc_t) xdr_void; xdr_result = (xdrproc_t) xdr_int; local = (amqsvcproc_t) amqproc_getpid_1_svc; break; case AMQPROC_PAWD: xdr_argument = (xdrproc_t) xdr_amq_string; xdr_result = (xdrproc_t) xdr_amq_string; local = (amqsvcproc_t) amqproc_pawd_1_svc; break; case AMQPROC_SYNC_UMNT: xdr_argument = (xdrproc_t) xdr_amq_string; xdr_result = (xdrproc_t) xdr_amq_sync_umnt; parent = (amqsvcproc_t) amqproc_sync_umnt_1_svc_parent; child = (amqsvcproc_t) amqproc_sync_umnt_1_svc_child; /* used if fork fails */ local = (amqsvcproc_t) amqproc_sync_umnt_1_svc_async; break; default: svcerr_noproc(transp); return; } memset((char *) &argument, 0, sizeof(argument)); if (!svc_getargs(transp, (XDRPROC_T_TYPE) xdr_argument, (SVC_IN_ARG_TYPE) & argument)) { svcerr_decode(transp); return; } pid = -1; result = NULL; if (child) { switch ((pid = amq_fork(&argument))) { case -1: /* error */ break; case 0: /* child */ result = (*child) (&argument, rqstp); local = NULL; break; default: /* parent */ result = (*parent) (&argument, rqstp); local = NULL; break; } } if (local) result = (*local) (&argument, rqstp); if (result != NULL && !svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_result, result)) { svcerr_systemerr(transp); } if (!svc_freeargs(transp, (XDRPROC_T_TYPE) xdr_argument, (SVC_IN_ARG_TYPE) & argument)) { plog(XLOG_FATAL, "unable to free rpc arguments in amqprog_1"); going_down(1); } if (pid == 0) exit(0); /* the child is done! */ } am-utils-6.2+rc20110530/amd/autil.c000066400000000000000000000547511157065440000163710ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/autil.c * */ /* * utilities specified to amd, taken out of the older amd/util.c. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include int NumChildren = 0; /* number of children of primary amd */ static char invalid_keys[] = "\"'!;@ \t\n"; /**************************************************************************** *** MACROS *** ****************************************************************************/ #ifdef HAVE_TRANSPORT_TYPE_TLI # define PARENT_USLEEP_TIME 100000 /* 0.1 seconds */ #endif /* HAVE_TRANSPORT_TYPE_TLI */ /**************************************************************************** *** FORWARD DEFINITIONS *** ****************************************************************************/ static void domain_strip(char *otherdom, char *localdom); static int dofork(void); /**************************************************************************** *** FUNCTIONS *** ****************************************************************************/ /* * Copy s into p, reallocating p if necessary */ char * strealloc(char *p, char *s) { size_t len = strlen(s) + 1; p = (char *) xrealloc((voidp) p, len); xstrlcpy(p, s, len); #ifdef DEBUG_MEM # if defined(HAVE_MALLINFO) && defined(HAVE_MALLOC_VERIFY) malloc_verify(); # endif /* not defined(HAVE_MALLINFO) && defined(HAVE_MALLOC_VERIFY) */ #endif /* DEBUG_MEM */ return p; } /* * Strip off the trailing part of a domain * to produce a short-form domain relative * to the local host domain. * Note that this has no effect if the domain * names do not have the same number of * components. If that restriction proves * to be a problem then the loop needs recoding * to skip from right to left and do partial * matches along the way -- ie more expensive. */ static void domain_strip(char *otherdom, char *localdom) { char *p1, *p2; if ((p1 = strchr(otherdom, '.')) && (p2 = strchr(localdom, '.')) && STREQ(p1 + 1, p2 + 1)) *p1 = '\0'; } /* * Normalize a host name: replace cnames with real names, and decide if to * strip domain name or not. */ void host_normalize(char **chp) { /* * Normalize hosts is used to resolve host name aliases * and replace them with the standard-form name. * Invoked with "-n" command line option. */ if (gopt.flags & CFM_NORMALIZE_HOSTNAMES) { struct hostent *hp; hp = gethostbyname(*chp); if (hp && hp->h_addrtype == AF_INET) { dlog("Hostname %s normalized to %s", *chp, hp->h_name); *chp = strealloc(*chp, (char *) hp->h_name); } } if (gopt.flags & CFM_DOMAIN_STRIP) { domain_strip(*chp, hostd); } } /* * Keys are not allowed to contain " ' ! or ; to avoid * problems with macro expansions. */ int valid_key(char *key) { while (*key) if (strchr(invalid_keys, *key++)) return FALSE; return TRUE; } void forcibly_timeout_mp(am_node *mp) { mntfs *mf = mp->am_al->al_mnt; /* * Arrange to timeout this node */ if (mf && ((mp->am_flags & AMF_ROOT) || (mf->mf_flags & (MFF_MOUNTING | MFF_UNMOUNTING)))) { /* * We aren't going to schedule a timeout, so we need to notify the * child here unless we are already unmounting, in which case that * process is responsible for notifying the child. */ if (mf->mf_flags & MFF_UNMOUNTING) plog(XLOG_WARNING, "node %s is currently being unmounted, ignoring timeout request", mp->am_path); else { plog(XLOG_WARNING, "ignoring timeout request for active node %s", mp->am_path); notify_child(mp, AMQ_UMNT_FAILED, EBUSY, 0); } } else { plog(XLOG_INFO, "\"%s\" forcibly timed out", mp->am_path); mp->am_flags &= ~AMF_NOTIMEOUT; mp->am_ttl = clocktime(NULL); /* * Force mtime update of parent dir, to prevent DNLC/dcache from caching * the old entry, which could result in ESTALE errors, bad symlinks, and * more. */ clocktime(&mp->am_parent->am_fattr.na_mtime); reschedule_timeout_mp(); } } void mf_mounted(mntfs *mf, bool_t call_free_opts) { int quoted; int wasmounted = mf->mf_flags & MFF_MOUNTED; if (!wasmounted) { /* * If this is a freshly mounted * filesystem then update the * mntfs structure... */ mf->mf_flags |= MFF_MOUNTED; mf->mf_error = 0; /* * Do mounted callback */ if (mf->mf_ops->mounted) mf->mf_ops->mounted(mf); /* * We used to free the mf_mo (options) here, however they're now stored * and managed with the mntfs and do not need to be free'd here (this ensures * that we use the same options to monitor/unmount the system as we used * to mount it). */ } if (mf->mf_flags & MFF_RESTART) { mf->mf_flags &= ~MFF_RESTART; dlog("Restarted filesystem %s, flags 0x%x", mf->mf_mount, mf->mf_flags); } /* * Log message */ quoted = strchr(mf->mf_info, ' ') != 0; plog(XLOG_INFO, "%s%s%s %s fstype %s on %s", quoted ? "\"" : "", mf->mf_info, quoted ? "\"" : "", wasmounted ? "referenced" : "mounted", mf->mf_ops->fs_type, mf->mf_mount); } void am_mounted(am_node *mp) { int notimeout = 0; /* assume normal timeouts initially */ mntfs *mf = mp->am_al->al_mnt; /* * This is the parent mntfs which does the mf->mf_fo (am_opts type), and * we're passing TRUE here to tell mf_mounted to actually free the * am_opts. See a related comment in mf_mounted(). */ mf_mounted(mf, TRUE); #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS) autofs_mounted(mp); #endif /* HAVE_FS_AUTOFS */ /* * Patch up path for direct mounts */ if (mp->am_parent && mp->am_parent->am_al->al_mnt->mf_fsflags & FS_DIRECT) mp->am_path = str3cat(mp->am_path, mp->am_parent->am_path, "/", "."); /* * Check whether this mount should be cached permanently or not, * and handle user-requested timeouts. */ /* first check if file system was set to never timeout */ if (mf->mf_fsflags & FS_NOTIMEOUT) notimeout = 1; /* next, alter that decision by map flags */ if (mf->mf_mopts) { mntent_t mnt; mnt.mnt_opts = mf->mf_mopts; /* umount option: user wants to unmount this entry */ if (amu_hasmntopt(&mnt, "unmount") || amu_hasmntopt(&mnt, "umount")) notimeout = 0; /* noumount option: user does NOT want to unmount this entry */ if (amu_hasmntopt(&mnt, "nounmount") || amu_hasmntopt(&mnt, "noumount")) notimeout = 1; /* utimeout=N option: user wants to unmount this option AND set timeout */ if ((mp->am_timeo = hasmntval(&mnt, "utimeout")) == 0) mp->am_timeo = gopt.am_timeo; /* otherwise use default timeout */ else notimeout = 0; /* special case: don't try to unmount "/" (it can never succeed) */ if (mf->mf_mount[0] == '/' && mf->mf_mount[1] == '\0') notimeout = 1; } /* finally set actual flags */ if (notimeout) { mp->am_flags |= AMF_NOTIMEOUT; plog(XLOG_INFO, "%s set to never timeout", mp->am_path); } else { mp->am_flags &= ~AMF_NOTIMEOUT; plog(XLOG_INFO, "%s set to timeout in %d seconds", mp->am_path, mp->am_timeo); } /* * If this node is a symlink then * compute the length of the returned string. */ if (mp->am_fattr.na_type == NFLNK) mp->am_fattr.na_size = strlen(mp->am_link ? mp->am_link : mf->mf_mount); /* * Record mount time, and update am_stats at the same time. */ mp->am_stats.s_mtime = clocktime(&mp->am_fattr.na_mtime); new_ttl(mp); /* * Update mtime of parent node (copying "struct nfstime" in '=' below) */ if (mp->am_parent && mp->am_parent->am_al->al_mnt) mp->am_parent->am_fattr.na_mtime = mp->am_fattr.na_mtime; /* * This is ugly, but essentially unavoidable * Sublinks must be treated separately as type==link * when the base type is different. */ if (mp->am_link && mf->mf_ops != &amfs_link_ops) amfs_link_ops.mount_fs(mp, mf); /* * Now, if we can, do a reply to our client here * to speed things up. */ #ifdef HAVE_FS_AUTOFS if (mp->am_flags & AMF_AUTOFS) autofs_mount_succeeded(mp); else #endif /* HAVE_FS_AUTOFS */ nfs_quick_reply(mp, 0); /* * Update stats */ amd_stats.d_mok++; } /* * Replace mount point with a reference to an error filesystem. * The mount point (struct mntfs) is NOT discarded, * the caller must do it if it wants to _before_ calling this function. */ void assign_error_mntfs(am_node *mp) { int error; dlog("assign_error_mntfs"); /* * Save the old error code */ error = mp->am_error; if (error <= 0) error = mp->am_al->al_mnt->mf_error; /* * Allocate a new error reference */ free_loc(mp->am_al); mp->am_al = new_loc(); /* * Put back the error code */ mp->am_al->al_mnt->mf_error = error; mp->am_al->al_mnt->mf_flags |= MFF_ERROR; /* * Zero the error in the mount point */ mp->am_error = 0; } /* * Build a new map cache for this node, or re-use * an existing cache for the same map. */ void amfs_mkcacheref(mntfs *mf) { char *cache; if (mf->mf_fo && mf->mf_fo->opt_cache) cache = mf->mf_fo->opt_cache; else cache = "none"; mf->mf_private = (opaque_t) mapc_find(mf->mf_info, cache, (mf->mf_fo ? mf->mf_fo->opt_maptype : NULL), mf->mf_mount); mf->mf_prfree = mapc_free; } /* * Locate next node in sibling list which is mounted * and is not an error node. */ am_node * next_nonerror_node(am_node *xp) { mntfs *mf; /* * Bug report (7/12/89) from Rein Tollevik * Fixes a race condition when mounting direct automounts. * Also fixes a problem when doing a readdir on a directory * containing hung automounts. */ while (xp && (!(mf = xp->am_al->al_mnt) || /* No mounted filesystem */ mf->mf_error != 0 || /* There was a mntfs error */ xp->am_error != 0 || /* There was a mount error */ !(mf->mf_flags & MFF_MOUNTED) || /* The fs is not mounted */ (mf->mf_server->fs_flags & FSF_DOWN)) /* The fs may be down */ ) xp = xp->am_osib; return xp; } /* * Mount an automounter directory. * The automounter is connected into the system * as a user-level NFS server. amfs_mount constructs * the necessary NFS parameters to be given to the * kernel so that it will talk back to us. * * NOTE: automounter mounts in themselves are using NFS Version 2 (UDP). * * NEW: on certain systems, mounting can be done using the * kernel-level automount (autofs) support. In that case, * we don't need NFS at all here. */ int amfs_mount(am_node *mp, mntfs *mf, char *opts) { char fs_hostname[MAXHOSTNAMELEN + MAXPATHLEN + 1]; int retry, error = 0, genflags; int on_autofs = mf->mf_flags & MFF_ON_AUTOFS; char *dir = mf->mf_mount; mntent_t mnt; MTYPE_TYPE type; int forced_unmount = 0; /* are we using forced unmounts? */ memset((voidp) &mnt, 0, sizeof(mnt)); mnt.mnt_dir = dir; mnt.mnt_fsname = pid_fsname; mnt.mnt_opts = opts; #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS) { type = MOUNT_TYPE_AUTOFS; /* * Make sure that amd's top-level autofs mounts are hidden by default * from df. * XXX: It works ok on Linux, might not work on other systems. */ mnt.mnt_type = "autofs"; } else #endif /* HAVE_FS_AUTOFS */ { type = MOUNT_TYPE_NFS; /* * Make sure that amd's top-level NFS mounts are hidden by default * from df. * If they don't appear to support the either the "ignore" mnttab * option entry, or the "auto" one, set the mount type to "nfs". */ mnt.mnt_type = HIDE_MOUNT_TYPE; } retry = hasmntval(&mnt, MNTTAB_OPT_RETRY); if (retry <= 0) retry = 2; /* XXX: default to 2 retries */ /* * SET MOUNT ARGS */ /* * Make a ``hostname'' string for the kernel */ xsnprintf(fs_hostname, sizeof(fs_hostname), "pid%ld@%s:%s", get_server_pid(), am_get_hostname(), dir); /* * Most kernels have a name length restriction (64 bytes)... */ if (strlen(fs_hostname) >= MAXHOSTNAMELEN) xstrlcpy(fs_hostname + MAXHOSTNAMELEN - 3, "..", sizeof(fs_hostname) - MAXHOSTNAMELEN + 3); #ifdef HOSTNAMESZ /* * ... and some of these restrictions are 32 bytes (HOSTNAMESZ) * If you need to get the definition for HOSTNAMESZ found, you may * add the proper header file to the conf/nfs_prot/nfs_prot_*.h file. */ if (strlen(fs_hostname) >= HOSTNAMESZ) xstrlcpy(fs_hostname + HOSTNAMESZ - 3, "..", sizeof(fs_hostname) - HOSTNAMESZ + 3); #endif /* HOSTNAMESZ */ /* * Finally we can compute the mount genflags set above, * and add any automounter specific flags. */ genflags = compute_mount_flags(&mnt); #ifdef HAVE_FS_AUTOFS if (on_autofs) genflags |= autofs_compute_mount_flags(&mnt); #endif /* HAVE_FS_AUTOFS */ genflags |= compute_automounter_mount_flags(&mnt); again: if (!(mf->mf_flags & MFF_IS_AUTOFS)) { nfs_args_t nfs_args; am_nfs_fh *fhp; am_nfs_handle_t anh; #ifndef HAVE_TRANSPORT_TYPE_TLI u_short port; struct sockaddr_in sin; #endif /* not HAVE_TRANSPORT_TYPE_TLI */ /* * get fhandle of remote path for automount point */ fhp = get_root_nfs_fh(dir); if (!fhp) { plog(XLOG_FATAL, "Can't find root file handle for %s", dir); return EINVAL; } #ifndef HAVE_TRANSPORT_TYPE_TLI /* * Create sockaddr to point to the local machine. */ memset((voidp) &sin, 0, sizeof(sin)); /* as per POSIX, sin_len need not be set (used internally by kernel) */ sin.sin_family = AF_INET; sin.sin_addr = myipaddr; port = hasmntval(&mnt, MNTTAB_OPT_PORT); if (port) { sin.sin_port = htons(port); } else { plog(XLOG_ERROR, "no port number specified for %s", dir); return EINVAL; } #endif /* not HAVE_TRANSPORT_TYPE_TLI */ /* setup the many fields and flags within nfs_args */ memmove(&anh.v2, fhp, sizeof(*fhp)); #ifdef HAVE_TRANSPORT_TYPE_TLI compute_nfs_args(&nfs_args, &mnt, genflags, nfsncp, NULL, /* remote host IP addr is set below */ NFS_VERSION, /* version 2 */ "udp", &anh, fs_hostname, pid_fsname); /* * IMPORTANT: set the correct IP address AFTERWARDS. It cannot * be done using the normal mechanism of compute_nfs_args(), because * that one will allocate a new address and use NFS_SA_DREF() to copy * parts to it, while assuming that the ip_addr passed is always * a "struct sockaddr_in". That assumption is incorrect on TLI systems, * because they define a special macro HOST_SELF which is DIFFERENT * than localhost (127.0.0.1)! */ nfs_args.addr = &nfsxprt->xp_ltaddr; #else /* not HAVE_TRANSPORT_TYPE_TLI */ compute_nfs_args(&nfs_args, &mnt, genflags, NULL, &sin, NFS_VERSION, /* version 2 */ "udp", &anh, fs_hostname, pid_fsname); #endif /* not HAVE_TRANSPORT_TYPE_TLI */ /************************************************************************* * NOTE: while compute_nfs_args() works ok for regular NFS mounts * * the toplvl one is not quite regular, and so some options must be * * corrected by hand more carefully, *after* compute_nfs_args() runs. * *************************************************************************/ compute_automounter_nfs_args(&nfs_args, &mnt); if (amuDebug(D_TRACE)) { print_nfs_args(&nfs_args, 0); plog(XLOG_DEBUG, "Generic mount flags 0x%x", genflags); } /* This is it! Here we try to mount amd on its mount points */ error = mount_fs(&mnt, genflags, (caddr_t) &nfs_args, retry, type, 0, NULL, mnttab_file_name, on_autofs); #ifdef HAVE_TRANSPORT_TYPE_TLI free_knetconfig(nfs_args.knconf); /* * local automounter mounts do not allocate a special address, so * no need to XFREE(nfs_args.addr) under TLI. */ #endif /* HAVE_TRANSPORT_TYPE_TLI */ #ifdef HAVE_FS_AUTOFS } else { /* This is it! Here we try to mount amd on its mount points */ error = mount_fs(&mnt, genflags, (caddr_t) mp->am_autofs_fh, retry, type, 0, NULL, mnttab_file_name, on_autofs); #endif /* HAVE_FS_AUTOFS */ } if (error == 0 || forced_unmount) return error; /* * If user wants forced/lazy unmount semantics, then try it iff the * current mount failed with EIO or ESTALE. */ if (gopt.flags & CFM_FORCED_UNMOUNTS) { switch (errno) { case ESTALE: case EIO: forced_unmount = errno; plog(XLOG_WARNING, "Mount %s failed (%m); force unmount.", mp->am_path); if ((error = UMOUNT_FS(mp->am_path, mnttab_file_name, AMU_UMOUNT_FORCE | AMU_UMOUNT_DETACH)) < 0) { plog(XLOG_WARNING, "Forced umount %s failed: %m.", mp->am_path); errno = forced_unmount; } else goto again; default: break; } } return error; } void am_unmounted(am_node *mp) { mntfs *mf = mp->am_al->al_mnt; if (!foreground) { /* firewall - should never happen */ /* * This is a coding error. Make sure we hear about it! */ plog(XLOG_FATAL, "am_unmounted: illegal use in background (%s)", mp->am_name); notify_child(mp, AMQ_UMNT_OK, 0, 0); /* XXX - be safe? */ return; } /* * Do unmounted callback */ if (mf->mf_ops->umounted) mf->mf_ops->umounted(mf); /* * This is ugly, but essentially unavoidable. * Sublinks must be treated separately as type==link * when the base type is different. */ if (mp->am_link && mf->mf_ops != &amfs_link_ops) amfs_link_ops.umount_fs(mp, mf); #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS) autofs_release_fh(mp); if (mp->am_flags & AMF_AUTOFS) autofs_umount_succeeded(mp); #endif /* HAVE_FS_AUTOFS */ /* * Clean up any directories that were made * * If we remove the mount point of a pending mount, any queued access * to it will fail. So don't do it in that case. * Also don't do it if the refcount is > 1. */ if (mf->mf_flags & MFF_MKMNT && mf->mf_refc == 1 && !(mp->am_flags & AMF_REMOUNT)) { plog(XLOG_INFO, "removing mountpoint directory '%s'", mf->mf_mount); rmdirs(mf->mf_mount); mf->mf_flags &= ~MFF_MKMNT; } /* * If this is a pseudo-directory then adjust the link count * in the parent */ if (mp->am_parent && mp->am_fattr.na_type == NFDIR) --mp->am_parent->am_fattr.na_nlink; /* * Update mtime of parent node */ if (mp->am_parent && mp->am_parent->am_al->al_mnt) clocktime(&mp->am_parent->am_fattr.na_mtime); if (mp->am_parent && (mp->am_flags & AMF_REMOUNT)) { char *fname = strdup(mp->am_name); am_node *mp_parent = mp->am_parent; mntfs *mf_parent = mp_parent->am_al->al_mnt; am_node fake_mp; int error = 0; /* * We need to use notify_child() after free_map(), so save enough * to do that in fake_mp. */ fake_mp.am_fd[1] = mp->am_fd[1]; mp->am_fd[1] = -1; free_map(mp); plog(XLOG_INFO, "am_unmounted: remounting %s", fname); mp = mf_parent->mf_ops->lookup_child(mp_parent, fname, &error, VLOOK_CREATE); if (mp && error < 0) mp = mf_parent->mf_ops->mount_child(mp, &error); if (error > 0) { errno = error; plog(XLOG_ERROR, "am_unmounted: could not remount %s: %m", fname); notify_child(&fake_mp, AMQ_UMNT_OK, 0, 0); } else { notify_child(&fake_mp, AMQ_UMNT_FAILED, EBUSY, 0); } XFREE(fname); } else { /* * We have a race here. * If this node has a pending mount and amd is going down (unmounting * everything in the process), then we could potentially free it here * while a struct continuation still has a reference to it. So when * amfs_cont is called, it blows up. * We avoid the race by refusing to free any nodes that have * pending mounts (defined as having a non-NULL am_alarray). */ notify_child(mp, AMQ_UMNT_OK, 0, 0); /* do this regardless */ if (!mp->am_alarray) free_map(mp); } } /* * Fork the automounter * * TODO: Need a better strategy for handling errors */ static int dofork(void) { int pid; top: pid = fork(); if (pid < 0) { /* fork error, retry in 1 second */ sleep(1); goto top; } if (pid == 0) { /* child process (foreground==false) */ am_set_mypid(); foreground = 0; } else { /* parent process, has one more child */ NumChildren++; } return pid; } int background(void) { int pid = dofork(); if (pid == 0) { dlog("backgrounded"); foreground = 0; } else dlog("forked process %d", pid); return pid; } am-utils-6.2+rc20110530/amd/clock.c000066400000000000000000000136721157065440000163430ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/clock.c * */ /* * Callouts. * * Modeled on kernel object of the same name. * See usual references. * * Use of a heap-based mechanism was rejected: * 1. more complex implementation needed. * 2. not obvious that a list is too slow for Amd. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include void reschedule_timeouts(time_t now, time_t then); typedef struct callout callout; struct callout { callout *c_next; /* List of callouts */ callout_fun *c_fn; /* Function to call */ opaque_t c_arg; /* Argument to pass to call */ time_t c_time; /* Time of call */ int c_id; /* Unique identifier */ }; static callout callouts; /* List of pending callouts */ static callout *free_callouts; /* Cache of free callouts */ static int nfree_callouts; /* Number on free list */ static int callout_id; /* Next free callout identifier */ time_t next_softclock; /* Time of next call to softclock() */ /* * Number of callout slots we keep on the free list */ #define CALLOUT_FREE_SLOP 10 /* * Global assumption: valid id's are non-zero. */ #define CID_ALLOC() (++callout_id) #define CID_UNDEF (0) static callout * alloc_callout(void) { callout *cp = free_callouts; if (cp) { --nfree_callouts; free_callouts = free_callouts->c_next; return cp; } return ALLOC(struct callout); } static void free_callout(callout *cp) { if (nfree_callouts > CALLOUT_FREE_SLOP) { XFREE(cp); } else { cp->c_next = free_callouts; free_callouts = cp; nfree_callouts++; } } /* * Schedule a callout. * * (*fn)(fn_arg) will be called at clocktime(NULL) + secs */ int timeout(u_int secs, callout_fun *fn, opaque_t fn_arg) { callout *cp, *cp2; time_t t = clocktime(NULL) + secs; /* * Allocate and fill in a new callout structure */ callout *cpnew = alloc_callout(); cpnew->c_arg = fn_arg; cpnew->c_fn = fn; cpnew->c_time = t; cpnew->c_id = CID_ALLOC(); if (t < next_softclock) next_softclock = t; /* * Find the correct place in the list */ for (cp = &callouts; (cp2 = cp->c_next); cp = cp2) if (cp2->c_time >= t) break; /* * And link it in */ cp->c_next = cpnew; cpnew->c_next = cp2; /* * Return callout identifier */ return cpnew->c_id; } /* * De-schedule a callout */ void untimeout(int id) { callout *cp, *cp2; for (cp = &callouts; (cp2 = cp->c_next); cp = cp2) { if (cp2->c_id == id) { cp->c_next = cp2->c_next; free_callout(cp2); break; } } } /* * Reschedule after clock changed */ void reschedule_timeouts(time_t now, time_t then) { callout *cp; for (cp = callouts.c_next; cp; cp = cp->c_next) { if (cp->c_time >= now && cp->c_time <= then) { plog(XLOG_WARNING, "job %d rescheduled to run immediately", cp->c_id); dlog("rescheduling job %d back %ld seconds", cp->c_id, (long) (cp->c_time - now)); next_softclock = cp->c_time = now; } } } /* * Clock handler */ int softclock(void) { time_t now; callout *cp; do { if (task_notify_todo) do_task_notify(); now = clocktime(NULL); /* * While there are more callouts waiting... */ while ((cp = callouts.c_next) && cp->c_time <= now) { /* * Extract first from list, save fn & fn_arg and * unlink callout from list and free. * Finally call function. * * The free is done first because * it is quite common that the * function will call timeout() * and try to allocate a callout */ callout_fun *fn = cp->c_fn; opaque_t fn_arg = cp->c_arg; callouts.c_next = cp->c_next; free_callout(cp); (*fn) (fn_arg); } } while (task_notify_todo); /* * Return number of seconds to next event, * or 0 if there is no event. */ if ((cp = callouts.c_next)) return cp->c_time - now; return 0; } am-utils-6.2+rc20110530/amd/conf.c000066400000000000000000001043651157065440000161750ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/conf.c * */ /* * Functions to handle the configuration file. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * MACROS: */ /* Turn on to show some info about maps being configured */ /* #define DEBUG_CONF */ /* * TYPEDEFS: */ typedef int (*OptFuncPtr)(const char *); /* * STRUCTURES: */ struct _func_map { char *name; OptFuncPtr func; }; /* * FORWARD DECLARATIONS: */ static int gopt_arch(const char *val); static int gopt_auto_attrcache(const char *val); static int gopt_auto_dir(const char *val); static int gopt_autofs_use_lofs(const char *val); static int gopt_browsable_dirs(const char *val); static int gopt_cache_duration(const char *val); static int gopt_cluster(const char *val); static int gopt_debug_mtab_file(const char *val); static int gopt_debug_options(const char *val); static int gopt_dismount_interval(const char *val); static int gopt_domain_strip(const char *val); static int gopt_exec_map_timeout(const char *val); static int gopt_forced_unmounts(const char *val); static int gopt_full_os(const char *val); static int gopt_fully_qualified_hosts(const char *val); static int gopt_hesiod_base(const char *val); static int gopt_karch(const char *val); static int gopt_ldap_base(const char *val); static int gopt_ldap_cache_maxmem(const char *val); static int gopt_ldap_cache_seconds(const char *val); static int gopt_ldap_hostports(const char *val); static int gopt_ldap_proto_version(const char *val); static int gopt_local_domain(const char *val); static int gopt_localhost_address(const char *val); static int gopt_log_file(const char *val); static int gopt_log_options(const char *val); static int gopt_map_defaults(const char *val); static int gopt_map_options(const char *val); static int gopt_map_reload_interval(const char *val); static int gopt_map_type(const char *val); static int gopt_mount_type(const char *val); static int gopt_pid_file(const char *val); static int gopt_portmap_program(const char *val); static int gopt_preferred_amq_port(const char *val); static int gopt_nfs_allow_any_interface(const char *val); static int gopt_nfs_allow_insecure_port(const char *val); static int gopt_nfs_proto(const char *val); static int gopt_nfs_retransmit_counter(const char *val); static int gopt_nfs_retransmit_counter_udp(const char *val); static int gopt_nfs_retransmit_counter_tcp(const char *val); static int gopt_nfs_retransmit_counter_toplvl(const char *val); static int gopt_nfs_retry_interval(const char *val); static int gopt_nfs_retry_interval_udp(const char *val); static int gopt_nfs_retry_interval_tcp(const char *val); static int gopt_nfs_retry_interval_toplvl(const char *val); static int gopt_nfs_vers(const char *val); static int gopt_nis_domain(const char *val); static int gopt_normalize_hostnames(const char *val); static int gopt_normalize_slashes(const char *val); static int gopt_os(const char *val); static int gopt_osver(const char *val); static int gopt_plock(const char *val); static int gopt_print_pid(const char *val); static int gopt_print_version(const char *val); static int gopt_restart_mounts(const char *val); static int gopt_search_path(const char *val); static int gopt_selectors_in_defaults(const char *val); static int gopt_show_statfs_entries(const char *val); static int gopt_sun_map_syntax(const char *val); static int gopt_truncate_log(const char *val); static int gopt_unmount_on_exit(const char *val); static int gopt_use_tcpwrappers(const char *val); static int gopt_vendor(const char *val); static int process_global_option(const char *key, const char *val); static int process_one_regular_map(const cf_map_t *cfm); static int process_regular_option(const char *section, const char *key, const char *val, cf_map_t *cfm); static int ropt_browsable_dirs(const char *val, cf_map_t *cfm); static int ropt_map_name(const char *val, cf_map_t *cfm); static int ropt_map_defaults(const char *val, cf_map_t *cfm); static int ropt_map_options(const char *val, cf_map_t *cfm); static int ropt_map_type(const char *val, cf_map_t *cfm); static int ropt_mount_type(const char *val, cf_map_t *cfm); static int ropt_search_path(const char *val, cf_map_t *cfm); static int ropt_sun_map_syntax(const char *val, cf_map_t *cfm); static int ropt_tag(const char *val, cf_map_t *cfm); static void init_cf_map(cf_map_t *cfm); /* * STATIC VARIABLES: */ static cf_map_t *head_map, *cur_map; static struct _func_map glob_functable[] = { {"arch", gopt_arch}, {"auto_attrcache", gopt_auto_attrcache}, {"auto_dir", gopt_auto_dir}, {"autofs_use_lofs", gopt_autofs_use_lofs}, {"browsable_dirs", gopt_browsable_dirs}, {"cache_duration", gopt_cache_duration}, {"cluster", gopt_cluster}, {"debug_mtab_file", gopt_debug_mtab_file}, {"debug_options", gopt_debug_options}, {"dismount_interval", gopt_dismount_interval}, {"domain_strip", gopt_domain_strip}, {"exec_map_timeout", gopt_exec_map_timeout}, {"forced_unmounts", gopt_forced_unmounts}, {"fully_qualified_hosts", gopt_fully_qualified_hosts}, {"full_os", gopt_full_os}, {"hesiod_base", gopt_hesiod_base}, {"karch", gopt_karch}, {"ldap_base", gopt_ldap_base}, {"ldap_cache_maxmem", gopt_ldap_cache_maxmem}, {"ldap_cache_seconds", gopt_ldap_cache_seconds}, {"ldap_hostports", gopt_ldap_hostports}, {"ldap_proto_version", gopt_ldap_proto_version}, {"local_domain", gopt_local_domain}, {"localhost_address", gopt_localhost_address}, {"log_file", gopt_log_file}, {"log_options", gopt_log_options}, {"map_defaults", gopt_map_defaults}, {"map_options", gopt_map_options}, {"map_reload_interval", gopt_map_reload_interval}, {"map_type", gopt_map_type}, {"mount_type", gopt_mount_type}, {"pid_file", gopt_pid_file}, {"portmap_program", gopt_portmap_program}, {"preferred_amq_port", gopt_preferred_amq_port}, {"nfs_allow_any_interface", gopt_nfs_allow_any_interface}, {"nfs_allow_insecure_port", gopt_nfs_allow_insecure_port}, {"nfs_proto", gopt_nfs_proto}, {"nfs_retransmit_counter", gopt_nfs_retransmit_counter}, {"nfs_retransmit_counter_udp", gopt_nfs_retransmit_counter_udp}, {"nfs_retransmit_counter_tcp", gopt_nfs_retransmit_counter_tcp}, {"nfs_retransmit_counter_toplvl", gopt_nfs_retransmit_counter_toplvl}, {"nfs_retry_interval", gopt_nfs_retry_interval}, {"nfs_retry_interval_udp", gopt_nfs_retry_interval_udp}, {"nfs_retry_interval_tcp", gopt_nfs_retry_interval_tcp}, {"nfs_retry_interval_toplvl", gopt_nfs_retry_interval_toplvl}, {"nfs_vers", gopt_nfs_vers}, {"nis_domain", gopt_nis_domain}, {"normalize_hostnames", gopt_normalize_hostnames}, {"normalize_slashes", gopt_normalize_slashes}, {"os", gopt_os}, {"osver", gopt_osver}, {"plock", gopt_plock}, {"print_pid", gopt_print_pid}, {"print_version", gopt_print_version}, {"restart_mounts", gopt_restart_mounts}, {"search_path", gopt_search_path}, {"selectors_on_default", gopt_selectors_in_defaults}, {"selectors_in_defaults", gopt_selectors_in_defaults}, {"show_statfs_entries", gopt_show_statfs_entries}, {"sun_map_syntax", gopt_sun_map_syntax}, {"truncate_log", gopt_truncate_log}, {"unmount_on_exit", gopt_unmount_on_exit}, {"use_tcpwrappers", gopt_use_tcpwrappers}, {"vendor", gopt_vendor}, {NULL, NULL} }; /* * Initialize a map from [global] defaults. */ static void init_cf_map(cf_map_t *cfm) { if (!cfm) return; /* * Initialize a regular map's flags and other variables from the * global ones, so that they are applied to all maps. Of course, each map * can then override the flags individually. * * NOTES: * (1): Will only work for maps that appear after [global]. * (2): I'm assigning pointers directly from the global map. */ /* initialize map_type from [global] */ cfm->cfm_type = gopt.map_type; /* initialize map_defaults from [global] */ cfm->cfm_defaults = gopt.map_defaults; /* initialize map_opts from [global] */ cfm->cfm_opts = gopt.map_options; /* initialize search_path from [global] */ cfm->cfm_search_path = gopt.search_path; /* * Initialize flags that are common both to [global] and a local map * (that is, they could be inherited from the global section). */ cfm->cfm_flags = gopt.flags & (CFM_BROWSABLE_DIRS | CFM_BROWSABLE_DIRS_FULL | CFM_MOUNT_TYPE_AUTOFS | CFM_SELECTORS_IN_DEFAULTS | CFM_SUN_MAP_SYNTAX ); } /* * Process configuration file options (called from YACC parser). * Return 0 if OK, 1 otherwise. */ int set_conf_kv(const char *section, const char *key, const char *val) { int ret; #ifdef DEBUG_CONF fprintf(stderr, "set_conf_kv: section=%s, key=%s, val=%s\n", section, key, val); #endif /* DEBUG_CONF */ /* * If global section, process kv pairs one at a time. */ if (STREQ(section, "global")) { /* * Check if a regular map was configured before "global", * and warn about it. */ if (cur_map && cur_map->cfm_dir) { static short printed_this_error; if (!printed_this_error) { fprintf(stderr, "found regular map \"%s\" before global one.\n", cur_map->cfm_dir); printed_this_error = 1; } } /* process the global option first */ ret = process_global_option(key, val); /* return status from the processing of the global option */ return ret; } /* * Otherwise we found a non-global option: store it after some testing. */ /* initialize (static) global list head and current map pointer */ if (!head_map && !cur_map) { cur_map = CALLOC(cf_map_t); if (!cur_map) { perror("calloc"); exit(1); } /* initialize first head map from global defaults */ init_cf_map(cur_map); head_map = cur_map; } /* check if we found a new map, then allocate and initialize it */ if (cur_map->cfm_dir && !STREQ(cur_map->cfm_dir, section)) { /* allocate new map struct */ cf_map_t *tmp_map = CALLOC(cf_map_t); if (!tmp_map) { perror("calloc"); exit(1); } /* initialize it from global defaults */ init_cf_map(tmp_map); /* append it to end of linked list */ cur_map->cfm_next = tmp_map; cur_map = tmp_map; } /* now process a single entry of a regular map */ return process_regular_option(section, key, val, cur_map); } /* * Process global section of configuration file options. * Return 0 upon success, 1 otherwise. */ static int process_global_option(const char *key, const char *val) { struct _func_map *gfp; /* ensure that val is valid */ if (!val || val[0] == '\0') return 1; /* * search for global function. */ for (gfp = glob_functable; gfp->name; gfp++) if (FSTREQ(gfp->name, key)) return (gfp->func)(val); fprintf(stderr, "conf: unknown global key: \"%s\"\n", key); return 1; /* failed to match any command */ } static int gopt_arch(const char *val) { gopt.arch = strdup((char *)val); return 0; } static int gopt_auto_attrcache(const char *val) { gopt.auto_attrcache = atoi(val); if (gopt.auto_attrcache < 0) { fprintf(stderr, "conf: bad attrcache value: \"%s\"\n", val); return 1; } return 0; } static int gopt_auto_dir(const char *val) { gopt.auto_dir = strdup((char *)val); return 0; } static int gopt_autofs_use_lofs(const char *val) { if (STREQ(val, "yes")) { gopt.flags |= CFM_AUTOFS_USE_LOFS; return 0; } else if (STREQ(val, "no")) { gopt.flags &= ~CFM_AUTOFS_USE_LOFS; return 0; } fprintf(stderr, "conf: unknown value to autofs_use_lofs \"%s\"\n", val); return 1; /* unknown value */ } static int gopt_browsable_dirs(const char *val) { if (STREQ(val, "full")) { gopt.flags |= CFM_BROWSABLE_DIRS_FULL; return 0; } else if (STREQ(val, "yes")) { gopt.flags |= CFM_BROWSABLE_DIRS; return 0; } else if (STREQ(val, "no")) { gopt.flags &= ~CFM_BROWSABLE_DIRS; return 0; } fprintf(stderr, "conf: unknown value to browsable_dirs \"%s\"\n", val); return 1; /* unknown value */ } static int gopt_cache_duration(const char *val) { gopt.am_timeo = atoi(val); if (gopt.am_timeo <= 0) gopt.am_timeo = AM_TTL; return 0; } static int gopt_cluster(const char *val) { gopt.cluster = strdup((char *)val); return 0; } static int gopt_debug_mtab_file(const char *val) { gopt.debug_mtab_file = strdup((char*)val); return 0; } static int gopt_debug_options(const char *val) { #ifdef DEBUG usage += debug_option((char *)val); return 0; #else /* not DEBUG */ fprintf(stderr, "%s: not compiled with DEBUG option -- sorry.\n", am_get_progname()); return 1; #endif /* not DEBUG */ } static int gopt_dismount_interval(const char *val) { gopt.am_timeo_w = atoi(val); if (gopt.am_timeo_w <= 0) gopt.am_timeo_w = AM_TTL_W; return 0; } static int gopt_domain_strip(const char *val) { if (STREQ(val, "yes")) { gopt.flags |= CFM_DOMAIN_STRIP; return 0; } else if (STREQ(val, "no")) { gopt.flags &= ~CFM_DOMAIN_STRIP; return 0; } fprintf(stderr, "conf: unknown value to domain_strip \"%s\"\n", val); return 1; /* unknown value */ } static int gopt_exec_map_timeout(const char *val) { gopt.exec_map_timeout = atoi(val); if (gopt.exec_map_timeout <= 0) gopt.exec_map_timeout = AMFS_EXEC_MAP_TIMEOUT; /* default exec map timeout */ return 0; } static int gopt_forced_unmounts(const char *val) { if (STREQ(val, "yes")) { #if !defined(MNT2_GEN_OPT_DETACH) && !defined(MNT2_GEN_OPT_FORCE) fprintf(stderr, "conf: forced_unmounts unsupported on this system.\n"); return 1; #else /* defined(MNT2_GEN_OPT_DETACH) || defined(MNT2_GEN_OPT_FORCE) */ # ifdef __linux__ /* * HACK ALERT: Linux has had MNT_FORCE since 2.2, but it hasn't gotten * stable until 2.4. And it had MNT_DETACH since 2.4, but it hasn't * gotten stable since 2.6. So alert users if they're trying to use a * feature that may not work well on their older kernel. */ { struct utsname un; if (uname(&un) >= 0) { # ifdef MNT2_GEN_OPT_FORCE if (strcmp(un.release, "2.4.0") < 0) fprintf(stderr, "warning: forced-unmounts (MNT_FORCE) may not work well before 2.4.0\n"); # endif /* MNT2_GEN_OPT_FORCE */ # ifdef MNT2_GEN_OPT_DETACH if (strcmp(un.release, "2.6.0") < 0) fprintf(stderr, "warning: lazy-unmounts (MNT_DETACH) may not work well before 2.6.0\n"); # endif /* MNT2_GEN_OPT_DETACH */ } } # endif /* __linux__ */ gopt.flags |= CFM_FORCED_UNMOUNTS; return 0; #endif /* defined(MNT2_GEN_OPT_DETACH) || defined(MNT2_GEN_OPT_FORCE) */ } else if (STREQ(val, "no")) { gopt.flags &= ~CFM_FORCED_UNMOUNTS; return 0; } fprintf(stderr, "conf: unknown value to unmount_on_exit \"%s\"\n", val); return 1; /* unknown value */ } static int gopt_full_os(const char *val) { gopt.op_sys_full = strdup((char *)val); return 0; } static int gopt_fully_qualified_hosts(const char *val) { if (STREQ(val, "yes")) { gopt.flags |= CFM_FULLY_QUALIFIED_HOSTS; return 0; } else if (STREQ(val, "no")) { gopt.flags &= ~CFM_FULLY_QUALIFIED_HOSTS; return 0; } fprintf(stderr, "conf: unknown value to fully_qualified_hosts \"%s\"\n", val); return 1; /* unknown value */ } static int gopt_hesiod_base(const char *val) { #ifdef HAVE_MAP_HESIOD gopt.hesiod_base = strdup((char *)val); return 0; #else /* not HAVE_MAP_HESIOD */ fprintf(stderr, "conf: hesiod_base option ignored. No Hesiod support available.\n"); return 1; #endif /* not HAVE_MAP_HESIOD */ } static int gopt_karch(const char *val) { gopt.karch = strdup((char *)val); return 0; } static int gopt_pid_file(const char *val) { gopt.pid_file = strdup((char *)val); return 0; } static int gopt_local_domain(const char *val) { gopt.sub_domain = strdup((char *)val); return 0; } static int gopt_localhost_address(const char *val) { gopt.localhost_address = strdup((char *)val); return 0; } static int gopt_ldap_base(const char *val) { #ifdef HAVE_MAP_LDAP gopt.ldap_base = strdup((char *)val); return 0; #else /* not HAVE_MAP_LDAP */ fprintf(stderr, "conf: ldap_base option ignored. No LDAP support available.\n"); return 1; #endif /* not HAVE_MAP_LDAP */ } static int gopt_ldap_cache_seconds(const char *val) { #ifdef HAVE_MAP_LDAP char *end; gopt.ldap_cache_seconds = strtol((char *)val, &end, 10); if (end == val) { fprintf(stderr, "conf: bad LDAP cache (seconds) option: %s\n",val); return 1; } return 0; #else /* not HAVE_MAP_LDAP */ fprintf(stderr, "conf: ldap_cache_seconds option ignored. No LDAP support available.\n"); return 1; #endif /* not HAVE_MAP_LDAP */ } static int gopt_ldap_cache_maxmem(const char *val) { #ifdef HAVE_MAP_LDAP char *end; gopt.ldap_cache_maxmem = strtol((char *)val, &end, 10); if (end == val) { fprintf(stderr, "conf: bad LDAP cache (maxmem) option: %s\n",val); return 1; } return 0; #else /* not HAVE_MAP_LDAP */ fprintf(stderr, "conf: ldap_cache_maxmem option ignored. No LDAP support available.\n"); return 1; #endif /* not HAVE_MAP_LDAP */ } static int gopt_ldap_hostports(const char *val) { #ifdef HAVE_MAP_LDAP gopt.ldap_hostports = strdup((char *)val); return 0; #else /* not HAVE_MAP_LDAP */ fprintf(stderr, "conf: ldap_hostports option ignored. No LDAP support available.\n"); return 1; #endif /* not HAVE_MAP_LDAP */ } static int gopt_ldap_proto_version(const char *val) { #ifdef HAVE_MAP_LDAP char *end; gopt.ldap_proto_version = strtol((char *)val, &end, 10); if (end == val) { fprintf(stderr, "conf: bad ldap_proto_version option: %s\n",val); return 1; } if (gopt.ldap_proto_version < 0 || gopt.ldap_proto_version > LDAP_VERSION_MAX) { fprintf(stderr, "conf: bad ldap_proto_version option value: %s\n",val); return 1; } switch (gopt.ldap_proto_version) { /* XXX: what about LDAP_VERSION1? */ case LDAP_VERSION2: #ifdef LDAP_VERSION3 case LDAP_VERSION3: #endif /* LDAP_VERSION3 */ #ifdef LDAP_VERSION4 case LDAP_VERSION4: #endif /* LDAP_VERSION4 */ break; default: fprintf(stderr, "conf: unsupported ldap_proto_version option value: %s\n",val); return 1; } return 0; #else /* not HAVE_MAP_LDAP */ fprintf(stderr, "conf: ldap_proto_version option ignored. No LDAP support available.\n"); return 1; #endif /* not HAVE_MAP_LDAP */ } static int gopt_log_file(const char *val) { gopt.logfile = strdup((char *)val); return 0; } static int gopt_log_options(const char *val) { usage += switch_option((char *)val); return 0; } static int gopt_map_defaults(const char *val) { gopt.map_defaults = strdup((char *)val); return 0; } static int gopt_map_options(const char *val) { gopt.map_options = strdup((char *)val); return 0; } static int gopt_map_reload_interval(const char *val) { gopt.map_reload_interval = atoi(val); if (gopt.map_reload_interval <= 0) gopt.map_reload_interval = ONE_HOUR; return 0; } static int gopt_map_type(const char *val) { /* check if map type exist */ if (!mapc_type_exists(val)) { fprintf(stderr, "conf: no such map type \"%s\"\n", val); return 1; } gopt.map_type = strdup((char *)val); return 0; } static int gopt_mount_type(const char *val) { if (STREQ(val, "autofs")) { #ifdef HAVE_FS_AUTOFS gopt.flags |= CFM_MOUNT_TYPE_AUTOFS; amd_use_autofs++; return 0; #else /* not HAVE_FS_AUTOFS */ fprintf(stderr, "conf: no autofs support available\n"); return 1; #endif /* not HAVE_FS_AUTOFS */ } else if (STREQ(val, "nfs")) { gopt.flags &= ~CFM_MOUNT_TYPE_AUTOFS; return 0; } fprintf(stderr, "conf: unknown value to mount_type \"%s\"\n", val); return 1; /* unknown value */ } static int gopt_portmap_program(const char *val) { gopt.portmap_program = atol(val); /* * allow alternate program numbers to be no more than 10 offset from * official amd program number (300019). */ if (gopt.portmap_program < AMQ_PROGRAM || gopt.portmap_program > AMQ_PROGRAM + 10) { gopt.portmap_program = AMQ_PROGRAM; set_amd_program_number(gopt.portmap_program); fprintf(stderr, "conf: illegal amd program number \"%s\"\n", val); return 1; } set_amd_program_number(gopt.portmap_program); return 0; /* all is OK */ } static int gopt_preferred_amq_port(const char *val) { gopt.preferred_amq_port = atoi(val); /* * No need to check value: preferred_amq_port is an unsigned short and 0 * is a valid number, meaning "any port". */ return 0; /* all is OK */ } static int gopt_nfs_allow_any_interface(const char *val) { if (STREQ(val, "yes")) { gopt.flags |= CFM_NFS_ANY_INTERFACE; return 0; } else if (STREQ(val, "no")) { gopt.flags &= ~CFM_NFS_ANY_INTERFACE; return 0; } fprintf(stderr, "conf: unknown value to nfs_allow_insecure_port \"%s\"\n", val); return 1; /* unknown value */ } static int gopt_nfs_allow_insecure_port(const char *val) { if (STREQ(val, "yes")) { gopt.flags |= CFM_NFS_INSECURE_PORT; return 0; } else if (STREQ(val, "no")) { gopt.flags &= ~CFM_NFS_INSECURE_PORT; return 0; } fprintf(stderr, "conf: unknown value to nfs_allow_insecure_port \"%s\"\n", val); return 1; /* unknown value */ } static int gopt_nfs_proto(const char *val) { if (STREQ(val, "udp") || STREQ(val, "tcp")) { gopt.nfs_proto = strdup((char *)val); return 0; } fprintf(stderr, "conf: illegal nfs_proto \"%s\"\n", val); return 1; } static int gopt_nfs_retransmit_counter(const char *val) { int i; for (i=0; icfm_dir) cfm->cfm_dir = strdup((char *)section); /* check for each possible field */ if (STREQ(key, "browsable_dirs")) return ropt_browsable_dirs(val, cfm); if (STREQ(key, "map_name")) return ropt_map_name(val, cfm); if (STREQ(key, "map_defaults")) return ropt_map_defaults(val, cfm); if (STREQ(key, "map_options")) return ropt_map_options(val, cfm); if (STREQ(key, "map_type")) return ropt_map_type(val, cfm); if (STREQ(key, "mount_type")) return ropt_mount_type(val, cfm); if (STREQ(key, "search_path")) return ropt_search_path(val, cfm); if (STREQ(key, "sun_map_syntax")) return ropt_sun_map_syntax(val, cfm); if (STREQ(key, "tag")) return ropt_tag(val, cfm); fprintf(stderr, "conf: unknown regular key \"%s\" for section \"%s\"\n", key, section); return 1; /* failed to match any command */ } static int ropt_browsable_dirs(const char *val, cf_map_t *cfm) { if (STREQ(val, "full")) { cfm->cfm_flags |= CFM_BROWSABLE_DIRS_FULL; return 0; } else if (STREQ(val, "yes")) { cfm->cfm_flags |= CFM_BROWSABLE_DIRS; return 0; } else if (STREQ(val, "no")) { cfm->cfm_flags &= ~CFM_BROWSABLE_DIRS; return 0; } fprintf(stderr, "conf: unknown value to browsable_dirs \"%s\"\n", val); return 1; /* unknown value */ } static int ropt_map_name(const char *val, cf_map_t *cfm) { cfm->cfm_name = strdup((char *)val); return 0; } static int ropt_map_defaults(const char *val, cf_map_t *cfm) { cfm->cfm_defaults = strdup((char *)val); return 0; } static int ropt_map_options(const char *val, cf_map_t *cfm) { cfm->cfm_opts = strdup((char *)val); return 0; } static int ropt_map_type(const char *val, cf_map_t *cfm) { /* check if map type exist */ if (!mapc_type_exists(val)) { fprintf(stderr, "conf: no such map type \"%s\"\n", val); return 1; } cfm->cfm_type = strdup((char *)val); return 0; } static int ropt_mount_type(const char *val, cf_map_t *cfm) { if (STREQ(val, "autofs")) { #ifdef HAVE_FS_AUTOFS cfm->cfm_flags |= CFM_MOUNT_TYPE_AUTOFS; amd_use_autofs++; return 0; #else /* not HAVE_FS_AUTOFS */ fprintf(stderr, "conf: no autofs support available\n"); return 1; #endif /* not HAVE_FS_AUTOFS */ } else if (STREQ(val, "nfs")) { cfm->cfm_flags &= ~CFM_MOUNT_TYPE_AUTOFS; return 0; } fprintf(stderr, "conf: unknown value to mount_type \"%s\"\n", val); return 1; /* unknown value */ } static int ropt_search_path(const char *val, cf_map_t *cfm) { cfm->cfm_search_path = strdup((char *)val); return 0; } static int ropt_sun_map_syntax(const char *val, cf_map_t *cfm) { if (STREQ(val, "yes")) { cfm->cfm_flags |= CFM_SUN_MAP_SYNTAX; return 0; } else if (STREQ(val, "no")) { cfm->cfm_flags &= ~CFM_SUN_MAP_SYNTAX; return 0; } fprintf(stderr, "conf: unknown value to sun_map_syntax \"%s\"\n", val); return 1; /* unknown value */ } static int ropt_tag(const char *val, cf_map_t *cfm) { cfm->cfm_tag = strdup((char *)val); return 0; } /* * Process one collected map. */ static int process_one_regular_map(const cf_map_t *cfm) { if (!cfm->cfm_name) { fprintf(stderr, "conf: map_name must be defined for map \"%s\"\n", cfm->cfm_dir); return 1; } /* * If map has no tag defined, process the map. * If no conf_tag was set in amd -T, process all untagged entries. * If a tag is defined, then process it only if it matches the map tag. */ if (!cfm->cfm_tag || (conf_tag && STREQ(cfm->cfm_tag, conf_tag))) { #ifdef DEBUG_CONF fprintf(stderr, "processing map %s (flags=0x%x)...\n", cfm->cfm_dir, cfm->cfm_flags); #endif /* DEBUG_CONF */ root_newmap(cfm->cfm_dir, cfm->cfm_opts ? cfm->cfm_opts : "", cfm->cfm_name, cfm); } else { fprintf(stderr, "skipping map %s...\n", cfm->cfm_dir); } return 0; } /* * Process all regular maps in conf file (if any) */ int process_all_regular_maps(void) { cf_map_t *tmp_map = head_map; /* * If the amd.conf file only has a [global] section (pretty useless * IMHO), there's nothing to process */ if (!tmp_map) return 0; while (tmp_map) { if (process_one_regular_map(tmp_map) != 0) return 1; tmp_map = tmp_map->cfm_next; } return 0; } /* * Find a cf_map_t for a given map name. * Return NULL if not found. */ cf_map_t * find_cf_map(const char *name) { cf_map_t *tmp_map = head_map; if (!tmp_map || !name) return NULL; while (tmp_map) { if (STREQ(tmp_map->cfm_dir, name)) { return tmp_map; } tmp_map = tmp_map->cfm_next; } return NULL; } am-utils-6.2+rc20110530/amd/conf_parse.y000066400000000000000000000107621157065440000174120ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/conf_parse.y * */ %{ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include extern char *yytext; extern int ayylineno; extern int yylex(void); static int yyerror(const char *s); static int retval; static char *header_section = NULL; /* start with no header section */ #define YYDEBUG 1 #define PARSE_DEBUG 0 #if PARSE_DEBUG # define dprintf(f,s) fprintf(stderr, (f), ayylineno, (s)) # define amu_return(v) #else /* not PARSE_DEBUG */ # define dprintf(f,s) # define amu_return(v) return((v)) #endif /* not PARSE_DEBUG */ %} %union { char *strtype; } %token LEFT_BRACKET RIGHT_BRACKET EQUAL %token NEWLINE %token NONWS_STRING %token NONWSEQ_STRING %token QUOTED_NONWSEQ_STRING %start file %% /****************************************************************************/ file : { yydebug = PARSE_DEBUG; } newlines map_sections | { yydebug = PARSE_DEBUG; } map_sections ; newlines : NEWLINE | NEWLINE newlines ; map_sections : map_section | map_section map_sections ; map_section : sec_header kv_pairs ; sec_header : LEFT_BRACKET NONWS_STRING RIGHT_BRACKET NEWLINE { if (yydebug) fprintf(stderr, "sec_header1 = \"%s\"\n", $2); header_section = $2; } ; kv_pairs : kv_pair | kv_pair kv_pairs ; kv_pair : NONWS_STRING EQUAL NONWS_STRING NEWLINE { if (yydebug) fprintf(stderr,"parse1: key=\"%s\", val=\"%s\"\n", $1, $3); retval = set_conf_kv(header_section, $1, $3); if (retval != 0) { yyerror("syntax error"); YYABORT; } } | NONWS_STRING EQUAL NONWSEQ_STRING NEWLINE { if (yydebug) fprintf(stderr,"parse2: key=\"%s\", val=\"%s\"\n", $1, $3); retval = set_conf_kv(header_section, $1, $3); if (retval != 0) { yyerror("syntax error"); YYABORT; } } | NONWS_STRING EQUAL QUOTED_NONWSEQ_STRING NEWLINE { if (yydebug) fprintf(stderr,"parse3: key=\"%s\", val=\"%s\"\n", $1, $3); retval = set_conf_kv(header_section, $1, $3); if (retval != 0) { yyerror("syntax error"); YYABORT; } } | NEWLINE ; /****************************************************************************/ %% static int yyerror(const char *s) { fprintf(stderr, "AMDCONF: %s on line %d (section %s)\n", s, ayylineno, (header_section ? header_section : "null")); exit(1); return 1; /* to full compilers that insist on a return statement */ } am-utils-6.2+rc20110530/amd/conf_tok.l000066400000000000000000000132151157065440000170540ustar00rootroot00000000000000%{ /* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/conf_tok.l * */ /* * Lexical analyzer for AMD configuration parser. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ /* * Some systems include a definition for the macro ECHO in , * and their (bad) version of lex defines it too at the very beginning of * the generated lex.yy.c file (before it can be easily undefined), * resulting in a conflict. So undefine it here before needed. * Luckily, it does not appear that this macro is actually used in the rest * of the generated lex.yy.c file. */ #ifdef ECHO # undef ECHO #endif /* ECHO */ #include #include #include /* and once again undefine this, just in case */ #ifdef ECHO # undef ECHO #endif /* ECHO */ /* * There are some things that need to be defined only if using GNU flex. * These must not be defined if using standard lex */ #ifdef FLEX_SCANNER # ifndef ECHO # define ECHO __IGNORE(fwrite( yytext, yyleng, 1, yyout )) # endif /* not ECHO */ #endif /* FLEX_SCANNER */ int ayylineno = 0; int yylex(void); /* * some systems such as DU-4.x have a different GNU flex in /usr/bin * which automatically generates yywrap macros and symbols. So I must * distinguish between them and when yywrap is actually needed. */ #if !defined(yywrap) || defined(yylex) int yywrap(void); #endif /* not yywrap or yylex */ #define TOK_DEBUG 0 #if TOK_DEBUG # define dprintf(f,s) fprintf(stderr, (f), ayylineno, (s)) # define amu_return(v) #else /* not TOK_DEBUG */ # define dprintf(f,s) # define amu_return(v) return((v)) #endif /* not TOK_DEBUG */ /* no need to use yywrap() */ #define YY_SKIP_YYWRAP /* no need for input() */ #define YY_NO_INPUT %} /* This option causes Solaris lex to fail. Use flex. See BUGS file */ /* no need to use yyunput() */ %option nounput /* allocate more output slots so lex scanners don't run out of mem */ %o 1024 DIGIT [0-9] ALPHA [A-Za-z] ALPHANUM [A-Za-z0-9] SYMBOL [A-Za-z0-9_-] PATH [A-Za-z0-9_-/] NONWSCHAR [^ \t\n\[\]=] NONWSEQCHAR [^ \t\n\[\]] NONNL [^\n] NONQUOTE [^\"] %% \n { ayylineno++; amu_return(NEWLINE); } \[ { dprintf("%8d: Left bracket \"%s\"\n", yytext); yylval.strtype = strdup((char *)yytext); amu_return(LEFT_BRACKET); } \] { dprintf("%8d: Right bracket \"%s\"\n", yytext); yylval.strtype = strdup((char *)yytext); amu_return(RIGHT_BRACKET); } = { dprintf("%8d: Equal \"%s\"\n", yytext); yylval.strtype = strdup((char *)yytext); amu_return(EQUAL); } [ \t]* { dprintf("%8d: Whitespace \"%s\"\n", yytext); } "#"[^\n]*\n { /* a comment line includes the terminating \n */ ayylineno++; yytext[strlen((char *)yytext)-1] = '\0'; dprintf("%8d: Comment \"%s\"\n", yytext); } {NONWSCHAR}{NONWSCHAR}* { dprintf("%8d: Non-WS string \"%s\"\n", yytext); yylval.strtype = strdup((char *)yytext); amu_return(NONWS_STRING); } \"{NONQUOTE}{NONQUOTE}*\" { dprintf("%8d: QUOTED-Non-WS-EQ string \"%s\"\n", yytext); /* must strip quotes */ yytext[strlen((char *)yytext)-1] = '\0'; yylval.strtype = strdup((char *)&yytext[1]); amu_return(QUOTED_NONWSEQ_STRING); } {NONWSEQCHAR}{NONWSEQCHAR}* { dprintf("%8d: Non-WS-EQ string \"%s\"\n", yytext); yylval.strtype = strdup((char *)yytext); amu_return(NONWSEQ_STRING); } %% /* * some systems such as DU-4.x have a different GNU flex in /usr/bin * which automatically generates yywrap macros and symbols. So I must * distinguish between them and when yywrap is actually needed. */ #if !defined(yywrap) || defined(yylex) int yywrap(void) { return 1; } #endif /* not yywrap or yylex */ am-utils-6.2+rc20110530/amd/get_args.c000066400000000000000000000275621157065440000170460ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/get_args.c * */ /* * Argument decode */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* include auto-generated version file */ #include char *amu_conf_file = "/etc/amd.conf"; /* default amd configuration file */ char *conf_tag = NULL; /* default conf file tags to use */ int usage = 0; int use_conf_file = 0; /* default don't use amd.conf file */ char *mnttab_file_name = NULL; /* symbol must be available always */ /* * Return the version string (dynamic buffer) */ char * get_version_string(void) { char *vers = NULL; char tmpbuf[1024]; char *wire_buf; int wire_buf_len = 0; size_t len; /* max allocated length (to avoid buf overflow) */ /* * First get dynamic string listing all known networks. * This could be a long list, if host has lots of interfaces. */ wire_buf = print_wires(); if (wire_buf) wire_buf_len = strlen(wire_buf); len = 2048 + wire_buf_len; vers = xmalloc(len); xsnprintf(vers, len, "%s\n%s\n%s\n%s\n", "Copyright (c) 1997-2011 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."); xsnprintf(tmpbuf, sizeof(tmpbuf), "%s version %s (build %d).\n", PACKAGE_NAME, PACKAGE_VERSION, AMU_BUILD_VERSION); xstrlcat(vers, tmpbuf, len); xsnprintf(tmpbuf, sizeof(tmpbuf), "Report bugs to %s.\n", PACKAGE_BUGREPORT); xstrlcat(vers, tmpbuf, len); xsnprintf(tmpbuf, sizeof(tmpbuf), "Configured by %s@%s on date %s.\n", USER_NAME, HOST_NAME, CONFIG_DATE); xstrlcat(vers, tmpbuf, len); xsnprintf(tmpbuf, sizeof(tmpbuf), "Built by %s@%s on date %s.\n", BUILD_USER, BUILD_HOST, BUILD_DATE); xstrlcat(vers, tmpbuf, len); xsnprintf(tmpbuf, sizeof(tmpbuf), "cpu=%s (%s-endian), arch=%s, karch=%s.\n", cpu, endian, gopt.arch, gopt.karch); xstrlcat(vers, tmpbuf, len); xsnprintf(tmpbuf, sizeof(tmpbuf), "full_os=%s, os=%s, osver=%s, vendor=%s, distro=%s.\n", gopt.op_sys_full, gopt.op_sys, gopt.op_sys_ver, gopt.op_sys_vendor, DISTRO_NAME); xstrlcat(vers, tmpbuf, len); xsnprintf(tmpbuf, sizeof(tmpbuf), "domain=%s, host=%s, hostd=%s.\n", hostdomain, am_get_hostname(), hostd); xstrlcat(vers, tmpbuf, len); xstrlcat(vers, "Map support for: ", len); mapc_showtypes(tmpbuf, sizeof(tmpbuf)); xstrlcat(vers, tmpbuf, len); xstrlcat(vers, ".\nAMFS: ", len); ops_showamfstypes(tmpbuf, sizeof(tmpbuf)); xstrlcat(vers, tmpbuf, len); xstrlcat(vers, ", inherit.\nFS: ", len); /* hack: "show" that we support type:=inherit */ ops_showfstypes(tmpbuf, sizeof(tmpbuf)); xstrlcat(vers, tmpbuf, len); /* append list of networks if available */ if (wire_buf) { xstrlcat(vers, wire_buf, len); XFREE(wire_buf); } return vers; } static void show_usage(void) { fprintf(stderr, "Usage: %s [-nprvHS] [-a mount_point] [-c cache_time] [-d domain]\n\ \t[-k kernel_arch] [-l logfile%s\n\ \t[-t timeout.retrans] [-w wait_timeout] [-A arch] [-C cluster_name]\n\ \t[-o op_sys_ver] [-O op_sys_name]\n\ \t[-F conf_file] [-T conf_tag]", am_get_progname(), #ifdef HAVE_SYSLOG # ifdef LOG_DAEMON "|\"syslog[:facility]\"]" # else /* not LOG_DAEMON */ "|\"syslog\"]" # endif /* not LOG_DAEMON */ #else /* not HAVE_SYSLOG */ "]" #endif /* not HAVE_SYSLOG */ ); #ifdef HAVE_MAP_NIS fputs(" [-y nis-domain]\n", stderr); #else /* not HAVE_MAP_NIS */ fputc('\n', stderr); #endif /* HAVE_MAP_NIS */ show_opts('x', xlog_opt); #ifdef DEBUG show_opts('D', dbg_opt); #endif /* DEBUG */ fprintf(stderr, "\t[directory mapname [-map_options]] ...\n"); } void get_args(int argc, char *argv[]) { int opt_ch, i; FILE *fp = stdin; char getopt_arguments[] = "+nprvSa:c:d:k:l:o:t:w:x:y:C:D:F:T:O:HA:"; char *getopt_args; int print_version = 0; /* 1 means we should print version info */ #ifdef HAVE_GNU_GETOPT getopt_args = getopt_arguments; #else /* ! HAVE_GNU_GETOPT */ getopt_args = &getopt_arguments[1]; #endif /* HAVE_GNU_GETOPT */ /* if no arguments were passed, try to use /etc/amd.conf file */ if (argc <= 1) use_conf_file = 1; while ((opt_ch = getopt(argc, argv, getopt_args)) != -1) switch (opt_ch) { case 'a': if (*optarg != '/') { fprintf(stderr, "%s: -a option must begin with a '/'\n", am_get_progname()); exit(1); } gopt.auto_dir = optarg; break; case 'c': gopt.am_timeo = atoi(optarg); if (gopt.am_timeo <= 0) gopt.am_timeo = AM_TTL; break; case 'd': gopt.sub_domain = optarg; break; case 'k': gopt.karch = optarg; break; case 'l': gopt.logfile = optarg; break; case 'n': gopt.flags |= CFM_NORMALIZE_HOSTNAMES; break; case 'o': gopt.op_sys_ver = optarg; break; case 'p': gopt.flags |= CFM_PRINT_PID; break; case 'r': gopt.flags |= CFM_RESTART_EXISTING_MOUNTS; break; case 't': /* timeo.retrans (also affects toplvl mounts) */ { char *dot = strchr(optarg, '.'); int i; if (dot) *dot = '\0'; if (*optarg) { for (i=0; i #endif /* HAVE_CONFIG_H */ #include #include #include /* forward declarations */ int exec_init(mnt_map *m, char *map, time_t *tp); int exec_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp); /* * a timed fgets() */ static char * fgets_timed(char *s, int size, int rdfd, int secs) { fd_set fds; struct timeval timeo; time_t start, now; int rval=0, i=0; if (!s || size < 0 || rdfd < 0) return 0; s[0] = '\0'; if (size == 0) return s; start = clocktime(NULL); while (s[i] != '\n' && i < size-1) { s[i+1] = '\0'; /* places the requisite trailing '\0' */ /* ready for reading */ rval = read(rdfd, (void *)(s+i), 1); if (rval == 1) { if (s[i] == 0) { rval = 0; break; } i++; continue; } else if (rval == 0) { break; } else if (rval < 0 && errno != EAGAIN && errno != EINTR) { plog(XLOG_WARNING, "fgets_timed read error: %m"); break; } timeo.tv_usec = 0; now = clocktime(NULL) - start; if (secs <= 0) timeo.tv_sec = 0; else if (now < secs) timeo.tv_sec = secs - now; else { /* timed out (now>=secs) */ plog(XLOG_WARNING, "executable map read timed out (> %d secs)", secs); rval = -1; break; } FD_ZERO(&fds); FD_SET(rdfd, &fds); rval = select(rdfd+1, &fds, NULL, NULL, &timeo); if (rval < 0) { /* error selecting */ plog(XLOG_WARNING, "fgets_timed select error: %m"); if (errno == EINTR) continue; rval = -1; break; } else if (rval == 0) { /* timed out */ plog(XLOG_WARNING, "executable map read timed out (> %d secs)", secs); rval = -1; break; } } if (rval > 0) return s; close(rdfd); return (rval == 0 ? s : 0); } static int read_line(char *buf, int size, int fd) { int done = 0; while (fgets_timed(buf, size, fd, gopt.exec_map_timeout)) { int len = strlen(buf); done += len; if (len > 1 && buf[len - 2] == '\\' && buf[len - 1] == '\n') { buf += len - 2; size -= len - 2; *buf = '\n'; buf[1] = '\0'; } else { return done; } } return done; } /* * Try to locate a value in a query answer */ static int exec_parse_qanswer(mnt_map *m, int fd, char *map, char *key, char **pval, time_t *tp) { char qanswer[INFO_MAX_LINE_LEN], *dc = NULL; int chuck = 0; int line_no = 0; while (read_line(qanswer, sizeof(qanswer), fd)) { char *cp; char *hash; int len = strlen(qanswer); line_no++; /* * Make sure we got the whole line */ if (qanswer[len - 1] != '\n') { plog(XLOG_WARNING, "line %d in \"%s\" is too long", line_no, map); chuck = 1; } else { qanswer[len - 1] = '\0'; } /* * Strip comments */ hash = strchr(qanswer, '#'); if (hash) *hash = '\0'; /* * Find beginning of value (query answer) */ for (cp = qanswer; *cp && !isascii((unsigned char)*cp) && !isspace((unsigned char)*cp); cp++) ;; /* Ignore blank lines */ if (!*cp) goto again; /* * Return a copy of the data */ if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) dc = sun_entry2amd(key, cp); else dc = strdup(cp); *pval = dc; dlog("%s returns %s", key, dc); close(fd); return 0; again: /* * If the last read didn't get a whole line then * throw away the remainder before continuing... */ if (chuck) { while (fgets_timed(qanswer, sizeof(qanswer), fd, gopt.exec_map_timeout) && !strchr(qanswer, '\n')) ; chuck = 0; } } return ENOENT; } static int set_nonblock(int fd) { int val; if (fd < 0) return 0; if ((val = fcntl(fd, F_GETFL, 0)) < 0) { plog(XLOG_WARNING, "set_nonblock fcntl F_GETFL error: %m"); return 0; } val |= O_NONBLOCK; if (fcntl(fd, F_SETFL, val) < 0) { plog(XLOG_WARNING, "set_nonblock fcntl F_SETFL error: %m"); return 0; } return 1; } static int exec_map_open(char *emap, char *key) { pid_t p1, p2; int pdes[2], nullfd, i; char *argv[3]; if (!emap) return 0; argv[0] = emap; argv[1] = key; argv[2] = NULL; if ((nullfd = open("/dev/null", O_WRONLY|O_NOCTTY)) < 0) return -1; if (pipe(pdes) < 0) { close(nullfd); return -1; } switch ((p1 = vfork())) { case -1: /* parent: fork error */ close(nullfd); close(pdes[0]); close(pdes[1]); return -1; case 0: /* child #1 */ p2 = vfork(); switch (p2) { case -1: /* child #1: fork error */ exit(errno); case 0: /* child #2: init will reap our status */ if (pdes[1] != STDOUT_FILENO) { dup2(pdes[1], STDOUT_FILENO); close(pdes[1]); } if (nullfd != STDERR_FILENO) { dup2(nullfd, STDERR_FILENO); close(nullfd); } for (i=0; i0 (errno) if failed * 0 if ok */ static int exec_check_perm(char *map) { struct stat sb; /* sanity and permission checks */ if (!map) { dlog("exec_check_permission got a NULL map"); return EINVAL; } if (stat(map, &sb)) { plog(XLOG_ERROR, "map \"%s\" stat failure: %m", map); return errno; } if (!S_ISREG(sb.st_mode)) { plog(XLOG_ERROR, "map \"%s\" should be regular file", map); return EINVAL; } if (sb.st_uid != 0) { plog(XLOG_ERROR, "map \"%s\" owned by uid %u (must be 0)", map, (u_int) sb.st_uid); return EACCES; } if (!(sb.st_mode & S_IXUSR)) { plog(XLOG_ERROR, "map \"%s\" should be executable", map); return EACCES; } if (sb.st_mode & (S_ISUID|S_ISGID)) { plog(XLOG_ERROR, "map \"%s\" should not be setuid/setgid", map); return EACCES; } if (sb.st_mode & S_IWOTH) { plog(XLOG_ERROR, "map \"%s\" should not be world writeable", map); return EACCES; } return 0; /* all is well */ } int exec_init(mnt_map *m, char *map, time_t *tp) { /* * Basically just test that the executable map can be found * and has proper permissions. */ return exec_check_perm(map); } int exec_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) { int mapfd, ret; if ((ret = exec_check_perm(map)) != 0) { return ret; } if (!key) return 0; if (logfp) fflush(logfp); dlog("exec_search \"%s\", key: \"%s\"", map, key); mapfd = exec_map_open(map, key); if (mapfd >= 0) { if (tp) *tp = clocktime(NULL); return exec_parse_qanswer(m, mapfd, map, key, pval, tp); } return errno; } am-utils-6.2+rc20110530/amd/info_file.c000066400000000000000000000142011157065440000171670ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/info_file.c * */ /* * Get info from file */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include /* forward declarations */ int file_init_or_mtime(mnt_map *m, char *map, time_t *tp); int file_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *)); int file_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp); int file_read_line(char *buf, int size, FILE *fp) { int done = 0; do { while (fgets(buf, size, fp)) { int len = strlen(buf); done += len; if (len > 1 && buf[len - 2] == '\\' && buf[len - 1] == '\n') { int ch; buf += len - 2; size -= len - 2; *buf = '\n'; buf[1] = '\0'; /* * Skip leading white space on next line */ while ((ch = getc(fp)) != EOF && isascii((unsigned char)ch) && isspace((unsigned char)ch)) ; (void) ungetc(ch, fp); } else { return done; } } } while (size > 0 && !feof(fp) && !ferror(fp)); return done; } /* * Try to locate a key in a file */ static int file_search_or_reload(mnt_map *m, FILE *fp, char *map, char *key, char **val, void (*fn) (mnt_map *m, char *, char *)) { char key_val[INFO_MAX_LINE_LEN]; int chuck = 0; int line_no = 0; while (file_read_line(key_val, sizeof(key_val), fp)) { char *kp; char *cp; char *hash; int len = strlen(key_val); line_no++; /* * Make sure we got the whole line */ if (key_val[len - 1] != '\n') { plog(XLOG_WARNING, "line %d in \"%s\" is too long", line_no, map); chuck = 1; } else { key_val[len - 1] = '\0'; } /* * Strip comments */ hash = strchr(key_val, '#'); if (hash) *hash = '\0'; /* * Find start of key */ for (kp = key_val; *kp && isascii((unsigned char)*kp) && isspace((unsigned char)*kp); kp++) ; /* * Ignore blank lines */ if (!*kp) goto again; /* * Find end of key */ for (cp = kp; *cp && (!isascii((unsigned char)*cp) || !isspace((unsigned char)*cp)); cp++) ; /* * Check whether key matches */ if (*cp) *cp++ = '\0'; if (fn || (*key == *kp && STREQ(key, kp))) { while (*cp && isascii((unsigned char)*cp) && isspace((unsigned char)*cp)) cp++; if (*cp) { /* * Return a copy of the data */ char *dc; /* if m->cfm == NULL, not using amd.conf file */ if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) dc = sun_entry2amd(kp, cp); else dc = strdup(cp); if (fn) { (*fn) (m, strdup(kp), dc); } else { *val = dc; dlog("%s returns %s", key, dc); } if (!fn) return 0; } else { plog(XLOG_USER, "%s: line %d has no value field", map, line_no); } } again: /* * If the last read didn't get a whole line then * throw away the remainder before continuing... */ if (chuck) { while (fgets(key_val, sizeof(key_val), fp) && !strchr(key_val, '\n')) ; chuck = 0; } } return fn ? 0 : ENOENT; } static FILE * file_open(char *map, time_t *tp) { FILE *mapf = fopen(map, "r"); if (mapf && tp) { struct stat stb; if (fstat(fileno(mapf), &stb) < 0) *tp = clocktime(NULL); else *tp = stb.st_mtime; } return mapf; } int file_init_or_mtime(mnt_map *m, char *map, time_t *tp) { FILE *mapf = file_open(map, tp); if (mapf) { fclose(mapf); return 0; } return errno; } int file_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *)) { FILE *mapf = file_open(map, (time_t *) NULL); if (mapf) { int error = file_search_or_reload(m, mapf, map, NULL, NULL, fn); (void) fclose(mapf); return error; } return errno; } int file_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) { time_t t; FILE *mapf = file_open(map, &t); if (mapf) { int error; if (*tp < t) { *tp = t; error = -1; } else { error = file_search_or_reload(m, mapf, map, key, pval, NULL); } (void) fclose(mapf); return error; } return errno; } am-utils-6.2+rc20110530/amd/info_hesiod.c000066400000000000000000000135201157065440000175260ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/info_hesiod.c * */ /* * Get info from Hesiod */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include #define HES_PREFIX "hesiod." #define HES_PREFLEN 7 #ifdef HAVE_HESIOD_INIT /* bsdi3 does not define this extern in any header file */ extern char **hesiod_resolve(void *context, const char *name, const char *type); extern int hesiod_init(void **context); static voidp hesiod_context; #endif /* HAVE_HESIOD_INIT */ /* forward declarations */ int amu_hesiod_init(mnt_map *m, char *map, time_t *tp); int hesiod_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp); int hesiod_isup(mnt_map *m, char *map); /* * No easy way to probe the server - check the map name begins with "hesiod." * Note: this name includes 'amu_' so as to not conflict with libhesiod's * hesiod_init() function. */ int amu_hesiod_init(mnt_map *m, char *map, time_t *tp) { dlog("amu_hesiod_init(%s)", map); *tp = 0; #ifdef HAVE_HESIOD_INIT if (!hesiod_context && hesiod_init(&hesiod_context) != 0) return ENOENT; #endif /* HAVE_HESIOD_INIT */ return NSTREQ(map, HES_PREFIX, HES_PREFLEN) ? 0 : ENOENT; } /* * Do a Hesiod nameserver call. * Modify time is ignored by Hesiod - XXX */ int hesiod_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) { char hes_key[MAXPATHLEN]; char **rvec; #ifndef HAVE_HESIOD_INIT int error; #endif /* not HAVE_HESIOD_INIT */ dlog("hesiod_search(m=%lx, map=%s, key=%s, pval=%lx tp=%lx)", (unsigned long) m, map, key, (unsigned long) pval, (unsigned long) tp); if (key[0] == '.') return ENOENT; xsnprintf(hes_key, sizeof(hes_key), "%s.%s", key, map + HES_PREFLEN); /* * Call the resolver */ dlog("Hesiod base is: %s\n", gopt.hesiod_base); dlog("hesiod_search: hes_resolve(%s, %s)", hes_key, gopt.hesiod_base); if (amuDebug(D_INFO)) _res.options |= RES_DEBUG; #ifdef HAVE_HESIOD_INIT /* new style hesiod */ rvec = hesiod_resolve(hesiod_context, hes_key, gopt.hesiod_base); #else /* not HAVE_HESIOD_INIT */ rvec = hes_resolve(hes_key, gopt.hesiod_base); #endif /* not HAVE_HESIOD_INIT */ /* * If a reply was forthcoming then return * it (and free subsequent replies) */ if (rvec && *rvec) { if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) { *pval = sun_entry2amd(key, *rvec); XFREE(*rvec); } else *pval = *rvec; while (*++rvec) XFREE(*rvec); return 0; } #ifdef HAVE_HESIOD_INIT /* new style hesiod */ return errno; #else /* not HAVE_HESIOD_INIT */ /* * Otherwise reflect the hesiod error into a Un*x error */ dlog("hesiod_search: Error: %d", hes_error()); switch (hes_error()) { case HES_ER_NOTFOUND: error = ENOENT; break; case HES_ER_CONFIG: error = EIO; break; case HES_ER_NET: error = ETIMEDOUT; break; default: error = EINVAL; break; } dlog("hesiod_search: Returning: %d", error); return error; #endif /* not HAVE_HESIOD_INIT */ } /* * Check if Hesiod is up, so we can determine if to clear the map or not. * Test it by querying for /defaults. * Returns: 0 if Hesiod is down, 1 if it is up. */ int hesiod_isup(mnt_map *m, char *map) { int error; char *val; time_t mtime; static int last_status = 1; /* assume up by default */ error = hesiod_search(m, map, "/defaults", &val, &mtime); dlog("hesiod_isup(%s): %s", map, strerror(error)); if (error != 0 && error != ENOENT) { plog(XLOG_ERROR, "hesiod_isup: error getting `/defaults' entry in map %s: %m", map); last_status = 0; return 0; /* Hesiod is down */ } if (last_status == 0) { /* if was down before */ plog(XLOG_INFO, "hesiod_isup: Hesiod came back up for map %s", map); last_status = 1; } return 1; /* Hesiod is up */ } am-utils-6.2+rc20110530/amd/info_ldap.c000066400000000000000000000364221157065440000172010ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/info_ldap.c * */ /* * Get info from LDAP (Lightweight Directory Access Protocol) * LDAP Home Page: http://www.umich.edu/~rsug/ldap/ */ /* * WARNING: as of Linux Fedora Core 5 (which comes with openldap-2.3.9), the * ldap.h headers deprecate several functions used in this file, such as * ldap_unbind. You get compile errors about missing extern definitions. * Those externs are still in , but surrounded by an ifdef * LDAP_DEPRECATED. I am turning on that ifdef here, under the assumption * that the functions may be deprecated, but they still work for this * (older?) version of the LDAP API. It gets am-utils to compile, but it is * not clear if it will work perfectly. */ #ifndef LDAP_DEPRECATED # define LDAP_DEPRECATED 1 #endif /* not LDAP_DEPRECATED */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include /* * MACROS: */ #define AMD_LDAP_TYPE "ldap" /* Time to live for an LDAP cached in an mnt_map */ #define AMD_LDAP_TTL 3600 #define AMD_LDAP_RETRIES 5 #define AMD_LDAP_HOST "ldap" #ifndef LDAP_PORT # define LDAP_PORT 389 #endif /* LDAP_PORT */ /* How timestamps are searched */ #define AMD_LDAP_TSFILTER "(&(objectClass=amdmapTimestamp)(amdmapName=%s))" /* How maps are searched */ #define AMD_LDAP_FILTER "(&(objectClass=amdmap)(amdmapName=%s)(amdmapKey=%s))" /* How timestamps are stored */ #define AMD_LDAP_TSATTR "amdmaptimestamp" /* How maps are stored */ #define AMD_LDAP_ATTR "amdmapvalue" /* * TYPEDEFS: */ typedef struct ald_ent ALD; typedef struct cr_ent CR; typedef struct he_ent HE_ENT; /* * STRUCTURES: */ struct ald_ent { LDAP *ldap; HE_ENT *hostent; CR *credentials; time_t timestamp; }; struct cr_ent { char *who; char *pw; int method; }; struct he_ent { char *host; int port; struct he_ent *next; }; static ALD *ldap_connection; /* * FORWARD DECLARATIONS: */ static int amu_ldap_rebind(ALD *a); static int get_ldap_timestamp(ALD *a, char *map, time_t *ts); int amu_ldap_init(mnt_map *m, char *map, time_t *tsu); int amu_ldap_search(mnt_map *m, char *map, char *key, char **pval, time_t *ts); int amu_ldap_mtime(mnt_map *m, char *map, time_t *ts); /* * FUNCTIONS: */ static void he_free(HE_ENT *h) { XFREE(h->host); if (h->next != NULL) he_free(h->next); XFREE(h); } static HE_ENT * string2he(char *s_orig) { char *c, *p; char *s; HE_ENT *first = NULL, *cur = NULL; if (NULL == s_orig || NULL == (s = strdup(s_orig))) return NULL; for (p = strtok(s, ","); p; p = strtok(NULL, ",")) { if (cur != NULL) { cur->next = ALLOC(HE_ENT); cur = cur->next; } else first = cur = ALLOC(HE_ENT); cur->next = NULL; c = strchr(p, ':'); if (c) { /* Host and port */ *c++ = '\0'; cur->host = strdup(p); cur->port = atoi(c); } else { cur->host = strdup(p); cur->port = LDAP_PORT; } plog(XLOG_USER, "Adding ldap server %s:%d", cur->host, cur->port); } XFREE(s); return first; } static void cr_free(CR *c) { XFREE(c->who); XFREE(c->pw); XFREE(c); } /* * Special ldap_unbind function to handle SIGPIPE. * We first ignore SIGPIPE, in case a remote LDAP server was * restarted, then we reinstall the handler. */ static int amu_ldap_unbind(LDAP *ld) { int e; #ifdef HAVE_SIGACTION struct sigaction sa; #else /* not HAVE_SIGACTION */ void (*handler)(int); #endif /* not HAVE_SIGACTION */ dlog("amu_ldap_unbind()\n"); #ifdef HAVE_SIGACTION sa.sa_handler = SIG_IGN; sa.sa_flags = 0; sigemptyset(&(sa.sa_mask)); sigaddset(&(sa.sa_mask), SIGPIPE); sigaction(SIGPIPE, &sa, &sa); /* set IGNORE, and get old action */ #else /* not HAVE_SIGACTION */ handler = signal(SIGPIPE, SIG_IGN); #endif /* not HAVE_SIGACTION */ e = ldap_unbind(ld); #ifdef HAVE_SIGACTION sigemptyset(&(sa.sa_mask)); sigaddset(&(sa.sa_mask), SIGPIPE); sigaction(SIGPIPE, &sa, NULL); #else /* not HAVE_SIGACTION */ (void) signal(SIGPIPE, handler); #endif /* not HAVE_SIGACTION */ return e; } static void ald_free(ALD *a) { he_free(a->hostent); cr_free(a->credentials); if (a->ldap != NULL) amu_ldap_unbind(a->ldap); XFREE(a); } int amu_ldap_init(mnt_map *m, char *map, time_t *ts) { ALD *aldh; CR *creds; dlog("-> amu_ldap_init: map <%s>\n", map); /* * XXX: by checking that map_type must be defined, aren't we * excluding the possibility of automatic searches through all * map types? */ if (!gopt.map_type || !STREQ(gopt.map_type, AMD_LDAP_TYPE)) { dlog("amu_ldap_init called with map_type <%s>\n", (gopt.map_type ? gopt.map_type : "null")); return ENOENT; } else { dlog("Map %s is ldap\n", map); } #ifndef LDAP_CONNECTION_PER_MAP if (ldap_connection != NULL) { m->map_data = (void *) ldap_connection; return 0; } #endif aldh = ALLOC(ALD); creds = ALLOC(CR); aldh->ldap = NULL; aldh->hostent = string2he(gopt.ldap_hostports); if (aldh->hostent == NULL) { plog(XLOG_USER, "Unable to parse hostport %s for ldap map %s", gopt.ldap_hostports ? gopt.ldap_hostports : "(null)", map); XFREE(creds); XFREE(aldh); return (ENOENT); } creds->who = ""; creds->pw = ""; creds->method = LDAP_AUTH_SIMPLE; aldh->credentials = creds; aldh->timestamp = 0; aldh->ldap = NULL; dlog("Trying for %s:%d\n", aldh->hostent->host, aldh->hostent->port); if (amu_ldap_rebind(aldh)) { ald_free(aldh); return (ENOENT); } dlog("Bound to %s:%d\n", aldh->hostent->host, aldh->hostent->port); if (get_ldap_timestamp(aldh, map, ts)) { ald_free(aldh); return (ENOENT); } dlog("Got timestamp for map %s: %ld\n", map, (u_long) *ts); ldap_connection = aldh; m->map_data = (void *) ldap_connection; return (0); } static int amu_ldap_rebind(ALD *a) { LDAP *ld; HE_ENT *h; CR *c = a->credentials; time_t now = clocktime(NULL); int try; dlog("-> amu_ldap_rebind\n"); if (a->ldap != NULL) { if ((a->timestamp - now) > AMD_LDAP_TTL) { dlog("Re-establishing ldap connection\n"); amu_ldap_unbind(a->ldap); a->timestamp = now; a->ldap = NULL; } else { /* Assume all is OK. If it wasn't we'll be back! */ dlog("amu_ldap_rebind: timestamp OK\n"); return (0); } } for (try=0; try<10; try++) { /* XXX: try up to 10 times (makes sense?) */ for (h = a->hostent; h != NULL; h = h->next) { if ((ld = ldap_open(h->host, h->port)) == NULL) { plog(XLOG_WARNING, "Unable to ldap_open to %s:%d\n", h->host, h->port); continue; } #if LDAP_VERSION_MAX > LDAP_VERSION2 /* handle LDAPv3 and heigher, if available and amd.conf-igured */ if (gopt.ldap_proto_version > LDAP_VERSION2) { if (!ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &gopt.ldap_proto_version)) { dlog("amu_ldap_rebind: LDAP protocol version set to %ld\n", gopt.ldap_proto_version); } else { plog(XLOG_WARNING, "Unable to set ldap protocol version to %ld for " "%s:%d\n", gopt.ldap_proto_version, h->host, h->port); continue; } } #endif /* LDAP_VERSION_MAX > LDAP_VERSION2 */ if (ldap_bind_s(ld, c->who, c->pw, c->method) != LDAP_SUCCESS) { plog(XLOG_WARNING, "Unable to ldap_bind to %s:%d as %s\n", h->host, h->port, c->who); continue; } if (gopt.ldap_cache_seconds > 0) { #if defined(HAVE_LDAP_ENABLE_CACHE) && defined(HAVE_EXTERN_LDAP_ENABLE_CACHE) ldap_enable_cache(ld, gopt.ldap_cache_seconds, gopt.ldap_cache_maxmem); #else /* not defined(HAVE_LDAP_ENABLE_CACHE) && defined(HAVE_EXTERN_LDAP_ENABLE_CACHE) */ plog(XLOG_WARNING, "ldap_enable_cache(%ld) is not available on this system!\n", gopt.ldap_cache_seconds); #endif /* not defined(HAVE_LDAP_ENABLE_CACHE) && defined(HAVE_EXTERN_LDAP_ENABLE_CACHE) */ } a->ldap = ld; a->timestamp = now; return (0); } plog(XLOG_WARNING, "Exhausted list of ldap servers, looping.\n"); } plog(XLOG_USER, "Unable to (re)bind to any ldap hosts\n"); return (ENOENT); } static int get_ldap_timestamp(ALD *a, char *map, time_t *ts) { struct timeval tv; char **vals, *end; char filter[MAXPATHLEN]; int i, err = 0, nentries = 0; LDAPMessage *res = NULL, *entry; dlog("-> get_ldap_timestamp: map <%s>\n", map); tv.tv_sec = 3; tv.tv_usec = 0; xsnprintf(filter, sizeof(filter), AMD_LDAP_TSFILTER, map); dlog("Getting timestamp for map %s\n", map); dlog("Filter is: %s\n", filter); dlog("Base is: %s\n", gopt.ldap_base); for (i = 0; i < AMD_LDAP_RETRIES; i++) { err = ldap_search_st(a->ldap, gopt.ldap_base, LDAP_SCOPE_SUBTREE, filter, 0, 0, &tv, &res); if (err == LDAP_SUCCESS) break; if (res) { ldap_msgfree(res); res = NULL; } plog(XLOG_USER, "Timestamp LDAP search attempt %d failed: %s\n", i + 1, ldap_err2string(err)); if (err != LDAP_TIMEOUT) { dlog("get_ldap_timestamp: unbinding...\n"); amu_ldap_unbind(a->ldap); a->ldap = NULL; if (amu_ldap_rebind(a)) return (ENOENT); } dlog("Timestamp search failed, trying again...\n"); } if (err != LDAP_SUCCESS) { *ts = 0; plog(XLOG_USER, "LDAP timestamp search failed: %s\n", ldap_err2string(err)); if (res) ldap_msgfree(res); return (ENOENT); } nentries = ldap_count_entries(a->ldap, res); if (nentries == 0) { plog(XLOG_USER, "No timestamp entry for map %s\n", map); *ts = 0; ldap_msgfree(res); return (ENOENT); } entry = ldap_first_entry(a->ldap, res); vals = ldap_get_values(a->ldap, entry, AMD_LDAP_TSATTR); if (ldap_count_values(vals) == 0) { plog(XLOG_USER, "Missing timestamp value for map %s\n", map); *ts = 0; ldap_value_free(vals); ldap_msgfree(res); return (ENOENT); } dlog("TS value is:%s:\n", vals[0]); if (vals[0]) { *ts = (time_t) strtol(vals[0], &end, 10); if (end == vals[0]) { plog(XLOG_USER, "Unable to decode ldap timestamp %s for map %s\n", vals[0], map); err = ENOENT; } if (!*ts > 0) { plog(XLOG_USER, "Nonpositive timestamp %ld for map %s\n", (u_long) *ts, map); err = ENOENT; } } else { plog(XLOG_USER, "Empty timestamp value for map %s\n", map); *ts = 0; err = ENOENT; } ldap_value_free(vals); ldap_msgfree(res); dlog("The timestamp for %s is %ld (err=%d)\n", map, (u_long) *ts, err); return (err); } int amu_ldap_search(mnt_map *m, char *map, char *key, char **pval, time_t *ts) { char **vals, filter[MAXPATHLEN], filter2[2 * MAXPATHLEN]; char *f1, *f2; struct timeval tv; int i, err = 0, nvals = 0, nentries = 0; LDAPMessage *entry, *res = NULL; ALD *a = (ALD *) (m->map_data); dlog("-> amu_ldap_search: map <%s>, key <%s>\n", map, key); tv.tv_sec = 2; tv.tv_usec = 0; if (a == NULL) { plog(XLOG_USER, "LDAP panic: no map data\n"); return (EIO); } if (amu_ldap_rebind(a)) /* Check that's the handle is still valid */ return (ENOENT); xsnprintf(filter, sizeof(filter), AMD_LDAP_FILTER, map, key); /* "*" is special to ldap_search(); run through the filter escaping it. */ f1 = filter; f2 = filter2; while (*f1) { if (*f1 == '*') { *f2++ = '\\'; *f2++ = '2'; *f2++ = 'a'; f1++; } else { *f2++ = *f1++; } } *f2 = '\0'; dlog("Search with filter: <%s>\n", filter2); for (i = 0; i < AMD_LDAP_RETRIES; i++) { err = ldap_search_st(a->ldap, gopt.ldap_base, LDAP_SCOPE_SUBTREE, filter2, 0, 0, &tv, &res); if (err == LDAP_SUCCESS) break; if (res) { ldap_msgfree(res); res = NULL; } plog(XLOG_USER, "LDAP search attempt %d failed: %s\n", i + 1, ldap_err2string(err)); if (err != LDAP_TIMEOUT) { dlog("amu_ldap_search: unbinding...\n"); amu_ldap_unbind(a->ldap); a->ldap = NULL; if (amu_ldap_rebind(a)) return (ENOENT); } } switch (err) { case LDAP_SUCCESS: break; case LDAP_NO_SUCH_OBJECT: dlog("No object\n"); if (res) ldap_msgfree(res); return (ENOENT); default: plog(XLOG_USER, "LDAP search failed: %s\n", ldap_err2string(err)); if (res) ldap_msgfree(res); return (EIO); } nentries = ldap_count_entries(a->ldap, res); dlog("Search found %d entries\n", nentries); if (nentries == 0) { ldap_msgfree(res); return (ENOENT); } entry = ldap_first_entry(a->ldap, res); vals = ldap_get_values(a->ldap, entry, AMD_LDAP_ATTR); nvals = ldap_count_values(vals); if (nvals == 0) { plog(XLOG_USER, "Missing value for %s in map %s\n", key, map); ldap_value_free(vals); ldap_msgfree(res); return (EIO); } dlog("Map %s, %s => %s\n", map, key, vals[0]); if (vals[0]) { if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) *pval = sun_entry2amd(key, vals[0]); else *pval = strdup(vals[0]); err = 0; } else { plog(XLOG_USER, "Empty value for %s in map %s\n", key, map); err = ENOENT; } ldap_msgfree(res); ldap_value_free(vals); return (err); } int amu_ldap_mtime(mnt_map *m, char *map, time_t *ts) { ALD *aldh = (ALD *) (m->map_data); if (aldh == NULL) { dlog("LDAP panic: unable to find map data\n"); return (ENOENT); } if (amu_ldap_rebind(aldh)) { return (ENOENT); } if (get_ldap_timestamp(aldh, map, ts)) { return (ENOENT); } return (0); } am-utils-6.2+rc20110530/amd/info_ndbm.c000066400000000000000000000101371157065440000171740ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/info_ndbm.c * */ /* * Get info from NDBM map */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include /* forward declarations */ int ndbm_init(mnt_map *m, char *map, time_t *tp); int ndbm_mtime(mnt_map *m, char *map, time_t *tp); int ndbm_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp); static int search_ndbm(mnt_map *m, DBM *db, char *key, char **val) { datum k, v; k.dptr = key; k.dsize = strlen(key) + 1; v = dbm_fetch(db, k); if (v.dptr) { if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) *val = sun_entry2amd(key, v.dptr); else *val = strdup(v.dptr); return 0; } return ENOENT; } int ndbm_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) { DBM *db; db = dbm_open(map, O_RDONLY, 0); if (db) { struct stat stb; int error; #ifdef DBM_SUFFIX char dbfilename[256]; xstrlcpy(dbfilename, map, sizeof(dbfilename)); xstrlcat(dbfilename, DBM_SUFFIX, sizeof(dbfilename)); error = stat(dbfilename, &stb); #else /* not DBM_SUFFIX */ error = fstat(dbm_pagfno(db), &stb); #endif /* not DBM_SUFFIX */ if (!error && *tp < stb.st_mtime) { *tp = stb.st_mtime; error = -1; } else { error = search_ndbm(m, db, key, pval); } (void) dbm_close(db); return error; } return errno; } int ndbm_init(mnt_map *m, char *map, time_t *tp) { DBM *db; db = dbm_open(map, O_RDONLY, 0); if (db) { struct stat stb; int error; #ifdef DBM_SUFFIX char dbfilename[256]; xstrlcpy(dbfilename, map, sizeof(dbfilename)); xstrlcat(dbfilename, DBM_SUFFIX, sizeof(dbfilename)); error = stat(dbfilename, &stb); #else /* not DBM_SUFFIX */ error = fstat(dbm_pagfno(db), &stb); #endif /* not DBM_SUFFIX */ if (error < 0) *tp = clocktime(NULL); else *tp = stb.st_mtime; dbm_close(db); return 0; } return errno; } int ndbm_mtime(mnt_map *m, char *map, time_t *tp) { return ndbm_init(m,map, tp); } am-utils-6.2+rc20110530/amd/info_nis.c000066400000000000000000000262451157065440000170540ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/info_nis.c * */ /* * Get info from NIS map */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include /* * NIS+ servers in NIS compat mode don't have yp_order() * * has_yp_order = 1 NIS server * = 0 NIS+ server * = -1 server is down */ static int has_yp_order = -1; /* forward declarations */ int nis_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *)); int nis_search(mnt_map *m, char *map, char *key, char **val, time_t *tp); int nis_init(mnt_map *m, char *map, time_t *tp); int nis_isup(mnt_map *m, char *map); int nis_mtime(mnt_map *m, char *map, time_t *tp); /* typedefs */ typedef void (*nis_callback_fxn_t)(mnt_map *, char *, char *); #ifndef DEFINED_YPALL_CALLBACK_FXN_T typedef int (*ypall_callback_fxn_t)(); #endif /* DEFINED_YPALL_CALLBACK_FXN_T */ struct nis_callback_data { mnt_map *ncd_m; char *ncd_map; nis_callback_fxn_t ncd_fn; }; /* Map to the right version of yp_all */ #ifdef HAVE_BAD_YP_ALL # define yp_all am_yp_all static int am_yp_all(char *indomain, char *inmap, struct ypall_callback *incallback); #endif /* HAVE_BAD_YP_ALL */ /* * Figure out the nis domain name */ static int determine_nis_domain(void) { static int nis_not_running = 0; char default_domain[YPMAXDOMAIN]; if (nis_not_running) return ENOENT; if (getdomainname(default_domain, sizeof(default_domain)) < 0) { nis_not_running = 1; plog(XLOG_ERROR, "getdomainname: %m"); return EIO; } if (!*default_domain) { nis_not_running = 1; plog(XLOG_WARNING, "NIS domain name is not set. NIS ignored."); return ENOENT; } gopt.nis_domain = strdup(default_domain); return 0; } /* * Callback from yp_all */ static int callback(int status, char *key, int kl, char *val, int vl, char *data) { struct nis_callback_data *ncdp = (struct nis_callback_data *) data; if (status == YP_TRUE) { /* add to list of maps */ char *kp = strnsave(key, kl); char *vp = strnsave(val, vl); (*ncdp->ncd_fn) (ncdp->ncd_m, kp, vp); /* we want more ... */ return FALSE; } else { /* NOMORE means end of map - otherwise log error */ if (status != YP_NOMORE) { /* check what went wrong */ int e = ypprot_err(status); plog(XLOG_ERROR, "yp enumeration of %s: %s, status=%d, e=%d", ncdp->ncd_map, yperr_string(e), status, e); } return TRUE; } } int nis_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *)) { int error; struct nis_callback_data data; struct ypall_callback cbinfo; if (!gopt.nis_domain) { error = determine_nis_domain(); if (error) return error; } data.ncd_m = m; data.ncd_map = map; data.ncd_fn = fn; cbinfo.data = (voidp) &data; cbinfo.foreach = (ypall_callback_fxn_t) callback; /* * If you are using NIS and your yp_all function is "broken", you have to * get it fixed. The bug in yp_all() is that it does not close a TCP * connection to ypserv, and this ypserv runs out of open file descriptors, * getting into an infinite loop, thus all YP clients eventually unbind * and hang too. */ error = yp_all(gopt.nis_domain, map, &cbinfo); if (error) plog(XLOG_ERROR, "error grabbing nis map of %s: %s", map, yperr_string(ypprot_err(error))); return error; } /* * Check if NIS is up, so we can determine if to clear the map or not. * Test it by checking the yp order. * Returns: 0 if NIS is down, 1 if it is up. */ int nis_isup(mnt_map *m, char *map) { YP_ORDER_OUTORDER_TYPE order; int error; char *master; static int last_status = 1; /* assume up by default */ switch (has_yp_order) { case 1: /* * NIS server with yp_order */ error = yp_order(gopt.nis_domain, map, &order); if (error != 0) { plog(XLOG_ERROR, "nis_isup: error getting the order of map %s: %s", map, yperr_string(ypprot_err(error))); last_status = 0; return 0; /* NIS is down */ } break; case 0: /* * NIS+ server without yp_order */ error = yp_master(gopt.nis_domain, map, &master); if (error != 0) { plog(XLOG_ERROR, "nis_isup: error getting the master of map %s: %s", map, yperr_string(ypprot_err(error))); last_status = 0; return 0; /* NIS+ is down */ } break; default: /* * server was down */ last_status = 0; } if (last_status == 0) { /* reinitialize if was down before */ time_t dummy; error = nis_init(m, map, &dummy); if (error) return 0; /* still down */ plog(XLOG_INFO, "nis_isup: NIS came back up for map %s", map); last_status = 1; } return 1; /* NIS is up */ } /* * Try to locate a key using NIS. */ int nis_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) { int outlen; int res; YP_ORDER_OUTORDER_TYPE order; /* * Make sure domain initialized */ if (!gopt.nis_domain) { int error = determine_nis_domain(); if (error) return error; } switch (has_yp_order) { case 1: /* * NIS server with yp_order * Check if map has changed */ if (yp_order(gopt.nis_domain, map, &order)) return EIO; if ((time_t) order > *tp) { *tp = (time_t) order; return -1; } break; case 0: /* * NIS+ server without yp_order * Check if timeout has expired to invalidate the cache */ order = time(NULL); if ((time_t)order - *tp > gopt.am_timeo) { *tp = (time_t)order; return(-1); } break; default: /* * server was down */ if (nis_isup(m, map)) return -1; return EIO; } /* * Lookup key */ res = yp_match(gopt.nis_domain, map, key, strlen(key), pval, &outlen); if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX) && res == 0) { char *oldval = *pval; *pval = sun_entry2amd(key, oldval); /* We always need to free the output of the yp_match call. */ XFREE(oldval); if (*pval == NULL) return -1; /* sun2amd parser error */ } /* * Do something interesting with the return code */ switch (res) { case 0: return 0; case YPERR_KEY: return ENOENT; default: plog(XLOG_ERROR, "nis_search: %s: %s", map, yperr_string(res)); return EIO; } } int nis_init(mnt_map *m, char *map, time_t *tp) { YP_ORDER_OUTORDER_TYPE order; int yp_order_result; char *master; if (!gopt.nis_domain) { int error = determine_nis_domain(); if (error) return error; } /* * To see if the map exists, try to find * a master for it. */ yp_order_result = yp_order(gopt.nis_domain, map, &order); switch (yp_order_result) { case 0: /* NIS server found */ has_yp_order = 1; *tp = (time_t) order; dlog("NIS master for %s@%s has order %lu", map, gopt.nis_domain, (unsigned long) order); break; case YPERR_YPERR: /* NIS+ server found ! */ has_yp_order = 0; /* try yp_master() instead */ if (yp_master(gopt.nis_domain, map, &master)) { return ENOENT; } else { dlog("NIS master for %s@%s is a NIS+ server", map, gopt.nis_domain); /* Use fake timestamps */ *tp = time(NULL); } break; default: /* server is down */ has_yp_order = -1; return ENOENT; } return 0; } int nis_mtime(mnt_map *m, char *map, time_t *tp) { return nis_init(m, map, tp); } #ifdef HAVE_BAD_YP_ALL /* * If you are using NIS and your yp_all function is "broken", use an * alternate code which avoids a bug in yp_all(). The bug in yp_all() is * that it does not close a TCP connection to ypserv, and this ypserv runs * out of open filedescriptors, getting into an infinite loop, thus all YP * clients eventually unbind and hang too. * * Systems known to be plagued with this bug: * earlier SunOS 4.x * all irix systems (at this time, up to 6.4 was checked) * * -Erez Zadok * -James Tanis */ static int am_yp_all(char *indomain, char *inmap, struct ypall_callback *incallback) { int i, j; char *outkey, *outval; int outkeylen, outvallen; char *outkey_old; int outkeylen_old; plog(XLOG_INFO, "NIS map %s reloading using am_yp_all", inmap); i = yp_first(indomain, inmap, &outkey, &outkeylen, &outval, &outvallen); if (i) { plog(XLOG_ERROR, "yp_first() returned error: %s\n", yperr_string(i)); } do { j = (incallback->foreach)(YP_TRUE, outkey, outkeylen, outval, outvallen, incallback->data); if (j != FALSE) /* terminate loop */ break; /* * We have to manually free all char ** arguments to yp_first/yp_next * outval must be freed *before* calling yp_next again, outkey can be * freed as outkey_old *after* the call (this saves one call to * strnsave). */ XFREE(outval); outkey_old = outkey; outkeylen_old = outkeylen; i = yp_next(indomain, inmap, outkey_old, outkeylen_old, &outkey, &outkeylen, &outval, &outvallen); XFREE(outkey_old); } while (!i); if (i) { dlog("yp_next() returned error: %s\n", yperr_string(i)); } if (i == YPERR_NOMORE) return 0; return i; } #endif /* HAVE_BAD_YP_ALL */ am-utils-6.2+rc20110530/amd/info_nisplus.c000066400000000000000000000177451157065440000177650ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/info_nisplus.c * */ /* * Get info from NIS+ (version 3) map */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include #define NISPLUS_KEY "key=" #define NISPLUS_ORGDIR ".org_dir" struct nis_callback_data { mnt_map *ncd_m; char *ncd_map; void (*ncd_fn)(); }; struct nisplus_search_callback_data { nis_name key; char *value; }; static int nisplus_callback(const nis_name key, const nis_object *value, voidp opaquedata) { char *kp = strnsave(ENTRY_VAL(value, 0), ENTRY_LEN(value, 0)); char *vp = strnsave(ENTRY_VAL(value, 1), ENTRY_LEN(value, 1)); struct nis_callback_data *data = (struct nis_callback_data *) opaquedata; dlog("NISplus callback for <%s,%s>", kp, vp); (*data->ncd_fn) (data->ncd_m, kp, vp); /* * We want more ... */ return FALSE; } int nisplus_reload(mnt_map *m, char *map, void (*fn) ()) { int error = 0; struct nis_callback_data data; nis_result *result; char *org; /* if map does not have ".org_dir" then append it */ nis_name map_name; size_t l; org = strstr(map, NISPLUS_ORGDIR); if (org == NULL) org = NISPLUS_ORGDIR; else org = ""; /* make some room for the NIS map_name */ l = strlen(map) + sizeof(NISPLUS_ORGDIR); map_name = xmalloc(l); if (map_name == NULL) { plog(XLOG_ERROR, "Unable to create map_name %s: %s", map, strerror(ENOMEM)); return ENOMEM; } xsnprintf(map_name, l, "%s%s", map, org); data.ncd_m = m; data.ncd_map = map_name; data.ncd_fn = fn; dlog("NISplus reload for %s", map); result = nis_list(map_name, EXPAND_NAME | FOLLOW_LINKS | FOLLOW_PATH, (int (*)()) nisplus_callback, &data); /* free off the NIS map_name */ XFREE(map_name); if (result->status != NIS_SUCCESS && result->status != NIS_CBRESULTS) error = 1; if (error) plog(XLOG_ERROR, "error grabbing nisplus map of %s: %s", map, nis_sperrno(result->status)); nis_freeresult(result); return error; } static int nisplus_search_callback(const nis_name key, const nis_object *value, voidp opaquedata) { struct nisplus_search_callback_data *data = (struct nisplus_search_callback_data *) opaquedata; dlog("NISplus search callback for <%s>", ENTRY_VAL(value, 0)); dlog("NISplus search callback value <%s>", ENTRY_VAL(value, 1)); data->value = strnsave(ENTRY_VAL(value, 1), ENTRY_LEN(value, 1)); return TRUE; } /* * Try to locate a key using NIS+. */ int nisplus_search(mnt_map *m, char *map, char *key, char **val, time_t *tp) { nis_result *result; int error = 0; struct nisplus_search_callback_data data; nis_name index; char *org; /* if map does not have ".org_dir" then append it */ size_t l; org = strstr(map, NISPLUS_ORGDIR); if (org == NULL) org = NISPLUS_ORGDIR; else org = ""; /* make some room for the NIS index */ l = sizeof('[') /* for opening selection criteria */ + sizeof(NISPLUS_KEY) + strlen(key) + sizeof(']') /* for closing selection criteria */ + sizeof(',') /* + 1 for , separator */ + strlen(map) + sizeof(NISPLUS_ORGDIR); index = xmalloc(l); if (index == NULL) { plog(XLOG_ERROR, "Unable to create index %s: %s", map, strerror(ENOMEM)); return ENOMEM; } xsnprintf(index, l, "[%s%s],%s%s", NISPLUS_KEY, key, map, org); data.key = key; data.value = NULL; dlog("NISplus search for %s", index); result = nis_list(index, EXPAND_NAME | FOLLOW_LINKS | FOLLOW_PATH, (int (*)()) nisplus_search_callback, &data); /* free off the NIS index */ XFREE(index); if (result == NULL) { plog(XLOG_ERROR, "nisplus_search: %s: %s", map, strerror(ENOMEM)); return ENOMEM; } /* * Do something interesting with the return code */ switch (result->status) { case NIS_SUCCESS: case NIS_CBRESULTS: if (data.value == NULL) { nis_object *value = result->objects.objects_val; dlog("NISplus search found "); dlog("NISplus search for %s: %s(%d)", map, nis_sperrno(result->status), result->status); if (value != NULL) data.value = strnsave(ENTRY_VAL(value, 1), ENTRY_LEN(value, 1)); } if (m->cfm && (m->cfm->cfm_flags & CFM_SUN_MAP_SYNTAX)) { *val = sun_entry2amd(key, data.value); XFREE(data.value); /* strnsave malloc'ed it above */ } else *val = data.value; if (*val) { error = 0; dlog("NISplus search found %s", *val); } else { error = ENOENT; dlog("NISplus search found nothing"); } *tp = 0; break; case NIS_NOSUCHNAME: dlog("NISplus search returned %d", result->status); error = ENOENT; break; default: plog(XLOG_ERROR, "nisplus_search: %s: %s", map, nis_sperrno(result->status)); error = EIO; break; } nis_freeresult(result); return error; } int nisplus_init(mnt_map *m, char *map, time_t *tp) { nis_result *result; char *org; /* if map does not have ".org_dir" then append it */ nis_name map_name; int error = 0; size_t l; org = strstr(map, NISPLUS_ORGDIR); if (org == NULL) org = NISPLUS_ORGDIR; else org = ""; /* make some room for the NIS map_name */ l = strlen(map) + sizeof(NISPLUS_ORGDIR); map_name = xmalloc(l); if (map_name == NULL) { plog(XLOG_ERROR, "Unable to create map_name %s: %s", map, strerror(ENOMEM)); return ENOMEM; } xsnprintf(map_name, l, "%s%s", map, org); result = nis_lookup(map_name, (EXPAND_NAME | FOLLOW_LINKS | FOLLOW_PATH)); /* free off the NIS map_name */ XFREE(map_name); if (result == NULL) { plog(XLOG_ERROR, "NISplus init <%s>: %s", map, strerror(ENOMEM)); return ENOMEM; } if (result->status != NIS_SUCCESS) { dlog("NISplus init <%s>: %s (%d)", map, nis_sperrno(result->status), result->status); error = ENOENT; } *tp = 0; /* no time */ nis_freeresult(result); return error; } int nisplus_mtime(mnt_map *m, char *map, time_t *tp) { return nisplus_init(m,map, tp); } am-utils-6.2+rc20110530/amd/info_passwd.c000066400000000000000000000123701157065440000175560ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/info_passwd.c * */ /* * Get info from password "file" * * This is experimental and probably doesn't do what you expect. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #define PASSWD_MAP "/etc/passwd" /* forward declarations */ int passwd_init(mnt_map *m, char *map, time_t *tp); int passwd_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp); /* * Nothing to probe - check the map name is PASSWD_MAP. */ int passwd_init(mnt_map *m, char *map, time_t *tp) { *tp = 0; /* * Recognize the old format "PASSWD_MAP" * Uses default return string * "type:=nfs;rfs:=/${var0}/${var1};rhost:=${var1};sublink:=${var2};fs:=${autodir}${var3}" */ if (STREQ(map, PASSWD_MAP)) return 0; /* * Recognize the new format "PASSWD_MAP:pval-format" */ if (!NSTREQ(map, PASSWD_MAP, sizeof(PASSWD_MAP) - 1)) return ENOENT; if (map[sizeof(PASSWD_MAP)-1] != ':') return ENOENT; return 0; } /* * Grab the entry via the getpwname routine * Modify time is ignored by passwd - XXX */ int passwd_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) { char *dir = NULL; struct passwd *pw; if (STREQ(key, "/defaults")) { *pval = strdup("type:=nfs"); return 0; } pw = getpwnam(key); if (pw) { /* * We chop the home directory up as follows: * /anydir/dom1/dom2/dom3/user * * and return * rfs:=/anydir/dom3;rhost:=dom3.dom2.dom1;sublink:=user * and now have * var0:=pw-prefix:=anydir * var1:=pw-rhost:=dom3.dom2.dom1 * var2:=pw-user:=user * var3:=pw-home:=/anydir/dom1/dom2/dom3/user * * This allows cross-domain entries in your passwd file. * ... but forget about security! */ char *user; char *p, *q; char val[MAXPATHLEN]; char rhost[MAXHOSTNAMELEN]; dir = strdup(pw->pw_dir); /* * Find user name. If no / then Invalid... */ user = strrchr(dir, '/'); if (!user) goto enoent; *user++ = '\0'; /* * Find start of host "path". If no / then Invalid... */ p = strchr(dir + 1, '/'); if (!p) goto enoent; *p++ = '\0'; /* * At this point, p is dom1/dom2/dom3 * Copy, backwards, into rhost replacing * / with . */ rhost[0] = '\0'; do { q = strrchr(p, '/'); if (q) { xstrlcat(rhost, q + 1, sizeof(rhost)); xstrlcat(rhost, ".", sizeof(rhost)); *q = '\0'; } else { xstrlcat(rhost, p, sizeof(rhost)); } } while (q); /* * Sanity check */ if (*rhost == '\0' || *user == '\0' || *dir == '\0') goto enoent; /* * Make up return string */ q = strchr(rhost, '.'); if (q) *q = '\0'; p = strchr(map, ':'); if (p) p++; else p = "type:=nfs;rfs:=/${var0}/${var1};rhost:=${var1};sublink:=${var2};fs:=${autodir}${var3}"; xsnprintf(val, sizeof(val), "var0:=%s;var1:=%s;var2:=%s;var3:=%s;%s", dir+1, rhost, user, pw->pw_dir, p); dlog("passwd_search: map=%s key=%s -> %s", map, key, val); if (q) *q = '.'; *pval = strdup(val); return 0; } enoent: if (dir) XFREE(dir); return ENOENT; } am-utils-6.2+rc20110530/amd/info_sun.c000066400000000000000000000046241157065440000170650ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/info_sun.c * */ /* * Get info from Sun automount-style /etc/auto_master, possibly following * into multiple info services (via /etc/nsswitch.conf). */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include /* XXX: just a placeholder. fill in */ am-utils-6.2+rc20110530/amd/info_union.c000066400000000000000000000104621157065440000174050ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/info_union.c * */ /* * Get info from the system namespace * * NOTE: Cannot handle reads back through the automounter. * THIS WILL CAUSE A DEADLOCK! */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #define UNION_PREFIX "union:" #define UNION_PREFLEN 6 /* forward declarations */ int union_init(mnt_map *m, char *map, time_t *tp); int union_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp); int union_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *)); /* * No way to probe - check the map name begins with "union:" */ int union_init(mnt_map *m, char *map, time_t *tp) { *tp = 0; return NSTREQ(map, UNION_PREFIX, UNION_PREFLEN) ? 0 : ENOENT; } int union_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) { char *mapd = strdup(map + UNION_PREFLEN); char **v = strsplit(mapd, ':', '\"'); char **p; size_t l; for (p = v; p[1]; p++) ; l = strlen(*p) + 5; *pval = xmalloc(l); xsnprintf(*pval, l, "fs:=%s", *p); XFREE(mapd); XFREE(v); return 0; } int union_reload(mnt_map *m, char *map, void (*fn) (mnt_map *, char *, char *)) { char *mapd = strdup(map + UNION_PREFLEN); char **v = strsplit(mapd, ':', '\"'); char **dir; /* * Add fake /defaults entry */ (*fn) (m, strdup("/defaults"), strdup("type:=link;opts:=nounmount;sublink:=${key}")); for (dir = v; *dir; dir++) { size_t l; struct dirent *dp; DIR *dirp = opendir(*dir); if (!dirp) { plog(XLOG_USER, "Cannot read directory %s: %m", *dir); continue; } l = strlen(*dir) + 5; dlog("Reading directory %s...", *dir); while ((dp = readdir(dirp))) { char *val, *dpname = &dp->d_name[0]; if (dpname[0] == '.' && (dpname[1] == '\0' || (dpname[1] == '.' && dpname[2] == '\0'))) continue; dlog("... gives %s", dp->d_name); val = xmalloc(l); xsnprintf(val, l + 5, "fs:=%s", *dir); (*fn) (m, strdup(dp->d_name), val); } closedir(dirp); } /* * Add wildcard entry */ { size_t l = strlen(*(dir-1)) + 5; char *val = xmalloc(l); xsnprintf(val, l, "fs:=%s", *(dir-1)); (*fn) (m, strdup("*"), val); } XFREE(mapd); XFREE(v); return 0; } am-utils-6.2+rc20110530/amd/map.c000066400000000000000000000617261157065440000160300ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/map.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #define smallest_t(t1, t2) (t1 != NEVER ? (t2 != NEVER ? (t1 < t2 ? t1 : t2) : t1) : t2) #define IGNORE_FLAGS (MFF_MOUNTING|MFF_UNMOUNTING|MFF_RESTART) #define new_gen() (am_gen++) /* * Generation Numbers. * * Generation numbers are allocated to every node created * by amd. When a filehandle is computed and sent to the * kernel, the generation number makes sure that it is safe * to reallocate a node slot even when the kernel has a cached * reference to its old incarnation. * No garbage collection is done, since it is assumed that * there is no way that 2^32 generation numbers could ever * be allocated by a single run of amd - there is simply * not enough cpu time available. * Famous last words... -Ion */ static u_int am_gen = 2; /* Initial generation number */ static int timeout_mp_id; /* Id from last call to timeout */ static am_node *root_node; /* The root of the mount tree */ static am_node **exported_ap = (am_node **) NULL; static int exported_ap_size = 0; static int first_free_map = 0; /* First available free slot */ static int last_used_map = -1; /* Last unavailable used slot */ /* * This is the default attributes field which * is copied into every new node to be created. * The individual filesystem fs_init() routines * patch the copy to represent the particular * details for the relevant filesystem type */ static nfsfattr gen_fattr = { NFLNK, /* type */ NFSMODE_LNK | 0777, /* mode */ 1, /* nlink */ 0, /* uid */ 0, /* gid */ 0, /* size */ 4096, /* blocksize */ 0, /* rdev */ 1, /* blocks */ 0, /* fsid */ 0, /* fileid */ {0, 0}, /* atime */ {0, 0}, /* mtime */ {0, 0}, /* ctime */ }; /* forward declarations */ static int unmount_node(opaque_t arg); static void exported_ap_free(am_node *mp); static void remove_am(am_node *mp); static am_node *get_root_ap(char *dir); /* * Iterator functions for exported_ap[] */ am_node * get_first_exported_ap(int *index) { *index = -1; return get_next_exported_ap(index); } am_node * get_next_exported_ap(int *index) { (*index)++; while (*index < exported_ap_size) { if (exported_ap[*index] != NULL) return exported_ap[*index]; (*index)++; } return NULL; } /* * Get exported_ap by index */ am_node * get_exported_ap(int index) { if (index < 0 || index >= exported_ap_size) return 0; return exported_ap[index]; } /* * Get exported_ap by path */ am_node * path_to_exported_ap(char *path) { int index; am_node *mp; mp = get_first_exported_ap(&index); while (mp != NULL) { if (STREQ(mp->am_path, path)) break; mp = get_next_exported_ap(&index); } return mp; } /* * Resize exported_ap map */ static int exported_ap_realloc_map(int nsize) { /* * this shouldn't happen, but... */ if (nsize < 0 || nsize == exported_ap_size) return 0; exported_ap = (am_node **) xrealloc((voidp) exported_ap, nsize * sizeof(am_node *)); if (nsize > exported_ap_size) memset((char *) (exported_ap + exported_ap_size), 0, (nsize - exported_ap_size) * sizeof(am_node *)); exported_ap_size = nsize; return 1; } am_node * get_ap_child(am_node *mp, char *fname) { am_node *new_mp; mntfs *mf = mp->am_al->al_mnt; /* * Allocate a new map */ new_mp = exported_ap_alloc(); if (new_mp) { /* * Fill it in */ init_map(new_mp, fname); /* * Put it in the table */ insert_am(new_mp, mp); /* * Fill in some other fields, * path and mount point. * * bugfix: do not prepend old am_path if direct map * William Sebok */ new_mp->am_path = str3cat(new_mp->am_path, (mf->mf_fsflags & FS_DIRECT) ? "" : mp->am_path, *fname == '/' ? "" : "/", fname); dlog("setting path to %s", new_mp->am_path); } return new_mp; } /* * Allocate a new mount slot and create * a new node. * Fills in the map number of the node, * but leaves everything else uninitialized. */ am_node * exported_ap_alloc(void) { am_node *mp, **mpp; /* * First check if there are any slots left, realloc if needed */ if (first_free_map >= exported_ap_size) if (!exported_ap_realloc_map(exported_ap_size + NEXP_AP)) return 0; /* * Grab the next free slot */ mpp = exported_ap + first_free_map; mp = *mpp = ALLOC(struct am_node); memset((char *) mp, 0, sizeof(struct am_node)); mp->am_mapno = first_free_map++; /* * Update free pointer */ while (first_free_map < exported_ap_size && exported_ap[first_free_map]) first_free_map++; if (first_free_map > last_used_map) last_used_map = first_free_map - 1; return mp; } /* * Free a mount slot */ static void exported_ap_free(am_node *mp) { /* * Sanity check */ if (!mp) return; /* * Zero the slot pointer to avoid double free's */ exported_ap[mp->am_mapno] = NULL; /* * Update the free and last_used indices */ if (mp->am_mapno == last_used_map) while (last_used_map >= 0 && exported_ap[last_used_map] == 0) --last_used_map; if (first_free_map > mp->am_mapno) first_free_map = mp->am_mapno; /* * Free the mount node, and zero out it's internal struct data. */ memset((char *) mp, 0, sizeof(am_node)); XFREE(mp); } /* * Insert mp into the correct place, * where p_mp is its parent node. * A new node gets placed as the youngest sibling * of any other children, and the parent's child * pointer is adjusted to point to the new child node. */ void insert_am(am_node *mp, am_node *p_mp) { /* * If this is going in at the root then flag it * so that it cannot be unmounted by amq. */ if (p_mp == root_node) mp->am_flags |= AMF_ROOT; /* * Fill in n-way links */ mp->am_parent = p_mp; mp->am_osib = p_mp->am_child; if (mp->am_osib) mp->am_osib->am_ysib = mp; p_mp->am_child = mp; #ifdef HAVE_FS_AUTOFS if (p_mp->am_al->al_mnt->mf_flags & MFF_IS_AUTOFS) mp->am_flags |= AMF_AUTOFS; #endif /* HAVE_FS_AUTOFS */ } /* * Remove am from its place in the mount tree */ static void remove_am(am_node *mp) { /* * 1. Consistency check */ if (mp->am_child && mp->am_parent) { plog(XLOG_WARNING, "children of \"%s\" still exist - deleting anyway", mp->am_path); } /* * 2. Update parent's child pointer */ if (mp->am_parent && mp->am_parent->am_child == mp) mp->am_parent->am_child = mp->am_osib; /* * 3. Unlink from sibling chain */ if (mp->am_ysib) mp->am_ysib->am_osib = mp->am_osib; if (mp->am_osib) mp->am_osib->am_ysib = mp->am_ysib; } /* * Compute a new time to live value for a node. */ void new_ttl(am_node *mp) { mp->am_timeo_w = 0; mp->am_ttl = clocktime(&mp->am_fattr.na_atime); mp->am_ttl += mp->am_timeo; /* sun's -tl option */ } void mk_fattr(nfsfattr *fattr, nfsftype vntype) { switch (vntype) { case NFDIR: fattr->na_type = NFDIR; fattr->na_mode = NFSMODE_DIR | 0555; fattr->na_nlink = 2; fattr->na_size = 512; break; case NFLNK: fattr->na_type = NFLNK; fattr->na_mode = NFSMODE_LNK | 0777; fattr->na_nlink = 1; fattr->na_size = 0; break; default: plog(XLOG_FATAL, "Unknown fattr type %d - ignored", vntype); break; } } /* * Initialize an allocated mount node. * It is assumed that the mount node was b-zero'd * before getting here so anything that would * be set to zero isn't done here. */ void init_map(am_node *mp, char *dir) { /* * mp->am_mapno is initialized by exported_ap_alloc * other fields don't need to be set to zero. */ mp->am_al = new_loc(); mp->am_alarray = NULL; mp->am_name = strdup(dir); mp->am_path = strdup(dir); mp->am_gen = new_gen(); #ifdef HAVE_FS_AUTOFS mp->am_autofs_fh = NULL; #endif /* HAVE_FS_AUTOFS */ mp->am_timeo = gopt.am_timeo; mp->am_attr.ns_status = NFS_OK; mp->am_fattr = gen_fattr; mp->am_fattr.na_fsid = 42; mp->am_fattr.na_fileid = mp->am_gen; clocktime(&mp->am_fattr.na_atime); /* next line copies a "struct nfstime" among several fields */ mp->am_fattr.na_mtime = mp->am_fattr.na_ctime = mp->am_fattr.na_atime; new_ttl(mp); mp->am_stats.s_mtime = mp->am_fattr.na_atime.nt_seconds; mp->am_dev = -1; mp->am_rdev = -1; mp->am_fd[0] = -1; mp->am_fd[1] = -1; } void notify_child(am_node *mp, au_etype au_etype, int au_errno, int au_signal) { amq_sync_umnt rv; int err; if (mp->am_fd[1] >= 0) { /* we have a child process */ rv.au_etype = au_etype; rv.au_signal = au_signal; rv.au_errno = au_errno; err = write(mp->am_fd[1], &rv, sizeof(rv)); /* XXX: do something else on err? */ if (err < sizeof(rv)) plog(XLOG_INFO, "notify_child: write returned %d instead of %d.", err, (int) sizeof(rv)); close(mp->am_fd[1]); mp->am_fd[1] = -1; } } /* * Free a mount node. * The node must be already unmounted. */ void free_map(am_node *mp) { remove_am(mp); if (mp->am_fd[1] != -1) plog(XLOG_FATAL, "free_map: called prior to notifying the child for %s.", mp->am_path); if (mp->am_link) XFREE(mp->am_link); if (mp->am_name) XFREE(mp->am_name); if (mp->am_path) XFREE(mp->am_path); if (mp->am_pref) XFREE(mp->am_pref); if (mp->am_transp) XFREE(mp->am_transp); if (mp->am_al) free_loc(mp->am_al); if (mp->am_alarray) { am_loc **temp_al; for (temp_al = mp->am_alarray; *temp_al; temp_al++) free_loc(*temp_al); XFREE(mp->am_alarray); } #ifdef HAVE_FS_AUTOFS if (mp->am_autofs_fh) autofs_release_fh(mp); #endif /* HAVE_FS_AUTOFS */ exported_ap_free(mp); } static am_node * find_ap_recursive(char *dir, am_node *mp) { if (mp) { am_node *mp2; if (STREQ(mp->am_path, dir)) return mp; if ((mp->am_al->al_mnt->mf_flags & MFF_MOUNTED) && STREQ(mp->am_al->al_mnt->mf_mount, dir)) return mp; mp2 = find_ap_recursive(dir, mp->am_osib); if (mp2) return mp2; return find_ap_recursive(dir, mp->am_child); } return 0; } /* * Find the mount node corresponding to dir. dir can match either the * automount path or, if the node is mounted, the mount location. */ am_node * find_ap(char *dir) { int i; for (i = last_used_map; i >= 0; --i) { am_node *mp = exported_ap[i]; if (mp && (mp->am_flags & AMF_ROOT)) { mp = find_ap_recursive(dir, exported_ap[i]); if (mp) { return mp; } } } return 0; } /* * Get the filehandle for a particular named directory. * This is used during the bootstrap to tell the kernel * the filehandles of the initial automount points. */ am_nfs_fh * get_root_nfs_fh(char *dir) { static am_nfs_fh nfh; am_node *mp = get_root_ap(dir); if (mp) { mp_to_fh(mp, &nfh); return &nfh; } /* * Should never get here... */ plog(XLOG_ERROR, "Can't find root filehandle for %s", dir); return 0; } static am_node * get_root_ap(char *dir) { am_node *mp = find_ap(dir); if (mp && mp->am_parent == root_node) return mp; return 0; } /* * Timeout all nodes waiting on * a given Fserver. */ void map_flush_srvr(fserver *fs) { int i; int done = 0; for (i = last_used_map; i >= 0; --i) { am_node *mp = exported_ap[i]; if (mp && mp->am_al->al_mnt && mp->am_al->al_mnt->mf_server == fs) { plog(XLOG_INFO, "Flushed %s; dependent on %s", mp->am_path, fs->fs_host); mp->am_ttl = clocktime(NULL); done = 1; } } if (done) reschedule_timeout_mp(); } /* * Mount a top level automount node * by calling lookup in the parent * (root) node which will cause the * automount node to be automounted. */ int mount_auto_node(char *dir, opaque_t arg) { int error = 0; am_node *mp = (am_node *) arg; am_node *new_mp; new_mp = mp->am_al->al_mnt->mf_ops->lookup_child(mp, dir, &error, VLOOK_CREATE); if (new_mp && error < 0) { /* * We can't allow the fileid of the root node to change. * Should be ok to force it to 1, always. */ new_mp->am_gen = new_mp->am_fattr.na_fileid = 1; new_mp = mp->am_al->al_mnt->mf_ops->mount_child(new_mp, &error); } if (error > 0) { errno = error; /* XXX */ plog(XLOG_ERROR, "Could not mount %s: %m", dir); } return error; } /* * Cause all the top-level mount nodes * to be automounted */ int mount_exported(void) { /* * Iterate over all the nodes to be started */ return root_keyiter(mount_auto_node, root_node); } /* * Construct top-level node */ void make_root_node(void) { mntfs *root_mf; char *rootmap = ROOT_MAP; root_node = exported_ap_alloc(); /* * Allocate a new map */ init_map(root_node, ""); /* * Allocate a new mounted filesystem */ root_mf = find_mntfs(&amfs_root_ops, (am_opts *) NULL, "", rootmap, "", "", ""); /* * Replace the initial null reference */ free_mntfs(root_node->am_al->al_mnt); root_node->am_al->al_mnt = root_mf; /* * Initialize the root */ if (root_mf->mf_ops->fs_init) (*root_mf->mf_ops->fs_init) (root_mf); /* * Mount the root */ root_mf->mf_error = root_mf->mf_ops->mount_fs(root_node, root_mf); } /* * Cause all the nodes to be unmounted by timing * them out. */ void umount_exported(void) { int i, work_done; do { work_done = 0; for (i = last_used_map; i >= 0; --i) { am_node *mp = exported_ap[i]; mntfs *mf; if (!mp) continue; /* * Wait for children to be removed first */ if (mp->am_child) continue; mf = mp->am_al->al_mnt; if (mf->mf_flags & MFF_UNMOUNTING) { /* * If this node is being unmounted then just ignore it. However, * this could prevent amd from finishing if the unmount gets blocked * since the am_node will never be free'd. am_unmounted needs * telling about this possibility. - XXX */ continue; } if (!(mf->mf_fsflags & FS_DIRECTORY)) /* * When shutting down this had better * look like a directory, otherwise it * can't be unmounted! */ mk_fattr(&mp->am_fattr, NFDIR); if ((--immediate_abort < 0 && !(mp->am_flags & AMF_ROOT) && mp->am_parent) || (mf->mf_flags & MFF_RESTART)) { work_done++; /* * Just throw this node away without bothering to unmount it. If * the server is not known to be up then don't discard the mounted * on directory or Amd might hang... */ if (mf->mf_server && (mf->mf_server->fs_flags & (FSF_DOWN | FSF_VALID)) != FSF_VALID) mf->mf_flags &= ~MFF_MKMNT; if (gopt.flags & CFM_UNMOUNT_ON_EXIT || mp->am_flags & AMF_AUTOFS) { plog(XLOG_INFO, "on-exit attempt to unmount %s", mf->mf_mount); /* * use unmount_mp, not unmount_node, so that unmounts be * backgrounded as needed. */ unmount_mp((opaque_t) mp); } else { am_unmounted(mp); } exported_ap[i] = NULL; } else { /* * Any other node gets forcibly timed out. */ mp->am_flags &= ~AMF_NOTIMEOUT; mp->am_al->al_mnt->mf_flags &= ~MFF_RSTKEEP; mp->am_ttl = 0; mp->am_timeo = 1; mp->am_timeo_w = 0; } } } while (work_done); } /* * Try to mount a file system. Can be called directly or in a sub-process by run_task. * * Warning: this function might be running in a child process context. * Don't expect any changes made here to survive in the parent amd process. */ int mount_node(opaque_t arg) { am_node *mp = (am_node *) arg; mntfs *mf = mp->am_al->al_mnt; int error = 0; #ifdef HAVE_FS_AUTOFS if (mp->am_flags & AMF_AUTOFS) error = autofs_mount_fs(mp, mf); else #endif /* HAVE_FS_AUTOFS */ if (!(mf->mf_flags & MFF_MOUNTED)) error = mf->mf_ops->mount_fs(mp, mf); if (error > 0) dlog("mount_node: call to mf_ops->mount_fs(%s) failed: %s", mp->am_path, strerror(error)); return error; } static int unmount_node(opaque_t arg) { am_node *mp = (am_node *) arg; mntfs *mf = mp->am_al->al_mnt; int error = 0; if (mf->mf_flags & MFF_ERROR) { /* * Just unlink */ dlog("No-op unmount of error node %s", mf->mf_info); } else { dlog("Unmounting <%s> <%s> (%s) flags %x", mp->am_path, mf->mf_mount, mf->mf_info, mf->mf_flags); #ifdef HAVE_FS_AUTOFS if (mp->am_flags & AMF_AUTOFS) error = autofs_umount_fs(mp, mf); else #endif /* HAVE_FS_AUTOFS */ if (mf->mf_refc == 1) error = mf->mf_ops->umount_fs(mp, mf); } /* do this again, it might have changed */ mf = mp->am_al->al_mnt; if (error) { errno = error; /* XXX */ dlog("%s: unmount: %m", mf->mf_mount); } return error; } static void free_map_if_success(int rc, int term, opaque_t arg) { am_node *mp = (am_node *) arg; mntfs *mf = mp->am_al->al_mnt; wchan_t wchan = get_mntfs_wchan(mf); /* * Not unmounting any more */ mf->mf_flags &= ~MFF_UNMOUNTING; /* * If a timeout was deferred because the underlying filesystem * was busy then arrange for a timeout as soon as possible. */ if (mf->mf_flags & MFF_WANTTIMO) { mf->mf_flags &= ~MFF_WANTTIMO; reschedule_timeout_mp(); } if (term) { notify_child(mp, AMQ_UMNT_SIGNAL, 0, term); plog(XLOG_ERROR, "unmount for %s got signal %d", mp->am_path, term); #if defined(DEBUG) && defined(SIGTRAP) /* * dbx likes to put a trap on exit(). * Pretend it succeeded for now... */ if (term == SIGTRAP) { am_unmounted(mp); } #endif /* DEBUG */ #ifdef HAVE_FS_AUTOFS if (mp->am_flags & AMF_AUTOFS) autofs_umount_failed(mp); #endif /* HAVE_FS_AUTOFS */ amd_stats.d_uerr++; } else if (rc) { notify_child(mp, AMQ_UMNT_FAILED, rc, 0); if (mf->mf_ops == &amfs_program_ops || rc == EBUSY) plog(XLOG_STATS, "\"%s\" on %s still active", mp->am_path, mf->mf_mount); else plog(XLOG_ERROR, "%s: unmount: %s", mp->am_path, strerror(rc)); #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS) autofs_get_mp(mp); if (mp->am_flags & AMF_AUTOFS) autofs_umount_failed(mp); #endif /* HAVE_FS_AUTOFS */ amd_stats.d_uerr++; } else { /* * am_unmounted() will call notify_child() appropriately. */ am_unmounted(mp); } /* * Wakeup anything waiting for this unmount */ wakeup(wchan); } int unmount_mp(am_node *mp) { int was_backgrounded = 0; mntfs *mf = mp->am_al->al_mnt; #ifdef notdef plog(XLOG_INFO, "\"%s\" on %s timed out (flags 0x%x)", mp->am_path, mf->mf_mount, (int) mf->mf_flags); #endif /* notdef */ #ifndef MNT2_NFS_OPT_SYMTTL /* * This code is needed to defeat Solaris 2.4's (and newer) symlink * values cache. It forces the last-modified time of the symlink to be * current. It is not needed if the O/S has an nfs flag to turn off the * symlink-cache at mount time (such as Irix 5.x and 6.x). -Erez. * * Additionally, Linux currently ignores the nt_useconds field, * so we must update the nt_seconds field every time if clocktime(NULL) * didn't return a new number of seconds. */ if (mp->am_parent) { time_t last = mp->am_parent->am_attr.ns_u.ns_attr_u.na_mtime.nt_seconds; clocktime(&mp->am_parent->am_attr.ns_u.ns_attr_u.na_mtime); /* defensive programming... can't we assert the above condition? */ if (last == (time_t) mp->am_parent->am_attr.ns_u.ns_attr_u.na_mtime.nt_seconds) mp->am_parent->am_attr.ns_u.ns_attr_u.na_mtime.nt_seconds++; } #endif /* not MNT2_NFS_OPT_SYMTTL */ if (mf->mf_refc == 1 && !FSRV_ISUP(mf->mf_server)) { /* * Don't try to unmount from a server that is known to be down */ if (!(mf->mf_flags & MFF_LOGDOWN)) { /* Only log this once, otherwise gets a bit boring */ plog(XLOG_STATS, "file server %s is down - timeout of \"%s\" ignored", mf->mf_server->fs_host, mp->am_path); mf->mf_flags |= MFF_LOGDOWN; } notify_child(mp, AMQ_UMNT_SERVER, 0, 0); return 0; } dlog("\"%s\" on %s timed out", mp->am_path, mf->mf_mount); mf->mf_flags |= MFF_UNMOUNTING; #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS) autofs_release_mp(mp); #endif /* HAVE_FS_AUTOFS */ if ((mf->mf_fsflags & FS_UBACKGROUND) && (mf->mf_flags & MFF_MOUNTED)) { dlog("Trying unmount in background"); run_task(unmount_node, (opaque_t) mp, free_map_if_success, (opaque_t) mp); was_backgrounded = 1; } else { dlog("Trying unmount in foreground"); free_map_if_success(unmount_node((opaque_t) mp), 0, (opaque_t) mp); dlog("unmount attempt done"); } return was_backgrounded; } void timeout_mp(opaque_t v) /* argument not used?! */ { int i; time_t t = NEVER; time_t now = clocktime(NULL); int backoff = NumChildren / 4; dlog("Timing out automount points..."); for (i = last_used_map; i >= 0; --i) { am_node *mp = exported_ap[i]; mntfs *mf; /* * Just continue if nothing mounted */ if (!mp) continue; /* * Pick up mounted filesystem */ mf = mp->am_al->al_mnt; if (!mf) continue; #ifdef HAVE_FS_AUTOFS if (mf->mf_flags & MFF_IS_AUTOFS && mp->am_autofs_ttl != NEVER) { if (now >= mp->am_autofs_ttl) autofs_timeout_mp(mp); t = smallest_t(t, mp->am_autofs_ttl); } #endif /* HAVE_FS_AUTOFS */ if (mp->am_flags & AMF_NOTIMEOUT) continue; /* * Don't delete last reference to a restarted filesystem. */ if ((mf->mf_flags & MFF_RSTKEEP) && mf->mf_refc == 1) continue; /* * If there is action on this filesystem then ignore it */ if (!(mf->mf_flags & IGNORE_FLAGS)) { int expired = 0; mf->mf_flags &= ~MFF_WANTTIMO; if (now >= mp->am_ttl) { if (!backoff) { expired = 1; /* * Move the ttl forward to avoid thrashing effects * on the next call to timeout! */ /* sun's -tw option */ if (mp->am_timeo_w < 4 * gopt.am_timeo_w) mp->am_timeo_w += gopt.am_timeo_w; mp->am_ttl = now + mp->am_timeo_w; } else { /* * Just backoff this unmount for * a couple of seconds to avoid * many multiple unmounts being * started in parallel. */ mp->am_ttl = now + backoff + 1; } } /* * If the next ttl is smallest, use that */ t = smallest_t(t, mp->am_ttl); if (!mp->am_child && mf->mf_error >= 0 && expired) { /* * If the unmount was backgrounded then * bump the backoff counter. */ if (unmount_mp(mp)) { backoff = 2; } } } else if (mf->mf_flags & MFF_UNMOUNTING) { mf->mf_flags |= MFF_WANTTIMO; } } if (t == NEVER) { dlog("No further timeouts"); t = now + ONE_HOUR; } /* * Sanity check to avoid runaways. * Absolutely should never get this but * if you do without this trap amd will thrash. */ if (t <= now) { t = now + 6; /* XXX */ plog(XLOG_ERROR, "Got a zero interval in timeout_mp()!"); } /* * XXX - when shutting down, make things happen faster */ if ((int) amd_state >= (int) Finishing) t = now + 1; dlog("Next mount timeout in %lds", (long) (t - now)); timeout_mp_id = timeout(t - now, timeout_mp, NULL); } /* * Cause timeout_mp to be called soonest */ void reschedule_timeout_mp(void) { if (timeout_mp_id) untimeout(timeout_mp_id); timeout_mp_id = timeout(0, timeout_mp, NULL); } am-utils-6.2+rc20110530/amd/mapc.c000066400000000000000000000677551157065440000162030ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/mapc.c * */ /* * Mount map cache */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Make a duplicate reference to an existing map */ #define mapc_dup(m) ((m)->refc++, (m)) /* * Map cache types * default, none, incremental, all, regexp * MAPC_RE implies MAPC_ALL and must be numerically * greater. */ #define MAPC_DFLT 0x000 #define MAPC_NONE 0x001 #define MAPC_INC 0x002 #define MAPC_ROOT 0x004 #define MAPC_ALL 0x010 #define MAPC_CACHE_MASK 0x0ff #define MAPC_SYNC 0x100 #ifdef HAVE_REGEXEC # define MAPC_RE 0x020 # define MAPC_ISRE(m) ((m)->alloc == MAPC_RE) #else /* not HAVE_REGEXEC */ # define MAPC_ISRE(m) FALSE #endif /* not HAVE_REGEXEC */ /* * Lookup recursion */ #define MREC_FULL 2 #define MREC_PART 1 #define MREC_NONE 0 static struct opt_tab mapc_opt[] = { {"all", MAPC_ALL}, {"default", MAPC_DFLT}, {"inc", MAPC_INC}, {"mapdefault", MAPC_DFLT}, {"none", MAPC_NONE}, #ifdef HAVE_REGEXEC {"re", MAPC_RE}, {"regexp", MAPC_RE}, #endif /* HAVE_REGEXEC */ {"sync", MAPC_SYNC}, {NULL, 0} }; /* * Wildcard key */ static char wildcard[] = "*"; /* * Map type */ typedef struct map_type map_type; struct map_type { char *name; /* Name of this map type */ init_fn *init; /* Initialization */ reload_fn *reload; /* Reload or fill */ isup_fn *isup; /* Is service up or not? (1=up, 0=down) */ search_fn *search; /* Search for new entry */ mtime_fn *mtime; /* Find modify time */ int def_alloc; /* Default allocation mode */ }; /* * Map for root node */ static mnt_map *root_map; /* * List of known maps */ qelem map_list_head = {&map_list_head, &map_list_head}; /* * Configuration */ /* forward definitions */ static const char *get_full_path(const char *map, const char *path, const char *type); static int mapc_meta_search(mnt_map *, char *, char **, int); static void mapc_sync(mnt_map *); static void mapc_clear(mnt_map *); /* ROOT MAP */ static int root_init(mnt_map *, char *, time_t *); /* ERROR MAP */ static int error_init(mnt_map *, char *, time_t *); static int error_reload(mnt_map *, char *, add_fn *); static int error_search(mnt_map *, char *, char *, char **, time_t *); static int error_mtime(mnt_map *, char *, time_t *); /* PASSWD MAPS */ #ifdef HAVE_MAP_PASSWD extern int passwd_init(mnt_map *, char *, time_t *); extern int passwd_search(mnt_map *, char *, char *, char **, time_t *); #endif /* HAVE_MAP_PASSWD */ /* HESIOD MAPS */ #ifdef HAVE_MAP_HESIOD extern int amu_hesiod_init(mnt_map *, char *map, time_t *tp); extern int hesiod_isup(mnt_map *, char *); extern int hesiod_search(mnt_map *, char *, char *, char **, time_t *); #endif /* HAVE_MAP_HESIOD */ /* LDAP MAPS */ #ifdef HAVE_MAP_LDAP extern int amu_ldap_init(mnt_map *, char *map, time_t *tp); extern int amu_ldap_search(mnt_map *, char *, char *, char **, time_t *); extern int amu_ldap_mtime(mnt_map *, char *, time_t *); #endif /* HAVE_MAP_LDAP */ /* UNION MAPS */ #ifdef HAVE_MAP_UNION extern int union_init(mnt_map *, char *, time_t *); extern int union_search(mnt_map *, char *, char *, char **, time_t *); extern int union_reload(mnt_map *, char *, add_fn *); #endif /* HAVE_MAP_UNION */ /* Network Information Service PLUS (NIS+) */ #ifdef HAVE_MAP_NISPLUS extern int nisplus_init(mnt_map *, char *, time_t *); extern int nisplus_reload(mnt_map *, char *, add_fn *); extern int nisplus_search(mnt_map *, char *, char *, char **, time_t *); extern int nisplus_mtime(mnt_map *, char *, time_t *); #endif /* HAVE_MAP_NISPLUS */ /* Network Information Service (YP, Yellow Pages) */ #ifdef HAVE_MAP_NIS extern int nis_init(mnt_map *, char *, time_t *); extern int nis_reload(mnt_map *, char *, add_fn *); extern int nis_isup(mnt_map *, char *); extern int nis_search(mnt_map *, char *, char *, char **, time_t *); extern int nis_mtime(mnt_map *, char *, time_t *); #endif /* HAVE_MAP_NIS */ /* NDBM MAPS */ #ifdef HAVE_MAP_NDBM extern int ndbm_init(mnt_map *, char *, time_t *); extern int ndbm_search(mnt_map *, char *, char *, char **, time_t *); extern int ndbm_mtime(mnt_map *, char *, time_t *); #endif /* HAVE_MAP_NDBM */ /* FILE MAPS */ #ifdef HAVE_MAP_FILE extern int file_init_or_mtime(mnt_map *, char *, time_t *); extern int file_reload(mnt_map *, char *, add_fn *); extern int file_search(mnt_map *, char *, char *, char **, time_t *); #endif /* HAVE_MAP_FILE */ /* EXECUTABLE MAPS */ #ifdef HAVE_MAP_EXEC extern int exec_init(mnt_map *, char *, time_t *); extern int exec_search(mnt_map *, char *, char *, char **, time_t *); #endif /* HAVE_MAP_EXEC */ /* Sun-syntax MAPS */ #ifdef HAVE_MAP_SUN /* XXX: fill in */ #endif /* HAVE_MAP_SUN */ /* note that the choice of MAPC_{INC,ALL} will affect browsable_dirs */ static map_type maptypes[] = { { "root", root_init, error_reload, NULL, /* isup function */ error_search, error_mtime, MAPC_ROOT }, #ifdef HAVE_MAP_PASSWD { "passwd", passwd_init, error_reload, NULL, /* isup function */ passwd_search, error_mtime, MAPC_INC }, #endif /* HAVE_MAP_PASSWD */ #ifdef HAVE_MAP_HESIOD { "hesiod", amu_hesiod_init, error_reload, hesiod_isup, /* is Hesiod up or not? */ hesiod_search, error_mtime, MAPC_INC }, #endif /* HAVE_MAP_HESIOD */ #ifdef HAVE_MAP_LDAP { "ldap", amu_ldap_init, error_reload, NULL, /* isup function */ amu_ldap_search, amu_ldap_mtime, MAPC_INC }, #endif /* HAVE_MAP_LDAP */ #ifdef HAVE_MAP_UNION { "union", union_init, union_reload, NULL, /* isup function */ union_search, error_mtime, MAPC_ALL }, #endif /* HAVE_MAP_UNION */ #ifdef HAVE_MAP_NISPLUS { "nisplus", nisplus_init, nisplus_reload, NULL, /* isup function */ nisplus_search, nisplus_mtime, MAPC_INC }, #endif /* HAVE_MAP_NISPLUS */ #ifdef HAVE_MAP_NIS { "nis", nis_init, nis_reload, nis_isup, /* is NIS up or not? */ nis_search, nis_mtime, MAPC_ALL }, #endif /* HAVE_MAP_NIS */ #ifdef HAVE_MAP_NDBM { "ndbm", ndbm_init, error_reload, NULL, /* isup function */ ndbm_search, ndbm_mtime, MAPC_INC }, #endif /* HAVE_MAP_NDBM */ #ifdef HAVE_MAP_FILE { "file", file_init_or_mtime, file_reload, NULL, /* isup function */ file_search, file_init_or_mtime, MAPC_ALL }, #endif /* HAVE_MAP_FILE */ #ifdef HAVE_MAP_EXEC { "exec", exec_init, error_reload, NULL, /* isup function */ exec_search, error_mtime, MAPC_INC }, #endif /* HAVE_MAP_EXEC */ #ifdef HAVE_MAP_SUN { /* XXX: fill in */ "sun", NULL, NULL, NULL, /* isup function */ NULL, NULL, 0 }, #endif /* HAVE_MAP_SUN */ { "error", error_init, error_reload, NULL, /* isup function */ error_search, error_mtime, MAPC_NONE }, }; /* * Hash function */ static u_int kvhash_of(char *key) { u_int i, j; for (i = 0; (j = *key++); i += j) ; return i % NKVHASH; } void mapc_showtypes(char *buf, size_t l) { map_type *mt=NULL, *lastmt; int linesize = 0, i; i = sizeof(maptypes) / sizeof(maptypes[0]); lastmt = maptypes + i; buf[0] = '\0'; for (mt = maptypes; mt < lastmt; mt++) { xstrlcat(buf, mt->name, l); if (mt == (lastmt-1)) break; /* if last one, don't do xstrlcat's that follows */ linesize += strlen(mt->name); if (--i > 0) { xstrlcat(buf, ", ", l); linesize += 2; } if (linesize > 54) { linesize = 0; xstrlcat(buf, "\n\t\t ", l); } } } /* * Check if a map of a certain type exists. * Return 1 (true) if exists, 0 (false) if not. */ int mapc_type_exists(const char *type) { map_type *mt; if (!type) return 0; for (mt = maptypes; mt < maptypes + sizeof(maptypes) / sizeof(maptypes[0]); mt++) { if (STREQ(type, mt->name)) return 1; } return 0; /* not found anywhere */ } /* * Add key and val to the map m. * key and val are assumed to be safe copies */ void mapc_add_kv(mnt_map *m, char *key, char *val) { kv **h; kv *n; int hash = kvhash_of(key); #ifdef HAVE_REGEXEC regex_t re; #endif /* HAVE_REGEXEC */ dlog("add_kv: %s -> %s", key, val); if (val != NULL && strchr(val, '\n') != NULL) { /* * If the entry value contains multiple lines we need to break * them up and add them recursively. This is a workaround to * support Sun style multi-mounts. Amd converts Sun style * mulit-mounts to type:=auto. The problem is that Sun packs all * the entries on one line. When Amd does the conversion it puts * each type:=auto entry on the same line separated by '\n'. */ char *entry, *tok; /* * The first line should contain the first entry. The key for * this entry is the key passed into this function. */ if ((tok = strtok(val, "\n")) != NULL) { mapc_add_kv(m, key, strdup(tok)); } /* * For the rest of the entries we need to tokenize them by '\n' * and separate the keys from there entries. */ while ((tok = strtok(NULL, "\n")) != NULL) { key = tok; /* find the entry */ for (entry = key; *entry && !isspace((unsigned char)*entry); entry++); if (*entry) { *entry++ = '\0'; } mapc_add_kv(m, strdup(key), strdup(entry)); } XFREE(val); return; } #ifdef HAVE_REGEXEC if (MAPC_ISRE(m)) { char pattern[MAXPATHLEN]; int retval; /* * Make sure the string is bound to the start and end */ xsnprintf(pattern, sizeof(pattern), "^%s$", key); retval = regcomp(&re, pattern, REG_ICASE); if (retval != 0) { char errstr[256]; /* XXX: this code was recently ported, and must be tested -Erez */ errstr[0] = '\0'; regerror(retval, &re, errstr, 256); plog(XLOG_USER, "error compiling RE \"%s\": %s", pattern, errstr); return; } } #endif /* HAVE_REGEXEC */ h = &m->kvhash[hash]; n = ALLOC(struct kv); n->key = key; #ifdef HAVE_REGEXEC memcpy(&n->re, &re, sizeof(regex_t)); #endif /* HAVE_REGEXEC */ n->val = val; n->next = *h; *h = n; } static void mapc_repl_kv(mnt_map *m, char *key, char *val) { kv *k; /* * Compute the hash table offset */ k = m->kvhash[kvhash_of(key)]; /* * Scan the linked list for the key */ while (k && !FSTREQ(k->key, key)) k = k->next; if (k) { XFREE(k->val); k->val = val; } else { mapc_add_kv(m, key, val); } } /* * Search a map for a key. * Calls map specific search routine. * While map is out of date, keep re-syncing. */ static int search_map(mnt_map *m, char *key, char **valp) { int rc; do { rc = (*m->search) (m, m->map_name, key, valp, &m->modify); if (rc < 0) { plog(XLOG_MAP, "Re-synchronizing cache for map %s", m->map_name); mapc_sync(m); } } while (rc < 0); return rc; } /* * Do a wildcard lookup in the map and * save the result. */ static void mapc_find_wildcard(mnt_map *m) { /* * Attempt to find the wildcard entry */ int rc = search_map(m, wildcard, &m->wildcard); if (rc != 0) m->wildcard = NULL; } /* * Do a map reload. * Attempt to reload without losing current data by switching the hashes * round. * If reloading was needed and succeeded, return 1; else return 0. */ static int mapc_reload_map(mnt_map *m) { int error, ret = 0; kv *maphash[NKVHASH], *tmphash[NKVHASH]; time_t t; error = (*m->mtime) (m, m->map_name, &t); if (error) { t = m->modify; } /* * skip reloading maps that have not been modified, unless * amq -f was used (do_mapc_reload is 0) */ if (m->reloads != 0 && do_mapc_reload != 0) { if (t <= m->modify) { plog(XLOG_INFO, "reload of map %s is not needed (in sync)", m->map_name); dlog("map %s last load time is %d, last modify time is %d", m->map_name, (int) m->modify, (int) t); return ret; } } /* copy the old hash and zero the map */ memcpy((voidp) maphash, (voidp) m->kvhash, sizeof(m->kvhash)); memset((voidp) m->kvhash, 0, sizeof(m->kvhash)); dlog("calling map reload on %s", m->map_name); error = (*m->reload) (m, m->map_name, mapc_add_kv); if (error) { if (m->reloads == 0) plog(XLOG_FATAL, "first time load of map %s failed!", m->map_name); else plog(XLOG_ERROR, "reload of map %s failed - using old values", m->map_name); mapc_clear(m); memcpy((voidp) m->kvhash, (voidp) maphash, sizeof(m->kvhash)); } else { if (m->reloads++ == 0) plog(XLOG_INFO, "first time load of map %s succeeded", m->map_name); else plog(XLOG_INFO, "reload #%d of map %s succeeded", m->reloads, m->map_name); memcpy((voidp) tmphash, (voidp) m->kvhash, sizeof(m->kvhash)); memcpy((voidp) m->kvhash, (voidp) maphash, sizeof(m->kvhash)); mapc_clear(m); memcpy((voidp) m->kvhash, (voidp) tmphash, sizeof(m->kvhash)); m->modify = t; ret = 1; } m->wildcard = NULL; dlog("calling mapc_search for wildcard"); error = mapc_search(m, wildcard, &m->wildcard); if (error) m->wildcard = NULL; return ret; } /* * Create a new map */ static mnt_map * mapc_create(char *map, char *opt, const char *type, const char *mntpt) { mnt_map *m = ALLOC(struct mnt_map); map_type *mt; time_t modify = 0; u_int alloc = 0; cmdoption(opt, mapc_opt, &alloc); /* * If using a configuration file, and the map_type is defined, then look * for it, in the maptypes array. If found, initialize the map using that * map_type. If not found, return error. If no map_type was defined, * default to cycling through all maptypes. */ if (use_conf_file && type) { /* find what type of map this one is */ for (mt = maptypes; mt < maptypes + sizeof(maptypes) / sizeof(maptypes[0]); mt++) { if (STREQ(type, mt->name)) { plog(XLOG_INFO, "initializing amd.conf map %s of type %s", map, type); if ((*mt->init) (m, map, &modify) == 0) { break; } else { plog(XLOG_ERROR, "failed to initialize map %s", map); error_init(m, map, &modify); break; } } } /* end of "for (mt =" loop */ } else { /* cycle through all known maptypes */ /* * not using amd conf file or using it by w/o specifying map type */ for (mt = maptypes; mt < maptypes + sizeof(maptypes) / sizeof(maptypes[0]); mt++) { dlog("trying to initialize map %s of type %s ...", map, mt->name); if ((*mt->init) (m, map, &modify) == 0) { break; } } } /* end of "if (use_conf_file && (colpos = strchr ..." statement */ /* assert: mt in maptypes */ m->flags = alloc & ~MAPC_CACHE_MASK; alloc &= MAPC_CACHE_MASK; if (alloc == MAPC_DFLT) alloc = mt->def_alloc; switch (alloc) { default: plog(XLOG_USER, "Ambiguous map cache type \"%s\"; using \"inc\"", opt); alloc = MAPC_INC; /* fall-through... */ case MAPC_NONE: case MAPC_INC: case MAPC_ROOT: break; case MAPC_ALL: /* * If there is no support for reload and it was requested * then back off to incremental instead. */ if (mt->reload == error_reload) { plog(XLOG_WARNING, "Map type \"%s\" does not support cache type \"all\"; using \"inc\"", mt->name); alloc = MAPC_INC; } break; #ifdef HAVE_REGEXEC case MAPC_RE: if (mt->reload == error_reload) { plog(XLOG_WARNING, "Map type \"%s\" does not support cache type \"re\"", mt->name); mt = &maptypes[sizeof(maptypes) / sizeof(maptypes[0]) - 1]; /* assert: mt->name == "error" */ } break; #endif /* HAVE_REGEXEC */ } dlog("Map for %s coming from maptype %s", map, mt->name); m->alloc = alloc; m->reload = mt->reload; m->isup = mt->isup; m->modify = modify; m->search = alloc >= MAPC_ALL ? error_search : mt->search; m->mtime = mt->mtime; memset((voidp) m->kvhash, 0, sizeof(m->kvhash)); m->map_name = strdup(map); m->refc = 1; m->wildcard = NULL; m->reloads = 0; /* initialize per-map information (flags, etc.) */ m->cfm = find_cf_map(mntpt); /* * synchronize cache with reality */ mapc_sync(m); return m; } /* * Free the cached data in a map */ static void mapc_clear(mnt_map *m) { int i; /* * For each of the hash slots, chain * along free'ing the data. */ for (i = 0; i < NKVHASH; i++) { kv *k = m->kvhash[i]; while (k) { kv *n = k->next; XFREE(k->key); if (k->val) XFREE(k->val); XFREE(k); k = n; } } /* * Zero the hash slots */ memset((voidp) m->kvhash, 0, sizeof(m->kvhash)); /* * Free the wildcard if it exists */ if (m->wildcard) XFREE(m->wildcard); } /* * Find a map, or create one if it does not exist */ mnt_map * mapc_find(char *map, char *opt, const char *maptype, const char *mntpt) { mnt_map *m; /* * Search the list of known maps to see if * it has already been loaded. If it is found * then return a duplicate reference to it. * Otherwise make a new map as required and * add it to the list of maps */ ITER(m, mnt_map, &map_list_head) if (STREQ(m->map_name, map)) return mapc_dup(m); m = mapc_create(map, opt, maptype, mntpt); ins_que(&m->hdr, &map_list_head); return m; } /* * Free a map. */ void mapc_free(opaque_t arg) { mnt_map *m = (mnt_map *) arg; /* * Decrement the reference count. * If the reference count hits zero * then throw the map away. */ if (m && --m->refc == 0) { mapc_clear(m); XFREE(m->map_name); rem_que(&m->hdr); XFREE(m); } } /* * Search the map for the key. Put a safe (malloc'ed) copy in *pval or * return an error code */ static int mapc_meta_search(mnt_map *m, char *key, char **pval, int recurse) { int error = 0; kv *k = NULL; /* * Firewall */ if (!m) { plog(XLOG_ERROR, "Null map request for %s", key); return ENOENT; } if (m->flags & MAPC_SYNC) { /* * Get modify time... */ time_t t; error = (*m->mtime) (m, m->map_name, &t); if (error || t > m->modify) { plog(XLOG_INFO, "Map %s is out of date", m->map_name); mapc_sync(m); } } if (!MAPC_ISRE(m)) { /* * Compute the hash table offset */ k = m->kvhash[kvhash_of(key)]; /* * Scan the linked list for the key */ while (k && !FSTREQ(k->key, key)) k = k->next; } #ifdef HAVE_REGEXEC else if (recurse == MREC_FULL) { /* * Try for an RE match against the entire map. * Note that this will be done in a "random" * order. */ int i; for (i = 0; i < NKVHASH; i++) { k = m->kvhash[i]; while (k) { int retval; /* XXX: this code was recently ported, and must be tested -Erez */ retval = regexec(&k->re, key, 0, NULL, 0); if (retval == 0) { /* succeeded */ break; } else { /* failed to match, log error */ char errstr[256]; errstr[0] = '\0'; regerror(retval, &k->re, errstr, 256); plog(XLOG_USER, "error matching RE \"%s\" against \"%s\": %s", key, k->key, errstr); } k = k->next; } if (k) break; } } #endif /* HAVE_REGEXEC */ /* * If found then take a copy */ if (k) { if (k->val) *pval = strdup(k->val); else error = ENOENT; } else if (m->alloc >= MAPC_ALL) { /* * If the entire map is cached then this * key does not exist. */ error = ENOENT; } else { /* * Otherwise search the map. If we are * in incremental mode then add the key * to the cache. */ error = search_map(m, key, pval); if (!error && m->alloc == MAPC_INC) mapc_add_kv(m, strdup(key), strdup(*pval)); } /* * If an error, and a wildcard exists, * and the key is not internal then * return a copy of the wildcard. */ if (error > 0) { if (recurse == MREC_FULL && !MAPC_ISRE(m)) { char wildname[MAXPATHLEN]; char *subp; if (*key == '/') return error; /* * Keep chopping sub-directories from the RHS * and replacing with "/ *" and repeat the lookup. * For example: * "src/gnu/gcc" -> "src / gnu / *" -> "src / *" */ xstrlcpy(wildname, key, sizeof(wildname)); while (error && (subp = strrchr(wildname, '/'))) { /* * sizeof space left in subp is sizeof wildname minus what's left * after the strchr above returned a pointer inside wildname into * subp. */ xstrlcpy(subp, "/*", sizeof(wildname) - (subp - wildname)); dlog("mapc recurses on %s", wildname); error = mapc_meta_search(m, wildname, pval, MREC_PART); if (error) *subp = '\0'; } if (error > 0 && m->wildcard) { *pval = strdup(m->wildcard); error = 0; } } } return error; } int mapc_search(mnt_map *m, char *key, char **pval) { return mapc_meta_search(m, key, pval, MREC_FULL); } /* * Get map cache in sync with physical representation */ static void mapc_sync(mnt_map *m) { int need_mtime_update = 0; if (m->alloc == MAPC_ROOT) return; /* nothing to do */ /* do not clear map if map service is down */ if (m->isup) { if (!((*m->isup)(m, m->map_name))) { plog(XLOG_ERROR, "mapc_sync: map %s is down: not clearing map", m->map_name); return; } } if (m->alloc >= MAPC_ALL) { /* mapc_reload_map() always works */ need_mtime_update = mapc_reload_map(m); } else { mapc_clear(m); /* * Attempt to find the wildcard entry */ mapc_find_wildcard(m); need_mtime_update = 1; /* because mapc_clear always works */ } /* * To be safe, update the mtime of the mnt_map's own node, so that the * kernel will flush all of its cached entries. */ if (need_mtime_update && m->cfm) { am_node *mp = find_ap(m->cfm->cfm_dir); if (mp) { clocktime(&mp->am_fattr.na_mtime); } else { plog(XLOG_ERROR, "cannot find map %s to update its mtime", m->cfm->cfm_dir); } } } /* * Reload all the maps * Called when Amd gets hit by a SIGHUP. */ void mapc_reload(void) { mnt_map *m; /* * For all the maps, * Throw away the existing information. * Do a reload * Find the wildcard */ ITER(m, mnt_map, &map_list_head) mapc_sync(m); } /* * Root map. * The root map is used to bootstrap amd. * All the require top-level mounts are added * into the root map and then the map is iterated * and a lookup is done on all the mount points. * This causes the top level mounts to be automounted. */ static int root_init(mnt_map *m, char *map, time_t *tp) { *tp = clocktime(NULL); return STREQ(map, ROOT_MAP) ? 0 : ENOENT; } /* * Add a new entry to the root map * * dir - directory (key) * opts - mount options * map - map name * cfm - optional amd configuration file map section structure */ void root_newmap(const char *dir, const char *opts, const char *map, const cf_map_t *cfm) { char str[MAXPATHLEN]; /* * First make sure we have a root map to talk about... */ if (!root_map) root_map = mapc_find(ROOT_MAP, "mapdefault", NULL, NULL); /* * Then add the entry... */ /* * Here I plug in the code to process other amd.conf options like * map_type, search_path, and flags (browsable_dirs, mount_type). */ if (cfm) { if (map) { xsnprintf(str, sizeof(str), "cache:=mapdefault;type:=toplvl;mount_type:=%s;fs:=\"%s\"", cfm->cfm_flags & CFM_MOUNT_TYPE_AUTOFS ? "autofs" : "nfs", get_full_path(map, cfm->cfm_search_path, cfm->cfm_type)); if (opts && opts[0] != '\0') { xstrlcat(str, ";", sizeof(str)); xstrlcat(str, opts, sizeof(str)); } if (cfm->cfm_flags & CFM_BROWSABLE_DIRS_FULL) xstrlcat(str, ";opts:=rw,fullybrowsable", sizeof(str)); if (cfm->cfm_flags & CFM_BROWSABLE_DIRS) xstrlcat(str, ";opts:=rw,browsable", sizeof(str)); if (cfm->cfm_type) { xstrlcat(str, ";maptype:=", sizeof(str)); xstrlcat(str, cfm->cfm_type, sizeof(str)); } } else { xstrlcpy(str, opts, sizeof(str)); } } else { if (map) xsnprintf(str, sizeof(str), "cache:=mapdefault;type:=toplvl;fs:=\"%s\";%s", map, opts ? opts : ""); else xstrlcpy(str, opts, sizeof(str)); } mapc_repl_kv(root_map, strdup((char *)dir), strdup(str)); } int mapc_keyiter(mnt_map *m, key_fun *fn, opaque_t arg) { int i; int c = 0; for (i = 0; i < NKVHASH; i++) { kv *k = m->kvhash[i]; while (k) { (*fn) (k->key, arg); k = k->next; c++; } } return c; } /* * Iterate on the root map and call (*fn)() on the key of all the nodes. * Returns the number of entries in the root map. */ int root_keyiter(key_fun *fn, opaque_t arg) { if (root_map) { int c = mapc_keyiter(root_map, fn, arg); return c; } return 0; } /* * Error map */ static int error_init(mnt_map *m, char *map, time_t *tp) { plog(XLOG_USER, "No source data for map %s", map); *tp = 0; return 0; } static int error_search(mnt_map *m, char *map, char *key, char **pval, time_t *tp) { return ENOENT; } static int error_reload(mnt_map *m, char *map, add_fn *fn) { return ENOENT; } static int error_mtime(mnt_map *m, char *map, time_t *tp) { *tp = 0; return 0; } /* * Return absolute path of map, searched in a type-specific path. * Note: uses a static buffer for returned data. */ static const char * get_full_path(const char *map, const char *path, const char *type) { char component[MAXPATHLEN], *str; static char full_path[MAXPATHLEN]; int len; /* for now, only file-type search paths are implemented */ if (type && !STREQ(type, "file")) return map; /* if null map, return it */ if (!map) return map; /* if map includes a '/', return it (absolute or relative path) */ if (strchr(map, '/')) return map; /* if path is empty, return map */ if (!path) return map; /* now break path into components, and search in each */ xstrlcpy(component, path, sizeof(component)); str = strtok(component, ":"); do { xstrlcpy(full_path, str, sizeof(full_path)); len = strlen(full_path); if (full_path[len - 1] != '/') /* add trailing "/" if needed */ xstrlcat(full_path, "/", sizeof(full_path)); xstrlcat(full_path, map, sizeof(full_path)); if (access(full_path, R_OK) == 0) return full_path; str = strtok(NULL, ":"); } while (str); return map; /* if found nothing, return map */ } am-utils-6.2+rc20110530/amd/mntfs.c000066400000000000000000000243061157065440000163730ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/mntfs.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include qelem mfhead = {&mfhead, &mfhead}; int mntfs_allocated; am_loc * dup_loc(am_loc *loc) { loc->al_refc++; if (loc->al_mnt) { dup_mntfs(loc->al_mnt); } return loc; } mntfs * dup_mntfs(mntfs *mf) { if (mf->mf_refc == 0) { if (mf->mf_cid) untimeout(mf->mf_cid); mf->mf_cid = 0; } mf->mf_refc++; return mf; } static void init_mntfs(mntfs *mf, am_ops *ops, am_opts *mo, char *mp, char *info, char *auto_opts, char *mopts, char *remopts) { mf->mf_ops = ops; mf->mf_fsflags = ops->nfs_fs_flags; mf->mf_fo = 0; if (mo) mf->mf_fo = copy_opts(mo); mf->mf_mount = strdup(mp); mf->mf_info = strdup(info); mf->mf_auto = strdup(auto_opts); mf->mf_mopts = strdup(mopts); mf->mf_remopts = strdup(remopts); mf->mf_loopdev = NULL; mf->mf_refc = 1; mf->mf_flags = 0; mf->mf_error = -1; mf->mf_cid = 0; mf->mf_private = NULL; mf->mf_prfree = NULL; if (ops->ffserver) mf->mf_server = (*ops->ffserver) (mf); else mf->mf_server = NULL; } static mntfs * alloc_mntfs(am_ops *ops, am_opts *mo, char *mp, char *info, char *auto_opts, char *mopts, char *remopts) { mntfs *mf = ALLOC(struct mntfs); init_mntfs(mf, ops, mo, mp, info, auto_opts, mopts, remopts); ins_que(&mf->mf_q, &mfhead); mntfs_allocated++; return mf; } /* find a matching mntfs in our list */ mntfs * locate_mntfs(am_ops *ops, am_opts *mo, char *mp, char *info, char *auto_opts, char *mopts, char *remopts) { mntfs *mf; dlog("Locating mntfs reference to (%s,%s)", mp, info); ITER(mf, mntfs, &mfhead) { /* * For backwards compatibility purposes, we treat already-mounted * filesystems differently and only require a match of their mount point, * not of their server info. After all, there is little we can do if * the user asks us to mount two different things onto the same mount: one * will always cover the other one. */ if (STREQ(mf->mf_mount, mp) && ((mf->mf_flags & MFF_MOUNTED && !(mf->mf_fsflags & FS_DIRECT)) || (STREQ(mf->mf_info, info) && mf->mf_ops == ops))) { /* * Handle cases where error ops are involved */ if (ops == &amfs_error_ops) { /* * If the existing ops are not amfs_error_ops * then continue... */ if (mf->mf_ops != &amfs_error_ops) continue; return dup_mntfs(mf); } dlog("mf->mf_flags = %#x", mf->mf_flags); if ((mf->mf_flags & MFF_RESTART) && amd_state < Finishing) { /* * Restart a previously mounted filesystem. */ dlog("Restarting filesystem %s", mf->mf_mount); /* * If we are restarting an amd internal filesystem, * we need to initialize it a bit. * * We know it's internal because it is marked as toplvl. */ if (mf->mf_ops == &amfs_toplvl_ops) { mf->mf_ops = ops; mf->mf_info = strealloc(mf->mf_info, info); ops->mounted(mf); /* XXX: not right, but will do for now */ } return mf; } if (!(mf->mf_flags & (MFF_MOUNTED | MFF_MOUNTING | MFF_UNMOUNTING))) { fserver *fs; mf->mf_flags &= ~MFF_ERROR; mf->mf_error = -1; mf->mf_auto = strealloc(mf->mf_auto, auto_opts); mf->mf_mopts = strealloc(mf->mf_mopts, mopts); mf->mf_remopts = strealloc(mf->mf_remopts, remopts); mf->mf_info = strealloc(mf->mf_info, info); if (mf->mf_private && mf->mf_prfree) { mf->mf_prfree(mf->mf_private); mf->mf_private = NULL; } fs = ops->ffserver ? (*ops->ffserver) (mf) : (fserver *) NULL; if (mf->mf_server) free_srvr(mf->mf_server); mf->mf_server = fs; } return dup_mntfs(mf); } /* end of "if (STREQ(mf-> ..." */ } /* end of ITER */ return 0; } /* find a matching mntfs in our list, create a new one if none is found */ mntfs * find_mntfs(am_ops *ops, am_opts *mo, char *mp, char *info, char *auto_opts, char *mopts, char *remopts) { mntfs *mf = locate_mntfs(ops, mo, mp, info, auto_opts, mopts, remopts); if (mf) return mf; return alloc_mntfs(ops, mo, mp, info, auto_opts, mopts, remopts); } mntfs * new_mntfs(void) { return alloc_mntfs(&amfs_error_ops, (am_opts *) NULL, "//nil//", ".", "", "", ""); } am_loc * new_loc(void) { am_loc *loc = CALLOC(struct am_loc); loc->al_fo = 0; loc->al_mnt = new_mntfs(); loc->al_refc = 1; return loc; } static void uninit_mntfs(mntfs *mf) { if (mf->mf_fo) { free_opts(mf->mf_fo); XFREE(mf->mf_fo); } if (mf->mf_auto) XFREE(mf->mf_auto); if (mf->mf_mopts) XFREE(mf->mf_mopts); if (mf->mf_remopts) XFREE(mf->mf_remopts); if (mf->mf_info) XFREE(mf->mf_info); if (mf->mf_private && mf->mf_prfree) (*mf->mf_prfree) (mf->mf_private); if (mf->mf_mount) XFREE(mf->mf_mount); /* * Clean up the file server */ if (mf->mf_server) free_srvr(mf->mf_server); /* * Don't do a callback on this mount */ if (mf->mf_cid) { untimeout(mf->mf_cid); mf->mf_cid = 0; } } static void discard_mntfs(voidp v) { mntfs *mf = v; rem_que(&mf->mf_q); /* * Free memory */ uninit_mntfs(mf); XFREE(mf); --mntfs_allocated; } static void discard_loc(voidp v) { am_loc *loc = v; if (loc->al_fo) { free_opts(loc->al_fo); XFREE(loc->al_fo); } XFREE(loc); } void flush_mntfs(void) { mntfs *mf; mf = AM_FIRST(mntfs, &mfhead); while (mf != HEAD(mntfs, &mfhead)) { mntfs *mf2 = mf; mf = NEXT(mntfs, mf); if (mf2->mf_refc == 0 && mf2->mf_cid) discard_mntfs(mf2); } } void free_loc(opaque_t arg) { am_loc *loc = (am_loc *) arg; dlog("free_loc %p", loc); if (loc->al_refc <= 0) { plog(XLOG_ERROR, "IGNORING free_loc for 0x%p", loc); return; } if (loc->al_mnt) free_mntfs(loc->al_mnt); if (--loc->al_refc == 0) { discard_loc(loc); } } void free_mntfs(opaque_t arg) { mntfs *mf = (mntfs *) arg; dlog("free_mntfs <%s> type %s mf_refc %d flags %x", mf->mf_mount, mf->mf_ops->fs_type, mf->mf_refc, mf->mf_flags); /* * We shouldn't ever be called to free something that has * a non-positive refcount. Something is badly wrong if * we have been! Ignore the request for now... */ if (mf->mf_refc <= 0) { plog(XLOG_ERROR, "IGNORING free_mntfs for <%s>: refc %d, flags %x (bug?)", mf->mf_mount, mf->mf_refc, mf->mf_flags); return; } /* don't discard last reference of a restarted/kept mntfs */ if (mf->mf_refc == 1 && mf->mf_flags & MFF_RSTKEEP) { plog(XLOG_ERROR, "IGNORING free_mntfs for <%s>: refc %d, flags %x (restarted)", mf->mf_mount, mf->mf_refc, mf->mf_flags); return; } if (--mf->mf_refc == 0) { if (mf->mf_flags & MFF_MOUNTED) { int quoted; mf->mf_flags &= ~MFF_MOUNTED; /* * Record for posterity */ quoted = strchr(mf->mf_info, ' ') != 0; /* cheap */ plog(XLOG_INFO, "%s%s%s %sed fstype %s from %s", quoted ? "\"" : "", mf->mf_info, quoted ? "\"" : "", mf->mf_error ? "discard" : "unmount", mf->mf_ops->fs_type, mf->mf_mount); } if (mf->mf_fsflags & FS_DISCARD) { dlog("Immediately discarding mntfs for %s", mf->mf_mount); discard_mntfs(mf); } else { if (mf->mf_flags & MFF_RESTART) { dlog("Discarding remount hook for %s", mf->mf_mount); } else { dlog("Discarding last mntfs reference to %s fstype %s", mf->mf_mount, mf->mf_ops->fs_type); } if (mf->mf_flags & (MFF_MOUNTED | MFF_MOUNTING | MFF_UNMOUNTING)) dlog("mntfs reference for %s still active", mf->mf_mount); mf->mf_cid = timeout(ALLOWED_MOUNT_TIME, discard_mntfs, (voidp) mf); } } } mntfs * realloc_mntfs(mntfs *mf, am_ops *ops, am_opts *mo, char *mp, char *info, char *auto_opts, char *mopts, char *remopts) { mntfs *mf2; if (mf->mf_refc == 1 && mf->mf_flags & MFF_RESTART && STREQ(mf->mf_mount, mp)) { /* * If we are inheriting then just return * the same node... */ return mf; } /* * Re-use the existing mntfs if it is mounted. * This traps a race in nfsx. */ if (mf->mf_ops != &amfs_error_ops && (mf->mf_flags & MFF_MOUNTED) && !FSRV_ISDOWN(mf->mf_server)) { return mf; } mf2 = find_mntfs(ops, mo, mp, info, auto_opts, mopts, remopts); free_mntfs(mf); return mf2; } am-utils-6.2+rc20110530/amd/nfs_prot_svc.c000066400000000000000000000246031157065440000177510ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/nfs_prot_svc.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* external definitions */ extern voidp nfsproc_null_2_svc(voidp, struct svc_req *); extern nfsattrstat *nfsproc_getattr_2_svc(am_nfs_fh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern voidp nfsproc_root_2_svc(voidp, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2_svc(am_nfs_fh *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern voidp nfsproc_writecache_2_svc(voidp, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(am_nfs_fh *, struct svc_req *); /* global variables */ SVCXPRT *current_transp; /* typedefs */ typedef char *(*nfssvcproc_t)(voidp, struct svc_req *); void nfs_program_2(struct svc_req *rqstp, SVCXPRT *transp) { union { am_nfs_fh nfsproc_getattr_2_arg; nfssattrargs nfsproc_setattr_2_arg; nfsdiropargs nfsproc_lookup_2_arg; am_nfs_fh nfsproc_readlink_2_arg; nfsreadargs nfsproc_read_2_arg; nfswriteargs nfsproc_write_2_arg; nfscreateargs nfsproc_create_2_arg; nfsdiropargs nfsproc_remove_2_arg; nfsrenameargs nfsproc_rename_2_arg; nfslinkargs nfsproc_link_2_arg; nfssymlinkargs nfsproc_symlink_2_arg; nfscreateargs nfsproc_mkdir_2_arg; nfsdiropargs fsproc_rmdir_2_arg; nfsreaddirargs nfsproc_readdir_2_arg; am_nfs_fh nfsproc_statfs_2_arg; } argument; char *result; xdrproc_t xdr_argument, xdr_result; nfssvcproc_t local; #ifdef HAVE_TRANSPORT_TYPE_TLI /* * On TLI systems we don't use an INET network type, but a "ticlts" (see * /etc/netconfig and conf/transp_tli.c:create_nfs_service). This means * that packets could only come from the loopback interface, and we don't * need to check them and filter possibly spoofed packets. Therefore we * only need to check if the UID caller is correct. */ # ifdef HAVE___RPC_GET_LOCAL_UID uid_t u; /* extern definition for an internal libnsl function */ extern int __rpc_get_local_uid(SVCXPRT *transp, uid_t *uid); if (__rpc_get_local_uid(transp, &u) >= 0 && u != 0) { plog(XLOG_WARNING, "ignoring request from UID %ld, must be 0", (long) u); return; } # else /* not HAVE___RPC_GET_LOCAL_UID */ dlog("cannot verify local uid for rpc request"); # endif /* HAVE___RPC_GET_LOCAL_UID */ #else /* not HAVE_TRANPORT_TYPE_TLI */ struct sockaddr_in *sinp; char dq[20], dq2[28]; sinp = amu_svc_getcaller(rqstp->rq_xprt); # ifdef MNT2_NFS_OPT_RESVPORT /* Verify that the request comes from a reserved port */ if (sinp && ntohs(sinp->sin_port) >= IPPORT_RESERVED && !(gopt.flags & CFM_NFS_INSECURE_PORT)) { plog(XLOG_WARNING, "ignoring request from %s:%u, port not reserved", inet_dquad(dq, sizeof(dq), sinp->sin_addr.s_addr), ntohs(sinp->sin_port)); return; } # endif /* MNT2_NFS_OPT_RESVPORT */ /* if the address does not match, ignore the request */ if (sinp && (sinp->sin_addr.s_addr != myipaddr.s_addr)) { if (gopt.flags & CFM_NFS_ANY_INTERFACE) { if (!is_interface_local(sinp->sin_addr.s_addr)) { plog(XLOG_WARNING, "ignoring request from %s:%u, not a local interface", inet_dquad(dq, sizeof(dq), sinp->sin_addr.s_addr), ntohs(sinp->sin_port)); } } else { plog(XLOG_WARNING, "ignoring request from %s:%u, expected %s", inet_dquad(dq, sizeof(dq), sinp->sin_addr.s_addr), ntohs(sinp->sin_port), inet_dquad(dq2, sizeof(dq2), myipaddr.s_addr)); return; } } #endif /* not HAVE_TRANPORT_TYPE_TLI */ current_transp = NULL; switch (rqstp->rq_proc) { case NFSPROC_NULL: xdr_argument = (xdrproc_t) xdr_void; xdr_result = (xdrproc_t) xdr_void; local = (nfssvcproc_t) nfsproc_null_2_svc; break; case NFSPROC_GETATTR: xdr_argument = (xdrproc_t) xdr_nfs_fh; xdr_result = (xdrproc_t) xdr_attrstat; local = (nfssvcproc_t) nfsproc_getattr_2_svc; break; case NFSPROC_SETATTR: xdr_argument = (xdrproc_t) xdr_sattrargs; xdr_result = (xdrproc_t) xdr_attrstat; local = (nfssvcproc_t) nfsproc_setattr_2_svc; break; case NFSPROC_ROOT: xdr_argument = (xdrproc_t) xdr_void; xdr_result = (xdrproc_t) xdr_void; local = (nfssvcproc_t) nfsproc_root_2_svc; break; case NFSPROC_LOOKUP: xdr_argument = (xdrproc_t) xdr_diropargs; xdr_result = (xdrproc_t) xdr_diropres; local = (nfssvcproc_t) nfsproc_lookup_2_svc; /* * Cheap way to pass transp down to amfs_auto_lookuppn so it can * be stored in the am_node structure and later used for * quick_reply(). */ current_transp = transp; break; case NFSPROC_READLINK: xdr_argument = (xdrproc_t) xdr_nfs_fh; xdr_result = (xdrproc_t) xdr_readlinkres; local = (nfssvcproc_t) nfsproc_readlink_2_svc; break; case NFSPROC_READ: xdr_argument = (xdrproc_t) xdr_readargs; xdr_result = (xdrproc_t) xdr_readres; local = (nfssvcproc_t) nfsproc_read_2_svc; break; case NFSPROC_WRITECACHE: xdr_argument = (xdrproc_t) xdr_void; xdr_result = (xdrproc_t) xdr_void; local = (nfssvcproc_t) nfsproc_writecache_2_svc; break; case NFSPROC_WRITE: xdr_argument = (xdrproc_t) xdr_writeargs; xdr_result = (xdrproc_t) xdr_attrstat; local = (nfssvcproc_t) nfsproc_write_2_svc; break; case NFSPROC_CREATE: xdr_argument = (xdrproc_t) xdr_createargs; xdr_result = (xdrproc_t) xdr_diropres; local = (nfssvcproc_t) nfsproc_create_2_svc; break; case NFSPROC_REMOVE: xdr_argument = (xdrproc_t) xdr_diropargs; xdr_result = (xdrproc_t) xdr_nfsstat; local = (nfssvcproc_t) nfsproc_remove_2_svc; break; case NFSPROC_RENAME: xdr_argument = (xdrproc_t) xdr_renameargs; xdr_result = (xdrproc_t) xdr_nfsstat; local = (nfssvcproc_t) nfsproc_rename_2_svc; break; case NFSPROC_LINK: xdr_argument = (xdrproc_t) xdr_linkargs; xdr_result = (xdrproc_t) xdr_nfsstat; local = (nfssvcproc_t) nfsproc_link_2_svc; break; case NFSPROC_SYMLINK: xdr_argument = (xdrproc_t) xdr_symlinkargs; xdr_result = (xdrproc_t) xdr_nfsstat; local = (nfssvcproc_t) nfsproc_symlink_2_svc; break; case NFSPROC_MKDIR: xdr_argument = (xdrproc_t) xdr_createargs; xdr_result = (xdrproc_t) xdr_diropres; local = (nfssvcproc_t) nfsproc_mkdir_2_svc; break; case NFSPROC_RMDIR: xdr_argument = (xdrproc_t) xdr_diropargs; xdr_result = (xdrproc_t) xdr_nfsstat; local = (nfssvcproc_t) nfsproc_rmdir_2_svc; break; case NFSPROC_READDIR: xdr_argument = (xdrproc_t) xdr_readdirargs; xdr_result = (xdrproc_t) xdr_readdirres; local = (nfssvcproc_t) nfsproc_readdir_2_svc; break; case NFSPROC_STATFS: xdr_argument = (xdrproc_t) xdr_nfs_fh; xdr_result = (xdrproc_t) xdr_statfsres; local = (nfssvcproc_t) nfsproc_statfs_2_svc; break; default: svcerr_noproc(transp); return; } memset((char *) &argument, 0, sizeof(argument)); if (!svc_getargs(transp, (XDRPROC_T_TYPE) xdr_argument, (SVC_IN_ARG_TYPE) &argument)) { plog(XLOG_ERROR, "NFS xdr decode failed for %d %d %d", (int) rqstp->rq_prog, (int) rqstp->rq_vers, (int) rqstp->rq_proc); svcerr_decode(transp); return; } result = (*local) (&argument, rqstp); current_transp = NULL; if (result != NULL && !svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_result, result)) { svcerr_systemerr(transp); } if (!svc_freeargs(transp, (XDRPROC_T_TYPE) xdr_argument, (SVC_IN_ARG_TYPE) & argument)) { plog(XLOG_FATAL, "unable to free rpc arguments in nfs_program_2"); going_down(1); } } am-utils-6.2+rc20110530/amd/nfs_start.c000066400000000000000000000265411157065440000172520ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/nfs_start.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #ifndef SELECT_MAXWAIT # define SELECT_MAXWAIT 16 #endif /* not SELECT_MAXWAIT */ SVCXPRT *nfsxprt = NULL; u_short nfs_port = 0; #ifndef HAVE_SIGACTION # define MASKED_SIGS (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGCHLD)|sigmask(SIGHUP)) #endif /* not HAVE_SIGACTION */ #ifdef DEBUG /* * Check that we are not burning resources */ static void checkup(void) { static int max_fd = 0; static char *max_mem = NULL; int next_fd = dup(0); caddr_t next_mem = sbrk(0); close(next_fd); if (max_fd < next_fd) { dlog("%d new fds allocated; total is %d", next_fd - max_fd, next_fd); max_fd = next_fd; } if (max_mem < next_mem) { #ifdef HAVE_GETPAGESIZE dlog("%#lx bytes of memory allocated; total is %#lx (%ld pages)", (long) (next_mem - max_mem), (unsigned long) next_mem, ((long) next_mem + getpagesize() - 1) / (long) getpagesize()); #else /* not HAVE_GETPAGESIZE */ dlog("%#lx bytes of memory allocated; total is %#lx", (long) (next_mem - max_mem), (unsigned long) next_mem); #endif /* not HAVE_GETPAGESIZE */ max_mem = next_mem; } } #else /* not DEBUG */ #define checkup() #endif /* not DEBUG */ static int #ifdef HAVE_SIGACTION do_select(sigset_t smask, int fds, fd_set *fdp, struct timeval *tvp) #else /* not HAVE_SIGACTION */ do_select(int smask, int fds, fd_set *fdp, struct timeval *tvp) #endif /* not HAVE_SIGACTION */ { int sig; int nsel; if ((sig = setjmp(select_intr))) { select_intr_valid = 0; /* Got a signal */ switch (sig) { case SIGINT: case SIGTERM: amd_state = Finishing; reschedule_timeout_mp(); break; } nsel = -1; errno = EINTR; } else { select_intr_valid = 1; /* * Allow interrupts. If a signal * occurs, then it will cause a longjmp * up above. */ #ifdef HAVE_SIGACTION sigprocmask(SIG_SETMASK, &smask, NULL); #else /* not HAVE_SIGACTION */ (void) sigsetmask(smask); #endif /* not HAVE_SIGACTION */ /* * Wait for input */ nsel = select(fds, fdp, (fd_set *) NULL, (fd_set *) NULL, tvp->tv_sec ? tvp : (struct timeval *) NULL); } #ifdef HAVE_SIGACTION sigprocmask(SIG_BLOCK, &masked_sigs, NULL); #else /* not HAVE_SIGACTION */ (void) sigblock(MASKED_SIGS); #endif /* not HAVE_SIGACTION */ /* * Perhaps reload the cache? */ if (do_mapc_reload < clocktime(NULL)) { mapc_reload(); do_mapc_reload = clocktime(NULL) + gopt.map_reload_interval; } return nsel; } /* * Determine whether anything is left in * the RPC input queue. */ static int rpc_pending_now(void) { struct timeval tvv; int nsel; fd_set readfds; FD_ZERO(&readfds); FD_SET(fwd_sock, &readfds); tvv.tv_sec = tvv.tv_usec = 0; nsel = select(FD_SETSIZE, &readfds, (fd_set *) NULL, (fd_set *) NULL, &tvv); if (nsel < 1) return (0); if (FD_ISSET(fwd_sock, &readfds)) return (1); return (0); } static serv_state run_rpc(void) { #ifdef HAVE_SIGACTION sigset_t smask; sigprocmask(SIG_BLOCK, &masked_sigs, &smask); #else /* not HAVE_SIGACTION */ int smask = sigblock(MASKED_SIGS); #endif /* not HAVE_SIGACTION */ next_softclock = clocktime(NULL); amd_state = Run; /* * Keep on trucking while we are in Run mode. This state * is switched to Quit after all the file systems have * been unmounted. */ while ((int) amd_state <= (int) Finishing) { struct timeval tvv; int nsel; time_t now; fd_set readfds; #ifdef HAVE_SVC_GETREQSET memmove(&readfds, &svc_fdset, sizeof(svc_fdset)); #else /* not HAVE_SVC_GETREQSET */ FD_ZERO(&readfds); # ifdef HAVE_FD_SET_FDS_BITS readfds.fds_bits[0] = svc_fds; # else /* not HAVE_FD_SET_FDS_BITS */ readfds = svc_fds; # endif /* not HAVE_FD_SET_FDS_BITS */ #endif /* not HAVE_SVC_GETREQSET */ FD_SET(fwd_sock, &readfds); checkup(); /* * If the full timeout code is not called, * then recompute the time delta manually. */ now = clocktime(NULL); if (next_softclock <= now) { if (amd_state == Finishing) umount_exported(); tvv.tv_sec = softclock(); } else { tvv.tv_sec = next_softclock - now; } tvv.tv_usec = 0; if (amd_state == Finishing && get_exported_ap(0) == NULL) { flush_mntfs(); amd_state = Quit; break; } #ifdef HAVE_FS_AUTOFS autofs_add_fdset(&readfds); #endif /* HAVE_FS_AUTOFS */ if (tvv.tv_sec <= 0) tvv.tv_sec = SELECT_MAXWAIT; if (tvv.tv_sec) { dlog("Select waits for %ds", (int) tvv.tv_sec); } else { dlog("Select waits for Godot"); } nsel = do_select(smask, FD_SETSIZE, &readfds, &tvv); switch (nsel) { case -1: if (errno == EINTR) { dlog("select interrupted"); continue; } plog(XLOG_ERROR, "select: %m"); break; case 0: break; default: /* * Read all pending NFS responses at once to avoid having responses * queue up as a consequence of retransmissions. */ if (FD_ISSET(fwd_sock, &readfds)) { FD_CLR(fwd_sock, &readfds); --nsel; do { fwd_reply(); } while (rpc_pending_now() > 0); } #ifdef HAVE_FS_AUTOFS if (nsel) nsel = autofs_handle_fdset(&readfds, nsel); #endif /* HAVE_FS_AUTOFS */ if (nsel) { /* * Anything left must be a normal * RPC request. */ #ifdef HAVE_SVC_GETREQSET svc_getreqset(&readfds); #else /* not HAVE_SVC_GETREQSET */ # ifdef HAVE_FD_SET_FDS_BITS svc_getreq(readfds.fds_bits[0]); # else /* not HAVE_FD_SET_FDS_BITS */ svc_getreq(readfds); # endif /* not HAVE_FD_SET_FDS_BITS */ #endif /* not HAVE_SVC_GETREQSET */ } break; } } #ifdef HAVE_SIGACTION sigprocmask(SIG_SETMASK, &smask, NULL); #else /* not HAVE_SIGACTION */ (void) sigsetmask(smask); #endif /* not HAVE_SIGACTION */ if (amd_state == Quit) amd_state = Done; return amd_state; } int mount_automounter(int ppid) { /* * Old code replaced by rpc-trash patch. * Erez Zadok int so = socket(AF_INET, SOCK_DGRAM, 0); */ SVCXPRT *udp_amqp = NULL, *tcp_amqp = NULL; int nmount, ret; int soNFS; int udp_soAMQ, tcp_soAMQ; struct netconfig *udp_amqncp, *tcp_amqncp; /* * This must be done first, because it attempts to bind * to various UDP ports and we don't want anything else * potentially taking over those ports before we get a chance * to reserve them. */ if (gopt.flags & CFM_RESTART_EXISTING_MOUNTS) restart_automounter_nodes(); /* * Start RPC forwarding */ if (fwd_init() != 0) return 3; /* * Construct the root automount node */ make_root_node(); /* * Pick up the pieces from a previous run * This is likely to (indirectly) need the rpc_fwd package * so it *must* come after the call to fwd_init(). */ if (gopt.flags & CFM_RESTART_EXISTING_MOUNTS) restart(); /* * Create the nfs service for amd * If nfs_port is already initialized, it means we * already created the service during restart_automounter_nodes(). */ if (nfs_port == 0) { ret = create_nfs_service(&soNFS, &nfs_port, &nfsxprt, nfs_program_2); if (ret != 0) return ret; } xsnprintf(pid_fsname, sizeof(pid_fsname), "%s:(pid%ld,port%u)", am_get_hostname(), (long) am_mypid, nfs_port); /* security: if user sets -D noamq, don't even create listening socket */ if (amuDebug(D_AMQ)) { ret = create_amq_service(&udp_soAMQ, &udp_amqp, &udp_amqncp, &tcp_soAMQ, &tcp_amqp, &tcp_amqncp, gopt.preferred_amq_port); if (ret != 0) return ret; } #ifdef HAVE_FS_AUTOFS if (amd_use_autofs) { /* * Create the autofs service for amd. */ ret = create_autofs_service(); /* if autofs service fails it is OK if using a test amd */ if (ret != 0) { plog(XLOG_WARNING, "autofs service registration failed, turning off autofs support"); amd_use_autofs = 0; } } #endif /* HAVE_FS_AUTOFS */ /* * Mount the top-level auto-mountpoints */ nmount = mount_exported(); /* * Now safe to tell parent that we are up and running */ if (ppid) kill(ppid, SIGQUIT); if (nmount == 0) { plog(XLOG_FATAL, "No work to do - quitting"); amd_state = Done; return 0; } if (amuDebug(D_AMQ)) { /* * Complete registration of amq (first TCP service then UDP) */ int tcp_ok = 0, udp_ok = 0; unregister_amq(); /* unregister leftover Amd, if any, just in case */ tcp_ok = amu_svc_register(tcp_amqp, get_amd_program_number(), AMQ_VERSION, amq_program_1, IPPROTO_TCP, tcp_amqncp); if (!tcp_ok) plog(XLOG_FATAL, "unable to register (AMQ_PROGRAM=%lu, AMQ_VERSION, tcp)", get_amd_program_number()); udp_ok = amu_svc_register(udp_amqp, get_amd_program_number(), AMQ_VERSION, amq_program_1, IPPROTO_UDP, udp_amqncp); if (!udp_ok) plog(XLOG_FATAL, "unable to register (AMQ_PROGRAM=%lu, AMQ_VERSION, udp)", get_amd_program_number()); /* return error only if both failed */ if (!tcp_ok && !udp_ok) { amd_state = Done; return 3; } } /* * Start timeout_mp rolling */ reschedule_timeout_mp(); /* * Start the server */ if (run_rpc() != Done) { plog(XLOG_FATAL, "run_rpc failed"); amd_state = Done; } return 0; } am-utils-6.2+rc20110530/amd/nfs_subr.c000066400000000000000000000465461157065440000170770ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/nfs_subr.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Convert from UN*X to NFS error code. * Some systems like linux define their own (see * conf/mount/mount_linux.h). */ #ifndef nfs_error # define nfs_error(e) ((nfsstat)(e)) #endif /* nfs_error */ /* * File Handle structure * * This is interpreted by indexing the exported array * by fhh_id (for old-style filehandles), or by retrieving * the node name from fhh_path (for new-style filehandles). * * The whole structure is mapped onto a standard fhandle_t * when transmitted. */ struct am_fh { u_int fhh_gen; /* generation number */ union { struct { int fhh_type; /* old or new am_fh */ pid_t fhh_pid; /* process id */ int fhh_id; /* map id */ } s; char fhh_path[NFS_FHSIZE-sizeof(u_int)]; /* path to am_node */ } u; }; /* forward declarations */ /* converting am-filehandles to mount-points */ static am_node *fh_to_mp3(am_nfs_fh *fhp, int *rp, int vop); static am_node *fh_to_mp(am_nfs_fh *fhp); static void count_map_entries(const am_node *mp, u_int *out_blocks, u_int *out_bfree, u_int *out_bavail); static char * do_readlink(am_node *mp, int *error_return) { char *ln; /* * If there is a readlink method then use it, * otherwise if a link exists use that, * otherwise use the mount point. */ if (mp->am_al->al_mnt->mf_ops->readlink) { int retry = 0; mp = (*mp->am_al->al_mnt->mf_ops->readlink) (mp, &retry); if (mp == NULL) { *error_return = retry; return 0; } /* reschedule_timeout_mp(); */ } if (mp->am_link) { ln = mp->am_link; } else { ln = mp->am_al->al_mnt->mf_mount; } return ln; } voidp nfsproc_null_2_svc(voidp argp, struct svc_req *rqstp) { static char res; return (voidp) &res; } nfsattrstat * nfsproc_getattr_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) { static nfsattrstat res; am_node *mp; int retry = 0; time_t now = clocktime(NULL); if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "getattr:"); mp = fh_to_mp3(argp, &retry, VLOOK_CREATE); if (mp == NULL) { if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "\tretry=%d", retry); if (retry < 0) { amd_stats.d_drops++; return 0; } res.ns_status = nfs_error(retry); return &res; } res = mp->am_attr; if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "\tstat(%s), size = %d, mtime=%ld.%ld", mp->am_path, (int) res.ns_u.ns_attr_u.na_size, (long) res.ns_u.ns_attr_u.na_mtime.nt_seconds, (long) res.ns_u.ns_attr_u.na_mtime.nt_useconds); /* Delay unmount of what was looked up */ if (mp->am_timeo_w < 4 * gopt.am_timeo_w) mp->am_timeo_w += gopt.am_timeo_w; mp->am_ttl = now + mp->am_timeo_w; mp->am_stats.s_getattr++; return &res; } nfsattrstat * nfsproc_setattr_2_svc(nfssattrargs *argp, struct svc_req *rqstp) { static nfsattrstat res; if (!fh_to_mp(&argp->sag_fhandle)) res.ns_status = nfs_error(ESTALE); else res.ns_status = nfs_error(EROFS); return &res; } voidp nfsproc_root_2_svc(voidp argp, struct svc_req *rqstp) { static char res; return (voidp) &res; } nfsdiropres * nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp) { static nfsdiropres res; am_node *mp; int retry; uid_t uid; gid_t gid; if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "lookup:"); /* finally, find the effective uid/gid from RPC request */ if (getcreds(rqstp, &uid, &gid, nfsxprt) < 0) plog(XLOG_ERROR, "cannot get uid/gid from RPC credentials"); xsnprintf(opt_uid, sizeof(uid_str), "%d", (int) uid); xsnprintf(opt_gid, sizeof(gid_str), "%d", (int) gid); mp = fh_to_mp3(&argp->da_fhandle, &retry, VLOOK_CREATE); if (mp == NULL) { if (retry < 0) { amd_stats.d_drops++; return 0; } res.dr_status = nfs_error(retry); } else { int error; am_node *ap; if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "\tlookup(%s, %s)", mp->am_path, argp->da_name); ap = mp->am_al->al_mnt->mf_ops->lookup_child(mp, argp->da_name, &error, VLOOK_CREATE); if (ap && error < 0) ap = mp->am_al->al_mnt->mf_ops->mount_child(ap, &error); if (ap == 0) { if (error < 0) { amd_stats.d_drops++; return 0; } res.dr_status = nfs_error(error); } else { /* * XXX: EXPERIMENTAL! Delay unmount of what was looked up. This * should reduce the chance for race condition between unmounting an * entry synchronously, and re-mounting it asynchronously. */ if (ap->am_ttl < mp->am_ttl) ap->am_ttl = mp->am_ttl; mp_to_fh(ap, &res.dr_u.dr_drok_u.drok_fhandle); res.dr_u.dr_drok_u.drok_attributes = ap->am_fattr; res.dr_status = NFS_OK; } mp->am_stats.s_lookup++; /* reschedule_timeout_mp(); */ } return &res; } void nfs_quick_reply(am_node *mp, int error) { SVCXPRT *transp = mp->am_transp; nfsdiropres res; xdrproc_t xdr_result = (xdrproc_t) xdr_diropres; /* * If there's a transp structure then we can reply to the client's * nfs lookup request. */ if (transp) { if (error == 0) { /* * Construct a valid reply to a lookup request. Same * code as in nfsproc_lookup_2_svc() above. */ mp_to_fh(mp, &res.dr_u.dr_drok_u.drok_fhandle); res.dr_u.dr_drok_u.drok_attributes = mp->am_fattr; res.dr_status = NFS_OK; } else /* * Return the error that was passed to us. */ res.dr_status = nfs_error(error); /* * Send off our reply */ if (!svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_result, (SVC_IN_ARG_TYPE) & res)) svcerr_systemerr(transp); /* * Free up transp. It's only used for one reply. */ XFREE(mp->am_transp); dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount); } } nfsreadlinkres * nfsproc_readlink_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) { static nfsreadlinkres res; am_node *mp; int retry; if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "readlink:"); mp = fh_to_mp3(argp, &retry, VLOOK_CREATE); if (mp == NULL) { readlink_retry: if (retry < 0) { amd_stats.d_drops++; return 0; } res.rlr_status = nfs_error(retry); } else { char *ln = do_readlink(mp, &retry); if (ln == 0) goto readlink_retry; res.rlr_status = NFS_OK; if (amuDebug(D_TRACE) && ln) plog(XLOG_DEBUG, "\treadlink(%s) = %s", mp->am_path, ln); res.rlr_u.rlr_data_u = ln; mp->am_stats.s_readlink++; } return &res; } nfsreadres * nfsproc_read_2_svc(nfsreadargs *argp, struct svc_req *rqstp) { static nfsreadres res; memset((char *) &res, 0, sizeof(res)); res.rr_status = nfs_error(EACCES); return &res; } voidp nfsproc_writecache_2_svc(voidp argp, struct svc_req *rqstp) { static char res; return (voidp) &res; } nfsattrstat * nfsproc_write_2_svc(nfswriteargs *argp, struct svc_req *rqstp) { static nfsattrstat res; if (!fh_to_mp(&argp->wra_fhandle)) res.ns_status = nfs_error(ESTALE); else res.ns_status = nfs_error(EROFS); return &res; } nfsdiropres * nfsproc_create_2_svc(nfscreateargs *argp, struct svc_req *rqstp) { static nfsdiropres res; if (!fh_to_mp(&argp->ca_where.da_fhandle)) res.dr_status = nfs_error(ESTALE); else res.dr_status = nfs_error(EROFS); return &res; } static nfsstat * unlink_or_rmdir(nfsdiropargs *argp, struct svc_req *rqstp, int unlinkp) { static nfsstat res; int retry; am_node *mp = fh_to_mp3(&argp->da_fhandle, &retry, VLOOK_DELETE); if (mp == NULL) { if (retry < 0) { amd_stats.d_drops++; return 0; } res = nfs_error(retry); goto out; } if (mp->am_fattr.na_type != NFDIR) { res = nfs_error(ENOTDIR); goto out; } if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "\tremove(%s, %s)", mp->am_path, argp->da_name); mp = mp->am_al->al_mnt->mf_ops->lookup_child(mp, argp->da_name, &retry, VLOOK_DELETE); if (mp == NULL) { /* * Ignore retries... */ if (retry < 0) retry = 0; /* * Usual NFS workaround... */ else if (retry == ENOENT) retry = 0; res = nfs_error(retry); } else { forcibly_timeout_mp(mp); res = NFS_OK; } out: return &res; } nfsstat * nfsproc_remove_2_svc(nfsdiropargs *argp, struct svc_req *rqstp) { return unlink_or_rmdir(argp, rqstp, TRUE); } nfsstat * nfsproc_rename_2_svc(nfsrenameargs *argp, struct svc_req *rqstp) { static nfsstat res; if (!fh_to_mp(&argp->rna_from.da_fhandle) || !fh_to_mp(&argp->rna_to.da_fhandle)) res = nfs_error(ESTALE); /* * If the kernel is doing clever things with referenced files * then let it pretend... */ else if (NSTREQ(argp->rna_to.da_name, ".nfs", 4)) res = NFS_OK; /* * otherwise a failure */ else res = nfs_error(EROFS); return &res; } nfsstat * nfsproc_link_2_svc(nfslinkargs *argp, struct svc_req *rqstp) { static nfsstat res; if (!fh_to_mp(&argp->la_fhandle) || !fh_to_mp(&argp->la_to.da_fhandle)) res = nfs_error(ESTALE); else res = nfs_error(EROFS); return &res; } nfsstat * nfsproc_symlink_2_svc(nfssymlinkargs *argp, struct svc_req *rqstp) { static nfsstat res; if (!fh_to_mp(&argp->sla_from.da_fhandle)) res = nfs_error(ESTALE); else res = nfs_error(EROFS); return &res; } nfsdiropres * nfsproc_mkdir_2_svc(nfscreateargs *argp, struct svc_req *rqstp) { static nfsdiropres res; if (!fh_to_mp(&argp->ca_where.da_fhandle)) res.dr_status = nfs_error(ESTALE); else res.dr_status = nfs_error(EROFS); return &res; } nfsstat * nfsproc_rmdir_2_svc(nfsdiropargs *argp, struct svc_req *rqstp) { return unlink_or_rmdir(argp, rqstp, FALSE); } nfsreaddirres * nfsproc_readdir_2_svc(nfsreaddirargs *argp, struct svc_req *rqstp) { static nfsreaddirres res; static nfsentry e_res[MAX_READDIR_ENTRIES]; am_node *mp; int retry; if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "readdir:"); mp = fh_to_mp3(&argp->rda_fhandle, &retry, VLOOK_CREATE); if (mp == NULL) { if (retry < 0) { amd_stats.d_drops++; return 0; } res.rdr_status = nfs_error(retry); } else { if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "\treaddir(%s)", mp->am_path); res.rdr_status = nfs_error((*mp->am_al->al_mnt->mf_ops->readdir) (mp, argp->rda_cookie, &res.rdr_u.rdr_reply_u, e_res, argp->rda_count)); mp->am_stats.s_readdir++; } return &res; } nfsstatfsres * nfsproc_statfs_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) { static nfsstatfsres res; am_node *mp; int retry; mntent_t mnt; if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "statfs:"); mp = fh_to_mp3(argp, &retry, VLOOK_CREATE); if (mp == NULL) { if (retry < 0) { amd_stats.d_drops++; return 0; } res.sfr_status = nfs_error(retry); } else { nfsstatfsokres *fp; if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "\tstat_fs(%s)", mp->am_path); /* * just return faked up file system information */ fp = &res.sfr_u.sfr_reply_u; fp->sfrok_tsize = 1024; fp->sfrok_bsize = 1024; /* check if map is browsable and show_statfs_entries=yes */ if ((gopt.flags & CFM_SHOW_STATFS_ENTRIES) && mp->am_al->al_mnt && mp->am_al->al_mnt->mf_mopts) { mnt.mnt_opts = mp->am_al->al_mnt->mf_mopts; if (amu_hasmntopt(&mnt, "browsable")) { count_map_entries(mp, &fp->sfrok_blocks, &fp->sfrok_bfree, &fp->sfrok_bavail); } } else { fp->sfrok_blocks = 0; /* set to 1 if you don't want empty automounts */ fp->sfrok_bfree = 0; fp->sfrok_bavail = 0; } res.sfr_status = NFS_OK; mp->am_stats.s_statfs++; } return &res; } /* * count how many total entries there are in a map, and how many * of them are in use. */ static void count_map_entries(const am_node *mp, u_int *out_blocks, u_int *out_bfree, u_int *out_bavail) { u_int blocks, bfree, bavail, i; mntfs *mf; mnt_map *mmp; kv *k; blocks = bfree = bavail = 0; if (!mp) goto out; mf = mp->am_al->al_mnt; if (!mf) goto out; mmp = (mnt_map *) mf->mf_private; if (!mmp) goto out; /* iterate over keys */ for (i = 0; i < NKVHASH; i++) { for (k = mmp->kvhash[i]; k ; k = k->next) { if (!k->key) continue; blocks++; /* * XXX: Need to count how many are actively in use and recompute * bfree and bavail based on it. */ } } out: *out_blocks = blocks; *out_bfree = bfree; *out_bavail = bavail; } /* * Convert from file handle to automount node. */ static am_node * fh_to_mp3(am_nfs_fh *fhp, int *rp, int vop) { struct am_fh *fp = (struct am_fh *) fhp; am_node *ap = NULL; if (fp->u.s.fhh_type != 0) { /* New filehandle type */ int len = sizeof(*fhp) - sizeof(fp->fhh_gen); char *path = xmalloc(len+1); /* * Because fhp is treated as a filehandle we use memcpy * instead of xstrlcpy. */ memcpy(path, (char *) fp->u.fhh_path, len); path[len] = '\0'; /* dlog("fh_to_mp3: new filehandle: %s", path); */ ap = path_to_exported_ap(path); XFREE(path); } else { /* dlog("fh_to_mp3: old filehandle: %d", fp->u.s.fhh_id); */ /* * Check process id matches * If it doesn't then it is probably * from an old kernel-cached filehandle * which is now out of date. */ if (fp->u.s.fhh_pid != get_server_pid()) { dlog("fh_to_mp3: wrong pid %ld != my pid %ld", (long) fp->u.s.fhh_pid, get_server_pid()); goto drop; } /* * Get hold of the supposed mount node */ ap = get_exported_ap(fp->u.s.fhh_id); } /* * Check the generation number in the node * matches the one from the kernel. If not * then the old node has been timed out and * a new one allocated. */ if (ap != NULL && ap->am_gen != fp->fhh_gen) ap = NULL; /* * If it doesn't exists then drop the request */ if (!ap) goto drop; #if 0 /* * If the node is hung then locate a new node * for it. This implements the replicated filesystem * retries. */ if (ap->am_al->al_mnt && FSRV_ISDOWN(ap->am_al->al_mnt->mf_server) && ap->am_parent) { int error; am_node *orig_ap = ap; dlog("fh_to_mp3: %s (%s) is hung: lookup alternative file server", orig_ap->am_path, orig_ap->am_al->al_mnt->mf_info); /* * Update modify time of parent node. * With any luck the kernel will re-stat * the child node and get new information. */ clocktime(&orig_ap->am_fattr.na_mtime); /* * Call the parent's lookup routine for an object * with the same name. This may return -1 in error * if a mount is in progress. In any case, if no * mount node is returned the error code is propagated * to the caller. */ if (vop == VLOOK_CREATE) { ap = orig_ap->am_parent->am_al->al_mnt->mf_ops->lookup_child(orig_ap->am_parent, orig_ap->am_name, &error, vop); if (ap && error < 0) ap = orig_ap->am_parent->am_al->al_mnt->mf_ops->mount_child(ap, &error); } else { ap = NULL; error = ESTALE; } if (ap == 0) { if (error < 0 && amd_state == Finishing) error = ENOENT; *rp = error; return 0; } /* * Update last access to original node. This * avoids timing it out and so sending ESTALE * back to the kernel. * XXX - Not sure we need this anymore (jsp, 90/10/6). */ new_ttl(orig_ap); } #endif /* 0 */ /* * Disallow references to objects being unmounted, unless * they are automount points. */ if (ap->am_al->al_mnt && (ap->am_al->al_mnt->mf_flags & MFF_UNMOUNTING) && !(ap->am_flags & AMF_ROOT)) { if (amd_state == Finishing) *rp = ENOENT; else *rp = -1; return 0; } new_ttl(ap); drop: if (!ap || !ap->am_al->al_mnt) { /* * If we are shutting down then it is likely * that this node has disappeared because of * a fast timeout. To avoid things thrashing * just pretend it doesn't exist at all. If * ESTALE is returned, some NFS clients just * keep retrying (stupid or what - if it's * stale now, what's it going to be in 5 minutes?) */ if (amd_state == Finishing) *rp = ENOENT; else { *rp = ESTALE; amd_stats.d_stale++; } } return ap; } static am_node * fh_to_mp(am_nfs_fh *fhp) { int dummy; return fh_to_mp3(fhp, &dummy, VLOOK_CREATE); } /* * Convert from automount node to file handle. */ void mp_to_fh(am_node *mp, am_nfs_fh *fhp) { u_int pathlen; struct am_fh *fp = (struct am_fh *) fhp; memset((char *) fhp, 0, sizeof(am_nfs_fh)); /* Store the generation number */ fp->fhh_gen = mp->am_gen; pathlen = strlen(mp->am_path); if (pathlen <= sizeof(*fhp) - sizeof(fp->fhh_gen)) { /* dlog("mp_to_fh: new filehandle: %s", mp->am_path); */ /* * Because fhp is treated as a filehandle we use memcpy instead of * xstrlcpy. */ memcpy(fp->u.fhh_path, mp->am_path, pathlen); /* making a filehandle */ } else { /* * Take the process id */ fp->u.s.fhh_pid = get_server_pid(); /* * ... the map number */ fp->u.s.fhh_id = mp->am_mapno; /* * ... and the generation number (previously stored) * to make a "unique" triple that will never * be reallocated except across reboots (which doesn't matter) * or if we are unlucky enough to be given the same * pid as a previous amd (very unlikely). */ /* dlog("mp_to_fh: old filehandle: %d", fp->u.s.fhh_id); */ } } am-utils-6.2+rc20110530/amd/ops_TEMPLATE.c000066400000000000000000000165411157065440000173420ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_TEMPLATE.c * */ /* * An empty template for an amd pseudo filesystem "foofs". */ /* * NOTE: if this is an Amd file system, prepend "amfs_" to all foofs symbols * and renamed the file name to amfs_foofs.c. If it is a native file system * (such as pcfs, isofs, or ffs), then you can keep the names as is, and * just rename the file to ops_foofs.c. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward declarations */ static char *foofs_match(am_opts *fo); static int foofs_init(mntfs *mf); static int foofs_mount(am_node *mp, mntfs *mf); static int foofs_umount(am_node *mp, mntfs *mf); static am_node *foofs_lookuppn(am_node *mp, char *fname, int *error_return, int op); static int foofs_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, u_int count); static am_node *foofs_readlink(am_node *mp, int *error_return); static void foofs_mounted(am_node *am, mntfs *mf); static void foofs_umounted(am_node *mp, mntfs *mf); static fserver *foofs_ffserver(mntfs *mf); /* * Foofs operations. * Define only those you need, others set to 0 (NULL) */ am_ops foofs_ops = { "foofs", /* name of file system */ foofs_match, /* match */ foofs_init, /* initialize */ foofs_mount, /* mount vnode */ foofs_umount, /* unmount vnode */ foofs_lookup_child, /* lookup path-name */ foofs_mount_child, /* mount path-name */ foofs_readdir, /* read directory */ foofs_readlink, /* read link */ foofs_mounted, /* after-mount extra actions */ foofs_umounted, /* after-umount extra actions */ foofs_ffserver, /* find a file server */ foofs_get_wchan, /* return the waiting channel */ FS_MKMNT | FS_BACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_TEMPLATE_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * Check that f/s has all needed fields. * Returns: matched string if found, NULL otherwise. */ static char * foofs_match(am_opts *fo) { char *cp = "fill this with a way to find the match"; plog(XLOG_INFO, "entering foofs_match..."); if (cp) return cp; /* OK */ return NULL; /* not OK */ } /* * Initialize. * Returns: 0 if OK, non-zero (errno) if failed. */ static int foofs_init(mntfs *mf) { int error = 0; plog(XLOG_INFO, "entering foofs_init..."); error = EPERM; /* XXX: fixme */ return error; } /* * Mount vnode. * Returns: 0 if OK, non-zero (errno) if failed. */ static int foofs_mount(am_node *mp) { int error = 0; plog(XLOG_INFO, "entering foofs_mount..."); error = EPERM; /* XXX: fixme */ return error; } /* * Mount vfs. * Returns: 0 if OK, non-zero (errno) if failed. */ static int foofs_fmount(mntfs *mf) { int error = 0; plog(XLOG_INFO, "entering foofs_fmount..."); error = EPERM; /* XXX: fixme */ return error; } /* * Unmount vnode. * Returns: 0 if OK, non-zero (errno) if failed. */ static int foofs_umount(am_node *mp) { int error = 0; plog(XLOG_INFO, "entering foofs_umount..."); error = EPERM; /* XXX: fixme */ return error; } /* * Unmount VFS. * Returns: 0 if OK, non-zero (errno) if failed. */ static int foofs_fumount(mntfs *mf) { int error = 0; plog(XLOG_INFO, "entering foofs_fumount..."); error = EPERM; /* XXX: fixme */ return error; } /* * Lookup path-name. * Returns: the am_node that was found, or NULL if failed. * If failed, also fills in errno in error_return. */ static am_node * foofs_lookuppn(am_node *mp, char *fname, int *error_return, int op) { int error = 0; plog(XLOG_INFO, "entering foofs_lookuppn..."); error = EPERM; /* XXX: fixme */ *error_return = error; return NULL; } /* * Read directory. * Returns: 0 if OK, non-zero (errno) if failed. * If OK, fills in ep with chain of directory entries. */ static int foofs_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, u_int count) { int error = 0; plog(XLOG_INFO, "entering foofs_readdir..."); error = EPERM; /* XXX: fixme */ return error; } /* * Read link. * Returns: am_node found, or NULL if not found. * If failed, fills in errno in error_return. */ static am_node * foofs_readlink(am_node *mp, int *error_return) { int error = 0; plog(XLOG_INFO, "entering foofs_readlink..."); error = EPERM; /* XXX: fixme */ *error_return = error; return NULL; } /* * Async mount callback function. * After the base mount went OK, sometimes * there are additional actions that are needed. See union_mounted() and * toplvl_mounted(). */ static void foofs_mounted(mntfs *mf) { plog(XLOG_INFO, "entering foofs_mounted..."); return; } /* * Async unmount callback function. * After the base umount() succeeds, we may want to take extra actions, * such as informing remote mount daemons that we've unmounted them. * See amfs_auto_umounted(), host_umounted(), nfs_umounted(). */ static void foofs_umounted(am_node *mp) { plog(XLOG_INFO, "entering foofs_umounted..."); return; } /* * Find a file server. * Returns: fserver of found server, or NULL if not found. */ static fserver * foofs_ffserver(mntfs *mf) { plog(XLOG_INFO, "entering foofs_ffserver..."); return NULL; } /* * Normally just return mf. Only inherit needs to do special tricks. */ static wchan_t * foofs_get_wchan(mntfs *mf) { plog(XLOG_INFO, "entering foofs_get_wchan..."); return mf; } am-utils-6.2+rc20110530/amd/ops_cachefs.c000066400000000000000000000162531157065440000175230ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_cachefs.c * */ /* * Caching filesystem (Solaris 2.x) */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward declarations */ static char *cachefs_match(am_opts *fo); static int cachefs_init(mntfs *mf); static int cachefs_mount(am_node *am, mntfs *mf); static int cachefs_umount(am_node *am, mntfs *mf); /* * Ops structure */ am_ops cachefs_ops = { "cachefs", cachefs_match, cachefs_init, cachefs_mount, cachefs_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* cachefs_readlink */ 0, /* cachefs_mounted */ 0, /* cachefs_umounted */ amfs_generic_find_srvr, 0, /* cachefs_get_wchan */ FS_MKMNT | FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_CACHEFS_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * Check that f/s has all needed fields. * Returns: matched string if found, NULL otherwise. */ static char * cachefs_match(am_opts *fo) { /* sanity check */ if (!fo->opt_rfs || !fo->opt_fs || !fo->opt_cachedir) { plog(XLOG_USER, "cachefs: must specify cachedir, rfs, and fs"); return NULL; } dlog("CACHEFS: using cache directory \"%s\"", fo->opt_cachedir); /* determine magic cookie to put in mtab */ return strdup(fo->opt_cachedir); } /* * Initialize. * Returns: 0 if OK, non-zero (errno) if failed. */ static int cachefs_init(mntfs *mf) { /* * Save cache directory name */ if (!mf->mf_private) { mf->mf_private = (voidp) strdup(mf->mf_fo->opt_cachedir); mf->mf_prfree = (void (*)(voidp)) free; } return 0; } /* * mntpt is the mount point ($fs) [XXX: was 'dir'] * backdir is the mounted pathname ($rfs) [XXX: was 'fs_name'] * cachedir is the cache directory ($cachedir) */ static int mount_cachefs(char *mntdir, char *backdir, char *cachedir, char *opts, int on_autofs) { cachefs_args_t ca; mntent_t mnt; int flags; char *cp; MTYPE_TYPE type = MOUNT_TYPE_CACHEFS; /* F/S mount type */ memset((voidp) &ca, 0, sizeof(ca)); /* Paranoid */ /* * Fill in the mount structure */ memset((voidp) &mnt, 0, sizeof(mnt)); mnt.mnt_dir = mntdir; mnt.mnt_fsname = backdir; mnt.mnt_type = MNTTAB_TYPE_CACHEFS; mnt.mnt_opts = opts; flags = compute_mount_flags(&mnt); #ifdef HAVE_FS_AUTOFS if (on_autofs) flags |= autofs_compute_mount_flags(&mnt); #endif /* HAVE_FS_AUTOFS */ /* Fill in cachefs mount arguments */ /* * XXX: Caveats * (1) cache directory is NOT checked for sanity beforehand, nor is it * purged. Maybe it should be purged first? * (2) cache directory is NOT locked. Should we? */ /* mount flags */ ca.cfs_options.opt_flags = CFS_WRITE_AROUND | CFS_ACCESS_BACKFS; /* cache population size */ ca.cfs_options.opt_popsize = DEF_POP_SIZE; /* default: 64K */ /* filegrp size */ ca.cfs_options.opt_fgsize = DEF_FILEGRP_SIZE; /* default: 256 */ /* CFS ID for file system (must be unique) */ ca.cfs_fsid = cachedir; /* CFS fscdir name */ memset(ca.cfs_cacheid, 0, sizeof(ca.cfs_cacheid)); /* * Append cacheid and mountpoint. * sizeof(cfs_cacheid) should be C_MAX_MOUNT_FSCDIRNAME as per * (checked on Solaris 8). */ xsnprintf(ca.cfs_cacheid, sizeof(ca.cfs_cacheid), "%s:%s", ca.cfs_fsid, mntdir); /* convert '/' to '_' (Solaris does that...) */ cp = ca.cfs_cacheid; while ((cp = strpbrk(cp, "/")) != NULL) *cp = '_'; /* path for this cache dir */ ca.cfs_cachedir = cachedir; /* back filesystem dir */ ca.cfs_backfs = backdir; /* same as nfs values (XXX: need to handle these options) */ ca.cfs_acregmin = 0; ca.cfs_acregmax = 0; ca.cfs_acdirmin = 0; ca.cfs_acdirmax = 0; /* * Call generic mount routine */ return mount_fs(&mnt, flags, (caddr_t) &ca, 0, type, 0, NULL, mnttab_file_name, on_autofs); } static int cachefs_mount(am_node *am, mntfs *mf) { int on_autofs = mf->mf_flags & MFF_ON_AUTOFS; int error; error = mount_cachefs(mf->mf_mount, mf->mf_fo->opt_rfs, mf->mf_fo->opt_cachedir, mf->mf_mopts, on_autofs); if (error) { errno = error; /* according to Solaris, if errno==ESRCH, "options to not match" */ if (error == ESRCH) plog(XLOG_ERROR, "mount_cachefs: options to no match: %m"); else plog(XLOG_ERROR, "mount_cachefs: %m"); return error; } return 0; } static int cachefs_umount(am_node *am, mntfs *mf) { int unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; int error; error = UMOUNT_FS(mf->mf_mount, mnttab_file_name, unmount_flags); /* * In the case of cachefs, we must fsck the cache directory. Otherwise, * it will remain inconsistent, and the next cachefs mount will fail * with the error "no space left on device" (ENOSPC). * * XXX: this is hacky! use fork/exec/wait instead... */ if (!error) { char *cachedir = NULL; char cmd[128]; cachedir = (char *) mf->mf_private; plog(XLOG_INFO, "running fsck on cache directory \"%s\"", cachedir); xsnprintf(cmd, sizeof(cmd), "fsck -F cachefs %s", cachedir); system(cmd); } return error; } am-utils-6.2+rc20110530/amd/ops_cdfs.c000066400000000000000000000173141157065440000170450ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_cdfs.c * */ /* * High Sierra (CD-ROM) file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward declarations */ static char *cdfs_match(am_opts *fo); static int cdfs_mount(am_node *am, mntfs *mf); static int cdfs_umount(am_node *am, mntfs *mf); /* * Ops structure */ am_ops cdfs_ops = { "cdfs", cdfs_match, 0, /* cdfs_init */ cdfs_mount, cdfs_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* cdfs_readlink */ 0, /* cdfs_mounted */ 0, /* cdfs_umounted */ amfs_generic_find_srvr, 0, /* cdfs_get_wchan */ FS_MKMNT | FS_UBACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_CDFS_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * CDFS needs remote filesystem. */ static char * cdfs_match(am_opts *fo) { if (!fo->opt_dev) { plog(XLOG_USER, "cdfs: no source device specified"); return 0; } dlog("CDFS: mounting device \"%s\" on \"%s\"", fo->opt_dev, fo->opt_fs); /* * Determine magic cookie to put in mtab */ return strdup(fo->opt_dev); } static int mount_cdfs(char *mntdir, char *fs_name, char *opts, int on_autofs) { cdfs_args_t cdfs_args; mntent_t mnt; int genflags, cdfs_flags, retval; /* * Figure out the name of the file system type. */ MTYPE_TYPE type = MOUNT_TYPE_CDFS; memset((voidp) &cdfs_args, 0, sizeof(cdfs_args)); /* Paranoid */ cdfs_flags = 0; /* * Fill in the mount structure */ memset((voidp) &mnt, 0, sizeof(mnt)); mnt.mnt_dir = mntdir; mnt.mnt_fsname = fs_name; mnt.mnt_type = MNTTAB_TYPE_CDFS; mnt.mnt_opts = opts; #if defined(MNT2_CDFS_OPT_DEFPERM) && defined(MNTTAB_OPT_DEFPERM) if (amu_hasmntopt(&mnt, MNTTAB_OPT_DEFPERM)) # ifdef MNT2_CDFS_OPT_DEFPERM cdfs_flags |= MNT2_CDFS_OPT_DEFPERM; # else /* not MNT2_CDFS_OPT_DEFPERM */ cdfs_flags &= ~MNT2_CDFS_OPT_NODEFPERM; # endif /* not MNT2_CDFS_OPT_DEFPERM */ #endif /* defined(MNT2_CDFS_OPT_DEFPERM) && defined(MNTTAB_OPT_DEFPERM) */ #if defined(MNT2_CDFS_OPT_NODEFPERM) && defined(MNTTAB_OPT_NODEFPERM) if (amu_hasmntopt(&mnt, MNTTAB_OPT_NODEFPERM)) cdfs_flags |= MNT2_CDFS_OPT_NODEFPERM; #endif /* MNTTAB_OPT_NODEFPERM */ #if defined(MNT2_CDFS_OPT_NOVERSION) && defined(MNTTAB_OPT_NOVERSION) if (amu_hasmntopt(&mnt, MNTTAB_OPT_NOVERSION)) cdfs_flags |= MNT2_CDFS_OPT_NOVERSION; #endif /* defined(MNT2_CDFS_OPT_NOVERSION) && defined(MNTTAB_OPT_NOVERSION) */ #if defined(MNT2_CDFS_OPT_RRIP) && defined(MNTTAB_OPT_RRIP) if (amu_hasmntopt(&mnt, MNTTAB_OPT_RRIP)) cdfs_flags |= MNT2_CDFS_OPT_RRIP; #endif /* defined(MNT2_CDFS_OPT_RRIP) && defined(MNTTAB_OPT_RRIP) */ #if defined(MNT2_CDFS_OPT_NORRIP) && defined(MNTTAB_OPT_NORRIP) if (amu_hasmntopt(&mnt, MNTTAB_OPT_NORRIP)) cdfs_flags |= MNT2_CDFS_OPT_NORRIP; #endif /* defined(MNT2_CDFS_OPT_NORRIP) && defined(MNTTAB_OPT_NORRIP) */ #if defined(MNT2_CDFS_OPT_GENS) && defined(MNTTAB_OPT_GENS) if (amu_hasmntopt(&mnt, MNTTAB_OPT_GENS)) cdfs_flags |= MNT2_CDFS_OPT_GENS; #endif /* defined(MNT2_CDFS_OPT_GENS) && defined(MNTTAB_OPT_GENS) */ #if defined(MNT2_CDFS_OPT_EXTATT) && defined(MNTTAB_OPT_EXTATT) if (amu_hasmntopt(&mnt, MNTTAB_OPT_EXTATT)) cdfs_flags |= MNT2_CDFS_OPT_EXTATT; #endif /* defined(MNT2_CDFS_OPT_EXTATT) && defined(MNTTAB_OPT_EXTATT) */ #if defined(MNT2_CDFS_OPT_NOCASETRANS) && defined(MNTTAB_OPT_NOCASETRANS) if (amu_hasmntopt(&mnt, MNTTAB_OPT_NOCASETRANS)) cdfs_flags |= MNT2_CDFS_OPT_NOCASETRANS; #endif /* defined(MNT2_CDFS_OPT_NOCASETRANS) && defined(MNTTAB_OPT_NOCASETRANS) */ #if defined(MNT2_CDFS_OPT_NOJOLIET) && defined(MNTTAB_OPT_NOJOLIET) if (amu_hasmntopt(&mnt, MNTTAB_OPT_NOJOLIET)) cdfs_flags |= MNT2_CDFS_OPT_NOJOLIET; #endif /* defined(MNT2_CDFS_OPT_NOJOLIET) && defined(MNTTAB_OPT_NOJOLIET) */ #if defined(MNT2_CDFS_OPT_RRCASEINS) && defined(MNTTAB_OPT_RRCASEINS) if (amu_hasmntopt(&mnt, MNTTAB_OPT_RRCASEINS)) cdfs_flags |= MNT2_CDFS_OPT_RRCASEINS; #endif /* defined(MNT2_CDFS_OPT_RRCASEINS) && defined(MNTTAB_OPT_RRCASEINS) */ genflags = compute_mount_flags(&mnt); #ifdef HAVE_FS_AUTOFS if (on_autofs) genflags |= autofs_compute_mount_flags(&mnt); #endif /* HAVE_FS_AUTOFS */ #ifdef HAVE_CDFS_ARGS_T_FLAGS cdfs_args.flags = cdfs_flags; #endif /* HAVE_CDFS_ARGS_T_FLAGS */ #ifdef HAVE_CDFS_ARGS_T_ISO_FLAGS cdfs_args.iso_flags = genflags | cdfs_flags; #endif /* HAVE_CDFS_ARGS_T_ISO_FLAGS */ #ifdef HAVE_CDFS_ARGS_T_ISO_PGTHRESH cdfs_args.iso_pgthresh = hasmntval(&mnt, MNTTAB_OPT_PGTHRESH); #endif /* HAVE_CDFS_ARGS_T_ISO_PGTHRESH */ #ifdef HAVE_CDFS_ARGS_T_NORRIP /* XXX: need to provide norrip mount opt */ cdfs_args.norrip = 0; /* use Rock-Ridge Protocol extensions */ #endif /* HAVE_CDFS_ARGS_T_NORRIP */ #ifdef HAVE_CDFS_ARGS_T_SSECTOR /* XXX: need to provide ssector mount option */ cdfs_args.ssector = 0; /* use 1st session on disk */ #endif /* HAVE_CDFS_ARGS_T_SSECTOR */ #ifdef HAVE_CDFS_ARGS_T_FSPEC cdfs_args.fspec = fs_name; #endif /* HAVE_CDFS_ARGS_T_FSPEC */ /* * Call generic mount routine */ retval = mount_fs(&mnt, genflags, (caddr_t) &cdfs_args, 0, type, 0, NULL, mnttab_file_name, on_autofs); return retval; } static int cdfs_mount(am_node *am, mntfs *mf) { int on_autofs = mf->mf_flags & MFF_ON_AUTOFS; int error; error = mount_cdfs(mf->mf_mount, mf->mf_info, mf->mf_mopts, on_autofs); if (error) { errno = error; plog(XLOG_ERROR, "mount_cdfs: %m"); return error; } return 0; } static int cdfs_umount(am_node *am, mntfs *mf) { int unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; return UMOUNT_FS(mf->mf_mount, mnttab_file_name, unmount_flags); } am-utils-6.2+rc20110530/amd/ops_efs.c000066400000000000000000000115171157065440000167020ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_efs.c * */ /* * Irix UN*X file system: EFS (Extent File System) */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward declarations */ static char *efs_match(am_opts *fo); static int efs_mount(am_node *am, mntfs *mf); static int efs_umount(am_node *am, mntfs *mf); /* * Ops structure */ am_ops efs_ops = { "efs", efs_match, 0, /* efs_init */ efs_mount, efs_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* efs_readlink */ 0, /* efs_mounted */ 0, /* efs_umounted */ amfs_generic_find_srvr, 0, /* efs_get_wchan */ FS_MKMNT | FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_EFS_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * EFS needs local filesystem and device. */ static char * efs_match(am_opts *fo) { if (!fo->opt_dev) { plog(XLOG_USER, "efs: no device specified"); return 0; } dlog("EFS: mounting device \"%s\" on \"%s\"", fo->opt_dev, fo->opt_fs); /* * Determine magic cookie to put in mtab */ return strdup(fo->opt_dev); } static int mount_efs(char *mntdir, char *fs_name, char *opts, int on_autofs) { efs_args_t efs_args; mntent_t mnt; int flags; /* * Figure out the name of the file system type. */ MTYPE_TYPE type = MOUNT_TYPE_EFS; memset((voidp) &efs_args, 0, sizeof(efs_args)); /* Paranoid */ /* * Fill in the mount structure */ memset((voidp) &mnt, 0, sizeof(mnt)); mnt.mnt_dir = mntdir; mnt.mnt_fsname = fs_name; mnt.mnt_type = MNTTAB_TYPE_EFS; mnt.mnt_opts = opts; flags = compute_mount_flags(&mnt); #ifdef HAVE_FS_AUTOFS if (on_autofs) flags |= autofs_compute_mount_flags(&mnt); #endif /* HAVE_FS_AUTOFS */ #ifdef HAVE_EFS_ARGS_T_FLAGS efs_args.flags = 0; /* XXX: fix this to correct flags */ #endif /* HAVE_EFS_ARGS_T_FLAGS */ #ifdef HAVE_EFS_ARGS_T_FSPEC efs_args.fspec = fs_name; #endif /* HAVE_EFS_ARGS_T_FSPEC */ #if defined(HAVE_EFS_ARGS_T_VERSION) && defined(EFS_MNT_VERSION) efs_args.version = EFS_MNT_VERSION; #endif /* HAVE_EFS_ARGS_T_VERSION && EFS_MNT_VERSION */ /* * Call generic mount routine */ return mount_fs(&mnt, flags, (caddr_t) &efs_args, 0, type, 0, NULL, mnttab_file_name, on_autofs); } static int efs_mount(am_node *am, mntfs *mf) { int on_autofs = mf->mf_flags & MFF_ON_AUTOFS; int error; error = mount_efs(mf->mf_mount, mf->mf_info, mf->mf_mopts, on_autofs); if (error) { errno = error; plog(XLOG_ERROR, "mount_efs: %m"); return error; } return 0; } static int efs_umount(am_node *am, mntfs *mf) { int unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; return UMOUNT_FS(mf->mf_mount, mnttab_file_name, unmount_flags); } am-utils-6.2+rc20110530/amd/ops_lofs.c000066400000000000000000000105461157065440000170710ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_lofs.c * */ /* * Loopback file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward definitions */ static char *lofs_match(am_opts *fo); static int lofs_mount(am_node *am, mntfs *mf); static int lofs_umount(am_node *am, mntfs *mf); /* * Ops structure */ am_ops lofs_ops = { "lofs", lofs_match, 0, /* lofs_init */ lofs_mount, lofs_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* lofs_readlink */ 0, /* lofs_mounted */ 0, /* lofs_umounted */ amfs_generic_find_srvr, 0, /* lofs_get_wchan */ FS_MKMNT | FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_LOFS_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * LOFS needs remote filesystem. */ static char * lofs_match(am_opts *fo) { if (!fo->opt_rfs) { plog(XLOG_USER, "lofs: no source filesystem specified"); return 0; } dlog("LOFS: mounting fs \"%s\" on \"%s\"", fo->opt_rfs, fo->opt_fs); /* * Determine magic cookie to put in mtab */ return strdup(fo->opt_rfs); } int mount_lofs(char *mntdir, char *fs_name, char *opts, int on_autofs) { mntent_t mnt; int flags; /* * Figure out the name of the file system type. */ MTYPE_TYPE type = MOUNT_TYPE_LOFS; /* * Fill in the mount structure */ memset((voidp) &mnt, 0, sizeof(mnt)); mnt.mnt_dir = mntdir; mnt.mnt_fsname = fs_name; mnt.mnt_type = MNTTAB_TYPE_LOFS; mnt.mnt_opts = opts; flags = compute_mount_flags(&mnt); #ifdef HAVE_FS_AUTOFS if (on_autofs) flags |= autofs_compute_mount_flags(&mnt); #endif /* HAVE_FS_AUTOFS */ /* * Call generic mount routine */ return mount_fs(&mnt, flags, NULL, 0, type, 0, NULL, mnttab_file_name, on_autofs); } static int lofs_mount(am_node *am, mntfs *mf) { int on_autofs = mf->mf_flags & MFF_ON_AUTOFS; int error; error = mount_lofs(mf->mf_mount, mf->mf_info, mf->mf_mopts, on_autofs); if (error) { errno = error; plog(XLOG_ERROR, "mount_lofs: %m"); return error; } return 0; } static int lofs_umount(am_node *am, mntfs *mf) { int unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; return UMOUNT_FS(mf->mf_mount, mnttab_file_name, unmount_flags); } am-utils-6.2+rc20110530/amd/ops_mfs.c000066400000000000000000000044421157065440000167110ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_mfs.c * */ /* * Memory file system (RAM filesystem) */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* FEEL FREE TO IMPLEMENT THIS... :-) */ am-utils-6.2+rc20110530/amd/ops_nfs.c000066400000000000000000000715251157065440000167200ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_nfs.c * */ /* * Network file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Convert from nfsstat to UN*X error code */ #define unx_error(e) ((int)(e)) /* * FH_TTL is the time a file handle will remain in the cache since * last being used. If the file handle becomes invalid, then it * will be flushed anyway. */ #define FH_TTL (5 * 60) /* five minutes */ #define FH_TTL_ERROR (30) /* 30 seconds */ #define FHID_ALLOC() (++fh_id) /* * The NFS layer maintains a cache of file handles. * This is *fundamental* to the implementation and * also allows quick remounting when a filesystem * is accessed soon after timing out. * * The NFS server layer knows to flush this cache * when a server goes down so avoiding stale handles. * * Each cache entry keeps a hard reference to * the corresponding server. This ensures that * the server keepalive information is maintained. * * The copy of the sockaddr_in here is taken so * that the port can be twiddled to talk to mountd * instead of portmap or the NFS server as used * elsewhere. * The port# is flushed if a server goes down. * The IP address is never flushed - we assume * that the address of a mounted machine never * changes. If it does, then you have other * problems... */ typedef struct fh_cache fh_cache; struct fh_cache { qelem fh_q; /* List header */ wchan_t fh_wchan; /* Wait channel */ int fh_error; /* Valid data? */ int fh_id; /* Unique id */ int fh_cid; /* Callout id */ u_long fh_nfs_version; /* highest NFS version on host */ am_nfs_handle_t fh_nfs_handle; /* Handle on filesystem */ int fh_status; /* Status of last rpc */ struct sockaddr_in fh_sin; /* Address of mountd */ fserver *fh_fs; /* Server holding filesystem */ char *fh_path; /* Filesystem on host */ }; /* forward definitions */ static int nfs_init(mntfs *mf); static char *nfs_match(am_opts *fo); static int nfs_mount(am_node *am, mntfs *mf); static int nfs_umount(am_node *am, mntfs *mf); static void nfs_umounted(mntfs *mf); static int call_mountd(fh_cache *fp, u_long proc, fwd_fun f, wchan_t wchan); static int webnfs_lookup(fh_cache *fp, fwd_fun f, wchan_t wchan); static int fh_id = 0; /* globals */ AUTH *nfs_auth; qelem fh_head = {&fh_head, &fh_head}; /* * Network file system operations */ am_ops nfs_ops = { "nfs", nfs_match, nfs_init, nfs_mount, nfs_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* nfs_readlink */ 0, /* nfs_mounted */ nfs_umounted, find_nfs_srvr, 0, /* nfs_get_wchan */ FS_MKMNT | FS_BACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_NFS_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; static fh_cache * find_nfs_fhandle_cache(opaque_t arg, int done) { fh_cache *fp, *fp2 = NULL; int id = (long) arg; /* for 64-bit archs */ ITER(fp, fh_cache, &fh_head) { if (fp->fh_id == id) { fp2 = fp; break; } } if (fp2) { dlog("fh cache gives fp %#lx, fs %s", (unsigned long) fp2, fp2->fh_path); } else { dlog("fh cache search failed"); } if (fp2 && !done) { fp2->fh_error = ETIMEDOUT; return 0; } return fp2; } /* * Called when a filehandle appears via the mount protocol */ static void got_nfs_fh_mount(voidp pkt, int len, struct sockaddr_in *sa, struct sockaddr_in *ia, opaque_t arg, int done) { fh_cache *fp; struct fhstatus res; #ifdef HAVE_FS_NFS3 struct am_mountres3 res3; #endif /* HAVE_FS_NFS3 */ fp = find_nfs_fhandle_cache(arg, done); if (!fp) return; /* * retrieve the correct RPC reply for the file handle, based on the * NFS protocol version. */ #ifdef HAVE_FS_NFS3 if (fp->fh_nfs_version == NFS_VERSION3) { memset(&res3, 0, sizeof(res3)); fp->fh_error = pickup_rpc_reply(pkt, len, (voidp) &res3, (XDRPROC_T_TYPE) xdr_am_mountres3); fp->fh_status = unx_error(res3.fhs_status); memset(&fp->fh_nfs_handle.v3, 0, sizeof(am_nfs_fh3)); fp->fh_nfs_handle.v3.am_fh3_length = res3.mountres3_u.mountinfo.fhandle.fhandle3_len; memmove(fp->fh_nfs_handle.v3.am_fh3_data, res3.mountres3_u.mountinfo.fhandle.fhandle3_val, fp->fh_nfs_handle.v3.am_fh3_length); XFREE(res3.mountres3_u.mountinfo.fhandle.fhandle3_val); if (res3.mountres3_u.mountinfo.auth_flavors.auth_flavors_val) XFREE(res3.mountres3_u.mountinfo.auth_flavors.auth_flavors_val); } else { #endif /* HAVE_FS_NFS3 */ memset(&res, 0, sizeof(res)); fp->fh_error = pickup_rpc_reply(pkt, len, (voidp) &res, (XDRPROC_T_TYPE) xdr_fhstatus); fp->fh_status = unx_error(res.fhs_status); memmove(&fp->fh_nfs_handle.v2, &res.fhs_fh, NFS_FHSIZE); #ifdef HAVE_FS_NFS3 } #endif /* HAVE_FS_NFS3 */ if (!fp->fh_error) { dlog("got filehandle for %s:%s", fp->fh_fs->fs_host, fp->fh_path); } else { plog(XLOG_USER, "filehandle denied for %s:%s", fp->fh_fs->fs_host, fp->fh_path); /* * Force the error to be EACCES. It's debatable whether it should be * ENOENT instead, but the server really doesn't give us any clues, and * EACCES is more in line with the "filehandle denied" message. */ fp->fh_error = EACCES; } /* * Wakeup anything sleeping on this filehandle */ if (fp->fh_wchan) { dlog("Calling wakeup on %#lx", (unsigned long) fp->fh_wchan); wakeup(fp->fh_wchan); } } /* * Called when a filehandle appears via WebNFS */ static void got_nfs_fh_webnfs(voidp pkt, int len, struct sockaddr_in *sa, struct sockaddr_in *ia, opaque_t arg, int done) { fh_cache *fp; nfsdiropres res; #ifdef HAVE_FS_NFS3 am_LOOKUP3res res3; #endif /* HAVE_FS_NFS3 */ fp = find_nfs_fhandle_cache(arg, done); if (!fp) return; /* * retrieve the correct RPC reply for the file handle, based on the * NFS protocol version. */ #ifdef HAVE_FS_NFS3 if (fp->fh_nfs_version == NFS_VERSION3) { memset(&res3, 0, sizeof(res3)); fp->fh_error = pickup_rpc_reply(pkt, len, (voidp) &res3, (XDRPROC_T_TYPE) xdr_am_LOOKUP3res); fp->fh_status = unx_error(res3.status); memset(&fp->fh_nfs_handle.v3, 0, sizeof(am_nfs_fh3)); fp->fh_nfs_handle.v3.am_fh3_length = res3.res_u.ok.object.am_fh3_length; memmove(fp->fh_nfs_handle.v3.am_fh3_data, res3.res_u.ok.object.am_fh3_data, fp->fh_nfs_handle.v3.am_fh3_length); } else { #endif /* HAVE_FS_NFS3 */ memset(&res, 0, sizeof(res)); fp->fh_error = pickup_rpc_reply(pkt, len, (voidp) &res, (XDRPROC_T_TYPE) xdr_diropres); fp->fh_status = unx_error(res.dr_status); memmove(&fp->fh_nfs_handle.v2, &res.dr_u.dr_drok_u.drok_fhandle, NFS_FHSIZE); #ifdef HAVE_FS_NFS3 } #endif /* HAVE_FS_NFS3 */ if (!fp->fh_error) { dlog("got filehandle for %s:%s", fp->fh_fs->fs_host, fp->fh_path); } else { plog(XLOG_USER, "filehandle denied for %s:%s", fp->fh_fs->fs_host, fp->fh_path); /* * Force the error to be EACCES. It's debatable whether it should be * ENOENT instead, but the server really doesn't give us any clues, and * EACCES is more in line with the "filehandle denied" message. */ fp->fh_error = EACCES; } /* * Wakeup anything sleeping on this filehandle */ if (fp->fh_wchan) { dlog("Calling wakeup on %#lx", (unsigned long) fp->fh_wchan); wakeup(fp->fh_wchan); } } void flush_nfs_fhandle_cache(fserver *fs) { fh_cache *fp; ITER(fp, fh_cache, &fh_head) { if (fp->fh_fs == fs || fs == NULL) { /* * Only invalidate port info for non-WebNFS servers */ if (!(fp->fh_fs->fs_flags & FSF_WEBNFS)) fp->fh_sin.sin_port = (u_short) 0; fp->fh_error = -1; } } } static void discard_fh(opaque_t arg) { fh_cache *fp = (fh_cache *) arg; rem_que(&fp->fh_q); if (fp->fh_fs) { dlog("Discarding filehandle for %s:%s", fp->fh_fs->fs_host, fp->fh_path); free_srvr(fp->fh_fs); } if (fp->fh_path) XFREE(fp->fh_path); XFREE(fp); } /* * Determine the file handle for a node */ static int prime_nfs_fhandle_cache(char *path, fserver *fs, am_nfs_handle_t *fhbuf, mntfs *mf) { fh_cache *fp, *fp_save = NULL; int error; int reuse_id = FALSE; dlog("Searching cache for %s:%s", fs->fs_host, path); /* * First search the cache */ ITER(fp, fh_cache, &fh_head) { if (fs != fp->fh_fs || !STREQ(path, fp->fh_path)) continue; /* skip to next ITER item */ /* else we got a match */ switch (fp->fh_error) { case 0: plog(XLOG_INFO, "prime_nfs_fhandle_cache: NFS version %d", (int) fp->fh_nfs_version); error = fp->fh_error = fp->fh_status; if (error == 0) { if (mf->mf_flags & MFF_NFS_SCALEDOWN) { fp_save = fp; /* XXX: why reuse the ID? */ reuse_id = TRUE; break; } if (fhbuf) { #ifdef HAVE_FS_NFS3 if (fp->fh_nfs_version == NFS_VERSION3) { memmove((voidp) &(fhbuf->v3), (voidp) &(fp->fh_nfs_handle.v3), sizeof(fp->fh_nfs_handle.v3)); } else #endif /* HAVE_FS_NFS3 */ { memmove((voidp) &(fhbuf->v2), (voidp) &(fp->fh_nfs_handle.v2), sizeof(fp->fh_nfs_handle.v2)); } } if (fp->fh_cid) untimeout(fp->fh_cid); fp->fh_cid = timeout(FH_TTL, discard_fh, (opaque_t) fp); } else if (error == EACCES) { /* * Now decode the file handle return code. */ plog(XLOG_INFO, "Filehandle denied for \"%s:%s\"", fs->fs_host, path); } else { errno = error; /* XXX */ plog(XLOG_INFO, "Filehandle error for \"%s:%s\": %m", fs->fs_host, path); } /* * The error was returned from the remote mount daemon. * Policy: this error will be cached for now... */ return error; case -1: /* * Still thinking about it, but we can re-use. */ fp_save = fp; reuse_id = TRUE; break; default: /* * Return the error. * Policy: make sure we recompute if required again * in case this was caused by a network failure. * This can thrash mountd's though... If you find * your mountd going slowly then: * 1. Add a fork() loop to main. * 2. Remove the call to innetgr() and don't use * netgroups, especially if you don't use YP. */ error = fp->fh_error; fp->fh_error = -1; return error; } /* end of switch statement */ } /* end of ITER loop */ /* * Not in cache */ if (fp_save) { fp = fp_save; /* * Re-use existing slot */ untimeout(fp->fh_cid); free_srvr(fp->fh_fs); XFREE(fp->fh_path); } else { fp = ALLOC(struct fh_cache); memset((voidp) fp, 0, sizeof(struct fh_cache)); ins_que(&fp->fh_q, &fh_head); } if (!reuse_id) fp->fh_id = FHID_ALLOC(); fp->fh_wchan = get_mntfs_wchan(mf); fp->fh_error = -1; fp->fh_cid = timeout(FH_TTL, discard_fh, (opaque_t) fp); /* * If fs->fs_ip is null, remote server is probably down. */ if (!fs->fs_ip) { /* Mark the fileserver down and invalid again */ fs->fs_flags &= ~FSF_VALID; fs->fs_flags |= FSF_DOWN; error = AM_ERRNO_HOST_DOWN; return error; } /* * Either fp has been freshly allocated or the address has changed. * Initialize address and nfs version. Don't try to re-use the port * information unless using WebNFS where the port is fixed either by * the spec or the "port" mount option. */ if (fp->fh_sin.sin_addr.s_addr != fs->fs_ip->sin_addr.s_addr) { fp->fh_sin = *fs->fs_ip; if (!(mf->mf_flags & MFF_WEBNFS)) fp->fh_sin.sin_port = 0; fp->fh_nfs_version = fs->fs_version; } fp->fh_fs = dup_srvr(fs); fp->fh_path = strdup(path); if (mf->mf_flags & MFF_WEBNFS) error = webnfs_lookup(fp, got_nfs_fh_webnfs, get_mntfs_wchan(mf)); else error = call_mountd(fp, MOUNTPROC_MNT, got_nfs_fh_mount, get_mntfs_wchan(mf)); if (error) { /* * Local error - cache for a short period * just to prevent thrashing. */ untimeout(fp->fh_cid); fp->fh_cid = timeout(error < 0 ? 2 * ALLOWED_MOUNT_TIME : FH_TTL_ERROR, discard_fh, (opaque_t) fp); fp->fh_error = error; } else { error = fp->fh_error; } return error; } int make_nfs_auth(void) { AUTH_CREATE_GIDLIST_TYPE group_wheel = 0; /* Some NFS mounts (particularly cross-domain) require FQDNs to succeed */ #ifdef HAVE_TRANSPORT_TYPE_TLI if (gopt.flags & CFM_FULLY_QUALIFIED_HOSTS) { plog(XLOG_INFO, "Using NFS auth for FQHN \"%s\"", hostd); nfs_auth = authsys_create(hostd, 0, 0, 1, &group_wheel); } else { nfs_auth = authsys_create_default(); } #else /* not HAVE_TRANSPORT_TYPE_TLI */ if (gopt.flags & CFM_FULLY_QUALIFIED_HOSTS) { plog(XLOG_INFO, "Using NFS auth for FQHN \"%s\"", hostd); nfs_auth = authunix_create(hostd, 0, 0, 1, &group_wheel); } else { nfs_auth = authunix_create_default(); } #endif /* not HAVE_TRANSPORT_TYPE_TLI */ if (!nfs_auth) return ENOBUFS; return 0; } static int call_mountd(fh_cache *fp, u_long proc, fwd_fun fun, wchan_t wchan) { struct rpc_msg mnt_msg; int len; char iobuf[UDPMSGSIZE]; int error; u_long mnt_version; if (!nfs_auth) { error = make_nfs_auth(); if (error) return error; } if (fp->fh_sin.sin_port == 0) { u_short mountd_port; error = get_mountd_port(fp->fh_fs, &mountd_port, wchan); if (error) return error; fp->fh_sin.sin_port = mountd_port; } /* find the right version of the mount protocol */ #ifdef HAVE_FS_NFS3 if (fp->fh_nfs_version == NFS_VERSION3) mnt_version = AM_MOUNTVERS3; else #endif /* HAVE_FS_NFS3 */ mnt_version = MOUNTVERS; plog(XLOG_INFO, "call_mountd: NFS version %d, mount version %d", (int) fp->fh_nfs_version, (int) mnt_version); rpc_msg_init(&mnt_msg, MOUNTPROG, mnt_version, MOUNTPROC_NULL); len = make_rpc_packet(iobuf, sizeof(iobuf), proc, &mnt_msg, (voidp) &fp->fh_path, (XDRPROC_T_TYPE) xdr_nfspath, nfs_auth); if (len > 0) { error = fwd_packet(MK_RPC_XID(RPC_XID_MOUNTD, fp->fh_id), iobuf, len, &fp->fh_sin, &fp->fh_sin, (opaque_t) ((long) fp->fh_id), /* cast to long needed for 64-bit archs */ fun); } else { error = -len; } /* * It may be the case that we're sending to the wrong MOUNTD port. This * occurs if mountd is restarted on the server after the port has been * looked up and stored in the filehandle cache somewhere. The correct * solution, if we're going to cache port numbers is to catch the ICMP * port unreachable reply from the server and cause the portmap request * to be redone. The quick solution here is to invalidate the MOUNTD * port. */ fp->fh_sin.sin_port = 0; return error; } static int webnfs_lookup(fh_cache *fp, fwd_fun fun, wchan_t wchan) { struct rpc_msg wnfs_msg; int len; char iobuf[UDPMSGSIZE]; int error; u_long proc; XDRPROC_T_TYPE xdr_fn; voidp argp; nfsdiropargs args; #ifdef HAVE_FS_NFS3 am_LOOKUP3args args3; #endif /* HAVE_FS_NFS3 */ char *wnfs_path; size_t l; if (!nfs_auth) { error = make_nfs_auth(); if (error) return error; } if (fp->fh_sin.sin_port == 0) { /* FIXME: wrong, don't discard sin_port in the first place for WebNFS. */ plog(XLOG_WARNING, "webnfs_lookup: port == 0 for nfs on %s, fixed", fp->fh_fs->fs_host); fp->fh_sin.sin_port = htons(NFS_PORT); } /* * Use native path like the rest of amd (cf. RFC 2054, 6.1). */ l = strlen(fp->fh_path) + 2; wnfs_path = (char *) xmalloc(l); wnfs_path[0] = 0x80; xstrlcpy(wnfs_path + 1, fp->fh_path, l - 1); /* find the right program and lookup procedure */ #ifdef HAVE_FS_NFS3 if (fp->fh_nfs_version == NFS_VERSION3) { proc = AM_NFSPROC3_LOOKUP; xdr_fn = (XDRPROC_T_TYPE) xdr_am_LOOKUP3args; argp = &args3; /* WebNFS public file handle */ args3.what.dir.am_fh3_length = 0; args3.what.name = wnfs_path; } else { #endif /* HAVE_FS_NFS3 */ proc = NFSPROC_LOOKUP; xdr_fn = (XDRPROC_T_TYPE) xdr_diropargs; argp = &args; /* WebNFS public file handle */ memset(&args.da_fhandle, 0, NFS_FHSIZE); args.da_name = wnfs_path; #ifdef HAVE_FS_NFS3 } #endif /* HAVE_FS_NFS3 */ plog(XLOG_INFO, "webnfs_lookup: NFS version %d", (int) fp->fh_nfs_version); rpc_msg_init(&wnfs_msg, NFS_PROGRAM, fp->fh_nfs_version, proc); len = make_rpc_packet(iobuf, sizeof(iobuf), proc, &wnfs_msg, argp, (XDRPROC_T_TYPE) xdr_fn, nfs_auth); if (len > 0) { error = fwd_packet(MK_RPC_XID(RPC_XID_WEBNFS, fp->fh_id), iobuf, len, &fp->fh_sin, &fp->fh_sin, (opaque_t) ((long) fp->fh_id), /* cast to long needed for 64-bit archs */ fun); } else { error = -len; } XFREE(wnfs_path); return error; } /* * NFS needs the local filesystem, remote filesystem * remote hostname. * Local filesystem defaults to remote and vice-versa. */ static char * nfs_match(am_opts *fo) { char *xmtab; size_t l; if (fo->opt_fs && !fo->opt_rfs) fo->opt_rfs = fo->opt_fs; if (!fo->opt_rfs) { plog(XLOG_USER, "nfs: no remote filesystem specified"); return NULL; } if (!fo->opt_rhost) { plog(XLOG_USER, "nfs: no remote host specified"); return NULL; } /* * Determine magic cookie to put in mtab */ l = strlen(fo->opt_rhost) + strlen(fo->opt_rfs) + 2; xmtab = (char *) xmalloc(l); xsnprintf(xmtab, l, "%s:%s", fo->opt_rhost, fo->opt_rfs); dlog("NFS: mounting remote server \"%s\", remote fs \"%s\" on \"%s\"", fo->opt_rhost, fo->opt_rfs, fo->opt_fs); return xmtab; } /* * Initialize am structure for nfs */ static int nfs_init(mntfs *mf) { int error; am_nfs_handle_t fhs; char *colon; if (mf->mf_private) { if (mf->mf_flags & MFF_NFS_SCALEDOWN) { fserver *fs; /* tell remote mountd that we're done with this filehandle */ mf->mf_ops->umounted(mf); mf->mf_prfree(mf->mf_private); mf->mf_private = NULL; mf->mf_prfree = NULL; fs = mf->mf_ops->ffserver(mf); free_srvr(mf->mf_server); mf->mf_server = fs; } else return 0; } colon = strchr(mf->mf_info, ':'); if (colon == 0) return ENOENT; error = prime_nfs_fhandle_cache(colon + 1, mf->mf_server, &fhs, mf); if (!error) { mf->mf_private = (opaque_t) ALLOC(am_nfs_handle_t); mf->mf_prfree = (void (*)(opaque_t)) free; memmove(mf->mf_private, (voidp) &fhs, sizeof(fhs)); } return error; } int mount_nfs_fh(am_nfs_handle_t *fhp, char *mntdir, char *fs_name, mntfs *mf) { MTYPE_TYPE type; char *colon; char *xopts=NULL, transp_timeo_opts[40], transp_retrans_opts[40]; char host[MAXHOSTNAMELEN + MAXPATHLEN + 2]; fserver *fs = mf->mf_server; u_long nfs_version = fs->fs_version; char *nfs_proto = fs->fs_proto; /* "tcp" or "udp" */ int on_autofs = mf->mf_flags & MFF_ON_AUTOFS; int error; int genflags; int retry; int proto = AMU_TYPE_NONE; mntent_t mnt; nfs_args_t nfs_args; /* * Extract HOST name to give to kernel. * Some systems like osf1/aix3/bsd44 variants may need old code * for NFS_ARGS_NEEDS_PATH. */ if (!(colon = strchr(fs_name, ':'))) return ENOENT; #ifdef MOUNT_TABLE_ON_FILE *colon = '\0'; #endif /* MOUNT_TABLE_ON_FILE */ xstrlcpy(host, fs_name, sizeof(host)); #ifdef MOUNT_TABLE_ON_FILE *colon = ':'; #endif /* MOUNT_TABLE_ON_FILE */ #ifdef MAXHOSTNAMELEN /* most kernels have a name length restriction */ if (strlen(host) >= MAXHOSTNAMELEN) xstrlcpy(host + MAXHOSTNAMELEN - 3, "..", sizeof(host) - MAXHOSTNAMELEN + 3); #endif /* MAXHOSTNAMELEN */ /* * Create option=VAL for udp/tcp specific timeouts and retrans values, but * only if these options were specified. */ transp_timeo_opts[0] = transp_retrans_opts[0] = '\0'; /* initialize */ if (STREQ(nfs_proto, "udp")) proto = AMU_TYPE_UDP; else if (STREQ(nfs_proto, "tcp")) proto = AMU_TYPE_TCP; if (proto != AMU_TYPE_NONE) { if (gopt.amfs_auto_timeo[proto] > 0) xsnprintf(transp_timeo_opts, sizeof(transp_timeo_opts), "%s=%d,", MNTTAB_OPT_TIMEO, gopt.amfs_auto_timeo[proto]); if (gopt.amfs_auto_retrans[proto] > 0) xsnprintf(transp_retrans_opts, sizeof(transp_retrans_opts), "%s=%d,", MNTTAB_OPT_RETRANS, gopt.amfs_auto_retrans[proto]); } if (mf->mf_remopts && *mf->mf_remopts && !islocalnet(fs->fs_ip->sin_addr.s_addr)) { plog(XLOG_INFO, "Using remopts=\"%s\"", mf->mf_remopts); /* use transp_opts first, so map-specific opts will override */ xopts = str3cat(xopts, transp_timeo_opts, transp_retrans_opts, mf->mf_remopts); } else { /* use transp_opts first, so map-specific opts will override */ xopts = str3cat(xopts, transp_timeo_opts, transp_retrans_opts, mf->mf_mopts); } memset((voidp) &mnt, 0, sizeof(mnt)); mnt.mnt_dir = mntdir; mnt.mnt_fsname = fs_name; mnt.mnt_opts = xopts; /* * Set mount types accordingly */ #ifndef HAVE_FS_NFS3 type = MOUNT_TYPE_NFS; mnt.mnt_type = MNTTAB_TYPE_NFS; #else /* HAVE_FS_NFS3 */ if (nfs_version == NFS_VERSION3) { type = MOUNT_TYPE_NFS3; /* * Systems that include the mount table "vers" option generally do not * set the mnttab entry to "nfs3", but to "nfs" and then they set * "vers=3". Setting it to "nfs3" works, but it may break some things * like "df -t nfs" and the "quota" program (esp. on Solaris and Irix). * So on those systems, set it to "nfs". * Note: MNTTAB_OPT_VERS is always set for NFS3 (see am_compat.h). */ # if defined(MNTTAB_OPT_VERS) && defined(MOUNT_TABLE_ON_FILE) mnt.mnt_type = MNTTAB_TYPE_NFS; # else /* defined(MNTTAB_OPT_VERS) && defined(MOUNT_TABLE_ON_FILE) */ mnt.mnt_type = MNTTAB_TYPE_NFS3; # endif /* defined(MNTTAB_OPT_VERS) && defined(MOUNT_TABLE_ON_FILE) */ } else { type = MOUNT_TYPE_NFS; mnt.mnt_type = MNTTAB_TYPE_NFS; } #endif /* HAVE_FS_NFS3 */ plog(XLOG_INFO, "mount_nfs_fh: NFS version %d", (int) nfs_version); plog(XLOG_INFO, "mount_nfs_fh: using NFS transport %s", nfs_proto); retry = hasmntval(&mnt, MNTTAB_OPT_RETRY); if (retry <= 0) retry = 1; /* XXX */ genflags = compute_mount_flags(&mnt); #ifdef HAVE_FS_AUTOFS if (on_autofs) genflags |= autofs_compute_mount_flags(&mnt); #endif /* HAVE_FS_AUTOFS */ /* setup the many fields and flags within nfs_args */ compute_nfs_args(&nfs_args, &mnt, genflags, NULL, /* struct netconfig *nfsncp */ fs->fs_ip, nfs_version, nfs_proto, fhp, host, fs_name); /* finally call the mounting function */ if (amuDebug(D_TRACE)) { print_nfs_args(&nfs_args, nfs_version); plog(XLOG_DEBUG, "Generic mount flags 0x%x used for NFS mount", genflags); } error = mount_fs(&mnt, genflags, (caddr_t) &nfs_args, retry, type, nfs_version, nfs_proto, mnttab_file_name, on_autofs); XFREE(xopts); #ifdef HAVE_TRANSPORT_TYPE_TLI free_knetconfig(nfs_args.knconf); if (nfs_args.addr) XFREE(nfs_args.addr); /* allocated in compute_nfs_args() */ #endif /* HAVE_TRANSPORT_TYPE_TLI */ return error; } static int nfs_mount(am_node *am, mntfs *mf) { int error = 0; mntent_t mnt; if (!mf->mf_private) { plog(XLOG_ERROR, "Missing filehandle for %s", mf->mf_info); return EINVAL; } mnt.mnt_opts = mf->mf_mopts; if (amu_hasmntopt(&mnt, "softlookup") || (amu_hasmntopt(&mnt, "soft") && !amu_hasmntopt(&mnt, "nosoftlookup"))) am->am_flags |= AMF_SOFTLOOKUP; error = mount_nfs_fh((am_nfs_handle_t *) mf->mf_private, mf->mf_mount, mf->mf_info, mf); if (error) { errno = error; dlog("mount_nfs: %m"); } return error; } static int nfs_umount(am_node *am, mntfs *mf) { int unmount_flags, new_unmount_flags, error; dlog("attempting nfs umount"); unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; error = UMOUNT_FS(mf->mf_mount, mnttab_file_name, unmount_flags); #if defined(HAVE_UMOUNT2) && (defined(MNT2_GEN_OPT_FORCE) || defined(MNT2_GEN_OPT_DETACH)) /* * If the attempt to unmount failed with EBUSY, and this fserver was * marked for forced unmounts, then use forced/lazy unmounts. */ if (error == EBUSY && gopt.flags & CFM_FORCED_UNMOUNTS && mf->mf_server->fs_flags & FSF_FORCE_UNMOUNT) { plog(XLOG_INFO, "EZK: nfs_umount: trying forced/lazy unmounts"); /* * XXX: turning off the FSF_FORCE_UNMOUNT may not be perfectly * incorrect. Multiple nodes may need to be timed out and restarted for * a single hung fserver. */ mf->mf_server->fs_flags &= ~FSF_FORCE_UNMOUNT; new_unmount_flags = unmount_flags | AMU_UMOUNT_FORCE | AMU_UMOUNT_DETACH; error = UMOUNT_FS(mf->mf_mount, mnttab_file_name, new_unmount_flags); } #endif /* HAVE_UMOUNT2 && (MNT2_GEN_OPT_FORCE || MNT2_GEN_OPT_DETACH) */ /* * Here is some code to unmount 'restarted' file systems. * The restarted file systems are marked as 'nfs', not * 'host', so we only have the map information for the * the top-level mount. The unmount will fail (EBUSY) * if there are anything else from the NFS server mounted * below the mount-point. This code checks to see if there * is anything mounted with the same prefix as the * file system to be unmounted ("/a/b/c" when unmounting "/a/b"). * If there is, and it is a 'restarted' file system, we unmount * it. * Added by Mike Mitchell, mcm@unx.sas.com, 09/08/93 */ if (error == EBUSY) { mntfs *new_mf; int len = strlen(mf->mf_mount); int didsome = 0; ITER(new_mf, mntfs, &mfhead) { if (new_mf->mf_ops != mf->mf_ops || new_mf->mf_refc > 1 || mf == new_mf || ((new_mf->mf_flags & (MFF_MOUNTED | MFF_UNMOUNTING | MFF_RESTART)) == (MFF_MOUNTED | MFF_RESTART))) continue; if (NSTREQ(mf->mf_mount, new_mf->mf_mount, len) && new_mf->mf_mount[len] == '/') { new_unmount_flags = (new_mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; UMOUNT_FS(new_mf->mf_mount, mnttab_file_name, new_unmount_flags); didsome = 1; } } if (didsome) error = UMOUNT_FS(mf->mf_mount, mnttab_file_name, unmount_flags); } if (error) return error; return 0; } static void nfs_umounted(mntfs *mf) { fserver *fs; char *colon, *path; if (mf->mf_error || mf->mf_refc > 1) return; /* * No need to inform mountd when WebNFS is in use. */ if (mf->mf_flags & MFF_WEBNFS) return; /* * Call the mount daemon on the server to announce that we are not using * the fs any more. * * XXX: This is *wrong*. The mountd should be called when the fhandle is * flushed from the cache, and a reference held to the cached entry while * the fs is mounted... */ fs = mf->mf_server; colon = path = strchr(mf->mf_info, ':'); if (fs && colon) { fh_cache f; dlog("calling mountd for %s", mf->mf_info); *path++ = '\0'; f.fh_path = path; f.fh_sin = *fs->fs_ip; f.fh_sin.sin_port = (u_short) 0; f.fh_nfs_version = fs->fs_version; f.fh_fs = fs; f.fh_id = 0; f.fh_error = 0; prime_nfs_fhandle_cache(colon + 1, mf->mf_server, (am_nfs_handle_t *) NULL, mf); call_mountd(&f, MOUNTPROC_UMNT, (fwd_fun *) NULL, (wchan_t) NULL); *colon = ':'; } } am-utils-6.2+rc20110530/amd/ops_nfs3.c000066400000000000000000000044371157065440000170010ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_nfs3.c * */ /* * Network file system version 3.0 */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* FEEL FREE TO IMPLEMENT THIS... :-) */ am-utils-6.2+rc20110530/amd/ops_nullfs.c000066400000000000000000000045001157065440000174220ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_nullfs.c * */ /* * The null filesystem in BSD-4.4 is similar to the loopback one. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* FEEL FREE TO IMPLEMENT THIS... :-) */ am-utils-6.2+rc20110530/amd/ops_pcfs.c000066400000000000000000000155171157065440000170640ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_pcfs.c * */ /* * PC (MS-DOS) file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward definitions */ static char *pcfs_match(am_opts *fo); static int pcfs_mount(am_node *am, mntfs *mf); static int pcfs_umount(am_node *am, mntfs *mf); /* * Ops structure */ am_ops pcfs_ops = { "pcfs", pcfs_match, 0, /* pcfs_init */ pcfs_mount, pcfs_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* pcfs_readlink */ 0, /* pcfs_mounted */ 0, /* pcfs_umounted */ amfs_generic_find_srvr, 0, /* pcfs_get_wchan */ FS_MKMNT | FS_UBACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_PCFS_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * PCFS needs remote filesystem. */ static char * pcfs_match(am_opts *fo) { if (!fo->opt_dev) { plog(XLOG_USER, "pcfs: no source device specified"); return 0; } dlog("PCFS: mounting device \"%s\" on \"%s\"", fo->opt_dev, fo->opt_fs); /* * Determine magic cookie to put in mtab */ return strdup(fo->opt_dev); } static int mount_pcfs(char *mntdir, char *fs_name, char *opts, int on_autofs) { pcfs_args_t pcfs_args; mntent_t mnt; int flags; #if defined(HAVE_PCFS_ARGS_T_MASK) || defined(HAVE_PCFS_ARGS_T_DIRMASK) int mask; #endif /* defined(HAVE_PCFS_ARGS_T_MASK) || defined(HAVE_PCFS_ARGS_T_DIRMASK) */ #if defined(HAVE_PCFS_ARGS_T_UID) || defined(HAVE_PCFS_ARGS_T_UID) char *str; #endif /* defined(HAVE_PCFS_ARGS_T_UID) || defined(HAVE_PCFS_ARGS_T_UID) */ /* * Figure out the name of the file system type. */ MTYPE_TYPE type = MOUNT_TYPE_PCFS; memset((voidp) &pcfs_args, 0, sizeof(pcfs_args)); /* Paranoid */ /* * Fill in the mount structure */ memset((voidp) &mnt, 0, sizeof(mnt)); mnt.mnt_dir = mntdir; mnt.mnt_fsname = fs_name; mnt.mnt_type = MNTTAB_TYPE_PCFS; mnt.mnt_opts = opts; flags = compute_mount_flags(&mnt); #ifdef HAVE_FS_AUTOFS if (on_autofs) flags |= autofs_compute_mount_flags(&mnt); #endif /* HAVE_FS_AUTOFS */ if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "mount_pcfs: flags=0x%x", (u_int) flags); #ifdef HAVE_PCFS_ARGS_T_FSPEC pcfs_args.fspec = fs_name; #endif /* HAVE_PCFS_ARGS_T_FSPEC */ #ifdef HAVE_PCFS_ARGS_T_MASK pcfs_args.mask = 0777; /* this may be the msdos file modes */ if ((mask = hasmntval(&mnt, MNTTAB_OPT_MASK)) > 0) pcfs_args.mask = mask; if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "mount_pcfs: mask=%o (octal)", (u_int) pcfs_args.mask); #endif /* HAVE_PCFS_ARGS_T_MASK */ #ifdef HAVE_PCFS_ARGS_T_DIRMASK pcfs_args.dirmask = 0777; /* this may be the msdos dir modes */ if ((mask = hasmntval(&mnt, MNTTAB_OPT_DIRMASK)) > 0) pcfs_args.dirmask = mask; if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "mount_pcfs: dirmask=%o (octal)", (u_int) pcfs_args.dirmask); #endif /* HAVE_PCFS_ARGS_T_DIRMASK */ #ifdef HAVE_PCFS_ARGS_T_UID pcfs_args.uid = 0; /* default to root */ if ((str = hasmntstr(&mnt, MNTTAB_OPT_USER)) != NULL) { struct passwd *pw; if ((pw = getpwnam(str)) != NULL) pcfs_args.uid = pw->pw_uid; else /* maybe used passed a UID number, not user name */ pcfs_args.uid = atoi(str); /* atoi returns '0' if it failed */ XFREE(str); } if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "mount_pcfs: uid=%d", (int) pcfs_args.uid); #endif /* HAVE_PCFS_ARGS_T_UID */ #ifdef HAVE_PCFS_ARGS_T_GID pcfs_args.gid = 0; /* default to wheel/root group */ if ((str = hasmntstr(&mnt, MNTTAB_OPT_GROUP)) != NULL) { struct group *gr; if ((gr = getgrnam(str)) != NULL) pcfs_args.gid = gr->gr_gid; else /* maybe used passed a GID number, not group name */ pcfs_args.gid = atoi(str); /* atoi returns '0' if it failed */ XFREE(str); } if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "mount_pcfs: gid=%d", (int) pcfs_args.gid); #endif /* HAVE_PCFS_ARGS_T_GID */ #ifdef HAVE_PCFS_ARGS_T_SECONDSWEST pcfs_args.secondswest = 0; /* XXX: fill in correct values */ #endif /* HAVE_PCFS_ARGS_T_SECONDSWEST */ #ifdef HAVE_PCFS_ARGS_T_DSTTIME pcfs_args.dsttime = 0; /* XXX: fill in correct values */ #endif /* HAVE_PCFS_ARGS_T_DSTTIME */ /* * Call generic mount routine */ return mount_fs(&mnt, flags, (caddr_t) & pcfs_args, 0, type, 0, NULL, mnttab_file_name, on_autofs); } static int pcfs_mount(am_node *am, mntfs *mf) { int on_autofs = mf->mf_flags & MFF_ON_AUTOFS; int error; error = mount_pcfs(mf->mf_mount, mf->mf_info, mf->mf_mopts, on_autofs); if (error) { errno = error; plog(XLOG_ERROR, "mount_pcfs: %m"); return error; } return 0; } static int pcfs_umount(am_node *am, mntfs *mf) { int unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; return UMOUNT_FS(mf->mf_mount, mnttab_file_name, unmount_flags); } am-utils-6.2+rc20110530/amd/ops_tfs.c000066400000000000000000000044261157065440000167220ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_tfs.c * */ /* * Translucent file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* FEEL FREE TO IMPLEMENT THIS... :-) */ am-utils-6.2+rc20110530/amd/ops_tmpfs.c000066400000000000000000000132451157065440000172560ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_tmpfs.c * */ /* * TMPFS file system (combines RAM-fs and swap-fs) */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward declarations */ static char *tmpfs_match(am_opts *fo); static int tmpfs_mount(am_node *am, mntfs *mf); static int tmpfs_umount(am_node *am, mntfs *mf); /* * Ops structure */ am_ops tmpfs_ops = { "tmpfs", tmpfs_match, 0, /* tmpfs_init */ tmpfs_mount, tmpfs_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* tmpfs_readlink */ 0, /* tmpfs_mounted */ 0, /* tmpfs_umounted */ amfs_generic_find_srvr, 0, /* tmpfs_get_wchan */ FS_MKMNT | FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ #if defined(HAVE_FS_AUTOFS) && defined(AUTOFS_TMPFS_FS_FLAGS) AUTOFS_TMPFS_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * EFS needs local filesystem and device. */ static char * tmpfs_match(am_opts *fo) { if (!fo->opt_dev) { plog(XLOG_USER, "tmpfs: no device specified"); return 0; } dlog("EFS: mounting device \"%s\" on \"%s\"", fo->opt_dev, fo->opt_fs); /* * Determine magic cookie to put in mtab */ return strdup(fo->opt_dev); } static int mount_tmpfs(char *mntdir, char *fs_name, char *opts, int on_autofs) { tmpfs_args_t tmpfs_args; mntent_t mnt; int flags; const char *p; (void)&p; /* * Figure out the name of the file system type. */ MTYPE_TYPE type = MOUNT_TYPE_TMPFS; p = NULL; memset((voidp) &tmpfs_args, 0, sizeof(tmpfs_args)); /* Paranoid */ /* * Fill in the mount structure */ memset((voidp) &mnt, 0, sizeof(mnt)); mnt.mnt_dir = mntdir; mnt.mnt_fsname = fs_name; mnt.mnt_type = MNTTAB_TYPE_TMPFS; mnt.mnt_opts = opts; flags = compute_mount_flags(&mnt); #ifdef HAVE_FS_AUTOFS if (on_autofs) flags |= autofs_compute_mount_flags(&mnt); #endif /* HAVE_FS_AUTOFS */ #if defined(HAVE_TMPFS_ARGS_T_TA_VERSION) && defined(TMPFS_ARGS_VERSION) tmpfs_args.ta_version = TMPFS_ARGS_VERSION; #endif /* HAVE_TMPFS_ARGS_T_TA_VERSION && TMPFS_ARGS_VERSION */ #ifdef HAVE_TMPFS_ARGS_T_TA_NODES_MAX if ((p = amu_hasmntopt(&mnt, "nodes")) == NULL) p = "1000000"; tmpfs_args.ta_nodes_max = atoi(p); #endif /* HAVE_TMPFS_ARGS_T_TA_SIZE_MAX */ #ifdef HAVE_TMPFS_ARGS_T_TA_SIZE_MAX if ((p = amu_hasmntopt(&mnt, "size")) == NULL) p = "10000000"; tmpfs_args.ta_size_max = atoi(p); #endif /* HAVE_TMPFS_ARGS_T_TA_SIZE_MAX */ #ifdef HAVE_TMPFS_ARGS_T_TA_ROOT_UID if ((p = amu_hasmntopt(&mnt, "uid")) == NULL) p = "0"; tmpfs_args.ta_root_uid = atoi(p); #endif /* HAVE_TMPFS_ARGS_T_TA_ROOT_UID */ #ifdef HAVE_TMPFS_ARGS_T_TA_ROOT_GID if ((p = amu_hasmntopt(&mnt, "gid")) == NULL) p = "0"; tmpfs_args.ta_root_gid = atoi(p); #endif /* HAVE_TMPFS_ARGS_T_TA_ROOT_GID */ #ifdef HAVE_TMPFS_ARGS_T_TA_ROOT_MODE if ((p = amu_hasmntopt(&mnt, "mode")) == NULL) p = "01777"; tmpfs_args.ta_root_mode = strtol(p, NULL, 8); #endif /* HAVE_TMPFS_ARGS_T_TA_ROOT_MODE */ /* * Call generic mount routine */ return mount_fs(&mnt, flags, (caddr_t) &tmpfs_args, 0, type, 0, NULL, mnttab_file_name, on_autofs); } static int tmpfs_mount(am_node *am, mntfs *mf) { int on_autofs = mf->mf_flags & MFF_ON_AUTOFS; int error; error = mount_tmpfs(mf->mf_mount, mf->mf_info, mf->mf_mopts, on_autofs); if (error) { errno = error; plog(XLOG_ERROR, "mount_tmpfs: %m"); return error; } return 0; } static int tmpfs_umount(am_node *am, mntfs *mf) { int unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; return UMOUNT_FS(mf->mf_mount, mnttab_file_name, unmount_flags); } am-utils-6.2+rc20110530/amd/ops_udf.c000066400000000000000000000172561157065440000167110ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_udf.c * */ /* * UDF file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward definitions */ static char *udf_match(am_opts *fo); static int udf_mount(am_node *am, mntfs *mf); static int udf_umount(am_node *am, mntfs *mf); /* * Ops structure */ am_ops udf_ops = { "udf", udf_match, 0, /* udf_init */ udf_mount, udf_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* udf_readlink */ 0, /* udf_mounted */ 0, /* udf_umounted */ amfs_generic_find_srvr, 0, /* udf_get_wchan */ FS_MKMNT | FS_UBACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_UDF_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; #if defined(HAVE_UDF_ARGS_T_NOBODY_GID) || defined(HAVE_UDF_ARGS_T_NOBODY_UID) static int a_num(const char *s, const char *id_type) { int id; char *ep; id = strtol(s, &ep, 0); if (*ep || s == ep || id < 0) { plog(XLOG_ERROR, "mount_udf: unknown %s: %s", id_type, s); return 0; } return id; } #endif /* defined(HAVE_UDF_ARGS_T_NOBODY_GID) || defined(HAVE_UDF_ARGS_T_NOBODY_UID) */ #if defined(HAVE_UDF_ARGS_T_NOBODY_GID) static gid_t a_gid(const char *s, const char *id_type) { struct group *gr; if ((gr = getgrnam(s)) != NULL) return gr->gr_gid; return a_num(s, id_type); } #endif /* defined(HAVE_UDF_ARGS_T_NOBODY_GID) */ #if defined(HAVE_UDF_ARGS_T_NOBODY_UID) static uid_t a_uid(const char *s, const char *id_type) { struct passwd *pw; if ((pw = getpwnam(s)) != NULL) return pw->pw_uid; return a_num(s, id_type); } #endif /* defined(HAVE_UDF_ARGS_T_NOBODY_UID) */ /* * UDF needs remote filesystem. */ static char * udf_match(am_opts *fo) { if (!fo->opt_dev) { plog(XLOG_USER, "udf: no source device specified"); return 0; } dlog("UDF: mounting device \"%s\" on \"%s\"", fo->opt_dev, fo->opt_fs); /* * Determine magic cookie to put in mtab */ return strdup(fo->opt_dev); } static int mount_udf(char *mntdir, char *fs_name, char *opts, int on_autofs) { udf_args_t udf_args; mntent_t mnt; int flags; char *str; #if defined(HAVE_UDF_ARGS_T_NOBODY_UID) || defined(HAVE_UDF_ARGS_T_ANON_UID) uid_t uid_nobody; gid_t gid_nobody; #endif /* defined(HAVE_UDF_ARGS_T_NOBODY_UID) || defined(HAVE_UDF_ARGS_T_ANON_UID) */ /* * Figure out the name of the file system type. */ MTYPE_TYPE type = MOUNT_TYPE_UDF; #if defined(HAVE_UDF_ARGS_T_NOBODY_UID) || defined(HAVE_UDF_ARGS_T_ANON_UID) uid_nobody = a_uid("nobody", "user"); if (uid_nobody == 0) { plog(XLOG_ERROR, "mount_udf: invalid uid for nobody"); return EPERM; } #endif /* defined(HAVE_UDF_ARGS_T_NOBODY_UID) || defined(HAVE_UDF_ARGS_T_ANON_UID) */ #if defined(HAVE_UDF_ARGS_T_NOBODY_GID) || defined(HAVE_UDF_ARGS_T_ANON_GID) gid_nobody = a_gid("nobody", "group"); if (gid_nobody == 0) { plog(XLOG_ERROR, "mount_udf: invalid gid for nobody"); return EPERM; } #endif /* defined(HAVE_UDF_ARGS_T_NOBODY_GID) || defined(HAVE_UDF_ARGS_T_ANON_GID) */ str = NULL; memset((voidp) &udf_args, 0, sizeof(udf_args)); /* Paranoid */ /* * Fill in the mount structure */ memset((voidp)&mnt, 0, sizeof(mnt)); mnt.mnt_dir = mntdir; mnt.mnt_fsname = fs_name; mnt.mnt_type = MNTTAB_TYPE_UDF; mnt.mnt_opts = opts; flags = compute_mount_flags(&mnt); #ifdef HAVE_UDF_ARGS_T_UDFMFLAGS # if defined(MNT2_UDF_OPT_CLOSESESSION) && defined(MNTTAB_OPT_CLOSESESSION) if (amu_hasmntopt(&mnt, MNTTAB_OPT_CLOSESESSION)) udf_args.udfmflags |= MNT2_UDF_OPT_CLOSESESSION; # endif /* defined(MNT2_UDF_OPT_CLOSESESSION) && defined(MNTTAB_OPT_CLOSESESSION) */ #endif /* HAVE_UDF_ARGS_T_UDFMFLAGS */ #ifdef HAVE_UDF_ARGS_T_NOBODY_UID udf_args.nobody_uid = uid_nobody; #endif /* HAVE_UDF_ARGS_T_NOBODY_UID */ #ifdef HAVE_UDF_ARGS_T_NOBODY_GID udf_args.nobody_gid = gid_nobody; #endif /* HAVE_UDF_ARGS_T_NOBODY_GID */ #ifdef HAVE_UDF_ARGS_T_ANON_UID udf_args.anon_uid = uid_nobody; /* default to nobody */ if ((str = hasmntstr(&mnt, MNTTAB_OPT_USER)) != NULL) { udf_args.anon_uid = a_uid(str, MNTTAB_OPT_USER); XFREE(str); } #endif /* HAVE_UDF_ARGS_T_ANON_UID */ #ifdef HAVE_UDF_ARGS_T_ANON_GID udf_args.anon_gid = gid_nobody; /* default to nobody */ if ((str = hasmntstr(&mnt, MNTTAB_OPT_GROUP)) != NULL) { udf_args.anon_gid = a_gid(str, MNTTAB_OPT_GROUP); XFREE(str); } #endif /* HAVE_UDF_ARGS_T_ANON_GID */ #ifdef HAVE_UDF_ARGS_T_GMTOFF udf_args.gmtoff = 0; if ((str = hasmntstr(&mnt, MNTTAB_OPT_GMTOFF)) != NULL) { udf_args.gmtoff = a_num(str, MNTTAB_OPT_GMTOFF); XFREE(str); } #endif /* HAVE_UDF_ARGS_T_GMTOFF */ #ifdef HAVE_UDF_ARGS_T_SESSIONNR udf_args.sessionnr = 0; if ((str = hasmntstr(&mnt, MNTTAB_OPT_SESSIONNR)) != NULL) { udf_args.sessionnr = a_num(str, MNTTAB_OPT_SESSIONNR); XFREE(str); } #endif /* HAVE_UDF_ARGS_T_SESSIONNR */ #ifdef HAVE_UDF_ARGS_T_VERSION # ifdef UDFMNT_VERSION udf_args.version = UDFMNT_VERSION; # endif /* UDFMNT_VERSION */ #endif /* HAVE_UDF_ARGS_T_VERSION */ #ifdef HAVE_UFS_ARGS_T_FSPEC udf_args.fspec = fs_name; #endif /* HAVE_UFS_ARGS_T_FSPEC */ /* * Call generic mount routine */ return mount_fs(&mnt, flags, (caddr_t)&udf_args, 0, type, 0, NULL, mnttab_file_name, on_autofs); } static int udf_mount(am_node *am, mntfs *mf) { int on_autofs; int error; on_autofs = mf->mf_flags & MFF_ON_AUTOFS; error = mount_udf(mf->mf_mount, mf->mf_info, mf->mf_mopts, on_autofs); if (error) { errno = error; plog(XLOG_ERROR, "mount_udf: %m"); return error; } return 0; } static int udf_umount(am_node *am, mntfs *mf) { int unmount_flags; unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; return UMOUNT_FS(mf->mf_mount, mnttab_file_name, unmount_flags); } am-utils-6.2+rc20110530/amd/ops_ufs.c000066400000000000000000000116741157065440000167260ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_ufs.c * */ /* * UN*X file system */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward declarations */ static char *ufs_match(am_opts *fo); static int ufs_mount(am_node *am, mntfs *mf); static int ufs_umount(am_node *am, mntfs *mf); /* * Ops structure */ am_ops ufs_ops = { #ifndef __NetBSD__ "ufs", #else "ffs", #endif ufs_match, 0, /* ufs_init */ ufs_mount, ufs_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* ufs_readlink */ 0, /* ufs_mounted */ 0, /* ufs_umounted */ amfs_generic_find_srvr, 0, /* ufs_get_wchan */ FS_MKMNT | FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_UFS_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * UFS needs local filesystem and device. */ static char * ufs_match(am_opts *fo) { if (!fo->opt_dev) { plog(XLOG_USER, "ufs: no device specified"); return 0; } dlog("UFS: mounting device \"%s\" on \"%s\"", fo->opt_dev, fo->opt_fs); /* * Determine magic cookie to put in mtab */ return strdup(fo->opt_dev); } static int mount_ufs(char *mntdir, char *fs_name, char *opts, int on_autofs) { ufs_args_t ufs_args; mntent_t mnt; int genflags; /* * Figure out the name of the file system type. */ MTYPE_TYPE type = MOUNT_TYPE_UFS; memset((voidp) &ufs_args, 0, sizeof(ufs_args)); /* Paranoid */ /* * Fill in the mount structure */ memset((voidp) &mnt, 0, sizeof(mnt)); mnt.mnt_dir = mntdir; mnt.mnt_fsname = fs_name; mnt.mnt_type = MNTTAB_TYPE_UFS; mnt.mnt_opts = opts; genflags = compute_mount_flags(&mnt); #ifdef HAVE_FS_AUTOFS if (on_autofs) genflags |= autofs_compute_mount_flags(&mnt); #endif /* HAVE_FS_AUTOFS */ #ifdef HAVE_UFS_ARGS_T_FLAGS ufs_args.flags = genflags; /* XXX: is this correct? */ #endif /* HAVE_UFS_ARGS_T_FLAGS */ #ifdef HAVE_UFS_ARGS_T_UFS_FLAGS ufs_args.ufs_flags = genflags; #endif /* HAVE_UFS_ARGS_T_UFS_FLAGS */ #ifdef HAVE_UFS_ARGS_T_FSPEC ufs_args.fspec = fs_name; #endif /* HAVE_UFS_ARGS_T_FSPEC */ #ifdef HAVE_UFS_ARGS_T_UFS_PGTHRESH ufs_args.ufs_pgthresh = hasmntval(&mnt, MNTTAB_OPT_PGTHRESH); #endif /* HAVE_UFS_ARGS_T_UFS_PGTHRESH */ /* * Call generic mount routine */ return mount_fs(&mnt, genflags, (caddr_t) &ufs_args, 0, type, 0, NULL, mnttab_file_name, on_autofs); } static int ufs_mount(am_node *am, mntfs *mf) { int on_autofs = mf->mf_flags & MFF_ON_AUTOFS; int error; error = mount_ufs(mf->mf_mount, mf->mf_info, mf->mf_mopts, on_autofs); if (error) { errno = error; plog(XLOG_ERROR, "mount_ufs: %m"); return error; } return 0; } static int ufs_umount(am_node *am, mntfs *mf) { int unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; return UMOUNT_FS(mf->mf_mount, mnttab_file_name, unmount_flags); } am-utils-6.2+rc20110530/amd/ops_umapfs.c000066400000000000000000000044351157065440000174210ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_umapfs.c * */ /* * uid/gid mapping filesystem. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* FEEL FREE TO IMPLEMENT THIS... :-) */ am-utils-6.2+rc20110530/amd/ops_unionfs.c000066400000000000000000000044411157065440000176040ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_unionfs.c * */ /* * Union filesystem (ala BSD-4.4) */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* FEEL FREE TO IMPLEMENT THIS... :-) */ am-utils-6.2+rc20110530/amd/ops_xfs.c000066400000000000000000000112611157065440000167210ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/ops_xfs.c * */ /* * Irix UN*X file system: XFS (Extended File System) */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* forward declarations */ static char *xfs_match(am_opts *fo); static int xfs_mount(am_node *am, mntfs *mf); static int xfs_umount(am_node *am, mntfs *mf); /* * Ops structure */ am_ops xfs_ops = { "xfs", xfs_match, 0, /* xfs_init */ xfs_mount, xfs_umount, amfs_error_lookup_child, amfs_error_mount_child, amfs_error_readdir, 0, /* xfs_readlink */ 0, /* xfs_mounted */ 0, /* xfs_umounted */ amfs_generic_find_srvr, 0, /* xfs_get_wchan */ FS_MKMNT | FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO, /* nfs_fs_flags */ #ifdef HAVE_FS_AUTOFS AUTOFS_XFS_FS_FLAGS, #endif /* HAVE_FS_AUTOFS */ }; /* * XFS needs local filesystem and device. */ static char * xfs_match(am_opts *fo) { if (!fo->opt_dev) { plog(XLOG_USER, "xfs: no device specified"); return 0; } dlog("XFS: mounting device \"%s\" on \"%s\"", fo->opt_dev, fo->opt_fs); /* * Determine magic cookie to put in mtab */ return strdup(fo->opt_dev); } static int mount_xfs(char *mntdir, char *fs_name, char *opts, int on_autofs) { xfs_args_t xfs_args; mntent_t mnt; int flags; /* * Figure out the name of the file system type. */ MTYPE_TYPE type = MOUNT_TYPE_XFS; memset((voidp) &xfs_args, 0, sizeof(xfs_args)); /* Paranoid */ /* * Fill in the mount structure */ memset((voidp) &mnt, 0, sizeof(mnt)); mnt.mnt_dir = mntdir; mnt.mnt_fsname = fs_name; mnt.mnt_type = MNTTAB_TYPE_XFS; mnt.mnt_opts = opts; flags = compute_mount_flags(&mnt); #ifdef HAVE_FS_AUTOFS if (on_autofs) flags |= autofs_compute_mount_flags(&mnt); #endif /* HAVE_FS_AUTOFS */ #ifdef HAVE_XFS_ARGS_T_FLAGS xfs_args.flags = 0; /* XXX: fix this to correct flags */ #endif /* HAVE_XFS_ARGS_T_FLAGS */ #ifdef HAVE_XFS_ARGS_T_FSPEC xfs_args.fspec = fs_name; #endif /* HAVE_XFS_ARGS_T_FSPEC */ /* * Call generic mount routine */ return mount_fs(&mnt, flags, (caddr_t) &xfs_args, 0, type, 0, NULL, mnttab_file_name, on_autofs); } static int xfs_mount(am_node *am, mntfs *mf) { int on_autofs = mf->mf_flags & MFF_ON_AUTOFS; int error; error = mount_xfs(mf->mf_mount, mf->mf_info, mf->mf_mopts, on_autofs); if (error) { errno = error; plog(XLOG_ERROR, "mount_xfs: %m"); return error; } return 0; } static int xfs_umount(am_node *am, mntfs *mf) { int unmount_flags = (mf->mf_flags & MFF_ON_AUTOFS) ? AMU_UMOUNT_AUTOFS : 0; return UMOUNT_FS(mf->mf_mount, mnttab_file_name, unmount_flags); } am-utils-6.2+rc20110530/amd/opts.c000066400000000000000000001016041157065440000162260ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/opts.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * MACROS: */ #define NLEN 16 /* Length of longest option name (conservative) */ #define S(x) (x) , (sizeof(x)-1) /* * The BUFSPACE macros checks that there is enough space * left in the expansion buffer. If there isn't then we * give up completely. This is done to avoid crashing the * automounter itself (which would be a bad thing to do). */ #define BUFSPACE(ep, len) (((ep) + (len)) < expbuf+MAXPATHLEN) /* * TYPEDEFS: */ typedef int (*IntFuncPtr) (char *); typedef struct opt_apply opt_apply; enum vs_opt { SelEQ, SelNE, VarAss }; /* * STRUCTURES */ struct opt { char *name; /* Name of the option */ int nlen; /* Length of option name */ char **optp; /* Pointer to option value string */ char **sel_p; /* Pointer to selector value string */ int (*fxn_p)(char *); /* Pointer to boolean function */ int case_insensitive; /* How to do selector comparisons */ }; struct opt_apply { char **opt; char *val; }; struct functable { char *name; IntFuncPtr func; }; /* * FORWARD DEFINITION: */ static int f_in_network(char *); static int f_xhost(char *); static int f_netgrp(char *); static int f_netgrpd(char *); static int f_exists(char *); static int f_false(char *); static int f_true(char *); static inline char *expand_options(char *key); /* * STATICS: */ static char NullStr[] = ""; static char nullstr[] = ""; static char *opt_dkey = NullStr; static char *opt_host = nullstr; /* XXX: was the global hostname */ static char *opt_hostd = hostd; static char *opt_key = nullstr; static char *opt_keyd = nullstr; static char *opt_map = nullstr; static char *opt_path = nullstr; char uid_str[SIZEOF_UID_STR], gid_str[SIZEOF_GID_STR]; char *opt_uid = uid_str; char *opt_gid = gid_str; static char *vars[8]; static char *literal_dollar = "$"; /* ${dollar}: a literal '$' in maps */ /* * GLOBALS */ static struct am_opts fs_static; /* copy of the options to play with */ /* * Options in some order corresponding to frequency of use so that * first-match algorithm is sped up. */ static struct opt opt_fields[] = { /* Name and length. Option str. Selector str. boolean fxn. case sensitive */ { S("opts"), &fs_static.opt_opts, 0, 0, FALSE }, { S("host"), 0, &opt_host, 0, TRUE }, { S("hostd"), 0, &opt_hostd, 0, TRUE }, { S("type"), &fs_static.opt_type, 0, 0, FALSE }, { S("rhost"), &fs_static.opt_rhost, 0, 0, TRUE }, { S("rfs"), &fs_static.opt_rfs, 0, 0, FALSE }, { S("fs"), &fs_static.opt_fs, 0, 0, FALSE }, { S("key"), 0, &opt_key, 0, FALSE }, { S("map"), 0, &opt_map, 0, FALSE }, { S("sublink"), &fs_static.opt_sublink, 0, 0, FALSE }, { S("arch"), 0, &gopt.arch, 0, TRUE }, { S("dev"), &fs_static.opt_dev, 0, 0, FALSE }, { S("pref"), &fs_static.opt_pref, 0, 0, FALSE }, { S("path"), 0, &opt_path, 0, FALSE }, { S("autodir"), 0, &gopt.auto_dir, 0, FALSE }, { S("delay"), &fs_static.opt_delay, 0, 0, FALSE }, { S("domain"), 0, &hostdomain, 0, TRUE }, { S("karch"), 0, &gopt.karch, 0, TRUE }, { S("cluster"), 0, &gopt.cluster, 0, TRUE }, { S("wire"), 0, 0, f_in_network, TRUE }, { S("network"), 0, 0, f_in_network, TRUE }, { S("netnumber"), 0, 0, f_in_network, TRUE }, { S("byte"), 0, &endian, 0, TRUE }, { S("os"), 0, &gopt.op_sys, 0, TRUE }, { S("osver"), 0, &gopt.op_sys_ver, 0, TRUE }, { S("full_os"), 0, &gopt.op_sys_full, 0, TRUE }, { S("vendor"), 0, &gopt.op_sys_vendor, 0, TRUE }, { S("remopts"), &fs_static.opt_remopts, 0, 0, FALSE }, { S("mount"), &fs_static.opt_mount, 0, 0, FALSE }, { S("unmount"), &fs_static.opt_unmount, 0, 0, FALSE }, { S("umount"), &fs_static.opt_umount, 0, 0, FALSE }, { S("cache"), &fs_static.opt_cache, 0, 0, FALSE }, { S("user"), &fs_static.opt_user, 0, 0, FALSE }, { S("group"), &fs_static.opt_group, 0, 0, FALSE }, { S(".key"), 0, &opt_dkey, 0, FALSE }, { S("key."), 0, &opt_keyd, 0, FALSE }, { S("maptype"), &fs_static.opt_maptype, 0, 0, FALSE }, { S("cachedir"), &fs_static.opt_cachedir, 0, 0, FALSE }, { S("addopts"), &fs_static.opt_addopts, 0, 0, FALSE }, { S("uid"), 0, &opt_uid, 0, FALSE }, { S("gid"), 0, &opt_gid, 0, FALSE }, { S("mount_type"), &fs_static.opt_mount_type, 0, 0, FALSE }, { S("dollar"), &literal_dollar, 0, 0, FALSE }, { S("var0"), &vars[0], 0, 0, FALSE }, { S("var1"), &vars[1], 0, 0, FALSE }, { S("var2"), &vars[2], 0, 0, FALSE }, { S("var3"), &vars[3], 0, 0, FALSE }, { S("var4"), &vars[4], 0, 0, FALSE }, { S("var5"), &vars[5], 0, 0, FALSE }, { S("var6"), &vars[6], 0, 0, FALSE }, { S("var7"), &vars[7], 0, 0, FALSE }, { 0, 0, 0, 0, 0, FALSE }, }; static struct functable functable[] = { { "in_network", f_in_network }, { "xhost", f_xhost }, { "netgrp", f_netgrp }, { "netgrpd", f_netgrpd }, { "exists", f_exists }, { "false", f_false }, { "true", f_true }, { 0, 0 }, }; /* * Specially expand the remote host name first */ static opt_apply rhost_expansion[] = { {&fs_static.opt_rhost, "${host}"}, {0, 0}, }; /* * List of options which need to be expanded * Note that the order here _may_ be important. */ static opt_apply expansions[] = { {&fs_static.opt_sublink, 0}, {&fs_static.opt_rfs, "${path}"}, {&fs_static.opt_fs, "${autodir}/${rhost}${rfs}"}, {&fs_static.opt_opts, "rw"}, {&fs_static.opt_remopts, "${opts}"}, {&fs_static.opt_mount, 0}, {&fs_static.opt_unmount, 0}, {&fs_static.opt_umount, 0}, {&fs_static.opt_cachedir, 0}, {&fs_static.opt_addopts, 0}, {0, 0}, }; /* * List of options which need to be free'ed before re-use */ static opt_apply to_free[] = { {&fs_static.fs_glob, 0}, {&fs_static.fs_local, 0}, {&fs_static.fs_mtab, 0}, {&fs_static.opt_sublink, 0}, {&fs_static.opt_rfs, 0}, {&fs_static.opt_fs, 0}, {&fs_static.opt_rhost, 0}, {&fs_static.opt_opts, 0}, {&fs_static.opt_remopts, 0}, {&fs_static.opt_mount, 0}, {&fs_static.opt_unmount, 0}, {&fs_static.opt_umount, 0}, {&fs_static.opt_cachedir, 0}, {&fs_static.opt_addopts, 0}, {&vars[0], 0}, {&vars[1], 0}, {&vars[2], 0}, {&vars[3], 0}, {&vars[4], 0}, {&vars[5], 0}, {&vars[6], 0}, {&vars[7], 0}, {0, 0}, }; /* * expand backslash escape sequences * (escaped slash is handled separately in normalize_slash) */ static char backslash(char **p) { char c; if ((*p)[1] == '\0') { plog(XLOG_USER, "Empty backslash escape"); return **p; } if (**p == '\\') { (*p)++; switch (**p) { case 'g': c = '\007'; /* Bell */ break; case 'b': c = '\010'; /* Backspace */ break; case 't': c = '\011'; /* Horizontal Tab */ break; case 'n': c = '\012'; /* New Line */ break; case 'v': c = '\013'; /* Vertical Tab */ break; case 'f': c = '\014'; /* Form Feed */ break; case 'r': c = '\015'; /* Carriage Return */ break; case 'e': c = '\033'; /* Escape */ break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': { int cnt, val, ch; for (cnt = 0, val = 0; cnt < 3; cnt++) { ch = *(*p)++; if (ch < '0' || ch > '7') { (*p)--; break; } val = (val << 3) | (ch - '0'); } if ((val & 0xffffff00) != 0) plog(XLOG_USER, "Too large character constant %u\n", val); c = (char) val; --(*p); } break; default: c = **p; break; } } else c = **p; return c; } /* * Skip to next option in the string */ static char * opt(char **p) { char *cp = *p; char *dp = cp; char *s = cp; top: while (*cp && *cp != ';') { if (*cp == '"') { /* * Skip past string */ for (cp++; *cp && *cp != '"'; cp++) if (*cp == '\\') *dp++ = backslash(&cp); else *dp++ = *cp; if (*cp) cp++; } else { *dp++ = *cp++; } } /* * Skip past any remaining ';'s */ while (*cp == ';') cp++; /* * If we have a zero length string * and there are more fields, then * parse the next one. This allows * sequences of empty fields. */ if (*cp && dp == s) goto top; *dp = '\0'; *p = cp; return s; } /* * These routines add a new style of selector; function-style boolean * operators. To add new ones, just define functions as in true, false, * exists (below) and add them to the functable, above. * * Usage example: Some people have X11R5 local, some go to a server. I do * this: * * * exists(/usr/pkg/${key});type:=link;fs:=/usr/pkg/${key} || \ * -type:=nfs;rfs=/usr/pkg/${key} \ * rhost:=server1 \ * rhost:=server2 * * -Rens Troost */ static IntFuncPtr functable_lookup(char *key) { struct functable *fp; for (fp = functable; fp->name; fp++) if (FSTREQ(fp->name, key)) return (fp->func); return (IntFuncPtr) NULL; } /* * Fill in the global structure fs_static by * cracking the string opts. opts may be * scribbled on at will. Does NOT evaluate options. * Returns 0 on error, 1 if no syntax errors were discovered. */ static int split_opts(char *opts, char *mapkey) { char *o = opts; char *f; /* * For each user-specified option */ for (f = opt(&o); *f; f = opt(&o)) { struct opt *op; char *eq = strchr(f, '='); char *opt = NULL; if (!eq) continue; if (*(eq-1) == '!' || eq[1] == '=' || eq[1] == '!') { /* != or == or =! */ continue; /* we don't care about selectors */ } if (*(eq-1) == ':') { /* := */ *(eq-1) = '\0'; } else { /* old style assignment */ eq[0] = '\0'; } opt = eq + 1; /* * For each recognized option */ for (op = opt_fields; op->name; op++) { /* * Check whether they match */ if (FSTREQ(op->name, f)) { if (op->sel_p) { plog(XLOG_USER, "key %s: Can't assign to a selector (%s)", mapkey, op->name); return 0; } *op->optp = opt; /* actual assignment into fs_static */ break; /* break out of for loop */ } /* end of "if (FSTREQ(op->name, f))" statement */ } /* end of "for (op = opt_fields..." statement */ if (!op->name) plog(XLOG_USER, "key %s: Unrecognized key/option \"%s\"", mapkey, f); } return 1; } /* * Just evaluate selectors, which were split by split_opts. * Returns 0 on error or no match, 1 if matched. */ static int eval_selectors(char *opts, char *mapkey) { char *o, *old_o; char *f; int ret = 0; o = old_o = strdup(opts); /* * For each user-specified option */ for (f = opt(&o); *f; f = opt(&o)) { struct opt *op; enum vs_opt vs_opt; char *eq = strchr(f, '='); char *fx; IntFuncPtr func; char *opt = NULL; char *arg; if (!eq) { /* * No value, is it a function call? */ arg = strchr(f, '('); if (!arg || arg[1] == '\0' || arg == f) { /* * No, just continue */ plog(XLOG_USER, "key %s: No value component in \"%s\"", mapkey, f); continue; } /* null-terminate the argument */ *arg++ = '\0'; fx = strchr(arg, ')'); if (!arg || fx == arg) { plog(XLOG_USER, "key %s: Malformed function in \"%s\"", mapkey, f); continue; } *fx = '\0'; if (f[0] == '!') { vs_opt = SelNE; f++; } else { vs_opt = SelEQ; } /* * look up f in functable and pass it arg. * func must return 0 on failure, and 1 on success. */ if ((func = functable_lookup(f))) { int funok; /* this allocates memory, don't forget to free */ arg = expand_options(arg); funok = func(arg); XFREE(arg); if (vs_opt == SelNE) funok = !funok; if (!funok) goto out; continue; } else { plog(XLOG_USER, "key %s: unknown function \"%s\"", mapkey, f); goto out; } } else { if (eq[1] == '\0' || eq == f) { /* misformed selector */ plog(XLOG_USER, "key %s: Bad selector \"%s\"", mapkey, f); continue; } } /* * Check what type of operation is happening * !=, =! is SelNE * == is SelEQ * =, := is VarAss */ if (*(eq-1) == '!') { /* != */ vs_opt = SelNE; *(eq-1) = '\0'; opt = eq + 1; } else if (*(eq-1) == ':') { /* := */ continue; } else if (eq[1] == '=') { /* == */ vs_opt = SelEQ; eq[0] = '\0'; opt = eq + 2; } else if (eq[1] == '!') { /* =! */ vs_opt = SelNE; eq[0] = '\0'; opt = eq + 2; } else { /* old style assignment */ continue; } /* * For each recognized option */ for (op = opt_fields; op->name; op++) { /* * Check whether they match */ if (FSTREQ(op->name, f)) { opt = expand_options(opt); if (op->sel_p != NULL) { int selok; if (op->case_insensitive) { selok = STRCEQ(*op->sel_p, opt); } else { selok = STREQ(*op->sel_p, opt); } if (vs_opt == SelNE) selok = !selok; if (!selok) { plog(XLOG_MAP, "key %s: map selector %s (=%s) did not %smatch %s", mapkey, op->name, *op->sel_p, vs_opt == SelNE ? "mis" : "", opt); XFREE(opt); goto out; } XFREE(opt); } /* check if to apply a function */ if (op->fxn_p) { int funok; funok = op->fxn_p(opt); if (vs_opt == SelNE) funok = !funok; if (!funok) { plog(XLOG_MAP, "key %s: map function %s did not %smatch %s", mapkey, op->name, vs_opt == SelNE ? "mis" : "", opt); XFREE(opt); goto out; } XFREE(opt); } break; /* break out of for loop */ } } if (!op->name) plog(XLOG_USER, "key %s: Unrecognized key/option \"%s\"", mapkey, f); } /* all is ok */ ret = 1; out: free(old_o); return ret; } /* * Skip to next option in the string, but don't scribble over the string. * However, *p gets repointed to the start of the next string past ';'. */ static char * opt_no_scribble(char **p) { char *cp = *p; char *dp = cp; char *s = cp; top: while (*cp && *cp != ';') { if (*cp == '\"') { /* * Skip past string */ cp++; while (*cp && *cp != '\"') *dp++ = *cp++; if (*cp) cp++; } else { *dp++ = *cp++; } } /* * Skip past any remaining ';'s */ while (*cp == ';') cp++; /* * If we have a zero length string * and there are more fields, then * parse the next one. This allows * sequences of empty fields. */ if (*cp && dp == s) goto top; *p = cp; return s; } /* * Strip any selectors from a string. Selectors are all assumed to be * first in the string. This is used for the new /defaults method which will * use selectors as well. */ char * strip_selectors(char *opts, char *mapkey) { /* * Fill in the global structure fs_static by * cracking the string opts. opts may be * scribbled on at will. */ char *o = opts; char *oo = opts; char *f; /* * Scan options. Note that the opt() function scribbles on the opt string. */ while (*(f = opt_no_scribble(&o))) { enum vs_opt vs_opt = VarAss; char *eq = strchr(f, '='); if (!eq || eq[1] == '\0' || eq == f) { /* * No option or assignment? Return as is. */ plog(XLOG_USER, "key %s: No option or assignment in \"%s\"", mapkey, f); return o; } /* * Check what type of operation is happening * !=, =! is SelNE * == is SelEQ * := is VarAss */ if (*(eq-1) == '!') { /* != */ vs_opt = SelNE; } else if (*(eq-1) == ':') { /* := */ vs_opt = VarAss; } else if (eq[1] == '=') { /* == */ vs_opt = SelEQ; } else if (eq[1] == '!') { /* =! */ vs_opt = SelNE; } switch (vs_opt) { case SelEQ: case SelNE: /* Skip this selector, maybe there's another one following it */ plog(XLOG_USER, "skipping selector to \"%s\"", o); /* store previous match. it may have been the first assignment */ oo = o; break; case VarAss: /* found the first assignment, return the string starting with it */ dlog("found first assignment past selectors \"%s\"", o); return oo; } } /* return the same string by default. should not happen. */ return oo; } /***************************************************************************** *** BOOLEAN FUNCTIONS (return 0 if false, 1 if true): *** *****************************************************************************/ /* test if arg is any of this host's network names or numbers */ static int f_in_network(char *arg) { int status; if (!arg) return 0; status = is_network_member(arg); dlog("%s is %son a local network", arg, (status ? "" : "not ")); return status; } /* * Test if arg is any of this host's names or aliases (CNAMES). * Note: this function compares against the fully expanded host name (hostd). * XXX: maybe we also need to compare against the stripped host name? */ static int f_xhost(char *arg) { struct hostent *hp; char **cp; if (!arg) return 0; /* simple test: does it match main host name? */ if (STREQ(arg, opt_hostd)) return 1; /* now find all of the names of "arg" and compare against opt_hostd */ hp = gethostbyname(arg); if (hp == NULL) { #ifdef HAVE_HSTRERROR plog(XLOG_ERROR, "gethostbyname xhost(%s): %s", arg, hstrerror(h_errno)); #else /* not HAVE_HSTRERROR */ plog(XLOG_ERROR, "gethostbyname xhost(%s): h_errno %d", arg, h_errno); #endif /* not HAVE_HSTRERROR */ return 0; } /* check primary name */ if (hp->h_name) { dlog("xhost: compare %s==%s", hp->h_name, opt_hostd); if (STREQ(hp->h_name, opt_hostd)) { plog(XLOG_INFO, "xhost(%s): matched h_name %s", arg, hp->h_name); return 1; } } /* check all aliases, if any */ if (hp->h_aliases == NULL) { dlog("gethostbyname(%s) has no aliases", arg); return 0; } cp = hp->h_aliases; while (*cp) { dlog("xhost: compare alias %s==%s", *cp, opt_hostd); if (STREQ(*cp, opt_hostd)) { plog(XLOG_INFO, "xhost(%s): matched alias %s", arg, *cp); return 1; } cp++; } /* nothing matched */ return 0; } /* test if this host (short hostname form) is in netgroup (arg) */ static int f_netgrp(char *arg) { int status; char *ptr, *nhost; if ((ptr = strchr(arg, ',')) != NULL) { *ptr = '\0'; nhost = ptr + 1; } else { nhost = opt_host; } status = innetgr(arg, nhost, NULL, NULL); dlog("netgrp = %s status = %d host = %s", arg, status, nhost); if (ptr) *ptr = ','; return status; } /* test if this host (fully-qualified name) is in netgroup (arg) */ static int f_netgrpd(char *arg) { int status; char *ptr, *nhost; if ((ptr = strchr(arg, ',')) != NULL) { *ptr = '\0'; nhost = ptr + 1; } else { nhost = opt_hostd; } status = innetgr(arg, nhost, NULL, NULL); dlog("netgrp = %s status = %d hostd = %s", arg, status, nhost); if (ptr) *ptr = ','; return status; } /* test if file (arg) exists via lstat */ static int f_exists(char *arg) { struct stat buf; if (lstat(arg, &buf) < 0) return (0); else return (1); } /* always false */ static int f_false(char *arg) { return (0); } /* always true */ static int f_true(char *arg) { return (1); } /* * Free an option */ static void free_op(opt_apply *p, int b) { if (*p->opt) { XFREE(*p->opt); } } /* * Normalize slashes in the string. */ void normalize_slash(char *p) { char *f, *f0; if (!(gopt.flags & CFM_NORMALIZE_SLASHES)) return; f0 = f = strchr(p, '/'); if (f) { char *t = f; do { /* assert(*f == '/'); */ if (f == f0 && f[0] == '/' && f[1] == '/') { /* copy double slash iff first */ *t++ = *f++; *t++ = *f++; } else { /* copy a single / across */ *t++ = *f++; } /* assert(f[-1] == '/'); */ /* skip past more /'s */ while (*f == '/') f++; /* assert(*f != '/'); */ /* keep copying up to next / */ while (*f && *f != '/') { /* support escaped slashes '\/' */ if (f[0] == '\\' && f[1] == '/') f++; /* skip backslash */ *t++ = *f++; } /* assert(*f == 0 || *f == '/'); */ } while (*f); *t = '\0'; /* derived from fix by Steven Glassman */ } } /* * Macro-expand an option. Note that this does not * handle recursive expansions. They will go badly wrong. * If sel_p is true then old expand selectors, otherwise * don't expand selectors. */ static char * expand_op(char *opt, int sel_p) { #define EXPAND_ERROR "No space to expand \"%s\"" char expbuf[MAXPATHLEN + 1]; char nbuf[NLEN + 1]; char *ep = expbuf; char *cp = opt; char *dp; struct opt *op; char *cp_orig = opt; while ((dp = strchr(cp, '$'))) { char ch; /* * First copy up to the $ */ { int len = dp - cp; if (len > 0) { if (BUFSPACE(ep, len)) { /* * We use strncpy (not xstrlcpy) because 'ep' relies on its * semantics. BUFSPACE guarantees that ep can hold len. */ strncpy(ep, cp, len); ep += len; } else { plog(XLOG_ERROR, EXPAND_ERROR, opt); goto out; } } } cp = dp + 1; ch = *cp++; if (ch == '$') { if (BUFSPACE(ep, 1)) { *ep++ = '$'; } else { plog(XLOG_ERROR, EXPAND_ERROR, opt); goto out; } } else if (ch == '{') { /* Expansion... */ enum { E_All, E_Dir, E_File, E_Domain, E_Host } todo; /* * Find closing brace */ char *br_p = strchr(cp, '}'); int len; /* * Check we found it */ if (!br_p) { /* * Just give up */ plog(XLOG_USER, "No closing '}' in \"%s\"", opt); goto out; } len = br_p - cp; /* * Figure out which part of the variable to grab. */ if (*cp == '/') { /* * Just take the last component */ todo = E_File; cp++; --len; } else if (*(br_p-1) == '/') { /* * Take all but the last component */ todo = E_Dir; --len; } else if (*cp == '.') { /* * Take domain name */ todo = E_Domain; cp++; --len; } else if (*(br_p-1) == '.') { /* * Take host name */ todo = E_Host; --len; } else { /* * Take the whole lot */ todo = E_All; } /* * Truncate if too long. Since it won't * match anyway it doesn't matter that * it has been cut short. */ if (len > NLEN) len = NLEN; /* * Put the string into another buffer so * we can do comparisons. * * We use strncpy here (not xstrlcpy) because the dest is meant * to be truncated and we don't want to log it as an error. The * use of the BUFSPACE macro above guarantees the safe use of * strncpy with nbuf. */ strncpy(nbuf, cp, len); nbuf[len] = '\0'; /* * Advance cp */ cp = br_p + 1; /* * Search the option array */ for (op = opt_fields; op->name; op++) { /* * Check for match */ if (len == op->nlen && STREQ(op->name, nbuf)) { char xbuf[NLEN + 3]; char *val; /* * Found expansion. Copy * the correct value field. */ if (!(!op->sel_p == !sel_p)) { /* * Copy the string across unexpanded */ xsnprintf(xbuf, sizeof(xbuf), "${%s%s%s}", todo == E_File ? "/" : todo == E_Domain ? "." : "", nbuf, todo == E_Dir ? "/" : todo == E_Host ? "." : ""); val = xbuf; /* * Make sure expansion doesn't * munge the value! */ todo = E_All; } else if (op->sel_p) { val = *op->sel_p; } else { val = *op->optp; } if (val) { /* * Do expansion: * ${/var} means take just the last part * ${var/} means take all but the last part * ${.var} means take all but first part * ${var.} means take just the first part * ${var} means take the whole lot */ int vlen = strlen(val); char *vptr = val; switch (todo) { case E_Dir: vptr = strrchr(val, '/'); if (vptr) vlen = vptr - val; vptr = val; break; case E_File: vptr = strrchr(val, '/'); if (vptr) { vptr++; vlen = strlen(vptr); } else vptr = val; break; case E_Domain: vptr = strchr(val, '.'); if (vptr) { vptr++; vlen = strlen(vptr); } else { vptr = ""; vlen = 0; } break; case E_Host: vptr = strchr(val, '.'); if (vptr) vlen = vptr - val; vptr = val; break; case E_All: break; } if (BUFSPACE(ep, vlen+1)) { /* * Don't call xstrlcpy() to truncate a string here. It causes * spurious xstrlcpy() syslog() errors. Use memcpy() and * explicitly terminate the string. */ memcpy(ep, vptr, vlen+1); ep += vlen; *ep = '\0'; } else { plog(XLOG_ERROR, EXPAND_ERROR, opt); goto out; } } /* * Done with this variable */ break; } } /* * Check that the search was successful */ if (!op->name) { /* * If it wasn't then scan the * environment for that name * and use any value found */ char *env = getenv(nbuf); if (env) { int vlen = strlen(env); if (BUFSPACE(ep, vlen+1)) { xstrlcpy(ep, env, vlen+1); ep += vlen; } else { plog(XLOG_ERROR, EXPAND_ERROR, opt); goto out; } if (amuDebug(D_STR)) plog(XLOG_DEBUG, "Environment gave \"%s\" -> \"%s\"", nbuf, env); } else { plog(XLOG_USER, "Unknown sequence \"${%s}\"", nbuf); } } } else { /* * Error, error */ plog(XLOG_USER, "Unknown $ sequence in \"%s\"", opt); } } out: /* * Handle common case - no expansion */ if (cp == opt) { opt = strdup(cp); } else { /* * Finish off the expansion */ int vlen = strlen(cp); if (BUFSPACE(ep, vlen+1)) { xstrlcpy(ep, cp, vlen+1); /* ep += vlen; */ } else { plog(XLOG_ERROR, EXPAND_ERROR, opt); } /* * Save the expansion */ opt = strdup(expbuf); } normalize_slash(opt); if (amuDebug(D_STR)) { plog(XLOG_DEBUG, "Expansion of \"%s\"...", cp_orig); plog(XLOG_DEBUG, "......... is \"%s\"", opt); } return opt; } /* * Wrapper for expand_op */ static void expand_opts(opt_apply *p, int sel_p) { if (*p->opt) { *p->opt = expand_op(*p->opt, sel_p); } else if (p->val) { /* * Do double expansion, remembering * to free the string from the first * expansion... */ char *s = expand_op(p->val, TRUE); *p->opt = expand_op(s, sel_p); XFREE(s); } } /* * Apply a function to a list of options */ static void apply_opts(void (*op) (opt_apply *, int), opt_apply ppp[], int b) { opt_apply *pp; for (pp = ppp; pp->opt; pp++) (*op) (pp, b); } /* * Free the option table */ void free_opts(am_opts *fo) { /* * Copy in the structure we are playing with */ fs_static = *fo; /* * Free previously allocated memory */ apply_opts(free_op, to_free, FALSE); } am_opts * copy_opts(am_opts *old) { am_opts *newopts; newopts = CALLOC(struct am_opts); #define _AM_OPT_COPY(field) do { \ if (old->field) \ newopts->field = strdup(old->field); \ } while (0) _AM_OPT_COPY(fs_glob); _AM_OPT_COPY(fs_local); _AM_OPT_COPY(fs_mtab); _AM_OPT_COPY(opt_dev); _AM_OPT_COPY(opt_delay); _AM_OPT_COPY(opt_dir); _AM_OPT_COPY(opt_fs); _AM_OPT_COPY(opt_group); _AM_OPT_COPY(opt_mount); _AM_OPT_COPY(opt_opts); _AM_OPT_COPY(opt_remopts); _AM_OPT_COPY(opt_pref); _AM_OPT_COPY(opt_cache); _AM_OPT_COPY(opt_rfs); _AM_OPT_COPY(opt_rhost); _AM_OPT_COPY(opt_sublink); _AM_OPT_COPY(opt_type); _AM_OPT_COPY(opt_mount_type); _AM_OPT_COPY(opt_unmount); _AM_OPT_COPY(opt_umount); _AM_OPT_COPY(opt_user); _AM_OPT_COPY(opt_maptype); _AM_OPT_COPY(opt_cachedir); _AM_OPT_COPY(opt_addopts); return newopts; } /* * Expand selectors (variables that cannot be assigned to or overridden) */ char * expand_selectors(char *key) { return expand_op(key, TRUE); } /* * Expand options (i.e. non-selectors, see above for definition) */ static inline char * expand_options(char *key) { return expand_op(key, FALSE); } /* * Remove trailing /'s from a string * unless the string is a single / (Steven Glassman) * or unless it is two slashes // (Kevin D. Bond) * or unless amd.conf says not to touch slashes. */ void deslashify(char *s) { if (!(gopt.flags & CFM_NORMALIZE_SLASHES)) return; if (s && *s) { char *sl = s + strlen(s); while (*--sl == '/' && sl > s) *sl = '\0'; } } int eval_fs_opts(am_opts *fo, char *opts, char *g_opts, char *path, char *key, char *map) { int ok = TRUE; free_opts(fo); /* * Clear out the option table */ memset((voidp) &fs_static, 0, sizeof(fs_static)); memset((voidp) vars, 0, sizeof(vars)); memset((voidp) fo, 0, sizeof(*fo)); /* set hostname */ opt_host = (char *) am_get_hostname(); /* * Set key, map & path before expansion */ opt_key = key; opt_map = map; opt_path = path; opt_dkey = strchr(key, '.'); if (!opt_dkey) { opt_dkey = NullStr; opt_keyd = key; } else { opt_keyd = strnsave(key, opt_dkey - key); opt_dkey++; if (*opt_dkey == '\0') /* check for 'host.' */ opt_dkey = NullStr; } /* * Expand global options */ fs_static.fs_glob = expand_selectors(g_opts); /* * Expand local options */ fs_static.fs_local = expand_selectors(opts); /* break global options into fs_static fields */ if ((ok = split_opts(fs_static.fs_glob, key))) { dlog("global split_opts ok"); /* * evaluate local selectors */ if ((ok = eval_selectors(fs_static.fs_local, key))) { dlog("local eval_selectors ok"); /* if the local selectors matched, then do the local overrides */ ok = split_opts(fs_static.fs_local, key); if (ok) dlog("local split_opts ok"); } } /* * Normalize remote host name. * 1. Expand variables * 2. Normalize relative to host tables * 3. Strip local domains from the remote host * name before using it in other expansions. * This makes mount point names and other things * much shorter, while allowing cross domain * sharing of mount maps. */ apply_opts(expand_opts, rhost_expansion, FALSE); if (ok && fs_static.opt_rhost && *fs_static.opt_rhost) host_normalize(&fs_static.opt_rhost); /* * Macro expand the options. * Do this regardless of whether we are accepting * this mount - otherwise nasty things happen * with memory allocation. */ apply_opts(expand_opts, expansions, FALSE); /* * Strip trailing slashes from local pathname... */ deslashify(fs_static.opt_fs); /* * ok... copy the data back out. */ *fo = fs_static; /* * Clear defined options */ if (opt_keyd != key && opt_keyd != nullstr) XFREE(opt_keyd); opt_keyd = nullstr; opt_dkey = NullStr; opt_key = opt_map = opt_path = nullstr; return ok; } am-utils-6.2+rc20110530/amd/readdir.c000066400000000000000000000370261157065440000166610ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/readdir.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /**************************************************************************** *** MACROS *** ****************************************************************************/ #define DOT_DOT_COOKIE (u_int) 1 #define MAX_CHAIN 2048 /**************************************************************************** *** FORWARD DEFINITIONS *** ****************************************************************************/ static int key_already_in_chain(char *keyname, const nfsentry *chain); static nfsentry *make_entry_chain(am_node *mp, const nfsentry *current_chain, int fully_browsable); static int amfs_readdir_browsable(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, u_int count, int fully_browsable); static const u_int dotdotcookie = DOT_DOT_COOKIE; /**************************************************************************** *** FUNCTIONS *** ****************************************************************************/ /* * Was: NEW_TOPLVL_READDIR * Search a chain for an entry with some name. * -Erez Zadok */ static int key_already_in_chain(char *keyname, const nfsentry *chain) { const nfsentry *tmpchain = chain; while (tmpchain) { if (keyname && tmpchain->ne_name && STREQ(keyname, tmpchain->ne_name)) return 1; tmpchain = tmpchain->ne_nextentry; } return 0; } /* * Create a chain of entries which are not linked. * -Erez Zadok */ static nfsentry * make_entry_chain(am_node *mp, const nfsentry *current_chain, int fully_browsable) { static u_int last_cookie = (u_int) 2; /* monotonically increasing */ static nfsentry chain[MAX_CHAIN]; static int max_entries = MAX_CHAIN; char *key; int num_entries = 0, i; u_int preflen = 0; nfsentry *retval = (nfsentry *) NULL; mntfs *mf; mnt_map *mmp; if (!mp) { plog(XLOG_DEBUG, "make_entry_chain: mp is (NULL)"); return retval; } mf = mp->am_al->al_mnt; if (!mf) { plog(XLOG_DEBUG, "make_entry_chain: mp->am_al->al_mnt is (NULL)"); return retval; } mmp = (mnt_map *) mf->mf_private; if (!mmp) { plog(XLOG_DEBUG, "make_entry_chain: mp->am_al->al_mnt->mf_private is (NULL)"); return retval; } if (mp->am_pref) preflen = strlen(mp->am_pref); /* iterate over keys */ for (i = 0; i < NKVHASH; i++) { kv *k; for (k = mmp->kvhash[i]; k ; k = k->next) { /* * Skip unwanted entries which are either not real entries or * very difficult to interpret (wildcards...) This test needs * lots of improvement. Any takers? */ key = k->key; if (!key) continue; /* Skip '/defaults' */ if (STREQ(key, "/defaults")) continue; /* Skip '*' */ if (!fully_browsable && strchr(key, '*')) continue; /* * If the map has a prefix-string then check if the key starts with * this string, and if it does, skip over this prefix. If it has a * prefix and it doesn't match the start of the key, skip it. */ if (preflen) { if (preflen > strlen(key)) continue; if (!NSTREQ(key, mp->am_pref, preflen)) continue; key += preflen; } /* no more '/' are allowed, unless browsable_dirs=full was used */ if (!fully_browsable && strchr(key, '/')) continue; /* no duplicates allowed */ if (key_already_in_chain(key, current_chain)) continue; /* fill in a cell and link the entry */ if (num_entries >= max_entries) { /* out of space */ plog(XLOG_DEBUG, "make_entry_chain: no more space in chain"); if (num_entries > 0) { chain[num_entries - 1].ne_nextentry = NULL; retval = &chain[0]; } return retval; } /* we have space. put entry in next cell */ ++last_cookie; chain[num_entries].ne_fileid = last_cookie; (void)memcpy(chain[num_entries].ne_cookie, &last_cookie, sizeof(last_cookie)); chain[num_entries].ne_name = key; if (num_entries < max_entries - 1) { /* link to next one */ chain[num_entries].ne_nextentry = &chain[num_entries + 1]; } ++num_entries; } /* end of "while (k)" */ } /* end of "for (i ... NKVHASH ..." */ /* terminate chain */ if (num_entries > 0) { chain[num_entries - 1].ne_nextentry = NULL; retval = &chain[0]; } return retval; } /* This one is called only if map is browsable */ static int amfs_readdir_browsable(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, u_int count, int fully_browsable) { u_int gen = *(u_int *) cookie; int chain_length, i; static nfsentry *te, *te_next; static int j; dp->dl_eof = FALSE; /* assume readdir not done */ if (amuDebug(D_READDIR)) plog(XLOG_DEBUG, "amfs_readdir_browsable gen=%u, count=%d", gen, count); if (gen == 0) { /* * In the default instance (which is used to start a search) we return * "." and "..". * * This assumes that the count is big enough to allow both "." and ".." * to be returned in a single packet. If it isn't (which would be * fairly unbelievable) then tough. */ dlog("amfs_readdir_browsable: default search"); /* * Check for enough room. This is extremely approximate but is more * than enough space. Really need 2 times: * 4byte fileid * 4byte cookie * 4byte name length * 4byte name * plus the dirlist structure */ if (count < (2 * (2 * (sizeof(*ep) + sizeof("..") + 4) + sizeof(*dp)))) return EINVAL; /* * compute # of entries to send in this chain. * heuristics: 128 bytes per entry. * This is too much probably, but it seems to work better because * of the re-entrant nature of nfs_readdir, and esp. on systems * like OpenBSD 2.2. */ chain_length = count / 128; /* reset static state counters */ te = te_next = NULL; dp->dl_entries = ep; /* construct "." */ ep[0].ne_fileid = mp->am_gen; ep[0].ne_name = "."; ep[0].ne_nextentry = &ep[1]; (void)memset(ep[0].ne_cookie, 0, sizeof(u_int)); /* construct ".." */ if (mp->am_parent) ep[1].ne_fileid = mp->am_parent->am_gen; else ep[1].ne_fileid = mp->am_gen; ep[1].ne_name = ".."; ep[1].ne_nextentry = NULL; (void)memcpy(ep[1].ne_cookie, &dotdotcookie, sizeof(dotdotcookie)); /* * If map is browsable, call a function make_entry_chain() to construct * a linked list of unmounted keys, and return it. Then link the chain * to the regular list. Get the chain only once, but return * chunks of it each time. */ te = make_entry_chain(mp, dp->dl_entries, fully_browsable); if (!te) return 0; if (amuDebug(D_READDIR)) { nfsentry *ne; for (j = 0, ne = te; ne; ne = ne->ne_nextentry) plog(XLOG_DEBUG, "gen1 key %4d \"%s\"", j++, ne->ne_name); } /* return only "chain_length" entries */ te_next = te; for (i=1; ine_nextentry; if (!te_next) break; } if (te_next) { nfsentry *te_saved = te_next->ne_nextentry; te_next->ne_nextentry = NULL; /* terminate "te" chain */ te_next = te_saved; /* save rest of "te" for next iteration */ dp->dl_eof = FALSE; /* tell readdir there's more */ } else { dp->dl_eof = TRUE; /* tell readdir that's it */ } ep[1].ne_nextentry = te; /* append this chunk of "te" chain */ if (amuDebug(D_READDIR)) { nfsentry *ne; for (j = 0, ne = te; ne; ne = ne->ne_nextentry) plog(XLOG_DEBUG, "gen2 key %4d \"%s\"", j++, ne->ne_name); for (j = 0, ne = ep; ne; ne = ne->ne_nextentry) { u_int cookie; (void)memcpy(&cookie, ne->ne_cookie, sizeof(cookie)); plog(XLOG_DEBUG, "gen2+ key %4d \"%s\" fi=%d ck=%d", j++, ne->ne_name, ne->ne_fileid, cookie); } plog(XLOG_DEBUG, "EOF is %d", dp->dl_eof); } return 0; } /* end of "if (gen == 0)" statement */ dlog("amfs_readdir_browsable: real child"); if (gen == DOT_DOT_COOKIE) { dlog("amfs_readdir_browsable: End of readdir in %s", mp->am_path); dp->dl_eof = TRUE; dp->dl_entries = NULL; return 0; } /* * If browsable directories, then continue serving readdir() with another * chunk of entries, starting from where we left off (when gen was equal * to 0). Once again, assume last chunk served to readdir. */ dp->dl_eof = TRUE; dp->dl_entries = ep; te = te_next; /* reset 'te' from last saved te_next */ if (!te) { /* another indicator of end of readdir */ dp->dl_entries = NULL; return 0; } /* * compute # of entries to send in this chain. * heuristics: 128 bytes per entry. */ chain_length = count / 128; /* return only "chain_length" entries */ for (i = 1; i < chain_length; ++i) { te_next = te_next->ne_nextentry; if (!te_next) break; } if (te_next) { nfsentry *te_saved = te_next->ne_nextentry; te_next->ne_nextentry = NULL; /* terminate "te" chain */ te_next = te_saved; /* save rest of "te" for next iteration */ dp->dl_eof = FALSE; /* tell readdir there's more */ } ep = te; /* send next chunk of "te" chain */ dp->dl_entries = ep; if (amuDebug(D_READDIR)) { nfsentry *ne; plog(XLOG_DEBUG, "dl_entries=%p, te_next=%p, dl_eof=%d", dp->dl_entries, te_next, dp->dl_eof); for (ne = te; ne; ne = ne->ne_nextentry) plog(XLOG_DEBUG, "gen3 key %4d \"%s\"", j++, ne->ne_name); } return 0; } /* * This readdir function which call a special version of it that allows * browsing if browsable_dirs=yes was set on the map. */ int amfs_generic_readdir(am_node *mp, nfscookie cookie, nfsdirlist *dp, nfsentry *ep, u_int count) { u_int gen = *(u_int *) cookie; am_node *xp; mntent_t mnt; dp->dl_eof = FALSE; /* assume readdir not done */ /* check if map is browsable */ if (mp->am_al->al_mnt && mp->am_al->al_mnt->mf_mopts) { mnt.mnt_opts = mp->am_al->al_mnt->mf_mopts; if (amu_hasmntopt(&mnt, "fullybrowsable")) return amfs_readdir_browsable(mp, cookie, dp, ep, count, TRUE); if (amu_hasmntopt(&mnt, "browsable")) return amfs_readdir_browsable(mp, cookie, dp, ep, count, FALSE); } /* when gen is 0, we start reading from the beginning of the directory */ if (gen == 0) { /* * In the default instance (which is used to start a search) we return * "." and "..". * * This assumes that the count is big enough to allow both "." and ".." * to be returned in a single packet. If it isn't (which would be * fairly unbelievable) then tough. */ dlog("amfs_generic_readdir: default search"); /* * Check for enough room. This is extremely approximate but is more * than enough space. Really need 2 times: * 4byte fileid * 4byte cookie * 4byte name length * 4byte name * plus the dirlist structure */ if (count < (2 * (2 * (sizeof(*ep) + sizeof("..") + 4) + sizeof(*dp)))) return EINVAL; xp = next_nonerror_node(mp->am_child); dp->dl_entries = ep; /* construct "." */ ep[0].ne_fileid = mp->am_gen; ep[0].ne_name = "."; ep[0].ne_nextentry = &ep[1]; (void)memset(ep[0].ne_cookie, 0, sizeof(u_int)); /* construct ".." */ if (mp->am_parent) ep[1].ne_fileid = mp->am_parent->am_gen; else ep[1].ne_fileid = mp->am_gen; ep[1].ne_name = ".."; ep[1].ne_nextentry = NULL; (void)memcpy(ep[1].ne_cookie, (xp ? &xp->am_gen : &dotdotcookie), sizeof(dotdotcookie)); if (!xp) dp->dl_eof = TRUE; /* by default assume readdir done */ if (amuDebug(D_READDIR)) { nfsentry *ne; int j; for (j = 0, ne = ep; ne; ne = ne->ne_nextentry) { u_int cookie; (void)memcpy(&cookie, ne->ne_cookie, sizeof(cookie)); plog(XLOG_DEBUG, "gen1 key %4d \"%s\" fi=%d ck=%d", j++, ne->ne_name, ne->ne_fileid, cookie); } } return 0; } dlog("amfs_generic_readdir: real child"); if (gen == DOT_DOT_COOKIE) { dlog("amfs_generic_readdir: End of readdir in %s", mp->am_path); dp->dl_eof = TRUE; dp->dl_entries = NULL; if (amuDebug(D_READDIR)) plog(XLOG_DEBUG, "end of readdir eof=TRUE, dl_entries=0\n"); return 0; } /* non-browsable directories code */ xp = mp->am_child; while (xp && xp->am_gen != gen) xp = xp->am_osib; if (xp) { int nbytes = count / 2; /* conservative */ int todo = MAX_READDIR_ENTRIES; dp->dl_entries = ep; do { am_node *xp_next = next_nonerror_node(xp->am_osib); if (xp_next) { (void)memcpy(ep->ne_cookie, &xp_next->am_gen, sizeof(xp_next->am_gen)); } else { (void)memcpy(ep->ne_cookie, &dotdotcookie, sizeof(dotdotcookie)); dp->dl_eof = TRUE; } ep->ne_fileid = xp->am_gen; ep->ne_name = xp->am_name; nbytes -= sizeof(*ep) + 1; if (xp->am_name) nbytes -= strlen(xp->am_name); xp = xp_next; if (nbytes > 0 && !dp->dl_eof && todo > 1) { ep->ne_nextentry = ep + 1; ep++; --todo; } else { todo = 0; } } while (todo > 0); ep->ne_nextentry = NULL; if (amuDebug(D_READDIR)) { nfsentry *ne; int j; for (j=0,ne=ep; ne; ne=ne->ne_nextentry) { u_int cookie; (void)memcpy(&cookie, ne->ne_cookie, sizeof(cookie)); plog(XLOG_DEBUG, "gen2 key %4d \"%s\" fi=%d ck=%d", j++, ne->ne_name, ne->ne_fileid, cookie); } } return 0; } return ESTALE; } am-utils-6.2+rc20110530/amd/restart.c000066400000000000000000000205001157065440000167200ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/restart.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include static void restart_fake_mntfs(mntent_t *me, am_ops *fs_ops) { mntfs *mf; am_opts mo; char *cp; /* * Partially fake up an opts structure */ memset(&mo, 0, sizeof(mo)); mo.opt_rhost = NULL; mo.opt_rfs = NULL; cp = strchr(me->mnt_fsname, ':'); if (cp) { *cp = '\0'; mo.opt_rhost = strdup(me->mnt_fsname); mo.opt_rfs = strdup(cp + 1); *cp = ':'; } else if (STREQ(me->mnt_type, MNTTAB_TYPE_NFS)) { /* * Hacky workaround for mnttab NFS entries that only list the server */ plog(XLOG_WARNING, "NFS server entry assumed to be %s:/", me->mnt_fsname); mo.opt_rhost = strdup(me->mnt_fsname); mo.opt_rfs = strdup("/"); me->mnt_fsname = str3cat(me->mnt_fsname, mo.opt_rhost, ":", "/"); } mo.opt_fs = me->mnt_dir; mo.opt_opts = me->mnt_opts; /* * Make a new mounted filesystem */ mf = find_mntfs(fs_ops, &mo, me->mnt_dir, me->mnt_fsname, "", me->mnt_opts, ""); if (mf->mf_refc == 1) { mf->mf_flags |= MFF_RESTART | MFF_MOUNTED; mf->mf_error = 0; /* Already mounted correctly */ /* * Only timeout non-NFS entries */ if (!STREQ(me->mnt_type, MNTTAB_TYPE_NFS)) mf->mf_flags |= MFF_RSTKEEP; if (fs_ops->fs_init) { /* * Don't care whether this worked since * it is checked again when the fs is * inherited. */ (void) (*fs_ops->fs_init) (mf); } plog(XLOG_INFO, "%s restarted fstype %s on %s, flags 0x%x", me->mnt_fsname, fs_ops->fs_type, me->mnt_dir, mf->mf_flags); } else { /* Something strange happened - two mounts at the same place! */ free_mntfs(mf); } /* * Clean up mo */ if (mo.opt_rhost) XFREE(mo.opt_rhost); if (mo.opt_rfs) XFREE(mo.opt_rfs); } /* * Handle an amd restart. * * Scan through the mount list finding all "interesting" mount points. * Next hack up partial data structures and add the mounted file * system to the list of known filesystems. * * This module relies on internal details of other components. If * you change something else make *sure* restart() still works. */ void restart(void) { mntlist *ml, *mlp; /* * Read the existing mount table. For each entry, find nfs, ufs or auto * mounts and create a partial am_node to represent it. */ for (mlp = ml = read_mtab("restart", mnttab_file_name); mlp; mlp = mlp->mnext) { mntent_t *me = mlp->mnt; am_ops *fs_ops = NULL; if (STREQ(me->mnt_type, MNTTAB_TYPE_NFS)) { /* * NFS entry, or possibly an Amd entry... * The mnt_fsname for daemon mount points is * host:(pidXXX) * or (seen on Solaris) * host:daemon(pidXXX) */ char *colon = strchr(me->mnt_fsname, ':'); if (colon && strstr(colon, "(pid")) continue; } /* Search for the correct filesystem ops */ fs_ops = ops_search(me->mnt_type); /* * Catch everything else with symlinks to * avoid recursive mounts. This is debatable... */ if (!fs_ops) fs_ops = &amfs_link_ops; restart_fake_mntfs(me, fs_ops); } /* * Free the mount list */ free_mntlist(ml); } /* * Handle an amd restart for amd's own mount points. * * Scan through the mount list finding all daemon mount points * (determined by the presence of a pid inside the mount info). * Next hack up partial data structures and add the mounted file * system to the list of known filesystems. * * This module relies on internal details of other components. If * you change something else make *sure* restart() still works. */ void restart_automounter_nodes(void) { mntlist *ml, *mlp; /* reasonably sized list of restarted nfs ports */ u_short old_ports[256]; memset((voidp) &old_ports, 0, sizeof(u_short) * 256); /* * Read the existing mount table. For each entry, find nfs, ufs or auto * mounts and create a partial am_node to represent it. */ for (mlp = ml = read_mtab("restart", mnttab_file_name); mlp; mlp = mlp->mnext) { mntent_t *me = mlp->mnt; am_ops *fs_ops = NULL; char *colon; long pid; u_short port; int err; if (!STREQ(me->mnt_type, MNTTAB_TYPE_NFS)) continue; /* to next mlp */ /* * NFS entry, or possibly an Amd entry... * The mnt_fsname for daemon mount points is * host:(pidXXX) * or (seen on Solaris) * host:daemon(pidXXX) */ colon = strchr(me->mnt_fsname, ':'); if (!colon || !strstr(colon, "(pid")) continue; /* if got here, then we matched an existing Amd mount point */ err = 1; plog(XLOG_WARNING, "%s is an existing automount point", me->mnt_dir); /* Is the old automounter still alive? */ if (sscanf(colon, "%*[^(](pid%ld%*[,)]", &pid) != 1) { plog(XLOG_WARNING, "Can't parse pid in %s", me->mnt_fsname); goto give_up; } if (kill(pid, 0) != -1 || errno != ESRCH) { plog(XLOG_WARNING, "Automounter (pid: %ld) still alive", pid); goto give_up; } /* * Do we have a map for this mount point? Who cares, we'll restart * anyway -- getting ESTALE is way better than hanging. */ /* Can we restart it? Only if it tells us what port it was using... */ if (sscanf(colon, "%*[^,],port%hu)", &port) != 1) { plog(XLOG_WARNING, "No port specified for %s", me->mnt_fsname); goto give_up; } /* Maybe we already own that port... */ if (port != nfs_port) { int i; for (i = 0; i < 256; i++) { if (old_ports[i] == port || old_ports[i] == 0) break; } if (i == 256) { plog(XLOG_WARNING, "Too many open ports (256)"); goto give_up; } if (old_ports[i] == 0) { int soNFS; SVCXPRT *nfsxprt; if (create_nfs_service(&soNFS, &port, &nfsxprt, nfs_program_2) != 0) { plog(XLOG_WARNING, "Can't bind to port %u", port); goto give_up; } old_ports[i] = nfs_port = port; } } err = 0; give_up: if (err) { plog(XLOG_WARNING, "Can't restart %s, leaving it alone", me->mnt_dir); fs_ops = &amfs_link_ops; } else { fs_ops = &amfs_toplvl_ops; } restart_fake_mntfs(me, fs_ops); } /* end of "for (mlp" */ /* free the mount list */ free_mntlist(ml); } am-utils-6.2+rc20110530/amd/rpc_fwd.c000066400000000000000000000270611157065440000166710ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/rpc_fwd.c * */ /* * RPC packet forwarding */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Note that the ID field in the external packet is only * ever treated as a 32 bit opaque data object, so there * is no need to convert to and from network byte ordering. */ #define XID_ALLOC() (xid++) #define MAX_PACKET_SIZE 8192 /* Maximum UDP packet size */ /* * Each pending reply has an rpc_forward structure * associated with it. These have a 15 second lifespan. * If a new structure is required, then an expired * one will be re-allocated if available, otherwise a fresh * one is allocated. Whenever a reply is received the * structure is discarded. */ typedef struct rpc_forward rpc_forward; struct rpc_forward { qelem rf_q; /* Linked list */ time_t rf_ttl; /* Time to live */ u_int rf_xid; /* Packet id */ u_int rf_oldid; /* Original packet id */ fwd_fun *rf_fwd; /* Forwarding function */ voidp rf_ptr; struct sockaddr_in rf_sin; }; /* * Head of list of pending replies */ qelem rpc_head = {&rpc_head, &rpc_head}; int fwd_sock; static u_int xid; /* * Allocate a rely structure */ static rpc_forward * fwd_alloc(void) { time_t now = clocktime(NULL); rpc_forward *p = NULL, *p2; /* * First search for an existing expired one. */ ITER(p2, rpc_forward, &rpc_head) { if (p2->rf_ttl <= now) { p = p2; break; } } /* * If one couldn't be found then allocate * a new structure and link it at the * head of the list. */ if (p) { /* * Call forwarding function to say that * this message was junked. */ dlog("Re-using packet forwarding slot - id %#x", p->rf_xid); if (p->rf_fwd) (*p->rf_fwd) (0, 0, 0, &p->rf_sin, p->rf_ptr, FALSE); rem_que(&p->rf_q); } else { p = ALLOC(struct rpc_forward); } ins_que(&p->rf_q, &rpc_head); /* * Set the time to live field * Timeout in 43 seconds */ p->rf_ttl = now + 43; return p; } /* * Free an allocated reply structure. * First unlink it from the list, then * discard it. */ static void fwd_free(rpc_forward *p) { rem_que(&p->rf_q); XFREE(p); } /* * Initialize the RPC forwarder */ int fwd_init(void) { #ifdef FIONBIO int on = 1; #endif /* FIONBIO */ #ifdef HAVE_TRANSPORT_TYPE_TLI /* * Create ping TLI socket (/dev/tcp and /dev/ticlts did not work) * (HPUX-11 does not like using O_NDELAY in flags) */ fwd_sock = t_open("/dev/udp", O_RDWR|O_NONBLOCK, 0); if (fwd_sock < 0) { plog(XLOG_ERROR, "unable to create RPC forwarding TLI socket: %s", t_errlist[t_errno]); return errno; } #else /* not HAVE_TRANSPORT_TYPE_TLI */ /* * Create ping socket */ fwd_sock = socket(AF_INET, SOCK_DGRAM, 0); if (fwd_sock < 0) { plog(XLOG_ERROR, "unable to create RPC forwarding socket: %m"); return errno; } #endif /* not HAVE_TRANSPORT_TYPE_TLI */ /* * Some things we talk to require a priv port - so make one here */ if (bind_resv_port(fwd_sock, (u_short *) NULL) < 0) plog(XLOG_ERROR, "can't bind privileged port (rpc_fwd)"); if (fcntl(fwd_sock, F_SETFL, FNDELAY) < 0 #ifdef FIONBIO && ioctl(fwd_sock, FIONBIO, &on) < 0 #endif /* FIONBIO */ ) { plog(XLOG_ERROR, "Can't set non-block on forwarding socket: %m"); return errno; } return 0; } /* * Locate a packet in the forwarding list */ static rpc_forward * fwd_locate(u_int id) { rpc_forward *p; ITER(p, rpc_forward, &rpc_head) { if (p->rf_xid == id) return p; } return 0; } /* * This is called to forward a packet to another * RPC server. The message id is changed and noted * so that when a reply appears we can tie it up * correctly. Just matching the reply's source address * would not work because it might come from a * different address. */ int fwd_packet(int type_id, char *pkt, int len, struct sockaddr_in *fwdto, struct sockaddr_in *replyto, opaque_t cb_arg, fwd_fun cb) { rpc_forward *p; u_int *pkt_int; int error; #ifdef HAVE_TRANSPORT_TYPE_TLI struct t_unitdata ud; #endif /* HAVE_TRANSPORT_TYPE_TLI */ if ((int) amd_state >= (int) Finishing) return ENOENT; /* * See if the type_id is fully specified. * If so, then discard any old entries * for this id. * Otherwise make sure the type_id is * fully qualified by allocating an id here. */ switch (type_id & RPC_XID_MASK) { case RPC_XID_PORTMAP: dlog("Sending PORTMAP request %#x", type_id); break; case RPC_XID_MOUNTD: dlog("Sending MOUNTD request %#x", type_id); break; case RPC_XID_NFSPING: dlog("Sending NFS ping %#x", type_id); break; case RPC_XID_WEBNFS: dlog("Sending WebNFS lookup %#x", type_id); break; default: dlog("UNKNOWN RPC XID %#x", type_id); break; } if (type_id & ~RPC_XID_MASK) { p = fwd_locate(type_id); if (p) { dlog("Discarding earlier rpc fwd handle"); fwd_free(p); } } else { dlog("Allocating a new xid..."); type_id = MK_RPC_XID(type_id, XID_ALLOC()); } p = fwd_alloc(); if (!p) return ENOBUFS; error = 0; pkt_int = (u_int *) pkt; /* * Get the original packet id */ p->rf_oldid = ntohl(*pkt_int); /* * Replace with newly allocated id */ p->rf_xid = type_id; *pkt_int = htonl(type_id); /* * The sendto may fail if, for example, the route * to a remote host is lost because an intermediate * gateway has gone down. Important to fill in the * rest of "p" otherwise nasty things happen later... */ #ifdef DEBUG { char dq[20]; if (p && fwdto) dlog("Sending packet id %#x to %s:%d", p->rf_xid, inet_dquad(dq, sizeof(dq), fwdto->sin_addr.s_addr), ntohs(fwdto->sin_port)); } #endif /* DEBUG */ /* if NULL, remote server probably down */ if (!fwdto) { error = AM_ERRNO_HOST_DOWN; goto out; } #ifdef HAVE_TRANSPORT_TYPE_TLI ud.addr.buf = (char *) fwdto; if (fwdto) /* if NULL, set sizes to zero */ ud.addr.maxlen = ud.addr.len = sizeof(struct sockaddr_in); else ud.addr.maxlen = ud.addr.len = 0; ud.opt.buf = (char *) NULL; ud.opt.maxlen = ud.opt.len = 0; ud.udata.buf = pkt; ud.udata.maxlen = ud.udata.len = len; if (t_sndudata(fwd_sock, &ud) < 0) { plog(XLOG_ERROR,"fwd_packet failed: t_errno=%d, errno=%d",t_errno,errno); error = errno; } #else /* not HAVE_TRANSPORT_TYPE_TLI */ if (sendto(fwd_sock, (char *) pkt, len, 0, (struct sockaddr *) fwdto, sizeof(*fwdto)) < 0) error = errno; #endif /* not HAVE_TRANSPORT_TYPE_TLI */ /* * Save callback function and return address */ out: p->rf_fwd = cb; if (replyto) p->rf_sin = *replyto; else memset((voidp) &p->rf_sin, 0, sizeof(p->rf_sin)); p->rf_ptr = cb_arg; return error; } /* * Called when some data arrives on the forwarding socket */ void fwd_reply(void) { int len; u_int pkt[MAX_PACKET_SIZE / sizeof(u_int) + 1]; u_int *pkt_int; u_int pkt_xid; int rc; rpc_forward *p; struct sockaddr_in src_addr; RECVFROM_FROMLEN_TYPE src_addr_len; #ifdef HAVE_TRANSPORT_TYPE_TLI struct t_unitdata ud; int flags = 0; #endif /* HAVE_TRANSPORT_TYPE_TLI */ /* * Determine the length of the packet */ len = MAX_PACKET_SIZE; /* * Read the packet and check for validity */ again: src_addr_len = sizeof(src_addr); #ifdef HAVE_TRANSPORT_TYPE_TLI ud.addr.buf = (char *) &src_addr; ud.addr.maxlen = ud.addr.len = src_addr_len; ud.opt.buf = (char *) NULL; ud.opt.maxlen = ud.opt.len = 0; ud.udata.buf = (char *) pkt; ud.udata.maxlen = ud.udata.len = len; /* XXX: use flags accordingly such as if T_MORE set */ rc = t_rcvudata(fwd_sock, &ud, &flags); if (rc == 0) /* success, reset rc to length */ rc = ud.udata.len; else { plog(XLOG_ERROR,"fwd_reply failed: t_errno=%d, errno=%d, flags=%d",t_errno,errno, flags); /* * Clear error indication, otherwise the error condition persists and * amd gets into an infinite loop. */ if (t_errno == TLOOK) t_rcvuderr(fwd_sock, NULL); } #else /* not HAVE_TRANSPORT_TYPE_TLI */ rc = recvfrom(fwd_sock, (char *) pkt, len, 0, (struct sockaddr *) &src_addr, &src_addr_len); #endif /* not HAVE_TRANSPORT_TYPE_TLI */ /* * XXX: in svr4, if the T_MORE bit of flags is set, what do * we then do? -Erez */ if (rc < 0 || src_addr_len != sizeof(src_addr) || src_addr.sin_family != AF_INET) { if (rc < 0 && errno == EINTR) goto again; plog(XLOG_ERROR, "Error reading RPC reply: %m"); goto out; } /* * Do no more work if finishing soon */ if ((int) amd_state >= (int) Finishing) goto out; /* * Find packet reference */ pkt_int = (u_int *) pkt; pkt_xid = ntohl(*pkt_int); switch (pkt_xid & RPC_XID_MASK) { case RPC_XID_PORTMAP: dlog("Receiving PORTMAP reply %#x", pkt_xid); break; case RPC_XID_MOUNTD: dlog("Receiving MOUNTD reply %#x", pkt_xid); break; case RPC_XID_NFSPING: dlog("Receiving NFS ping %#x", pkt_xid); break; case RPC_XID_WEBNFS: dlog("Receiving WebNFS lookup %#x", pkt_xid); break; default: dlog("UNKNOWN RPC XID %#x", pkt_xid); break; } p = fwd_locate(pkt_xid); if (!p) { dlog("Can't forward reply id %#x", pkt_xid); goto out; } if (p->rf_fwd) { /* * Put the original message id back * into the packet. */ *pkt_int = htonl(p->rf_oldid); /* * Call forwarding function */ (*p->rf_fwd) ((voidp) pkt, rc, &src_addr, &p->rf_sin, p->rf_ptr, TRUE); } /* * Free forwarding info */ fwd_free(p); out:; } am-utils-6.2+rc20110530/amd/sched.c000066400000000000000000000161541157065440000163340ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/sched.c * */ /* * Process scheduler */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include typedef struct pjob pjob; struct pjob { qelem hdr; /* Linked list */ int pid; /* Process ID of job */ cb_fun *cb_fun; /* Callback function */ opaque_t cb_arg; /* Argument for callback */ int w; /* everyone these days uses int, not a "union wait" */ wchan_t wchan; /* Wait channel */ }; /* globals */ qelem proc_list_head = {&proc_list_head, &proc_list_head}; qelem proc_wait_list = {&proc_wait_list, &proc_wait_list}; int task_notify_todo; void ins_que(qelem *elem, qelem *pred) { qelem *p = pred->q_forw; elem->q_back = pred; elem->q_forw = p; pred->q_forw = elem; p->q_back = elem; } void rem_que(qelem *elem) { qelem *p = elem->q_forw; qelem *p2 = elem->q_back; p2->q_forw = p; p->q_back = p2; } static pjob * sched_job(cb_fun *cf, opaque_t ca) { pjob *p = ALLOC(struct pjob); p->cb_fun = cf; p->cb_arg = ca; /* * Now place on wait queue */ ins_que(&p->hdr, &proc_wait_list); return p; } /* * tf: The task to execute (ta is its arguments) * cf: Continuation function (ca is its arguments) */ void run_task(task_fun *tf, opaque_t ta, cb_fun *cf, opaque_t ca) { pjob *p = sched_job(cf, ca); #ifdef HAVE_SIGACTION sigset_t new, mask; #else /* not HAVE_SIGACTION */ int mask; #endif /* not HAVE_SIGACTION */ p->wchan = (wchan_t) p; #ifdef HAVE_SIGACTION sigemptyset(&new); /* initialize signal set we wish to block */ sigaddset(&new, SIGCHLD); /* only block on SIGCHLD */ sigprocmask(SIG_BLOCK, &new, &mask); #else /* not HAVE_SIGACTION */ mask = sigblock(sigmask(SIGCHLD)); #endif /* not HAVE_SIGACTION */ if ((p->pid = background())) { #ifdef HAVE_SIGACTION sigprocmask(SIG_SETMASK, &mask, NULL); #else /* not HAVE_SIGACTION */ sigsetmask(mask); #endif /* not HAVE_SIGACTION */ return; } /* child code runs here, parent has returned to caller */ exit((*tf) (ta)); /* firewall... */ abort(); } /* * Schedule a task to be run when woken up */ void sched_task(cb_fun *cf, opaque_t ca, wchan_t wchan) { /* * Allocate a new task */ pjob *p = sched_job(cf, ca); dlog("SLEEP on %p", wchan); p->wchan = wchan; p->pid = 0; p->w = 0; /* was memset (when ->w was union) */ } static void wakeupjob(pjob *p) { rem_que(&p->hdr); ins_que(&p->hdr, &proc_list_head); task_notify_todo++; } void wakeup(wchan_t wchan) { pjob *p, *p2; if (!foreground) return; /* * Can't use ITER() here because * wakeupjob() juggles the list. */ for (p = AM_FIRST(pjob, &proc_wait_list); p2 = NEXT(pjob, p), p != HEAD(pjob, &proc_wait_list); p = p2) { if (p->wchan == wchan) { wakeupjob(p); } } } void wakeup_task(int rc, int term, wchan_t wchan) { wakeup(wchan); } wchan_t get_mntfs_wchan(mntfs *mf) { if (mf && mf->mf_ops && mf->mf_ops->get_wchan) return mf->mf_ops->get_wchan(mf); return mf; } /* * Run any pending tasks. * This must be called with SIGCHLD disabled */ void do_task_notify(void) { /* * Keep taking the first item off the list and processing it. * * Done this way because the callback can, quite reasonably, * queue a new task, so no local reference into the list can be * held here. */ while (AM_FIRST(pjob, &proc_list_head) != HEAD(pjob, &proc_list_head)) { pjob *p = AM_FIRST(pjob, &proc_list_head); rem_que(&p->hdr); /* * This job has completed */ --task_notify_todo; /* * Do callback if it exists */ if (p->cb_fun) { /* these two trigraphs will ensure compatibility with strict POSIX.1 */ p->cb_fun(WIFEXITED(p->w) ? WEXITSTATUS(p->w) : 0, WIFSIGNALED(p->w) ? WTERMSIG(p->w) : 0, p->cb_arg); } XFREE(p); } } RETSIGTYPE sigchld(int sig) { int w; /* everyone these days uses int, not a "union wait" */ int pid; #ifdef HAVE_WAITPID while ((pid = waitpid((pid_t) -1, &w, WNOHANG)) > 0) { #else /* not HAVE_WAITPID */ while ((pid = wait3( &w, WNOHANG, (struct rusage *) NULL)) > 0) { #endif /* not HAVE_WAITPID */ pjob *p, *p2; if (WIFSIGNALED(w)) plog(XLOG_ERROR, "Process %d exited with signal %d", pid, WTERMSIG(w)); else dlog("Process %d exited with status %d", pid, WEXITSTATUS(w)); for (p = AM_FIRST(pjob, &proc_wait_list); p2 = NEXT(pjob, p), p != HEAD(pjob, &proc_wait_list); p = p2) { if (p->pid == pid) { p->w = w; wakeupjob(p); break; } } /* end of for loop */ if (p == HEAD(pjob, &proc_wait_list)) dlog("can't locate task block for pid %d", pid); /* * Must count down children inside the while loop, otherwise we won't * count them all, and NumChildren (and later backoff) will be set * incorrectly. SH/RUNIT 940519. */ if (--NumChildren < 0) NumChildren = 0; } /* end of "while wait..." loop */ #ifdef REINSTALL_SIGNAL_HANDLER signal(sig, sigchld); #endif /* REINSTALL_SIGNAL_HANDLER */ if (select_intr_valid) longjmp(select_intr, sig); } am-utils-6.2+rc20110530/amd/srvr_amfs_auto.c000066400000000000000000000121251157065440000202720ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/amd/srvr_amfs_auto.c * */ /* * Automount FS server ("localhost") modeling */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* globals */ /* statics */ static qelem amfs_auto_srvr_list = {&amfs_auto_srvr_list, &amfs_auto_srvr_list}; static fserver *localhost; /* * Find an nfs server for the local host */ fserver * amfs_generic_find_srvr(mntfs *mf) { fserver *fs = localhost; if (!fs) { fs = ALLOC(struct fserver); fs->fs_refc = 0; fs->fs_host = strdup("localhost"); fs->fs_ip = NULL; fs->fs_cid = 0; fs->fs_pinger = AM_PINGER; fs->fs_flags = FSF_VALID | FSF_PING_UNINIT; fs->fs_type = "local"; fs->fs_private = NULL; fs->fs_prfree = NULL; ins_que(&fs->fs_q, &amfs_auto_srvr_list); srvrlog(fs, "starts up"); localhost = fs; } fs->fs_refc++; return fs; } /***************************************************************************** *** GENERIC ROUTINES FOLLOW *****************************************************************************/ /* * Wakeup anything waiting for this server */ void wakeup_srvr(fserver *fs) { fs->fs_flags &= ~FSF_WANT; wakeup((voidp) fs); } /* * Called when final ttl of server has expired */ static void timeout_srvr(voidp v) { fserver *fs = v; /* * If the reference count is still zero then * we are free to remove this node */ if (fs->fs_refc == 0) { dlog("Deleting file server %s", fs->fs_host); if (fs->fs_flags & FSF_WANT) wakeup_srvr(fs); /* * Remove from queue. */ rem_que(&fs->fs_q); /* * (Possibly) call the private free routine. */ if (fs->fs_private && fs->fs_prfree) (*fs->fs_prfree) (fs->fs_private); /* * Free the net address */ if (fs->fs_ip) XFREE(fs->fs_ip); /* * Free the host name. */ XFREE(fs->fs_host); /* * Discard the fserver object. */ XFREE(fs); } } /* * Free a file server */ void free_srvr(fserver *fs) { if (--fs->fs_refc == 0) { /* * The reference count is now zero, * so arrange for this node to be * removed in AM_TTL seconds if no * other mntfs is referencing it. */ int ttl = (FSRV_ERROR(fs) || FSRV_ISDOWN(fs)) ? 19 : AM_TTL; dlog("Last hard reference to file server %s - will timeout in %ds", fs->fs_host, ttl); if (fs->fs_cid) { untimeout(fs->fs_cid); /* * Turn off pinging - XXX */ fs->fs_flags &= ~FSF_PINGING; } /* * Keep structure lying around for a while */ fs->fs_cid = timeout(ttl, timeout_srvr, (voidp) fs); /* * Mark the fileserver down and invalid again */ fs->fs_flags &= ~FSF_VALID; fs->fs_flags |= FSF_DOWN; } } /* * Make a duplicate fserver reference */ fserver * dup_srvr(fserver *fs) { fs->fs_refc++; return fs; } /* * Log state change */ void srvrlog(fserver *fs, char *state) { plog(XLOG_INFO, "file server %s, type %s, state %s", fs->fs_host, fs->fs_type, state); } am-utils-6.2+rc20110530/amd/srvr_nfs.c000066400000000000000000000677571157065440000171270ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amd/srvr_nfs.c * */ /* * NFS server modeling */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Number of pings allowed to fail before host is declared down * - three-fifths of the allowed mount time... */ #define MAX_ALLOWED_PINGS (3 + /* for luck ... */ 1) /* * How often to ping when starting a new server */ #define FAST_NFS_PING 3 #if (FAST_NFS_PING * MAX_ALLOWED_PINGS) >= ALLOWED_MOUNT_TIME # error: sanity check failed in srvr_nfs.c /* * you cannot do things this way... * sufficient fast pings must be given the chance to fail * within the allowed mount time */ #endif /* (FAST_NFS_PING * MAX_ALLOWED_PINGS) >= ALLOWED_MOUNT_TIME */ /* structures and typedefs */ typedef struct nfs_private { u_short np_mountd; /* Mount daemon port number */ char np_mountd_inval; /* Port *may* be invalid */ int np_ping; /* Number of failed ping attempts */ time_t np_ttl; /* Time when server is thought dead */ int np_xid; /* RPC transaction id for pings */ int np_error; /* Error during portmap request */ } nfs_private; /* globals */ qelem nfs_srvr_list = {&nfs_srvr_list, &nfs_srvr_list}; /* statics */ static int global_xid; /* For NFS pings */ #define XID_ALLOC() (++global_xid) #ifdef HAVE_FS_NFS3 # define NUM_NFS_VERS 2 #else /* not HAVE_FS_NFS3 */ # define NUM_NFS_VERS 1 #endif /* not HAVE_FS_NFS3 */ static int ping_len[NUM_NFS_VERS]; static char ping_buf[NUM_NFS_VERS][sizeof(struct rpc_msg) + 32]; #if defined(MNTTAB_OPT_PROTO) || defined(HAVE_FS_NFS3) /* * Protocols we know about, in order of preference. * * Note that Solaris 8 and newer NetBSD systems are switching to UDP first, * so this order may have to be adjusted for Amd in the future once more * vendors make that change. -Erez 11/24/2000 * * Or we might simply make this is a platform-specific order. -Ion 09/13/2003 */ static char *protocols[] = { "tcp", "udp", NULL }; #endif /* defined(MNTTAB_OPT_PROTO) || defined(HAVE_FS_NFS3) */ /* forward definitions */ static void nfs_keepalive(voidp); /* * Flush cached data for an fserver (or for all, if fs==NULL) */ void flush_srvr_nfs_cache(fserver *fs) { fserver *fs2 = NULL; ITER(fs2, fserver, &nfs_srvr_list) { if (fs == NULL || fs == fs2) { nfs_private *np = (nfs_private *) fs2->fs_private; if (np) { np->np_mountd_inval = TRUE; np->np_error = -1; } } } } /* * Startup the NFS ping for a particular version. */ static void create_ping_payload(u_long nfs_version) { XDR ping_xdr; struct rpc_msg ping_msg; /* * Non nfs mounts like /afs/glue.umd.edu have ended up here. */ if (nfs_version == 0) { nfs_version = NFS_VERSION; plog(XLOG_WARNING, "create_ping_payload: nfs_version = 0, changed to 2"); } else plog(XLOG_INFO, "create_ping_payload: nfs_version: %d", (int) nfs_version); rpc_msg_init(&ping_msg, NFS_PROGRAM, nfs_version, NFSPROC_NULL); /* * Create an XDR endpoint */ xdrmem_create(&ping_xdr, ping_buf[nfs_version - NFS_VERSION], sizeof(ping_buf[0]), XDR_ENCODE); /* * Create the NFS ping message */ if (!xdr_callmsg(&ping_xdr, &ping_msg)) { plog(XLOG_ERROR, "Couldn't create ping RPC message"); going_down(3); } /* * Find out how long it is */ ping_len[nfs_version - NFS_VERSION] = xdr_getpos(&ping_xdr); /* * Destroy the XDR endpoint - we don't need it anymore */ xdr_destroy(&ping_xdr); } /* * Called when a portmap reply arrives */ static void got_portmap(voidp pkt, int len, struct sockaddr_in *sa, struct sockaddr_in *ia, voidp idv, int done) { fserver *fs2 = (fserver *) idv; fserver *fs = NULL; /* * Find which fileserver we are talking about */ ITER(fs, fserver, &nfs_srvr_list) if (fs == fs2) break; if (fs == fs2) { u_long port = 0; /* XXX - should be short but protocol is naff */ int error = done ? pickup_rpc_reply(pkt, len, (voidp) &port, (XDRPROC_T_TYPE) xdr_u_long) : -1; nfs_private *np = (nfs_private *) fs->fs_private; if (!error && port) { dlog("got port (%d) for mountd on %s", (int) port, fs->fs_host); /* * Grab the port number. Portmap sends back * an u_long in native ordering, so it * needs converting to a u_short in * network ordering. */ np->np_mountd = htons((u_short) port); np->np_mountd_inval = FALSE; np->np_error = 0; } else { dlog("Error fetching port for mountd on %s", fs->fs_host); dlog("\t error=%d, port=%d", error, (int) port); /* * Almost certainly no mountd running on remote host */ np->np_error = error ? error : ETIMEDOUT; } if (fs->fs_flags & FSF_WANT) wakeup_srvr(fs); } else if (done) { dlog("Got portmap for old port request"); } else { dlog("portmap request timed out"); } } /* * Obtain portmap information */ static int call_portmap(fserver *fs, AUTH *auth, u_long prog, u_long vers, u_long prot) { struct rpc_msg pmap_msg; int len; char iobuf[UDPMSGSIZE]; int error; struct pmap pmap; rpc_msg_init(&pmap_msg, PMAPPROG, PMAPVERS, PMAPPROC_NULL); pmap.pm_prog = prog; pmap.pm_vers = vers; pmap.pm_prot = prot; pmap.pm_port = 0; len = make_rpc_packet(iobuf, sizeof(iobuf), PMAPPROC_GETPORT, &pmap_msg, (voidp) &pmap, (XDRPROC_T_TYPE) xdr_pmap, auth); if (len > 0) { struct sockaddr_in sin; memset((voidp) &sin, 0, sizeof(sin)); sin = *fs->fs_ip; sin.sin_port = htons(PMAPPORT); error = fwd_packet(RPC_XID_PORTMAP, iobuf, len, &sin, &sin, (voidp) fs, got_portmap); } else { error = -len; } return error; } static void recompute_portmap(fserver *fs) { int error; u_long mnt_version; /* * No portmap calls for pure WebNFS servers. */ if (fs->fs_flags & FSF_WEBNFS) return; if (nfs_auth) error = 0; else error = make_nfs_auth(); if (error) { nfs_private *np = (nfs_private *) fs->fs_private; np->np_error = error; return; } if (fs->fs_version == 0) plog(XLOG_WARNING, "recompute_portmap: nfs_version = 0 fixed"); plog(XLOG_INFO, "recompute_portmap: NFS version %d on %s", (int) fs->fs_version, fs->fs_host); #ifdef HAVE_FS_NFS3 if (fs->fs_version == NFS_VERSION3) mnt_version = AM_MOUNTVERS3; else #endif /* HAVE_FS_NFS3 */ mnt_version = MOUNTVERS; plog(XLOG_INFO, "Using MOUNT version: %d", (int) mnt_version); call_portmap(fs, nfs_auth, MOUNTPROG, mnt_version, (u_long) IPPROTO_UDP); } int get_mountd_port(fserver *fs, u_short *port, wchan_t wchan) { int error = -1; if (FSRV_ISDOWN(fs)) return EWOULDBLOCK; if (FSRV_ISUP(fs)) { nfs_private *np = (nfs_private *) fs->fs_private; if (np->np_error == 0) { *port = np->np_mountd; error = 0; } else { error = np->np_error; } /* * Now go get the port mapping again in case it changed. * Note that it is used even if (np_mountd_inval) * is True. The flag is used simply as an * indication that the mountd may be invalid, not * that it is known to be invalid. */ if (np->np_mountd_inval) recompute_portmap(fs); else np->np_mountd_inval = TRUE; } if (error < 0 && wchan && !(fs->fs_flags & FSF_WANT)) { /* * If a wait channel is supplied, and no * error has yet occurred, then arrange * that a wakeup is done on the wait channel, * whenever a wakeup is done on this fs node. * Wakeup's are done on the fs node whenever * it changes state - thus causing control to * come back here and new, better things to happen. */ fs->fs_flags |= FSF_WANT; sched_task(wakeup_task, wchan, (wchan_t) fs); } return error; } /* * This is called when we get a reply to an RPC ping. * The value of id was taken from the nfs_private * structure when the ping was transmitted. */ static void nfs_keepalive_callback(voidp pkt, int len, struct sockaddr_in *sp, struct sockaddr_in *tsp, voidp idv, int done) { int xid = (long) idv; /* cast needed for 64-bit archs */ fserver *fs; int found_map = 0; if (!done) return; /* * For each node... */ ITER(fs, fserver, &nfs_srvr_list) { nfs_private *np = (nfs_private *) fs->fs_private; if (np->np_xid == xid && (fs->fs_flags & FSF_PINGING)) { /* * Reset the ping counter. * Update the keepalive timer. * Log what happened. */ if (fs->fs_flags & FSF_DOWN) { fs->fs_flags &= ~FSF_DOWN; if (fs->fs_flags & FSF_VALID) { srvrlog(fs, "is up"); } else { if (np->np_ping > 1) srvrlog(fs, "ok"); else srvrlog(fs, "starts up"); fs->fs_flags |= FSF_VALID; } map_flush_srvr(fs); } else { if (fs->fs_flags & FSF_VALID) { dlog("file server %s type nfs is still up", fs->fs_host); } else { if (np->np_ping > 1) srvrlog(fs, "ok"); fs->fs_flags |= FSF_VALID; } } /* * Adjust ping interval */ untimeout(fs->fs_cid); fs->fs_cid = timeout(fs->fs_pinger, nfs_keepalive, (voidp) fs); /* * Update ttl for this server */ np->np_ttl = clocktime(NULL) + (MAX_ALLOWED_PINGS - 1) * FAST_NFS_PING + fs->fs_pinger - 1; /* * New RPC xid... */ np->np_xid = XID_ALLOC(); /* * Failed pings is zero... */ np->np_ping = 0; /* * Recompute portmap information if not known */ if (np->np_mountd_inval) recompute_portmap(fs); found_map++; break; } } if (found_map == 0) dlog("Spurious ping packet"); } static void check_fs_addr_change(fserver *fs) { struct hostent *hp = NULL; struct in_addr ia; char *old_ipaddr, *new_ipaddr; hp = gethostbyname(fs->fs_host); if (!hp || hp->h_addrtype != AF_INET || !STREQ((char *) hp->h_name, fs->fs_host) || memcmp((voidp) &fs->fs_ip->sin_addr, (voidp) hp->h_addr, sizeof(fs->fs_ip->sin_addr)) == 0) return; /* if got here: downed server changed IP address */ old_ipaddr = strdup(inet_ntoa(fs->fs_ip->sin_addr)); memmove((voidp) &ia, (voidp) hp->h_addr, sizeof(struct in_addr)); new_ipaddr = inet_ntoa(ia); /* ntoa uses static buf */ plog(XLOG_WARNING, "EZK: down fileserver %s changed ip: %s -> %s", fs->fs_host, old_ipaddr, new_ipaddr); XFREE(old_ipaddr); /* copy new IP addr */ memmove((voidp) &fs->fs_ip->sin_addr, (voidp) hp->h_addr, sizeof(fs->fs_ip->sin_addr)); /* XXX: do we need to un/set these flags? */ fs->fs_flags &= ~FSF_DOWN; fs->fs_flags |= FSF_VALID | FSF_WANT; map_flush_srvr(fs); /* XXX: a race with flush_srvr_nfs_cache? */ flush_srvr_nfs_cache(fs); fs->fs_flags |= FSF_FORCE_UNMOUNT; #if 0 flush_nfs_fhandle_cache(fs); /* done in caller: nfs_keepalive_timeout */ /* XXX: need to purge nfs_private so that somehow it will get re-initialized? */ #endif /* 0 */ } /* * Called when no ping-reply received */ static void nfs_keepalive_timeout(voidp v) { fserver *fs = v; nfs_private *np = (nfs_private *) fs->fs_private; /* * Another ping has failed */ np->np_ping++; if (np->np_ping > 1) srvrlog(fs, "not responding"); /* * Not known to be up any longer */ if (FSRV_ISUP(fs)) fs->fs_flags &= ~FSF_VALID; /* * If ttl has expired then guess that it is dead */ if (np->np_ttl < clocktime(NULL)) { int oflags = fs->fs_flags; dlog("ttl has expired"); if ((fs->fs_flags & FSF_DOWN) == 0) { /* * Server was up, but is now down. */ srvrlog(fs, "is down"); fs->fs_flags |= FSF_DOWN | FSF_VALID; /* * Since the server is down, the portmap * information may now be wrong, so it * must be flushed from the local cache */ flush_nfs_fhandle_cache(fs); np->np_error = -1; check_fs_addr_change(fs); /* check if IP addr of fserver changed */ } else { /* * Known to be down */ if ((fs->fs_flags & FSF_VALID) == 0) srvrlog(fs, "starts down"); fs->fs_flags |= FSF_VALID; } if (oflags != fs->fs_flags && (fs->fs_flags & FSF_WANT)) wakeup_srvr(fs); /* * Reset failed ping count */ np->np_ping = 0; } else { if (np->np_ping > 1) dlog("%d pings to %s failed - at most %d allowed", np->np_ping, fs->fs_host, MAX_ALLOWED_PINGS); } /* * New RPC xid, so any late responses to the previous ping * get ignored... */ np->np_xid = XID_ALLOC(); /* * Run keepalive again */ nfs_keepalive(fs); } /* * Keep track of whether a server is alive */ static void nfs_keepalive(voidp v) { fserver *fs = v; int error; nfs_private *np = (nfs_private *) fs->fs_private; int fstimeo = -1; /* * Send an NFS ping to this node */ if (ping_len[fs->fs_version - NFS_VERSION] == 0) create_ping_payload(fs->fs_version); /* * Queue the packet... */ error = fwd_packet(MK_RPC_XID(RPC_XID_NFSPING, np->np_xid), ping_buf[fs->fs_version - NFS_VERSION], ping_len[fs->fs_version - NFS_VERSION], fs->fs_ip, (struct sockaddr_in *) NULL, (voidp) ((long) np->np_xid), /* cast needed for 64-bit archs */ nfs_keepalive_callback); /* * See if a hard error occurred */ switch (error) { case ENETDOWN: case ENETUNREACH: case EHOSTDOWN: case EHOSTUNREACH: np->np_ping = MAX_ALLOWED_PINGS; /* immediately down */ np->np_ttl = (time_t) 0; /* * This causes an immediate call to nfs_keepalive_timeout * whenever the server was thought to be up. * See +++ below. */ fstimeo = 0; break; case 0: dlog("Sent NFS ping to %s", fs->fs_host); break; } /* * Back off the ping interval if we are not getting replies and * the remote system is known to be down. */ switch (fs->fs_flags & (FSF_DOWN | FSF_VALID)) { case FSF_VALID: /* Up */ if (fstimeo < 0) /* +++ see above */ fstimeo = FAST_NFS_PING; break; case FSF_VALID | FSF_DOWN: /* Down */ fstimeo = fs->fs_pinger; break; default: /* Unknown */ fstimeo = FAST_NFS_PING; break; } dlog("NFS timeout in %d seconds", fstimeo); fs->fs_cid = timeout(fstimeo, nfs_keepalive_timeout, (voidp) fs); } static void start_nfs_pings(fserver *fs, int pingval) { if (pingval == 0) /* could be because ping mnt option not found */ pingval = AM_PINGER; /* if pings haven't been initalized, then init them for first time */ if (fs->fs_flags & FSF_PING_UNINIT) { fs->fs_flags &= ~FSF_PING_UNINIT; plog(XLOG_INFO, "initializing %s's pinger to %d sec", fs->fs_host, pingval); goto do_pings; } if ((fs->fs_flags & FSF_PINGING) && fs->fs_pinger == pingval) { dlog("already running pings to %s", fs->fs_host); return; } /* if got here, then we need to update the ping value */ plog(XLOG_INFO, "changing %s's ping value from %d%s to %d%s", fs->fs_host, fs->fs_pinger, (fs->fs_pinger < 0 ? " (off)" : ""), pingval, (pingval < 0 ? " (off)" : "")); do_pings: fs->fs_pinger = pingval; if (fs->fs_cid) untimeout(fs->fs_cid); if (pingval < 0) { srvrlog(fs, "wired up (pings disabled)"); fs->fs_flags |= FSF_VALID; fs->fs_flags &= ~FSF_DOWN; } else { fs->fs_flags |= FSF_PINGING; nfs_keepalive(fs); } } /* * Find an nfs server for a host. */ fserver * find_nfs_srvr(mntfs *mf) { char *host = mf->mf_fo->opt_rhost; fserver *fs; int pingval; mntent_t mnt; nfs_private *np; struct hostent *hp = NULL; struct sockaddr_in *ip = NULL; u_long nfs_version = 0; /* default is no version specified */ u_long best_nfs_version = 0; char *nfs_proto = NULL; /* no IP protocol either */ int nfs_port = 0; int nfs_port_opt = 0; int fserver_is_down = 0; /* * Get ping interval from mount options. * Current only used to decide whether pings * are required or not. < 0 = no pings. */ mnt.mnt_opts = mf->mf_mopts; pingval = hasmntval(&mnt, "ping"); if (mf->mf_flags & MFF_NFS_SCALEDOWN) { /* * the server granted us a filehandle, but we were unable to mount it. * therefore, scale down to NFSv2/UDP and try again. */ nfs_version = NFS_VERSION; nfs_proto = "udp"; plog(XLOG_WARNING, "find_nfs_srvr: NFS mount failed, trying again with NFSv2/UDP"); mf->mf_flags &= ~MFF_NFS_SCALEDOWN; } else { /* * Get the NFS version from the mount options. This is used * to decide the highest NFS version to try. */ #ifdef MNTTAB_OPT_VERS nfs_version = hasmntval(&mnt, MNTTAB_OPT_VERS); #endif /* MNTTAB_OPT_VERS */ #ifdef MNTTAB_OPT_PROTO { char *proto_opt = hasmnteq(&mnt, MNTTAB_OPT_PROTO); if (proto_opt) { char **p; for (p = protocols; *p; p++) if (NSTREQ(proto_opt, *p, strlen(*p))) { nfs_proto = *p; break; } if (*p == NULL) plog(XLOG_WARNING, "ignoring unknown protocol option for %s:%s", host, mf->mf_fo->opt_rfs); } } #endif /* MNTTAB_OPT_PROTO */ #ifdef HAVE_NFS_NFSV2_H /* allow overriding if nfsv2 option is specified in mount options */ if (amu_hasmntopt(&mnt, "nfsv2")) { nfs_version = NFS_VERSION;/* nullify any ``vers=X'' statements */ nfs_proto = "udp"; /* nullify any ``proto=tcp'' statements */ plog(XLOG_WARNING, "found compatibility option \"nfsv2\": set options vers=2,proto=udp for host %s", host); } #endif /* HAVE_NFS_NFSV2_H */ /* check if we've globally overridden the NFS version/protocol */ if (gopt.nfs_vers) { nfs_version = gopt.nfs_vers; plog(XLOG_INFO, "find_nfs_srvr: force NFS version to %d", (int) nfs_version); } if (gopt.nfs_proto) { nfs_proto = gopt.nfs_proto; plog(XLOG_INFO, "find_nfs_srvr: force NFS protocol transport to %s", nfs_proto); } } /* * lookup host address and canonical name */ hp = gethostbyname(host); /* * New code from Bob Harris * Use canonical name to keep track of file server * information. This way aliases do not generate * multiple NFS pingers. (Except when we're normalizing * hosts.) */ if (hp && !(gopt.flags & CFM_NORMALIZE_HOSTNAMES)) host = (char *) hp->h_name; if (hp) { switch (hp->h_addrtype) { case AF_INET: ip = ALLOC(struct sockaddr_in); memset((voidp) ip, 0, sizeof(*ip)); /* as per POSIX, sin_len need not be set (used internally by kernel) */ ip->sin_family = AF_INET; memmove((voidp) &ip->sin_addr, (voidp) hp->h_addr, sizeof(ip->sin_addr)); break; default: plog(XLOG_USER, "No IP address for host %s", host); goto no_dns; } } else { plog(XLOG_USER, "Unknown host: %s", host); goto no_dns; } /* * This may not be the best way to do things, but it really doesn't make * sense to query a file server which is marked as 'down' for any * version/proto combination. */ ITER(fs, fserver, &nfs_srvr_list) { if (FSRV_ISDOWN(fs) && STREQ(host, fs->fs_host)) { plog(XLOG_WARNING, "fileserver %s is already hung - not running NFS proto/version discovery", host); fs->fs_refc++; if (ip) XFREE(ip); return fs; } } /* * Get the NFS Version, and verify server is up. * If the client only supports NFSv2, hardcode it but still try to * contact the remote portmapper to see if the service is running. */ #ifndef HAVE_FS_NFS3 nfs_version = NFS_VERSION; nfs_proto = "udp"; plog(XLOG_INFO, "The client supports only NFS(2,udp)"); #endif /* not HAVE_FS_NFS3 */ if (amu_hasmntopt(&mnt, MNTTAB_OPT_PUBLIC)) { /* * Use WebNFS to obtain file handles. */ mf->mf_flags |= MFF_WEBNFS; plog(XLOG_INFO, "%s option used, NOT contacting the portmapper on %s", MNTTAB_OPT_PUBLIC, host); /* * Prefer NFSv3/tcp if the client supports it (cf. RFC 2054, 7). */ if (!nfs_version) { #ifdef HAVE_FS_NFS3 nfs_version = NFS_VERSION3; #else /* not HAVE_FS_NFS3 */ nfs_version = NFS_VERSION; #endif /* not HAVE_FS_NFS3 */ plog(XLOG_INFO, "No NFS version specified, will use NFSv%d", (int) nfs_version); } if (!nfs_proto) { #if defined(MNTTAB_OPT_PROTO) || defined(HAVE_FS_NFS3) nfs_proto = "tcp"; #else /* not defined(MNTTAB_OPT_PROTO) || defined(HAVE_FS_NFS3) */ nfs_proto = "udp"; #endif /* not defined(MNTTAB_OPT_PROTO) || defined(HAVE_FS_NFS3) */ plog(XLOG_INFO, "No NFS protocol transport specified, will use %s", nfs_proto); } } else { /* * Find the best combination of NFS version and protocol. * When given a choice, use the highest available version, * and use TCP over UDP if available. */ if (check_pmap_up(host, ip)) { if (nfs_proto) { best_nfs_version = get_nfs_version(host, ip, nfs_version, nfs_proto); nfs_port = ip->sin_port; } #ifdef MNTTAB_OPT_PROTO else { u_int proto_nfs_version; char **p; for (p = protocols; *p; p++) { proto_nfs_version = get_nfs_version(host, ip, nfs_version, *p); if (proto_nfs_version > best_nfs_version) { best_nfs_version = proto_nfs_version; nfs_proto = *p; nfs_port = ip->sin_port; } } } #endif /* MNTTAB_OPT_PROTO */ } else { plog(XLOG_INFO, "portmapper service not running on %s", host); } /* use the portmapper results only nfs_version is not set yet */ if (!best_nfs_version) { /* * If the NFS server is down or does not support the portmapper call * (such as certain Novell NFS servers) we mark it as version 2 and we * let the nfs code deal with the case when it is down. If/when the * server comes back up and it can support NFSv3 and/or TCP, it will * use those. */ if (nfs_version == 0) { nfs_version = NFS_VERSION; nfs_proto = "udp"; } plog(XLOG_INFO, "NFS service not running on %s", host); fserver_is_down = 1; } else { if (nfs_version == 0) nfs_version = best_nfs_version; plog(XLOG_INFO, "Using NFS version %d, protocol %s on host %s", (int) nfs_version, nfs_proto, host); } } /* * Determine the NFS port. * * A valid "port" mount option overrides anything else. * If the port has been determined from the portmapper, use that. * Default to NFS_PORT otherwise (cf. RFC 2054, 3). */ nfs_port_opt = hasmntval(&mnt, MNTTAB_OPT_PORT); if (nfs_port_opt > 0) nfs_port = htons(nfs_port_opt); if (!nfs_port) nfs_port = htons(NFS_PORT); dlog("find_nfs_srvr: using port %d for nfs on %s", (int) ntohs(nfs_port), host); ip->sin_port = nfs_port; no_dns: /* * Try to find an existing fs server structure for this host. * Note that differing versions or protocols have their own structures. * XXX: Need to fix the ping mechanism to actually use the NFS protocol * chosen here (right now it always uses datagram sockets). */ ITER(fs, fserver, &nfs_srvr_list) { if (STREQ(host, fs->fs_host) && nfs_version == fs->fs_version && STREQ(nfs_proto, fs->fs_proto)) { /* * fill in the IP address -- this is only needed * if there is a chance an IP address will change * between mounts. * Mike Mitchell, mcm@unx.sas.com, 09/08/93 */ if (hp && fs->fs_ip && memcmp((voidp) &fs->fs_ip->sin_addr, (voidp) hp->h_addr, sizeof(fs->fs_ip->sin_addr)) != 0) { struct in_addr ia; char *old_ipaddr, *new_ipaddr; old_ipaddr = strdup(inet_ntoa(fs->fs_ip->sin_addr)); memmove((voidp) &ia, (voidp) hp->h_addr, sizeof(struct in_addr)); new_ipaddr = inet_ntoa(ia); /* ntoa uses static buf */ plog(XLOG_WARNING, "fileserver %s changed ip: %s -> %s", fs->fs_host, old_ipaddr, new_ipaddr); XFREE(old_ipaddr); flush_nfs_fhandle_cache(fs); memmove((voidp) &fs->fs_ip->sin_addr, (voidp) hp->h_addr, sizeof(fs->fs_ip->sin_addr)); } /* * If the new file systems doesn't use WebNFS, the nfs pings may * try to contact the portmapper. */ if (!(mf->mf_flags & MFF_WEBNFS)) fs->fs_flags &= ~FSF_WEBNFS; /* check if pingval needs to be updated/set/reset */ start_nfs_pings(fs, pingval); /* * Following if statement from Mike Mitchell * Initialize the ping data if we aren't pinging now. The np_ttl and * np_ping fields are especially important. */ if (!(fs->fs_flags & FSF_PINGING)) { np = (nfs_private *) fs->fs_private; np->np_mountd_inval = TRUE; np->np_xid = XID_ALLOC(); np->np_error = -1; np->np_ping = 0; /* * Initially the server will be deemed dead * after MAX_ALLOWED_PINGS of the fast variety * have failed. */ np->np_ttl = MAX_ALLOWED_PINGS * FAST_NFS_PING + clocktime(NULL) - 1; start_nfs_pings(fs, pingval); if (fserver_is_down) fs->fs_flags |= FSF_VALID | FSF_DOWN; } fs->fs_refc++; if (ip) XFREE(ip); return fs; } } /* * Get here if we can't find an entry */ /* * Allocate a new server */ fs = ALLOC(struct fserver); fs->fs_refc = 1; fs->fs_host = strdup(hp ? hp->h_name : "unknown_hostname"); if (gopt.flags & CFM_NORMALIZE_HOSTNAMES) host_normalize(&fs->fs_host); fs->fs_ip = ip; fs->fs_cid = 0; if (ip) { fs->fs_flags = FSF_DOWN; /* Starts off down */ } else { fs->fs_flags = FSF_ERROR | FSF_VALID; mf->mf_flags |= MFF_ERROR; mf->mf_error = ENOENT; } if (mf->mf_flags & MFF_WEBNFS) fs->fs_flags |= FSF_WEBNFS; fs->fs_version = nfs_version; fs->fs_proto = nfs_proto; fs->fs_type = MNTTAB_TYPE_NFS; fs->fs_pinger = AM_PINGER; fs->fs_flags |= FSF_PING_UNINIT; /* pinger hasn't been initialized */ np = ALLOC(struct nfs_private); memset((voidp) np, 0, sizeof(*np)); np->np_mountd_inval = TRUE; np->np_xid = XID_ALLOC(); np->np_error = -1; /* * Initially the server will be deemed dead after * MAX_ALLOWED_PINGS of the fast variety have failed. */ np->np_ttl = clocktime(NULL) + MAX_ALLOWED_PINGS * FAST_NFS_PING - 1; fs->fs_private = (voidp) np; fs->fs_prfree = (void (*)(voidp)) free; if (!FSRV_ERROR(fs)) { /* start of keepalive timer, first updating pingval */ start_nfs_pings(fs, pingval); if (fserver_is_down) fs->fs_flags |= FSF_VALID | FSF_DOWN; } /* * Add to list of servers */ ins_que(&fs->fs_q, &nfs_srvr_list); return fs; } am-utils-6.2+rc20110530/amd/sun2amd.8000066400000000000000000000061501157065440000165370ustar00rootroot00000000000000.\" .\" Copyright (c) 1997-2011 Erez Zadok .\" Copyright (c) 2005 Daniel P. Ottavio .\" 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. 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 .\" 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/amd/sun2amd.8 .\" .TH SUN2AMD 8L "14 August 2005" .SH NAME sun2amd \- converts Sun automount maps to Amd maps .SH SYNOPSIS .B sun2amd [-hH] [-i infile] [-o outfile] .SH DESCRIPTION .B sun2amd is used to convert Sun style automount maps to Amd style automount maps. By default .B sun2amd reads from stdin and writes to stdout. .SH OPTIONS .TP .B -h Help .TP .B -i Read Sun map information from specified file. .TP .B -o Write Amd map information to specified file. .SH EXAMPLE To convert a Sun automount file called auto_foo to an Amd file called auto.amd type: .B sun2amd -i auto_foo -o auto.amd .SH BUGS * Can not convert master maps yet. * NFS is the only automount type currently supported. total_bug_count = number_found + 1; .SH "SEE ALSO" .BR automount(8), .BR amd(8) .I "Linux NFS and Automounter Administration" by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). .LP .I http://www.am-utils.org .LP .SH AUTHOR Daniel P. Ottavio .I am-utils-6.2+rc20110530/amd/sun2amd.c000066400000000000000000000127761157065440000166250ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 Erez Zadok * Copyright (c) 2005 Daniel P. Ottavio * 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. * 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. 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 * 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/amd/sun2amd.c * */ /* * Translate Sun-syntax maps to Amd maps */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include /* dummies to make the program compile and link */ struct amu_global_options gopt; #if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) # ifdef NEED_LIBWRAP_SEVERITY_VARIABLES /* * Some systems that define libwrap already define these two variables * in libwrap, while others don't: so I need to know precisely iff * to define these two severity variables. */ int allow_severity=0, deny_severity=0, rfc931_timeout=0; # endif /* NEED_LIBWRAP_SEVERITY_VARIABLES */ #endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) */ /* * Parse the stream sun_in, convert the map information to amd, write * the results to amd_out. */ static int sun2amd_convert(FILE *sun_in, FILE *amd_out) { char line_buff[INFO_MAX_LINE_LEN], *tmp, *key, *entry; int pos, line = 0, retval = 1; /* just to be safe */ memset(line_buff, 0, sizeof(line_buff)); /* Read the input line by line and do the conversion. */ while ((pos = file_read_line(line_buff, sizeof(line_buff), sun_in))) { line++; line_buff[pos - 1] = '\0'; /* remove comments */ if ((tmp = strchr(line_buff, '#')) != NULL) { *tmp = '\0'; } /* find start of key */ key = line_buff; while (*key != '\0' && isspace((unsigned char)*key)) { key++; } /* ignore blank lines */ if (*key == '\0') { continue; } /* find the end of the key and NULL terminate */ tmp = key; while (*tmp != '\0' && isspace((unsigned char)*tmp) == 0) { tmp++; } if (*tmp == '\0') { plog(XLOG_ERROR, "map line %d has no entry", line); goto err; } *tmp++ = '\0'; if (*tmp == '\0') { plog(XLOG_ERROR, "map line %d has no entry", line); goto err; } entry = tmp; /* convert the sun entry to an amd entry */ if ((tmp = sun_entry2amd(key, entry)) == NULL) { plog(XLOG_ERROR, "parse error on line %d", line); goto err; } if (fprintf(amd_out, "%s %s\n", key, tmp) < 0) { plog(XLOG_ERROR, "can't write to output stream: %s", strerror(errno)); goto err; } /* just to be safe */ memset(line_buff, 0, sizeof(line_buff)); } /* success */ retval = 0; err: return retval; } /* * wrapper open function */ static FILE * sun2amd_open(const char *path, const char *mode) { FILE *retval = NULL; if ((retval = fopen(path,mode)) == NULL) { plog(XLOG_ERROR,"could not open file %s",path); } return retval; } /* * echo the usage and exit */ static void sun2amd_usage(void) { fprintf(stderr, "usage : sun2amd [-hH] [-i infile] [-o outfile]\n" "-h\thelp\n" "-i\tspecify an infile (defaults to stdin)\n" "-o\tspecify an outfile (defaults to stdout)\n"); } int main(int argc, char **argv) { /* default in/out to stdin/stdout */ FILE *sun_in = stdin, *amd_out = stdout; int opt, retval = 1; while ((opt = getopt(argc, argv , "i:o:hH")) != -1) { switch (opt) { case 'i': if ((sun_in = sun2amd_open(optarg,"r")) == NULL) { goto err; } break; case 'o': if ((amd_out = sun2amd_open(optarg,"w")) == NULL) { goto err; } break; case 'h': case 'H': sun2amd_usage(); goto err; } } retval = sun2amd_convert(sun_in,amd_out); err: exit(retval); } am-utils-6.2+rc20110530/amd/sun_map.c000066400000000000000000000422271157065440000167100ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 Erez Zadok * Copyright (c) 2005 Daniel P. Ottavio * 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. 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 * 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/amd/sun_map.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include /* * Add a data pointer to the end of the list. */ void sun_list_add(struct sun_list *list, qelem *item) { if (list->last == NULL) { list->last = item; list->first = item; item->q_back = NULL; } else { list->last->q_forw = item; item->q_back = list->last; list->last = item; } item->q_forw = NULL; } /* * Sun2Amd conversion routines */ /* * AMD entry keywords */ #define AMD_OPTS_KW "addopts:=" /* add entry options */ #define AMD_RHOST_KW "rhost:=" /* remote host */ #define AMD_RFS_KW "rfs:=" /* remote file system */ #define AMD_FS_KW "fs:=" /* local file system */ #define AMD_DEV_KW "dev:=" /* device */ #define AMD_TYPE_NFS_KW "type:=nfs;" /* fs type nfs */ #define AMD_TYPE_AUTO_KW "type:=auto;" /* fs type auto */ #define AMD_TYPE_CDFS_KW "type:=cdfs;" /* fs type cd */ #define AMD_MAP_FS_KW "fs:=${map};" /* set the mount map as current map */ #define AMD_MAP_PREF_KW "pref:=${key}/" /* set the mount map as current map */ /* * A set of string Sun fstypes. */ #define SUN_NFS_TYPE "nfs" #define SUN_HSFS_TYPE "hsfs" /* CD fs */ #define SUN_AUTOFS_TYPE "autofs" #define SUN_CACHEFS_TYPE "cachefs" #define SUN_KEY_SUB "&" /* Sun key substitution */ /* a set a Sun variable substitutions for map entries */ #define SUN_ARCH "$ARCH" /* host architecture */ #define SUN_CPU "$CPU" /* processor type */ #define SUN_HOST "$HOST" /* host name */ #define SUN_OSNAME "$OSNAME" /* OS name */ #define SUN_OSREL "$OSREL" /* OS release */ #define SUN_OSVERS "$OSVERS" /* OS version */ #define SUN_NATISA "$NATISA" /* native instruction set */ /* a set of Amd variable substitutions */ #define AMD_ARCH "${arch}" /* host architecture */ #define AMD_HOST "${host}" /* host name */ #define AMD_OSNAME "${os}" /* OS name */ #define AMD_OSVER "${osver}" /* OS version */ /* * Return a copy of src that has all occurrences of 'str' replaced * with sub. * * param src - the original string * param str - string that is the replaced with str * param sub - string that replaces an occurrences of 'delim' * * return - new string with str substitutions, NULL on error */ static char * sun_strsub(const char *src, const char *str, const char *sub) { char *retval = NULL, *str_start, *str_end, *src_end; size_t total_size, first_half, second_half, sub_size; /* assign pointers to the start and end of str */ if ((str_start = strstr(src, str)) == NULL) { return retval; } str_end = (strlen(str) - 1) + str_start; /* assign to the end of the src. */ src_end = (strlen(src) - 1) + (char*)src; /* size from the beginning of src to the start of str */ first_half = (size_t)(str_start - src); /* size from the end of str to the end of src */ second_half = (size_t)(src_end - str_end); sub_size = strlen(sub); total_size = (first_half + sub_size + second_half + 1); retval = (char*)xmalloc(total_size); memset(retval, 0, total_size); /* * Put together the string such that the first half is copied * followed the sub and second half. * * We use strncpy instead of xstrlcpy because we are intentionally * causing truncation and we don't want this to cause errors in the * log. */ (void)strncpy(retval, src, first_half); (void)strncat(retval, sub, sub_size); (void)strncat(retval, str_end + 1, second_half); if ((str_start = strstr(retval, str)) != NULL) { /* * If there is another occurrences of str call this function * recursively. */ char* tmp; if ((tmp = sun_strsub(retval, str, sub)) != NULL) { XFREE(retval); retval = tmp; } } return retval; } /* * Return a new string that is a copy of str, all occurrences of a Sun * variable substitutions are replaced by there equivalent Amd * substitutions. * * param str - source string * * return - A new string with the expansions, NULL if str does not * exist in src or error. */ static char * sun_expand2amd(const char *str) { char *retval = NULL, *tmp = NULL, *tmp2 = NULL; const char *pos; /* * Iterator through the string looking for '$' chars. For each '$' * found try to replace it with Sun variable substitutions. If we * find a '$' that is not a substation each of the i.e $blah than * each of the replace attempt will fail and we'll move on to the * next char. */ tmp = strdup(str); for (pos = str; *pos != '\0'; pos++) { if (*pos != '$') { continue; } if (tmp2 != NULL) { XFREE(tmp); tmp = tmp2; } /* * If a 'replace' does not return NULL than a variable was * successfully substituted. */ /* architecture */ if ((tmp2 = sun_strsub(tmp, SUN_ARCH, AMD_ARCH)) != NULL) { continue; } /* cpu - there is not POSIX uname for cpu so just use machine */ if ((tmp2 = sun_strsub(tmp, SUN_CPU, AMD_ARCH)) != NULL) { continue; } /* hostname */ if ((tmp2 = sun_strsub(tmp, SUN_HOST, AMD_HOST)) != NULL) { continue; } /* os name */ if ((tmp2 = sun_strsub(tmp, SUN_OSNAME, AMD_OSNAME)) != NULL) { continue; } /* * os release - Amd doesn't hava a OS release var just usr os * version or now. */ if ((tmp2 = sun_strsub(tmp, SUN_OSREL, AMD_OSVER)) != NULL) { continue; } /* os version */ if ((tmp2 = sun_strsub(tmp, SUN_OSVERS, AMD_OSVER)) != NULL) { continue; } /* native instruction set - there is no POSIX natisa so just use system */ if ((tmp2 = sun_strsub(tmp, SUN_NATISA, AMD_ARCH)) != NULL) { continue; } } if (tmp2 == NULL) { retval = tmp; } else { retval = tmp2; if (tmp != NULL) { XFREE(tmp); } } return retval; } /* * This is a wrapper function for appending Amd entry information to a * buffer. Any Sun variable substitutions will be converted into Amd * equivalents. * * param dest - destination buffer * param deslen - destination buffer length * param key - entry key, this might be needed for key substitutions * param str - string to append */ static void sun_append_str(char *dest, size_t destlen, const char *key, const char *str) { char *sub = NULL, *sub2 = NULL, *out = NULL; /* By default we are going to just write the original string. */ out = (char*)str; /* * Resolve variable substitutions in two steps; 1) replace any key * map substitutions with the entry key 2) expand any variable * substitutions i.e $HOST. * * Try to replace the key substitution '&'. If this function returns * with a new string, one or more key subs. where replaced with the * entry key. */ if ((sub = sun_strsub(str, SUN_KEY_SUB, "${key}")) != NULL) { out = sub; /* * Try to convert any variable substitutions. If this function * returns a new string one or more var subs where expanded. */ if ((sub2 = sun_expand2amd(sub)) != NULL) { out = sub2; } } /* * Try to convert any variable substitutions. If this function * returns a new string one or more var subs where expanded. */ else if ((sub = sun_expand2amd(out)) != NULL) { out = sub; } if (out != NULL) { xstrlcat(dest, out, destlen); } if (sub != NULL) { XFREE(sub); } if (sub2 != NULL) { XFREE(sub2); } } /* * Convert the list of Sun mount options to Amd mount options. The * result is concatenated to dest. * * param dest - destination buffer * param destlen - destination buffer length * param key - automount key * param opt_list - list of Sun mount options */ static void sun_opts2amd(char *dest, size_t destlen, const char *key, const struct sun_opt *opt_list) { const struct sun_opt *opt; xstrlcat(dest, AMD_OPTS_KW, destlen); /* Iterate through each option and append it to the buffer. */ for(opt = opt_list; opt != NULL; opt = NEXT(struct sun_opt, opt)) { sun_append_str(dest, destlen, key, opt->str); /* If there are more options add some commas. */ if (NEXT(struct sun_opt, opt) != NULL) { xstrlcat(dest, ",", destlen); } } xstrlcat(dest, ";", destlen); } /* * Convert the list of Sun mount locations to a list of Amd mount * locations. The result is concatenated to dest. * * param dest - destination buffer * param destlen - destination buffer length * param key - automount key * param local_list - list of Sun mount locations */ static void sun_locations2amd(char *dest, size_t destlen, const char *key, const struct sun_location *local_list) { const struct sun_location *local; const struct sun_host *host; for (local = local_list; local != NULL; local = NEXT(struct sun_location,local)) { /* * Check to see if the list of hosts is empty. Some mount types * i.e cd-rom may have mount location with no host. */ if (local->host_list != NULL) { /* Write each host that belongs to this location. */ for (host = local->host_list; host != NULL; host = NEXT(struct sun_host, host)) { /* set fstype NFS */ xstrlcat(dest, AMD_TYPE_NFS_KW, destlen); /* add rhost key word */ xstrlcat(dest, AMD_RHOST_KW, destlen); /* add host name */ sun_append_str(dest, destlen, key, host->name); xstrlcat(dest, ";", destlen); /* add remote fs key word */ xstrlcat(dest, AMD_RFS_KW, destlen); /* add local path */ sun_append_str(dest, destlen, key, local->path); if (NEXT(struct sun_host, host) != NULL) { xstrlcat(dest, ";", destlen); xstrlcat(dest, " ", destlen); } } } else { /* no host location */ xstrlcat(dest, AMD_FS_KW, destlen); sun_append_str(dest, destlen, key, local->path); } if (NEXT(struct sun_location, local) != NULL) { /* add a space to separate each location */ xstrlcat(dest, " ", destlen); } } } /* * Convert a Sun HSFS mount point to an Amd. The result is * concatenated intp dest. * * param dest - destination buffer * param destlen - destination buffer length * param key - automount key * param s_entry - Sun entry */ static void sun_hsfs2amd(char *dest, size_t destlen, const char *key, const struct sun_entry *s_entry) { /* set fstype CDFS */ xstrlcat(dest, AMD_TYPE_CDFS_KW, destlen); /* set the cdrom device */ xstrlcat(dest, AMD_DEV_KW, destlen); /* XXX: For now just assume that there is only one device. */ xstrlcat(dest, s_entry->location_list->path, destlen); } /* * Convert a Sun NFS automount entry to an Amd. The result is concatenated * into dest. * * param dest - destination buffer * param destlen - destination buffer length * param key - automount key * param s_entry - Sun entry */ static void sun_nfs2amd(char *dest, size_t destlen, const char *key, const struct sun_entry *s_entry) { if (s_entry->location_list != NULL) { /* write out the list of mountpoint locations */ sun_locations2amd(dest, destlen, key, s_entry->location_list); } } /* * Convert a Sun multi-mount point entry to an Amd. This is done * using the Amd type auto. Each auto entry is separated with a \n. * * param dest - destination buffer * param destlen - destination buffer length * param key - automount key * param s_entry - Sun entry */ static void sun_multi2amd(char *dest, size_t destlen, const char *key, const struct sun_entry *s_entry) { const struct sun_mountpt *mountpt; /* We need to setup a auto fs Amd automount point. */ xstrlcat(dest, AMD_TYPE_AUTO_KW, destlen); xstrlcat(dest, AMD_MAP_FS_KW, destlen); xstrlcat(dest, AMD_MAP_PREF_KW, destlen); /* write the mountpts to dest */ for (mountpt = s_entry->mountpt_list; mountpt != NULL; mountpt = NEXT(struct sun_mountpt, mountpt)) { xstrlcat(dest, "\n", destlen); /* write the key */ xstrlcat(dest, key, destlen); /* write the mount path */ sun_append_str(dest, destlen, key, mountpt->path); /* space */ xstrlcat(dest, " ", destlen); /* Write all the host locations for this mount point. */ sun_locations2amd(dest, destlen, key, mountpt->location_list); } } /* * Convert the sun_entry into an Amd equivalent string. * * param key - automount key * param s_entry - Sun style automap entry * * return - Amd entry on succes, NULL on error */ char * sun_entry2amd(const char *key, const char *s_entry_str) { char *retval = NULL; char line_buff[INFO_MAX_LINE_LEN]; int ws; struct sun_entry *s_entry = NULL; /* The key should not be NULL. */ if (key == NULL) { plog(XLOG_ERROR,"Sun key value was null"); goto err; } /* The Sun entry string should never be NULL. */ if (s_entry_str == NULL) { plog(XLOG_ERROR,"Sun entry value was null"); goto err; } /* Make sure there are no trailing white spaces or '\n'. */ xstrlcpy(line_buff, s_entry_str, sizeof(line_buff)); ws = strlen(line_buff) - 1; while (ws >= 0 && (isspace((unsigned char)line_buff[ws]) || line_buff[ws] == '\n')) { line_buff[ws--] = '\0'; } /* Parse the sun entry line. */ s_entry = sun_map_parse_read(line_buff); if (s_entry == NULL) { plog(XLOG_ERROR,"could not parse Sun style map"); goto err; } memset(line_buff, 0, sizeof(line_buff)); if (s_entry->opt_list != NULL) { /* write the mount options to the buffer */ sun_opts2amd(line_buff, sizeof(line_buff), key, s_entry->opt_list); } /* Check if this is a multi-mount entry. */ if (s_entry->mountpt_list != NULL) { /* multi-mount point */ sun_multi2amd(line_buff, sizeof(line_buff), key, s_entry); retval = strdup(line_buff); } else { /* single mount point */ if (s_entry->fstype != NULL) { if (NSTREQ(s_entry->fstype, SUN_NFS_TYPE, strlen(SUN_NFS_TYPE))) { /* NFS Type */ sun_nfs2amd(line_buff, sizeof(line_buff), key, s_entry); retval = strdup(line_buff); } else if (NSTREQ(s_entry->fstype, SUN_HSFS_TYPE, strlen(SUN_HSFS_TYPE))) { /* HSFS Type (CD fs) */ sun_hsfs2amd(line_buff, sizeof(line_buff), key, s_entry); retval = strdup(line_buff); } /* * XXX: The following fstypes are not yet supported. */ else if (NSTREQ(s_entry->fstype, SUN_AUTOFS_TYPE, strlen(SUN_AUTOFS_TYPE))) { /* AutoFS Type */ plog(XLOG_ERROR, "Sun fstype %s is currently not supported by Amd.", s_entry->fstype); goto err; } else if (NSTREQ(s_entry->fstype, SUN_CACHEFS_TYPE, strlen(SUN_CACHEFS_TYPE))) { /* CacheFS Type */ plog(XLOG_ERROR, "Sun fstype %s is currently not supported by Amd.", s_entry->fstype); goto err; } else { plog(XLOG_ERROR, "Sun fstype %s is currently not supported by Amd.", s_entry->fstype); goto err; } } else { plog(XLOG_INFO, "No SUN fstype specified defaulting to NFS."); sun_nfs2amd(line_buff, sizeof(line_buff), key, s_entry); retval = strdup(line_buff); } } err: if (s_entry != NULL) { XFREE(s_entry); } return retval; } am-utils-6.2+rc20110530/amd/sun_map.h000066400000000000000000000111711157065440000167070ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 Erez Zadok * Copyright (c) 2005 Daniel P. Ottavio * 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. 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 * 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/amd/sun_map.h * */ #ifndef _SUN_MAP_H #define _SUN_MAP_H /* host */ struct sun_host { qelem head; /* link-list header */ char *name; /* hostname */ int weight; /* weight given to the host */ }; /* location */ struct sun_location { qelem head; /* link-list header */ char *path; /* server path */ struct sun_host *host_list; /* list of hosts */ }; /* sun mount option */ struct sun_opt { qelem head; /* link-list header */ char *str; /* option string */ }; /* mount point */ struct sun_mountpt { qelem head; /* link-list header */ char *path; /* optional mount point path */ char *fstype; /* filesystem type */ struct sun_opt *opt_list; /* list of option strings */ struct sun_location *location_list; /* list of 'struct s2a_location' */ }; /* automount entry */ struct sun_entry { qelem head; /* link-list header */ char *key; /* auto map key */ char *fstype; /* filesystem type */ struct sun_opt *opt_list; /* list of mount options */ struct sun_location *location_list; /* list of mount locations */ struct sun_mountpt *mountpt_list; /* list of mount points */ }; /* * automount map file * * XXX: Only a place holder structure, not implemented yet. */ struct sun_map { qelem head; /* link-list header */ char *path; /* directory path of the map file */ char *mount_dir; /* top level mount point for this map */ int lookup; /* lookup type i.e file, yp, program, etc. */ int direct_bool; /* set true if this map is a direct map */ struct sun_opt *opt_list; /* list of global map options */ struct sun_opt *include_list; /* list of included map files */ struct sun_entry *entry_list; /* list of 'struct s2a_entry' */ }; /* * master map file * * XXX: Only a place holder structure, not implemented yet. */ struct sun_mmap { qelem head; /* link-list header */ struct sun_opt *include_list; /* list of included master maps */ struct sun_map *amap_list; /* list of 'struct s2a_amap' */ }; struct sun_list { qelem *first; qelem *last; }; /* * EXTERNS */ extern char *sun_entry2amd(const char *, const char *); extern struct sun_entry *sun_map_parse_read(const char *); extern void sun_list_add(struct sun_list *, qelem *); #endif /* not _SUN_MAP_H */ am-utils-6.2+rc20110530/amd/sun_map_parse.y000066400000000000000000000306041157065440000201240ustar00rootroot00000000000000%{ /* * Copyright (c) 1997-2011 Erez Zadok * Copyright (c) 2005 Daniel P. Ottavio * 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. 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 * 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/amd/sun_map_parse.y * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include #define SUN_FSTYPE_STR "fstype=" extern int sun_map_lex(void); extern int sun_map_error(const char *); extern void sun_map_tok_setbuff(const char *); extern int sun_map_parse(void); struct sun_entry *sun_map_parse_read(const char *); static struct sun_list *sun_entry_list = NULL; static struct sun_list *sun_opt_list = NULL; static struct sun_list *sun_host_list = NULL; static struct sun_list *sun_location_list = NULL; static struct sun_list *mountpt_list = NULL; static char *tmpFsType = NULL; /* * Each get* function returns a pointer to the corresponding global * list structure. If the structure is NULL than a new instance is * returned. */ static struct sun_list *get_sun_opt_list(void); static struct sun_list *get_sun_host_list(void); static struct sun_list *get_sun_location_list(void); static struct sun_list *get_mountpt_list(void); static struct sun_list *get_sun_entry_list(void); %} %union { char strval[2048]; } %token NEWLINE COMMENT WSPACE %token WORD %% amap : file ; file : new_lines entries | entries ; entries : entry | entry new_lines | entry new_lines entries ; new_lines : NEWLINE | NEWLINE new_lines ; entry : locations { struct sun_list *list; struct sun_entry *entry; /* allocate an entry */ entry = CALLOC(struct sun_entry); /* * Assign the global location list to this entry and reset the * global pointer. Reseting the global pointer will create a new * list instance next time get_sun_location_list() is called. */ list = get_sun_location_list(); entry->location_list = (struct sun_location *)list->first; sun_location_list = NULL; /* Add this entry to the entry list. */ sun_list_add(get_sun_entry_list(), (qelem *)entry); } | '-' options WSPACE locations { struct sun_list *list; struct sun_entry *entry; entry = CALLOC(struct sun_entry); /* An fstype may have been defined in the 'options'. */ if (tmpFsType != NULL) { entry->fstype = tmpFsType; tmpFsType = NULL; } /* * Assign the global location list to this entry and reset the * global pointer. Reseting the global pointer will create a new * list instance next time get_sun_location_list() is called. */ list = get_sun_location_list(); entry->location_list = (struct sun_location *)list->first; sun_location_list = NULL; /* * Assign the global opt list to this entry and reset the global * pointer. Reseting the global pointer will create a new list * instance next time get_sun_opt_list() is called. */ list = get_sun_opt_list(); entry->opt_list = (struct sun_opt *)list->first; sun_opt_list = NULL; /* Add this entry to the entry list. */ sun_list_add(get_sun_entry_list(), (qelem *)entry); } | mountpoints { struct sun_list *list; struct sun_entry *entry; /* allocate an entry */ entry = CALLOC(struct sun_entry); /* * Assign the global mountpt list to this entry and reset the global * pointer. Reseting the global pointer will create a new list * instance next time get_mountpt_list() is called. */ list = get_mountpt_list(); entry->mountpt_list = (struct sun_mountpt *)list->first; mountpt_list = NULL; /* Add this entry to the entry list. */ sun_list_add(get_sun_entry_list(), (qelem *)entry); } | '-' options WSPACE mountpoints { struct sun_list *list; struct sun_entry *entry; /* allocate an entry */ entry = CALLOC(struct sun_entry); /* An fstype may have been defined in the 'options'. */ if (tmpFsType != NULL) { entry->fstype = tmpFsType; tmpFsType = NULL; } /* * Assign the global mountpt list to this entry and reset the global * pointer. Reseting the global pointer will create a new list * instance next time get_mountpt_list() is called. */ list = get_mountpt_list(); entry->mountpt_list = (struct sun_mountpt *)list->first; mountpt_list = NULL; /* * Assign the global opt list to this entry and reset the global * pointer. Reseting the global pointer will create a new list * instance next time get_sun_opt_list() is called. */ list = get_sun_opt_list(); entry->opt_list = (struct sun_opt *)list->first; sun_opt_list = NULL; /* Add this entry to the entry list. */ sun_list_add(get_sun_entry_list(), (qelem *)entry); } ; mountpoints : mountpoint | mountpoint WSPACE mountpoints ; mountpoint : WORD WSPACE location { struct sun_list *list; struct sun_mountpt *mountpt; /* allocate a mountpt */ mountpt = CALLOC(struct sun_mountpt); /* * Assign the global loaction list to this entry and reset the * global pointer. Reseting the global pointer will create a new * list instance next time get_sun_location_list() is called. */ list = get_sun_location_list(); mountpt->location_list = (struct sun_location *)list->first; sun_location_list = NULL; mountpt->path = strdup($1); /* Add this mountpt to the mountpt list. */ sun_list_add(get_mountpt_list(), (qelem *)mountpt); } | WORD WSPACE '-' options WSPACE location { struct sun_list *list; struct sun_mountpt *mountpt; /* allocate a mountpt */ mountpt = CALLOC(struct sun_mountpt); /* An fstype may have been defined in the 'options'. */ if (tmpFsType != NULL) { mountpt->fstype = tmpFsType; tmpFsType = NULL; } /* * Assign the global location list to this entry and reset the * global pointer. Reseting the global pointer will create a new * list instance next time get_sun_location_list() is called. */ list = get_sun_location_list(); mountpt->location_list = (struct sun_location *)list->first; sun_location_list = NULL; /* * Assign the global opt list to this entry and reset the global * pointer. Reseting the global pointer will create a new list * instance next time get_sun_opt_list() is called. */ list = get_sun_opt_list(); mountpt->opt_list = (struct sun_opt *)list->first; sun_opt_list = NULL; mountpt->path = strdup($1); /* Add this mountpt to the mountpt list. */ sun_list_add(get_mountpt_list(), (qelem *)mountpt); } ; locations : location | location WSPACE locations ; location : hosts ':' WORD { struct sun_list *list; struct sun_location *location; /* allocate a new location */ location = CALLOC(struct sun_location); /* * Assign the global opt list to this entry and reset the global * pointer. Reseting the global pointer will create a new list * instance next time get_sun_opt_list() is called. */ list = get_sun_host_list(); location->host_list = (struct sun_host *)list->first; sun_host_list = NULL; location->path = strdup($3); /* Add this location to the location list. */ sun_list_add(get_sun_location_list(), (qelem *)location); } | ':' WORD { struct sun_location *location; /* allocate a new location */ location = CALLOC(struct sun_location); location->path = strdup($2); /* Add this location to the location list. */ sun_list_add(get_sun_location_list(), (qelem *)location); } ; hosts : host | host ',' hosts ; host : WORD { /* allocate a new host */ struct sun_host *host = CALLOC(struct sun_host); host->name = strdup($1); /* Add this host to the host list. */ sun_list_add(get_sun_host_list(),(qelem *)host); } | WORD weight { /* * It is assumed that the host for this rule was allocated by the * 'weight' rule and assigned to be the last host item on the host * list. */ struct sun_host *host = (struct sun_host *)sun_host_list->last; host->name = strdup($1); } ; weight : '(' WORD ')' { int val; /* allocate a new host */ struct sun_host *host = CALLOC(struct sun_host); val = atoi($2); host->weight = val; /* Add this host to the host list. */ sun_list_add(get_sun_host_list(), (qelem *)host); } ; options : option | option ',' options ; option : WORD { char *type; /* check if this is an fstype option */ if ((type = strstr($1,SUN_FSTYPE_STR)) != NULL) { /* parse out the fs type from the Sun fstype keyword */ if ((type = type + strlen(SUN_FSTYPE_STR)) != NULL) { /* * This global fstype str will be assigned to the current being * parsed later in the parsing. */ tmpFsType = strdup(type); } } else { /* * If it is not an fstype option allocate an opt struct and assign * the value. */ struct sun_opt *opt = CALLOC(struct sun_opt); opt->str = strdup($1); /* Add this opt to the opt list. */ sun_list_add(get_sun_opt_list(), (qelem *)opt); } } ; %% /* * Parse 'map_data' which is assumed to be a Sun-syle map. If * successful a sun_entry is returned. * * The parser is designed to parse map entries with out the keys. For * example the entry: * * usr -ro pluto:/usr/local * * should be passed to the parser as: * * -ro pluto:/usr/local * * The reason for this is that the Amd info services already strip off * the key when they read map info. */ struct sun_entry * sun_map_parse_read(const char *map_data) { struct sun_entry *retval = NULL; /* pass map_data to lex */ sun_map_tok_setbuff(map_data); /* call yacc */ sun_map_parse(); if (sun_entry_list != NULL) { /* return the first Sun entry in the list */ retval = (struct sun_entry*)sun_entry_list->first; sun_entry_list = NULL; } else { plog(XLOG_ERROR, "Sun map parser did not produce data structs."); } return retval; } static struct sun_list * get_sun_entry_list(void) { if (sun_entry_list == NULL) { sun_entry_list = CALLOC(struct sun_list); } return sun_entry_list; } static struct sun_list * get_mountpt_list(void) { if (mountpt_list == NULL) { mountpt_list = CALLOC(struct sun_list); } return mountpt_list; } static struct sun_list * get_sun_location_list(void) { if (sun_location_list == NULL) { sun_location_list = CALLOC(struct sun_list); } return sun_location_list; } static struct sun_list * get_sun_host_list(void) { if (sun_host_list == NULL) { sun_host_list = CALLOC(struct sun_list); } return sun_host_list; } static struct sun_list * get_sun_opt_list(void) { if (sun_opt_list == NULL) { sun_opt_list = CALLOC(struct sun_list); } return sun_opt_list; } am-utils-6.2+rc20110530/amd/sun_map_tok.l000066400000000000000000000150631157065440000175740ustar00rootroot00000000000000%{ /* * Copyright (c) 1997-2011 Erez Zadok * Copyright (c) 2005 Daniel P. Ottavio * 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. 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 * 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/amd/sun_map_tok.l * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ /* * Some systems include a definition for the macro ECHO in , * and their (bad) version of lex defines it too at the very beginning of * the generated lex.yy.c file (before it can be easily undefined), * resulting in a conflict. So undefine it here before needed. * Luckily, it does not appear that this macro is actually used in the rest * of the generated lex.yy.c file. */ #ifdef ECHO # undef ECHO #endif /* ECHO */ #include #include #include /* and once again undefine this, just in case */ #ifdef ECHO # undef ECHO #endif /* ECHO */ /* * There are some things that need to be defined only if using GNU flex. * These must not be defined if using standard lex */ #ifdef FLEX_SCANNER # ifndef ECHO # define ECHO __IGNORE(fwrite( yytext, yyleng, 1, yyout )) # endif /* not ECHO */ #endif /* FLEX_SCANNER */ int yylex(void); int yyerror(const char *); /* * We need to configure lex to parse from a string * instead of a file. Each version of lex has it's * own way of doing this (sigh). */ /* assign the buffer to parse */ void sun_map_tok_setbuff(const char* buff); /* buffer that contains the string to parse */ const char *sun_map_tok_buff = NULL; #ifdef FLEX_SCANNER /* * The flex scanner uses the YY_INPUT to parse the input. * We need to redefine it so that it can parse strings. * In addition to the above string buffer we need to have * a position pointer and a end pointer. */ /* current position of the buffer */ const char *sun_map_tok_pos = NULL; /* size of the buffer */ const char *sun_map_tok_end = NULL; /* copies the current position + maxsize into buff */ int sun_map_input(char *buff, int maxsize); # undef YY_INPUT # define YY_INPUT(buff,result,maxsize) (result = sun_map_input(buff,maxsize)) #else /* * If this is not Flex than fall back to an AT&T style lex. * We can parse strings by redefining input and unput. */ #undef input #undef unput #define input() (*(char *)sun_map_tok_buff++) #define unput(c) (*(char *)--sun_map_tok_buff = c) #endif /* FLEX_SCANNER */ /* * some systems such as DU-4.x have a different GNU flex in /usr/bin * which automatically generates yywrap macros and symbols. So I must * distinguish between them and when yywrap is actually needed. */ #if !defined(yywrap) || defined(yylex) int yywrap(void); #endif /* not yywrap or yylex */ /* no need to use yywrap() */ #define YY_SKIP_YYWRAP /* no need for input() */ #define YY_NO_INPUT int sun_map_line = 1; int sun_map_tokpos = 1; %} /* This option causes Solaris lex to fail. Use flex. See BUGS file */ /* no need to use yyunput() */ %option nounput /* allocate more output slots so lex scanners don't run out of mem */ %o 1024 WORD_REX [A-Za-z0-9_/&\.$=]+[A-Za-z0-9_/&\.$=-]* COMMENT_REX ^#.*\n WSPACE_REX [ \t]* NEWLINE_REX [ \t]*\n CONTINUE_REX "\\"\n %% {WORD_REX} { sun_map_tokpos += yyleng; xstrlcpy((char *)yylval.strval,(const char *)yytext,sizeof(yylval.strval)); return WORD; } {WSPACE_REX} { sun_map_tokpos += yyleng; return WSPACE; } {NEWLINE_REX} { sun_map_tokpos = 0; sun_map_line++; return NEWLINE; } {CONTINUE_REX} { sun_map_tokpos = 0; sun_map_line++; } {COMMENT_REX} { sun_map_line++; } . { return yytext[0]; } %% int yyerror(const char* s) { return 1; } #ifdef FLEX_SCANNER void sun_map_tok_setbuff(const char* buff) { sun_map_tok_end = buff + strlen(buff); sun_map_tok_pos = buff; sun_map_tok_buff = buff; } int sun_map_input(char *buff, int maxsize) { int size = MIN(maxsize, (sun_map_tok_end - sun_map_tok_pos)); if (size > 0) { memcpy(buff,sun_map_tok_pos,size); sun_map_tok_pos += size; } return size; } #else void sun_map_tok_setbuff(const char* buff) { sun_map_tok_buff = buff; } #endif /* FLEX_SCANNER */ /* * some systems such as DU-4.x have a different GNU flex in /usr/bin * which automatically generates yywrap macros and symbols. So I must * distinguish between them and when yywrap is actually needed. */ #if !defined(yywrap) || defined(yylex) int yywrap(void) { return 1; } #endif /* not yywrap or yylex */ am-utils-6.2+rc20110530/amd/test1.sh000077500000000000000000000000401157065440000164640ustar00rootroot00000000000000#!/bin/sh ./amd -v 2> /dev/null am-utils-6.2+rc20110530/amq/000077500000000000000000000000001157065440000151105ustar00rootroot00000000000000am-utils-6.2+rc20110530/amq/.cvsignore000066400000000000000000000000141157065440000171030ustar00rootroot00000000000000Makefile.in am-utils-6.2+rc20110530/amq/Makefile.am000066400000000000000000000017301157065440000171450ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in # Package: am-utils # Level: Makefile for amq/ directory # Author: Erez Zadok sbin_PROGRAMS = amq bin_PROGRAMS = pawd # man pages man_MANS = amq.8 pawd.1 # headers this depends on, not to be installed noinst_HEADERS = amq.h amq_SOURCES = amq.c amq_clnt.c amq_xdr.c pawd_SOURCES = amq_clnt.c amq_xdr.c pawd.c LDADD = ../libamu/libamu.la INCLUDES = -I$(top_srcdir)/include # allow users to add their own flags via "configure --enable-am-flags=ARG" AMU_CFLAGS = @AMU_CFLAGS@ AM_CFLAGS = @CFLAGS@ $(AMU_CFLAGS) # additional files to distribute and clean EXTRA_DIST = $(man_MANS) # dependencies $(PROGRAMS): $(LDADD) $(amq_OBJECTS) $(pawd_OBJECTS): \ ../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) am-utils-6.2+rc20110530/amq/amq.8000066400000000000000000000163071157065440000157660ustar00rootroot00000000000000.\" .\" Copyright (c) 1997-2011 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. 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 .\" 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/amq/amq.8 .\" .TH AMQ 8 "25 April 1989" .SH NAME amq \- automounter query tool .SH SYNOPSIS .B amq [ .BI \-fmpqsvwHTU ] [ .BI \-h " hostname" ] [ .BI \-l " log_file" ] [ .BI \-x " log_options" ] [ .BI \-D " debug_options" ] [ .BI \-P " program_number" ] [[ .B \-u ] .I directory .\|.\|. ] .SH DESCRIPTION .B Amq provides a simple way of determining the current state of .B amd program. Communication is by .SM RPC. Three modes of operation are supported by the current protocol. By default a list of mount points and auto-mounted filesystems is output. An alternative host can be specified using the .I \-h option. .LP If .I directory names are given, as output by default, then per-filesystem information is displayed. .SH OPTIONS .TP .B \-f Ask the automounter to flush the internal caches and reload all the maps. .TP .BI \-h " hostname" Specify an alternate host to query. By default the local host is used. In an .SM HP-UX cluster, the root server is queried by default, since that is the system on which the automounter is normally run. .TP .BI \-l " log_file" Tell amd to use .I log_file as the log file name. For security reasons, this must be the same log file which amd used when started. This option is therefore only useful to refresh amd's open file handle on the log file, so that it can be rotated and compressed via daily cron jobs. .TP .B \-m Ask the automounter to provide a list of mounted filesystems, including the number of references to each filesystem and any error which occurred while mounting. .TP .B \-p Return the process ID of the remote or locally running amd. Useful when you need to send a signal to the local amd process, and would rather not have to search through the process table. This option is used in the .I ctl-amd script. .TP .B \-q Suppress error messages produced when attempting synchronous unmounts with the .B \-u option. .TP .B \-s Ask the automounter to provide system-wide mount statistics. .TP .B \-u Ask the automounter to unmount the filesystems named in .I directory instead of providing information about them. Unmounts are requested, not forced. They merely cause the mounted filesystem to timeout, which will be picked up by .BR amd 's main scheduler thus causing the normal timeout action to be taken. If the .B \-u option is repeated, .B amq will attempt to unmount the file system synchronously by waiting until the timeout action is taken and returning an error if the unmount fails. Any error messages produced may be suppressed with the .B \-q option. .TP .B \-v Ask the automounter for its version information. This is a subset of the information output by .BR amd 's .I -v option. .TP .B \-w Translate a full pathname as returned by .IR getcwd (3) into a short .B Amd pathname that goes through its mount points. This option requires that .B Amd is running. .TP .BI \-x " log_options" Ask the automounter to use the logging options specified in .I log_options from now on. Note that the "fatal" and "error" options cannot be turned off. .TP .BI \-D " debug_options" Ask the automounter to use the debugging options specified in .I debug_options from now on. .TP .B \-H Display short usage message. .TP .BI \-P " program_number" Contact an alternate running amd that had registered itself on a different RPC .I program_number and apply all other operations to that instance of the automounter. This is useful when you run multiple copies of amd, and need to manage each one separately. If not specified, amq will use the default program number for amd, 300019. For security reasons, the only alternate program numbers amd can use range from 300019 to 300029, inclusive. .TP .B \-T Contact .B amd using the TCP transport only. Normally .B amq will try TCP, and if that failed, will try UDP. .TP .B \-U Contact .B amd using UDP (connectionless) transport only. Normally .B amq will try TCP, and if that failed, will try UDP. .SH FILES .TP 20 .B amq.x .SM RPC protocol description. .SH CAVEATS .B Amq uses a Sun registered .SM RPC program number (300019 decimal) which may not be in the /etc/rpc database. .PP If the TCP wrappers library is available, and the .B use_tcpwrappers global .B amd.conf option is set to ``yes'', then .B amd will verify that the host running .B amq is authorized to connect. The .I amd service name must used in the .B /etc/hosts.allow and .B /etc/hosts.deny files. For example, to allow only localhost to connect to .B amd, add this line to .B /etc/hosts.allow: .PP .RS amd: localhost .RE .PP and this line to .B /etc/hosts.deny: .PP .RS amd: ALL .RE .SH "SEE ALSO" .BR amd (8), .\" .BR ctl-amd (8), .BR amd.conf (5), .BR hosts_access (5). .LP ``am-utils'' .BR info (1) entry. .LP .I "Linux NFS and Automounter Administration" by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). .LP .I http://www.am-utils.org .LP .I "Amd \- The 4.4 BSD Automounter" .SH AUTHORS Jan-Simon Pendry , Department of Computing, Imperial College, London, UK. .P Erez Zadok , Computer Science Department, Stony Brook University, Stony Brook, New York, USA. .P Other authors and contributors to am-utils are listed in the .B AUTHORS file distributed with am-utils. am-utils-6.2+rc20110530/amq/amq.c000066400000000000000000000422231157065440000160350ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amq/amq.c * */ /* * Automounter query tool */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* locals */ static int flush_flag; static int getpid_flag; static int getpwd_flag; static int getvers_flag; static int minfo_flag; static int quiet_flag; static int stats_flag; static int unmount_flag; static int use_tcp_flag; static int use_udp_flag; static u_long amd_program_number = AMQ_PROGRAM; static char *debug_opts; static char *amq_logfile; static char *xlog_optstr; static char localhost[] = "localhost"; static char *def_server = localhost; /* externals */ extern int optind; extern char *optarg; /* structures */ enum show_opt { Full, Stats, Calc, Short, ShowDone }; /* * If (e) is Calc then just calculate the sizes * Otherwise display the mount node on stdout */ static void show_mti(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *twid) { switch (e) { case Calc: { int mw = strlen(mt->mt_mountinfo); int dw = strlen(mt->mt_directory); int tw = strlen(mt->mt_type); if (mw > *mwid) *mwid = mw; if (dw > *dwid) *dwid = dw; if (tw > *twid) *twid = tw; } break; case Full: { struct tm *tp = localtime((time_t *) ((voidp) &mt->mt_mounttime)); printf("%-*.*s %-*.*s %-*.*s %s\n\t%-5d %-7d %-6d %-7d %-7d %-6d %02d/%02d/%04d %02d:%02d:%02d\n", *dwid, *dwid, *mt->mt_directory ? mt->mt_directory : "/", /* XXX */ *twid, *twid, mt->mt_type, *mwid, *mwid, mt->mt_mountinfo, mt->mt_mountpoint, mt->mt_mountuid, mt->mt_getattr, mt->mt_lookup, mt->mt_readdir, mt->mt_readlink, mt->mt_statfs, tp->tm_mon + 1, tp->tm_mday, tp->tm_year < 1900 ? tp->tm_year + 1900 : tp->tm_year, tp->tm_hour, tp->tm_min, tp->tm_sec); } break; case Stats: { struct tm *tp = localtime((time_t *) ((voidp) &mt->mt_mounttime)); printf("%-*.*s %-5d %-7d %-6d %-7d %-7d %-6d %02d/%02d/%02d %02d:%02d:%04d\n", *dwid, *dwid, *mt->mt_directory ? mt->mt_directory : "/", /* XXX */ mt->mt_mountuid, mt->mt_getattr, mt->mt_lookup, mt->mt_readdir, mt->mt_readlink, mt->mt_statfs, tp->tm_mon + 1, tp->tm_mday, tp->tm_year < 1900 ? tp->tm_year + 1900 : tp->tm_year, tp->tm_hour, tp->tm_min, tp->tm_sec); } break; case Short: { printf("%-*.*s %-*.*s %-*.*s %s\n", *dwid, *dwid, *mt->mt_directory ? mt->mt_directory : "/", *twid, *twid, mt->mt_type, *mwid, *mwid, mt->mt_mountinfo, mt->mt_mountpoint); } break; default: break; } } /* * Display a pwd data */ static void show_pwd(amq_mount_tree *mt, char *path, size_t l, int *flag) { int len; while (mt) { len = strlen(mt->mt_mountpoint); if (NSTREQ(path, mt->mt_mountpoint, len) && !STREQ(mt->mt_directory, mt->mt_mountpoint)) { char buf[MAXPATHLEN+1]; /* must be same size as 'path' */ xstrlcpy(buf, mt->mt_directory, sizeof(buf)); xstrlcat(buf, &path[len], sizeof(buf)); xstrlcpy(path, buf, l); *flag = 1; } show_pwd(mt->mt_next, path, l, flag); mt = mt->mt_child; } } /* * Display a mount tree. */ static void show_mt(amq_mount_tree *mt, enum show_opt e, int *mwid, int *dwid, int *pwid) { while (mt) { show_mti(mt, e, mwid, dwid, pwid); show_mt(mt->mt_next, e, mwid, dwid, pwid); mt = mt->mt_child; } } static void show_mi(amq_mount_info_list *ml, enum show_opt e, int *mwid, int *dwid, int *twid) { u_int i; switch (e) { case Calc: { for (i = 0; i < ml->amq_mount_info_list_len; i++) { amq_mount_info *mi = &ml->amq_mount_info_list_val[i]; int mw = strlen(mi->mi_mountinfo); int dw = strlen(mi->mi_mountpt); int tw = strlen(mi->mi_type); if (mw > *mwid) *mwid = mw; if (dw > *dwid) *dwid = dw; if (tw > *twid) *twid = tw; } } break; case Full: { for (i = 0; i < ml->amq_mount_info_list_len; i++) { amq_mount_info *mi = &ml->amq_mount_info_list_val[i]; printf("%-*.*s %-*.*s %-*.*s %-3d %s is %s", *mwid, *mwid, mi->mi_mountinfo, *dwid, *dwid, mi->mi_mountpt, *twid, *twid, mi->mi_type, mi->mi_refc, mi->mi_fserver, mi->mi_up > 0 ? "up" : mi->mi_up < 0 ? "starting" : "down"); if (mi->mi_error > 0) { printf(" (%s)", strerror(mi->mi_error)); } else if (mi->mi_error < 0) { fputs(" (in progress)", stdout); } fputc('\n', stdout); } } break; default: break; } } /* * Display general mount statistics */ static void show_ms(amq_mount_stats *ms) { printf("\ requests stale mount mount unmount\n\ deferred fhandles ok failed failed\n\ %-9d %-9d %-9d %-9d %-9d\n", ms->as_drops, ms->as_stale, ms->as_mok, ms->as_merr, ms->as_uerr); } #if defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) static char * cluster_server(void) { struct cct_entry *cp; if (cnodeid() == 0) { /* * Not clustered */ return def_server; } while (cp = getccent()) if (cp->cnode_type == 'r') return cp->cnode_name; return def_server; } #endif /* defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) */ static void print_umnt_error(amq_sync_umnt *rv, const char *fs) { switch (rv->au_etype) { case AMQ_UMNT_OK: break; case AMQ_UMNT_FAILED: printf("unmount failed: %s\n", strerror(rv->au_errno)); break; case AMQ_UMNT_FORK: if (rv->au_errno == 0) printf("%s is not mounted\n", fs); else printf("falling back to asynchronous unmount: %s\n", strerror(rv->au_errno)); break; case AMQ_UMNT_READ: printf("pipe read error: %s\n", strerror(rv->au_errno)); break; case AMQ_UMNT_SERVER: printf("amd server down\n"); break; case AMQ_UMNT_SIGNAL: printf("got signal: %d\n", rv->au_signal); break; /* * Omit default so the compiler can check for missing cases. * default: break; */ } } static int amu_sync_umnt_to_retval(amq_sync_umnt *rv) { switch (rv->au_etype) { case AMQ_UMNT_FORK: if (rv->au_errno == 0) { /* * We allow this error so that things like: * amq -uu /l/cd0d && eject cd0 * will work when /l/cd0d is not mounted. * XXX - We still print an error message. */ return 0; } default: return rv->au_etype; } } static int clnt_failed(CLIENT *clnt, char *server) { fprintf(stderr, "%s: ", am_get_progname()); clnt_perror(clnt, server); return 1; } /* * MAIN */ int main(int argc, char *argv[]) { int opt_ch; int errs = 0; char *server; struct sockaddr_in server_addr; CLIENT *clnt = NULL; struct hostent *hp; int nodefault = 0; struct timeval tv; char *progname = NULL; /* * Compute program name */ if (argv[0]) { progname = strrchr(argv[0], '/'); if (progname && progname[1]) progname++; else progname = argv[0]; } if (!progname) progname = "amq"; am_set_progname(progname); /* * Parse arguments */ while ((opt_ch = getopt(argc, argv, "Hfh:l:mqsuvx:D:pP:TUw")) != -1) switch (opt_ch) { case 'H': goto show_usage; break; case 'f': flush_flag = 1; nodefault = 1; break; case 'h': def_server = optarg; break; case 'l': amq_logfile = optarg; nodefault = 1; break; case 'm': minfo_flag = 1; nodefault = 1; break; case 'p': getpid_flag = 1; nodefault = 1; break; case 'q': quiet_flag = 1; nodefault = 1; break; case 's': stats_flag = 1; nodefault = 1; break; case 'u': unmount_flag++; nodefault = 1; break; case 'v': getvers_flag = 1; nodefault = 1; break; case 'x': xlog_optstr = optarg; nodefault = 1; break; case 'D': debug_opts = optarg; nodefault = 1; break; case 'P': amd_program_number = atoi(optarg); break; case 'T': use_tcp_flag = 1; break; case 'U': use_udp_flag = 1; break; case 'w': getpwd_flag = 1; break; default: errs = 1; break; } if (optind == argc) { if (unmount_flag) errs = 1; } if (errs) { show_usage: fprintf(stderr, "\ Usage: %s [-fmpqsvwHTU] [-h hostname] [-l log_file|\"syslog\"]\n\ \t[-x log_options] [-D debug_options]\n\ \t[-P program_number] [[-u[u]] directory ...]\n", am_get_progname() ); exit(1); } /* set use_udp and use_tcp flags both to on if none are defined */ if (!use_tcp_flag && !use_udp_flag) use_tcp_flag = use_udp_flag = 1; #if defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) /* * Figure out root server of cluster */ if (def_server == localhost) server = cluster_server(); else #endif /* defined(HAVE_CLUSTER_H) && defined(HAVE_CNODEID) && defined(HAVE_GETCCENT) */ server = def_server; /* * Get address of server */ if ((hp = gethostbyname(server)) == 0 && !STREQ(server, localhost)) { fprintf(stderr, "%s: Can't get address of %s\n", am_get_progname(), server); exit(1); } memset(&server_addr, 0, sizeof(server_addr)); /* as per POSIX, sin_len need not be set (used internally by kernel) */ server_addr.sin_family = AF_INET; if (hp) { memmove((voidp) &server_addr.sin_addr, (voidp) hp->h_addr, sizeof(server_addr.sin_addr)); } else { /* fake "localhost" */ server_addr.sin_addr.s_addr = htonl(0x7f000001); } /* * Create RPC endpoint */ tv.tv_sec = 5; /* 5 seconds for timeout or per retry */ tv.tv_usec = 0; if (use_tcp_flag) /* try tcp first */ clnt = clnt_create(server, amd_program_number, AMQ_VERSION, "tcp"); if (!clnt && use_udp_flag) { /* try udp next */ clnt = clnt_create(server, amd_program_number, AMQ_VERSION, "udp"); /* if ok, set timeout (valid for connectionless transports only) */ if (clnt) clnt_control(clnt, CLSET_RETRY_TIMEOUT, (char *) &tv); } if (!clnt) { fprintf(stderr, "%s: ", am_get_progname()); clnt_pcreateerror(server); exit(1); } /* * Control debugging */ if (debug_opts) { int *rc; amq_setopt opt; opt.as_opt = AMOPT_DEBUG; opt.as_str = debug_opts; rc = amqproc_setopt_1(&opt, clnt); if (rc && *rc < 0) { fprintf(stderr, "%s: daemon not compiled for debug\n", am_get_progname()); errs = 1; } else if (!rc || *rc > 0) { fprintf(stderr, "%s: debug setting for \"%s\" failed\n", am_get_progname(), debug_opts); errs = 1; } } /* * Control logging */ if (xlog_optstr) { int *rc; amq_setopt opt; opt.as_opt = AMOPT_XLOG; opt.as_str = xlog_optstr; rc = amqproc_setopt_1(&opt, clnt); if (!rc || *rc) { fprintf(stderr, "%s: setting log level to \"%s\" failed\n", am_get_progname(), xlog_optstr); errs = 1; } } /* * Control log file */ if (amq_logfile) { int *rc; amq_setopt opt; opt.as_opt = AMOPT_LOGFILE; opt.as_str = amq_logfile; rc = amqproc_setopt_1(&opt, clnt); if (!rc || *rc) { fprintf(stderr, "%s: setting logfile to \"%s\" failed\n", am_get_progname(), amq_logfile); errs = 1; } } /* * Flush map cache */ if (flush_flag) { int *rc; amq_setopt opt; opt.as_opt = AMOPT_FLUSHMAPC; opt.as_str = ""; rc = amqproc_setopt_1(&opt, clnt); if (!rc || *rc) { fprintf(stderr, "%s: amd on %s cannot flush the map cache\n", am_get_progname(), server); errs = 1; } } /* * getpwd info */ if (getpwd_flag) { char path[MAXPATHLEN+1]; char *wd = getcwd(path, MAXPATHLEN+1); amq_mount_tree_list *mlp = amqproc_export_1((voidp) 0, clnt); amq_mount_tree_p mt; u_int i; int flag; if (!wd) { perror("getcwd"); exit(1); } for (i = 0; mlp && i < mlp->amq_mount_tree_list_len; i++) { mt = mlp->amq_mount_tree_list_val[i]; while (1) { flag = 0; show_pwd(mt, path, sizeof(path), &flag); if (!flag) { printf("%s\n", path); break; } } } exit(0); } /* * Mount info */ if (minfo_flag) { int dummy; amq_mount_info_list *ml = amqproc_getmntfs_1(&dummy, clnt); if (ml) { int mwid = 0, dwid = 0, twid = 0; show_mi(ml, Calc, &mwid, &dwid, &twid); mwid++; dwid++; twid++; show_mi(ml, Full, &mwid, &dwid, &twid); } else { fprintf(stderr, "%s: amd on %s cannot provide mount info\n", am_get_progname(), server); } } /* * Get Version */ if (getvers_flag) { amq_string *spp = amqproc_getvers_1((voidp) 0, clnt); if (spp && *spp) { fputs(*spp, stdout); XFREE(*spp); } else { fprintf(stderr, "%s: failed to get version information\n", am_get_progname()); errs = 1; } } /* * Get PID of amd */ if (getpid_flag) { int *ip = amqproc_getpid_1((voidp) 0, clnt); if (ip && *ip) { printf("%d\n", *ip); } else { fprintf(stderr, "%s: failed to get PID of amd\n", am_get_progname()); errs = 1; } } /* * Apply required operation to all remaining arguments */ if (optind < argc) { do { char *fs = argv[optind++]; if (unmount_flag > 1) { amq_sync_umnt *sup; /* * Synchronous unmount request */ sup = amqproc_sync_umnt_1(&fs, clnt); if (sup) { if (quiet_flag == 0) print_umnt_error(sup, fs); errs = amu_sync_umnt_to_retval(sup); } else { errs = clnt_failed(clnt, server); } } else if (unmount_flag) { /* * Unmount request */ amqproc_umnt_1(&fs, clnt); } else { /* * Stats request */ amq_mount_tree_p *mtp = amqproc_mnttree_1(&fs, clnt); if (mtp) { amq_mount_tree *mt = *mtp; if (mt) { int mwid = 0, dwid = 0, twid = 0; show_mt(mt, Calc, &mwid, &dwid, &twid); mwid++; dwid++, twid++; printf("%-*.*s Uid Getattr Lookup RdDir RdLnk Statfs Mounted@\n", dwid, dwid, "What"); show_mt(mt, Stats, &mwid, &dwid, &twid); } else { fprintf(stderr, "%s: %s not automounted\n", am_get_progname(), fs); } xdr_pri_free((XDRPROC_T_TYPE) xdr_amq_mount_tree_p, (caddr_t) mtp); } else { errs = clnt_failed(clnt, server); } } } while (optind < argc); } else if (unmount_flag) { goto show_usage; } else if (stats_flag) { amq_mount_stats *ms = amqproc_stats_1((voidp) 0, clnt); if (ms) { show_ms(ms); } else { errs = clnt_failed(clnt, server); } } else if (!nodefault) { amq_mount_tree_list *mlp = amqproc_export_1((voidp) 0, clnt); if (mlp) { enum show_opt e = Calc; int mwid = 0, dwid = 0, pwid = 0; while (e != ShowDone) { u_int i; for (i = 0; i < mlp->amq_mount_tree_list_len; i++) { show_mt(mlp->amq_mount_tree_list_val[i], e, &mwid, &dwid, &pwid); } mwid++; dwid++, pwid++; if (e == Calc) e = Short; else if (e == Short) e = ShowDone; } } else { errs = clnt_failed(clnt, server); } } exit(errs); return errs; /* should never reach here */ } am-utils-6.2+rc20110530/amq/amq.h000066400000000000000000000057371157065440000160530ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amq/amq.h * */ #ifndef _AMQ_H #define _AMQ_H /* * external definitions for building amq */ extern voidp amqproc_null_1(voidp argp, CLIENT *rqstp); extern amq_mount_tree_p *amqproc_mnttree_1(amq_string *argp, CLIENT *rqstp); extern voidp amqproc_umnt_1(amq_string *argp, CLIENT *rqstp); extern amq_sync_umnt *amqproc_sync_umnt_1(amq_string *argp, CLIENT *rqstp); extern amq_mount_stats *amqproc_stats_1(voidp argp, CLIENT *rqstp); extern amq_mount_tree_list *amqproc_export_1(voidp argp, CLIENT *rqstp); extern int *amqproc_setopt_1(amq_setopt *argp, CLIENT *rqstp); extern amq_mount_info_list *amqproc_getmntfs_1(voidp argp, CLIENT *rqstp); extern int *amqproc_mount_1(voidp argp, CLIENT *rqstp); extern amq_string *amqproc_getvers_1(voidp argp, CLIENT *rqstp); extern int *amqproc_getpid_1(voidp argp, CLIENT *rqstp); extern amq_string *amqproc_pawd_1(amq_string *argp, CLIENT *rqstp); #endif /* not _AMQ_H */ am-utils-6.2+rc20110530/amq/amq_clnt.c000066400000000000000000000144241157065440000170570ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amq/amq_clnt.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include static struct timeval TIMEOUT = {ALLOWED_MOUNT_TIME, 0}; voidp amqproc_null_1(voidp argp, CLIENT *clnt) { static char res; memset((char *) &res, 0, sizeof(res)); if (clnt_call(clnt, AMQPROC_NULL, (XDRPROC_T_TYPE) xdr_void, argp, (XDRPROC_T_TYPE) xdr_void, &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return ((voidp) &res); } amq_mount_tree_p * amqproc_mnttree_1(amq_string *argp, CLIENT *clnt) { static amq_mount_tree_p res; memset((char *) &res, 0, sizeof(res)); if (clnt_call(clnt, AMQPROC_MNTTREE, (XDRPROC_T_TYPE) xdr_amq_string, (SVC_IN_ARG_TYPE) argp, (XDRPROC_T_TYPE) xdr_amq_mount_tree_p, (SVC_IN_ARG_TYPE) &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&res); } voidp amqproc_umnt_1(amq_string *argp, CLIENT *clnt) { static char res; memset((char *) &res, 0, sizeof(res)); if (clnt_call(clnt, AMQPROC_UMNT, (XDRPROC_T_TYPE) xdr_amq_string, (SVC_IN_ARG_TYPE) argp, (XDRPROC_T_TYPE) xdr_void, &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return ((voidp) &res); } amq_sync_umnt * amqproc_sync_umnt_1(amq_string *argp, CLIENT *clnt) { static amq_sync_umnt res; enum clnt_stat rv; memset((char *) &res, 0, sizeof(res)); if ((rv = clnt_call(clnt, AMQPROC_SYNC_UMNT, (XDRPROC_T_TYPE) xdr_amq_string, (SVC_IN_ARG_TYPE) argp, (XDRPROC_T_TYPE) xdr_amq_sync_umnt, (SVC_IN_ARG_TYPE) &res, TIMEOUT)) != RPC_SUCCESS) { return (NULL); } return &res; } amq_mount_stats * amqproc_stats_1(voidp argp, CLIENT *clnt) { static amq_mount_stats res; memset((char *) &res, 0, sizeof(res)); if (clnt_call(clnt, AMQPROC_STATS, (XDRPROC_T_TYPE) xdr_void, argp, (XDRPROC_T_TYPE) xdr_amq_mount_stats, (SVC_IN_ARG_TYPE) &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&res); } amq_mount_tree_list * amqproc_export_1(voidp argp, CLIENT *clnt) { static amq_mount_tree_list res; memset((char *) &res, 0, sizeof(res)); if (clnt_call(clnt, AMQPROC_EXPORT, (XDRPROC_T_TYPE) xdr_void, argp, (XDRPROC_T_TYPE) xdr_amq_mount_tree_list, (SVC_IN_ARG_TYPE) &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&res); } int * amqproc_setopt_1(amq_setopt *argp, CLIENT *clnt) { static int res; memset((char *) &res, 0, sizeof(res)); if (clnt_call(clnt, AMQPROC_SETOPT, (XDRPROC_T_TYPE) xdr_amq_setopt, (SVC_IN_ARG_TYPE) argp, (XDRPROC_T_TYPE) xdr_int, (SVC_IN_ARG_TYPE) &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&res); } amq_mount_info_list * amqproc_getmntfs_1(voidp argp, CLIENT *clnt) { static amq_mount_info_list res; memset((char *) &res, 0, sizeof(res)); if (clnt_call(clnt, AMQPROC_GETMNTFS, (XDRPROC_T_TYPE) xdr_void, argp, (XDRPROC_T_TYPE) xdr_amq_mount_info_list, (SVC_IN_ARG_TYPE) &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&res); } int * amqproc_mount_1(voidp argp, CLIENT *clnt) { static int res; memset((char *) &res, 0, sizeof(res)); if (clnt_call(clnt, AMQPROC_MOUNT, (XDRPROC_T_TYPE) xdr_amq_string, argp, (XDRPROC_T_TYPE) xdr_int, (SVC_IN_ARG_TYPE) &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&res); } amq_string * amqproc_getvers_1(voidp argp, CLIENT *clnt) { static amq_string res; memset((char *) &res, 0, sizeof(res)); if (clnt_call(clnt, AMQPROC_GETVERS, (XDRPROC_T_TYPE) xdr_void, argp, (XDRPROC_T_TYPE) xdr_amq_string, (SVC_IN_ARG_TYPE) &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&res); } int * amqproc_getpid_1(voidp argp, CLIENT *clnt) { static int res; memset((char *) &res, 0, sizeof(res)); if (clnt_call(clnt, AMQPROC_GETPID, (XDRPROC_T_TYPE) xdr_void, argp, (XDRPROC_T_TYPE) xdr_int, (SVC_IN_ARG_TYPE) &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&res); } amq_string * amqproc_pawd_1(amq_string *argp, CLIENT *clnt) { static amq_string res; memset((char *) &res, 0, sizeof(res)); if (clnt_call(clnt, AMQPROC_PAWD, (XDRPROC_T_TYPE) xdr_amq_string, (SVC_IN_ARG_TYPE) argp, (XDRPROC_T_TYPE) xdr_amq_string, (SVC_IN_ARG_TYPE) &res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&res); } am-utils-6.2+rc20110530/amq/amq_xdr.c000066400000000000000000000134751157065440000167210ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amq/amq_xdr.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include bool_t xdr_time_type(XDR *xdrs, time_type *objp) { if (!xdr_long(xdrs, (long *) objp)) { return (FALSE); } return (TRUE); } bool_t xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp) { if (!xdr_amq_string(xdrs, &objp->mt_mountinfo)) { return (FALSE); } if (!xdr_amq_string(xdrs, &objp->mt_directory)) { return (FALSE); } if (!xdr_amq_string(xdrs, &objp->mt_mountpoint)) { return (FALSE); } if (!xdr_amq_string(xdrs, &objp->mt_type)) { return (FALSE); } if (!xdr_time_type(xdrs, &objp->mt_mounttime)) { return (FALSE); } if (!xdr_u_short(xdrs, &objp->mt_mountuid)) { return (FALSE); } if (!xdr_int(xdrs, &objp->mt_getattr)) { return (FALSE); } if (!xdr_int(xdrs, &objp->mt_lookup)) { return (FALSE); } if (!xdr_int(xdrs, &objp->mt_readdir)) { return (FALSE); } if (!xdr_int(xdrs, &objp->mt_readlink)) { return (FALSE); } if (!xdr_int(xdrs, &objp->mt_statfs)) { return (FALSE); } if (!xdr_pointer(xdrs, (char **) ((voidp) &objp->mt_next), sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_tree)) { return (FALSE); } if (!xdr_pointer(xdrs, (char **) ((voidp) &objp->mt_child), sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_tree)) { return (FALSE); } return (TRUE); } bool_t xdr_amq_mount_tree_p(XDR *xdrs, amq_mount_tree_p *objp) { if (!xdr_pointer(xdrs, (char **) objp, sizeof(amq_mount_tree), (XDRPROC_T_TYPE) xdr_amq_mount_tree)) { return (FALSE); } return (TRUE); } bool_t xdr_amq_mount_info(XDR *xdrs, amq_mount_info *objp) { if (!xdr_amq_string(xdrs, &objp->mi_type)) { return (FALSE); } if (!xdr_amq_string(xdrs, &objp->mi_mountpt)) { return (FALSE); } if (!xdr_amq_string(xdrs, &objp->mi_mountinfo)) { return (FALSE); } if (!xdr_amq_string(xdrs, &objp->mi_fserver)) { return (FALSE); } if (!xdr_int(xdrs, &objp->mi_error)) { return (FALSE); } if (!xdr_int(xdrs, &objp->mi_refc)) { return (FALSE); } if (!xdr_int(xdrs, &objp->mi_up)) { return (FALSE); } return (TRUE); } bool_t xdr_amq_mount_info_list(XDR *xdrs, amq_mount_info_list *objp) { if (!xdr_array(xdrs, (char **) ((voidp) &objp->amq_mount_info_list_val), (u_int *) &objp->amq_mount_info_list_len, ~0, sizeof(amq_mount_info), (XDRPROC_T_TYPE) xdr_amq_mount_info)) { return (FALSE); } return (TRUE); } bool_t xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp) { if (!xdr_array(xdrs, (char **) ((voidp) &objp->amq_mount_tree_list_val), (u_int *) &objp->amq_mount_tree_list_len, ~0, sizeof(amq_mount_tree_p), (XDRPROC_T_TYPE) xdr_amq_mount_tree_p)) { return (FALSE); } return (TRUE); } bool_t xdr_amq_mount_stats(XDR *xdrs, amq_mount_stats *objp) { if (!xdr_int(xdrs, &objp->as_drops)) { return (FALSE); } if (!xdr_int(xdrs, &objp->as_stale)) { return (FALSE); } if (!xdr_int(xdrs, &objp->as_mok)) { return (FALSE); } if (!xdr_int(xdrs, &objp->as_merr)) { return (FALSE); } if (!xdr_int(xdrs, &objp->as_uerr)) { return (FALSE); } return (TRUE); } bool_t xdr_amq_opt(XDR *xdrs, amq_opt *objp) { if (!xdr_enum(xdrs, (enum_t *) objp)) { return (FALSE); } return (TRUE); } bool_t xdr_amq_setopt(XDR *xdrs, amq_setopt *objp) { if (!xdr_amq_opt(xdrs, &objp->as_opt)) { return (FALSE); } if (!xdr_amq_string(xdrs, &objp->as_str)) { return (FALSE); } return (TRUE); } bool_t xdr_pri_free(XDRPROC_T_TYPE xdr_args, caddr_t args_ptr) { XDR xdr; xdr.x_op = XDR_FREE; return ((*xdr_args) (&xdr, (caddr_t *) args_ptr)); } am-utils-6.2+rc20110530/amq/pawd.1000066400000000000000000000065351157065440000161360ustar00rootroot00000000000000.\" .\" Copyright (c) 1997-2011 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. 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 .\" 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/amq/pawd.1 .\" .TH PAWD 1 "6 Jan 1998" .SH NAME pawd \- print automounter working directory .SH SYNOPSIS .B pawd [ .I path ... ] .SH DESCRIPTION .LP .B pawd is used to print the current working directory, adjusted to reflect proper paths that can be reused to go through the automounter for the shortest possible path. In particular, the path printed back does not include any of .BR Amd 's local mount points. Using them is unsafe, because .B Amd may unmount managed file systems from the mount points, and thus including them in paths may not always find the files within. .P Without any arguments, .B pawd will print the automounter adjusted current working directory. With any number of arguments, it will print the adjusted path of each one of the arguments. .SH "SEE ALSO" .BR pwd (1). .BR amd (8), .BR amq (8), .LP ``am-utils'' .BR info (1) entry. .LP .I "Linux NFS and Automounter Administration" by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). .LP .I http://www.am-utils.org .LP .I "Amd \- The 4.4 BSD Automounter" .SH AUTHORS Erez Zadok , Computer Science Department, Stony Brook University, Stony Brook, New York, USA. .P Other authors and contributors to am-utils are listed in the .B AUTHORS file distributed with am-utils. am-utils-6.2+rc20110530/amq/pawd.c000066400000000000000000000165221157065440000162150ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amq/pawd.c * */ /* * pawd is similar to pwd, except that it returns more "natural" versions of * pathnames for directories automounted with the amd automounter. If any * arguments are given, the "more natural" form of the given pathnames are * printed. * * Paul Anderson (paul@ed.lfcs) * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* statics */ static char *localhost = "localhost"; static char transform[MAXPATHLEN]; #ifdef HAVE_CNODEID static char * cluster_server(void) { # ifdef HAVE_EXTERN_GETCCENT struct cct_entry *cp; # endif /* HAVE_EXTERN_GETCCENT */ if (cnodeid() == 0) return localhost; # ifdef HAVE_EXTERN_GETCCENT while ((cp = getccent())) if (cp->cnode_type == 'r') return cp->cnode_name; # endif /* HAVE_EXTERN_GETCCENT */ return localhost; } #endif /* HAVE_CNODEID */ /* DISK_HOME_HACK added by gdmr */ #ifdef DISK_HOME_HACK static char * hack_name(char *dir) { char partition[MAXPATHLEN]; char username[MAXPATHLEN]; char hesiod_lookup[MAXPATHLEN]; char *to, *ch, *hes_name, *dot; char **hes; #ifdef DEBUG fprintf(stderr, "hack_name(%s)\n", dir); #endif /* DEBUG */ if (dir[0] == '/' && dir[1] == 'a' && dir[2] == '/') { /* Could be /a/server/disk/home/partition/user... */ ch = dir + 3; while (*ch && *ch != '/') ch++; /* Skip server */ if (!NSTREQ(ch, "/disk/home/", 11)) return NULL; /* Nope */ /* Looking promising, next should be the partition name */ ch += 11; to = partition; while (*ch && *ch != '/') *to++ = *ch++; to = '\0'; if (!(*ch)) return NULL; /* Off the end */ /* Now the username */ ch++; to = username; while (*ch && *ch != '/') *to++ = *ch++; to = '\0'; #ifdef DEBUG fprintf(stderr, "partition %s, username %s\n", partition, username); #endif /* DEBUG */ xsnprintf(hesiod_lookup, sizeof(hesiod_lookup), "%s.homes-remote", username); hes = hes_resolve(hesiod_lookup, "amd"); if (!hes) return NULL; #ifdef DEBUG fprintf(stderr, "hesiod -> <%s>\n", *hes); #endif /* DEBUG */ hes_name = strstr(*hes, "/homes/remote/"); if (!hes_name) return NULL; hes_name += 14; #ifdef DEBUG fprintf(stderr, "hesiod -> <%s>\n", hes_name); #endif /* DEBUG */ dot = hes_name; while (*dot && *dot != '.') dot++; *dot = '\0'; #ifdef DEBUG fprintf(stderr, "hesiod -> <%s>\n", hes_name); #endif /* DEBUG */ if (strcmp(partition, hes_name)) return NULL; #ifdef DEBUG fprintf(stderr, "A match, munging....\n"); #endif /* DEBUG */ xstrlcpy(transform, "/home/", sizeof(transform)); xstrlcat(transform, username, sizeof(transform)); if (*ch) xstrlcat(transform, ch, sizeof(transform)); #ifdef DEBUG fprintf(stderr, "Munged to <%s>\n", transform); #endif /* DEBUG */ return transform; } return NULL; } #endif /* DISK_HOME_HACK */ /* * The routine transform_dir(path) transforms pathnames of directories * mounted with the amd automounter to produce a more "natural" version. * The automount table is obtained from the local amd via the rpc interface * and reverse lookups are repeatedly performed on the directory name * substituting the name of the automount link for the value of the link * whenever it occurs as a prefix of the directory name. */ static char * transform_dir(char *dir) { #ifdef DISK_HOME_HACK char *ch; #endif /* DISK_HOME_HACK */ char *server; struct sockaddr_in server_addr; int s = RPC_ANYSOCK; CLIENT *clnt; struct hostent *hp; struct timeval tmo = {10, 0}; char *dummystr; amq_string *spp; #ifdef DISK_HOME_HACK if (ch = hack_name(dir)) return ch; #endif /* DISK_HOME_HACK */ #ifdef HAVE_CNODEID server = cluster_server(); #else /* not HAVE_CNODEID */ server = localhost; #endif /* not HAVE_CNODEID */ if ((hp = gethostbyname(server)) == NULL) return dir; memset(&server_addr, 0, sizeof(server_addr)); /* as per POSIX, sin_len need not be set (used internally by kernel) */ server_addr.sin_family = AF_INET; server_addr.sin_addr = *(struct in_addr *) hp->h_addr; clnt = clntudp_create(&server_addr, AMQ_PROGRAM, AMQ_VERSION, tmo, &s); if (clnt == NULL) clnt = clnttcp_create(&server_addr, AMQ_PROGRAM, AMQ_VERSION, &s, 0, 0); if (clnt == NULL) return dir; xstrlcpy(transform, dir, sizeof(transform)); dummystr = transform; spp = amqproc_pawd_1((amq_string *) &dummystr, clnt); if (spp && *spp && **spp) { xstrlcpy(transform, *spp, sizeof(transform)); XFREE(*spp); } clnt_destroy(clnt); return transform; } /* getawd() is a substitute for getwd() which transforms the path */ static char * getawd(char *path, size_t l) { #ifdef HAVE_GETCWD char *wd = getcwd(path, MAXPATHLEN); #else /* not HAVE_GETCWD */ char *wd = getwd(path); #endif /* not HAVE_GETCWD */ if (wd == NULL) { return NULL; } xstrlcpy(path, transform_dir(wd), l); return path; } int main(int argc, char *argv[]) { char tmp_buf[MAXPATHLEN], *wd; if (argc == 1) { wd = getawd(tmp_buf, sizeof(tmp_buf)); if (wd == NULL) { fprintf(stderr, "pawd: %s\n", tmp_buf); exit(1); } else { fprintf(stdout, "%s\n", wd); } } else { while (--argc) { wd = transform_dir(*++argv); fprintf(stdout, "%s\n", wd); } } exit(0); } am-utils-6.2+rc20110530/aux_conf.h.in000066400000000000000000000037541157065440000167230ustar00rootroot00000000000000/* * aux_conf.h: * This file gets "filled in" for each architecture. * @configure_input@ */ #ifndef _AUX_CONF_H #define _AUX_CONF_H /* * The next line is a literal inclusion of a file which includes a * definition for the MOUNT_TRAP macro for a particular architecture. * If it defines the wrong entry, check the AC_CHECK_MOUNT_TRAP m4 macro * in $srcdir/m4/macros. */ @am_utils_mount_trap@ /* End of included MOUNT_TRAP macro definition file */ /* * The next line is a literal replacement of a variable which defines the * the UNMOUNT_TRAP macro for a particular architecture. * If it defines the wrong entry, check the AC_CHECK_UNMOUNT_CALL m4 macro * in $srcdir/aclocal.m4. If the arguments are being defined wrong, check * the macro AC_CHECK_UNMOUNT_ARGS in $srcdir/m4/macros. */ #define UNMOUNT_TRAP(mnt) @am_utils_unmount_call@(@am_utils_unmount_args@) /* End of replaced UNMOUNT_TRAP macro definition */ /* umount(8) executable path, for type:=program */ #define UNMOUNT_PROGRAM "@UNMOUNT_PROGRAM@" /* * The next line is a literal inclusion of a file which includes a * definition for the NFS_FH_DREF macro for a particular architecture. * If it defines the wrong entry, check the AC_CHECK_NFS_FH_DREF m4 macro * in $srcdir/m4/macros. */ @am_utils_nfs_fh_dref@ /* End of included NFS_FH_DREF macro definition file */ /* * The next line is a literal inclusion of a file which includes a * definition for the NFS_SA_DREF macro for a particular architecture. * If it defines the wrong entry, check the AC_CHECK_NFS_SA_DREF m4 macro * in $srcdir/m4/macros. */ @am_utils_nfs_sa_dref@ /* End of included NFS_SA_DREF macro definition file */ /* * The next line is a literal inclusion of a file which includes a * definition for the NFS_HN_DREF macro for a particular architecture. * If it defines the wrong entry, check the AC_CHECK_NFS_HN_DREF m4 macro * in $srcdir/m4/macros. */ @am_utils_nfs_hn_dref@ /* End of included NFS_HN_DREF macro definition file */ #endif /* not _AUX_CONF_H */ am-utils-6.2+rc20110530/bootstrap000077500000000000000000000050651157065440000163030ustar00rootroot00000000000000#!/bin/sh #set -x # helps bootstrapping am-utils, when checked out from CVS # requires GNU autoconf and GNU automake # this is not meant to go into the distributions # Erez Zadok # test cwd test -f ../amd/amd.c && cd .. if [ ! -f amd/amd.c ]; then echo "Must run $0 from the top level source directory." exit 1 fi # validate macros directory and some macro files if [ ! -d m4/macros ]; then echo No m4/macros directory found! exit 1 fi if [ ! -f m4/macros/HEADER ]; then echo No m4/macros/HEADER file found! exit 1 fi # remove any remaining autom4te.cache directory rm -fr autom4te.cache autom4te-*.cache # generate acinclude.m4 file echo "AMU: prepare acinclude.m4..." test -f acinclude.m4 && mv -f acinclude.m4 acinclude.m4.old (cd m4/macros for i in HEADER *.m4; do cat $i echo echo done cat TRAILER ) > acinclude.m4 # generate aclocal.m4 file echo "AMU: aclocal..." test -f aclocal.m4 && mv -f aclocal.m4 aclocal.m4.old # show version aclocal --version 2>&1 | head -1 if aclocal ; then : else echo "aclocal command failed. fix errors and rerun $0." exit 2 fi # produce new configure.in (temp) script echo "AMU: autoconf..." # show version autoconf --version 2>&1 | head -1 LOG=/tmp/amu-$$.log rm -f ${LOG} autoconf configure.in > configure.new 2> ${LOG} # until Automake requires Autoconf 2.50, manual says to ignore this CUTWARNMSG1="warning: AC_PROG_LEX invoked multiple times|do not use m4_(patsubst|regexp):" egrep -v "${CUTWARNMSG1}" ${LOG} > ${LOG}.new mv ${LOG}.new ${LOG} if test -s ${LOG}; then echo "AUTOCONF ERRORS (MUST FIX):" cat ${LOG} rm -f ${LOG} exit 2 fi # now prepare the real configure script test -f configure && mv -f configure configure.old mv -f configure.new configure chmod a+rx configure rm -f configure.old # run autoheader to produce C header .in files echo "AMU: autoheader..." # show version autoheader --version 2>&1 | head -1 autoheader configure.in > config.h.in 2> ${LOG} CUTWARNMSG2="autoheader: \`config.h.in' is updated" egrep -v "${CUTWARNMSG2}" ${LOG} > ${LOG}.new mv ${LOG}.new ${LOG} if test -s ${LOG}; then echo "AUTOHEADER ERRORS (MUST FIX):" cat ${LOG} rm -f ${LOG} exit 2 fi rm -f ${LOG} # generate makefiles cmd="automake --add-missing --copy --ignore-deps" #cmd="automake --add-missing" echo "AMU: $cmd..." # show version automake --version 2>&1 | head -1 if ${cmd} ; then : else echo "automake command failed. fix errors and rerun $0." exit 2 fi # save timestamp echo "AMU: save timestamp..." echo timestamp > stamp-h.in exit 0 am-utils-6.2+rc20110530/buildall000077500000000000000000000211041157065440000160460ustar00rootroot00000000000000#!/bin/sh # Build all of the am-utils package in a directory A. # Used by am-utils users. # Erez Zadok # # run "buildall -h" to get usage # #set -x ############################################################################## # first test if we are in the right directory to run this script # change to the right directory test -f ../config.guess && cd .. test -f ../../config.guess && cd ../.. pwd=`pwd` host_alias=`(cd /tmp; $pwd/config.guess.long)` if test -z "$host_alias" ; then echo "$0: must run from the source or the A. directory." echo "$0: cannot find $pwd/config.guess" exit 1 else : fi ############################################################################## # pattern of lines to remove from config.cache (for developers only) # Example: if you change TRY_COMPILE_NFS, redo these: #pat='fhandle|nfs_fh|nfs_args|struct_nfs|opt' #pat='style_|mount_trap|mtype|transport|dref' #pat='mntent|mnttab' #pat='nfs_args|fh_len|irix|proto|vers' #pat='3|proto|tcp|ver|nfs_prot|mtype' #pat='trap|style|mtype|transport|os_libs|restartable|unmount_args|yp_order' #pat='yp_all|nsl|nis' ############################################################################## # initialize variables (build command, config command, variables) bld_cmd="" bld_flags="" cnf_cmd="" cnf_flags="-C" # use config.cache cache file inst_cmd="" inst_flags="" mkcnf_cmd="" vars="" expvars="" default=yes ############################################################################## # check if CFLAGS or AM_CFLAGS was passed test -z "$CFLAGS" || vars="$vars CFLAGS=\"${CFLAGS}\"" test -z "$CFLAGS" || expvars="$expvars CFLAGS" test -z "$AM_CFLAGS" || vars="$vars AM_CFLAGS=\"${AM_CFLAGS}\"" ############################################################################## # functions add_gcc_flags1 () { case "${CC}" in cc | */cc ) # do nothing ;; * ) vars="$vars AM_CFLAGS=\"-Werror\"" AM_CFLAGS="-Werror" expvars="$expvars AM_CFLAGS" ;; esac } add_gcc_flags2 () { case "${CC}" in cc | */cc ) # do nothing ;; * ) vars="$vars AM_CFLAGS=\"-Wall -Werror\"" AM_CFLAGS="-Wall -Werror" expvars="$expvars AM_CFLAGS" ;; esac } add_shared_flags () { cnf_cmd="$cnf_cmd --enable-shared --disable-static" } add_prefix_flags () { cnf_cmd="$cnf_cmd --prefix=/usr/local/AMD" } ############################################################################## # iterate over all options, and set the command to run with any variables while [ $# != 0 ]; do case "$1" in -b ) # look for GNU make if possible gmake --version -f /dev/null > /dev/null 2>&1 if [ $? = 0 ] then bld_cmd="${MAKE:-gmake}" else bld_cmd="${MAKE:-make}" fi default=no shift ;; -i ) # look for GNU make if possible gmake --version -f /dev/null > /dev/null 2>&1 if [ $? = 0 ] then inst_cmd="${MAKE:-gmake} install" else inst_cmd="${MAKE:-make} install" fi default=no shift ;; -c ) cnf_cmd="../configure --enable-debug=yes" # add_gcc_flags1 default=no shift ;; -cs ) cnf_cmd="../configure --enable-debug=yes" add_shared_flags # add_gcc_flags1 default=no shift ;; -C ) cnf_cmd="../configure --enable-debug=yes" add_gcc_flags2 default=no shift ;; -Cs ) cnf_cmd="../configure --enable-debug=yes" add_shared_flags add_gcc_flags2 default=no shift ;; -d ) cnf_cmd="../configure --enable-debug=yes" add_prefix_flags # add_gcc_flags1 default=no shift ;; -ds ) cnf_cmd="../configure --enable-debug=yes" add_prefix_flags add_shared_flags # add_gcc_flags1 default=no shift ;; -D ) cnf_cmd="../configure --enable-debug=yes" add_prefix_flags add_gcc_flags2 default=no shift ;; -Ds ) cnf_cmd="../configure -enable-debug=yes" # cnf_cmd="../configure -enable-debug=mem" # cnf_cmd="../configure --prefix=/usr/local/AMD --enable-debug=yes --enable-shared --disable-static \ # --enable-cppflags=\"-I${HOME}/ldap/include -I${HOME}/hesiod/include\" \ # --enable-ldflags=\"-L${HOME}/ldap/lib -L${HOME}/hesiod/lib\"" # cnf_cmd="$cnf_cmd \ # --enable-cppflags=-I${HOME}/ldap/include \ # --enable-ldflags=-L${HOME}/ldap/lib" # cnf_cmd="../configure -enable-debug=yes --enable-cppflags=-I/usr/local/include --enable-ldflags=-L/usr/local/lib" add_prefix_flags add_shared_flags add_gcc_flags2 default=no shift ;; -K ) # mkcnf_cmd="../m4/mkconf" mkcnf_cmd="../bootstrap" if test -f bootstrap ; then : else echo "am-utils maintainer option only!" exit 1 fi default=no shift ;; -q ) cnf_cmd="./config.status" default=no shift ;; -- ) shift cmdline_cnf_flags="$*" break # from while loop ;; -h | * ) cat < /dev/null 2>&1 if [ $? = 0 ] then bld_cmd="${MAKE:-gmake}" else bld_cmd="${MAKE:-make}" fi cnf_cmd="../configure" else : fi ############################################################################## # make build directory if needed if test -d ./A.${host_alias} ; then : else mkdir ./A.${host_alias} fi echo "Configuring/building am-utils in directory ./A.${host_alias} ..." echo cd ./A.${host_alias} cd ./A.${host_alias} || exit 1 ############################################################################## # this is for developers only (remove config.cache entries) if test -n "$pat"; then if test -f config.cache; then egrep $pat config.cache | while read i; do echo ' '$i;done egrep -v $pat config.cache > tmp.$$ && \ mv config.cache config.cache.old && mv tmp.$$ config.cache else : fi else : fi ############################################################################## # Some system's /bin/sh has limits/bugs which prevent it from being used # with configure case "${host_alias}" in *hpux9* | *aix5.1* ) if test -n "$cnf_cmd"; then if test -f /bin/bash; then cnf_cmd="/bin/bash $cnf_cmd" elif test -f /bin/ksh; then cnf_cmd="/bin/ksh $cnf_cmd" fi else : fi echo "WARNING: do not use /bin/make under this system." echo "Instead, use GNU make or 'ksh ./configure' directly." ;; mips-sgi-irix5.2) echo "WARNING: do not use /bin/make under this system." echo "Instead, use GNU make or ./configure directly." ;; esac ############################################################################## # see if need to run mkconf if test -n "$mkcnf_cmd"; then echo $mkcnf_cmd $mkcnf_cmd || exit 1 else : fi ############################################################################## # see if need to [re]configure if test -n "$cnf_cmd"; then if test -n "$vars"; then echo $vars eval $vars echo export $expvars export $expvars else : fi if test -z "${cnf_flags}${extra_cnf_flags}"; then echo $cnf_cmd $cmdline_cnf_flags $cnf_cmd $cmdline_cnf_flags || exit 1 else echo $cnf_cmd "$cnf_flags" "$extra_cnf_flags" $cmdline_cnf_flags $cnf_cmd "$cnf_flags" "$extra_cnf_flags" $cmdline_cnf_flags || exit 1 fi else : fi ############################################################################## # if need to [re]build if test -n "$bld_cmd"; then echo $bld_cmd $bld_flags $bld_cmd $bld_flags || exit 1 else : fi ############################################################################## # if need to install if test -n "$inst_cmd"; then echo $inst_cmd $inst_flags $inst_cmd $inst_flags || exit 1 else : fi ############################################################################## am-utils-6.2+rc20110530/commit000077500000000000000000000140401157065440000155470ustar00rootroot00000000000000#! /bin/sh # commit version 0.9.2 # Copyright (C) 1999, Free Software Foundation # This script is Free Software, and it can be copied, distributed and # modified as defined in the GNU General Public License. A copy of # its license can be downloaded from http://www.gnu.org/copyleft/gpl.html # Originally by Gary V. Vaughan # Heavily modified by Alexandre Oliva # This scripts eases checking in changes to CVS-maintained projects # with ChangeLog files. It will check that there have been no # conflicting commits in the CVS repository and print which files it # is going to commit to stderr. A list of files to compare and to # check in can be given in the command line. If it is not given, all # files in the current directory (and below, unless `-l' is given) are # considered for check in. # The commit message will be extracted from the differences between # the local ChangeLog and the one in the repository (unless a message # was specified with `-m' or `-F'). An empty message is not accepted # (but a blank line is). If the message is acceptable, it will be # presented for verification (and possible edition) using the $PAGER # environment variable (or `more', if it is not set, or `cat', if the # `-f' switch is given). If $PAGER exits successfully, the modified # files (at that moment) are checked in, unless `-n' was specified, in # which case nothing is checked in. # usage: commit [-v] [-h] [-f] [-l] [-n] [-q] [-z N] # [-m msg|-F msg_file] [--] [file|dir ...] # -f --fast don't check (unless *followed* by -n), and just # --force display commit message instead of running $PAGER # -l --local don't descend into subdirectories # -m msg --message=msg set commit message # --msg=msg same as -m # -F file --file=file read commit message from file # -n --dry-run don't commit anything # -q --quiet run cvs in quiet mode # -zN --compress=N set compression level (0-9, 0=none, 9=max) # -v --version print version information # -h,-? --help print short or long help message name=commit cvsopt= updateopt= commitopt= dry_run=false commit=: update=: log_file="${TMPDIR-/tmp}/commitlog.$$" rm -f "$log_file" trap 'rm -f "$log_file"; exit 1' 1 2 15 # this just eases exit handling main_repeat=":" while $main_repeat; do repeat="test $# -gt 0" while $repeat; do case "$1" in -f|--force|--fast) update=false PAGER=cat shift ;; -l|--local) updateopt="$updateopt -l" commitopt="$commitopt -l" shift ;; -m|--message|--msg) if test $# = 1; then echo "$name: missing argument for $1" >&2 break fi if test -f "$log_file"; then echo "$name: you can have at most one of -m and -F" >&2 break fi shift echo "$1" > "$log_file" shift ;; -F|--file) if test -f "$log_file"; then echo "$name: you can have at most one of -m and -F" >&2 break fi if test $# = 1; then echo "$name: missing argument for $1" >&2 break fi shift if cat < "$1" > "$log_file"; then :; else break fi shift ;; -n|--dry-run) commit=false update=true shift ;; -q|--quiet) cvsopt="$cvsopt -q" shift ;; -z|--compress) if test $# = 1; then echo "$name: missing argument for $1" >&2 break fi case "$2" in [0-9]) :;; *) echo "$name: invalid argument for $1" >&2 break ;; esac cvsopt="$cvsopt -z$2" shift shift ;; -m*|-F*|-z*) opt=`echo "$1" | sed '1s/^\(..\).*$/\1/;q'` arg=`echo "$1" | sed '1s/^-[a-zA-Z0-9]//'` shift set -- "$opt" "$arg" ${1+"$@"} ;; --message=*|--msg=*|--file=*|--compress=*) opt=`echo "$1" | sed '1s/^\(--[^=]*\)=.*/\1/;q'` arg=`echo "$1" | sed '1s/^--[^=]*=//'` shift set -- "$opt" "$arg" ${1+"$@"} ;; -v|--version) sed '/^# '$name' version /,/^# Heavily modified by/ { s/^# //; p; }; d' < $0 exit 0 ;; -\?|-h) sed '/^# usage:/,/# -h/ { s/^# //; p; }; d' < $0 && echo echo "run \`$name --help | more' for full usage" exit 0 ;; --help) sed '/^# '$name' version /,/^[^#]/ { /^[^#]/ d; s/^# //; p; }; d' < $0 exit 0 ;; --) shift repeat=false ;; -*) echo "$name: invalid flag $1" >&2 break ;; *) repeat=false ;; esac done # might have used break 2 within the previous loop, but so what $repeat && break $update && \ if echo "$name: checking for conflicts..." >&2 (cvs $cvsopt -q -n update $updateopt ${1+"$@"} 2>/dev/null \ | while read line; do echo "$line" echo "$line" >&3 done | grep '^C') 3>&1 >/dev/null; then echo "$name: some conflicts were found, aborting..." >&2 break fi if test ! -f "$log_file"; then echo "$name: checking commit message..." >&2 cvs $cvsopt diff -u ChangeLog \ | while read line; do case "$line" in "--- ChangeLog"*) :;; "-"*) echo "$name: *** Warning: the following line in ChangeLog diff is suspicious:" >&2 echo "$line" | sed 's/^.//' >&2;; "+ "*) echo "$name: *** Warning: lines should start with tabs, not spaces; ignoring line:" >&2 echo "$line" | sed 's/^.//' >&2;; "+") echo;; "+ "*) echo "$line";; esac done \ | sed -e 's,\+ ,,' -e '/./p' -e '/./d' -e '1d' -e '$d' > "$log_file" \ || break # The sed script above removes "+TAB" from the beginning of a line, then # deletes the first and/or the last line, when they happen to be empty fi if grep '[^ ]' < "$log_file" > /dev/null; then :; else echo "$name: empty commit message, aborting" >&2 break fi if grep '^$' < "$log_file" > /dev/null; then echo "$name: *** Warning: blank lines should not appear within a commit messages." >&2 echo "$name: *** They should be used to separate distinct commits." >&2 fi ${PAGER-more} "$log_file" || break sleep 1 # give the user some time for a ^C # Do not check for empty $log_file again, even though the user might have # zeroed it out. If s/he did, it was probably intentional. if $commit; then cvs $cvsopt commit $commitopt -F $log_file ${1+"$@"} || break fi main_repeat=false done rm -f "$log_file" # if main_repeat was not set to `false', we failed $main_repeat && exit 1 exit 0 am-utils-6.2+rc20110530/conf/000077500000000000000000000000001157065440000152575ustar00rootroot00000000000000am-utils-6.2+rc20110530/conf/autofs/000077500000000000000000000000001157065440000165605ustar00rootroot00000000000000am-utils-6.2+rc20110530/conf/autofs/autofs_default.c000066400000000000000000000043071157065440000217350ustar00rootroot00000000000000/* * Copyright (c) 1999-2003 Ion Badulescu * Copyright (c) 1997-2011 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. 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 * 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/conf/autofs/autofs_default.c * */ /* * Default Automounter filesystem (empty) */ am-utils-6.2+rc20110530/conf/autofs/autofs_default.h000066400000000000000000000050021157065440000217330ustar00rootroot00000000000000/* * Copyright (c) 1999-2003 Ion Badulescu * Copyright (c) 1997-2011 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. 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 * 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/conf/autofs/autofs_default.h * */ /* * Default automounter filesystem */ /* * Autofs is not supported on this platform, * so disable it if it gets detected. */ #ifdef MNTTYPE_AUTOFS # undef MNTTYPE_AUTOFS #endif /* MNTTYPE_AUTOFS */ #ifdef MNTTAB_TYPE_AUTOFS # undef MNTTAB_TYPE_AUTOFS #endif /* MNTTAB_TYPE_AUTOFS */ #ifdef HAVE_FS_AUTOFS # undef HAVE_FS_AUTOFS #endif /* HAVE_FS_AUTOFS */ am-utils-6.2+rc20110530/conf/autofs/autofs_linux.c000066400000000000000000000441141157065440000214500ustar00rootroot00000000000000/* * Copyright (c) 1999-2003 Ion Badulescu * Copyright (c) 1997-2011 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. 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 * 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/conf/autofs/autofs_linux.c * */ /* * Automounter filesystem for Linux */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #ifdef HAVE_FS_AUTOFS /* * MACROS: */ #define AUTOFS_MIN_VERSION 3 #define AUTOFS_MAX_VERSION AUTOFS_MAX_PROTO_VERSION /* * STRUCTURES: */ /* * VARIABLES: */ static int autofs_max_fds; static am_node **hash; static int *list; static int numfds = 0; static int bind_works = 1; static void hash_init(void) { int i; struct rlimit rlim; if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) { plog(XLOG_ERROR, "getrlimit failed, defaulting to 256 fd's"); autofs_max_fds = 256; } else { autofs_max_fds = (rlim.rlim_cur > 1024) ? 1024 : rlim.rlim_cur; plog(XLOG_INFO, "%d fd's available for autofs", autofs_max_fds); } list = malloc(autofs_max_fds * sizeof(*list)); hash = malloc(autofs_max_fds * sizeof(*hash)); for (i = 0 ; i < autofs_max_fds; i++) { hash[i] = NULL; list[i] = -1; } } static void hash_insert(int fd, am_node *mp) { if (hash[fd] != 0) plog(XLOG_ERROR, "file descriptor %d already in the hash", fd); hash[fd] = mp; list[numfds] = fd; numfds++; } static void hash_delete(int fd) { int i; if (hash[fd] == 0) plog(XLOG_WARNING, "file descriptor %d not in the hash", fd); hash[fd] = NULL; numfds--; for (i = 0; i < numfds; i++) if (list[i] == fd) { list[i] = list[numfds]; break; } } int autofs_get_fh(am_node *mp) { int fds[2]; autofs_fh_t *fh; plog(XLOG_DEBUG, "autofs_get_fh for %s", mp->am_path); if (pipe(fds) < 0) return errno; /* sanity check */ if (fds[0] > autofs_max_fds) { close(fds[0]); close(fds[1]); return EMFILE; } fh = ALLOC(autofs_fh_t); fh->fd = fds[0]; fh->kernelfd = fds[1]; fh->ioctlfd = -1; fh->pending_mounts = NULL; fh->pending_umounts = NULL; mp->am_autofs_fh = fh; return 0; } void autofs_mounted(am_node *mp) { autofs_fh_t *fh = mp->am_autofs_fh; unsigned long timeout = gopt.am_timeo; close(fh->kernelfd); fh->kernelfd = -1; autofs_get_mp(mp); /* Get autofs protocol version */ if (ioctl(fh->ioctlfd, AUTOFS_IOC_PROTOVER, &fh->version) < 0) { plog(XLOG_ERROR, "AUTOFS_IOC_PROTOVER: %s", strerror(errno)); fh->version = AUTOFS_MIN_VERSION; plog(XLOG_ERROR, "autofs: assuming protocol version %d", fh->version); } else plog(XLOG_INFO, "autofs: using protocol version %d", fh->version); /* set expiration timeout */ if (ioctl(fh->ioctlfd, AUTOFS_IOC_SETTIMEOUT, &timeout) < 0) plog(XLOG_ERROR, "AUTOFS_IOC_SETTIMEOUT: %s", strerror(errno)); /* tell the daemon to call us for expirations */ mp->am_autofs_ttl = clocktime(NULL) + gopt.am_timeo_w; } void autofs_get_mp(am_node *mp) { autofs_fh_t *fh = mp->am_autofs_fh; dlog("autofs: getting mount point"); if (fh->ioctlfd < 0) fh->ioctlfd = open(mp->am_path, O_RDONLY); hash_insert(fh->fd, mp); } void autofs_release_mp(am_node *mp) { autofs_fh_t *fh = mp->am_autofs_fh; dlog("autofs: releasing mount point"); if (fh->ioctlfd >= 0) { close(fh->ioctlfd); fh->ioctlfd = -1; } /* * take the kernel fd out of the hash/fdset * so select() doesn't go crazy if the umount succeeds */ if (fh->fd >= 0) hash_delete(fh->fd); } void autofs_release_fh(am_node *mp) { autofs_fh_t *fh = mp->am_autofs_fh; struct autofs_pending_mount **pp, *p; struct autofs_pending_umount **upp, *up; dlog("autofs: releasing file handle"); if (fh) { /* * if a mount succeeded, the kernel fd was closed on * the amd side, so it might have been reused. * we set it to -1 after closing it, to avoid the problem. */ if (fh->kernelfd >= 0) close(fh->kernelfd); if (fh->ioctlfd >= 0) close(fh->ioctlfd); if (fh->fd >= 0) close(fh->fd); pp = &fh->pending_mounts; while (*pp) { p = *pp; XFREE(p->name); *pp = p->next; XFREE(p); } upp = &fh->pending_umounts; while (*upp) { up = *upp; XFREE(up->name); *upp = up->next; XFREE(up); } XFREE(fh); mp->am_autofs_fh = NULL; } } void autofs_add_fdset(fd_set *readfds) { int i; for (i = 0; i < numfds; i++) FD_SET(list[i], readfds); } static int autofs_get_pkt(int fd, char *buf, int bytes) { int i; do { i = read(fd, buf, bytes); if (i <= 0) break; buf += i; bytes -= i; } while (bytes); return bytes; } static void send_fail(int fd, unsigned long token) { if (token == 0) return; if (ioctl(fd, AUTOFS_IOC_FAIL, token) < 0) plog(XLOG_ERROR, "AUTOFS_IOC_FAIL: %s", strerror(errno)); } static void send_ready(int fd, unsigned long token) { if (token == 0) return; if (ioctl(fd, AUTOFS_IOC_READY, token) < 0) plog(XLOG_ERROR, "AUTOFS_IOC_READY: %s", strerror(errno)); } static void autofs_lookup_failed(am_node *mp, char *name) { autofs_fh_t *fh = mp->am_autofs_fh; struct autofs_pending_mount **pp, *p; pp = &fh->pending_mounts; while (*pp && !STREQ((*pp)->name, name)) pp = &(*pp)->next; /* sanity check */ if (*pp == NULL) return; p = *pp; plog(XLOG_INFO, "autofs: lookup of %s failed", name); send_fail(fh->ioctlfd, p->wait_queue_token); XFREE(p->name); *pp = p->next; XFREE(p); } static void autofs_expire_one(am_node *mp, char *name, unsigned long token) { autofs_fh_t *fh; am_node *ap; struct autofs_pending_umount *p; char *ap_path; fh = mp->am_autofs_fh; ap_path = str3cat(NULL, mp->am_path, "/", name); if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "\tumount(%s)", ap_path); p = fh->pending_umounts; while (p && p->wait_queue_token != token) p = p->next; if (p) { /* already pending */ dlog("Umounting of %s already pending", ap_path); amd_stats.d_drops++; goto out; } ap = find_ap(ap_path); if (ap == NULL) { /* not found??? not sure what to do here... */ send_fail(fh->ioctlfd, token); goto out; } p = ALLOC(struct autofs_pending_umount); p->wait_queue_token = token; p->name = strdup(name); p->next = fh->pending_umounts; fh->pending_umounts = p; unmount_mp(ap); out: XFREE(ap_path); } static void autofs_handle_expire(am_node *mp, struct autofs_packet_expire *pkt) { autofs_expire_one(mp, pkt->name, 0); } #if AUTOFS_MAX_VERSION >= 4 static void autofs_handle_expire_multi(am_node *mp, struct autofs_packet_expire_multi *pkt) { autofs_expire_one(mp, pkt->name, pkt->wait_queue_token); } #endif /* AUTOFS_MAX_VERSION >= 4 */ static void autofs_handle_missing(am_node *mp, struct autofs_packet_missing *pkt) { autofs_fh_t *fh; mntfs *mf; am_node *ap; struct autofs_pending_mount *p; int error; mf = mp->am_al->al_mnt; fh = mp->am_autofs_fh; p = fh->pending_mounts; while (p && p->wait_queue_token != pkt->wait_queue_token) p = p->next; if (p) { /* already pending */ dlog("Mounting of %s/%s already pending", mp->am_path, pkt->name); amd_stats.d_drops++; return; } p = ALLOC(struct autofs_pending_mount); p->wait_queue_token = pkt->wait_queue_token; p->name = strdup(pkt->name); p->next = fh->pending_mounts; fh->pending_mounts = p; if (amuDebug(D_TRACE)) plog(XLOG_DEBUG, "\tlookup(%s, %s)", mp->am_path, pkt->name); ap = mf->mf_ops->lookup_child(mp, pkt->name, &error, VLOOK_CREATE); if (ap && error < 0) ap = mf->mf_ops->mount_child(ap, &error); /* some of the rest can be done in amfs_auto_cont */ if (ap == 0) { if (error < 0) { dlog("Mount still pending, not sending autofs reply yet"); return; } autofs_lookup_failed(mp, pkt->name); } mp->am_stats.s_lookup++; } int autofs_handle_fdset(fd_set *readfds, int nsel) { int i; union autofs_packet_union pkt; autofs_fh_t *fh; am_node *mp; for (i = 0; nsel && i < numfds; i++) { if (!FD_ISSET(list[i], readfds)) continue; nsel--; FD_CLR(list[i], readfds); mp = hash[list[i]]; fh = mp->am_autofs_fh; if (autofs_get_pkt(fh->fd, (char *) &pkt, sizeof(union autofs_packet_union))) continue; switch (pkt.hdr.type) { case autofs_ptype_missing: autofs_handle_missing(mp, &pkt.missing); break; case autofs_ptype_expire: autofs_handle_expire(mp, &pkt.expire); break; #if AUTOFS_MAX_VERSION >= 4 case autofs_ptype_expire_multi: autofs_handle_expire_multi(mp, &pkt.expire_multi); break; #endif /* AUTOFS_MAX_VERSION >= 4 */ default: plog(XLOG_ERROR, "Unknown autofs packet type %d", pkt.hdr.type); } } return nsel; } int create_autofs_service(void) { hash_init(); /* not the best place, but... */ if (linux_version_code() < KERNEL_VERSION(2,4,0)) bind_works = 0; return 0; } int destroy_autofs_service(void) { /* Nothing to do */ return 0; } static int autofs_bind_umount(char *mountpoint) { int err = 1; #ifdef MNT2_GEN_OPT_BIND if (bind_works && gopt.flags & CFM_AUTOFS_USE_LOFS) { struct stat buf; if ((err = lstat(mountpoint, &buf))) return errno; if (S_ISLNK(buf.st_mode)) goto use_symlink; plog(XLOG_INFO, "autofs: un-bind-mounting %s", mountpoint); err = umount_fs(mountpoint, mnttab_file_name, 1); if (err) plog(XLOG_INFO, "autofs: unmounting %s failed: %m", mountpoint); else err = rmdir(mountpoint); goto out; } #endif /* MNT2_GEN_OPT_BIND */ use_symlink: plog(XLOG_INFO, "autofs: deleting symlink %s", mountpoint); err = unlink(mountpoint); out: if (err) return errno; return 0; } int autofs_mount_fs(am_node *mp, mntfs *mf) { char *target, *target2 = NULL; int err = 0; if (mf->mf_flags & MFF_ON_AUTOFS) { if ((err = mkdir(mp->am_path, 0555))) return errno; } /* * For sublinks, we could end up here with an already mounted f/s. * Don't do anything in that case. */ if (!(mf->mf_flags & MFF_MOUNTED)) err = mf->mf_ops->mount_fs(mp, mf); if (err) { if (mf->mf_flags & MFF_ON_AUTOFS) rmdir(mp->am_path); return err; } if (mf->mf_flags & MFF_ON_AUTOFS) /* Nothing else to do */ return 0; if (mp->am_link) target = mp->am_link; else target = mf->mf_fo->opt_fs; #ifdef MNT2_GEN_OPT_BIND if (bind_works && gopt.flags & CFM_AUTOFS_USE_LOFS) { struct stat buf; /* * HACK ALERT! * * Since the bind mount mechanism doesn't allow mountpoint crossing, * we _must_ use symlinks for the host mount case. Otherwise we end up * with a bunch of empty mountpoints... */ if (mf->mf_ops == &amfs_host_ops) goto use_symlink; if (target[0] != '/') target2 = str3cat(NULL, mp->am_parent->am_path, "/", target); else target2 = strdup(target); /* * We need to stat() the destination, because the bind mount does not * follow symlinks and/or allow for non-existent destinations. * We fall back to symlinks if there are problems. * * We also need to temporarily change pgrp, otherwise our stat() won't * trigger whatever cascading mounts are needed. * * WARNING: we will deadlock if this function is called from the master * amd process and it happens to trigger another auto mount. Therefore, * this function should be called only from a child amd process, or * at the very least it should not be called from the parent unless we * know for sure that it won't cause a recursive mount. We refuse to * cause the recursive mount anyway if called from the parent amd. */ if (!foreground) { pid_t pgrp = getpgrp(); setpgrp(); err = stat(target2, &buf); if ((err = setpgid(0, pgrp))) { plog(XLOG_ERROR, "autofs: cannot restore pgrp: %s", strerror(errno)); plog(XLOG_ERROR, "autofs: aborting the mount"); goto out; } if (err) goto use_symlink; } if ((err = lstat(target2, &buf))) goto use_symlink; if (S_ISLNK(buf.st_mode)) goto use_symlink; plog(XLOG_INFO, "autofs: bind-mounting %s -> %s", mp->am_path, target2); mkdir(mp->am_path, 0555); err = mount_lofs(mp->am_path, target2, mf->mf_mopts, 1); if (err) { rmdir(mp->am_path); plog(XLOG_INFO, "autofs: bind-mounting %s -> %s failed", mp->am_path, target2); goto use_symlink; } goto out; } #endif /* MNT2_GEN_OPT_BIND */ use_symlink: plog(XLOG_INFO, "autofs: symlinking %s -> %s", mp->am_path, target); err = symlink(target, mp->am_path); out: if (target2) XFREE(target2); if (err) return errno; return 0; } int autofs_umount_fs(am_node *mp, mntfs *mf) { int err = 0; if (!(mf->mf_flags & MFF_ON_AUTOFS)) { err = autofs_bind_umount(mp->am_path); if (err) return err; } /* * Multiple sublinks could reference this f/s. * Don't actually unmount it unless we're holding the last reference. */ if (mf->mf_refc == 1) { err = mf->mf_ops->umount_fs(mp, mf); if (err) return err; if (mf->mf_flags & MFF_ON_AUTOFS) rmdir(mp->am_path); } return 0; } int autofs_umount_succeeded(am_node *mp) { autofs_fh_t *fh = mp->am_parent->am_autofs_fh; struct autofs_pending_umount **pp, *p; pp = &fh->pending_umounts; while (*pp && !STREQ((*pp)->name, mp->am_name)) pp = &(*pp)->next; /* sanity check */ if (*pp == NULL) return -1; p = *pp; plog(XLOG_INFO, "autofs: unmounting %s succeeded", mp->am_path); send_ready(fh->ioctlfd, p->wait_queue_token); XFREE(p->name); *pp = p->next; XFREE(p); return 0; } int autofs_umount_failed(am_node *mp) { autofs_fh_t *fh = mp->am_parent->am_autofs_fh; struct autofs_pending_umount **pp, *p; pp = &fh->pending_umounts; while (*pp && !STREQ((*pp)->name, mp->am_name)) pp = &(*pp)->next; /* sanity check */ if (*pp == NULL) return -1; p = *pp; plog(XLOG_INFO, "autofs: unmounting %s failed", mp->am_path); send_fail(fh->ioctlfd, p->wait_queue_token); XFREE(p->name); *pp = p->next; XFREE(p); return 0; } void autofs_mount_succeeded(am_node *mp) { autofs_fh_t *fh = mp->am_parent->am_autofs_fh; struct autofs_pending_mount **pp, *p; /* * don't expire the entries -- the kernel will do it for us. * * but it won't do autofs filesystems, so we expire them the old * fashioned way instead. */ if (!(mp->am_al->al_mnt->mf_flags & MFF_IS_AUTOFS)) mp->am_flags |= AMF_NOTIMEOUT; pp = &fh->pending_mounts; while (*pp && !STREQ((*pp)->name, mp->am_name)) pp = &(*pp)->next; /* sanity check */ if (*pp == NULL) return; p = *pp; plog(XLOG_INFO, "autofs: mounting %s succeeded", mp->am_path); send_ready(fh->ioctlfd, p->wait_queue_token); XFREE(p->name); *pp = p->next; XFREE(p); } void autofs_mount_failed(am_node *mp) { autofs_fh_t *fh = mp->am_parent->am_autofs_fh; struct autofs_pending_mount **pp, *p; pp = &fh->pending_mounts; while (*pp && !STREQ((*pp)->name, mp->am_name)) pp = &(*pp)->next; /* sanity check */ if (*pp == NULL) return; p = *pp; plog(XLOG_INFO, "autofs: mounting %s failed", mp->am_path); send_fail(fh->ioctlfd, p->wait_queue_token); XFREE(p->name); *pp = p->next; XFREE(p); } void autofs_get_opts(char *opts, size_t l, autofs_fh_t *fh) { xsnprintf(opts, l, "fd=%d,minproto=%d,maxproto=%d", fh->kernelfd, AUTOFS_MIN_VERSION, AUTOFS_MAX_VERSION); } int autofs_compute_mount_flags(mntent_t *mnt) { return 0; } #if AUTOFS_MAX_VERSION >= 4 static int autofs_timeout_mp_task(void *arg) { am_node *mp = (am_node *)arg; autofs_fh_t *fh = mp->am_autofs_fh; int now = 0; while (ioctl(fh->ioctlfd, AUTOFS_IOC_EXPIRE_MULTI, &now) == 0); return 0; } #endif /* AUTOFS_MAX_VERSION >= 4 */ void autofs_timeout_mp(am_node *mp) { autofs_fh_t *fh = mp->am_autofs_fh; time_t now = clocktime(NULL); /* update the ttl */ mp->am_autofs_ttl = now + gopt.am_timeo_w; if (fh->version < 4) { struct autofs_packet_expire pkt; while (ioctl(fh->ioctlfd, AUTOFS_IOC_EXPIRE, &pkt) == 0) autofs_handle_expire(mp, &pkt); return; } #if AUTOFS_MAX_VERSION >= 4 run_task(autofs_timeout_mp_task, mp, NULL, NULL); #endif /* AUTOFS_MAX_VERSION >= 4 */ } #endif /* HAVE_FS_AUTOFS */ am-utils-6.2+rc20110530/conf/autofs/autofs_linux.h000066400000000000000000000115441157065440000214560ustar00rootroot00000000000000/* * Copyright (c) 1999-2003 Ion Badulescu * Copyright (c) 1997-2011 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. 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 * 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/conf/autofs/autofs_linux.h * */ /* * Automounter filesystem headers for Linux */ #if !defined(HAVE_LINUX_AUTO_FS_H) && !defined(HAVE_LINUX_AUTO_FS4_H) /* We didn't find the headers, so we can't compile in the autofs support */ # undef HAVE_FS_AUTOFS # undef MNTTAB_TYPE_AUTOFS #endif /* !HAVE_LINUX_AUTO_FS_H && !HAVE_LINUX_AUTO_FS4_H */ #ifdef HAVE_FS_AUTOFS struct autofs_pending_mount { unsigned long wait_queue_token; /* Associated kernel wait token */ char *name; struct autofs_pending_mount *next; }; struct autofs_pending_umount { unsigned long wait_queue_token; /* Associated kernel wait token */ char *name; struct autofs_pending_umount *next; }; typedef struct { int fd; int kernelfd; int ioctlfd; int version; struct autofs_pending_mount *pending_mounts; struct autofs_pending_umount *pending_umounts; } autofs_fh_t; #ifndef HAVE_LINUX_AUTO_FS4_H union autofs_packet_union { struct autofs_packet_hdr hdr; struct autofs_packet_missing missing; struct autofs_packet_expire expire; }; #endif /* not HAVE_LINUX_AUTO_FS4_H */ #define AUTOFS_AUTO_FS_FLAGS (FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS | FS_ON_AUTOFS) #define AUTOFS_DIRECT_FS_FLAGS (FS_DIRECT | FS_MKMNT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO) #define AUTOFS_ERROR_FS_FLAGS (FS_DISCARD) #define AUTOFS_HOST_FS_FLAGS (FS_MKMNT | FS_BACKGROUND | FS_AMQINFO) #define AUTOFS_LINK_FS_FLAGS (FS_MBACKGROUND) #define AUTOFS_LINKX_FS_FLAGS (FS_MBACKGROUND) #define AUTOFS_NFSL_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_NFSX_FS_FLAGS (/* FS_UBACKGROUND| */ FS_AMQINFO ) #define AUTOFS_PROGRAM_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO) #define AUTOFS_ROOT_FS_FLAGS (FS_NOTIMEOUT | FS_AMQINFO | FS_DIRECTORY) #define AUTOFS_TOPLVL_FS_FLAGS (FS_MKMNT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS) #define AUTOFS_UNION_FS_FLAGS (FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_ON_AUTOFS) #define AUTOFS_CACHEFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_CDFS_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_UDF_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_EFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_LOFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_NFS_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_PCFS_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_UFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_XFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_TMPFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #endif /* HAVE_FS_AUTOFS */ am-utils-6.2+rc20110530/conf/autofs/autofs_solaris_v1.c000066400000000000000000000406261157065440000223770ustar00rootroot00000000000000/* * Copyright (c) 1999-2003 Ion Badulescu * Copyright (c) 1997-2011 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. 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 * 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/conf/autofs/autofs_solaris_v1.c * */ /* * Automounter filesystem */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #ifdef HAVE_FS_AUTOFS /* * MACROS: */ #ifndef AUTOFS_NULL # define AUTOFS_NULL NULLPROC #endif /* not AUTOFS_NULL */ /* * STRUCTURES: */ /* * VARIABLES: */ /* forward declarations */ # ifndef HAVE_XDR_MNTREQUEST bool_t xdr_mntrequest(XDR *xdrs, mntrequest *objp); # endif /* not HAVE_XDR_MNTREQUEST */ # ifndef HAVE_XDR_MNTRES bool_t xdr_mntres(XDR *xdrs, mntres *objp); # endif /* not HAVE_XDR_MNTRES */ # ifndef HAVE_XDR_UMNTREQUEST bool_t xdr_umntrequest(XDR *xdrs, umntrequest *objp); # endif /* not HAVE_XDR_UMNTREQUEST */ # ifndef HAVE_XDR_UMNTRES bool_t xdr_umntres(XDR *xdrs, umntres *objp); # endif /* not HAVE_XDR_UMNTRES */ static int autofs_mount_1_req(struct mntrequest *mr, struct mntres *result, struct authunix_parms *cred, SVCXPRT *transp); static int autofs_unmount_1_req(struct umntrequest *ur, struct umntres *result, struct authunix_parms *cred, SVCXPRT *transp); /**************************************************************************** *** VARIABLES *** ****************************************************************************/ /**************************************************************************** *** FUNCTIONS *** ****************************************************************************/ /* * AUTOFS XDR FUNCTIONS: */ #ifndef HAVE_XDR_MNTREQUEST bool_t xdr_mntrequest(XDR *xdrs, mntrequest *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_mntrequest:"); if (!xdr_string(xdrs, &objp->name, A_MAXNAME)) return (FALSE); if (!xdr_string(xdrs, &objp->map, A_MAXNAME)) return (FALSE); if (!xdr_string(xdrs, &objp->opts, A_MAXOPTS)) return (FALSE); if (!xdr_string(xdrs, &objp->path, A_MAXPATH)) return (FALSE); return (TRUE); } #endif /* not HAVE_XDR_MNTREQUEST */ #ifndef HAVE_XDR_MNTRES bool_t xdr_mntres(XDR *xdrs, mntres *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_mntres:"); if (!xdr_int(xdrs, &objp->status)) return (FALSE); return (TRUE); } # endif /* not HAVE_XDR_MNTRES */ #ifndef HAVE_XDR_UMNTREQUEST bool_t xdr_umntrequest(XDR *xdrs, umntrequest *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_umntrequest:"); if (!xdr_int(xdrs, (int *) &objp->isdirect)) return (FALSE); if (!xdr_u_int(xdrs, (u_int *) &objp->devid)) return (FALSE); #ifdef HAVE_UMNTREQUEST_RDEVID if (!xdr_u_long(xdrs, &objp->rdevid)) return (FALSE); #endif /* HAVE_UMNTREQUEST_RDEVID */ if (!xdr_pointer(xdrs, (char **) &objp->next, sizeof(umntrequest), (XDRPROC_T_TYPE) xdr_umntrequest)) return (FALSE); return (TRUE); } #endif /* not HAVE_XDR_UMNTREQUEST */ #ifndef HAVE_XDR_UMNTRES bool_t xdr_umntres(XDR *xdrs, umntres *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_mntres:"); if (!xdr_int(xdrs, &objp->status)) return (FALSE); return (TRUE); } #endif /* not HAVE_XDR_UMNTRES */ /* * AUTOFS RPC methods */ static int autofs_mount_1_req(struct mntrequest *m, struct mntres *res, struct authunix_parms *cred, SVCXPRT *transp) { int err = 0; int isdirect = 0; am_node *mp, *ap; mntfs *mf; dlog("MOUNT REQUEST: name=%s map=%s opts=%s path=%s", m->name, m->map, m->opts, m->path); /* find the effective uid/gid from RPC request */ xsnprintf(opt_uid, sizeof(uid_str), "%d", (int) cred->aup_uid); xsnprintf(opt_gid, sizeof(gid_str), "%d", (int) cred->aup_gid); mp = find_ap(m->path); if (!mp) { plog(XLOG_ERROR, "map %s not found", m->path); err = ENOENT; goto out; } mf = mp->am_al->al_mnt; isdirect = (mf->mf_fsflags & FS_DIRECT) ? 1 : 0; ap = mf->mf_ops->lookup_child(mp, m->name + isdirect, &err, VLOOK_CREATE); if (ap && err < 0) ap = mf->mf_ops->mount_child(ap, &err); if (ap == NULL) { if (err < 0) { /* we're working on it */ amd_stats.d_drops++; return 1; } err = ENOENT; goto out; } out: if (err) { if (isdirect) { /* direct mount */ plog(XLOG_ERROR, "mount of %s failed", m->path); } else { /* indirect mount */ plog(XLOG_ERROR, "mount of %s/%s failed", m->path, m->name); } } dlog("MOUNT REPLY: status=%d (%s)", err, strerror(err)); res->status = err; return 0; } static int autofs_unmount_1_req(struct umntrequest *ul, struct umntres *res, struct authunix_parms *cred, SVCXPRT *transp) { int mapno, err; am_node *mp = NULL; dlog("UNMOUNT REQUEST: dev=%lx rdev=%lx %s", (u_long) ul->devid, (u_long) ul->rdevid, ul->isdirect ? "direct" : "indirect"); /* by default, and if not found, succeed */ res->status = 0; for (mapno = 0; ; mapno++) { mp = get_exported_ap(mapno); if (!mp) break; if (mp->am_dev == ul->devid && (ul->rdevid == 0 || mp->am_rdev == ul->rdevid)) break; } if (mp) { /* save RPC context */ if (!mp->am_transp && transp) { mp->am_transp = (SVCXPRT *) xmalloc(sizeof(SVCXPRT)); *(mp->am_transp) = *transp; } mapno = mp->am_mapno; err = unmount_mp(mp); if (err) /* backgrounded, don't reply yet */ return 1; if (get_exported_ap(mapno)) /* unmounting failed, tell the kernel */ res->status = 1; } dlog("UNMOUNT REPLY: status=%d", res->status); return 0; } /****************************************************************************/ /* autofs program dispatcher */ static void autofs_program_1(struct svc_req *rqstp, SVCXPRT *transp) { union { mntrequest autofs_mount_1_arg; umntrequest autofs_umount_1_arg; } argument; union { mntres mount_res; umntres umount_res; } result; int ret; bool_t (*xdr_argument)(); bool_t (*xdr_result)(); int (*local)(); current_transp = transp; switch (rqstp->rq_proc) { case AUTOFS_NULL: svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_void, (SVC_IN_ARG_TYPE) NULL); return; case AUTOFS_MOUNT: xdr_argument = xdr_mntrequest; xdr_result = xdr_mntres; local = autofs_mount_1_req; break; case AUTOFS_UNMOUNT: xdr_argument = xdr_umntrequest; xdr_result = xdr_umntres; local = autofs_unmount_1_req; break; default: svcerr_noproc(transp); return; } memset((char *) &argument, 0, sizeof(argument)); if (!svc_getargs(transp, (XDRPROC_T_TYPE) xdr_argument, (SVC_IN_ARG_TYPE) &argument)) { plog(XLOG_ERROR, "AUTOFS xdr decode failed for %d %d %d", (int) rqstp->rq_prog, (int) rqstp->rq_vers, (int) rqstp->rq_proc); svcerr_decode(transp); return; } memset((char *)&result, 0, sizeof(result)); ret = (*local) (&argument, &result, rqstp, transp); current_transp = NULL; /* send reply only if the RPC method returned 0 */ if (!ret) { if (!svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_result, (SVC_IN_ARG_TYPE) &result)) { svcerr_systemerr(transp); } } if (!svc_freeargs(transp, (XDRPROC_T_TYPE) xdr_argument, (SVC_IN_ARG_TYPE) &argument)) { plog(XLOG_FATAL, "unable to free rpc arguments in autofs_program_1"); } } int autofs_get_fh(am_node *mp) { autofs_fh_t *fh; char buf[MAXHOSTNAMELEN]; mntfs *mf = mp->am_al->al_mnt; struct utsname utsname; plog(XLOG_DEBUG, "autofs_get_fh for %s", mp->am_path); fh = ALLOC(autofs_fh_t); memset((voidp) fh, 0, sizeof(autofs_fh_t)); /* Paranoid */ /* * SET MOUNT ARGS */ if (uname(&utsname) < 0) { xstrlcpy(buf, "localhost.autofs", sizeof(buf)); } else { xstrlcpy(buf, utsname.nodename, sizeof(buf)); xstrlcat(buf, ".autofs", sizeof(buf)); } #ifdef HAVE_AUTOFS_ARGS_T_ADDR fh->addr.buf = strdup(buf); fh->addr.len = fh->addr.maxlen = strlen(buf); #endif /* HAVE_AUTOFS_ARGS_T_ADDR */ fh->direct = (mf->mf_fsflags & FS_DIRECT) ? 1 : 0; fh->rpc_to = 1; /* XXX: arbitrary */ fh->mount_to = mp->am_timeo; fh->path = mp->am_path; fh->opts = ""; /* XXX: arbitrary */ fh->map = mp->am_path; /* this is what we get back in readdir */ mp->am_autofs_fh = fh; return 0; } void autofs_mounted(am_node *mp) { /* We don't want any timeouts on autofs nodes */ mp->am_autofs_ttl = NEVER; } void autofs_release_fh(am_node *mp) { autofs_fh_t *fh = mp->am_autofs_fh; #ifdef HAVE_AUTOFS_ARGS_T_ADDR XFREE(fh->addr.buf); #endif /* HAVE_AUTOFS_ARGS_T_ADDR */ XFREE(fh); mp->am_autofs_fh = NULL; } void autofs_get_mp(am_node *mp) { /* nothing to do */ } void autofs_release_mp(am_node *mp) { /* nothing to do */ } void autofs_add_fdset(fd_set *readfds) { /* nothing to do */ } int autofs_handle_fdset(fd_set *readfds, int nsel) { /* nothing to do */ return nsel; } /* * Create the autofs service for amd */ int create_autofs_service(void) { dlog("creating autofs service listener"); return register_autofs_service(AUTOFS_CONFTYPE, autofs_program_1); } int destroy_autofs_service(void) { dlog("destroying autofs service listener"); return unregister_autofs_service(AUTOFS_CONFTYPE); } int autofs_mount_fs(am_node *mp, mntfs *mf) { int err = 0; char *target, *target2 = NULL; char *space_hack = autofs_strdup_space_hack(mp->am_path); struct stat buf; if (mf->mf_flags & MFF_ON_AUTOFS) { if ((err = mkdir(space_hack, 0555))) goto out; } /* * For sublinks, we could end up here with an already mounted f/s. * Don't do anything in that case. */ if (!(mf->mf_flags & MFF_MOUNTED)) err = mf->mf_ops->mount_fs(mp, mf); if (err) { if (mf->mf_flags & MFF_ON_AUTOFS) rmdir(space_hack); errno = err; goto out; } /* * Autofs v1 doesn't support symlinks, * so we ignore the CFM_AUTOFS_USE_LOFS flag */ if (mf->mf_flags & MFF_ON_AUTOFS) /* Nothing to do */ goto out; if (mp->am_link) target = mp->am_link; else target = mf->mf_mount; if (target[0] != '/') target2 = str3cat(NULL, mp->am_parent->am_path, "/", target); else target2 = strdup(target); plog(XLOG_INFO, "autofs: converting from link to lofs (%s -> %s)", mp->am_path, target2); /* * we need to stat() the destination, because the bind mount does not * follow symlinks and/or allow for non-existent destinations. * * WARNING: we will deadlock if this function is called from the master * amd process and it happens to trigger another auto mount. Therefore, * this function should be called only from a child amd process, or * at the very least it should not be called from the parent unless we * know for sure that it won't cause a recursive mount. We refuse to * cause the recursive mount anyway if called from the parent amd. */ if (!foreground) { if ((err = stat(target2, &buf))) goto out; } if ((err = lstat(target2, &buf))) goto out; if ((err = mkdir(space_hack, 0555))) goto out; if ((err = mount_lofs(mp->am_path, target2, mf->mf_mopts, 1))) { errno = err; goto out; } out: XFREE(space_hack); if (target2) XFREE(target2); if (err) return errno; return 0; } int autofs_umount_fs(am_node *mp, mntfs *mf) { int err = 0; char *space_hack = autofs_strdup_space_hack(mp->am_path); /* * Autofs v1 doesn't support symlinks, * so we ignore the CFM_AUTOFS_USE_LOFS flag */ if (!(mf->mf_flags & MFF_ON_AUTOFS)) { err = UMOUNT_FS(mp->am_path, mnttab_file_name, 1); if (err) goto out; rmdir(space_hack); } /* * Multiple sublinks could reference this f/s. * Don't actually unmount it unless we're holding the last reference. */ if (mf->mf_refc == 1) { if ((err = mf->mf_ops->umount_fs(mp, mf))) goto out; if (mf->mf_flags & MFF_ON_AUTOFS) rmdir(space_hack); } out: XFREE(space_hack); return err; } int autofs_umount_succeeded(am_node *mp) { umntres res; SVCXPRT *transp = mp->am_transp; if (transp) { res.status = 0; if (!svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_umntres, (SVC_IN_ARG_TYPE) &res)) svcerr_systemerr(transp); dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount); XFREE(transp); mp->am_transp = NULL; } plog(XLOG_INFO, "autofs: unmounting %s succeeded", mp->am_path); return 0; } int autofs_umount_failed(am_node *mp) { umntres res; SVCXPRT *transp = mp->am_transp; if (transp) { res.status = 1; if (!svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_umntres, (SVC_IN_ARG_TYPE) &res)) svcerr_systemerr(transp); dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount); XFREE(transp); mp->am_transp = NULL; } plog(XLOG_INFO, "autofs: unmounting %s failed", mp->am_path); return 0; } void autofs_mount_succeeded(am_node *mp) { SVCXPRT *transp = mp->am_transp; struct stat stb; char *space_hack; if (transp) { /* this was a mount request */ mntres res; res.status = 0; if (!svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_mntres, (SVC_IN_ARG_TYPE) &res)) svcerr_systemerr(transp); dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount); XFREE(transp); mp->am_transp = NULL; } space_hack = autofs_strdup_space_hack(mp->am_path); if (!lstat(space_hack, &stb)) { mp->am_dev = stb.st_dev; mp->am_rdev = stb.st_rdev; } XFREE(space_hack); /* don't expire the entries -- the kernel will do it for us */ mp->am_flags |= AMF_NOTIMEOUT; plog(XLOG_INFO, "autofs: mounting %s succeeded", mp->am_path); } void autofs_mount_failed(am_node *mp) { SVCXPRT *transp = mp->am_transp; if (transp) { /* this was a mount request */ mntres res; res.status = ENOENT; if (!svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_mntres, (SVC_IN_ARG_TYPE) &res)) svcerr_systemerr(transp); dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount); XFREE(transp); mp->am_transp = NULL; } plog(XLOG_INFO, "autofs: mounting %s failed", mp->am_path); } void autofs_get_opts(char *opts, size_t l, autofs_fh_t *fh) { xsnprintf(opts, l, "%sdirect", fh->direct ? "" : "in"); } int autofs_compute_mount_flags(mntent_t *mntp) { /* Must use overlay mounts */ return MNT2_GEN_OPT_OVERLAY; } void autofs_timeout_mp(am_node *mp) { /* We don't want any timeouts on autofs nodes */ mp->am_autofs_ttl = NEVER; } #endif /* HAVE_FS_AUTOFS */ am-utils-6.2+rc20110530/conf/autofs/autofs_solaris_v1.h000066400000000000000000000102531157065440000223750ustar00rootroot00000000000000/* * Copyright (c) 1999-2003 Ion Badulescu * Copyright (c) 1997-2011 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. 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 * 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/conf/autofs/autofs_solaris_v1.h * */ /* * Automounter filesystem header for Solaris v1 */ #ifndef autofs_args_t # undef HAVE_FS_AUTOFS # undef MNTTAB_TYPE_AUTOFS #endif /* !autofs_args_t */ #ifdef HAVE_FS_AUTOFS typedef autofs_args_t autofs_fh_t; #define NEED_AUTOFS_SPACE_HACK /* * autofs hack: append a space to the directory name * to stop the kernel->daemon recursion. * * Returns malloc'ed space which needs to be freed by the caller. */ #define autofs_strdup_space_hack(s) str3cat(NULL, (s), " ", "") #define AUTOFS_AUTO_FS_FLAGS (FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS | FS_ON_AUTOFS) #define AUTOFS_DIRECT_FS_FLAGS (FS_DIRECT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS) #define AUTOFS_ERROR_FS_FLAGS (FS_DISCARD) #define AUTOFS_HOST_FS_FLAGS (FS_MKMNT | FS_BACKGROUND | FS_AMQINFO) #define AUTOFS_LINK_FS_FLAGS (FS_MBACKGROUND) #define AUTOFS_LINKX_FS_FLAGS (FS_MBACKGROUND) #define AUTOFS_NFSL_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_NFSX_FS_FLAGS (/* FS_UBACKGROUND| */ FS_AMQINFO ) #define AUTOFS_PROGRAM_FS_FLAGS (FS_MKMNT | FS_BACKGROUND | FS_AMQINFO) #define AUTOFS_ROOT_FS_FLAGS (FS_NOTIMEOUT | FS_AMQINFO | FS_DIRECTORY) #define AUTOFS_TOPLVL_FS_FLAGS (FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS) #define AUTOFS_UNION_FS_FLAGS (FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_ON_AUTOFS) #define AUTOFS_CACHEFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_CDFS_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_EFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_LOFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_NFS_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_PCFS_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_UFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_XFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #endif /* HAVE_FS_AUTOFS */ am-utils-6.2+rc20110530/conf/autofs/autofs_solaris_v2_v3.c000066400000000000000000000744741157065440000230200ustar00rootroot00000000000000/* * Copyright (c) 1999-2003 Ion Badulescu * Copyright (c) 1997-2011 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. 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 * 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/conf/autofs/autofs_solaris_v2_v3.c * */ /* * Automounter filesystem */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * MACROS: */ #ifndef AUTOFS_NULL # define AUTOFS_NULL NULLPROC #endif /* not AUTOFS_NULL */ /* * STRUCTURES: */ struct amd_rddirres { enum autofs_res rd_status; u_long rd_bufsize; nfsdirlist rd_dl; }; typedef struct amd_rddirres amd_rddirres; /* * VARIABLES: */ SVCXPRT *autofs_xprt = NULL; /* forward declarations */ bool_t xdr_umntrequest(XDR *xdrs, umntrequest *objp); bool_t xdr_umntres(XDR *xdrs, umntres *objp); bool_t xdr_autofs_lookupargs(XDR *xdrs, autofs_lookupargs *objp); bool_t xdr_autofs_mountres(XDR *xdrs, autofs_mountres *objp); bool_t xdr_autofs_lookupres(XDR *xdrs, autofs_lookupres *objp); bool_t xdr_autofs_rddirargs(XDR *xdrs, autofs_rddirargs *objp); static bool_t xdr_amd_rddirres(XDR *xdrs, amd_rddirres *objp); /* * These exist only in the AutoFS V2 protocol. */ #ifdef AUTOFS_POSTUNMOUNT bool_t xdr_postumntreq(XDR *xdrs, postumntreq *objp); bool_t xdr_postumntres(XDR *xdrs, postumntres *objp); bool_t xdr_postmountreq(XDR *xdrs, postmountreq *objp); bool_t xdr_postmountres(XDR *xdrs, postmountres *objp); #endif /* AUTOFS_POSTUMOUNT */ /* * AUTOFS XDR FUNCTIONS: */ bool_t xdr_autofs_stat(XDR *xdrs, autofs_stat *objp) { if (!xdr_enum(xdrs, (enum_t *)objp)) return (FALSE); return (TRUE); } bool_t xdr_autofs_action(XDR *xdrs, autofs_action *objp) { if (!xdr_enum(xdrs, (enum_t *)objp)) return (FALSE); return (TRUE); } bool_t xdr_linka(XDR *xdrs, linka *objp) { if (!xdr_string(xdrs, &objp->dir, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->link, AUTOFS_MAXPATHLEN)) return (FALSE); return (TRUE); } bool_t xdr_autofs_netbuf(XDR *xdrs, struct netbuf *objp) { bool_t dummy; if (!xdr_u_long(xdrs, (u_long *) &objp->maxlen)) return (FALSE); dummy = xdr_bytes(xdrs, (char **)&(objp->buf), (u_int *)&(objp->len), objp->maxlen); return (dummy); } bool_t xdr_autofs_args(XDR *xdrs, autofs_args *objp) { if (!xdr_autofs_netbuf(xdrs, &objp->addr)) return (FALSE); if (!xdr_string(xdrs, &objp->path, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->opts, AUTOFS_MAXOPTSLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->map, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->subdir, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->key, AUTOFS_MAXCOMPONENTLEN)) return (FALSE); if (!xdr_int(xdrs, &objp->mount_to)) return (FALSE); if (!xdr_int(xdrs, &objp->rpc_to)) return (FALSE); if (!xdr_int(xdrs, &objp->direct)) return (FALSE); return (TRUE); } bool_t xdr_mounta(XDR *xdrs, struct mounta *objp) { if (!xdr_string(xdrs, &objp->spec, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->dir, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_int(xdrs, &objp->flags)) return (FALSE); if (!xdr_string(xdrs, &objp->fstype, AUTOFS_MAXCOMPONENTLEN)) return (FALSE); if (!xdr_pointer(xdrs, (char **)&objp->dataptr, sizeof(autofs_args), (XDRPROC_T_TYPE) xdr_autofs_args)) return (FALSE); if (!xdr_int(xdrs, &objp->datalen)) return (FALSE); return (TRUE); } bool_t xdr_action_list_entry(XDR *xdrs, action_list_entry *objp) { if (!xdr_autofs_action(xdrs, &objp->action)) return (FALSE); switch (objp->action) { case AUTOFS_MOUNT_RQ: if (!xdr_mounta(xdrs, &objp->action_list_entry_u.mounta)) return (FALSE); break; case AUTOFS_LINK_RQ: if (!xdr_linka(xdrs, &objp->action_list_entry_u.linka)) return (FALSE); break; default: break; } return (TRUE); } bool_t xdr_action_list(XDR *xdrs, action_list *objp) { if (!xdr_action_list_entry(xdrs, &objp->action)) return (FALSE); if (!xdr_pointer(xdrs, (char **)&objp->next, sizeof(action_list), (XDRPROC_T_TYPE) xdr_action_list)) return (FALSE); return (TRUE); } bool_t xdr_umntrequest(XDR *xdrs, umntrequest *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_umntrequest:"); if (!xdr_bool_t(xdrs, &objp->isdirect)) return (FALSE); #ifdef HAVE_STRUCT_UMNTREQUEST_DEVID if (!xdr_dev_t(xdrs, &objp->devid)) return (FALSE); if (!xdr_dev_t(xdrs, &objp->rdevid)) return (FALSE); #else /* not HAVE_STRUCT_UMNTREQUEST_DEVID */ if (!xdr_string(xdrs, &objp->mntresource, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->mntpnt, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->fstype, AUTOFS_MAXCOMPONENTLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->mntopts, AUTOFS_MAXOPTSLEN)) return (FALSE); #endif /* not HAVE_STRUCT_UMNTREQUEST_DEVID */ if (!xdr_pointer(xdrs, (char **) &objp->next, sizeof(umntrequest), (XDRPROC_T_TYPE) xdr_umntrequest)) return (FALSE); return (TRUE); } bool_t xdr_umntres(XDR *xdrs, umntres *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_mntres:"); if (!xdr_int(xdrs, &objp->status)) return (FALSE); return (TRUE); } /* * These exist only in the AutoFS V2 protocol. */ #ifdef AUTOFS_POSTUNMOUNT bool_t xdr_postumntreq(XDR *xdrs, postumntreq *objp) { if (!xdr_dev_t(xdrs, &objp->devid)) return (FALSE); if (!xdr_dev_t(xdrs, &objp->rdevid)) return (FALSE); if (!xdr_pointer(xdrs, (char **)&objp->next, sizeof(struct postumntreq), (XDRPROC_T_TYPE) xdr_postumntreq)) return (FALSE); return (TRUE); } bool_t xdr_postumntres(XDR *xdrs, postumntres *objp) { if (!xdr_int(xdrs, &objp->status)) return (FALSE); return (TRUE); } bool_t xdr_postmountreq(XDR *xdrs, postmountreq *objp) { if (!xdr_string(xdrs, &objp->special, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->mountp, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->fstype, AUTOFS_MAXCOMPONENTLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->mntopts, AUTOFS_MAXOPTSLEN)) return (FALSE); if (!xdr_dev_t(xdrs, &objp->devid)) return (FALSE); return (TRUE); } bool_t xdr_postmountres(XDR *xdrs, postmountres *objp) { if (!xdr_int(xdrs, &objp->status)) return (FALSE); return (TRUE); } #endif /* AUTOFS_POSTUNMOUNT */ bool_t xdr_autofs_res(XDR *xdrs, autofs_res *objp) { if (!xdr_enum(xdrs, (enum_t *)objp)) return (FALSE); return (TRUE); } bool_t xdr_autofs_lookupargs(XDR *xdrs, autofs_lookupargs *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_autofs_lookupargs:"); if (!xdr_string(xdrs, &objp->map, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->path, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->name, AUTOFS_MAXCOMPONENTLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->subdir, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_string(xdrs, &objp->opts, AUTOFS_MAXOPTSLEN)) return (FALSE); if (!xdr_bool_t(xdrs, &objp->isdirect)) return (FALSE); return (TRUE); } bool_t xdr_mount_result_type(XDR *xdrs, mount_result_type *objp) { if (!xdr_autofs_stat(xdrs, &objp->status)) return (FALSE); switch (objp->status) { case AUTOFS_ACTION: if (!xdr_pointer(xdrs, (char **)&objp->mount_result_type_u.list, sizeof(action_list), (XDRPROC_T_TYPE) xdr_action_list)) return (FALSE); break; case AUTOFS_DONE: if (!xdr_int(xdrs, &objp->mount_result_type_u.error)) return (FALSE); break; } return (TRUE); } bool_t xdr_autofs_mountres(XDR *xdrs, autofs_mountres *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_mntres:"); if (!xdr_mount_result_type(xdrs, &objp->mr_type)) return (FALSE); if (!xdr_int(xdrs, &objp->mr_verbose)) return (FALSE); return (TRUE); } bool_t xdr_lookup_result_type(XDR *xdrs, lookup_result_type *objp) { if (!xdr_autofs_action(xdrs, &objp->action)) return (FALSE); switch (objp->action) { case AUTOFS_LINK_RQ: if (!xdr_linka(xdrs, &objp->lookup_result_type_u.lt_linka)) return (FALSE); break; default: break; } return (TRUE); } bool_t xdr_autofs_lookupres(XDR *xdrs, autofs_lookupres *objp) { if (!xdr_autofs_res(xdrs, &objp->lu_res)) return (FALSE); if (!xdr_lookup_result_type(xdrs, &objp->lu_type)) return (FALSE); if (!xdr_int(xdrs, &objp->lu_verbose)) return (FALSE); return (TRUE); } bool_t xdr_autofs_rddirargs(XDR *xdrs, autofs_rddirargs *objp) { if (!xdr_string(xdrs, &objp->rda_map, AUTOFS_MAXPATHLEN)) return (FALSE); if (!xdr_u_int(xdrs, (u_int *) &objp->rda_offset)) return (FALSE); if (!xdr_u_int(xdrs, (u_int *) &objp->rda_count)) return (FALSE); return (TRUE); } /* * ENCODE ONLY * * Solaris automountd uses struct autofsrddir to pass the results. * We use the traditional nfsreaddirres and do the conversion ourselves. */ static bool_t xdr_amd_putrddirres(XDR *xdrs, nfsdirlist *dp, ulong reqsize) { nfsentry *ep; char *name; u_int namlen; bool_t true = TRUE; bool_t false = FALSE; int entrysz; int tofit; int bufsize; u_long ino, off; bufsize = 1 * BYTES_PER_XDR_UNIT; for (ep = dp->dl_entries; ep; ep = ep->ne_nextentry) { name = ep->ne_name; namlen = strlen(name); ino = (u_long) ep->ne_fileid; off = (u_long) ep->ne_cookie + AUTOFS_DAEMONCOOKIE; entrysz = (1 + 1 + 1 + 1) * BYTES_PER_XDR_UNIT + roundup(namlen, BYTES_PER_XDR_UNIT); tofit = entrysz + 2 * BYTES_PER_XDR_UNIT; if (bufsize + tofit > reqsize) { dp->dl_eof = FALSE; break; } if (!xdr_bool(xdrs, &true) || !xdr_u_long(xdrs, &ino) || !xdr_bytes(xdrs, &name, &namlen, AUTOFS_MAXPATHLEN) || !xdr_u_long(xdrs, &off)) { return (FALSE); } bufsize += entrysz; } if (!xdr_bool(xdrs, &false)) { return (FALSE); } if (!xdr_bool(xdrs, &dp->dl_eof)) { return (FALSE); } return (TRUE); } static bool_t xdr_amd_rddirres(XDR *xdrs, amd_rddirres *objp) { if (!xdr_enum(xdrs, (enum_t *)&objp->rd_status)) return (FALSE); if (objp->rd_status != AUTOFS_OK) return (TRUE); return (xdr_amd_putrddirres(xdrs, &objp->rd_dl, objp->rd_bufsize)); } /* * AUTOFS RPC methods */ static int autofs_lookup_2_req(autofs_lookupargs *m, autofs_lookupres *res, struct authunix_parms *cred, SVCXPRT *transp) { int err; am_node *mp, *new_mp; mntfs *mf; dlog("LOOKUP REQUEST: name=%s[%s] map=%s opts=%s path=%s direct=%d", m->name, m->subdir, m->map, m->opts, m->path, m->isdirect); /* find the effective uid/gid from RPC request */ xsnprintf(opt_uid, sizeof(uid_str), "%d", (int) cred->aup_uid); xsnprintf(opt_gid, sizeof(gid_str), "%d", (int) cred->aup_gid); mp = find_ap(m->path); if (!mp) { plog(XLOG_ERROR, "map %s not found", m->path); err = AUTOFS_NOENT; goto out; } mf = mp->am_al->al_mnt; new_mp = mf->mf_ops->lookup_child(mp, m->name, &err, VLOOK_LOOKUP); if (!new_mp) { err = AUTOFS_NOENT; goto out; } if (err == 0) { plog(XLOG_ERROR, "autofs requests to mount an already mounted node???"); } else { free_map(new_mp); } err = AUTOFS_OK; res->lu_type.action = AUTOFS_NONE; out: res->lu_res = err; res->lu_verbose = 1; dlog("LOOKUP REPLY: status=%d", res->lu_res); return 0; } static void autofs_lookup_2_free(autofs_lookupres *res) { struct linka link; if ((res->lu_res == AUTOFS_OK) && (res->lu_type.action == AUTOFS_LINK_RQ)) { /* * Free link information */ link = res->lu_type.lookup_result_type_u.lt_linka; if (link.dir) XFREE(link.dir); if (link.link) XFREE(link.link); } } static int autofs_mount_2_req(autofs_lookupargs *m, autofs_mountres *res, struct authunix_parms *cred, SVCXPRT *transp) { int err = AUTOFS_OK; am_node *mp, *new_mp; mntfs *mf; dlog("MOUNT REQUEST: name=%s[%s] map=%s opts=%s path=%s direct=%d", m->name, m->subdir, m->map, m->opts, m->path, m->isdirect); /* find the effective uid/gid from RPC request */ xsnprintf(opt_uid, sizeof(uid_str), "%d", (int) cred->aup_uid); xsnprintf(opt_gid, sizeof(gid_str), "%d", (int) cred->aup_gid); mp = find_ap(m->path); if (!mp) { plog(XLOG_ERROR, "map %s not found", m->path); res->mr_type.status = AUTOFS_DONE; res->mr_type.mount_result_type_u.error = AUTOFS_NOENT; goto out; } mf = mp->am_al->al_mnt; new_mp = mf->mf_ops->lookup_child(mp, m->name + m->isdirect, &err, VLOOK_CREATE); if (new_mp && err < 0) { /* new_mp->am_transp = transp; */ new_mp = mf->mf_ops->mount_child(new_mp, &err); } if (new_mp == NULL) { if (err < 0) { /* we're working on it */ amd_stats.d_drops++; return 1; } res->mr_type.status = AUTOFS_DONE; res->mr_type.mount_result_type_u.error = AUTOFS_NOENT; goto out; } if (gopt.flags & CFM_AUTOFS_USE_LOFS || new_mp->am_al->al_mnt->mf_flags & MFF_ON_AUTOFS) { res->mr_type.status = AUTOFS_DONE; res->mr_type.mount_result_type_u.error = AUTOFS_OK; } else { struct action_list *list = malloc(sizeof(struct action_list)); char *target; if (new_mp->am_link) target = new_mp->am_link; else target = new_mp->am_al->al_mnt->mf_mount; list->action.action = AUTOFS_LINK_RQ; list->action.action_list_entry_u.linka.dir = strdup(new_mp->am_name); list->action.action_list_entry_u.linka.link = strdup(target); list->next = NULL; res->mr_type.status = AUTOFS_ACTION; res->mr_type.mount_result_type_u.list = list; } out: res->mr_verbose = 1; switch (res->mr_type.status) { case AUTOFS_ACTION: dlog("MOUNT REPLY: status=%d, AUTOFS_ACTION", err); break; case AUTOFS_DONE: dlog("MOUNT REPLY: status=%d, AUTOFS_DONE", err); break; default: dlog("MOUNT REPLY: status=%d, UNKNOWN(%d)", err, res->mr_type.status); } if (err) { if (m->isdirect) { /* direct mount */ plog(XLOG_ERROR, "mount of %s failed", m->path); } else { /* indirect mount */ plog(XLOG_ERROR, "mount of %s/%s failed", m->path, m->name); } } return 0; } static void autofs_mount_2_free(struct autofs_mountres *res) { if (res->mr_type.status == AUTOFS_ACTION && res->mr_type.mount_result_type_u.list != NULL) { autofs_action action; dlog("freeing action list"); action = res->mr_type.mount_result_type_u.list->action.action; if (action == AUTOFS_LINK_RQ) { /* * Free link information */ struct linka *link; link = &(res->mr_type.mount_result_type_u.list->action.action_list_entry_u.linka); if (link->dir) XFREE(link->dir); if (link->link) XFREE(link->link); } else if (action == AUTOFS_MOUNT_RQ) { struct mounta *mnt; mnt = &(res->mr_type.mount_result_type_u.list->action.action_list_entry_u.mounta); if (mnt->spec) XFREE(mnt->spec); if (mnt->dir) XFREE(mnt->dir); if (mnt->fstype) XFREE(mnt->fstype); if (mnt->dataptr) XFREE(mnt->dataptr); #ifdef HAVE_MOUNTA_OPTPTR if (mnt->optptr) XFREE(mnt->optptr); #endif /* HAVE_MOUNTA_OPTPTR */ } XFREE(res->mr_type.mount_result_type_u.list); } } static int autofs_unmount_2_req(umntrequest *ul, umntres *res, struct authunix_parms *cred, SVCXPRT *transp) { int mapno, err; am_node *mp = NULL; #ifdef HAVE_STRUCT_UMNTREQUEST_DEVID dlog("UNMOUNT REQUEST: dev=%lx rdev=%lx %s", (u_long) ul->devid, (u_long) ul->rdevid, ul->isdirect ? "direct" : "indirect"); #else /* not HAVE_STRUCT_UMNTREQUEST_DEVID */ dlog("UNMOUNT REQUEST: mntresource='%s' mntpnt='%s' fstype='%s' mntopts='%s' %s", ul->mntresource, ul->mntpnt, ul->fstype, ul->mntopts, ul->isdirect ? "direct" : "indirect"); #endif /* not HAVE_STRUCT_UMNTREQUEST_DEVID */ /* by default, and if not found, succeed */ res->status = 0; #ifdef HAVE_STRUCT_UMNTREQUEST_DEVID for (mp = get_first_exported_ap(&mapno); mp; mp = get_next_exported_ap(&mapno)) { if (mp->am_dev == ul->devid && mp->am_rdev == ul->rdevid) break; } #else /* not HAVE_STRUCT_UMNTREQUEST_DEVID */ mp = find_ap(ul->mntpnt); #endif /* not HAVE_STRUCT_UMNTREQUEST_DEVID */ if (mp) { /* save RPC context */ if (!mp->am_transp && transp) { mp->am_transp = (SVCXPRT *) xmalloc(sizeof(SVCXPRT)); *(mp->am_transp) = *transp; } mapno = mp->am_mapno; err = unmount_mp(mp); if (err) /* backgrounded, don't reply yet */ return 1; if (get_exported_ap(mapno)) /* unmounting failed, tell the kernel */ res->status = 1; } dlog("UNMOUNT REPLY: status=%d", res->status); return 0; } /* * These exist only in the AutoFS V2 protocol. */ #ifdef AUTOFS_POSTUNMOUNT /* XXX not implemented */ static int autofs_postunmount_2_req(postumntreq *req, postumntres *res, struct authunix_parms *cred, SVCXPRT *transp) { postumntreq *ul = req; dlog("POSTUNMOUNT REQUEST: dev=%lx rdev=%lx", (u_long) ul->devid, (u_long) ul->rdevid); /* succeed unconditionally */ res->status = 0; dlog("POSTUNMOUNT REPLY: status=%d", res->status); return 0; } /* XXX not implemented */ static int autofs_postmount_2_req(postmountreq *req, postmountres *res, struct authunix_parms *cred, SVCXPRT *transp) { dlog("POSTMOUNT REQUEST: %s\tdev=%lx\tspecial=%s %s", req->mountp, (u_long) req->devid, req->special, req->mntopts); /* succeed unconditionally */ res->status = 0; dlog("POSTMOUNT REPLY: status=%d", res->status); return 0; } #endif /* AUTOFS_POSTUNMOUNT */ static int autofs_readdir_2_req(struct autofs_rddirargs *req, struct amd_rddirres *res, struct authunix_parms *cred, SVCXPRT *transp) { am_node *mp; int err; static nfsentry e_res[MAX_READDIR_ENTRIES]; dlog("READDIR REQUEST: %s @ %d", req->rda_map, (int) req->rda_offset); mp = find_ap(req->rda_map); if (!mp) { plog(XLOG_ERROR, "map %s not found", req->rda_map); res->rd_status = AUTOFS_NOENT; goto out; } mp->am_stats.s_readdir++; req->rda_offset -= AUTOFS_DAEMONCOOKIE; err = mp->am_al->al_mnt->mf_ops->readdir(mp, (char *)&req->rda_offset, &res->rd_dl, e_res, req->rda_count); if (err) { res->rd_status = AUTOFS_ECOMM; goto out; } res->rd_status = AUTOFS_OK; res->rd_bufsize = req->rda_count; out: dlog("READDIR REPLY: status=%d", res->rd_status); return 0; } /****************************************************************************/ /* autofs program dispatcher */ static void autofs_program_2(struct svc_req *rqstp, SVCXPRT *transp) { union { autofs_lookupargs autofs_mount_2_arg; autofs_lookupargs autofs_lookup_2_arg; umntrequest autofs_umount_2_arg; autofs_rddirargs autofs_readdir_2_arg; #ifdef AUTOFS_POSTUNMOUNT postmountreq autofs_postmount_2_arg; postumntreq autofs_postumnt_2_arg; #endif /* AUTOFS_POSTUNMOUNT */ } argument; union { autofs_mountres mount_res; autofs_lookupres lookup_res; umntres umount_res; amd_rddirres readdir_res; #ifdef AUTOFS_POSTUNMOUNT postumntres postumnt_res; postmountres postmnt_res; #endif /* AUTOFS_POSTUNMOUNT */ } result; int ret; bool_t (*xdr_argument)(); bool_t (*xdr_result)(); int (*local)(); void (*local_free)() = NULL; current_transp = transp; switch (rqstp->rq_proc) { case AUTOFS_NULL: svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_void, (SVC_IN_ARG_TYPE) NULL); return; case AUTOFS_LOOKUP: xdr_argument = xdr_autofs_lookupargs; xdr_result = xdr_autofs_lookupres; local = autofs_lookup_2_req; local_free = autofs_lookup_2_free; break; case AUTOFS_MOUNT: xdr_argument = xdr_autofs_lookupargs; xdr_result = xdr_autofs_mountres; local = autofs_mount_2_req; local_free = autofs_mount_2_free; break; case AUTOFS_UNMOUNT: xdr_argument = xdr_umntrequest; xdr_result = xdr_umntres; local = autofs_unmount_2_req; break; /* * These exist only in the AutoFS V2 protocol. */ #ifdef AUTOFS_POSTUNMOUNT case AUTOFS_POSTUNMOUNT: xdr_argument = xdr_postumntreq; xdr_result = xdr_postumntres; local = autofs_postunmount_2_req; break; case AUTOFS_POSTMOUNT: xdr_argument = xdr_postmountreq; xdr_result = xdr_postmountres; local = autofs_postmount_2_req; break; #endif /* AUTOFS_POSTUNMOUNT */ case AUTOFS_READDIR: xdr_argument = xdr_autofs_rddirargs; xdr_result = xdr_amd_rddirres; local = autofs_readdir_2_req; break; default: svcerr_noproc(transp); return; } memset((char *) &argument, 0, sizeof(argument)); if (!svc_getargs(transp, (XDRPROC_T_TYPE) xdr_argument, (SVC_IN_ARG_TYPE) &argument)) { plog(XLOG_ERROR, "AUTOFS xdr decode failed for %d %d %d", (int) rqstp->rq_prog, (int) rqstp->rq_vers, (int) rqstp->rq_proc); svcerr_decode(transp); return; } memset((char *)&result, 0, sizeof(result)); ret = (*local) (&argument, &result, rqstp->rq_clntcred, transp); current_transp = NULL; /* send reply only if the RPC method returned 0 */ if (!ret) { if (!svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_result, (SVC_IN_ARG_TYPE) &result)) { svcerr_systemerr(transp); } } if (!svc_freeargs(transp, (XDRPROC_T_TYPE) xdr_argument, (SVC_IN_ARG_TYPE) &argument)) { plog(XLOG_FATAL, "unable to free rpc arguments in autofs_program_2"); } if (local_free) (*local_free)(&result); } int autofs_get_fh(am_node *mp) { autofs_fh_t *fh; char buf[MAXHOSTNAMELEN]; mntfs *mf = mp->am_al->al_mnt; struct utsname utsname; plog(XLOG_DEBUG, "autofs_get_fh for %s", mp->am_path); fh = ALLOC(autofs_fh_t); memset((voidp) fh, 0, sizeof(autofs_fh_t)); /* Paranoid */ /* * SET MOUNT ARGS */ if (uname(&utsname) < 0) { xstrlcpy(buf, "localhost.autofs", sizeof(buf)); } else { xstrlcpy(buf, utsname.nodename, sizeof(buf)); xstrlcat(buf, ".autofs", sizeof(buf)); } #ifdef HAVE_AUTOFS_ARGS_T_ADDR fh->addr.buf = strdup(buf); fh->addr.len = fh->addr.maxlen = strlen(buf); #endif /* HAVE_AUTOFS_ARGS_T_ADDR */ fh->direct = ((mf->mf_ops->autofs_fs_flags & FS_DIRECT) == FS_DIRECT); fh->rpc_to = 1; /* XXX: arbitrary */ fh->mount_to = mp->am_timeo; fh->path = mp->am_path; fh->opts = ""; /* XXX: arbitrary */ fh->map = mp->am_path; /* this is what we get back in readdir */ fh->subdir = ""; if (fh->direct) fh->key = mp->am_name; else fh->key = ""; mp->am_autofs_fh = fh; return 0; } void autofs_mounted(am_node *mp) { /* We don't want any timeouts on autofs nodes */ mp->am_autofs_ttl = NEVER; } void autofs_release_fh(am_node *mp) { autofs_fh_t *fh = mp->am_autofs_fh; #ifdef HAVE_AUTOFS_ARGS_T_ADDR XFREE(fh->addr.buf); #endif /* HAVE_AUTOFS_ARGS_T_ADDR */ XFREE(fh); mp->am_autofs_fh = NULL; } void autofs_get_mp(am_node *mp) { /* nothing to do */ } void autofs_release_mp(am_node *mp) { /* nothing to do */ } void autofs_add_fdset(fd_set *readfds) { /* nothing to do */ } int autofs_handle_fdset(fd_set *readfds, int nsel) { /* nothing to do */ return nsel; } /* * Create the autofs service for amd */ int create_autofs_service(void) { dlog("creating autofs service listener"); return register_autofs_service(AUTOFS_CONFTYPE, autofs_program_2); } int destroy_autofs_service(void) { dlog("destroying autofs service listener"); return unregister_autofs_service(AUTOFS_CONFTYPE); } int autofs_mount_fs(am_node *mp, mntfs *mf) { int err = 0; char *target, *target2 = NULL; struct stat buf; /* * For sublinks, we could end up here with an already mounted f/s. * Don't do anything in that case. */ if (!(mf->mf_flags & MFF_MOUNTED)) err = mf->mf_ops->mount_fs(mp, mf); if (err || mf->mf_flags & MFF_ON_AUTOFS) /* Nothing else to do */ return err; if (!(gopt.flags & CFM_AUTOFS_USE_LOFS)) /* Symlinks will be requested in autofs_mount_succeeded */ return 0; if (mp->am_link) target = mp->am_link; else target = mf->mf_mount; if (target[0] != '/') target2 = str3cat(NULL, mp->am_parent->am_path, "/", target); else target2 = strdup(target); plog(XLOG_INFO, "autofs: converting from link to lofs (%s -> %s)", mp->am_path, target2); /* * we need to stat() the destination, because the bind mount does not * follow symlinks and/or allow for non-existent destinations. * we fall back to symlinks if there are problems. * * we need to temporarily change pgrp, otherwise our stat() won't * trigger whatever cascading mounts are needed. * * WARNING: we will deadlock if this function is called from the master * amd process and it happens to trigger another auto mount. Therefore, * this function should be called only from a child amd process, or * at the very least it should not be called from the parent unless we * know for sure that it won't cause a recursive mount. We refuse to * cause the recursive mount anyway if called from the parent amd. */ if (!foreground) { if ((err = stat(target2, &buf))) goto out; } if ((err = lstat(target2, &buf))) goto out; if ((err = mount_lofs(mp->am_path, target2, mf->mf_mopts, 1))) { errno = err; goto out; } out: if (target2) XFREE(target2); if (err) return errno; return 0; } int autofs_umount_fs(am_node *mp, mntfs *mf) { int err = 0; if (!(mf->mf_flags & MFF_ON_AUTOFS) && gopt.flags & CFM_AUTOFS_USE_LOFS) { err = UMOUNT_FS(mp->am_path, mnttab_file_name, 1); if (err) return err; } /* * Multiple sublinks could reference this f/s. * Don't actually unmount it unless we're holding the last reference. */ if (mf->mf_refc == 1) err = mf->mf_ops->umount_fs(mp, mf); return err; } int autofs_umount_succeeded(am_node *mp) { umntres res; SVCXPRT *transp = mp->am_transp; if (transp) { res.status = 0; if (!svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_umntres, (SVC_IN_ARG_TYPE) &res)) svcerr_systemerr(transp); dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount); XFREE(transp); mp->am_transp = NULL; } plog(XLOG_INFO, "autofs: unmounting %s succeeded", mp->am_path); return 0; } int autofs_umount_failed(am_node *mp) { umntres res; SVCXPRT *transp = mp->am_transp; if (transp) { res.status = 1; if (!svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_umntres, (SVC_IN_ARG_TYPE) &res)) svcerr_systemerr(transp); dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount); XFREE(transp); mp->am_transp = NULL; } plog(XLOG_INFO, "autofs: unmounting %s failed", mp->am_path); return 0; } void autofs_mount_succeeded(am_node *mp) { SVCXPRT *transp = mp->am_transp; struct stat stb; /* * Store dev and rdev -- but not for symlinks */ if (gopt.flags & CFM_AUTOFS_USE_LOFS || mp->am_al->al_mnt->mf_flags & MFF_ON_AUTOFS) { if (!lstat(mp->am_path, &stb)) { mp->am_dev = stb.st_dev; mp->am_rdev = stb.st_rdev; } /* don't expire the entries -- the kernel will do it for us */ mp->am_flags |= AMF_NOTIMEOUT; } if (transp) { autofs_mountres res; res.mr_type.status = AUTOFS_DONE; res.mr_type.mount_result_type_u.error = AUTOFS_OK; res.mr_verbose = 1; if (!svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_autofs_mountres, (SVC_IN_ARG_TYPE) &res)) svcerr_systemerr(transp); dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount); XFREE(transp); mp->am_transp = NULL; } plog(XLOG_INFO, "autofs: mounting %s succeeded", mp->am_path); } void autofs_mount_failed(am_node *mp) { SVCXPRT *transp = mp->am_transp; if (transp) { autofs_mountres res; res.mr_type.status = AUTOFS_DONE; res.mr_type.mount_result_type_u.error = AUTOFS_NOENT; res.mr_verbose = 1; if (!svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_autofs_mountres, (SVC_IN_ARG_TYPE) &res)) svcerr_systemerr(transp); dlog("Quick reply sent for %s", mp->am_al->al_mnt->mf_mount); XFREE(transp); mp->am_transp = NULL; } plog(XLOG_INFO, "autofs: mounting %s failed", mp->am_path); } void autofs_get_opts(char *opts, size_t l, autofs_fh_t *fh) { xsnprintf(opts, l, "%sdirect", fh->direct ? "" : "in"); } int autofs_compute_mount_flags(mntent_t *mntp) { /* Must use overlay mounts */ return MNT2_GEN_OPT_OVERLAY; } void autofs_timeout_mp(am_node *mp) { /* We don't want any timeouts on autofs nodes */ mp->am_autofs_ttl = NEVER; } am-utils-6.2+rc20110530/conf/autofs/autofs_solaris_v2_v3.h000066400000000000000000000075101157065440000230100ustar00rootroot00000000000000/* * Copyright (c) 1999-2003 Ion Badulescu * Copyright (c) 1997-2011 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. 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 * 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/conf/autofs/autofs_solaris_v2_v3.h * */ /* * Automounter filesystem headers for Solaris v2-v3 */ #ifdef HAVE_FS_AUTOFS typedef struct autofs_args autofs_fh_t; #define AUTOFS_AUTO_FS_FLAGS (FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS | FS_ON_AUTOFS) #define AUTOFS_DIRECT_FS_FLAGS (FS_DIRECT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS) #define AUTOFS_ERROR_FS_FLAGS (FS_DISCARD) #define AUTOFS_HOST_FS_FLAGS (FS_MKMNT | FS_BACKGROUND | FS_AMQINFO) #define AUTOFS_LINK_FS_FLAGS (FS_MBACKGROUND) #define AUTOFS_LINKX_FS_FLAGS (FS_MBACKGROUND) #define AUTOFS_NFSL_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_NFSX_FS_FLAGS (/* FS_UBACKGROUND| */ FS_AMQINFO ) #define AUTOFS_PROGRAM_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO) #define AUTOFS_ROOT_FS_FLAGS (FS_NOTIMEOUT | FS_AMQINFO | FS_DIRECTORY) #define AUTOFS_TOPLVL_FS_FLAGS (FS_MKMNT | FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_AUTOFS) #define AUTOFS_UNION_FS_FLAGS (FS_NOTIMEOUT | FS_BACKGROUND | FS_AMQINFO | FS_DIRECTORY | FS_ON_AUTOFS) #define AUTOFS_CACHEFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_CDFS_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_EFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_LOFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_NFS_FS_FLAGS (FS_BACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_PCFS_FS_FLAGS (FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_UFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #define AUTOFS_XFS_FS_FLAGS (FS_NOTIMEOUT | FS_UBACKGROUND | FS_AMQINFO | FS_ON_AUTOFS) #endif /* HAVE_FS_AUTOFS */ am-utils-6.2+rc20110530/conf/checkmount/000077500000000000000000000000001157065440000174175ustar00rootroot00000000000000am-utils-6.2+rc20110530/conf/checkmount/checkmount_aix.c000066400000000000000000000070601157065440000225670ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/checkmount/checkmount_aix.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include /* * These were missing external definitions from old AIX's headers. They * appear to be available in on AIX 5.3, and possibly * earlier. Hence I commented this out. */ #ifndef HAVE_EXTERN_MNTCTL extern int mntctl(int cmd, int size, voidp buf); #endif /* not HAVE_EXTERN_MNTCTL */ extern int is_same_host(char *name1, char *name2, struct in_addr addr2); int fixmount_check_mount(char *host, struct in_addr hostaddr, char *path) { int ret, i; char *mntinfo = NULL, *cp; char *short_hostname, *long_hostname, *mount_point; struct vmount *vp; /* * First figure out size of mount table and allocate space for a copy... * Then get mount table for real. */ ret = mntctl(MCTL_QUERY, sizeof(i), (char *) &i); if (ret == 0) { mntinfo = xmalloc(i); ret = mntctl(MCTL_QUERY, i, mntinfo); } if (ret <= 0) { fprintf(stderr, "mntctl: %m"); XFREE(mntinfo); exit(1); } /* iterate over each vmount structure */ for (i = 0, cp = mntinfo; i < ret; i++, cp += vp->vmt_length) { vp = (struct vmount *) cp; mount_point = vmt2dataptr(vp, VMT_STUB); long_hostname = vmt2dataptr(vp, VMT_HOSTNAME); short_hostname = vmt2dataptr(vp, VMT_HOST); if (STREQ(path, mount_point) && (is_same_host(long_hostname, host, hostaddr) || is_same_host(short_hostname, host, hostaddr))) return 1; } return 0; } am-utils-6.2+rc20110530/conf/checkmount/checkmount_bsd44.c000066400000000000000000000056651157065440000227370ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/checkmount/checkmount_bsd44.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #if __NetBSD_Version__ > 200030000 #define statfs statvfs #endif extern int is_same_host(char *name1, char *name2, struct in_addr addr2); int fixmount_check_mount(char *host, struct in_addr hostaddr, char *path); int fixmount_check_mount(char *host, struct in_addr hostaddr, char *path) { struct statfs *mntbufp, *mntp; int nloc, i; char *colon; /* read mount table from kernel */ nloc = getmntinfo(&mntbufp, MNT_NOWAIT); if (nloc <= 0) { perror("getmntinfo"); exit(1); } mntp = mntbufp; for (i=0; if_mntfromname, ':'))) { *colon = '\0'; if (STREQ(colon + 1, path) && is_same_host(mntp->f_mntfromname, host, hostaddr)) return 1; } } return 0; } am-utils-6.2+rc20110530/conf/checkmount/checkmount_default.c000066400000000000000000000073231157065440000234340ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/checkmount/checkmount_default.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #ifndef _PATH_MTAB #define _PATH_MTAB "/etc/mtab" #endif /* not _PATH_MTAB */ extern int is_same_host(char *name1, char *name2, struct in_addr addr2); int fixmount_check_mount(char *host, struct in_addr hostaddr, char *path) { FILE *mtab; mntent_t *ment; int found = 0; /* scan mtab for path */ if (!(mtab = setmntent(_PATH_MTAB, "r"))) { perror(_PATH_MTAB); exit(1); } /* * setmntent() doesn't do locking in read-only mode. Too bad -- it seems to * rely on mount() and friends to do atomic updates by renaming the file. * Well, our patched amd rewrites mtab in place to avoid NFS lossage, so * better do the locking ourselves. */ #ifdef HAVE_FLOCK if (flock(fileno(mtab), LOCK_SH) < 0) { #else /* not HAVE_FLOCK */ if (lockf(fileno(mtab), F_LOCK, 0) < 0) { #endif /* not HAVE_FLOCK */ perror(_PATH_MTAB); exit(1); } while (!found && (ment = getmntent(mtab))) { char *colon; if ((colon = strchr(ment->mnt_fsname, ':'))) { *colon = '\0'; if ((STREQ(colon + 1, path) || STREQ(ment->mnt_dir, path)) && is_same_host(ment->mnt_fsname, host, hostaddr)) found = 1; } } (void) endmntent(mtab); if (!found) { char *swap; /* swap files never show up in mtab, only root fs */ if ((swap = strstr(path, "swap"))) { strncpy(swap, "root", 4); /* this should NOT use xstrlcpy */ found = fixmount_check_mount(host, hostaddr, path); strncpy(swap, "swap", 4); /* this should NOT use xstrlcpy */ } } return found; } am-utils-6.2+rc20110530/conf/checkmount/checkmount_osf.c000066400000000000000000000062731157065440000226020ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/checkmount/checkmount_osf.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include extern int is_same_host(char *name1, char *name2, struct in_addr addr2); int fixmount_check_mount(char *host, struct in_addr hostaddr, char *path) { int nentries, i; struct statfs *fslist; int found = 0; nentries = getmntinfo(&fslist, MNT_NOWAIT); if (nentries <= 0) { perror("getmntinfo"); exit(1); } for (i = 0; !found && (i < nentries); i++) { char *delim; /* * Apparently two forms of nfs mount syntax are * accepted: host:/path or /path@host */ if ((delim = strchr(fslist[i].f_mntfromname, ':'))) { *delim = '\0'; if ((STREQ(delim + 1, path) || STREQ(fslist[i].f_mntonname, path)) && is_same_host(fslist[i].f_mntfromname, host, hostaddr)) found = 1; } else if ((delim = strchr(fslist[i].f_mntfromname, '@'))) { *delim = '\0'; if ((STREQ(fslist[i].f_mntfromname, path) || STREQ(fslist[i].f_mntonname, path)) && is_same_host(delim + 1, host, hostaddr)) found = 1; } } return found; } am-utils-6.2+rc20110530/conf/checkmount/checkmount_svr4.c000066400000000000000000000067621157065440000227140ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/checkmount/checkmount_svr4.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include extern int is_same_host(char *name1, char *name2, struct in_addr addr2); int fixmount_check_mount(char *host, struct in_addr hostaddr, char *path) { FILE *mtab; struct mnttab ment; int err = 0; int found = 0; /* scan mtab for path */ if (!(mtab = fopen(MNTTAB, "r"))) { perror(MNTTAB); exit(1); } while (!found && (err = getmntent(mtab, &ment)) == 0) { char *colon; if ((colon = strchr(ment.mnt_fsname, ':'))) { *colon = '\0'; if ((STREQ(colon + 1, path) || STREQ(ment.mnt_dir, path)) && is_same_host(ment.mnt_fsname, host, hostaddr)) found = 1; } } if (err > 0) { fprintf(stderr, "getmntent: %s: %s\n", MNTTAB, err == MNT_TOOLONG ? "entry exceeds MNT_LINE_MAX" : err == MNT_TOOMANY ? "too many fields in line" : err == MNT_TOOFEW ? "too few fields in line" : "unknown error code"); exit(1); } (void) fclose(mtab); /* XXX: Is this still valid in SunOS 5.x ? */ if (!found) { char *swap; /* swap files never show up in mtab, only root fs */ if ((swap = strstr(path, "swap"))) { strncpy(swap, "root", 4); /* this should NOT use xstrlcpy */ found = fixmount_check_mount(host, hostaddr, path); strncpy(swap, "swap", 4); /* this should NOT use xstrlcpy */ } } return found; } am-utils-6.2+rc20110530/conf/checkmount/checkmount_ultrix.c000066400000000000000000000055451157065440000233430ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/checkmount/checkmount_ultrix.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include extern int is_same_host(char *name1, char *name2, struct in_addr addr2); int fixmount_check_mount(char *host, struct in_addr hostaddr, char *path) { int start = 0; int err = 0; struct fs_data ment; int found = 0; /* scan mtab for path */ while (!found && (err = getmnt(&start, &ment, sizeof(ment), NOSTAT_MANY, NULL)) > 0) { char *colon; if (colon = strchr(ment.fd_devname, ':')) { *colon = '\0'; if ((STREQ(colon + 1, path) || STREQ(ment.fd_path, path)) && is_same_host(ment.fd_devname, host, hostaddr)) found = 1; } } if (!found && err < 0) { perror("getmnt"); exit(1); } return found; } am-utils-6.2+rc20110530/conf/fh_dref/000077500000000000000000000000001157065440000166545ustar00rootroot00000000000000am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_aix3.h000066400000000000000000000002071157065440000213450ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_aix3.h */ #define NFS_FH_DREF(dst, src) memcpy((char *) &(dst.x), (char *) src, sizeof(struct nfs_fh)) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_aix42.h000066400000000000000000000001401157065440000214240ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_aix42.h */ #define NFS_FH_DREF(dst, src) (dst) = (caddr_t)(src) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_bsd44.h000066400000000000000000000001451157065440000214220ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_bsd44.h */ #define NFS_FH_DREF(dst, src) (dst) = (nfsv2fh_t *) (src) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_default.h000066400000000000000000000001311157065440000221210ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_default.h */ #define NFS_FH_DREF(dst, src) (dst) = (src) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_freebsd22.h000066400000000000000000000001461157065440000222610ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_freebsd22.h */ #define NFS_FH_DREF(dst, src) (dst) = (u_char *) (src) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_hpux.h000066400000000000000000000001441157065440000214650ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_hpux.h */ #define NFS_FH_DREF(dst, src) (dst) = (fhandle_t *) (src) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_irix.h000066400000000000000000000001441157065440000214540ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_irix.h */ #define NFS_FH_DREF(dst, src) (dst) = (fhandle_t *) (src) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_isc3.h000066400000000000000000000001271157065440000213430ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_isc3.h */ #define NFS_FH_DREF(dst, src) (dst) = *(src) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_linux.h000066400000000000000000000002131157065440000216350ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_linux.h */ #define NFS_FH_DREF(dst, src) memcpy((char *) &(dst.data), (char *) src, sizeof(struct nfs_fh)) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_nextstep.h000066400000000000000000000001441157065440000223530ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_nextstep.h */ #define NFS_FH_DREF(dst, src) (dst) = (caddr_t) (src) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_osf2.h000066400000000000000000000001441157065440000213520ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_osf2.h */ #define NFS_FH_DREF(dst, src) (dst) = (nfsv2fh_t *) (src) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_osf4.h000066400000000000000000000001401157065440000213500ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_osf4.h */ #define NFS_FH_DREF(dst, src) (dst) = (caddr_t) (src) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_sunos3.h000066400000000000000000000001421157065440000217310ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_sunos3.h */ #define NFS_FH_DREF(dst, src) (dst) = (caddr_t) (src) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_sunos4.h000066400000000000000000000001421157065440000217320ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_sunos4.h */ #define NFS_FH_DREF(dst, src) (dst) = (caddr_t) (src) am-utils-6.2+rc20110530/conf/fh_dref/fh_dref_svr4.h000066400000000000000000000001401157065440000213730ustar00rootroot00000000000000/* $srcdir/conf/fh_dref/fh_dref_svr4.h */ #define NFS_FH_DREF(dst, src) (dst) = (caddr_t) (src) am-utils-6.2+rc20110530/conf/hn_dref/000077500000000000000000000000001157065440000166645ustar00rootroot00000000000000am-utils-6.2+rc20110530/conf/hn_dref/hn_dref_default.h000066400000000000000000000001311157065440000221410ustar00rootroot00000000000000/* $srcdir/conf/hn_dref/hn_dref_default.h */ #define NFS_HN_DREF(dst, src) (dst) = (src) am-utils-6.2+rc20110530/conf/hn_dref/hn_dref_isc3.h000066400000000000000000000001571157065440000213660ustar00rootroot00000000000000/* $srcdir/conf/hn_dref/hn_dref_isc3.h */ #define NFS_HN_DREF(dst, src) xstrlcpy((dst), (src), MAXHOSTNAMELEN) am-utils-6.2+rc20110530/conf/hn_dref/hn_dref_linux.h000066400000000000000000000001601157065440000216560ustar00rootroot00000000000000/* $srcdir/conf/hn_dref/hn_dref_linux.h */ #define NFS_HN_DREF(dst, src) xstrlcpy((dst), (src), MAXHOSTNAMELEN) am-utils-6.2+rc20110530/conf/mount/000077500000000000000000000000001157065440000164215ustar00rootroot00000000000000am-utils-6.2+rc20110530/conf/mount/mount_aix.c000066400000000000000000000134431157065440000205750ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mount/mount_aix.c * */ /* * AIX 5.x Mount helper */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #define VMT_ROUNDUP(len) (4 * ((len + 3) / 4)) #define VMT_ASSIGN(vp, idx, data, size) \ vp->vmt_data[idx].vmt_off = p - (char *) vp; \ vp->vmt_data[idx].vmt_size = size; \ memmove(p, data, size); \ p += VMT_ROUNDUP(size); /* missing external definitions from AIX's headers */ extern int vmount(struct vmount *vmount, int size); static int aix5_mkvp(char *p, int gfstype, int flags, char *object, char *stub, char *host, char *info, int info_size, char *args) { struct vmount *vp = (struct vmount *) p; memset((voidp) vp, 0, sizeof(*vp)); /* * Fill in standard fields */ vp->vmt_revision = VMT_REVISION; vp->vmt_flags = flags; vp->vmt_gfstype = gfstype; /* * Fill in all variable length data */ p += sizeof(*vp); VMT_ASSIGN(vp, VMT_OBJECT, object, strlen(object) + 1); VMT_ASSIGN(vp, VMT_STUB, stub, strlen(stub) + 1); VMT_ASSIGN(vp, VMT_HOST, host, strlen(host) + 1); VMT_ASSIGN(vp, VMT_HOSTNAME, host, strlen(host) + 1); VMT_ASSIGN(vp, VMT_INFO, info, info_size); VMT_ASSIGN(vp, VMT_ARGS, args, strlen(args) + 1); /* * Return length */ return vp->vmt_length = p - (char *) vp; } /* * Map from conventional mount arguments to AIX 3,x style arguments. * But we avoid all the messy BIS stuff for AIX 5.x */ int mount_aix3(char *fsname, char *dir, int flags, int type, void *data, char *mnt_opts) { char buf[4096]; int size, ret; int real_size = sizeof(nfs_args_t); /* size passed to aix5_mkvp() */ char *real_args = data; /* args passed to aix5_mkvp() */ char *host, *rfs, *idx; int aix_type = type; #ifdef HAVE_FS_NFS3 struct nfs_args v2args; nfs_args_t *v3args = (nfs_args_t *) data; #endif /* HAVE_FS_NFS3 */ #ifdef DEBUG dlog("mount_aix3: fsname %s, dir %s, type %d", fsname, dir, type); #endif /* DEBUG */ switch (aix_type) { case MOUNT_TYPE_NFS: #ifdef HAVE_FS_NFS3 /* * This is tricky. If we have v3 support, but this nfs mount is v2, * then I must copy the arguments from the v3 nfs_args to the v2 one. */ memmove((voidp) &v2args.addr, (voidp) &v3args->addr, sizeof(struct sockaddr_in)); v2args.hostname = v3args->hostname; v2args.netname = v3args->netname; memmove((voidp) v2args.fh.x, v3args->fh, FHSIZE); v2args.flags = v3args->flags; v2args.wsize = v3args->wsize; v2args.rsize = v3args->rsize; v2args.timeo = v3args->timeo; v2args.retrans = v3args->retrans; v2args.acregmin = v3args->acregmin; v2args.acregmax = v3args->acregmax; v2args.acdirmin = v3args->acdirmin; v2args.acdirmax = v3args->acdirmax; v2args.pathconf = v3args->pathconf; /* now set real_* stuff */ real_size = sizeof(v2args); real_args = (char *) &v2args; case MOUNT_TYPE_NFS3: #endif /* HAVE_FS_NFS3 */ idx = strchr(fsname, ':'); if (idx) { *idx = '\0'; rfs = strdup(idx + 1); host = strdup(fsname); *idx = ':'; } else { rfs = strdup(fsname); host = strdup(am_get_hostname()); } size = aix5_mkvp(buf, type, flags, rfs, dir, host, real_args, real_size, mnt_opts); XFREE(rfs); XFREE(host); break; case MOUNT_TYPE_UFS: /* Need to open block device and extract log device info from sblk. */ return EINVAL; default: return EINVAL; } /* * XXX: Warning, if vmount() hangs your amd in AIX 5.1, it * is because of a kernel bug in the NFS code. Get a patch from IBM * or upgrade to 5.2. */ ret = vmount((struct vmount *)buf, size); if (ret < 0) { plog(XLOG_ERROR, "mount_aix3: vmount failed with errno %d", errno); perror ("vmount"); } return ret; } am-utils-6.2+rc20110530/conf/mount/mount_aix3.c000066400000000000000000000165571157065440000206710ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mount/mount_aix3.c * */ /* * AIX 3.x/4.x Mount helper */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #define VMT_ROUNDUP(len) (4 * ((len + 3) / 4)) #define VMT_ASSIGN(vp, idx, data, size) \ vp->vmt_data[idx].vmt_off = p - (char *) vp; \ vp->vmt_data[idx].vmt_size = size; \ memmove(p, data, size); \ p += VMT_ROUNDUP(size); /* missing external definitions from AIX's headers */ extern int vmount(struct vmount *vmount, int size); static int aix3_mkvp(char *p, int gfstype, int flags, char *object, char *stub, char *host, char *info, int info_size, char *args) { struct vmount *vp = (struct vmount *) p; memset((voidp) vp, 0, sizeof(*vp)); /* * Fill in standard fields */ vp->vmt_revision = VMT_REVISION; vp->vmt_flags = flags; vp->vmt_gfstype = gfstype; /* * Fill in all variable length data */ p += sizeof(*vp); VMT_ASSIGN(vp, VMT_OBJECT, object, strlen(object) + 1); VMT_ASSIGN(vp, VMT_STUB, stub, strlen(stub) + 1); VMT_ASSIGN(vp, VMT_HOST, host, strlen(host) + 1); VMT_ASSIGN(vp, VMT_HOSTNAME, host, strlen(host) + 1); VMT_ASSIGN(vp, VMT_INFO, info, info_size); VMT_ASSIGN(vp, VMT_ARGS, args, strlen(args) + 1); /* * Return length */ return vp->vmt_length = p - (char *) vp; } /* * Map from conventional mount arguments * to AIX 3-style arguments. */ int mount_aix3(char *fsname, char *dir, int flags, int type, void *data, char *mnt_opts) { char buf[4096]; int size, ret; int real_size = sizeof(nfs_args_t); /* size passed to aix3_mkvp() */ char *real_args = data; /* args passed to aix3_mkvp() */ char *host, *rfs, *idx; int aix_type = type; #ifdef HAVE_FS_NFS3 struct nfs_args v2args; nfs_args_t *v3args = (nfs_args_t *) data; #ifdef MOUNT_TYPE_NFS3_BIS struct aix4_nfs_args_bis v3args_bis; #endif /* MOUNT_TYPE_NFS3_BIS */ #endif /* HAVE_FS_NFS3 */ #ifdef DEBUG dlog("mount_aix3: fsname %s, dir %s, type %d", fsname, dir, type); #endif /* DEBUG */ #ifdef MOUNT_TYPE_NFS3_BIS retry_ibm_buggy_service_pack: #endif /* MOUNT_TYPE_NFS3_BIS */ switch (aix_type) { case MOUNT_TYPE_NFS: #ifdef HAVE_FS_NFS3 /* * This is tricky. If we have v3 support, but this nfs mount is v2, * then I must copy the arguments from the v3 nfs_args to the v2 one. */ memmove((voidp) &v2args.addr, (voidp) &v3args->addr, sizeof(struct sockaddr_in)); v2args.hostname = v3args->hostname; v2args.netname = v3args->netname; memmove((voidp) v2args.fh, v3args->fh, FHSIZE); v2args.flags = v3args->flags; v2args.wsize = v3args->wsize; v2args.rsize = v3args->rsize; v2args.timeo = v3args->timeo; v2args.retrans = v3args->retrans; v2args.acregmin = v3args->acregmin; v2args.acregmax = v3args->acregmax; v2args.acdirmin = v3args->acdirmin; v2args.acdirmax = v3args->acdirmax; v2args.pathconf = v3args->pathconf; /* now set real_* stuff */ real_size = sizeof(v2args); real_args = (char *) &v2args; case MOUNT_TYPE_NFS3: #ifdef MOUNT_TYPE_NFS3_BIS case MOUNT_TYPE_NFS3_BIS: /* just fall through */ if (aix_type == MOUNT_TYPE_NFS3_BIS) { dlog("mount_aix3: creating alternate nfs3_args structure"); memmove((voidp) &v3args_bis.addr, (voidp) &v3args->addr, sizeof(struct sockaddr_in)); v3args_bis.syncaddr = v3args->syncaddr; v3args_bis.proto = v3args->proto; v3args_bis.hostname = v3args->hostname; v3args_bis.netname = v3args->netname; v3args_bis.fh = v3args->fh; v3args_bis.flags = v3args->flags; v3args_bis.wsize = v3args->wsize; v3args_bis.rsize = v3args->rsize; v3args_bis.timeo = v3args->timeo; v3args_bis.retrans = v3args->retrans; v3args_bis.acregmin = v3args->acregmin; v3args_bis.acregmax = v3args->acregmax; v3args_bis.acdirmin = v3args->acdirmin; v3args_bis.acdirmax = v3args->acdirmax; v3args_bis.pathconf = v3args->pathconf; v3args_bis.biods = v3args->biods; v3args_bis.numclust = v3args->numclust; /* now set real_* stuff */ real_size = sizeof(v3args_bis); real_args = (char *) &v3args_bis; } #endif /* MOUNT_TYPE_NFS3_BIS */ #endif /* HAVE_FS_NFS3 */ idx = strchr(fsname, ':'); if (idx) { *idx = '\0'; rfs = strdup(idx + 1); host = strdup(fsname); *idx = ':'; } else { rfs = strdup(fsname); host = strdup(am_get_hostname()); } size = aix3_mkvp(buf, type, flags, rfs, dir, host, real_args, real_size, mnt_opts); XFREE(rfs); XFREE(host); break; case MOUNT_TYPE_UFS: /* Need to open block device and extract log device info from sblk. */ return EINVAL; default: return EINVAL; } /* * XXX: Warning, if vmount() hangs your amd in AIX 5.1, it * is because of a kernel bug in the NFS code. Get a patch from IBM * or upgrade to 5.2. */ ret = vmount((struct vmount *)buf, size); if (ret < 0) { plog(XLOG_ERROR, "mount_aix3: vmount failed with errno %d", errno); perror ("vmount"); #ifdef MOUNT_TYPE_NFS3_BIS if (aix_type == MOUNT_TYPE_NFS3 && errno == EINVAL) { aix_type = MOUNT_TYPE_NFS3_BIS; #ifdef DEBUG dlog("mount_aix3: retrying with alternate nfs3_args structure"); #endif /* DEBUG */ goto retry_ibm_buggy_service_pack; } #endif /* MOUNT_TYPE_NFS3_BIS */ } return ret; } am-utils-6.2+rc20110530/conf/mount/mount_bsdi3.c000066400000000000000000000043651157065440000210230ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mount/mount_bsdi3.c * */ /* * BSD/OS 3 Mount helper */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include am-utils-6.2+rc20110530/conf/mount/mount_default.c000066400000000000000000000042311157065440000214330ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mount/mount_default.c */ /* * Default mount helper (currently empty) */ am-utils-6.2+rc20110530/conf/mount/mount_hpux.c000066400000000000000000000065541157065440000210050ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mount/mount_hpux.c * */ /* * HPUX: * HPUX 9.0 and 10.0 Mount helper. * -Erez Zadok */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Map from conventional mount arguments * to HPUX style arguments. */ int mount_hpux(MTYPE_TYPE type, const char *dir, int flags, caddr_t data) { #if defined(MOUNT_TYPE_NFS) && defined(MOUNT_NFS) if (STREQ(type, MOUNT_TYPE_NFS)) return vfsmount(MOUNT_NFS, dir, flags, data); #endif /* defined(MOUNT_TYPE_NFS) && defined(MOUNT_NFS) */ #if defined(MOUNT_TYPE_UFS) && defined(MOUNT_UFS) if (STREQ(type, MOUNT_TYPE_UFS)) return vfsmount(MOUNT_UFS, dir, flags, data); #endif /* defined(MOUNT_TYPE_UFS) && defined(MOUNT_UFS) */ #if defined(MOUNT_TYPE_PCFS) && defined(MOUNT_PC) /* * MOUNT_TYPE_PCFS gets redefined in conf/trap/trap_hpux.h because of * stupidities in HPUX 9.0's headers. */ if (STREQ(type, MOUNT_TYPE_PCFS)) return vfsmount(MOUNT_PC, dir, flags, data); #endif /* defined(MOUNT_TYPE_PCFS) && defined(MOUNT_PC) */ #if defined(MOUNT_TYPE_CDFS) && defined(MOUNT_CDFS) if (STREQ(type, MOUNT_TYPE_CDFS)) return vfsmount(MOUNT_CDFS, dir, flags, data); #endif /* defined(MOUNT_TYPE_CDFS) && defined(MOUNT_CDFS) */ return EINVAL; } am-utils-6.2+rc20110530/conf/mount/mount_irix5.c000066400000000000000000000073141157065440000210540ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mount/mount_irix5.c * */ /* * IRIX Mount helper */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Map from conventional mount arguments * to IRIX style arguments. * * NOTE: We have to use struct nfs_args (not nfs_args_t) below because * while IRIX5.3 needs the fh_len field added to struct nfs_args for NFS3 * mounts to succeed, the the mount syscall fails if the argument size * includes fh_len! Talk about a broken interface ... -- stolcke 7/4/97 */ int mount_irix(char *fsname, char *dir, int flags, MTYPE_TYPE type, voidp data) { #ifdef DEBUG dlog("mount_irix: fsname %s, dir %s, type %d", fsname, dir, type); #endif /* DEBUG */ #ifdef HAVE_FS_NFS3 if (STREQ(type, MOUNT_TYPE_NFS3)) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags), type, (struct nfs_args *) data, sizeof(struct nfs_args)); #endif /* HAVE_FS_NFS3 */ #ifdef HAVE_FS_NFS if (STREQ(type, MOUNT_TYPE_NFS)) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags), type, (struct nfs_args *) data, sizeof(struct nfs_args)); #endif /* HAVE_FS_NFS */ /* XXX: do I need to pass {u,x,e}fs_args ? */ #ifdef HAVE_FS_UFS if (STREQ(type, MOUNT_TYPE_UFS)) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags), type); #endif /* HAVE_FS_UFS */ #ifdef HAVE_FS_EFS if (STREQ(type, MOUNT_TYPE_EFS)) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags), type); #endif /* HAVE_FS_EFS */ #ifdef HAVE_FS_XFS if (STREQ(type, MOUNT_TYPE_XFS)) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags), type); #endif /* HAVE_FS_XFS */ return EINVAL; } am-utils-6.2+rc20110530/conf/mount/mount_irix6.c000066400000000000000000000077001157065440000210540ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mount/mount_irix6.c * */ /* * IRIX Mount helper */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Map from conventional mount arguments * to IRIX style arguments. */ int mount_irix(char *fsname, char *dir, int flags, MTYPE_TYPE type, voidp data) { #ifdef DEBUG dlog("mount_irix: fsname %s, dir %s, type %s", fsname, dir, type); #endif /* DEBUG */ #ifdef HAVE_FS_NFS3 if (STREQ(type, MOUNT_TYPE_NFS3)) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags), type, (nfs_args_t *) data, sizeof(nfs_args_t)); #endif /* HAVE_FS_NFS3 */ #ifdef HAVE_FS_NFS if (STREQ(type, MOUNT_TYPE_NFS)) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags), type, (nfs_args_t *) data, sizeof(nfs_args_t)); #endif /* HAVE_FS_NFS */ #ifdef HAVE_FS_UFS if (STREQ(type, MOUNT_TYPE_UFS)) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags), type, (ufs_args_t *) data, sizeof(ufs_args_t)); #endif /* HAVE_FS_UFS */ #ifdef HAVE_FS_XFS if (STREQ(type, MOUNT_TYPE_XFS)) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags), type, (xfs_args_t *) data, sizeof(xfs_args_t)); #endif /* HAVE_FS_XFS */ #ifdef HAVE_FS_EFS if (STREQ(type, MOUNT_TYPE_EFS)) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags), type, (efs_args_t *) data, sizeof(efs_args_t)); #endif /* HAVE_FS_EFS */ #ifdef HAVE_FS_AUTOFS if (STREQ(type, MOUNT_TYPE_AUTOFS)) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags), type, (autofs_args_t *) data, sizeof(autofs_args_t)); #endif /* HAVE_FS_AUTOFS */ #ifdef HAVE_FS_LOFS if (STREQ(type, MOUNT_TYPE_LOFS)) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags), type, (char *) NULL, 0); #endif /* HAVE_FS_LOFS */ return EINVAL; } am-utils-6.2+rc20110530/conf/mount/mount_isc3.c000066400000000000000000000054311157065440000206530ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mount/mount_isc3.c */ /* * IX/386 Mount helper */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Map from conventional mount arguments * to IX/386 style arguments. */ int mount_isc3(char *fsname, char *dir, int flags, int type, void *data) { #ifdef DEBUG dlog("mount_isc3: fsname %s, dir %s, type %d", fsname, dir, type); #endif /* DEBUG */ if (type == MOUNT_TYPE_NFS) return mount("/dev/nfsd", dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_DATA | flags), type, (struct nfs_args *) data, sizeof(struct nfs_args)); if (type == MOUNT_TYPE_UFS) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags), type); return EINVAL; } am-utils-6.2+rc20110530/conf/mount/mount_linux.c000066400000000000000000000605701157065440000211560ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mount/mount_linux.c */ /* * Linux mount helper. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #ifdef HAVE_RPC_AUTH_H # include #endif #ifndef MOUNT_TYPE_UFS /* * Autoconf didn't find any disk-based f/s on this system, * So provide some default definition for this file to compile. */ # define MOUNT_TYPE_UFS "no_disk_fs" #endif /* not MOUNT_TYPE_UFS */ struct opt_map { const char *opt; /* option name */ int inv; /* true if flag value should be inverted */ int mask; /* flag mask value */ }; const struct opt_map opt_map[] = { {"defaults", 0, 0}, {MNTTAB_OPT_RO, 0, MNT2_GEN_OPT_RDONLY}, {MNTTAB_OPT_RW, 1, MNT2_GEN_OPT_RDONLY}, {MNTTAB_OPT_EXEC, 1, MNT2_GEN_OPT_NOEXEC}, {MNTTAB_OPT_NOEXEC, 0, MNT2_GEN_OPT_NOEXEC}, {MNTTAB_OPT_SUID, 1, MNT2_GEN_OPT_NOSUID}, {MNTTAB_OPT_NOSUID, 0, MNT2_GEN_OPT_NOSUID}, #ifdef MNT2_GEN_OPT_NODEV {MNTTAB_OPT_NODEV, 0, MNT2_GEN_OPT_NODEV}, #endif /* MNT2_GEN_OPT_NODEV */ #ifdef MNT2_GEN_OPT_SYNC {MNTTAB_OPT_SYNC, 0, MNT2_GEN_OPT_SYNC}, {MNTTAB_OPT_ASYNC, 1, MNT2_GEN_OPT_SYNC}, #endif /* MNT2_GEN_OPT_SYNC */ #ifdef MNT2_GEN_OPT_NOSUB {MNTTAB_OPT_SUB, 1, MNT2_GEN_OPT_NOSUB}, {MNTTAB_OPT_NOSUB, 0, MNT2_GEN_OPT_NOSUB}, #endif /* MNT2_GEN_OPT_NOSUB */ {NULL, 0, 0} }; struct fs_opts { const char *opt; int type; /* XXX: Ion, what is this for? */ }; const struct fs_opts iso_opts[] = { { "map", 0 }, { "norock", 0 }, { "cruft", 0 }, { "unhide", 0 }, { "conv", 1 }, { "block", 1 }, { "mode", 1 }, { "gid", 1 }, { "uid", 1 }, { NULL, 0 } }; const struct fs_opts dos_opts[] = { { "check", 1 }, { "conv", 1 }, { "uid", 1 }, { "gid", 1 }, { "umask", 1 }, { "debug", 0 }, { "fat", 1 }, { "quiet", 0 }, { "blocksize",1 }, { NULL, 0 } }; const struct fs_opts autofs_opts[] = { { "fd", 1 }, { "pgrp", 1 }, { "minproto", 1 }, { "maxproto", 1 }, { NULL, 0 } }; const struct fs_opts null_opts[] = { { NULL, 0 } }; /* * New parser for linux-specific mounts. * Should now handle fs-type specific mount-options correctly. * Currently implemented: msdos, iso9660. */ static char * parse_opts(char *type, const char *optstr, int *flags, char **xopts, int *noauto) { const struct opt_map *std_opts; const struct fs_opts *dev_opts; char *opt, *topts, *xoptstr; size_t l; if (optstr == NULL) return NULL; xoptstr = strdup(optstr); /* because strtok is destructive below */ *noauto = 0; l = strlen(optstr) + 2; *xopts = (char *) xmalloc(l); topts = (char *) xmalloc(l); *topts = '\0'; **xopts = '\0'; for (opt = strtok(xoptstr, ","); opt; opt = strtok(NULL, ",")) { /* * First, parse standard options */ std_opts = opt_map; while (std_opts->opt && !NSTREQ(std_opts->opt, opt, strlen(std_opts->opt))) ++std_opts; if (!(*noauto = STREQ(opt, MNTTAB_OPT_NOAUTO)) || std_opts->opt) { xstrlcat(topts, opt, l); xstrlcat(topts, ",", l); if (std_opts->inv) *flags &= ~std_opts->mask; else *flags |= std_opts->mask; } /* * Next, select which fs-type is to be used * and parse the fs-specific options */ #ifdef MOUNT_TYPE_AUTOFS if (STREQ(type, MOUNT_TYPE_AUTOFS)) { dev_opts = autofs_opts; goto do_opts; } #endif /* MOUNT_TYPE_AUTOFS */ #ifdef MOUNT_TYPE_PCFS if (STREQ(type, MOUNT_TYPE_PCFS)) { dev_opts = dos_opts; goto do_opts; } #endif /* MOUNT_TYPE_PCFS */ #ifdef MOUNT_TYPE_CDFS if (STREQ(type, MOUNT_TYPE_CDFS)) { dev_opts = iso_opts; goto do_opts; } #endif /* MOUNT_TYPE_CDFS */ #ifdef MOUNT_TYPE_LOFS if (STREQ(type, MOUNT_TYPE_LOFS)) { dev_opts = null_opts; goto do_opts; } #endif /* MOUNT_TYPE_LOFS */ plog(XLOG_FATAL, "linux mount: unknown fs-type: %s\n", type); XFREE(xoptstr); XFREE(*xopts); XFREE(topts); return NULL; do_opts: while (dev_opts->opt && (!NSTREQ(dev_opts->opt, opt, strlen(dev_opts->opt)))) { ++dev_opts; } if (dev_opts->opt && *xopts) { xstrlcat(*xopts, opt, l); xstrlcat(*xopts, ",", l); } } /* * All other options are discarded */ if (strlen(*xopts)) *(*xopts + strlen(*xopts)-1) = '\0'; if (strlen(topts)) topts[strlen(topts)-1] = '\0'; XFREE(xoptstr); return topts; } /* * Returns combined linux kernel version number. For a kernel numbered * x.y.z, returns x*65535+y*256+z. */ int linux_version_code(void) { struct utsname my_utsname; static int release = 0; if ( 0 == release && 0 == uname(&my_utsname)) { release = 65536 * atoi(strtok(my_utsname.release, ".")) + 256 * atoi(strtok(NULL, ".")) + atoi(strtok(NULL, ".")); } return release; } int do_mount_linux(MTYPE_TYPE type, mntent_t *mnt, int flags, caddr_t data) { if (amuDebug(D_FULL)) { plog(XLOG_DEBUG, "do_mount_linux: fsname %s\n", mnt->mnt_fsname); plog(XLOG_DEBUG, "do_mount_linux: type (mntent) %s\n", mnt->mnt_type); plog(XLOG_DEBUG, "do_mount_linux: opts %s\n", mnt->mnt_opts); plog(XLOG_DEBUG, "do_mount_linux: dir %s\n", mnt->mnt_dir); } /* * If we have an nfs mount, the 5th argument to system mount() must be the * nfs_mount_data structure, otherwise it is the return from parse_opts() */ return mount(mnt->mnt_fsname, mnt->mnt_dir, type, MS_MGC_VAL | flags, data); } int mount_linux_nfs(MTYPE_TYPE type, mntent_t *mnt, int flags, caddr_t data) { nfs_args_t *mnt_data = (nfs_args_t *) data; int errorcode; /* Fake some values for linux */ mnt_data->version = NFS_MOUNT_VERSION; if (!mnt_data->timeo) { #ifdef MNT2_NFS_OPT_TCP if (mnt_data->flags & MNT2_NFS_OPT_TCP) mnt_data->timeo = 600; else #endif /* MNT2_NFS_OPT_TCP */ mnt_data->timeo = 7; } if (!mnt_data->retrans) mnt_data->retrans = 3; #ifdef MNT2_NFS_OPT_NOAC if (!(mnt_data->flags & MNT2_NFS_OPT_NOAC)) { if (!(mnt_data->flags & MNT2_NFS_OPT_ACREGMIN)) mnt_data->acregmin = 3; if (!(mnt_data->flags & MNT2_NFS_OPT_ACREGMAX)) mnt_data->acregmax = 60; if (!(mnt_data->flags & MNT2_NFS_OPT_ACDIRMIN)) mnt_data->acdirmin = 30; if (!(mnt_data->flags & MNT2_NFS_OPT_ACDIRMAX)) mnt_data->acdirmax = 60; } #endif /* MNT2_NFS_OPT_NOAC */ /* * in nfs structure implementation version 4, the old * filehandle field was renamed "old_root" and left as 3rd field, * while a new field called "root" was added to the end of the * structure. Both of them however need a copy of the file handle * for NFSv2 mounts. */ #ifdef MNT2_NFS_OPT_VER3 if (mnt_data->flags & MNT2_NFS_OPT_VER3) memset(mnt_data->old_root.data, 0, FHSIZE); else #endif /* MNT2_NFS_OPT_VER3 */ memcpy(mnt_data->old_root.data, mnt_data->root.data, FHSIZE); #ifdef HAVE_NFS_ARGS_T_BSIZE /* linux mount version 3 */ mnt_data->bsize = 0; /* let the kernel decide */ #endif /* HAVE_NFS_ARGS_T_BSIZE */ #ifdef HAVE_NFS_ARGS_T_NAMLEN /* linux mount version 2 */ mnt_data->namlen = NAME_MAX; /* 256 bytes */ #endif /* HAVE_NFS_ARGS_T_NAMELEN */ #ifdef HAVE_NFS_ARGS_T_PSEUDOFLAVOR # ifdef HAVE_RPC_AUTH_H mnt_data->pseudoflavor = AUTH_UNIX; # else mnt_data->pseudoflavor = 0; # endif #endif /* HAVE_NFS_ARGS_T_PSEUDOFLAVOR */ #ifdef HAVE_NFS_ARGS_T_CONTEXT memset(mnt_data->context, 0, sizeof(mnt_data->context)); #endif /* HAVE_NFS_ARGS_T_CONTEXT */ mnt_data->fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if (mnt_data->fd < 0) { plog(XLOG_ERROR, "Can't create socket for kernel"); return 1; } if (bindresvport(mnt_data->fd, NULL) < 0) { plog(XLOG_ERROR, "Can't bind to reserved port"); errorcode = 1; goto out; } /* * connect() the socket for kernels 1.3.10 and below * only to avoid problems with multihomed hosts. */ if (linux_version_code() <= 0x01030a) { int ret = connect(mnt_data->fd, (struct sockaddr *) &mnt_data->addr, sizeof(mnt_data->addr)); if (ret < 0) { plog(XLOG_ERROR, "Can't connect socket for kernel"); errorcode = 1; goto out; } } if (amuDebug(D_FULL)) { plog(XLOG_DEBUG, "mount_linux_nfs: type %s\n", type); plog(XLOG_DEBUG, "mount_linux_nfs: version %d\n", mnt_data->version); plog(XLOG_DEBUG, "mount_linux_nfs: fd %d\n", mnt_data->fd); plog(XLOG_DEBUG, "mount_linux_nfs: hostname %s\n", inet_ntoa(mnt_data->addr.sin_addr)); plog(XLOG_DEBUG, "mount_linux_nfs: port %d\n", htons(mnt_data->addr.sin_port)); } if (amuDebug(D_TRACE)) { plog(XLOG_DEBUG, "mount_linux_nfs: Generic mount flags 0x%x", MS_MGC_VAL | flags); plog(XLOG_DEBUG, "mount_linux_nfs: updated nfs_args..."); print_nfs_args(mnt_data, 0); } mnt_data->flags &= MNT2_NFS_OPT_FLAGMASK; errorcode = do_mount_linux(type, mnt, flags, data); out: /* * If we failed, (i.e. errorcode != 0), then close the socket * if it is open. */ if (errorcode && mnt_data->fd != -1) { /* save errno, may be clobbered by close() call! */ int save_errno = errno; close(mnt_data->fd); errno = save_errno; } return errorcode; } int mount_linux_nonfs(MTYPE_TYPE type, mntent_t *mnt, int flags, caddr_t data) { char *extra_opts = NULL; char *tmp_opts = NULL; char *sub_type = NULL; char *loopdev = NULL; int noauto = 0; int errorcode; sub_type = hasmnteq(mnt, "type"); if (sub_type) { sub_type = strdup(sub_type); if (sub_type) { /* the strdup malloc might have failed */ type = strpbrk(sub_type, ",:;\n\t"); if (type == NULL) type = MOUNT_TYPE_UFS; else { *type = '\0'; type = sub_type; } } else { plog(XLOG_ERROR, "strdup returned null in mount_linux_nonfs"); } } if (!hasmntopt(mnt, "type")) mnt->mnt_type = type; tmp_opts = parse_opts(type, mnt->mnt_opts, &flags, &extra_opts, &noauto); #ifdef MOUNT_TYPE_LOFS if (STREQ(type, MOUNT_TYPE_LOFS)) { # ifndef MNT2_GEN_OPT_BIND size_t l; /* this is basically a hack to support fist lofs */ XFREE(extra_opts); l = strlen(mnt->mnt_fsname) + sizeof("dir=") + 1; extra_opts = (char *) xmalloc(l); xsnprintf(extra_opts, l, sizeof(extra_opts), "dir=%s", mnt->mnt_fsname); # else /* MNT2_GEN_OPT_BIND */ /* use bind mounts for lofs */ flags |= MNT2_GEN_OPT_BIND; # endif /* MNT2_GEN_OPT_BIND */ errorcode = do_mount_linux(type, mnt, flags, extra_opts); } else /* end of "if type is LOFS" */ #endif /* MOUNT_TYPE_LOFS */ { #ifdef HAVE_LOOP_DEVICE /* * If the mounted "device" is actually a regular file, # try to attach a loop device to it. */ struct stat buf; char *old_fsname = NULL; if (stat(mnt->mnt_fsname, &buf) == 0 && S_ISREG(buf.st_mode)) { if ((loopdev = setup_loop_device(mnt->mnt_fsname)) != NULL) { char *str; size_t l; plog(XLOG_INFO, "setup loop device %s over %s OK", loopdev, mnt->mnt_fsname); old_fsname = mnt->mnt_fsname; mnt->mnt_fsname = loopdev; /* XXX: hack, append loop=/dev/loopX to mnttab opts */ l = strlen(mnt->mnt_opts) + 7 + strlen(loopdev); str = (char *) xmalloc(l); if (str) { xsnprintf(str, l, "%s,loop=%s", mnt->mnt_opts, loopdev); XFREE(mnt->mnt_opts); mnt->mnt_opts = str; } } else { plog(XLOG_ERROR, "failed to set up a loop device: %m"); errorcode = 1; goto out; } } #endif /* HAVE_LOOP_DEVICE */ errorcode = do_mount_linux(type, mnt, flags, extra_opts); #ifdef HAVE_LOOP_DEVICE /* if mount failed and we used a loop device, then undo it */ if (errorcode != 0 && loopdev != NULL) { if (delete_loop_device(loopdev) < 0) plog(XLOG_WARNING, "mount() failed to release loop device %s: %m", loopdev); else plog(XLOG_INFO, "mount() released loop device %s OK", loopdev); } if (old_fsname) mnt->mnt_fsname = old_fsname; #endif /* HAVE_LOOP_DEVICE */ } /* * Free all allocated space and return errorcode. */ out: if (loopdev) XFREE(loopdev); if (extra_opts != NULL) XFREE(extra_opts); if (tmp_opts != NULL) XFREE(tmp_opts); if (sub_type != NULL) XFREE(sub_type); return errorcode; } int mount_linux(MTYPE_TYPE type, mntent_t *mnt, int flags, caddr_t data) { int errorcode; if (mnt->mnt_opts && STREQ(mnt->mnt_opts, "defaults")) mnt->mnt_opts = NULL; if (type == NULL) type = index(mnt->mnt_fsname, ':') ? MOUNT_TYPE_NFS : MOUNT_TYPE_UFS; if (STREQ(type, MOUNT_TYPE_NFS)) errorcode = mount_linux_nfs(type, mnt, flags, data); else /* non-NFS mounts */ errorcode = mount_linux_nonfs(type, mnt, flags, data); return errorcode; } /****************************************************************************/ /* * NFS error numbers and Linux errno's are two different things! Linux is * `worse' than other OSes in the respect that it loudly complains about * undefined NFS return value ("bad NFS return value.."). So we should * translate ANY possible Linux errno to their NFS equivalent. Just, there * aren't much NFS numbers, so most go to EINVAL or EIO. The mapping below * should fit at least for Linux/i386 and Linux/68k. I haven't checked * other architectures yet. */ #define NE_PERM 1 #define NE_NOENT 2 #define NE_IO 5 #define NE_NXIO 6 #define NE_AGAIN 11 #define NE_ACCES 13 #define NE_EXIST 17 #define NE_NODEV 19 #define NE_NOTDIR 20 #define NE_ISDIR 21 #define NE_INVAL 22 #define NE_FBIG 27 #define NE_NOSPC 28 #define NE_ROFS 30 #define NE_OPNOTSUPP 45 #define NE_NAMETOOLONG 63 #define NE_NOTEMPTY 66 #define NE_DQUOT 69 #define NE_STALE 70 #define NE_REMOTE 71 #define NFS_LOMAP 0 #define NFS_HIMAP 122 /* * The errno's below are correct for Linux/i386. One day, somebody * with lots of energy ought to verify them against the other ports... */ static int nfs_errormap[] = { 0, /* success(0) */ NE_PERM, /* EPERM (1) */ NE_NOENT, /* ENOENT (2) */ NE_INVAL, /* ESRCH (3) */ NE_IO, /* EINTR (4) */ NE_IO, /* EIO (5) */ NE_NXIO, /* ENXIO (6) */ NE_INVAL, /* E2BIG (7) */ NE_INVAL, /* ENOEXEC (8) */ NE_INVAL, /* EBADF (9) */ NE_IO, /* ECHILD (10) */ NE_AGAIN, /* EAGAIN (11) */ NE_IO, /* ENOMEM (12) */ NE_ACCES, /* EACCES (13) */ NE_INVAL, /* EFAULT (14) */ NE_INVAL, /* ENOTBLK (15) */ NE_IO, /* EBUSY (16) */ NE_EXIST, /* EEXIST (17) */ NE_INVAL, /* EXDEV (18) */ NE_NODEV, /* ENODEV (19) */ NE_NOTDIR, /* ENOTDIR (20) */ NE_ISDIR, /* EISDIR (21) */ NE_INVAL, /* EINVAL (22) */ NE_IO, /* ENFILE (23) */ NE_IO, /* EMFILE (24) */ NE_INVAL, /* ENOTTY (25) */ NE_ACCES, /* ETXTBSY (26) */ NE_FBIG, /* EFBIG (27) */ NE_NOSPC, /* ENOSPC (28) */ NE_INVAL, /* ESPIPE (29) */ NE_ROFS, /* EROFS (30) */ NE_INVAL, /* EMLINK (31) */ NE_INVAL, /* EPIPE (32) */ NE_INVAL, /* EDOM (33) */ NE_INVAL, /* ERANGE (34) */ NE_INVAL, /* EDEADLK (35) */ NE_NAMETOOLONG, /* ENAMETOOLONG (36) */ NE_INVAL, /* ENOLCK (37) */ NE_INVAL, /* ENOSYS (38) */ NE_NOTEMPTY, /* ENOTEMPTY (39) */ NE_INVAL, /* ELOOP (40) */ NE_INVAL, /* unused (41) */ NE_INVAL, /* ENOMSG (42) */ NE_INVAL, /* EIDRM (43) */ NE_INVAL, /* ECHRNG (44) */ NE_INVAL, /* EL2NSYNC (45) */ NE_INVAL, /* EL3HLT (46) */ NE_INVAL, /* EL3RST (47) */ NE_INVAL, /* ELNRNG (48) */ NE_INVAL, /* EUNATCH (49) */ NE_INVAL, /* ENOCSI (50) */ NE_INVAL, /* EL2HLT (51) */ NE_INVAL, /* EBADE (52) */ NE_INVAL, /* EBADR (53) */ NE_INVAL, /* EXFULL (54) */ NE_INVAL, /* ENOANO (55) */ NE_INVAL, /* EBADRQC (56) */ NE_INVAL, /* EBADSLT (57) */ NE_INVAL, /* unused (58) */ NE_INVAL, /* EBFONT (59) */ NE_INVAL, /* ENOSTR (60) */ NE_INVAL, /* ENODATA (61) */ NE_INVAL, /* ETIME (62) */ NE_INVAL, /* ENOSR (63) */ NE_INVAL, /* ENONET (64) */ NE_INVAL, /* ENOPKG (65) */ NE_INVAL, /* EREMOTE (66) */ NE_INVAL, /* ENOLINK (67) */ NE_INVAL, /* EADV (68) */ NE_INVAL, /* ESRMNT (69) */ NE_IO, /* ECOMM (70) */ NE_IO, /* EPROTO (71) */ NE_IO, /* EMULTIHOP (72) */ NE_IO, /* EDOTDOT (73) */ NE_INVAL, /* EBADMSG (74) */ NE_INVAL, /* EOVERFLOW (75) */ NE_INVAL, /* ENOTUNIQ (76) */ NE_INVAL, /* EBADFD (77) */ NE_IO, /* EREMCHG (78) */ NE_IO, /* ELIBACC (79) */ NE_IO, /* ELIBBAD (80) */ NE_IO, /* ELIBSCN (81) */ NE_IO, /* ELIBMAX (82) */ NE_IO, /* ELIBEXEC (83) */ NE_INVAL, /* EILSEQ (84) */ NE_INVAL, /* ERESTART (85) */ NE_INVAL, /* ESTRPIPE (86) */ NE_INVAL, /* EUSERS (87) */ NE_INVAL, /* ENOTSOCK (88) */ NE_INVAL, /* EDESTADDRREQ (89) */ NE_INVAL, /* EMSGSIZE (90) */ NE_INVAL, /* EPROTOTYPE (91) */ NE_INVAL, /* ENOPROTOOPT (92) */ NE_INVAL, /* EPROTONOSUPPORT (93) */ NE_INVAL, /* ESOCKTNOSUPPORT (94) */ NE_INVAL, /* EOPNOTSUPP (95) */ NE_INVAL, /* EPFNOSUPPORT (96) */ NE_INVAL, /* EAFNOSUPPORT (97) */ NE_INVAL, /* EADDRINUSE (98) */ NE_INVAL, /* EADDRNOTAVAIL (99) */ NE_IO, /* ENETDOWN (100) */ NE_IO, /* ENETUNREACH (101) */ NE_IO, /* ENETRESET (102) */ NE_IO, /* ECONNABORTED (103) */ NE_IO, /* ECONNRESET (104) */ NE_IO, /* ENOBUFS (105) */ NE_IO, /* EISCONN (106) */ NE_IO, /* ENOTCONN (107) */ NE_IO, /* ESHUTDOWN (108) */ NE_IO, /* ETOOMANYREFS (109) */ NE_IO, /* ETIMEDOUT (110) */ NE_IO, /* ECONNREFUSED (111) */ NE_IO, /* EHOSTDOWN (112) */ NE_IO, /* EHOSTUNREACH (113) */ NE_IO, /* EALREADY (114) */ NE_IO, /* EINPROGRESS (115) */ NE_STALE, /* ESTALE (116) */ NE_IO, /* EUCLEAN (117) */ NE_INVAL, /* ENOTNAM (118) */ NE_INVAL, /* ENAVAIL (119) */ NE_INVAL, /* EISNAM (120) */ NE_IO, /* EREMOTEIO (121) */ NE_DQUOT, /* EDQUOT (122) */ }; int linux_nfs_error(int e) { int ret = (nfsstat) NE_IO; if (e < NFS_LOMAP || e > NFS_HIMAP) ret = (nfsstat) NE_IO; else ret = nfs_errormap[e - NFS_LOMAP]; dlog("linux_nfs_error: map error %d to NFS error %d", e, ret); return (nfsstat) ret; } #ifdef HAVE_LOOP_DEVICE /****************************************************************************/ /*** LOOP DEVICE SUPPORT ***/ /*** Loop Device setup code taken from mount-2.11g-5.src.rpm, which was ***/ /*** originally written bt Ted T'so and others. ***/ /****************************************************************************/ #define PROC_DEVICES "/proc/devices" #if not_used_yet static int show_loop(char *device) { struct loop_info loopinfo; int fd; if ((fd = open(device, O_RDONLY)) < 0) { dlog("loop: can't open device %s: %m", device); return -2; } if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) < 0) { dlog("loop: can't get info on device %s: %m", device); close(fd); return -1; } dlog("show_loop: %s: [%04x]:%ld (%s)", device, loopinfo.lo_device, loopinfo.lo_inode, loopinfo.lo_name); close(fd); return 0; } static int is_loop_device(const char *device) { struct stat statbuf; int loopmajor = 7; return (loopmajor && stat(device, &statbuf) == 0 && S_ISBLK(statbuf.st_mode) && (statbuf.st_rdev>>8) == loopmajor); } #endif /* not_used_yet */ /* * Just creating a device, say in /tmp, is probably a bad idea - people * might have problems with backup or so. So, we just try /dev/loop[0-7]. */ static char * find_unused_loop_device(void) { char dev[20]; char *loop_formats[] = { "/dev/loop%d", "/dev/loop/%d" }; int i, j, fd, somedev = 0, someloop = 0, loop_known = 0; struct stat statbuf; struct loop_info loopinfo; FILE *procdev; #define LOOP_FMT_SIZE(a) (sizeof(a)/sizeof(a[0])) for (j = 0; j < (int) LOOP_FMT_SIZE(loop_formats); j++) { for (i = 0; i < 256; i++) { xsnprintf(dev, sizeof(dev), loop_formats[j], i); if (stat(dev, &statbuf) == 0 && S_ISBLK(statbuf.st_mode)) { somedev++; fd = open(dev, O_RDONLY); if (fd >= 0) { if (ioctl(fd, LOOP_GET_STATUS, &loopinfo) == 0) someloop++; /* in use */ else if (errno == ENXIO) { close(fd); return strdup(dev); /* probably free */ } close(fd); } continue; /* continue trying as long as devices exist */ } break; } } /* Nothing found. Why not? */ if ((procdev = fopen(PROC_DEVICES, "r")) != NULL) { char line[100]; while (fgets(line, sizeof(line), procdev)) if (strstr(line, " loop\n")) { loop_known = 1; break; } fclose(procdev); if (!loop_known) loop_known = -1; } if (!somedev) { dlog("Could not find any device /dev/loop#"); } else if (!someloop) { if (loop_known == 1) { dlog("Could not find any loop device."); dlog("...Maybe /dev/loop# has a wrong major number?"); } else if (loop_known == -1) { dlog("Could not find any loop device, and, according to %s,", PROC_DEVICES); dlog("...this kernel does not know about the loop device."); dlog("... (If so, then recompile or `insmod loop.o'.)"); } else { dlog("Could not find any loop device. Maybe this kernel does not know,"); dlog("...about the loop device (then recompile or `insmod loop.o'), or"); dlog("...maybe /dev/loop# has the wrong major number?"); } } else { dlog("Could not find any free loop device!"); } return NULL; } /* returns 0 if OK, -1 otherwise */ char * setup_loop_device(const char *file) { struct loop_info loopinfo; int fd, ffd, mode, err = -1; char *device = find_unused_loop_device(); if (!device) { dlog("no unused loop device"); goto out; } mode = O_RDWR | O_LARGEFILE; if ((ffd = open(file, mode)) < 0) { if (errno == EROFS) { mode = O_RDONLY | O_LARGEFILE; ffd = open(file, mode); } if (ffd < 0) { dlog("%s: %m", file); goto out; } } if ((fd = open(device, mode)) < 0) { dlog("%s: %m", device); goto out_close; } memset(&loopinfo, 0, sizeof(loopinfo)); xstrlcpy(loopinfo.lo_name, file, LO_NAME_SIZE); loopinfo.lo_offset = 0; if (ioctl(fd, LOOP_SET_FD, ffd) < 0) { dlog("ioctl: LOOP_SET_FD: %m"); goto out_close_all; } if (ioctl(fd, LOOP_SET_STATUS, &loopinfo) < 0) { (void) ioctl(fd, LOOP_CLR_FD, 0); dlog("ioctl: LOOP_SET_STATUS: %m"); goto out_close_all; } /* if gets here, all is OK */ err = 0; out_close_all: close(fd); out_close: close(ffd); out: if (err) { XFREE(device); return NULL; } else { dlog("setup_loop_device(%s,%s): success", device, file); return device; } } int delete_loop_device(const char *device) { int fd; if ((fd = open(device, O_RDONLY)) < 0) { dlog("delete_loop_device: can't delete device %s: %m", device); return -1; } if (ioctl(fd, LOOP_CLR_FD, 0) < 0) { dlog("ioctl: LOOP_CLR_FD: %m"); return -1; } close(fd); dlog("delete_loop_device(%s): success", device); return 0; } #endif /* HAVE_LOOP_DEVICE */ /****************************************************************************/ am-utils-6.2+rc20110530/conf/mount/mount_mach3.c000066400000000000000000000062271157065440000210110ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mount/mount_mach3.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include int mount_mach3(char *type, char *mnt, int flags, caddr_t mnt_data) { int err = 0; errno = 0; if (syscall(SYS_vfsmount, type, mnt->mnt_dir, flags, mnt_data)) { err = -1; if (errno == ENODEV) { /* * might be an old kernel, need to try again * with file type number instead of string */ int typeno = 1; plog(XLOG_ERROR, "%s: 1SYS_vfsmount: %m", mnt->mnt_dir); if (STREQ(mnt->mnt_type, MOUNT_TYPE_UFS)) typeno = 0; else if (STREQ(mnt->mnt_type, MOUNT_TYPE_NFS)) typeno = 1; else plog(XLOG_ERROR, "%s: type defaults to nfs...", mnt->mnt_dir); plog(XLOG_ERROR, "%s: retry SYS_vfsmount %s %d", mnt->mnt_dir, mnt->mnt_type, typeno); if (typeno >= 0) { if (syscall(SYS_vfsmount, typeno, mnt->mnt_dir, flags, mnt_data)) { plog(XLOG_ERROR, "%s: 2SYS_vfsmount: %m", mnt->mnt_dir); } else { err = 0; } } } } return err; } am-utils-6.2+rc20110530/conf/mount/mount_stellix.c000066400000000000000000000053651157065440000215040ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mount/mount_stellix.c * */ /* * STELLIX Mount helper */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Map from conventional mount arguments * to STELLIX style arguments. */ int mount_stellix(char *fsname, char *dir, int flags, int type, void *data) { #ifdef DEBUG dlog("stellix_mount: fsname %s, dir %s, type %d", fsname, dir, type); #endif /* DEBUG */ if (type == MOUNT_TYPE_NFS) return mount(dir, dir, (MNT2_GEN_OPT_FSS | MNT2_GEN_OPT_NFS | flags), type, (caddr_t) data); if (type == MOUNT_TYPE_UFS) return mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags), type); return EINVAL; } am-utils-6.2+rc20110530/conf/mount/mount_svr4.c000066400000000000000000000152111157065440000207050ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mount/mount_svr4.c * */ /* * SVR4: * Solaris 2.x (SunOS 5.x) and HPUX-11 Mount helper. * -Erez Zadok */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * On Solaris 8 with in-kernel mount table, pass mount options to kernel to * have them evaluated. They will also show up in /etc/mnttab. */ #if defined(MNT2_GEN_OPT_OPTIONSTR) && defined(MAX_MNTOPT_STR) # define sys_mount(fsname, dir, flags, type, data, datasize) \ mount((fsname), (dir), (MNT2_GEN_OPT_OPTIONSTR | flags), (type), \ (data), (datasize), mountopts, sizeof(mountopts)) #else /* not defined(MNT2_GEN_OPT_OPTIONSTR) && defined(MAX_MNTOPT_STR) */ # define sys_mount(fsname, dir, flags, type, data, datasize) \ mount((fsname), (dir), (flags), (type), (data), (datasize)) #endif /* not defined(MNT2_GEN_OPT_OPTIONSTR) && defined(MAX_MNTOPT_STR) */ /* * Map from conventional mount arguments * to Solaris 2.x (SunOS 5.x) style arguments. */ int mount_svr4(char *fsname, char *dir, int flags, MTYPE_TYPE type, caddr_t data, const char *optstr) { #if defined(MNT2_GEN_OPT_OPTIONSTR) && defined(MAX_MNTOPT_STR) char mountopts[MAX_MNTOPT_STR]; /* * Save a copy of the mount options. The kernel will overwrite them with * those it recognizes. */ xstrlcpy(mountopts, optstr, MAX_MNTOPT_STR); #endif /* defined(MNT2_GEN_OPT_OPTIONSTR) && defined(MAX_MNTOPT_STR) */ #if defined(MOUNT_TYPE_NFS3) && defined(MNTTAB_TYPE_NFS3) if (STREQ(type, MOUNT_TYPE_NFS3)) { return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags), type, (char *) data, sizeof(nfs_args_t)); } #endif /* defined(MOUNT_TYPE_NFS3) && defined(MNTTAB_TYPE_NFS3) */ #if defined(MOUNT_TYPE_NFS) && defined(MNTTAB_TYPE_NFS) if (STREQ(type, MOUNT_TYPE_NFS)) { return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags), type, (char *) data, sizeof(nfs_args_t)); } #endif /* defined(MOUNT_TYPE_NFS) && defined(MNTTAB_TYPE_NFS) */ #if defined(MOUNT_TYPE_AUTOFS) && defined(MNTTAB_TYPE_AUTOFS) if (STREQ(type, MOUNT_TYPE_AUTOFS)) { return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags), type, (char *) data, sizeof(autofs_args_t)); } #endif /* defined(MOUNT_TYPE_AUTOFS) && defined(MNTTAB_TYPE_AUTOFS) */ #if defined(MOUNT_TYPE_UFS) && defined(MNTTAB_TYPE_UFS) if (STREQ(type, MOUNT_TYPE_UFS)) return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags), type, (char *) data, sizeof(ufs_args_t)); #endif /* defined(MOUNT_TYPE_UFS) && defined(MNTTAB_TYPE_UFS) */ #if defined(MOUNT_TYPE_PCFS) && defined(MNTTAB_TYPE_PCFS) if (STREQ(type, MOUNT_TYPE_PCFS)) return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags), type, (char *) data, sizeof(pcfs_args_t)); #endif /* defined(MOUNT_TYPE_PCFS) && defined(MNTTAB_TYPE_PCFS) */ #if defined(MOUNT_TYPE_CDFS) && defined(MNTTAB_TYPE_CDFS) /* * HSFS on Solaris allows for 3 HSFSMNT_* flags to be passed * as arguments to the mount(). These flags are bit fields in an * integer, and that integer is passed as the "data" of this system * call. The flags are described in . However, * Solaris does not have an interface to these. It does not define * a structure hsfs_args or anything that one can figure out what * arguments to pass to mount(2) for this type of filesystem. * Therefore, until Sun does, no arguments are passed to this mount * below. * -Erez Zadok . */ if (STREQ(type, MOUNT_TYPE_CDFS)) return sys_mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags), type, (char *) NULL, 0); #endif /* defined(MOUNT_TYPE_CDFS) && defined(MNTTAB_TYPE_CDFS) */ #if defined(MOUNT_TYPE_LOFS) && defined(MNTTAB_TYPE_LOFS) if (STREQ(type, MOUNT_TYPE_LOFS)) return sys_mount(fsname, dir, (MNT2_GEN_OPT_FSS | flags), type, (char *) NULL, 0); #endif /* defined(MOUNT_TYPE_LOFS) && defined(MNTTAB_TYPE_LOFS) */ #ifdef HAVE_FS_CACHEFS # if defined(MOUNT_TYPE_CACHEFS) && defined(MNTTAB_TYPE_CACHEFS) if (STREQ(type, MOUNT_TYPE_CACHEFS)) return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags), type, (char *) data, sizeof(cachefs_args_t)); # endif /* defined(MOUNT_TYPE_CACHEFS) && defined(MNTTAB_TYPE_CACHEFS) */ #endif /*HAVE_FS_CACHEFS */ #ifdef HAVE_FS_AUTOFS # if defined(MOUNT_TYPE_AUTOFS) && defined(MNTTAB_TYPE_AUTOFS) if (STREQ(type, MOUNT_TYPE_AUTOFS)) return sys_mount(fsname, dir, (MNT2_GEN_OPT_DATA | flags), type, (char *) data, sizeof(autofs_args_t)); # endif /* defined(MOUNT_TYPE_AUTOFS) && defined(MNTTAB_TYPE_AUTOFS) */ #endif /* HAVE_FS_AUTOFS */ return EINVAL; } am-utils-6.2+rc20110530/conf/mtab/000077500000000000000000000000001157065440000162025ustar00rootroot00000000000000am-utils-6.2+rc20110530/conf/mtab/mtab_aix.c000066400000000000000000000120421157065440000201310ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mtab/mtab_aix.c * */ /* * AIX systems don't write their mount tables on a file. Instead, they * use a (better) system where the kernel keeps this state, and you access * the mount tables via a known interface. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * These were missing external definitions from old AIX's headers. They * appear to be available in on AIX 5.3, and possibly * earlier. Hence I commented this out. */ #ifndef HAVE_EXTERN_MNTCTL extern int mntctl(int cmd, int size, voidp buf); #endif /* not HAVE_EXTERN_MNTCTL */ static mntent_t * mnt_dup(struct vmount *mp) { mntent_t *new_mp = ALLOC(mntent_t); char *ty; char *fsname = strdup(vmt2dataptr(mp, VMT_OBJECT)); new_mp->mnt_dir = strdup(vmt2dataptr(mp, VMT_STUB)); new_mp->mnt_opts = strdup(vmt2dataptr(mp, VMT_ARGS)); switch (mp->vmt_gfstype) { case MOUNT_TYPE_UFS: ty = MNTTAB_TYPE_UFS; new_mp->mnt_fsname = strdup(fsname); break; case MOUNT_TYPE_NFS: ty = MNTTAB_TYPE_NFS; new_mp->mnt_fsname = str3cat((char *) NULL, vmt2dataptr(mp, VMT_HOSTNAME), ":", fsname); break; #ifdef HAVE_FS_NFS3 case MOUNT_TYPE_NFS3: ty = MNTTAB_TYPE_NFS3; new_mp->mnt_fsname = str3cat((char *) NULL, vmt2dataptr(mp, VMT_HOSTNAME), ":", fsname); break; #endif /* HAVE_FS_NFS3 */ default: ty = "unknown"; new_mp->mnt_fsname = strdup(fsname); break; } new_mp->mnt_type = strdup(ty); /* store the VFS ID for uvmount() */ new_mp->mnt_passno = mp->vmt_vfsnumber; new_mp->mnt_freq = 0; XFREE(fsname); return new_mp; } /* * Read a mount table into memory */ mntlist * read_mtab(char *fs, const char *mnttabname) { mntlist **mpp, *mhp; int i; char *mntinfo = NULL, *cp; struct vmount *vp; int ret; int maxtry = 10; /* maximum number of times to try mntctl */ /* * Figure out size of mount table and allocate space for a copy. Then get * mount table for real. We repeat this loop at most 10 times to minimze * the chance of a race condition (something gets un/mounted in between * calls to mntctl() */ i = sizeof(int); do { if (mntinfo) XFREE(mntinfo); mntinfo = xmalloc(i); ret = mntctl(MCTL_QUERY, i, mntinfo); if (ret == 0) i = *(int*) mntinfo; if (--maxtry <= 0) { plog(XLOG_ERROR, "mntctl: could not get a stable result"); ret = -1; errno = EINVAL; break; } } while (ret == 0); if (ret < 0) { plog(XLOG_ERROR, "mntctl: %m"); goto out; } mpp = &mhp; for (i = 0, cp = mntinfo; i < ret; i++, cp += vp->vmt_length) { vp = (struct vmount *) cp; /* * Allocate a new slot */ *mpp = ALLOC(struct mntlist); /* * Copy the data returned by mntctl */ (*mpp)->mnt = mnt_dup(vp); /* * Move to next pointer */ mpp = &(*mpp)->mnext; } *mpp = NULL; out: if (mntinfo) XFREE(mntinfo); return mhp; } am-utils-6.2+rc20110530/conf/mtab/mtab_bsd.c000066400000000000000000000102561157065440000201250ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mtab/mtab_bsd.c * */ /* * BSD 4.4 systems don't write their mount tables on a file. Instead, they * use a (better) system where the kernel keeps this state, and you access * the mount tables via a known interface. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #if __NetBSD_Version__ > 200030000 #define statfs statvfs #endif static mntent_t * mnt_dup(struct statfs *mp) { mntent_t *new_mp = ALLOC(mntent_t); char *ty; new_mp->mnt_fsname = strdup(mp->f_mntfromname); new_mp->mnt_dir = strdup(mp->f_mntonname); #ifdef HAVE_STRUCT_STATFS_F_FSTYPENAME ty = mp->f_fstypename; #else /* not HAVE_STRUCT_STATFS_F_FSTYPENAME */ switch (mp->f_type) { # if defined(MOUNT_UFS) && defined(MNTTAB_TYPE_UFS) case MOUNT_UFS: ty = MNTTAB_TYPE_UFS; break; # endif /* defined(MOUNT_UFS) && defined(MNTTAB_TYPE_UFS) */ # if defined(MOUNT_NFS) && defined(MNTTAB_TYPE_NFS) case MOUNT_NFS: ty = MNTTAB_TYPE_NFS; break; # endif /* defined(MOUNT_NFS) && defined(MNTTAB_TYPE_NFS) */ # if defined(MOUNT_MFS) && defined(MNTTAB_TYPE_MFS) case MOUNT_MFS: ty = MNTTAB_TYPE_MFS; break; # endif /* defined(MOUNT_MFS) && defined(MNTTAB_TYPE_MFS) */ default: ty = "unknown"; break; } #endif /* not HAVE_STRUCT_STATFS_F_FSTYPENAME */ new_mp->mnt_type = strdup(ty); new_mp->mnt_opts = strdup("unset"); new_mp->mnt_freq = 0; new_mp->mnt_passno = 0; return new_mp; } /* * Read a mount table into memory */ mntlist * read_mtab(char *fs, const char *mnttabname) { mntlist **mpp, *mhp; struct statfs *mntbufp, *mntp; int nloc = getmntinfo(&mntbufp, MNT_NOWAIT); if (nloc == 0) { plog(XLOG_ERROR, "Can't read mount table"); return 0; } mpp = &mhp; for (mntp = mntbufp; mntp < mntbufp + nloc; mntp++) { /* * Allocate a new slot */ *mpp = ALLOC(struct mntlist); /* * Copy the data returned by getmntent */ (*mpp)->mnt = mnt_dup(mntp); /* * Move to next pointer */ mpp = &(*mpp)->mnext; } /* * Terminate the list */ *mpp = NULL; return mhp; } am-utils-6.2+rc20110530/conf/mtab/mtab_file.c000066400000000000000000000264721157065440000203030ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mtab/mtab_file.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #define NFILE_RETRIES 10 /* number of retries (seconds) */ #ifdef MOUNT_TABLE_ON_FILE static FILE *mnt_file; /* * If the system is being trashed by something, then * opening mtab may fail with ENFILE. So, go to sleep * for a second and try again. (Yes - this has happened to me.) * * Note that this *may* block the automounter, oh well. * If we get to this state then things are badly wrong anyway... * * Give the system 10 seconds to recover but then give up. * Hopefully something else will exit and free up some file * table slots in that time. */ # ifdef HAVE_FLOCK # define lock(fd) (flock((fd), LOCK_EX)) # else /* not HAVE_FLOCK */ static int lock(int fd) { int rc; struct flock lk; lk.l_type = F_WRLCK; lk.l_whence = 0; lk.l_start = 0; lk.l_len = 0; again: rc = fcntl(fd, F_SETLKW, (caddr_t) & lk); if (rc < 0 && (errno == EACCES || errno == EAGAIN)) { # ifdef DEBUG dlog("Blocked, trying to obtain exclusive mtab lock"); # endif /* DEBUG */ sleep(1); goto again; } return rc; } # endif /* not HAVE_FLOCK */ static FILE * open_locked_mtab(const char *mnttabname, char *mode, char *fs) { FILE *mfp = NULL; /* * There is a possible race condition if two processes enter * this routine at the same time. One will be blocked by the * exclusive lock below (or by the shared lock in setmntent) * and by the time the second process has the exclusive lock * it will be on the wrong underlying object. To check for this * the mtab file is stat'ed before and after all the locking * sequence, and if it is a different file then we assume that * it may be the wrong file (only "may", since there is another * race between the initial stat and the setmntent). * * Simpler solutions to this problem are invited... */ int racing = 2; int rc; int retries = 0; struct stat st_before, st_after; if (mnt_file) { # ifdef DEBUG dlog("Forced close on %s in read_mtab", mnttabname); # endif /* DEBUG */ endmntent(mnt_file); mnt_file = NULL; } again: if (mfp) { endmntent(mfp); mfp = NULL; } if (stat(mnttabname, &st_before) < 0) { plog(XLOG_ERROR, "%s: stat: %m", mnttabname); if (errno == ESTALE) { /* happens occasionally */ sleep(1); goto again; } /* * If 'mnttabname' file does not exist give setmntent() a * chance to create it (depending on the mode). * Otherwise, bail out. */ else if (errno != ENOENT) { return 0; } } eacces: mfp = setmntent((char *)mnttabname, mode); if (!mfp) { /* * Since setmntent locks the descriptor, it * is possible it can fail... so retry if * needed. */ if (errno == EACCES || errno == EAGAIN) { # ifdef DEBUG dlog("Blocked, trying to obtain exclusive mtab lock"); # endif /* DEBUG */ goto eacces; } else if (errno == ENFILE && retries++ < NFILE_RETRIES) { sleep(1); goto eacces; } plog(XLOG_ERROR, "setmntent(\"%s\", \"%s\"): %m", mnttabname, mode); return 0; } /* * At this point we have an exclusive lock on the mount list, * but it may be the wrong one so... */ /* * Need to get an exclusive lock on the current * mount table until we have a new copy written * out, when the lock is released in free_mntlist. * flock is good enough since the mount table is * not shared between machines. */ do rc = lock(fileno(mfp)); while (rc < 0 && errno == EINTR); if (rc < 0) { plog(XLOG_ERROR, "Couldn't lock %s: %m", mnttabname); endmntent(mfp); return 0; } /* * Now check whether the mtab file has changed under our feet */ if (stat(mnttabname, &st_after) < 0) { plog(XLOG_ERROR, "%s: stat: %m", mnttabname); goto again; } if (st_before.st_dev != st_after.st_dev || st_before.st_ino != st_after.st_ino) { struct timeval tv; if (racing == 0) { /* Sometimes print a warning */ plog(XLOG_WARNING, "Possible mount table race - retrying %s", fs); } racing = (racing + 1) & 3; /* * Take a nap. From: Doug Kingston */ tv.tv_sec = 0; tv.tv_usec = (am_mypid & 0x07) << 17; if (tv.tv_usec) if (select(0, (voidp) 0, (voidp) 0, (voidp) 0, &tv) < 0) plog(XLOG_WARNING, "mtab nap failed: %m"); goto again; } return mfp; } /* * Unlock the mount table */ void unlock_mntlist(void) { /* * Release file lock, by closing the file */ if (mnt_file) { dlog("unlock_mntlist: releasing"); endmntent(mnt_file); mnt_file = NULL; } } /* * Write out a mount list */ void rewrite_mtab(mntlist *mp, const char *mnttabname) { FILE *mfp; int error = 0; /* * Concoct a temporary name in the same directory as the target mount * table so that rename() will work. */ char tmpname[64]; int retries; int tmpfd; char *cp; char mcp[128]; xstrlcpy(mcp, mnttabname, sizeof(mcp)); cp = strrchr(mcp, '/'); if (cp) { memmove(tmpname, mcp, cp - mcp); tmpname[cp - mcp] = '\0'; } else { plog(XLOG_WARNING, "No '/' in mtab (%s), using \".\" as tmp directory", mnttabname); tmpname[0] = '.'; tmpname[1] = '\0'; } xstrlcat(tmpname, "/mtabXXXXXX", sizeof(tmpname)); retries = 0; enfile1: #ifdef HAVE_MKSTEMP tmpfd = mkstemp(tmpname); fchmod(tmpfd, 0644); #else /* not HAVE_MKSTEMP */ mktemp(tmpname); tmpfd = open(tmpname, O_RDWR | O_CREAT | O_TRUNC, 0644); #endif /* not HAVE_MKSTEMP */ if (tmpfd < 0) { if (errno == ENFILE && retries++ < NFILE_RETRIES) { sleep(1); goto enfile1; } plog(XLOG_ERROR, "%s: open: %m", tmpname); return; } if (close(tmpfd) < 0) plog(XLOG_ERROR, "Couldn't close tmp file descriptor: %m"); retries = 0; enfile2: mfp = setmntent(tmpname, "w"); if (!mfp) { if (errno == ENFILE && retries++ < NFILE_RETRIES) { sleep(1); goto enfile2; } plog(XLOG_ERROR, "setmntent(\"%s\", \"w\"): %m", tmpname); error = 1; goto out; } while (mp) { if (mp->mnt) { if (addmntent(mfp, mp->mnt)) { plog(XLOG_ERROR, "Can't write entry to %s", tmpname); error = 1; goto out; } } mp = mp->mnext; } /* * SunOS 4.1 manuals say that the return code from entmntent() * is always 1 and to treat as a void. That means we need to * call fflush() to make sure the new mtab file got written. */ if (fflush(mfp)) { plog(XLOG_ERROR, "flush new mtab file: %m"); error = 1; goto out; } (void) endmntent(mfp); /* * Rename temporary mtab to real mtab */ if (rename(tmpname, mnttabname) < 0) { plog(XLOG_ERROR, "rename %s to %s: %m", tmpname, mnttabname); error = 1; goto out; } out: if (error) (void) unlink(tmpname); } static void mtab_stripnl(char *s) { do { s = strchr(s, '\n'); if (s) *s++ = ' '; } while (s); } /* * Append a mntent structure to the * current mount table. */ void write_mntent(mntent_t *mp, const char *mnttabname) { int retries = 0; FILE *mfp; enfile: mfp = open_locked_mtab(mnttabname, "a", mp->mnt_dir); if (mfp) { mtab_stripnl(mp->mnt_opts); if (addmntent(mfp, mp)) plog(XLOG_ERROR, "Couldn't write %s: %m", mnttabname); if (fflush(mfp)) plog(XLOG_ERROR, "Couldn't flush %s: %m", mnttabname); (void) endmntent(mfp); } else { if (errno == ENFILE && retries < NFILE_RETRIES) { sleep(1); goto enfile; } plog(XLOG_ERROR, "setmntent(\"%s\", \"a\"): %m", mnttabname); } } #endif /* MOUNT_TABLE_ON_FILE */ static mntent_t * mnt_dup(mntent_t *mp) { mntent_t *new_mp = ALLOC(mntent_t); new_mp->mnt_fsname = strdup(mp->mnt_fsname); new_mp->mnt_dir = strdup(mp->mnt_dir); new_mp->mnt_type = strdup(mp->mnt_type); new_mp->mnt_opts = strdup(mp->mnt_opts); new_mp->mnt_freq = mp->mnt_freq; new_mp->mnt_passno = mp->mnt_passno; #ifdef HAVE_MNTENT_T_MNT_TIME # ifdef HAVE_MNTENT_T_MNT_TIME_STRING new_mp->mnt_time = strdup(mp->mnt_time); # else /* not HAVE_MNTENT_T_MNT_TIME_STRING */ new_mp->mnt_time = mp->mnt_time; # endif /* not HAVE_MNTENT_T_MNT_TIME_STRING */ #endif /* HAVE_MNTENT_T_MNT_TIME */ #ifdef HAVE_MNTENT_T_MNT_CNODE new_mp->mnt_cnode = mp->mnt_cnode; #endif /* HAVE_MNTENT_T_MNT_CNODE */ return new_mp; } /* * Read a mount table into memory */ mntlist * read_mtab(char *fs, const char *mnttabname) { mntlist **mpp, *mhp; mntent_t *mep; FILE *mfp = open_locked_mtab(mnttabname, "r+", fs); if (!mfp) return 0; mpp = &mhp; /* * XXX - In SunOS 4 there is (yet another) memory leak * which loses 1K the first time getmntent is called. * (jsp) */ while ((mep = getmntent(mfp))) { /* * Allocate a new slot */ *mpp = ALLOC(struct mntlist); /* * Copy the data returned by getmntent */ (*mpp)->mnt = mnt_dup(mep); /* * Move to next pointer */ mpp = &(*mpp)->mnext; } *mpp = NULL; #ifdef MOUNT_TABLE_ON_FILE /* * If we are not updating the mount table then we * can free the resources held here, otherwise they * must be held until the mount table update is complete */ mnt_file = mfp; #else /* not MOUNT_TABLE_ON_FILE */ endmntent(mfp); #endif /* not MOUNT_TABLE_ON_FILE */ return mhp; } am-utils-6.2+rc20110530/conf/mtab/mtab_isc3.c000066400000000000000000000142211157065440000202120ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mtab/mtab_isc3.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* fd for /etc/.mnt.lock (also act as flag for: is_locked) */ static int mtlckf = 0; static char mtlckname[] = "/etc/.mnt.lock"; static char mnttabname[] = "/etc/mnttab"; static void unlockmnttab(void) { if (mtlckf) { close(mtlckf); mtlckf = 0; } } static lockfile(int fd, int type) { struct flock lk; lk.l_type = type; lk.l_whence = 0; lk.l_start = 0; lk.l_len = 0; return fcntl(fd, F_SETLKW, &lk); } static lockmnttab(void) { if (mtlckf == 0) { /* need lock on /etc/.mnt.lock */ mtlckf = open(mtlckname, O_RDWR); if (mtlckf >= 0) { if (lockfile(mtlckf, F_WRLCK) < 0) { close(mtlckf); mtlckf = 0; #ifdef DEBUG dlog("lock failed %m"); #endif /* DEBUG */ } else { return 0; } } } plog(XLOG_ERROR, "Unable to lock %s: %m", mtlckname); return -1; } void unlock_mntlist(void) { dlog("unlock_mntlist: releasing"); unlockmnttab(); } /* convert from ix386 mnttab to amd mntent */ static mntent_t * mnt_dup(mntent_t *mp) { /* note: may not be null terminated */ mntent_t *new_mp = ALLOC(mntent_t); char nullcpy[128]; xstrlcpy(nullcpy, mp->mt_dev, 32); new_mp->mnt_fsname = strdup(nullcpy); xstrlcpy(nullcpy, mp->mt_filsys, 32); new_mp->mnt_dir = strdup(nullcpy); xstrlcpy(nullcpy, mp->mt_fstyp, 16); new_mp->mnt_type = strdup(nullcpy); xstrlcpy(nullcpy, mp->mt_mntopts, 64); new_mp->mnt_opts = strdup(nullcpy); new_mp->mnt_freq = 0; new_mp->mnt_passno = 0; new_mp->mnt_time = mp->mt_time; new_mp->mnt_ro = mp->mt_ro_flg; return new_mp; } /* convert back (static alloc) */ static mntent_t * mtab_of(mntent_t *mnt) { static mntent_t mt; xstrlcpy(mt.mt_dev, mnt->mnt_fsname, 32); xstrlcpy(mt.mt_filsys, mnt->mnt_dir, 32); mt.mt_ro_flg = mnt->mnt_ro; mt.mt_time = mnt->mnt_time; xstrlcpy(mt.mt_fstyp, mnt->mnt_type, 16); xstrlcpy(mt.mt_mntopts, mnt->mnt_opts, 64); return &mt; } /* * Read a mount table into memory */ mntlist * read_mtab(char *fs, const char *mnttabname) { mntlist **mpp, *mhp; /* From: Piete Brooks */ int fd; mntent_t mountbuffer[NMOUNT], *fs_data; int ret; int nmts; if (lockmnttab() != 0) return (mntlist *) NULL; fd = open(mnttabname, O_RDONLY); if (fd < 0) { plog(XLOG_ERROR, "Can't open %s: %m", mnttabname); return (mntlist *) NULL; } mpp = &mhp; while ((ret = read(fd, (char *) mountbuffer, NMOUNT * sizeof(mntent_t))) > 0) { nmts = ret / sizeof(mntent_t); for (fs_data = mountbuffer; fs_data < &mountbuffer[nmts]; fs_data++) { /* * Allocate a new slot */ *mpp = ALLOC(struct mntlist); /* * Copy the data returned by getmntent */ (*mpp)->mnt = mnt_dup(fs_data); /* * Move to next pointer */ mpp = &(*mpp)->mnext; } } if (ret < 0) { plog(XLOG_ERROR, "read error on %s: %m", mnttabname); unlockmnttab(); mhp = (mntlist *) NULL; } *mpp = NULL; close(fd); return mhp; } static write_mntent_to_mtab(int fd, mntent_t *mnt) { int wr; eagain: wr = write(fd, (char *) mtab_of(mnt), sizeof(mntent_t)); if (wr < 0) { switch (wr) { case EAGAIN: goto eagain; default: return -1; } } if (wr != sizeof(mntent_t)) plog(XLOG_ERROR, "Can't write entry to %s: %m", mnttabname); return 0; } void rewrite_mtab(mntlist *mp, const char *mnttabname) { int fd; assert(mtlckf != 0); fd = open(mnttabname, O_RDWR | O_TRUNC); if (fd < 0) { plog(XLOG_ERROR, "Can't open %s: %m", mnttabname); unlockmnttab(); } while (mp) { if (mp->mnt) write_mntent_to_mtab(fd, mp->mnt); mp = mp->mnext; } close(fd); unlockmnttab(); } void write_mntent(mntent_t *mp, const char *mnttabname) { int fd; if (lockmnttab() == -1) return; fd = open(mnttabname, O_RDWR | O_APPEND); if (fd < 0) { plog(XLOG_ERROR, "Unable to append %s: %m", mnttabname); return; } write_mntent_to_mtab(fd, mp); close(fd); unlockmnttab(); } am-utils-6.2+rc20110530/conf/mtab/mtab_linux.c000066400000000000000000000341241157065440000205140ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mtab/mtab_linux.c * */ /* This file was adapted by Red Hat for Linux from mtab_file.c */ /* * The locking code must be kept in sync with that used * by the mount command in util-linux, otherwise you'll * end with with race conditions leading to a corrupt * /etc/mtab, particularly when AutoFS is used on same * machine as AMD. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #define NFILE_RETRIES 10 /* number of retries (seconds) */ #define LOCK_TIMEOUT 10 #ifdef MOUNT_TABLE_ON_FILE # define PROC_MOUNTS "/proc/mounts" static FILE *mnt_file = NULL; /* Information about mtab. ------------------------------------*/ static int have_mtab_info = 0; static int var_mtab_does_not_exist = 0; static int var_mtab_is_a_symlink = 0; /* Flag for already existing lock file. */ static int we_created_lockfile = 0; static int lockfile_fd = -1; static void get_mtab_info(void) { struct stat mtab_stat; if (!have_mtab_info) { if (lstat(MOUNTED, &mtab_stat)) var_mtab_does_not_exist = 1; else if (S_ISLNK(mtab_stat.st_mode)) var_mtab_is_a_symlink = 1; have_mtab_info = 1; } } static int mtab_is_a_symlink(void) { get_mtab_info(); return var_mtab_is_a_symlink; } static int mtab_is_writable() { static int ret = -1; /* * Should we write to /etc/mtab upon an update? Probably not if it is a * symlink to /proc/mounts, since that would create a file /proc/mounts in * case the proc filesystem is not mounted. */ if (mtab_is_a_symlink()) return 0; if (ret == -1) { int fd = open(MOUNTED, O_RDWR | O_CREAT, 0644); if (fd >= 0) { close(fd); ret = 1; } else ret = 0; } return ret; } static void setlkw_timeout(int sig) { /* nothing, fcntl will fail anyway */ } /* * Create the lock file. * The lock file will be removed if we catch a signal or when we exit. * * The old code here used flock on a lock file /etc/mtab~ and deleted * this lock file afterwards. However, as rgooch remarks, that has a * race: a second mount may be waiting on the lock and proceed as * soon as the lock file is deleted by the first mount, and immediately * afterwards a third mount comes, creates a new /etc/mtab~, applies * flock to that, and also proceeds, so that the second and third mount * now both are scribbling in /etc/mtab. * The new code uses a link() instead of a creat(), where we proceed * only if it was us that created the lock, and hence we always have * to delete the lock afterwards. Now the use of flock() is in principle * superfluous, but avoids an arbitrary sleep(). */ /* * Where does the link point to? Obvious choices are mtab and mtab~~. * HJLu points out that the latter leads to races. Right now we use * mtab~. instead. */ #define MOUNTED_LOCK "/etc/mtab~" #define MOUNTLOCK_LINKTARGET MOUNTED_LOCK "%d" int lock_mtab(void) { int tries = 100000, i; char *linktargetfile; size_t l; int rc = 1; /* * Redhat's original code set a signal handler called "handler()" for all * non-ALRM signals. The handler called unlock_mntlist(), plog'ed the * signal name, and then exit(1)! Never, ever, exit() from inside a * utility function. This messed up Amd's careful signal-handling code, * and caused Amd to abort uncleanly only any other "innocent" signal * (even simple SIGUSR1), leaving behind a hung Amd mnt point. That code * should have at least restored the signal handlers' states upon a * successful mtab unlocking. Anyway, that handler was unnecessary, * because will call unlock_mntlist() properly anyway on exit. */ setup_sighandler(SIGALRM, setlkw_timeout); /* somewhat clumsy, but some ancient systems do not have snprintf() */ /* use 20 as upper bound for the length of %d output */ l = strlen(MOUNTLOCK_LINKTARGET) + 20; linktargetfile = xmalloc(l); xsnprintf(linktargetfile, l, MOUNTLOCK_LINKTARGET, getpid()); i = open(linktargetfile, O_WRONLY|O_CREAT, 0); if (i < 0) { int errsv = errno; /* * linktargetfile does not exist (as a file) and we cannot create * it. Read-only filesystem? Too many files open in the system? * Filesystem full? */ plog(XLOG_ERROR, "can't create lock file %s: %s (use -n flag to override)", linktargetfile, strerror(errsv)); } close(i); /* Repeat until it was us who made the link */ while (!we_created_lockfile) { struct flock flock; int errsv, j; j = link(linktargetfile, MOUNTED_LOCK); errsv = errno; if (j < 0 && errsv != EEXIST) { (void) unlink(linktargetfile); plog(XLOG_ERROR, "can't link lock file %s: %s ", MOUNTED_LOCK, strerror(errsv)); rc = 0; goto error; } lockfile_fd = open(MOUNTED_LOCK, O_WRONLY); if (lockfile_fd < 0) { int errsv = errno; /* Strange... Maybe the file was just deleted? */ if (errno == ENOENT && tries-- > 0) { if (tries % 200 == 0) usleep(30); continue; } (void) unlink(linktargetfile); plog(XLOG_ERROR,"can't open lock file %s: %s ", MOUNTED_LOCK, strerror(errsv)); rc = 0; goto error; } flock.l_type = F_WRLCK; flock.l_whence = SEEK_SET; flock.l_start = 0; flock.l_len = 0; if (j == 0) { /* We made the link. Now claim the lock. */ if (fcntl(lockfile_fd, F_SETLK, &flock) == -1) { int errsv = errno; plog(XLOG_ERROR, "Can't lock lock file %s: %s", MOUNTED_LOCK, strerror(errsv)); /* proceed, since it was us who created the lockfile anyway */ } we_created_lockfile = 1; (void) unlink(linktargetfile); } else { static int tries = 0; /* Someone else made the link. Wait. */ alarm(LOCK_TIMEOUT); if (fcntl(lockfile_fd, F_SETLKW, &flock) == -1) { int errsv = errno; (void) unlink(linktargetfile); plog(XLOG_ERROR, "can't lock lock file %s: %s", MOUNTED_LOCK, (errno == EINTR) ? "timed out" : strerror(errsv)); rc = 0; goto error; } alarm(0); /* * Limit the number of iterations - maybe there * still is some old /etc/mtab~ */ ++tries; if (tries % 200 == 0) usleep(30); if (tries > 100000) { (void) unlink(linktargetfile); close(lockfile_fd); plog(XLOG_ERROR, "Cannot create link %s; Perhaps there is a stale lock file?", MOUNTED_LOCK); rc = 0; goto error; } close(lockfile_fd); } } error: if (linktargetfile != NULL) { XFREE(linktargetfile); } return rc; } static FILE * open_locked_mtab(const char *mnttabname, char *mode, char *fs) { FILE *mfp = NULL; if (mnt_file) { dlog("Forced close on %s in read_mtab", mnttabname); endmntent(mnt_file); mnt_file = NULL; } if (!mtab_is_a_symlink() && !lock_mtab()) { plog(XLOG_ERROR, "Couldn't lock mtab"); return 0; } mfp = setmntent((char *)mnttabname, mode); if (!mfp) { plog(XLOG_ERROR, "setmntent(\"%s\", \"%s\"): %m", mnttabname, mode); return 0; } return mfp; } /* * Unlock the mount table */ void unlock_mntlist(void) { if (mnt_file || we_created_lockfile) dlog("unlock_mntlist: releasing"); if (mnt_file) { endmntent(mnt_file); mnt_file = NULL; } if (we_created_lockfile) { close(lockfile_fd); lockfile_fd = -1; unlink(MOUNTED_LOCK); we_created_lockfile = 0; } } /* * Write out a mount list */ void rewrite_mtab(mntlist *mp, const char *mnttabname) { FILE *mfp; int error = 0; char tmpname[64]; int retries; int tmpfd; char *cp; char mcp[128]; if (!mtab_is_writable()) { return; } /* * Concoct a temporary name in the same directory as the target mount * table so that rename() will work. */ xstrlcpy(mcp, mnttabname, sizeof(mcp)); cp = strrchr(mcp, '/'); if (cp) { memmove(tmpname, mcp, cp - mcp); tmpname[cp - mcp] = '\0'; } else { plog(XLOG_WARNING, "No '/' in mtab (%s), using \".\" as tmp directory", mnttabname); tmpname[0] = '.'; tmpname[1] = '\0'; } xstrlcat(tmpname, "/mtabXXXXXX", sizeof(tmpname)); retries = 0; enfile1: #ifdef HAVE_MKSTEMP tmpfd = mkstemp(tmpname); fchmod(tmpfd, 0644); #else /* not HAVE_MKSTEMP */ mktemp(tmpname); tmpfd = open(tmpname, O_RDWR | O_CREAT | O_TRUNC, 0644); #endif /* not HAVE_MKSTEMP */ if (tmpfd < 0) { if (errno == ENFILE && retries++ < NFILE_RETRIES) { sleep(1); goto enfile1; } plog(XLOG_ERROR, "%s: open: %m", tmpname); return; } if (close(tmpfd) < 0) plog(XLOG_ERROR, "Couldn't close tmp file descriptor: %m"); retries = 0; enfile2: mfp = setmntent(tmpname, "w"); if (!mfp) { if (errno == ENFILE && retries++ < NFILE_RETRIES) { sleep(1); goto enfile2; } plog(XLOG_ERROR, "setmntent(\"%s\", \"w\"): %m", tmpname); error = 1; goto out; } while (mp) { if (mp->mnt) { if (addmntent(mfp, mp->mnt)) { plog(XLOG_ERROR, "Can't write entry to %s", tmpname); error = 1; goto out; } } mp = mp->mnext; } /* * SunOS 4.1 manuals say that the return code from entmntent() * is always 1 and to treat as a void. That means we need to * call fflush() to make sure the new mtab file got written. */ if (fflush(mfp)) { plog(XLOG_ERROR, "flush new mtab file: %m"); error = 1; goto out; } (void) endmntent(mfp); /* * Rename temporary mtab to real mtab */ if (rename(tmpname, mnttabname) < 0) { plog(XLOG_ERROR, "rename %s to %s: %m", tmpname, mnttabname); error = 1; goto out; } out: if (error) (void) unlink(tmpname); } static void mtab_stripnl(char *s) { do { s = strchr(s, '\n'); if (s) *s++ = ' '; } while (s); } /* * Append a mntent structure to the * current mount table. */ void write_mntent(mntent_t *mp, const char *mnttabname) { int retries = 0; FILE *mfp; if (!mtab_is_writable()) { return; } enfile: mfp = open_locked_mtab(mnttabname, "a", mp->mnt_dir); if (mfp) { mtab_stripnl(mp->mnt_opts); if (addmntent(mfp, mp)) plog(XLOG_ERROR, "Couldn't write %s: %m", mnttabname); if (fflush(mfp)) plog(XLOG_ERROR, "Couldn't flush %s: %m", mnttabname); (void) endmntent(mfp); } else { if (errno == ENFILE && retries < NFILE_RETRIES) { sleep(1); goto enfile; } plog(XLOG_ERROR, "setmntent(\"%s\", \"a\"): %m", mnttabname); } unlock_mntlist(); } #endif /* MOUNT_TABLE_ON_FILE */ static mntent_t * mnt_dup(mntent_t *mp) { mntent_t *new_mp = ALLOC(mntent_t); new_mp->mnt_fsname = strdup(mp->mnt_fsname); new_mp->mnt_dir = strdup(mp->mnt_dir); new_mp->mnt_type = strdup(mp->mnt_type); new_mp->mnt_opts = strdup(mp->mnt_opts); new_mp->mnt_freq = mp->mnt_freq; new_mp->mnt_passno = mp->mnt_passno; #ifdef HAVE_MNTENT_T_MNT_TIME # ifdef HAVE_MNTENT_T_MNT_TIME_STRING new_mp->mnt_time = strdup(mp->mnt_time); # else /* not HAVE_MNTENT_T_MNT_TIME_STRING */ new_mp->mnt_time = mp->mnt_time; # endif /* not HAVE_MNTENT_T_MNT_TIME_STRING */ #endif /* HAVE_MNTENT_T_MNT_TIME */ #ifdef HAVE_MNTENT_T_MNT_CNODE new_mp->mnt_cnode = mp->mnt_cnode; #endif /* HAVE_MNTENT_T_MNT_CNODE */ return new_mp; } /* * Read a mount table into memory */ mntlist * read_mtab(char *fs, const char *mnttabname) { mntlist **mpp, *mhp; mntent_t *mep; FILE *mfp = open_locked_mtab(mnttabname, "r+", fs); if (!mfp) return 0; mpp = &mhp; /* * XXX - In SunOS 4 there is (yet another) memory leak * which loses 1K the first time getmntent is called. * (jsp) */ while ((mep = getmntent(mfp))) { /* * Allocate a new slot */ *mpp = ALLOC(struct mntlist); /* * Copy the data returned by getmntent */ (*mpp)->mnt = mnt_dup(mep); /* * Move to next pointer */ mpp = &(*mpp)->mnext; } *mpp = NULL; #ifdef MOUNT_TABLE_ON_FILE /* * If we are not updating the mount table then we * can free the resources held here, otherwise they * must be held until the mount table update is complete */ mnt_file = mfp; #else /* not MOUNT_TABLE_ON_FILE */ endmntent(mfp); #endif /* not MOUNT_TABLE_ON_FILE */ return mhp; } am-utils-6.2+rc20110530/conf/mtab/mtab_mach3.c000066400000000000000000000304521157065440000203500ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mtab/mtab_mach3.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #define NFILE_RETRIES 10 /* number of retries (seconds) */ static FILE *mnt_file; /* * If the system is being trashed by something, then * opening mtab may fail with ENFILE. So, go to sleep * for a second and try again. (Yes - this has happened to me.) * * Note that this *may* block the automounter, oh well. * If we get to this state then things are badly wrong anyway... * * Give the system 10 seconds to recover but then give up. * Hopefully something else will exit and free up some file * table slots in that time. */ #ifdef HAVE_FCNTL_H static int lock(int fd) { int rc; struct flock lk; lk.l_type = F_WRLCK; lk.l_whence = 0; lk.l_start = 0; lk.l_len = 0; again: rc = fcntl(fd, F_SETLKW, (caddr_t) & lk); if (rc < 0 && (errno == EACCES || errno == EAGAIN)) { # ifdef DEBUG dlog("Blocked, trying to obtain exclusive mtab lock"); # endif /* DEBUG */ sleep(1); goto again; } return rc; } #else /* not HAVE_FCNTL_H */ # define lock(fd) (flock((fd), LOCK_EX)) #endif /* not HAVE_FCNTL_H */ static FILE * open_locked_mtab(char *mnttabname, char *mode, char *fs) { FILE *mfp = NULL; /* * There is a possible race condition if two processes enter * this routine at the same time. One will be blocked by the * exclusive lock below (or by the shared lock in setmntent) * and by the time the second process has the exclusive lock * it will be on the wrong underlying object. To check for this * the mtab file is stat'ed before and after all the locking * sequence, and if it is a different file then we assume that * it may be the wrong file (only "may", since there is another * race between the initial stat and the setmntent). * * Simpler solutions to this problem are invited... */ int racing = 2; int rc; int retries = 0; struct stat st_before, st_after; if (mnt_file) { #ifdef DEBUG dlog("Forced close on %s in read_mtab", mnttabname); #endif /* DEBUG */ endmntent(mnt_file); mnt_file = NULL; } again: if (mfp) { endmntent(mfp); mfp = NULL; } if (stat(mnttabname, &st_before) < 0) { plog(XLOG_ERROR, "%s: stat: %m", mnttabname); if (errno == ESTALE) { /* happens occasionally */ sleep(1); goto again; } /* * If 'mnttabname' file does not exist give setmntent() a * chance to create it (depending on the mode). * Otherwise, bail out. */ else if (errno != ENOENT) { return 0; } } eacces: mfp = setmntent(mnttabname, mode); if (!mfp) { /* * Since setmntent locks the descriptor, it * is possible it can fail... so retry if * needed. */ if (errno == EACCES || errno == EAGAIN) { #ifdef DEBUG dlog("Blocked, trying to obtain exclusive mtab lock"); #endif /* DEBUG */ goto eacces; } else if (errno == ENFILE && retries++ < NFILE_RETRIES) { sleep(1); goto eacces; } plog(XLOG_ERROR, "setmntent(\"%s\", \"%s\"): %m", mnttabname, mode); return 0; } /* * At this point we have an exclusive lock on the mount list, * but it may be the wrong one so... */ /* * Need to get an exclusive lock on the current * mount table until we have a new copy written * out, when the lock is released in free_mntlist. * flock is good enough since the mount table is * not shared between machines. */ do rc = lock(fileno(mfp)); while (rc < 0 && errno == EINTR); if (rc < 0) { plog(XLOG_ERROR, "Couldn't lock %s: %m", mnttabname); endmntent(mfp); return 0; } /* * Now check whether the mtab file has changed under our feet */ if (stat(mnttabname, &st_after) < 0) { plog(XLOG_ERROR, "%s: stat", mnttabname); goto again; } if (st_before.st_dev != st_after.st_dev || st_before.st_ino != st_after.st_ino) { struct timeval tv; if (racing == 0) { /* Sometimes print a warning */ plog(XLOG_WARNING, "Possible mount table race - retrying %s", fs); } racing = (racing + 1) & 3; /* * Take a nap. From: Doug Kingston */ tv.tv_sec = 0; tv.tv_usec = (am_mypid & 0x07) << 17; if (tv.tv_usec) if (select(0, (voidp) 0, (voidp) 0, (voidp) 0, &tv) < 0) plog(XLOG_WARNING, "mtab nap failed: %m"); goto again; } return mfp; } /* * Unlock the mount table */ void unlock_mntlist(void) { /* * Release file lock, by closing the file */ if (mnt_file) { dlog("unlock_mntlist: releasing"); endmntent(mnt_file); mnt_file = NULL; } } /* * routine to convert notation "/@honeydew" to the notation * honeydew:/ and vice versa (honeydew:/ to /@honeydew) * This lets you put /@honeydew in /etc/fstab without changing * fstab.c and it lets you use EITHER notation on the command line! */ static char * convert(register char *s, char bad, char good) { char *index(); register char *t, *p; register int len1, len2, i; char *ptr; if ((p = index(s, bad)) == NULL) { return (s); } ptr = t = (char *) xzalloc(MAXPATHLEN * sizeof(char)); len1 = p - s; len2 = strlen(s) - len1 - 1; p++; for (i = 0; i < len2; i++) *t++ = p[i]; *t++ = good; for (i = 0; i < len1; i++) *t++ = s[i]; return (ptr); } static mntprtent3(FILE *mnttabp, register mntent_t *mnt) { char *cvtd = convert(mnt->mnt_fsname, ':', '@'); dlog("%x:%s:%s:%s:%d:%d:%s:%s:\n", mnttabp, (cvtd ? cvtd : ""), (mnt->mnt_dir ? mnt->mnt_dir : ""), (mnt->mnt_opts ? mnt->mnt_opts : ""), mnt->mnt_freq, mnt->mnt_passno, (mnt->mnt_type ? mnt->mnt_type : ""), (mnt->mnt_opts2 ? mnt->mnt_opts2 : "") ); fprintf(mnttabp, "%s:%s:%s:%d:%d:%s:%s:\n", (cvtd ? cvtd : ""), (mnt->mnt_dir ? mnt->mnt_dir : ""), (mnt->mnt_opts ? mnt->mnt_opts : ""), mnt->mnt_freq, mnt->mnt_passno, (mnt->mnt_type ? mnt->mnt_type : ""), (mnt->mnt_opts2 ? mnt->mnt_opts2 : "") ); XFREE(cvtd); cvtd = NULL; return (0); } addmntent3(FILE *mnttabp, register mntent_t *mnt) { if (fseek(mnttabp, 0, 2) < 0) { return (1); } mntprtent3(mnttabp, mnt); return (0); } /* * Write out a mount list */ void rewrite_mtab(mntlist *mp, const char *mnttabname) { FILE *mfp; int error = 0; /* * Concoct a temporary name in the same directory as the target mount * table so that rename() will work. */ char tmpname[64]; int retries; int tmpfd; char *cp; char *mcp = mnttabname; cp = strrchr(mcp, '/'); if (cp) { memmove(tmpname, mcp, cp - mcp); tmpname[cp - mcp] = '\0'; } else { plog(XLOG_WARNING, "No '/' in mtab (%s), using \".\" as tmp directory", mnttabname); tmpname[0] = '.'; tmpname[1] = '\0'; } xstrlcat(tmpname, "/mtabXXXXXX", sizeof(tmpname)); retries = 0; enfile1: #ifdef HAVE_MKSTEMP tmpfd = mkstemp(tmpname); fchmod(tmpfd, 0644); #else /* not HAVE_MKSTEMP */ mktemp(tmpname); tmpfd = open(tmpname, O_RDWR | O_CREAT | O_TRUNC, 0644); #endif /* not HAVE_MKSTEMP */ if (tmpfd < 0) { if (errno == ENFILE && retries++ < NFILE_RETRIES) { sleep(1); goto enfile1; } plog(XLOG_ERROR, "%s: open: %m", tmpname); return; } if (close(tmpfd) < 0) plog(XLOG_ERROR, "Couldn't close tmp file descriptor: %m"); retries = 0; enfile2: mfp = setmntent(tmpname, "w"); if (!mfp) { if (errno == ENFILE && retries++ < NFILE_RETRIES) { sleep(1); goto enfile2; } plog(XLOG_ERROR, "setmntent(\"%s\", \"w\"): %m", tmpname); error = 1; goto out; } while (mp) { if (mp->mnt) { if (addmntent3(mfp, mp->mnt)) { plog(XLOG_ERROR, "Can't write entry to %s", tmpname); error = 1; goto out; } } mp = mp->mnext; } /* * SunOS 4.1 manuals say that the return code from endmntent() * is always 1 and to treat as a void. That means we need to * call fflush() to make sure the new mtab file got written. */ if (fflush(mfp)) { plog(XLOG_ERROR, "flush new mtab file: %m"); error = 1; goto out; } (void) endmntent(mfp); /* * Rename temporary mtab to real mtab */ if (rename(tmpname, mnttabname) < 0) { plog(XLOG_ERROR, "rename %s to %s: %m", tmpname, mnttabname); error = 1; goto out; } out: if (error) (void) unlink(tmpname); } static void mtab_stripnl(char *s) { do { s = strchr(s, '\n'); if (s) *s++ = ' '; } while (s); } /* * Append a mntent structure to the * current mount table. */ void write_mntent(mntent_t *mp, const char *mnttabname) { int retries = 0; FILE *mfp; enfile: mfp = open_locked_mtab(mnttabname, "a", mp->mnt_dir); if (mfp) { mtab_stripnl(mp->mnt_opts); if (addmntent3(mfp, mp)) plog(XLOG_ERROR, "Couldn't write %s: %m", mnttabname); if (fflush(mfp)) plog(XLOG_ERROR, "Couldn't flush %s: %m", mnttabname); (void) endmntent(mfp); } else { if (errno == ENFILE && retries < NFILE_RETRIES) { sleep(1); goto enfile; } plog(XLOG_ERROR, "setmntent(\"%s\", \"a\"): %m", mnttabname); } } static mntent_t * mnt_dup(mntent_t *mp) { mntent_t *new_mp = ALLOC(mntent_t); new_mp->mnt_fsname = convert(mp->mnt_fsname, '@', ':'); new_mp->mnt_dir = strdup(mp->mnt_dir); new_mp->mnt_type = strdup(mp->mnt_type); new_mp->mnt_opts = strdup(mp->mnt_opts); new_mp->mnt_freq = mp->mnt_freq; new_mp->mnt_passno = mp->mnt_passno; return new_mp; } /* * Read a mount table into memory */ mntlist * read_mtab(char *fs, const char *mnttabname) { mntlist **mpp, *mhp; mntent_t *mep; FILE *mfp = open_locked_mtab(mnttabname, "r+", fs); if (!mfp) return 0; mpp = &mhp; /* * XXX - In SunOS 4 there is (yet another) memory leak * which loses 1K the first time getmntent is called. * (jsp) */ while (mep = getmntent(mfp)) { /* * Allocate a new slot */ *mpp = ALLOC(struct mntlist); /* * Copy the data returned by getmntent */ (*mpp)->mnt = mnt_dup(mep); /* * Move to next pointer */ mpp = &(*mpp)->mnext; } *mpp = NULL; /* * If we are not updating the mount table then we * can free the resources held here, otherwise they * must be held until the mount table update is complete */ mnt_file = mfp; return mhp; } am-utils-6.2+rc20110530/conf/mtab/mtab_osf.c000066400000000000000000000103471157065440000201450ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mtab/mtab_osf.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include static mntent_t * mnt_dup(struct statfs *mp) { mntent_t *new_mp = ALLOC(mntent_t); char *ty; char *at; char mntfrombuf[MNAMELEN]; char *mntfromptr; /* * Under DEC OSF/1 T1.2-2 the f_mntfromname fields of * the statfs structure can be in the format @ * instead of :. Here we check for this and * reformat it if necessary. */ mntfromptr = mp->f_mntfromname; switch (mp->f_type) { case MOUNT_TYPE_NFS: #ifdef HAVE_FS_NFS3 case MOUNT_TYPE_NFS3: #endif /* HAVE_FS_NFS3 */ at = strchr(mp->f_mntfromname, '@'); if (at != '\0') { xstrlcpy(mntfrombuf, (at + 1), sizeof(mntfrombuf)); xstrlcat(mntfrombuf, ":", sizeof(mntfrombuf)); strncat(mntfrombuf, mp->f_mntfromname, (at - mp->f_mntfromname)); mntfromptr = mntfrombuf; } } new_mp->mnt_fsname = strdup(mntfromptr); new_mp->mnt_dir = strdup(mp->f_mntonname); switch (mp->f_type) { case MOUNT_TYPE_UFS: ty = MNTTAB_TYPE_UFS; break; #ifdef HAVE_FS_NFS3 case MOUNT_TYPE_NFS3: ty = MNTTAB_TYPE_NFS3; break; #endif /* HAVE_FS_NFS3 */ case MOUNT_TYPE_NFS: ty = MNTTAB_TYPE_NFS; break; case MOUNT_TYPE_MFS: ty = MNTTAB_TYPE_MFS; break; default: ty = "unknown"; break; } new_mp->mnt_type = strdup(ty); new_mp->mnt_opts = strdup("unset"); new_mp->mnt_freq = 0; new_mp->mnt_passno = 0; return new_mp; } /* * Read a mount table into memory */ mntlist * read_mtab(char *fs, const char *mnttabname) { mntlist **mpp, *mhp; struct statfs *mntbufp, *mntp; int nloc = getmntinfo(&mntbufp, MNT_NOWAIT); if (nloc == 0) { plog(XLOG_ERROR, "Can't read mount table"); return 0; } mpp = &mhp; for (mntp = mntbufp; mntp < mntbufp + nloc; mntp++) { /* * Allocate a new slot */ *mpp = ALLOC(struct mntlist); /* * Copy the data returned by getmntent */ (*mpp)->mnt = mnt_dup(mntp); /* * Move to next pointer */ mpp = &(*mpp)->mnext; } /* terminate the linked list */ *mpp = NULL; return mhp; } am-utils-6.2+rc20110530/conf/mtab/mtab_svr4.c000066400000000000000000000171061157065440000202540ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mtab/mtab_svr4.c * * How to manage the mount table file. Based on other SVR3 ports. * -Erez Zadok */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * file descriptor for lock file * values: -1 no file-descriptor was set yet (or mnttab unlocked, or error * in locking). * >=0 legal file-descriptor value (file lock succeeded) */ static int mntent_lock_fd = -1; #ifdef MOUNT_TABLE_ON_FILE static char mtlckname[] = "/etc/.mnttab.lock"; #endif /* MOUNT_TABLE_ON_FILE */ /****************************************************************************/ /*** Private functions */ /****************************************************************************/ static void unlockmnttab(void) { #ifdef MOUNT_TABLE_ON_FILE if (mntent_lock_fd >= 0) { close(mntent_lock_fd); mntent_lock_fd = -1; } #endif /* MOUNT_TABLE_ON_FILE */ } #ifdef MOUNT_TABLE_ON_FILE static int lockfile(int fd, int type) { struct flock lk; int ret; lk.l_type = type; lk.l_whence = 0; lk.l_start = 0; lk.l_len = 0; /* * F_SETLKW means to block until the read or write block is free to be * locked. */ ret = fcntl(fd, F_SETLKW, &lk); return ret; } #endif /* MOUNT_TABLE_ON_FILE */ /* return 0 if locking succeeded, -1 if failed */ static int lockmnttab(void) { #ifdef MOUNT_TABLE_ON_FILE /* if mnttab file is locked, all is well */ if (mntent_lock_fd >= 0) return 0; /* need to lock mnttab file. first, open the file */ mntent_lock_fd = open(mtlckname, O_RDWR | O_CREAT, 0600); if (mntent_lock_fd < 0) { plog(XLOG_ERROR, "Unable to open/creat %s: %m", mtlckname); return -1; } /* if succeeded in opening the file, try to lock it */ if (lockfile(mntent_lock_fd, F_WRLCK) < 0) { close(mntent_lock_fd); mntent_lock_fd = -1; #ifdef DEBUG dlog("lock %s failed: %m", mtlckname); #endif /* DEBUG */ return -1; } #else /* not MOUNT_TABLE_ON_FILE */ /* fake lock for in-kernel mount table */ #endif /* not MOUNT_TABLE_ON_FILE */ /* finally, succeeded in also locking the file */ return 0; } /* * Convert from solaris mnttab to Amd mntent. Since am-utils uses * native "struct mnttab" if available, this really copies fields of * the same structure. */ static mntent_t * mnt_dup(const mntent_t *mtp) { mntent_t *mep = ALLOC(mntent_t); mep->mnt_fsname = strdup(mtp->mnt_fsname); mep->mnt_dir = strdup(mtp->mnt_dir); mep->mnt_type = strdup(mtp->mnt_type); mep->mnt_opts = strdup(mtp->mnt_opts); mep->mnt_time = strdup(mtp->mnt_time); return mep; } /* * Adjust arguments in mntent_t. */ #ifdef MOUNT_TABLE_ON_FILE static mntent_t * update_mnttab_fields(const mntent_t *mnt) { static mntent_t mt; static char timestr[16]; struct timeval tv; /* most fields don't change, only update mnt_time below */ mt.mnt_fsname = mnt->mnt_fsname; mt.mnt_dir = mnt->mnt_dir; mt.mnt_type = mnt->mnt_type; mt.mnt_opts = mnt->mnt_opts; /* * Solaris 2.5 and newer take a second argument to gettimeofday(). If you * find a useful svr4-like OS that uses the old style, and this code here * fails, then create a new autoconf test that will determine the number * of arguments gettimeofday() takes. -Erez. */ if (gettimeofday(&tv, NULL) < 0) timestr[0] = '\0'; else xsnprintf(timestr, sizeof(timestr), "%ld", tv.tv_sec); mt.mnt_time = timestr; return &mt; } #endif /* MOUNT_TABLE_ON_FILE */ static void write_mntent_to_mtab(FILE *fp, const mntent_t *mnt) { #ifdef MOUNT_TABLE_ON_FILE putmntent(fp, update_mnttab_fields(mnt)); #endif /* MOUNT_TABLE_ON_FILE */ } /****************************************************************************/ /*** Public functions */ /****************************************************************************/ void unlock_mntlist(void) { unlockmnttab(); } /* * Read a mount table into memory */ mntlist * read_mtab(char *fs, const char *mnttabname) { mntlist **mpp, *mhp; FILE *fp; mntent_t mountbuf; int ret; if (lockmnttab() < 0) /* failed locking */ return NULL; fp = fopen(mnttabname, "r"); if (fp == NULL) { plog(XLOG_ERROR, "Can't open %s: %m", mnttabname); return NULL; } mpp = &mhp; while ((ret = getmntent(fp, &mountbuf)) == 0) { /* * Allocate a new slot */ *mpp = ALLOC(struct mntlist); /* * Copy the data returned by getmntent */ (*mpp)->mnt = mnt_dup(&mountbuf); /* * Move to next pointer */ mpp = &(*mpp)->mnext; } if (ret > 0) { plog(XLOG_ERROR, "read error on %s: %m", mnttabname); unlockmnttab(); mhp = NULL; } *mpp = NULL; fclose(fp); return mhp; } void rewrite_mtab(mntlist *mp, const char *mnttabname) { FILE *fp; assert(mntent_lock_fd >= 0); /* ensure lock fd is valid */ fp = fopen(mnttabname, "r+"); if (fp == NULL) { plog(XLOG_ERROR, "Can't open %s: %m", mnttabname); unlockmnttab(); return; } while (mp) { if (mp->mnt) write_mntent_to_mtab(fp, mp->mnt); mp = mp->mnext; } ftruncate(fileno(fp), ftell(fp)); fclose(fp); unlockmnttab(); } void write_mntent(mntent_t *mtp, const char *mnttabname) { FILE *fp; if (lockmnttab() < 0) return; fp = fopen(mnttabname, "a"); if (fp == NULL) { plog(XLOG_ERROR, "Unable to append %s: %m", mnttabname); return; } write_mntent_to_mtab(fp, mtp); fclose(fp); unlockmnttab(); } am-utils-6.2+rc20110530/conf/mtab/mtab_ultrix.c000066400000000000000000000075111157065440000207040ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/mtab/mtab_ultrix.c * */ /* * Include before config.h to force single definition of gt_names[] here. * This can be done unconditionally since this file is Ultrix specific * anyway and is properly protected from multiple inclusion. * - Rainer Orth * Hack hack hack. Sigh. -Erez. */ #include #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #ifndef NMOUNT # define NMOUNT 20 #endif /* NMOUNT */ static mntent_t * mnt_dup(struct fs_data *mp) { mntent_t *new_mp = ALLOC(mntent_t); new_mp->mnt_fsname = strdup(mp->fd_devname); new_mp->mnt_dir = strdup(mp->fd_path); if (mp->fd_fstype >= GT_NUMTYPES) mp->fd_fstype = GT_UNKWN; else if (gt_names[mp->fd_fstype] == 0) mp->fd_fstype = GT_UNKWN; new_mp->mnt_type = strdup(gt_names[mp->fd_fstype]); new_mp->mnt_opts = strdup("unset"); new_mp->mnt_freq = 0; new_mp->mnt_passno = mp->fd_dev; return new_mp; } /* * Read a mount table into memory */ mntlist * read_mtab(char *fs, const char *mnttabname) { mntlist **mpp, *mhp; /* From: Piete Brooks */ int loc = 0; struct fs_data mountbuffer[NMOUNT], *fs_data; int ret; mpp = &mhp; while ((ret = getmountent(&loc, mountbuffer, NMOUNT)) > 0) { for (fs_data = mountbuffer; fs_data < &mountbuffer[ret]; fs_data++) { /* * Allocate a new slot */ *mpp = ALLOC(struct mntlist); /* * Copy the data returned by getmntent */ (*mpp)->mnt = mnt_dup(fs_data); /* * Move to next pointer */ mpp = &(*mpp)->mnext; } } if (ret < 0) { plog(XLOG_ERROR, "getmountent: %m"); return 0; } *mpp = NULL; return mhp; } am-utils-6.2+rc20110530/conf/nfs_prot/000077500000000000000000000000001157065440000171115ustar00rootroot00000000000000am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_aix3.h000066400000000000000000000141211157065440000220370ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_aix3.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ /* don't include this one */ #ifdef HAVE_RPCSVC_MOUNT_H_not # include #endif /* HAVE_RPCSVC_MOUNT_H */ /* * MACROS */ #ifndef MNTPATHLEN # define MNTPATHLEN 1024 #endif /* not MNTPATHLEN */ #ifndef MNTNAMLEN # define MNTNAMLEN 255 #endif /* not MNTNAMLEN */ /* map field names */ #define ex_dir ex_name #define gr_name g_name #define gr_next g_next #define ml_directory ml_path #define ml_hostname ml_name #define ml_next ml_nxt #define dr_drok_u diropres #define ca_attributes attributes #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_blocks blocks #define na_blocksize blocksize #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_gid gid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_rdev rdev #define na_size size #define na_type type #define na_uid uid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define ra_count count #define ra_fhandle file #define ra_offset offset #define ra_totalcount totalcount #define raok_attributes attributes #define raok_len_u data_len #define raok_u data #define raok_val_u data_val #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_reply_u reply #define rr_status status #define rr_u readres_u #define sa_atime atime #define sa_gid gid #define sa_mode mode #define sa_mtime mtime #define sa_size size #define sa_uid uid #define sag_attributes attributes #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_attributes attributes #define sla_from from #define sla_to to #define wra_beginoffset beginoffset #define wra_fhandle file #define wra_len_u data_len #define wra_offset offset #define wra_totalcount totalcount #define wra_u data #define wra_val_u data_val /* * TYPEDEFS: */ typedef char *dirpath; typedef char *name; typedef struct exports *exports; typedef struct exports exportnode; typedef struct groups *groups; typedef struct groups groupnode; typedef struct mountlist *mountlist; typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropokres nfsdiropokres; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readokres nfsreadokres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattr nfssattr; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* * EXTERNALS: */ extern bool_t xdr_groups(XDR *xdrs, groups *objp); /* * STRUCTURES: */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_aix4.h000066400000000000000000000140571157065440000220500ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_aix4.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ /* * MACROS */ #ifndef MNTPATHLEN # define MNTPATHLEN 1024 #endif /* not MNTPATHLEN */ #ifndef MNTNAMLEN # define MNTNAMLEN 255 #endif /* not MNTNAMLEN */ /* map field names */ #define ex_dir ex_name #define gr_name g_name #define gr_next g_next #define ml_directory ml_path #define ml_hostname ml_name #define ml_next ml_nxt #define dr_drok_u diropres #define ca_attributes attributes #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_blocks blocks #define na_blocksize blocksize #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_gid gid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_rdev rdev #define na_size size #define na_type type #define na_uid uid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define ra_count count #define ra_fhandle file #define ra_offset offset #define ra_totalcount totalcount #define raok_attributes attributes #define raok_len_u data_len #define raok_u data #define raok_val_u data_val #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_reply_u reply #define rr_status status #define rr_u readres_u #define sa_atime atime #define sa_gid gid #define sa_mode mode #define sa_mtime mtime #define sa_size size #define sa_uid uid #define sag_attributes attributes #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_attributes attributes #define sla_from from #define sla_to to #define wra_beginoffset beginoffset #define wra_fhandle file #define wra_len_u data_len #define wra_offset offset #define wra_totalcount totalcount #define wra_u data #define wra_val_u data_val /* * TYPEDEFS: */ typedef char *dirpath; typedef char *name; typedef struct exports *exports; typedef struct exports exportnode; typedef struct groups *groups; typedef struct groups groupnode; typedef struct mountlist *mountlist; typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropokres nfsdiropokres; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readokres nfsreadokres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattr nfssattr; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* * EXTERNALS: */ extern bool_t xdr_groups(XDR *xdrs, groups *objp); /* * STRUCTURES: */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_aix4_2.h000066400000000000000000000160431157065440000222660ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_aix4_2.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H /* * AIX 4.2 and newer support NFS V.3, hence the separate header. */ #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ /* * MACROS */ #ifndef MNTPATHLEN # define MNTPATHLEN 1024 #endif /* not MNTPATHLEN */ #ifndef MNTNAMLEN # define MNTNAMLEN 255 #endif /* not MNTNAMLEN */ /* map field names */ #define ex_dir ex_name #define gr_name g_name #define gr_next g_next #define ml_directory ml_path #define ml_hostname ml_name #define ml_next ml_nxt #define dr_drok_u diropres #define ca_attributes attributes #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_blocks blocks #define na_blocksize blocksize #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_gid gid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_rdev rdev #define na_size size #define na_type type #define na_uid uid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define ra_count count #define ra_fhandle file #define ra_offset offset #define ra_totalcount totalcount #define raok_attributes attributes #define raok_len_u data_len #define raok_u data #define raok_val_u data_val #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_reply_u reply #define rr_status status #define rr_u readres_u #define sa_atime atime #define sa_gid gid #define sa_mode mode #define sa_mtime mtime #define sa_size size #define sa_uid uid #define sag_attributes attributes #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_attributes attributes #define sla_from from #define sla_to to #define wra_beginoffset beginoffset #define wra_fhandle file #define wra_len_u data_len #define wra_offset offset #define wra_totalcount totalcount #define wra_u data #define wra_val_u data_val /* * TYPEDEFS: */ typedef char *dirpath; typedef char *name; typedef struct exports *exports; typedef struct exports exportnode; typedef struct groups *groups; typedef struct groups groupnode; typedef struct mountlist *mountlist; typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropokres nfsdiropokres; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readokres nfsreadokres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattr nfssattr; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* * EXTERNALS: */ /* * STRUCTURES: */ /* * AIX 4.2 has NFS V3, but it is undefined in the header files. * so I define everything that's needed for NFS V3 here. */ #ifdef MNT_NFS3 struct aix4_nfs_args { struct sockaddr_in addr; /* server address and port */ caddr_t u0; /* ??? UNKNOWN ??? */ unsigned long proto; /* IPPROTO_TCP/IPPROTO_UDP */ char *hostname; /* pointer to hostname? */ char *netname; /* pointer to netname? */ caddr_t fh; /* pointer to NFS v3 fh? */ unsigned long flags; /* flags */ unsigned long wsize; /* wsize */ unsigned long rsize; /* rsize */ unsigned long timeo; /* timeo */ unsigned long retrans; /* retrans */ unsigned long acregmin; /* acregmin */ unsigned long acregmax; /* acregmax */ unsigned long acdirmin; /* acdirmin */ unsigned long acdirmax; /* acdirmax */ unsigned long u14; /* ??? UNKNOWN ??? */ struct pathcnf *pathconf; /* pathconf */ }; #endif /* MNT_NFS3 */ /* * EXTERNALS: */ extern bool_t xdr_groups(XDR *xdrs, groups *objp); #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_aix4_3.h000066400000000000000000000227331157065440000222720ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_aix4_3.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H /* * AIX 4.3 and newer support NFS V.3, hence the separate header. */ #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ /* * MACROS */ #ifndef MNTPATHLEN # define MNTPATHLEN 1024 #endif /* not MNTPATHLEN */ #ifndef MNTNAMLEN # define MNTNAMLEN 255 #endif /* not MNTNAMLEN */ /* map field names */ #define ex_dir ex_name #define gr_name g_name #define gr_next g_next #define ml_directory ml_path #define ml_hostname ml_name #define ml_next ml_nxt #define dr_drok_u diropres #define ca_attributes attributes #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_blocks blocks #define na_blocksize blocksize #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_gid gid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_rdev rdev #define na_size size #define na_type type #define na_uid uid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define ra_count count #define ra_fhandle file #define ra_offset offset #define ra_totalcount totalcount #define raok_attributes attributes #define raok_len_u data_len #define raok_u data #define raok_val_u data_val #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_reply_u reply #define rr_status status #define rr_u readres_u #define sa_atime atime #define sa_gid gid #define sa_mode mode #define sa_mtime mtime #define sa_size size #define sa_uid uid #define sag_attributes attributes #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_attributes attributes #define sla_from from #define sla_to to #define wra_beginoffset beginoffset #define wra_fhandle file #define wra_len_u data_len #define wra_offset offset #define wra_totalcount totalcount #define wra_u data #define wra_val_u data_val /* * TYPEDEFS: */ typedef char *dirpath; typedef char *name; typedef struct exports *exports; typedef struct exports exportnode; typedef struct groups *groups; typedef struct groups groupnode; typedef struct mountlist *mountlist; typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropokres nfsdiropokres; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readokres nfsreadokres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattr nfssattr; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* * EXTERNALS: */ /* * STRUCTURES: */ /* * AIX 4.3 has NFS V3, but it is undefined in the header files. * so I define everything that's needed for NFS V3 here. */ #ifdef MNT_NFS3 struct aix4_nfs_args { struct sockaddr_in addr; /* file server address */ struct sockaddr_in *syncaddr; /* secure NFS time sync addr */ int proto; /* IPPROTO_TCP/IPPROTO_UDP ??? */ char *hostname; /* server's hostname */ char *netname; /* server's netname */ caddr_t fh; /* File handle to be mounted */ int flags; /* flags */ int wsize; /* write size in bytes */ int rsize; /* read size in bytes */ int timeo; /* initial timeout in .1 secs */ int retrans; /* times to retry send */ int acregmin; /* attr cache file min secs */ int acregmax; /* attr cache file max secs */ int acdirmin; /* attr cache dir min secs */ int acdirmax; /* attr cache dir max secs */ struct ppathcnf *pathconf; /* static pathconf kludge */ int biods; /* biods per mount */ int numclust; /* numclust per mount */ }; #if 0 /* old structure we hand crafted. no longer needed */ struct aix4_nfs_args { struct sockaddr_in addr; /* server address and port */ caddr_t u0; /* ??? UNKNOWN ??? */ unsigned long proto; /* IPPROTO_TCP/IPPROTO_UDP */ char *hostname; /* pointer to hostname? */ char *netname; /* pointer to netname? */ caddr_t fh; /* pointer to NFS v3 fh? */ unsigned long flags; /* flags */ unsigned long wsize; /* wsize */ unsigned long rsize; /* rsize */ unsigned long timeo; /* timeo */ unsigned long retrans; /* retrans */ unsigned long acregmin; /* acregmin */ unsigned long acregmax; /* acregmax */ unsigned long acdirmin; /* acdirmin */ unsigned long acdirmax; /* acdirmax */ unsigned long u14; /* ??? UNKNOWN ??? */ struct pathcnf *pathconf; /* pathconf */ }; #endif /* 0 */ /* * IBM is in dire need of taking a soft-eng class. * They changed the API/ABI (namely the nfs3_args structure) * in a service pack... * * All the following *_bis junk is here to try and deal with this idiocy. */ #define MOUNT_TYPE_NFS3_BIS 0x12344321 struct aix4_nfs_args_bis { struct sockaddr_in addr; /* server address and port */ struct sockaddr_in *syncaddr; /* secure NFS time sync addr */ int proto; /* IPPROTO_TCP/IPPROTO_UDP ??? */ char *hostname; /* pointer to hostname? */ char *netname; /* pointer to netname? */ caddr_t fh; /* pointer to NFS v3 fh? */ unsigned long flags; /* flags */ unsigned long wsize; /* wsize */ unsigned long rsize; /* rsize */ unsigned long timeo; /* timeo */ unsigned long retrans; /* retrans */ unsigned long acregmin; /* acregmin */ unsigned long acregmax; /* acregmax */ unsigned long acdirmin; /* acdirmin */ unsigned long acdirmax; /* acdirmax */ unsigned long u14; /* ??? UNKNOWN ??? */ struct ppathcnf *pathconf; /* static pathconf kludge */ int biods; /* biods per mount */ int numclust; /* numclust per mount */ }; #endif /* MNT_NFS3 */ /* ************************************************************************** * AIX 4.3's autofs is not ported or tested yet... * For now, undefine it or define dummy entries. ************************************************************************** */ #ifdef MNT_AUTOFS # undef MNT_AUTOFS #endif /* MNT_AUTOFS */ #ifdef HAVE_FS_AUTOFS # undef HAVE_FS_AUTOFS #endif /* HAVE_FS_AUTOFS */ /* * EXTERNALS: */ extern bool_t xdr_groups(XDR *xdrs, groups *objp); extern char *yperr_string (int incode); #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_aix5_1.h000066400000000000000000000201471157065440000222660ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_aix5_1.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H /* * AIX 5.1 has a different aix5_nfs_args structure, hence the separate header. */ #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ /* * MACROS */ #ifndef MNTPATHLEN # define MNTPATHLEN 1024 #endif /* not MNTPATHLEN */ #ifndef MNTNAMLEN # define MNTNAMLEN 255 #endif /* not MNTNAMLEN */ /* map field names */ #define ex_dir ex_name #define gr_name g_name #define gr_next g_next #define ml_directory ml_path #define ml_hostname ml_name #define ml_next ml_nxt #define dr_drok_u diropres #define ca_attributes attributes #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_blocks blocks #define na_blocksize blocksize #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_gid gid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_rdev rdev #define na_size size #define na_type type #define na_uid uid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define ra_count count #define ra_fhandle file #define ra_offset offset #define ra_totalcount totalcount #define raok_attributes attributes #define raok_len_u data_len #define raok_u data #define raok_val_u data_val #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_reply_u reply #define rr_status status #define rr_u readres_u #define sa_atime atime #define sa_gid gid #define sa_mode mode #define sa_mtime mtime #define sa_size size #define sa_uid uid #define sag_attributes attributes #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_attributes attributes #define sla_from from #define sla_to to #define wra_beginoffset beginoffset #define wra_fhandle file #define wra_len_u data_len #define wra_offset offset #define wra_totalcount totalcount #define wra_u data #define wra_val_u data_val /* * TYPEDEFS: */ typedef char *dirpath; typedef char *name; typedef struct exports *exports; typedef struct exports exportnode; typedef struct groups *groups; typedef struct groups groupnode; typedef struct mountlist *mountlist; typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropokres nfsdiropokres; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readokres nfsreadokres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattr nfssattr; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* * EXTERNALS: */ /* * STRUCTURES: */ /* * AIX 5.1 has NFS V3, but it is undefined in the header files. * so I define everything that's needed for NFS V3 here. */ #ifdef MNT_NFS3 struct aix5_nfs_args { struct sockaddr_in addr; /* server address and port */ caddr_t u0; /* ??? UNKNOWN ??? */ unsigned long proto; /* IPPROTO_TCP/IPPROTO_UDP */ char *hostname; /* pointer to hostname? */ char *netname; /* pointer to netname? */ caddr_t fh; /* pointer to NFS v3 fh? */ unsigned long u5; /* IBM sux, IBM sux, IBM sux... */ unsigned long flags; /* flags */ unsigned long wsize; /* wsize */ unsigned long rsize; /* rsize */ unsigned long timeo; /* timeo */ unsigned long retrans; /* retrans */ unsigned long acregmin; /* acregmin */ unsigned long acregmax; /* acregmax */ unsigned long acdirmin; /* acdirmin */ unsigned long acdirmax; /* acdirmax */ unsigned long u15; /* ??? UNKNOWN ??? */ struct pathcnf *pathconf; /* pathconf */ }; #endif /* MNT_NFS3 */ #ifdef MNT_AUTOFS #define A_MAXNAME 255 #define A_MAXOPTS 255 #define A_MAXPATH 1024 struct mntrequest { char *name; char *map; char *opts; char *path; }; typedef struct mntrequest mntrequest; struct mntres { int status; }; typedef struct mntres mntres; struct umntrequest { int isdirect; u_int devid; u_long rdevid; struct umntrequest *next; }; typedef struct umntrequest umntrequest; struct umntres { int status; }; typedef struct umntres umntres; #define AUTOFS_PROG ((unsigned long)(100099)) #define AUTOFS_VERS ((unsigned long)(1)) #endif /* MNT_AUTOFS */ /* ************************************************************************** * AIX 5.1's autofs is not ported or tested yet... * For now, undefine it or define dummy entries. ************************************************************************** */ #ifdef MNT_AUTOFS # undef MNT_AUTOFS #endif /* MNT_AUTOFS */ #ifdef HAVE_FS_AUTOFS # undef HAVE_FS_AUTOFS #endif /* HAVE_FS_AUTOFS */ /* * EXTERNALS: */ extern bool_t xdr_groups(XDR *xdrs, groups *objp); extern char *yperr_string (int incode); #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_aix5_2.h000066400000000000000000000323231157065440000222660ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_aix5_2.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H /* * AIX 5.2 has a different aix5_nfs_args structure, hence the separate header. */ #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H /* * AIX 5.2 wants 'struct pathcnf', but I couldn't find its definition * anywhere. Luckily, amd doesn't need the size of this structure in * any other structure that it uses. So we sidestep it for now. */ struct pathcnf; # include #endif /* HAVE_RPCSVC_MOUNT_H */ #ifdef HAVE_SYS_VFS_H /* AIX 5.3 (ppc) wants definition of kernel-specific structure */ struct thread_credentials; #endif /* HAVE_SYS_VFS_H */ /* * MACROS */ #ifndef MNTPATHLEN # define MNTPATHLEN 1024 #endif /* not MNTPATHLEN */ #ifndef MNTNAMLEN # define MNTNAMLEN 255 #endif /* not MNTNAMLEN */ /* compatible macro name with other OSs */ #ifdef UVMNT_FORCE # define MS_FORCE UVMNT_FORCE #endif /* UVMNT_FORCE */ /********************************************************************************/ /* * NFS mount option flags (out of mount.h) * Maybe one day IBM will include them in system headers. */ #ifndef MNTOPT_ACDIRMAX # define MNTOPT_ACDIRMAX "acdirmax" /* max ac timeout for dirs (sec) */ # define MNTOPT_ACDIRMIN "acdirmin" /* min ac timeout for dirs (sec) */ # define MNTOPT_ACREGMAX "acregmax" /* max ac timeout for reg files (sec) */ # define MNTOPT_ACREGMIN "acregmin" /* min ac timeout for reg files (sec) */ # define MNTOPT_ACTIMEO "actimeo" /* attr cache timeout (sec) */ # define MNTOPT_BG "bg" /* mount op in background if 1st attempt fails */ # define MNTOPT_FASTATTR "fastattr" /* no sync_vp in nfs3_getattr */ # define MNTOPT_FG "fg" /* mount op in fg if 1st attempt fails, default */ # define MNTOPT_GRPID "grpid" /* SysV-compatible group-id on create */ # define MNTOPT_HARD "hard" /* hard mount (default) */ # define MNTOPT_INTR "intr" /* allow interrupts on hard mount */ # define MNTOPT_NOAC "noac" /* don't cache file attributes */ # define MNTOPT_NOACL "noacl" /* don't read acl's from server - default */ # define MNTOPT_ACL "acl" /* read acl's from server means we load ksec */ # define MNTOPT_NOAUTO "noauto"/* hide entry from mount -a */ # define MNTOPT_NOCTO "nocto" /* no "close to open" attr consistency */ # define MNTOPT_NODEV "nodev" /*don't allow opening of devices accross mount*/ # define MNTOPT_NOINTR "nointr" /* don't allow interrupts on hard mounts */ # define MNTOPT_NOQUOTA "noquota" /* don't check quotas */ # define MNTOPT_NOSUID "nosuid" /* no set uid allowed */ # define MNTOPT_BSY "bsy" # define MNTOPT_PORT "port" /* server IP port number */ # define MNTOPT_POSIX "posix" /* ask for static pathconf values from mountd */ # define MNTOPT_QUOTA "quota" /* quotas */ # define MNTOPT_RETRANS "retrans" /* set number of request retries */ # define MNTOPT_RETRYS "retry" /* # of times mount is attempted, def=10000*/ # define MNTOPT_RMNT "remount" /* remount to rw if mode ro */ # define MNTOPT_RO "ro" /* read only */ # define MNTOPT_RSIZE "rsize" /* set read size (bytes) */ # define MNTOPT_RW "rw" /* read/write */ # define MNTOPT_SECURE "secure"/* use secure RPC for NFS */ # define MNTOPT_SHORTDEV "shortdev" /* server dev */ # define MNTOPT_SOFT "soft" /* soft mount */ # define MNTOPT_TIMEO "timeo" /* set initial timeout (1/10 sec) */ # define MNTOPT_WSIZE "wsize" /* set write size (bytes) */ # define MNTOPT_VERS "vers" /* protocol version number indicator */ # define MNTOPT_PROTO "proto" /* protocol network_id indicator */ # define MNTOPT_LLOCK "llock" /* Local locking (no lock manager) */ # define MNTOPT_BIODS "biods" /* max biods per mount */ # define MNTOPT_EXTATTR "extraattr" /* extended attribute usage */ # define MNTOPT_COMBEHND "combehind" /* extended attribute usage */ # define MNTOPT_NUMCLUST "numclust" /* max numclust per mount */ # define MNTOPT_NODIRCACHE "nodircache" /* No readdir cache */ # define NFSMNT_NOACL 0x0 /* turn off acl support (not supported) */ # define NFSMNT_SHORTDEV 0x0 /* server does not support 32-bit device no. (not supported) */ # define NFSMNT_SOFT 0x001 /* soft mount (hard is default) */ # define NFSMNT_WSIZE 0x002 /* set write size */ # define NFSMNT_RSIZE 0x004 /* set read size */ # define NFSMNT_TIMEO 0x008 /* set initial timeout */ # define NFSMNT_RETRANS 0x010 /* set number of request retrys */ # define NFSMNT_HOSTNAME 0x020 /* set hostname for error printf */ # define NFSMNT_INT 0x040 /* allow interrupts on hard mount */ # define NFSMNT_NOAC 0x080 /* don't cache attributes */ # define NFSMNT_ACREGMIN 0x0100 /* set min secs for file attr cache */ # define NFSMNT_ACREGMAX 0x0200 /* set max secs for file attr cache */ # define NFSMNT_ACDIRMIN 0x0400 /* set min secs for dir attr cache */ # define NFSMNT_ACDIRMAX 0x0800 /* set max secs for dir attr cache */ # define NFSMNT_SECURE 0x1000 /* secure mount */ # define NFSMNT_NOCTO 0x2000 /* no close-to-open consistency */ # define NFSMNT_KNCONF 0x4000 /* transport's knetconfig structure */ # define NFSMNT_GRPID 0x8000 /* System V-style gid inheritance */ # define NFSMNT_RPCTIMESYNC 0x10000 /* use RPC to do secure NFS time sync */ # define NFSMNT_KERBEROS 0x20000 /* use kerberos credentials */ # define NFSMNT_POSIX 0x40000 /* static pathconf kludge info */ # define NFSMNT_LLOCK 0x80000 /* Local locking (no lock manager) */ # define NFSMNT_ACL 0x100000 /* turn on acl support */ # define NFSMNT_BIODS 0x200000 /* number of biods per mount */ # define NFSMNT_EXTATTR 0x400000 /* extended attribute usage */ # define NFSMNT_FASTATTR 0x800000 /* no sync_vp in nfs3_getattr */ # define NFSMNT_COMBEHND 0x1000000 /* allow commit behind */ # define NFSMNT_NUMCLUST 0x2000000 /* number of cluster per mount */ # define NFSMNT_NODIRCACHE 0x4000000 /* No readdir cache */ #endif /* not MNTOPT_ACDIRMAX */ /********************************************************************************/ /* map field names */ #define ex_dir ex_name #define gr_name g_name #define gr_next g_next #define ml_directory ml_path #define ml_hostname ml_name #define ml_next ml_nxt #define dr_drok_u diropres #define ca_attributes attributes #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_blocks blocks #define na_blocksize blocksize #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_gid gid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_rdev rdev #define na_size size #define na_type type #define na_uid uid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define ra_count count #define ra_fhandle file #define ra_offset offset #define ra_totalcount totalcount #define raok_attributes attributes #define raok_len_u data_len #define raok_u data #define raok_val_u data_val #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_reply_u reply #define rr_status status #define rr_u readres_u #define sa_atime atime #define sa_gid gid #define sa_mode mode #define sa_mtime mtime #define sa_size size #define sa_uid uid #define sag_attributes attributes #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_attributes attributes #define sla_from from #define sla_to to #define wra_beginoffset beginoffset #define wra_fhandle file #define wra_len_u data_len #define wra_offset offset #define wra_totalcount totalcount #define wra_u data #define wra_val_u data_val /* * TYPEDEFS: */ typedef char *dirpath; typedef char *name; typedef struct exports *exports; typedef struct exports exportnode; typedef struct groups *groups; typedef struct groups groupnode; typedef struct mountlist *mountlist; /* * If these definitions fail to compile on your AIX 5.2 system, be * sure you install all of the necessary header files. */ typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropokres nfsdiropokres; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readokres nfsreadokres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattr nfssattr; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* * EXTERNALS: */ /* * STRUCTURES: */ /* * AIX 5.2 has NFS V3, but it is undefined in the header files. * so I define everything that's needed for NFS V3 here. */ #ifdef MNT_NFS3 struct aix5_nfs_args { struct sockaddr_in addr; /* file server address */ struct sockaddr_in *syncaddr; /* secure NFS time sync addr */ int proto; char *hostname; /* server's hostname */ char *netname; /* server's netname */ caddr_t fh; /* File handle to be mounted */ int flags; /* flags */ int wsize; /* write size in bytes */ int rsize; /* read size in bytes */ int timeo; /* initial timeout in .1 secs */ int retrans; /* times to retry send */ int acregmin; /* attr cache file min secs */ int acregmax; /* attr cache file max secs */ int acdirmin; /* attr cache dir min secs */ int acdirmax; /* attr cache dir max secs */ struct ppathcnf *pathconf; /* static pathconf kludge */ int biods; /* biods per mount */ int numclust; /* numclust per mount */ }; #endif /* MNT_NFS3 */ /* ************************************************************************** * AIX 5.2's autofs is not ported or tested yet... * For now, undefine it or define dummy entries. ************************************************************************** */ #ifdef MNT_AUTOFS # undef MNT_AUTOFS #endif /* MNT_AUTOFS */ #ifdef HAVE_FS_AUTOFS # undef HAVE_FS_AUTOFS #endif /* HAVE_FS_AUTOFS */ /* * EXTERNALS: */ extern bool_t xdr_groups(XDR *xdrs, groups *objp); extern char *yperr_string (int incode); #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_bsdi2.h000066400000000000000000000317011157065440000222010ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_bsdi2.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ #ifdef HAVE_UFS_UFS_UFSMOUNT_H # ifndef MAXQUOTAS # define MAXQUOTAS 2 # endif /* not MAXQUOTAS */ /* fake structure: too difficult to include other headers here */ struct netexport { int this_is_SO_wrong; }; # include #endif /* HAVE_UFS_UFS_UFSMOUNT_H */ /* * is for kernel only on bsdi2, so do not * include it. */ #ifndef ____MSDOSFS_MSDOSFSMOUNT_H__ # define ____MSDOSFS_MSDOSFSMOUNT_H__ #endif /* ____MSDOSFS_MSDOSFSMOUNT_H__ */ /* * getifaddrs() on bsdi2 is broken. Don't use it. */ #ifdef HAVE_GETIFADDRS # undef HAVE_GETIFADDRS #endif /* HAVE_GETIFADDRS */ /* * MACROS */ #define NFS_PORT 2049 #ifndef NFS_MAXDATA # define NFS_MAXDATA 8192 #endif /* NFS_MAXDATA */ #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #ifndef NFS_PROGRAM # define NFS_PROGRAM ((u_long)100003) #endif /* not NFS_PROGRAM */ #ifndef NFS_VERSION # define NFS_VERSION ((u_long)2) #endif /* not NFS_VERSION */ /* * BSD/OS 2.1 deprecated NFSPROC_ROOT and NFSPROC_WRITECACHE and set them * to NFSPROC_NOOP. * Since amd is its own NFS server, reinstate them. */ #if (NFSPROC_ROOT == NFSPROC_NOOP) # undef NFSPROC_ROOT # define NFSPROC_ROOT 3 #endif /* (NFSPROC_ROOT == NFSPROC_NOOP) */ #if (NFSPROC_WRITECACHE == NFSPROC_NOOP) # undef NFSPROC_WRITECACHE # define NFSPROC_WRITECACHE 7 #endif /* (NFSPROC_WRITECACHE == NFSPROC_NOOP) */ /* map field names */ #define ex_dir ex_name #define gr_name g_name #define gr_next g_next #define ml_directory ml_path #define ml_hostname ml_name #define ml_next ml_nxt #define fh_data fh_bytes /* * TYPEDEFS: */ typedef char *dirpath; typedef char *filename; typedef char *name; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef nfstype nfsftype; typedef enum nfsstat nfsstat; typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct exports *exports; typedef struct exports exportnode; typedef struct fattr nfsfattr; typedef struct fhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct linkargs nfslinkargs; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; typedef struct nfstime nfstime; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern nfsattrstat *nfsproc_getattr_2_svc(nfsv2fh_t *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2_svc(nfsv2fh_t *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(nfsv2fh_t *, struct svc_req *); extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern bool_t xdr_attrstat(XDR *, nfsattrstat*); extern bool_t xdr_createargs(XDR *, nfscreateargs*); extern bool_t xdr_dirlist(XDR *, nfsdirlist*); extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); extern bool_t xdr_diropres(XDR *, nfsdiropres*); extern bool_t xdr_entry(XDR *, nfsentry*); extern bool_t xdr_fattr(XDR *, nfsfattr*); extern bool_t xdr_filename(XDR *, filename*); extern bool_t xdr_ftype(XDR *, nfsftype*); extern bool_t xdr_linkargs(XDR *, nfslinkargs*); extern bool_t xdr_mountlist(XDR *xdrs, mountlist *objp); extern bool_t xdr_nfs_fh(XDR *, nfsv2fh_t*); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_nfspath(XDR *, nfspath*); extern bool_t xdr_nfsstat(XDR *, nfsstat*); extern bool_t xdr_nfstime(XDR *, nfstime*); extern bool_t xdr_readargs(XDR *, nfsreadargs*); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); extern bool_t xdr_readokres(XDR *, nfsreadokres*); extern bool_t xdr_readres(XDR *, nfsreadres*); extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); extern bool_t xdr_sattr(XDR *, nfssattr*); extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); extern bool_t xdr_writeargs(XDR *, nfswriteargs*); /* * ENUMS: */ /* * Use AMU_ prefixes so as to not conflict with #define's in . * It is vital! that the AMU_* match one-to-one with the NFS_OK and NFSERR_* * codes listed in . */ enum nfsstat { AMU_NFS_OK = 0, AMU_NFSERR_PERM = 1, AMU_NFSERR_NOENT = 2, AMU_NFSERR_IO = 5, AMU_NFSERR_NXIO = 6, AMU_NFSERR_ACCES = 13, AMU_NFSERR_EXIST = 17, AMU_NFSERR_NODEV = 19, AMU_NFSERR_NOTDIR = 20, AMU_NFSERR_ISDIR = 21, AMU_NFSERR_FBIG = 27, AMU_NFSERR_NOSPC = 28, AMU_NFSERR_ROFS = 30, AMU_NFSERR_NAMETOOLONG = 63, AMU_NFSERR_NOTEMPTY = 66, AMU_NFSERR_DQUOT = 69, AMU_NFSERR_STALE = 70, AMU_NFSERR_WFLUSH = 99 }; /* * STRUCTURES: */ struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct sattrargs { nfsv2fh_t sag_fhandle; nfssattr sag_attributes; }; struct diropargs { nfsv2fh_t da_fhandle; /* was dir */ filename da_name; }; struct diropokres { nfsv2fh_t drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct readlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct readargs { nfsv2fh_t ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct readokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct readres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { nfsv2fh_t wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct createargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct renameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct linkargs { nfsv2fh_t la_fhandle; nfsdiropargs la_to; }; struct symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct readdirargs { nfsv2fh_t rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct entry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct dirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct readdirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; /****************************************************************************/ /*** XDR ADDITIONS ***/ /****************************************************************************/ struct exports { dirpath ex_dir; groups ex_groups; exports ex_next; }; typedef char fhandle[NFS_FHSIZE]; struct fhstatus { u_int fhs_status; union { fhandle fhs_fhandle; } fhstatus_u; }; struct groups { name gr_name; groups gr_next; }; struct mountlist { name ml_hostname; dirpath ml_directory; mountlist ml_next; }; /****************************************************************************/ /*** NFS ADDITIONS ***/ /****************************************************************************/ #ifndef MOUNTPROG # define MOUNTPROG RPCPROG_MNT #endif /* not MOUNTPROG */ #ifndef MOUNTVERS # define MOUNTVERS RPCMNT_VER1 #endif /* not MOUNTVERS */ #ifndef MOUNTPROC_MNT # define MOUNTPROC_MNT RPCMNT_MOUNT #endif /* not MOUNTPROC_MNT */ #ifndef MOUNTPROC_DUMP # define MOUNTPROC_DUMP RPCMNT_DUMP #endif /* not MOUNTPROC_DUMP */ #ifndef MOUNTPROC_UMNT # define MOUNTPROC_UMNT RPCMNT_UMOUNT #endif /* not MOUNTPROC_UMNT */ #ifndef MOUNTPROC_UMNTALL # define MOUNTPROC_UMNTALL RPCMNT_UMNTALL #endif /* not MOUNTPROC_UMNTALL */ #ifndef MOUNTPROC_EXPORT # define MOUNTPROC_EXPORT RPCMNT_EXPORT #endif /* not MOUNTPROC_EXPORT */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_bsdi3.h000066400000000000000000000132671157065440000222110ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_bsdi3.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifndef NFS_NPROCS # define NFS_NPROCS 26 #endif /* not NFS_NPROCS */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ #ifdef HAVE_UFS_UFS_UFSMOUNT_H # include #endif /* HAVE_UFS_UFS_UFSMOUNT_H */ /****************************************************************************/ /* * NFS V3 support: * BSD/OS 3.0 has it but no easy way to figure it out from the header files. */ #ifndef MNTTYPE_NFS3 # define MNTTYPE_NFS3 "nfs" #endif /* MNTTYPE_NFS3 */ /****************************************************************************/ /* * MACROS: */ #define dr_drok_u diropres #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_size size #define na_type type #define na_gid gid #define na_uid uid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_status status #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_from from #define wra_fhandle file /* * TYPEDEFS: */ typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* missing definitions from bsdi4 */ #if defined(HAVE_MAP_HESIOD) && !defined(HAVE_HESIOD_H) extern int hesiod_init(void **context); #endif /* defined(HAVE_MAP_HESIOD) && !defined(HAVE_HESIOD_H) */ /* * On bsdi4, NFS V3/tcp mounts should not use the default resvport option. * Defining this mnt option string will force compute_nfs_args() to not * use reserved ports unless it was specified as a mount option. */ #ifndef MNTTAB_OPT_RESVPORT # define MNTTAB_OPT_RESVPORT "resvport" #endif /* not MNTTAB_OPT_RESVPORT */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_darwin.h000066400000000000000000000127541157065440000224710ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_darwin.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_UFS_UFS_UFSMOUNT_H # include #endif /* HAVE_UFS_UFS_UFSMOUNT_H */ /* * MACROS: */ #define dr_drok_u diropres #define ca_attributes attributes #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_gid gid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_size size #define na_type type #define na_uid uid #define na_blocks blocks #define na_blocksize blocksize #define na_rdev rdev #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define ra_count count #define ra_fhandle file #define ra_offset offset #define ra_totalcount totalcount #define raok_attributes attributes #define raok_len_u data_len #define raok_u data #define raok_val_u data_val #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_reply_u reply #define rr_status status #define rr_u readres_u #define sa_atime atime #define sa_gid gid #define sa_mode mode #define sa_mtime mtime #define sa_size size #define sa_uid uid #define sag_attributes attributes #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_attributes attributes #define sla_from from #define sla_to to #define wra_beginoffset beginoffset #define wra_fhandle file #define wra_len_u data_len #define wra_offset offset #define wra_totalcount totalcount #define wra_u data #define wra_val_u data_val /* * TYPEDEFS: */ typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropokres nfsdiropokres; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readokres nfsreadokres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattr nfssattr; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; #ifdef NFSMNT_NFSV3 # define MOUNT_NFS3 "nfs" /* is this right? */ # define MNTOPT_NFS3 "nfs" #endif /* NFSMNT_NFSV3 */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_default.h000066400000000000000000000122011157065440000226140ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_default.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ /* * MACROS: */ #define dr_drok_u diropres #define ca_attributes attributes #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_blocks blocks #define na_blocksize blocksize #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_gid gid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_rdev rdev #define na_size size #define na_type type #define na_uid uid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define ra_count count #define ra_fhandle file #define ra_offset offset #define ra_totalcount totalcount #define raok_attributes attributes #define raok_len_u data_len #define raok_u data #define raok_val_u data_val #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_reply_u reply #define rr_status status #define rr_u readres_u #define sa_atime atime #define sa_gid gid #define sa_mode mode #define sa_mtime mtime #define sa_size size #define sa_uid uid #define sag_attributes attributes #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_attributes attributes #define sla_from from #define sla_to to #define wra_beginoffset beginoffset #define wra_fhandle file #define wra_len_u data_len #define wra_offset offset #define wra_totalcount totalcount #define wra_u data #define wra_val_u data_val /* * TYPEDEFS: */ typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropokres nfsdiropokres; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readokres nfsreadokres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattr nfssattr; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_freebsd2.h000066400000000000000000000107111157065440000226700ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_freebsd2.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ /* * MACROS: */ #define dr_drok_u diropres #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_size size #define na_type type #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_status status #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_from from #define wra_fhandle file /* * TYPEDEFS: */ typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* * FreeBSD 2.2.x has NFS V3, but it does not define enough macros * in the headers to automatically detect it. * So fake it in the meant time. */ #if 0 #define MOUNT_NFS3 MOUNT_NFS #endif /* 0 */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_freebsd3.h000066400000000000000000000136561157065440000227040ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_freebsd3.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_UFS_UFS_UFSMOUNT_H # ifdef HAVE_UFS_UFS_EXTATTR_H /* * Define a dummy struct ufs_extattr_per_mount, which is used in struct * ufsmount in . */ struct ufs_extattr_per_mount; # endif /* HAVE_UFS_UFS_EXTATTR_H */ # include #endif /* HAVE_UFS_UFS_UFSMOUNT_H */ /* nfsclient/nfsargs.h was introduced in FreeBSD 5.0, and is needed */ #ifdef HAVE_NFSCLIENT_NFSARGS_H # include #endif /* HAVE_NFSCLIENT_NFSARGS_H */ /* * MACROS: */ #define dr_drok_u diropres #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_size size #define na_type type #define na_uid uid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_status status #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_from from #define wra_fhandle file /* * TYPEDEFS: */ typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* * * FreeBSD-3.0-RELEASE has NFS V3. Older versions had it only defined * in the rpcgen source file. If you are on an older system, and you * want NFSv3 support, you need to regenerate the rpcsvc header files as * follows: * cd /usr/include/rpcsvc * rpcgen -h -C -DWANT_NFS3 mount.x * rpcgen -h -C -DWANT_NFS3 nfs_prot.x * If you don't want NFSv3, then you will have to turn off the NFSMNT_NFSV3 * macro below. If the code doesn't compile, upgrade to the latest 3.0 * version... */ #ifdef NFSMNT_NFSV3 # define MOUNT_NFS3 "nfs" /* is this right? */ # define MNTOPT_NFS3 "nfs" # ifndef HAVE_XDR_LOOKUP3RES /* * FreeBSD uses different field names than are defined on most other * systems. */ # define AMU_LOOKUP3RES_OK(x) ((x)->LOOKUP3res_u.resok) # define AMU_LOOKUP3RES_FAIL(x) ((x)->LOOKUP3res_u.resfail) # define AMU_LOOKUP3RES_FH_LEN(x) (AMU_LOOKUP3RES_OK(x).object.data.data_len) # define AMU_LOOKUP3RES_FH_DATA(x) (AMU_LOOKUP3RES_OK(x).object.data.data_val) # endif /* not HAVE_XDR_LOOKUP3RES */ #endif /* NFSMNT_NFSV3 */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_hpux.h000066400000000000000000000255151157065440000221700ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_hpux.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_NFS_EXPORT_H_not /* don't include this b/c it'll get included twice */ # include #endif /* HAVE_NFS_EXPORT_H */ #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ #ifdef HAVE_NETDB_H extern int h_errno; /* missing from older hpux10 systems */ #endif /* HAVE_NETDB_H */ /* * Turn off NFS V.3 support to avoid confusing am-utils. * 10.20 with some patches has incomplete support. */ #undef MNTTYPE_NFS3 #undef MNTTAB_TYPE_NFS3 #undef HAVE_FS_NFS3 /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #ifndef NFS_PROGRAM # define NFS_PROGRAM ((u_long)100003) #endif /* not NFS_PROGRAM */ #ifndef NFS_VERSION # define NFS_VERSION ((u_long)2) #endif /* not NFS_VERSION */ #define NFSPROC_NULL ((u_long)0) #define NFSPROC_GETATTR ((u_long)1) #define NFSPROC_SETATTR ((u_long)2) #define NFSPROC_ROOT ((u_long)3) #define NFSPROC_LOOKUP ((u_long)4) #define NFSPROC_READLINK ((u_long)5) #define NFSPROC_READ ((u_long)6) #define NFSPROC_WRITECACHE ((u_long)7) #define NFSPROC_WRITE ((u_long)8) #define NFSPROC_CREATE ((u_long)9) #define NFSPROC_REMOVE ((u_long)10) #define NFSPROC_RENAME ((u_long)11) #define NFSPROC_LINK ((u_long)12) #define NFSPROC_SYMLINK ((u_long)13) #define NFSPROC_MKDIR ((u_long)14) #define NFSPROC_RMDIR ((u_long)15) #define NFSPROC_READDIR ((u_long)16) #define NFSPROC_STATFS ((u_long)17) /* map field names */ #define ml_hostname ml_name #define ml_directory ml_path #define ml_next ml_nxt #define gr_next g_next #define gr_name g_name #define ex_dir ex_name /* * TYPEDEFS: */ typedef char *dirpath; typedef char *filename; typedef char *name; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; #ifndef HAVE_FHANDLE typedef fhandle_t fhandle; #endif /* not HAVE_FHANDLE */ typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct exports *exports; typedef struct exports exportnode; typedef struct fattr nfsfattr; typedef struct fhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct linkargs nfslinkargs; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; typedef struct nfstime nfstime; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_getattr_2_svc(fhandle_t *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2_svc(fhandle_t *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(fhandle_t *, struct svc_req *); extern bool_t xdr_nfsstat(XDR *, nfsstat*); extern bool_t xdr_ftype(XDR *, nfsftype*); extern bool_t xdr_nfs_fh(XDR *, fhandle_t*); extern bool_t xdr_nfstime(XDR *, nfstime*); extern bool_t xdr_fattr(XDR *, nfsfattr*); extern bool_t xdr_sattr(XDR *, nfssattr*); extern bool_t xdr_filename(XDR *, filename*); extern bool_t xdr_nfspath(XDR *, nfspath*); extern bool_t xdr_attrstat(XDR *, nfsattrstat*); extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); extern bool_t xdr_diropres(XDR *, nfsdiropres*); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); extern bool_t xdr_readargs(XDR *, nfsreadargs*); extern bool_t xdr_readokres(XDR *, nfsreadokres*); extern bool_t xdr_readres(XDR *, nfsreadres*); extern bool_t xdr_writeargs(XDR *, nfswriteargs*); extern bool_t xdr_createargs(XDR *, nfscreateargs*); extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); extern bool_t xdr_linkargs(XDR *, nfslinkargs*); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); extern bool_t xdr_entry(XDR *, nfsentry*); extern bool_t xdr_dirlist(XDR *, nfsdirlist*); extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); /* * STRUCTURES: */ struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct sattrargs { fhandle_t sag_fhandle; nfssattr sag_attributes; }; struct diropargs { fhandle_t da_fhandle; /* was dir */ filename da_name; }; struct diropokres { fhandle_t drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct readlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct readargs { fhandle_t ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct readokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct readres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { fhandle_t wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct createargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct renameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct linkargs { fhandle_t la_fhandle; nfsdiropargs la_to; }; struct symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct readdirargs { fhandle_t rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct entry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct dirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct readdirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_hpux11.h000066400000000000000000000414671157065440000223360ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_hpux11.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H /* * NOTE: HPUX 11 is missing many header definitions which had to be * guessed and copied over from HPUX 10.20. */ /* don't include this file as it isn't needed on hpux */ #ifndef _TIUSER_H # define _TIUSER_H #endif /* TIUSER_H */ #ifndef _TIUSER_INCLUDED # define _TIUSER_INCLUDED #endif /* TIUSER_INCLUDED */ #ifndef _SYS_TIUSER_INCLUDED # define _SYS_TIUSER_INCLUDED #endif /* _SYS_TIUSER_INCLUDED */ /* if T_NULL is defined, undefine it due to a conflict with */ #ifdef T_NULL # undef T_NULL #endif /* T_NULL */ #ifdef HAVE_NFS_EXPORT_H_not /* don't include this b/c it'll get included twice */ # include #endif /* HAVE_NFS_EXPORT_H */ #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #define HOSTNAMESZ 32 /* Max size of hostname in struct nfs_args */ #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #ifndef NFS_PROGRAM # define NFS_PROGRAM ((u_long)100003) #endif /* not NFS_PROGRAM */ #ifndef NFS_VERSION # define NFS_VERSION ((u_long)2) #endif /* not NFS_VERSION */ #define NFSPROC_NULL ((u_long)0) #define NFSPROC_GETATTR ((u_long)1) #define NFSPROC_SETATTR ((u_long)2) #define NFSPROC_ROOT ((u_long)3) #define NFSPROC_LOOKUP ((u_long)4) #define NFSPROC_READLINK ((u_long)5) #define NFSPROC_READ ((u_long)6) #define NFSPROC_WRITECACHE ((u_long)7) #define NFSPROC_WRITE ((u_long)8) #define NFSPROC_CREATE ((u_long)9) #define NFSPROC_REMOVE ((u_long)10) #define NFSPROC_RENAME ((u_long)11) #define NFSPROC_LINK ((u_long)12) #define NFSPROC_SYMLINK ((u_long)13) #define NFSPROC_MKDIR ((u_long)14) #define NFSPROC_RMDIR ((u_long)15) #define NFSPROC_READDIR ((u_long)16) #define NFSPROC_STATFS ((u_long)17) /* * NFS mount option flags */ #define NFSMNT_SOFT 0x001 /* soft mount (hard is default) */ #define NFSMNT_WSIZE 0x002 /* set write size */ #define NFSMNT_RSIZE 0x004 /* set read size */ #define NFSMNT_TIMEO 0x008 /* set initial timeout */ #define NFSMNT_RETRANS 0x010 /* set number of request retries */ #define NFSMNT_HOSTNAME 0x020 /* set hostname for error printf */ #define NFSMNT_INT 0x040 /* allow interrupts on hard mount */ #define NFSMNT_NOAC 0x080 /* don't cache attributes */ #define NFSMNT_ACREGMIN 0x0100 /* set min secs for file attr cache */ #define NFSMNT_ACREGMAX 0x0200 /* set max secs for file attr cache */ #define NFSMNT_ACDIRMIN 0x0400 /* set min secs for dir attr cache */ #define NFSMNT_ACDIRMAX 0x0800 /* set max secs for dir attr cache */ #define NFSMNT_SECURE 0x1000 /* secure mount */ #define NFSMNT_NOCTO 0x2000 /* no close-to-open consistency */ #define NFSMNT_KNCONF 0x4000 /* transport's knetconfig structure */ #define NFSMNT_GRPID 0x8000 /* System V-style gid inheritance */ #define NFSMNT_RPCTIMESYNC 0x10000 /* use RPC to do secure NFS time sync */ #define NFSMNT_KERBEROS 0x20000 /* use kerberos credentials */ #define NFSMNT_POSIX 0x40000 /* static pathconf kludge info */ #define NFSMNT_LLOCK 0x80000 /* Local locking (no lock manager) */ #define NFSMNT_REMOUNT 0x100000 /* Remount from r/o to r/w */ #define NFSMNT_FSNAME 0x1000000 /* FS name e.g. "host:/path/" */ #define NFSMNT_NODEVS 0x2000000 /* no devices access (default on) */ #define NFSMNT_IGNORE 0x4000000 /* ignore in mnttab */ #define MS_FSS 0x00 /* fake flag to do nothing */ /* * ENUMS: */ /* * Error status * Should include all possible net errors. * For now we just cast errno into an enum nfsstat. */ enum nfsstat { NFS_OK = 0, /* no error */ NFSERR_PERM = 1, /* Not owner */ NFSERR_NOENT = 2, /* No such file or directory */ NFSERR_IO = 5, /* I/O error */ NFSERR_NXIO = 6, /* No such device or address */ NFSERR_ACCES = 13, /* Permission denied */ NFSERR_EXIST = 17, /* File exists */ NFSERR_XDEV = 18, /* Cross-device link */ NFSERR_NODEV = 19, /* No such device */ NFSERR_NOTDIR = 20, /* Not a directory */ NFSERR_ISDIR = 21, /* Is a directory */ NFSERR_INVAL = 22, /* Invalid argument */ NFSERR_FBIG = 27, /* File too large */ NFSERR_NOSPC = 28, /* No space left on device */ NFSERR_ROFS = 30, /* Read-only file system */ NFSERR_OPNOTSUPP = 45, /* Operation not supported */ NFSERR_NAMETOOLONG = 63, /* File name too long */ NFSERR_NOTEMPTY = 66, /* Directory not empty */ NFSERR_DQUOT = 69, /* Disc quota exceeded */ NFSERR_STALE = 70, /* Stale NFS file handle */ NFSERR_REMOTE = 71, /* Object is remote */ NFSERR_WFLUSH /* write cache flushed */ }; /* * File types */ enum nfsftype { NFNON, NFREG, /* regular file */ NFDIR, /* directory */ NFBLK, /* block special */ NFCHR, /* character special */ NFLNK, /* symbolic link */ NFSOC /* socket */ }; /* * TYPEDEFS: */ typedef struct nfs_fh nfs_fh; typedef char *filename; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct fattr nfsfattr; typedef struct linkargs nfslinkargs; typedef struct nfstime nfstime; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * NFSv3 handle (copied from am_xdr_func.h, because it is needed here) * we use a different name but same storage size/alignment to avoid * conflicts. Sigh, this is so hacky. -ezk */ #define HPUX11_FHSIZE3 64 /* size in bytes of a file handle (v3) */ struct hpux11_nfs_fh3 { u_int am_fh3_length; char am_fh3_data[HPUX11_FHSIZE3]; }; typedef struct hpux11_nfs_fh3 hpux11_nfs_fh3; /* * EXTERNALS: */ extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); extern bool_t xdr_nfsstat(XDR *, nfsstat*); extern bool_t xdr_ftype(XDR *, nfsftype*); extern bool_t xdr_nfs_fh(XDR *, nfs_fh*); extern bool_t xdr_nfstime(XDR *, nfstime*); extern bool_t xdr_fattr(XDR *, nfsfattr*); extern bool_t xdr_sattr(XDR *, nfssattr*); extern bool_t xdr_filename(XDR *, filename*); extern bool_t xdr_nfspath(XDR *, nfspath*); extern bool_t xdr_attrstat(XDR *, nfsattrstat*); extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); extern bool_t xdr_diropres(XDR *, nfsdiropres*); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); extern bool_t xdr_readargs(XDR *, nfsreadargs*); extern bool_t xdr_readokres(XDR *, nfsreadokres*); extern bool_t xdr_readres(XDR *, nfsreadres*); extern bool_t xdr_writeargs(XDR *, nfswriteargs*); extern bool_t xdr_createargs(XDR *, nfscreateargs*); extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); extern bool_t xdr_linkargs(XDR *, nfslinkargs*); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); extern bool_t xdr_entry(XDR *, nfsentry*); extern bool_t xdr_dirlist(XDR *, nfsdirlist*); extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); /* * STRUCTURES: */ /* This is similar to Solaris 2.5.1 */ struct nfs_args { struct netbuf *addr; /* file server address */ struct netbuf *syncaddr; /* secure NFS time sync addr */ struct knetconfig *knconf; /* transport netconfig struct */ char *hostname; /* server's hostname */ char *netname; /* server's netname */ caddr_t fh; /* File handle to be mounted */ int flags; /* flags */ int wsize; /* write size in bytes */ int rsize; /* read size in bytes */ int timeo; /* initial timeout in .1 secs */ int retrans; /* times to retry send */ int acregmin; /* attr cache file min secs */ int acregmax; /* attr cache file max secs */ int acdirmin; /* attr cache dir min secs */ int acdirmax; /* attr cache dir max secs */ char *fsname; /* F/S name */ #if 0 struct pathcnf *pathconf; /* static pathconf kludge */ #endif /* 0 */ }; struct nfs_fh { char fh_data[NFS_FHSIZE]; }; struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct sattrargs { nfs_fh sag_fhandle; nfssattr sag_attributes; }; struct diropargs { nfs_fh da_fhandle; /* was dir */ filename da_name; }; struct diropokres { nfs_fh drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct readlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct readargs { nfs_fh ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct readokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct readres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { nfs_fh wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct createargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct renameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct linkargs { nfs_fh la_fhandle; nfsdiropargs la_to; }; struct symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct readdirargs { nfs_fh rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct entry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct dirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct readdirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; /* ************************************************************************** * HP-UX 11 has Autofs support, but we don't support it yet. * For now, undefine it or define dummy entries. ************************************************************************** */ #ifdef MNTTYPE_AUTOFS # undef MNTTYPE_AUTOFS #endif /* MNTTYPE_AUTOFS */ #ifdef MNTTAB_TYPE_AUTOFS # undef MNTTAB_TYPE_AUTOFS #endif /* MNTTAB_TYPE_AUTOFS */ #ifdef HAVE_FS_AUTOFS # undef HAVE_FS_AUTOFS #endif /* HAVE_FS_AUTOFS */ #ifdef MNTTYPE_NFS3 #define NFSPROC3_LOOKUP ((u_long) 3) enum nfsstat3 { NFS3_OK = 0, NFS3ERR_PERM = 1, NFS3ERR_NOENT = 2, NFS3ERR_IO = 5, NFS3ERR_NXIO = 6, NFS3ERR_ACCES = 13, NFS3ERR_EXIST = 17, NFS3ERR_XDEV = 18, NFS3ERR_NODEV = 19, NFS3ERR_NOTDIR = 20, NFS3ERR_ISDIR = 21, NFS3ERR_INVAL = 22, NFS3ERR_FBIG = 27, NFS3ERR_NOSPC = 28, NFS3ERR_ROFS = 30, NFS3ERR_MLINK = 31, NFS3ERR_NAMETOOLONG = 63, NFS3ERR_NOTEMPTY = 66, NFS3ERR_DQUOT = 69, NFS3ERR_STALE = 70, NFS3ERR_REMOTE = 71, NFS3ERR_BADHANDLE = 10001, NFS3ERR_NOT_SYNC = 10002, NFS3ERR_BAD_COOKIE = 10003, NFS3ERR_NOTSUPP = 10004, NFS3ERR_TOOSMALL = 10005, NFS3ERR_SERVERFAULT = 10006, NFS3ERR_BADTYPE = 10007, NFS3ERR_JUKEBOX = 10008 }; typedef enum nfsstat3 nfsstat3; typedef char *filename3; struct diropargs3 { hpux11_nfs_fh3 dir; filename3 name; }; typedef struct diropargs3 diropargs3; struct LOOKUP3args { diropargs3 what; }; typedef struct LOOKUP3args LOOKUP3args; struct LOOKUP3resok { hpux11_nfs_fh3 object; #if 0 post_op_attr obj_attributes; post_op_attr dir_attributes; #endif /* 0 */ }; typedef struct LOOKUP3resok LOOKUP3resok; struct LOOKUP3resfail { int dummy; #if 0 post_op_attr dir_attributes; #endif /* 0 */ }; typedef struct LOOKUP3resfail LOOKUP3resfail; struct LOOKUP3res { nfsstat3 status; union { LOOKUP3resok ok; LOOKUP3resfail fail; } res_u; }; typedef struct LOOKUP3res LOOKUP3res; # endif /* MNTTYPE_NFS3 */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_irix5.h000066400000000000000000000310171157065440000222360ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_irix5.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_SYS_UIO_H # define _KMEMUSER # include # undef _KMEMUSER #endif /* HAVE_SYS_UIO_H */ #ifdef HAVE_SYS_VNODE_H # include #endif /* HAVE_SYS_VNODE_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ #ifdef HAVE_SYS_FSTYP_H # include #endif /* HAVE_SYS_FSTYP_H */ /* XFS isn't really supported in 5.3, but the header files are confusing */ #undef MNTTYPE_XFS #undef MNTTAB_TYPE_XFS /****************************************************************************/ /* * NFS V3 SUPPORT: * * IRIX5.3 requires the fh_len field to be added to the struct nfs_args * defined in for NFS3 mounts (it doesn't hurt for * NFS2 mounts). The mount syscall however always expects the argument * structure size to be sizeof(struct nfs_args). * So we need to use an extended struct nfs_args in amd/ops_nfs.c, * while using the original struct nfs_arg in libamu/mountutil.c. * -- stolcke 7/4/97 */ /* * NFS arguments to the mount system call. */ struct irix5_nfs_args { struct sockaddr_in *addr; /* file server address */ fhandle_t *fh; /* File handle to be mounted */ int flags; /* flags */ u_int wsize; /* write size in bytes */ u_int rsize; /* read size in bytes */ u_int timeo; /* initial timeout in .1 secs */ u_int retrans; /* times to retry send */ char *hostname; /* server's name */ u_int acregmin; /* attr cache file min secs */ u_int acregmax; /* attr cache file max secs */ u_int acdirmin; /* attr cache dir min secs */ u_int acdirmax; /* attr cache dir max secs */ u_int symttl; /* symlink cache time-to-live */ char base[FSTYPSZ]; /* base type for statvfs */ u_int namemax; /* name length for statvfs */ u_int fh_len; /* length for a v3 filehandle */ }; #ifndef MNTOPT_PROTO # define MNTOPT_PROTO "proto" #endif /* not MNTOPT_PROTO */ #ifndef MNTOPT_VERS # define MNTOPT_VERS "vers" #endif /* not MNTOPT_VERS */ /****************************************************************************/ /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #ifndef FHSIZE /* Irix 5.2 is missing the definition for FHSIZE */ # define FHSIZE NFS_FHSIZE #endif /* not FHSIZE */ #define NFS_COOKIESIZE 4 #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #ifndef NFS_PROGRAM # define NFS_PROGRAM ((u_long)100003) #endif /* not NFS_PROGRAM */ #ifndef NFS_VERSION # define NFS_VERSION ((u_long)2) #endif /* not NFS_VERSION */ #define NFSPROC_NULL ((u_long)0) #define NFSPROC_GETATTR ((u_long)1) #define NFSPROC_SETATTR ((u_long)2) #define NFSPROC_ROOT ((u_long)3) #define NFSPROC_LOOKUP ((u_long)4) #define NFSPROC_READLINK ((u_long)5) #define NFSPROC_READ ((u_long)6) #define NFSPROC_WRITECACHE ((u_long)7) #define NFSPROC_WRITE ((u_long)8) #define NFSPROC_CREATE ((u_long)9) #define NFSPROC_REMOVE ((u_long)10) #define NFSPROC_RENAME ((u_long)11) #define NFSPROC_LINK ((u_long)12) #define NFSPROC_SYMLINK ((u_long)13) #define NFSPROC_MKDIR ((u_long)14) #define NFSPROC_RMDIR ((u_long)15) #define NFSPROC_READDIR ((u_long)16) #define NFSPROC_STATFS ((u_long)17) /* map field names */ #define ml_hostname ml_name #define ml_directory ml_path #define ml_next ml_nxt #define gr_next g_next #define gr_name g_name #define ex_dir ex_name /* * TYPEDEFS: */ typedef char *dirpath; typedef char *filename; typedef char *name; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct exports *exports; typedef struct exports exportnode; typedef struct fattr nfsfattr; typedef struct fhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct linkargs nfslinkargs; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; typedef struct nfs_fh nfs_fh; typedef struct nfstime nfstime; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); extern bool_t xdr_nfsstat(XDR *, nfsstat*); extern bool_t xdr_ftype(XDR *, nfsftype*); extern bool_t xdr_nfs_fh(XDR *, nfs_fh*); extern bool_t xdr_nfstime(XDR *, nfstime*); extern bool_t xdr_fattr(XDR *, nfsfattr*); extern bool_t xdr_sattr(XDR *, nfssattr*); extern bool_t xdr_filename(XDR *, filename*); extern bool_t xdr_nfspath(XDR *, nfspath*); extern bool_t xdr_attrstat(XDR *, nfsattrstat*); extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); extern bool_t xdr_diropres(XDR *, nfsdiropres*); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); extern bool_t xdr_readargs(XDR *, nfsreadargs*); extern bool_t xdr_readokres(XDR *, nfsreadokres*); extern bool_t xdr_readres(XDR *, nfsreadres*); extern bool_t xdr_writeargs(XDR *, nfswriteargs*); extern bool_t xdr_createargs(XDR *, nfscreateargs*); extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); extern bool_t xdr_linkargs(XDR *, nfslinkargs*); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); extern bool_t xdr_entry(XDR *, nfsentry*); extern bool_t xdr_dirlist(XDR *, nfsdirlist*); extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); /* * STRUCTURES: */ struct nfs_fh { char fh_data[NFS_FHSIZE]; }; struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct sattrargs { nfs_fh sag_fhandle; nfssattr sag_attributes; }; struct diropargs { nfs_fh da_fhandle; /* was dir */ filename da_name; }; struct diropokres { nfs_fh drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct readlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct readargs { nfs_fh ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct readokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct readres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { nfs_fh wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct createargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct renameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct linkargs { nfs_fh la_fhandle; nfsdiropargs la_to; }; struct symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct readdirargs { nfs_fh rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct entry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct dirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct readdirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_irix6.h000066400000000000000000000315501157065440000222410ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_irix6.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H_off # include #endif /* HAVE_RPCSVC_MOUNT_H */ /* evil: don't include */ #undef HAVE_RPCSVC_MOUNT_H /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #define FHSIZE 32 #define MOUNTPROG 100005 #define MOUNTPROC_MNT 1 #define MOUNTPROC_DUMP 2 #define MOUNTPROC_UMNT 3 #define MOUNTPROC_UMNTALL 4 #define MOUNTPROC_EXPORT 5 #define MOUNTPROC_EXPORTALL 6 #define MOUNTVERS_ORIG 1 #define MOUNTVERS 1 #define MOUNTVERS3 3 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #ifndef NFS_PROGRAM # define NFS_PROGRAM ((u_long)100003) #endif /* not NFS_PROGRAM */ #ifndef NFS_VERSION # define NFS_VERSION ((u_long)2) #endif /* not NFS_VERSION */ #define NFSPROC_NULL ((u_long)0) #define NFSPROC_GETATTR ((u_long)1) #define NFSPROC_SETATTR ((u_long)2) #define NFSPROC_ROOT ((u_long)3) #define NFSPROC_LOOKUP ((u_long)4) #define NFSPROC_READLINK ((u_long)5) #define NFSPROC_READ ((u_long)6) #define NFSPROC_WRITECACHE ((u_long)7) #define NFSPROC_WRITE ((u_long)8) #define NFSPROC_CREATE ((u_long)9) #define NFSPROC_REMOVE ((u_long)10) #define NFSPROC_RENAME ((u_long)11) #define NFSPROC_LINK ((u_long)12) #define NFSPROC_SYMLINK ((u_long)13) #define NFSPROC_MKDIR ((u_long)14) #define NFSPROC_RMDIR ((u_long)15) #define NFSPROC_READDIR ((u_long)16) #define NFSPROC_STATFS ((u_long)17) /* map field names */ #define ml_hostname ml_name #define ml_directory ml_path #define ml_next ml_nxt #define gr_next g_next #define gr_name g_name #define ex_dir ex_name /* * Irix 6.2 does not define the proto/dev options, although they * do support them for NFS V3. */ #ifdef MNTTYPE_NFS3 # ifndef MNTOPT_PROTO # define MNTOPT_PROTO "proto" # endif /* not MNTOPT_PROTO */ # ifndef MNTOPT_VERS # define MNTOPT_VERS "vers" # endif /* not MNTOPT_VERS */ #endif /* MNTTYPE_NFS3 */ #define AUTOFS_CONFTYPE "udp" /* * TYPEDEFS: */ typedef char *dirpath; typedef char *filename; typedef char *name; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct exports *exports; typedef struct exports exportnode; typedef struct fattr nfsfattr; typedef struct fhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct linkargs nfslinkargs; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; typedef struct nfs_fh nfs_fh; typedef struct nfstime nfstime; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); extern bool_t xdr_nfsstat(XDR *, nfsstat*); extern bool_t xdr_ftype(XDR *, nfsftype*); extern bool_t xdr_nfs_fh(XDR *, nfs_fh*); extern bool_t xdr_nfstime(XDR *, nfstime*); extern bool_t xdr_fattr(XDR *, nfsfattr*); extern bool_t xdr_sattr(XDR *, nfssattr*); extern bool_t xdr_filename(XDR *, filename*); extern bool_t xdr_nfspath(XDR *, nfspath*); extern bool_t xdr_attrstat(XDR *, nfsattrstat*); extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); extern bool_t xdr_diropres(XDR *, nfsdiropres*); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); extern bool_t xdr_readargs(XDR *, nfsreadargs*); extern bool_t xdr_readokres(XDR *, nfsreadokres*); extern bool_t xdr_readres(XDR *, nfsreadres*); extern bool_t xdr_writeargs(XDR *, nfswriteargs*); extern bool_t xdr_createargs(XDR *, nfscreateargs*); extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); extern bool_t xdr_linkargs(XDR *, nfslinkargs*); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); extern bool_t xdr_entry(XDR *, nfsentry*); extern bool_t xdr_dirlist(XDR *, nfsdirlist*); extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); /* * STRUCTURES: */ struct nfs_fh { char fh_data[NFS_FHSIZE]; }; struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct sattrargs { nfs_fh sag_fhandle; nfssattr sag_attributes; }; struct diropargs { nfs_fh da_fhandle; /* was dir */ filename da_name; }; struct diropokres { nfs_fh drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct readlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct readargs { nfs_fh ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct readokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct readres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { nfs_fh wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct createargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct renameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct linkargs { nfs_fh la_fhandle; nfsdiropargs la_to; }; struct symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct readdirargs { nfs_fh rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct entry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct dirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct readdirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; /* * Partial definitions from rpcsvc/mount.h (can't use that header * because it includes other "bad" stuff wrt xdr_groups. */ struct mountlist { char *ml_name; char *ml_path; struct mountlist *ml_nxt; }; struct fhstatus { int fhs_status; fhandle_t fhs_fh; }; typedef char fhandle[FHSIZE]; typedef struct { u_int fhandle3_len; char *fhandle3_val; } fhandle3; enum mountstat3 { MNT_OK = 0, MNT3ERR_PERM = 1, MNT3ERR_NOENT = 2, MNT3ERR_IO = 5, MNT3ERR_ACCES = 13, MNT3ERR_NOTDIR = 20, MNT3ERR_INVAL = 22, MNT3ERR_NAMETOOLONG = 63, MNT3ERR_NOTSUPP = 10004, MNT3ERR_SERVERFAULT = 10006 }; typedef enum mountstat3 mountstat3; struct mountres3_ok { fhandle3 fhandle; struct { u_int auth_flavors_len; int *auth_flavors_val; } auth_flavors; }; typedef struct mountres3_ok mountres3_ok; struct mountres3 { mountstat3 fhs_status; union { mountres3_ok mountinfo; } mountres3_u; }; typedef struct mountres3 mountres3; /* * List of exported directories * An export entry with ex_groups * NULL indicates an entry which is exported to the world. */ struct exports { dev_t ex_dev; /* dev of directory */ char *ex_name; /* name of directory */ struct groups *ex_groups; /* groups allowed to mount this entry */ struct exports *ex_next; short ex_rootmap; /* id to map root requests to */ short ex_flags; /* bits to mask off file mode */ }; struct groups { char *g_name; struct groups *g_next; }; extern bool_t xdr_groups(XDR *, groups *); extern bool_t xdr_exports(XDR *, struct exports **); extern bool_t xdr_mountres3_ok(XDR *, mountres3_ok *); extern bool_t xdr_mountres3(XDR *, mountres3 *); extern bool_t xdr_fhstatus(XDR *, struct fhstatus *); extern bool_t xdr_mountlist(XDR *, struct mountlist **); #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_linux.h000066400000000000000000000216161157065440000223410ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_linux.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ /* * Hard-code support for some file systems so the built amd * binary can always run them. Also, this helps detection of iso9660 * file system for which the module isn't named as the file system mount * name. */ #include #ifndef KERNEL_VERSION # define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) #endif /* not KERNEL_VERSION */ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) # ifndef MS_BIND # define MS_BIND 4096 # endif /* not MS_BIND */ # ifndef MNTTYPE_LOFS # define MNTTYPE_LOFS "bind" # endif /* not MNTTYPE_LOFS */ #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0) */ #ifndef MNTTYPE_ISO9660 # define MNTTYPE_ISO9660 "iso9660" #endif /* not MNTTYPE_ISO9660 */ #ifndef FHSIZE # define FHSIZE 32 #endif /* not FHSIZE */ #ifndef FHSIZE3 # define FHSIZE3 64 #endif /* not FHSIZE3 */ #ifdef HAVE_FS_NFS3 #ifndef MNTTYPE_NFS3 # define MNTTYPE_NFS3 "nfs" #endif /* not MNTTYPE_NFS3 */ #endif /* HAVE_FS_NFS3 */ /* * These two force/lazy unmount flags are sometimes missing from some linux * systems' headers. */ #ifdef HAVE_UMOUNT2 # ifndef MNT_FORCE # define MNT_FORCE 0x1 /* from */ # endif /* not MNT_FORCE */ # ifndef MNT_DETACH # define MNT_DETACH 0x2 /* from kernel */ # endif /* not MNT_DETACH */ #endif /* HAVE_UMOUNT2 */ /* XXX: hack until we have a better way to detect /dev/loop devices */ #ifdef HAVE_LINUX_LOOP_H # define HAVE_LOOP_DEVICE extern char *setup_loop_device(const char *file); extern int delete_loop_device(const char *device); #endif /* HAVE_LINUX_LOOP_H */ /* * MACROS: */ #define dr_drok_u diropres #define ca_attributes attributes #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define fhsize root.size #define la_fhandle from #define la_to to #define na_atime atime #define na_blocks blocks #define na_blocksize blocksize #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_gid gid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_rdev rdev #define na_size size #define na_type type #define na_uid uid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define ra_count count #define ra_fhandle file #define ra_offset offset #define ra_totalcount totalcount #define raok_attributes attributes #define raok_len_u data_len #define raok_u data #define raok_val_u data_val #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_reply_u reply #define rr_status status #define rr_u readres_u #define sa_atime atime #define sa_gid gid #define sa_mode mode #define sa_mtime mtime #define sa_size size #define sa_uid uid #define sag_attributes attributes #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_attributes attributes #define sla_from from #define sla_to to #define wra_beginoffset beginoffset #define wra_fhandle file #define wra_len_u data_len #define wra_offset offset #define wra_totalcount totalcount #define wra_u data #define wra_val_u data_val /* * TYPEDEFS: */ typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropokres nfsdiropokres; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readokres nfsreadokres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattr nfssattr; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* Autofs trick */ typedef int autofs_args_t; /* * We use our own definitions here, because the definitions in the * kernel change the API (though not the ABI) *way* too often. */ #undef nfs_args_t struct nfs2_fh { char data[FHSIZE]; }; struct nfs3_fh { u_short size; u_char data[FHSIZE3]; }; struct nfs_args { int version; /* 1 */ int fd; /* 1 */ struct nfs2_fh old_root; /* 1 */ int flags; /* 1 */ int rsize; /* 1 */ int wsize; /* 1 */ int timeo; /* 1 */ int retrans; /* 1 */ int acregmin; /* 1 */ int acregmax; /* 1 */ int acdirmin; /* 1 */ int acdirmax; /* 1 */ struct sockaddr_in addr; /* 1 */ char hostname[256]; /* 1 */ int namlen; /* 2 */ unsigned int bsize; /* 3 */ struct nfs3_fh root; /* 4 */ int pseudoflavor; /* 5 */ char context[256 + 1];/* 6 */ }; typedef struct nfs_args nfs_args_t; /* HACK: these are not defined on Linux but we still need them * internally. We have to be able to differentiate between having a * timeout value set to zero and not having the option at all. These * flags are masked off before passing the nfs_args structure to * mount2() */ #define MNT2_NFS_OPT_ACREGMIN 0x10000 #define MNT2_NFS_OPT_ACREGMAX 0x20000 #define MNT2_NFS_OPT_ACDIRMIN 0x40000 #define MNT2_NFS_OPT_ACDIRMAX 0x80000 #define MNT2_NFS_OPT_FLAGMASK 0xFFFF /* * Missing definitions on redhat alpha linux */ #ifdef _SELECTBITS_H # ifndef __FD_ZERO /* This line MUST be split! Otherwise m4 will not change it. */ # define __FD_ZERO(set) \ ((void) memset ((__ptr_t) (set), 0, sizeof(fd_set))) # endif /* not __FD_ZERO */ # ifndef __FD_SET # define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) # endif /* not __FD_SET */ # ifndef __FD_CLR # define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d)) # endif /* not __FD_CLR */ # ifndef __FD_ISSET # define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) # endif /* not __FD_ISSET */ #endif /* _SELECTBITS_H */ /* turn off this (b/c of hlfsd) */ #undef HAVE_RPC_AUTH_DES_H extern int linux_version_code(); /* use a private mapper from errno's to NFS errors */ extern int linux_nfs_error(int e); #define nfs_error(e) linux_nfs_error(e) #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_ncr2.h000066400000000000000000000340351157065440000220450ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_ncr2.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H /* * Do NOT include to get NFS V2 specs, because * it will result in conflicts with . The latter is a must * for NFS V3 specs. */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ /* * MACROS */ /* ncr2 does not define this one! Incredible */ #ifndef MNTTYPE_NFS # define MNTTYPE_NFS "nfs" #endif /* MNTTYPE_NFS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #define NFSPROC_NULL ((unsigned long)(0)) #define NFSPROC_GETATTR ((unsigned long)(1)) #define NFSPROC_SETATTR ((unsigned long)(2)) #define NFSPROC_ROOT ((unsigned long)(3)) #define NFSPROC_LOOKUP ((unsigned long)(4)) #define NFSPROC_READLINK ((unsigned long)(5)) #define NFSPROC_READ ((unsigned long)(6)) #define NFSPROC_WRITECACHE ((unsigned long)(7)) #define NFSPROC_WRITE ((unsigned long)(8)) #define NFSPROC_CREATE ((unsigned long)(9)) #define NFSPROC_REMOVE ((unsigned long)(10)) #define NFSPROC_RENAME ((unsigned long)(11)) #define NFSPROC_LINK ((unsigned long)(12)) #define NFSPROC_SYMLINK ((unsigned long)(13)) #define NFSPROC_MKDIR ((unsigned long)(14)) #define NFSPROC_RMDIR ((unsigned long)(15)) #define NFSPROC_READDIR ((unsigned long)(16)) #define NFSPROC_STATFS ((unsigned long)(17)) /* map field names */ #define ml_hostname ml_name #define ml_directory ml_path #define ml_next ml_nxt #define gr_next g_next #define gr_name g_name #define ex_dir ex_name /* * TYPEDEFS: */ typedef char *dirpath; typedef char *filename; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct fattr nfsfattr; typedef struct linkargs nfslinkargs; typedef struct nfs_fh nfs_fh; typedef struct nfstime nfstime; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; typedef char *name; typedef fhandle_t fhandle; typedef struct exports *exports; typedef struct exports exportnode; typedef struct fhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; /* * EXTERNALS: */ extern bool_t xdr_nfsstat(XDR *, nfsstat *); extern bool_t xdr_ftype(XDR *, nfsftype *); extern bool_t xdr_nfs_fh(XDR *, nfs_fh *); extern bool_t xdr_nfstime(XDR *, nfstime *); extern bool_t xdr_fattr(XDR *, nfsfattr *); extern bool_t xdr_sattr(XDR *, nfssattr *); extern bool_t xdr_filename(XDR *, filename *); extern bool_t xdr_nfspath(XDR *, nfspath *); extern bool_t xdr_attrstat(XDR *, nfsattrstat *); extern bool_t xdr_sattrargs(XDR *, nfssattrargs *); extern bool_t xdr_diropargs(XDR *, nfsdiropargs *); extern bool_t xdr_diropokres(XDR *, nfsdiropokres *); extern bool_t xdr_diropres(XDR *, nfsdiropres *); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *); extern bool_t xdr_readargs(XDR *, nfsreadargs *); extern bool_t xdr_readokres(XDR *, nfsreadokres *); extern bool_t xdr_readres(XDR *, nfsreadres *); extern bool_t xdr_writeargs(XDR *, nfswriteargs *); extern bool_t xdr_createargs(XDR *, nfscreateargs *); extern bool_t xdr_renameargs(XDR *, nfsrenameargs *); extern bool_t xdr_linkargs(XDR *, nfslinkargs *); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *); extern bool_t xdr_entry(XDR *, nfsentry *); extern bool_t xdr_dirlist(XDR *, nfsdirlist *); extern bool_t xdr_readdirres(XDR *, nfsreaddirres *); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *); extern bool_t xdr_statfsres(XDR *, nfsstatfsres *); extern nfsattrstat *nfsproc_getattr_2(nfs_fh *, CLIENT *); extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2(nfssattrargs *, CLIENT *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern nfsattrstat *nfsproc_write_2(nfswriteargs *, CLIENT *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2(nfscreateargs *, CLIENT *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2(nfsdiropargs *, CLIENT *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2(nfscreateargs *, CLIENT *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_link_2(nfslinkargs *, CLIENT *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2(nfsdiropargs *, CLIENT *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2(nfsrenameargs *, CLIENT *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2(nfsdiropargs *, CLIENT *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2(nfssymlinkargs *, CLIENT *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2(nfsreaddirargs *, CLIENT *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2(nfs_fh *, CLIENT *); extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); extern nfsreadres *nfsproc_read_2(nfsreadargs *, CLIENT *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2(nfs_fh *, CLIENT *); extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); extern void *nfsproc_null_2(void *, CLIENT *); extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern void *nfsproc_root_2(void *, CLIENT *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern void *nfsproc_writecache_2(void *, CLIENT *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t); /* * ENUMS: */ /* * STRUCTURES: */ /* ncr2 (sysv4) forgets to include this in */ struct rusage { struct timeval ru_utime; /* user time used */ struct timeval ru_stime; /* system time used */ long ru_maxrss; /* XXX: 0 */ long ru_ixrss; /* XXX: 0 */ long ru_idrss; /* XXX: sum of rm_asrss */ long ru_isrss; /* XXX: 0 */ long ru_minflt; /* any page faults not requiring I/O */ long ru_majflt; /* any page faults requiring I/O */ long ru_nswap; /* swaps */ long ru_inblock; /* block input operations */ long ru_oublock; /* block output operations */ long ru_msgsnd; /* messages sent */ long ru_msgrcv; /* messages received */ long ru_nsignals; /* signals received */ long ru_nvcsw; /* voluntary context switches */ long ru_nivcsw; /* involuntary " */ }; /* * ncr2 has ndbm functions, but no * only a partial */ #define PBLKSIZ 1024 #define DBLKSIZ 4096 typedef struct { int dbm_dirf; /* open directory file */ int dbm_pagf; /* open page file */ int dbm_flags; /* flags, see below */ long dbm_maxbno; /* last ``bit'' in dir file */ long dbm_bitno; /* current bit number */ long dbm_hmask; /* hash mask */ long dbm_blkptr; /* current block for dbm_nextkey */ int dbm_keyptr; /* current key for dbm_nextkey */ long dbm_blkno; /* current page to read/write */ long dbm_pagbno; /* current page in pagbuf */ char dbm_pagbuf[PBLKSIZ]; /* page file block buffer */ long dbm_dirbno; /* current block in dirbuf */ char dbm_dirbuf[DBLKSIZ]; /* directory file block buffer */ } DBM; #define _DBM_RDONLY 0x1 /* data base open read-only */ #define _DBM_IOERR 0x2 /* data base I/O error */ #define dbm_rdonly(db) ((db)->dbm_flags & _DBM_RDONLY) #define dbm_error(db) ((db)->dbm_flags & _DBM_IOERR) /* use this one at your own risk! */ #define dbm_clearerr(db) ((db)->dbm_flags &= ~_DBM_IOERR) /* for fstat(2) */ #define dbm_dirfno(db) ((db)->dbm_dirf) #define dbm_pagfno(db) ((db)->dbm_pagf) /* * flags to dbm_store() */ #define DBM_INSERT 0 #define DBM_REPLACE 1 extern DBM *dbm_open(char *, int, int); extern void dbm_close(DBM *); #ifndef DATUM typedef struct { char *dptr; int dsize; } datum; # define DATUM #endif /* not DATUM */ extern datum dbm_fetch(DBM *, datum); extern datum dbm_firstkey(DBM *); extern datum dbm_nextkey(DBM *); extern int dbm_delete(DBM *, datum); extern int dbm_store(DBM *, datum, datum, int); struct nfs_fh { char fh_data[NFS_FHSIZE]; }; struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct sattrargs { nfs_fh sag_fhandle; nfssattr sag_attributes; }; struct diropargs { nfs_fh da_fhandle; /* was dir */ filename da_name; }; struct diropokres { nfs_fh drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct readlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct readargs { nfs_fh ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct readokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct readres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { nfs_fh wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct createargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct renameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct linkargs { nfs_fh la_fhandle; nfsdiropargs la_to; }; struct symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct readdirargs { nfs_fh rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct entry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct dirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct readdirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_netbsd.h000066400000000000000000000121471157065440000224600ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_netbsd.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifndef NFS_NPROCS # define NFS_NPROCS 26 #endif /* not NFS_NPROCS */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ /* NON-NFS STUFF (doesn't really belong here) */ #ifndef DEFINED_YPALL_CALLBACK_FXN_T # define DEFINED_YPALL_CALLBACK_FXN_T /* this is RIGHT for 1.2G and 1.2.1 */ typedef int (*ypall_callback_fxn_t)(u_long, char *, int, char *, int, void *); #if 0 /* this is right for 1.3beta */ typedef int (*ypall_callback_fxn_t)(int, char *, int, char *, int, char *); #endif /* 0 */ #endif /* DEFINED_YPALL_CALLBACK_FXN_T */ /* * MACROS: */ #define dr_drok_u diropres #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_size size #define na_type type #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_status status #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_from from #define wra_fhandle file /* * TYPEDEFS: */ typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* * * NetBSD 1.2 has NFS V3, but it is undefined in the header files. * so I define everything that's needed for NFS V3 here. */ #ifdef NFSMNT_NFSV3 # define MOUNT_NFS3 MOUNT_NFS # define MNTOPT_NFS3 "nfs" #endif /* NFSMNT_NFSV3 */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_netbsd1_3.h000066400000000000000000000116261157065440000227640ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_netbsd1_3.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ /* NON-NFS STUFF (doesn't really belong here) */ #ifndef DEFINED_YPALL_CALLBACK_FXN_T # define DEFINED_YPALL_CALLBACK_FXN_T #if 0 /* this is RIGHT for 1.2G and 1.2.1 */ typedef int (*ypall_callback_fxn_t)(u_long, char *, int, char *, int, void *); #endif /* 0 */ /* this is right for 1.3beta and newer */ typedef int (*ypall_callback_fxn_t)(int, char *, int, char *, int, char *); #endif /* DEFINED_YPALL_CALLBACK_FXN_T */ /* * MACROS: */ #define dr_drok_u diropres #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_size size #define na_type type #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_status status #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_from from #define wra_fhandle file /* * TYPEDEFS: */ typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* * * NetBSD 1.2 has NFS V3, but it is undefined in the header files. * so I define everything that's needed for NFS V3 here. */ #ifdef NFSMNT_NFSV3 # define MOUNT_NFS3 MOUNT_NFS # define MNTOPT_NFS3 "nfs" #endif /* NFSMNT_NFSV3 */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_netbsd1_4.h000066400000000000000000000130621157065440000227610ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_netbsd1_4.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifndef NFS_NPROCS # define NFS_NPROCS 26 #endif /* not NFS_NPROCS */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_NFS_NFSMOUNT_H # include #endif /* HAVE_NFS_NFSMOUNT_H */ #ifdef HAVE_UFS_UFS_UFSMOUNT_H /* netbsd-1.4 does't protect */ # ifndef _UFS_UFS_UFSMOUNT_H # include # define _UFS_UFS_UFSMOUNT_H # endif /* not _UFS_UFS_UFSMOUNT_H */ #endif /* HAVE_UFS_UFS_UFSMOUNT_H */ /* NON-NFS STUFF (doesn't really belong here) */ #ifndef DEFINED_YPALL_CALLBACK_FXN_T # define DEFINED_YPALL_CALLBACK_FXN_T #if 0 /* this is RIGHT for 1.2G and 1.2.1 */ typedef int (*ypall_callback_fxn_t)(u_long, char *, int, char *, int, void *); #endif /* 0 */ /* this is right for 1.3beta and newer */ typedef int (*ypall_callback_fxn_t)(int, char *, int, char *, int, char *); #endif /* DEFINED_YPALL_CALLBACK_FXN_T */ #ifdef HAVE_STATVFS # define statfs statvfs #endif /* HAVE_STATVFS */ /* * MACROS: */ #define dr_drok_u diropres #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_gid gid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_size size #define na_uid uid #define na_type type #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_status status #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_from from #define wra_fhandle file /* * TYPEDEFS: */ typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* * * NetBSD 1.2 has NFS V3, but it is undefined in the header files. * so I define everything that's needed for NFS V3 here. */ #ifdef NFSMNT_NFSV3 # define MOUNT_NFS3 MOUNT_NFS # define MNTOPT_NFS3 "nfs" #endif /* NFSMNT_NFSV3 */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_nextstep.h000066400000000000000000000421161157065440000230520ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_nextstep.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_BSD_RPC_RPC_H # include #endif /* HAVE_BSD_RPC_RPC_H */ #ifdef HAVE_SYS_STAT_H # include #endif /* HAVE_SYS_STAT_H */ /* * odd problems happen during configuration and nextstep's /bin/cc * gets strange errors from /bin/sh. I suspect it may be a conflict * over some memory, a bad /bin/cc, or even kernel bug. * this is what I get, as a result of running cc inside configure: * /bin/cc -o conftest -g -O2 -D_POSIX_SOURCE conftest.c -lrpcsvc * configure:2294: illegal external declaration, found `#' * configure:2388: illegal file name 'AMU_NFS_PROTOCOL_HEADER' * configure:2416: illegal external declaration, found `{' * I have no explanation for it... -Erez * Solution: don't use /bin/cc, but gcc 2.7.2.1 or better! */ #if 0 /* cannot include this file b/c it refers to non-existing headers */ # include #endif /* 0 */ /* * MACROS: */ /* ugly: fix up nextstep's nfs mount type */ #ifdef MOUNT_TYPE_NFS___off_no_longer_needed # undef MOUNT_TYPE_UFS # define MOUNT_TYPE_UFS MOUNT_UFS # undef MOUNT_TYPE_NFS # define MOUNT_TYPE_NFS MOUNT_NFS # undef MOUNT_TYPE_PCFS # define MOUNT_TYPE_PCFS MOUNT_PC # undef MOUNT_TYPE_LOFS # define MOUNT_TYPE_LOFS MOUNT_LO # undef MOUNT_TYPE_SPECFS # define MOUNT_TYPE_SPECFS MOUNT_SPECFS # undef MOUNT_TYPE_CFS # define MOUNT_TYPE_CFS MOUNT_CFS #endif /* MOUNT_TYPE_NFS */ #define dr_drok_u diropres #define ca_attributes attributes #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_blocks blocks #define na_blocksize blocksize #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_gid gid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_rdev rdev #define na_size size #define na_type type #define na_uid uid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define ra_count count #define ra_fhandle file #define ra_offset offset #define ra_totalcount totalcount #define raok_attributes attributes #define raok_len_u data_len #define raok_u data #define raok_val_u data_val #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_reply_u reply #define rr_status status #define rr_u readres_u #define sa_atime atime #define sa_gid gid #define sa_mode mode #define sa_mtime mtime #define sa_size size #define sa_uid uid #define sag_attributes attributes #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_attributes attributes #define sla_from from #define sla_to to #define wra_beginoffset beginoffset #define wra_fhandle file #define wra_len_u data_len #define wra_offset offset #define wra_totalcount totalcount #define wra_u data #define wra_val_u data_val /* map field names */ #define ex_dir ex_name #define gr_name g_name #define gr_next g_next #define ml_directory ml_path #define ml_hostname ml_name #define ml_next ml_nxt /* * NFS mount option flags */ #define NFSMNT_SOFT 0x001 /* soft mount (hard is default) */ #define NFSMNT_WSIZE 0x002 /* set write size */ #define NFSMNT_RSIZE 0x004 /* set read size */ #define NFSMNT_TIMEO 0x008 /* set initial timeout */ #define NFSMNT_RETRANS 0x010 /* set number of request retries */ #define NFSMNT_HOSTNAME 0x020 /* set hostname for error printf */ #define NFSMNT_INT 0x040 /* allow interrupts on hard mount */ #define NFSMNT_NOAC 0x080 /* don't cache attributes */ #define NFSMNT_ACREGMIN 0x0100 /* set min secs for file attr cache */ #define NFSMNT_ACREGMAX 0x0200 /* set max secs for file attr cache */ #define NFSMNT_ACDIRMIN 0x0400 /* set min secs for dir attr cache */ #define NFSMNT_ACDIRMAX 0x0800 /* set max secs for dir attr cache */ #define NFSMNT_SECURE 0x1000 /* secure mount */ #define NFSMNT_NOCTO 0x2000 /* no close-to-open consistency */ #define NFS_PORT 2049 #ifndef NFS_MAXDATA # define NFS_MAXDATA 8192 #endif /* NFS_MAXDATA */ #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #ifndef NFS_PROGRAM # define NFS_PROGRAM ((u_long)100003) #endif /* not NFS_PROGRAM */ #ifndef NFS_VERSION # define NFS_VERSION ((u_long)2) #endif /* not NFS_VERSION */ #define NFSPROC_NULL ((u_long)0) #define NFSPROC_GETATTR ((u_long)1) #define NFSPROC_SETATTR ((u_long)2) #define NFSPROC_ROOT ((u_long)3) #define NFSPROC_LOOKUP ((u_long)4) #define NFSPROC_READLINK ((u_long)5) #define NFSPROC_READ ((u_long)6) #define NFSPROC_WRITECACHE ((u_long)7) #define NFSPROC_WRITE ((u_long)8) #define NFSPROC_CREATE ((u_long)9) #define NFSPROC_REMOVE ((u_long)10) #define NFSPROC_RENAME ((u_long)11) #define NFSPROC_LINK ((u_long)12) #define NFSPROC_SYMLINK ((u_long)13) #define NFSPROC_MKDIR ((u_long)14) #define NFSPROC_RMDIR ((u_long)15) #define NFSPROC_READDIR ((u_long)16) #define NFSPROC_STATFS ((u_long)17) /* * fix up or complete other some definitions... */ #define WNOHANG 01 #define WUNTRACED 02 #define WIFSTOPPED(status) ((status) & 0100) #define WSTOPSIG(status) (int)(WIFSTOPPED(status) ? \ (((status) >> 8) & 0177) : -1) #define WIFSIGNALED(status) ( !WIFEXITED(status) && \ !WIFSTOPPED(status) ) #define WTERMSIG(status) (int)(WIFSIGNALED(status) ? \ ((status) & 0177) : -1) /* define missing macros */ #ifndef S_ISDIR # ifdef S_IFMT # define S_ISDIR(mode) (((mode) & (S_IFMT)) == (S_IFDIR)) # else /* not S_IFMT */ # define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR)) # endif /* not S_IFMT */ #endif /* not S_ISDIR */ /* * ENUMS: */ enum nfstype { NFNON = 0, NFREG = 1, NFDIR = 2, NFBLK = 3, NFCHR = 4, NFLNK = 5, NFSOCK = 6, NFBAD = 7, NFFIFO = 8, }; enum nfsstat { NFS_OK = 0, /* no error */ NFSERR_PERM=EPERM, /* Not owner */ NFSERR_NOENT=ENOENT, /* No such file or directory */ NFSERR_IO=EIO, /* I/O error */ NFSERR_NXIO=ENXIO, /* No such device or address */ NFSERR_ACCES=EACCES, /* Permission denied */ NFSERR_EXIST=EEXIST, /* File exists */ NFSERR_NODEV=ENODEV, /* No such device */ NFSERR_NOTDIR=ENOTDIR, /* Not a directory */ NFSERR_ISDIR=EISDIR, /* Is a directory */ NFSERR_FBIG=EFBIG, /* File too large */ NFSERR_NOSPC=ENOSPC, /* No space left on device */ NFSERR_ROFS=EROFS, /* Read-only file system */ NFSERR_NAMETOOLONG=ENAMETOOLONG,/* File name too long */ NFSERR_NOTEMPTY=ENOTEMPTY, /* Directory not empty */ NFSERR_DQUOT=EDQUOT, /* Disc quota exceeded */ NFSERR_STALE=ESTALE, /* Stale NFS file handle */ NFSERR_WFLUSH /* write cache flushed */ }; /* * TYPEDEFS: */ typedef char *dirpath; typedef char *filename; typedef char *name; typedef char *nfspath; typedef char fhandle[NFS_FHSIZE]; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum ftype ftype; typedef enum nfsstat nfsstat; typedef enum nfstype nfsftype; typedef fhandle fhandle_t; typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct exports *exports; typedef struct exports exportnode; typedef struct fattr nfsfattr; typedef struct fhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct linkargs nfslinkargs; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; typedef struct nfs_fh nfs_fh; typedef struct nfstime nfstime; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern bool_t xdr_attrstat(XDR *, nfsattrstat*); extern bool_t xdr_createargs(XDR *, nfscreateargs*); extern bool_t xdr_dirlist(XDR *, nfsdirlist*); extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); extern bool_t xdr_diropres(XDR *, nfsdiropres*); extern bool_t xdr_entry(XDR *, nfsentry*); extern bool_t xdr_fattr(XDR *, nfsfattr*); extern bool_t xdr_filename(XDR *, filename*); extern bool_t xdr_ftype(XDR *, nfsftype*); extern bool_t xdr_linkargs(XDR *, nfslinkargs*); extern bool_t xdr_mountlist(XDR *xdrs, mountlist *objp); extern bool_t xdr_nfs_fh(XDR *, nfs_fh*); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_nfspath(XDR *, nfspath*); extern bool_t xdr_nfsstat(XDR *, nfsstat*); extern bool_t xdr_nfstime(XDR *, nfstime*); extern bool_t xdr_readargs(XDR *, nfsreadargs*); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); extern bool_t xdr_readokres(XDR *, nfsreadokres*); extern bool_t xdr_readres(XDR *, nfsreadres*); extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); extern bool_t xdr_sattr(XDR *, nfssattr*); extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); extern bool_t xdr_writeargs(XDR *, nfswriteargs*); /* * STRUCTURES: */ struct nfs_args { struct sockaddr_in *addr; /* file server address */ caddr_t fh; /* File handle to be mounted */ int flags; /* flags */ int wsize; /* write size in bytes */ int rsize; /* read size in bytes */ int timeo; /* initial timeout in .1 secs */ int retrans; /* times to retry send */ char *hostname; /* server's hostname */ int acregmin; /* attr cache file min secs */ int acregmax; /* attr cache file max secs */ int acdirmin; /* attr cache dir min secs */ int acdirmax; /* attr cache dir max secs */ char *netname; /* server's netname */ }; struct nfs_fh { char data[NFS_FHSIZE]; }; struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct sattrargs { nfs_fh sag_fhandle; nfssattr sag_attributes; }; struct diropargs { nfs_fh da_fhandle; /* was dir */ filename da_name; }; struct diropokres { nfs_fh drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct readlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct readargs { nfs_fh ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct readokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct readres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { nfs_fh wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct createargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct renameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct linkargs { nfs_fh la_fhandle; nfsdiropargs la_to; }; struct symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct readdirargs { nfs_fh rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct entry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct dirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct readdirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_openbsd.h000066400000000000000000000131121157065440000226240ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_openbsd.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifndef NFS_NPROCS # define NFS_NPROCS 26 #endif /* not NFS_NPROCS */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_UFS_UFS_UFSMOUNT_H # ifdef HAVE_UFS_UFS_EXTATTR_H /* * Need to define _KERNEL to include protected definition of struct * ufs_extattr_per_mount, which is used in struct ufsmount in * , but is NOT protected by _KERNEL there. */ # define _KERNEL # include # undef _KERNEL # endif /* HAVE_UFS_UFS_EXTATTR_H */ # ifndef MAXQUOTAS # define MAXQUOTAS 2 # endif /* not MAXQUOTAS */ /* * XXX: fake struct nextexport: trying to include proper headers here is too * difficult: those headers drag many other headers, etc. */ struct netexport { int this_is_SO_wrong; }; # include #endif /* HAVE_UFS_UFS_UFSMOUNT_H */ /* * MACROS: */ #define dr_drok_u diropres #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_size size #define na_type type #define na_uid uid #define na_gid gid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_status status #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_from from #define wra_fhandle file /* * TYPEDEFS: */ typedef attrstat nfsattrstat; typedef createargs nfscreateargs; typedef dirlist nfsdirlist; typedef diropargs nfsdiropargs; typedef diropres nfsdiropres; typedef entry nfsentry; typedef fattr nfsfattr; typedef ftype nfsftype; typedef linkargs nfslinkargs; typedef readargs nfsreadargs; typedef readdirargs nfsreaddirargs; typedef readdirres nfsreaddirres; typedef readlinkres nfsreadlinkres; typedef readres nfsreadres; typedef renameargs nfsrenameargs; typedef sattrargs nfssattrargs; typedef statfsokres nfsstatfsokres; typedef statfsres nfsstatfsres; typedef symlinkargs nfssymlinkargs; typedef writeargs nfswriteargs; /* * OpenBSD 2.2 has NFS V3, but it is undefined in the header files. * so I define everything that's needed for NFS V3 here. */ #ifdef NFSMNT_NFSV3 /* * turn of this function so it cannot be used! OpenBSD seems to * require that NFS sockets be connected. * See m4/macros/check_nfs_socket_connection.m4. */ # define MOUNT_NFS3 MOUNT_NFS # define MNTOPT_NFS3 "nfs" #endif /* NFSMNT_NFSV3 */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_osf2.h000066400000000000000000000227411157065440000220530ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_osf2.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_SYS_ERRNO_H # include #endif /* HAVE_SYS_ERRNO_H */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ /* avoid conflicts with Irix's EFS */ #undef MOUNT_EFS /* DCE Episode FS */ /* includes a global symbol in every module! */ #define _SYS_FS_TYPES_H_ /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #ifndef NFS_PROGRAM # define NFS_PROGRAM ((u_long)100003) #endif /* not NFS_PROGRAM */ #ifndef NFS_VERSION # define NFS_VERSION ((u_long)2) #endif /* not NFS_VERSION */ #define NFSPROC_NULL ((u_long)0) #define NFSPROC_GETATTR ((u_long)1) #define NFSPROC_SETATTR ((u_long)2) #define NFSPROC_ROOT ((u_long)3) #define NFSPROC_LOOKUP ((u_long)4) #define NFSPROC_READLINK ((u_long)5) #define NFSPROC_READ ((u_long)6) #define NFSPROC_WRITECACHE ((u_long)7) #define NFSPROC_WRITE ((u_long)8) #define NFSPROC_CREATE ((u_long)9) #define NFSPROC_REMOVE ((u_long)10) #define NFSPROC_RENAME ((u_long)11) #define NFSPROC_LINK ((u_long)12) #define NFSPROC_SYMLINK ((u_long)13) #define NFSPROC_MKDIR ((u_long)14) #define NFSPROC_RMDIR ((u_long)15) #define NFSPROC_READDIR ((u_long)16) #define NFSPROC_STATFS ((u_long)17) /* map field names */ #define fh_data fh_bytes #define ml_hostname ml_name #define ml_directory ml_path #define ml_next ml_nxt #define gr_next g_next #define gr_name g_name #define ex_dir ex_name #define drok_attributes drok_attr #define na_fileid na_nodeid #define la_fhandle la_from #define nt_seconds tv_sec #define nt_useconds tv_usec #define ra_totalcount ra_totcount #define sla_to sla_tnm #define sla_attributes sla_sa #define sag_fhandle saa_fh #define sag_attributes saa_sa #define sfrok_tsize fsok_tsize #define sfrok_bsize fsok_bsize #define sfrok_blocks fsok_blocks #define sfrok_bfree fsok_bfree #define sfrok_bavail fsok_bavail #define sfr_status fs_status #define sfr_u fs_u #define sfr_reply_u fs_fsok_u #define wra_fhandle wa_fhandle #define wra_beginoffset wa_begoff #define wra_offset wa_offset #define wra_totalcount wa_totcount #define wra_u wa_mbuf->m_hdr #define wra_val_u mh_data #define wra_len_u mh_len /* * TYPEDEFS: */ typedef char *dirpath; typedef char *filename; typedef char *name; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef struct nfssvcfh fhandle; typedef struct nfsattrstat nfsattrstat; typedef struct nfscreateargs nfscreateargs; typedef struct nfsdirlist nfsdirlist; typedef struct nfsdiropargs nfsdiropargs; typedef struct nfsdrok nfsdiropokres; typedef struct nfsdiropres nfsdiropres; typedef struct nfsentry nfsentry; typedef struct exports *exports; typedef struct exports exportnode; typedef struct nfsfattr nfsfattr; typedef struct fhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct nfslinkargs nfslinkargs; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; typedef struct _nfs_fh _nfs_fh; typedef struct timeval nfstime; typedef struct nfsreadargs nfsreadargs; typedef struct nfsreaddirargs nfsreaddirargs; typedef struct nfsreaddirres nfsreaddirres; typedef struct nfsreadlinkres nfsreadlinkres; typedef struct nfsreadokres nfsreadokres; typedef struct nfsreadres nfsreadres; typedef struct nfsrenameargs nfsrenameargs; typedef struct nfssattr nfssattr; typedef struct nfssaargs nfssattrargs; typedef struct nfsstatfsok nfsstatfsokres; typedef struct nfsstatfs nfsstatfsres; typedef struct nfsslargs nfssymlinkargs; typedef struct nfswriteargs nfswriteargs; /* * EXTERNALS: */ extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern bool_t xdr_nfsstat(XDR *, nfsstat*); extern bool_t xdr_ftype(XDR *, nfsftype*); extern bool_t xdr_nfstime(XDR *, nfstime*); extern bool_t xdr_fattr(XDR *, nfsfattr*); extern bool_t xdr_sattr(XDR *, nfssattr*); extern bool_t xdr_filename(XDR *, filename*); extern bool_t xdr_nfspath(XDR *, nfspath*); extern bool_t xdr_attrstat(XDR *, nfsattrstat*); extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); extern bool_t xdr_diropres(XDR *, nfsdiropres*); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); extern bool_t xdr_readargs(XDR *, nfsreadargs*); extern bool_t xdr_readokres(XDR *, nfsreadokres*); extern bool_t xdr_readres(XDR *, nfsreadres*); extern bool_t xdr_writeargs(XDR *, nfswriteargs*); extern bool_t xdr_createargs(XDR *, nfscreateargs*); extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); extern bool_t xdr_linkargs(XDR *, nfslinkargs*); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); extern bool_t xdr_entry(XDR *, nfsentry*); extern bool_t xdr_dirlist(XDR *, nfsdirlist*); extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); /* * STRUCTURES: */ struct _nfs_fh { char data[NFS_FHSIZE]; }; struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct nfsreadlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct nfsreadokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct nfsreadres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct nfscreateargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct nfsrenameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct nfsreaddirargs { nfsv2fh_t rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct nfsentry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct nfsdirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct nfsreaddirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_osf4.h000066400000000000000000000271441157065440000220570ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_osf4.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNTV3_H # include #endif /* HAVE_RPCSVC_MOUNTV3_H */ #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ /* avoid conflicts with Irix's EFS */ #undef MOUNT_EFS /* DCE Episode FS */ /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #ifndef NFS_PROGRAM # define NFS_PROGRAM ((u_long)100003) #endif /* not NFS_PROGRAM */ #ifndef NFS_VERSION # define NFS_VERSION ((u_long)2) #endif /* not NFS_VERSION */ #define NFSPROC_NULL ((u_long)0) #define NFSPROC_GETATTR ((u_long)1) #define NFSPROC_SETATTR ((u_long)2) #define NFSPROC_ROOT ((u_long)3) #define NFSPROC_LOOKUP ((u_long)4) #define NFSPROC_READLINK ((u_long)5) #define NFSPROC_READ ((u_long)6) #define NFSPROC_WRITECACHE ((u_long)7) #define NFSPROC_WRITE ((u_long)8) #define NFSPROC_CREATE ((u_long)9) #define NFSPROC_REMOVE ((u_long)10) #define NFSPROC_RENAME ((u_long)11) #define NFSPROC_LINK ((u_long)12) #define NFSPROC_SYMLINK ((u_long)13) #define NFSPROC_MKDIR ((u_long)14) #define NFSPROC_RMDIR ((u_long)15) #define NFSPROC_READDIR ((u_long)16) #define NFSPROC_STATFS ((u_long)17) /* map field names */ #define ml_hostname ml_name #define ml_directory ml_path #define ml_next ml_nxt #define gr_next g_next #define gr_name g_name #define ex_dir ex_name #define drok_attributes drok_attr #define na_fileid na_nodeid #define la_fhandle la_from #define nt_seconds tv_sec #define nt_useconds tv_usec #define ra_totalcount ra_totcount #define sla_to sla_tnm #define sla_attributes sla_sa #define sag_fhandle saa_fh #define sag_attributes saa_sa #define sfrok_tsize fsok_tsize #define sfrok_bsize fsok_bsize #define sfrok_blocks fsok_blocks #define sfrok_bfree fsok_bfree #define sfrok_bavail fsok_bavail #define sfr_status fs_status #define sfr_u fs_u #define sfr_reply_u fs_fsok_u #define wra_fhandle wa_fhandle #define wra_beginoffset wa_begoff #define wra_offset wa_offset #define wra_totalcount wa_totcount #define wra_u wa_mbuf->m_hdr #define wra_val_u mh_data #define wra_len_u mh_len /* * TYPEDEFS: */ typedef char *dirpath; typedef char *filename; typedef char *name; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef struct nfssvcfh fhandle; typedef struct nfsattrstat nfsattrstat; typedef struct nfscreateargs nfscreateargs; typedef struct nfsdirlist nfsdirlist; typedef struct nfsdiropargs nfsdiropargs; typedef struct nfsdrok nfsdiropokres; typedef struct nfsdiropres nfsdiropres; typedef struct nfsentry nfsentry; typedef struct exports *exports; typedef struct exports exportnode; typedef struct nfsfattr nfsfattr; typedef struct fhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct nfslinkargs nfslinkargs; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; typedef struct _nfs_fh _nfs_fh; typedef struct timeval nfstime; typedef struct nfsreadargs nfsreadargs; typedef struct nfsreaddirargs nfsreaddirargs; typedef struct nfsreaddirres nfsreaddirres; typedef struct nfsreadlinkres nfsreadlinkres; typedef struct nfsreadokres nfsreadokres; typedef struct nfsreadres nfsreadres; typedef struct nfsrenameargs nfsrenameargs; typedef struct nfssattr nfssattr; typedef struct nfssaargs nfssattrargs; typedef struct nfsstatfsok nfsstatfsokres; typedef struct nfsstatfs nfsstatfsres; typedef struct nfsslargs nfssymlinkargs; typedef struct nfswriteargs nfswriteargs; /* * EXTERNALS: (some are missing from system headers) */ extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_getattr_2_svc(struct nfssvcfh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2_svc(struct nfssvcfh *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(struct nfssvcfh *, struct svc_req *); extern int plock(int op); extern const char *hstrerror(int err); extern int getmntinfo(struct statfs **mntbufp, int flags); extern bool_t xdr_nfsstat(XDR *, nfsstat*); extern bool_t xdr_ftype(XDR *, nfsftype*); extern bool_t xdr_nfs_fh(XDR *, struct nfssvcfh*); extern bool_t xdr_nfstime(XDR *, nfstime*); extern bool_t xdr_fattr(XDR *, nfsfattr*); extern bool_t xdr_sattr(XDR *, nfssattr*); extern bool_t xdr_filename(XDR *, filename*); extern bool_t xdr_nfspath(XDR *, nfspath*); extern bool_t xdr_attrstat(XDR *, nfsattrstat*); extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); extern bool_t xdr_diropres(XDR *, nfsdiropres*); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); extern bool_t xdr_readargs(XDR *, nfsreadargs*); extern bool_t xdr_readokres(XDR *, nfsreadokres*); extern bool_t xdr_readres(XDR *, nfsreadres*); extern bool_t xdr_writeargs(XDR *, nfswriteargs*); extern bool_t xdr_createargs(XDR *, nfscreateargs*); extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); extern bool_t xdr_linkargs(XDR *, nfslinkargs*); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); extern bool_t xdr_entry(XDR *, nfsentry*); extern bool_t xdr_dirlist(XDR *, nfsdirlist*); extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); extern bool_t xdr_exportnode (XDR *, exportnode*); extern bool_t xdr_groups (XDR *, groups*); /* * STRUCTURES: */ struct _nfs_fh { char data[NFS_FHSIZE]; }; struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct _fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct _sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct _attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct _sattrargs { struct nfssvcfh sag_fhandle; nfssattr sag_attributes; }; struct _diropargs { struct nfssvcfh da_fhandle; /* was dir */ filename da_name; }; struct _diropokres { struct nfssvcfh drok_fhandle; nfsfattr drok_attributes; }; struct _diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct nfsreadlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct _readargs { struct nfssvcfh ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct nfsreadokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct nfsreadres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; #if 0 struct _writeargs { struct nfssvcfh wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; #endif /* 0 */ struct nfscreateargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct nfsrenameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct _linkargs { struct nfssvcfh la_fhandle; nfsdiropargs la_to; }; struct _symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct nfsreaddirargs { struct nfssvcfh rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct nfsentry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct nfsdirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct nfsreaddirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct _statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct _statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_osf5.h000066400000000000000000000307711157065440000220600ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_osf5.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNTV3_H # include #endif /* HAVE_RPCSVC_MOUNTV3_H */ #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ /* avoid conflicts with Irix's EFS */ #undef MOUNT_EFS /* DCE Episode FS */ /* * The NFSMNT_AUTO flag in Tru64 UNIX V5 has two effects: it causes df and * mount not to display this mount point without the -e switch, as it did in * previous releases. Unfortunately it also ignores the timeo mount option, * disables the usual timeout backof and enforces a timeout of NFS_MAXTIMO * (20 seconds) instead. This breaks amd which can sometimes take longer to * respond to an NFS request, causing `nfs server not responding still trying' * messages. * * To avoid this, we need to completely disable this flag on automount points, * with the unfortunate side effect that they are no longer hidden in df and * mount output. */ #undef MNT2_NFS_OPT_AUTO /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #ifndef NFS_PROGRAM # define NFS_PROGRAM ((u_long)100003) #endif /* not NFS_PROGRAM */ #ifndef NFS_VERSION # define NFS_VERSION ((u_long)2) #endif /* not NFS_VERSION */ #define NFSPROC_NULL ((u_long)0) #define NFSPROC_GETATTR ((u_long)1) #define NFSPROC_SETATTR ((u_long)2) #define NFSPROC_ROOT ((u_long)3) #define NFSPROC_LOOKUP ((u_long)4) #define NFSPROC_READLINK ((u_long)5) #define NFSPROC_READ ((u_long)6) #define NFSPROC_WRITECACHE ((u_long)7) #define NFSPROC_WRITE ((u_long)8) #define NFSPROC_CREATE ((u_long)9) #define NFSPROC_REMOVE ((u_long)10) #define NFSPROC_RENAME ((u_long)11) #define NFSPROC_LINK ((u_long)12) #define NFSPROC_SYMLINK ((u_long)13) #define NFSPROC_MKDIR ((u_long)14) #define NFSPROC_RMDIR ((u_long)15) #define NFSPROC_READDIR ((u_long)16) #define NFSPROC_STATFS ((u_long)17) /* map field names */ #define ml_hostname ml_name #define ml_directory ml_path #define ml_next ml_nxt #define gr_next g_next #define gr_name g_name #define ex_dir ex_name #define drok_attributes drok_attr #define na_fileid na_nodeid #define la_fhandle la_from #define nt_seconds tv_sec #define nt_useconds tv_usec #define ra_totalcount ra_totcount #define sla_to sla_tnm #define sla_attributes sla_sa #define sag_fhandle saa_fh #define sag_attributes saa_sa #define sfrok_tsize fsok_tsize #define sfrok_bsize fsok_bsize #define sfrok_blocks fsok_blocks #define sfrok_bfree fsok_bfree #define sfrok_bavail fsok_bavail #define sfr_status fs_status #define sfr_u fs_u #define sfr_reply_u fs_fsok_u #define wra_fhandle wa_fhandle #define wra_beginoffset wa_begoff #define wra_offset wa_offset #define wra_totalcount wa_totcount #define wra_u wa_mbuf->m_hdr #define wra_val_u mh_data #define wra_len_u mh_len /* * TYPEDEFS: */ typedef char *dirpath; typedef char *filename; typedef char *name; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef struct nfssvcfh fhandle; typedef struct nfsattrstat nfsattrstat; typedef struct nfscreateargs nfscreateargs; typedef struct nfsdirlist nfsdirlist; typedef struct nfsdiropargs nfsdiropargs; typedef struct nfsdrok nfsdiropokres; typedef struct nfsdiropres nfsdiropres; typedef struct nfsentry nfsentry; typedef struct exports *exports; typedef struct exports exportnode; typedef struct nfsfattr nfsfattr; typedef struct fhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct nfslinkargs nfslinkargs; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; typedef struct _nfs_fh _nfs_fh; typedef struct timeval nfstime; typedef struct nfsreadargs nfsreadargs; typedef struct nfsreaddirargs nfsreaddirargs; typedef struct nfsreaddirres nfsreaddirres; typedef struct nfsreadlinkres nfsreadlinkres; typedef struct nfsreadokres nfsreadokres; typedef struct nfsreadres nfsreadres; typedef struct nfsrenameargs nfsrenameargs; typedef struct nfssattr nfssattr; typedef struct nfssaargs nfssattrargs; typedef struct nfsstatfsok nfsstatfsokres; typedef struct nfsstatfs nfsstatfsres; typedef struct nfsslargs nfssymlinkargs; typedef struct nfswriteargs nfswriteargs; /* * EXTERNALS: */ extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_getattr_2_svc(struct nfssvcfh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2_svc(struct nfssvcfh *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(struct nfssvcfh *, struct svc_req *); extern bool_t xdr_nfsstat(XDR *, nfsstat*); extern bool_t xdr_ftype(XDR *, nfsftype*); extern bool_t xdr_nfs_fh(XDR *, struct nfssvcfh*); extern bool_t xdr_nfstime(XDR *, nfstime*); extern bool_t xdr_fattr(XDR *, nfsfattr*); extern bool_t xdr_sattr(XDR *, nfssattr*); extern bool_t xdr_filename(XDR *, filename*); extern bool_t xdr_nfspath(XDR *, nfspath*); extern bool_t xdr_attrstat(XDR *, nfsattrstat*); extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); extern bool_t xdr_diropres(XDR *, nfsdiropres*); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); extern bool_t xdr_readargs(XDR *, nfsreadargs*); extern bool_t xdr_readokres(XDR *, nfsreadokres*); extern bool_t xdr_readres(XDR *, nfsreadres*); extern bool_t xdr_writeargs(XDR *, nfswriteargs*); extern bool_t xdr_createargs(XDR *, nfscreateargs*); extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); extern bool_t xdr_linkargs(XDR *, nfslinkargs*); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); extern bool_t xdr_entry(XDR *, nfsentry*); extern bool_t xdr_dirlist(XDR *, nfsdirlist*); extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); /* * STRUCTURES: */ struct _nfs_fh { char data[NFS_FHSIZE]; }; struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct _fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct _sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct _attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct _sattrargs { struct nfssvcfh sag_fhandle; nfssattr sag_attributes; }; struct _diropargs { struct nfssvcfh da_fhandle; /* was dir */ filename da_name; }; struct _diropokres { struct nfssvcfh drok_fhandle; nfsfattr drok_attributes; }; struct _diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct nfsreadlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct _readargs { struct nfssvcfh ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct nfsreadokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct nfsreadres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; #if 0 struct _writeargs { struct nfssvcfh wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; #endif /* 0 */ struct nfscreateargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct nfsrenameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct _linkargs { struct nfssvcfh la_fhandle; nfsdiropargs la_to; }; struct _symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct nfsreaddirargs { struct nfssvcfh rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct nfsentry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct nfsdirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct nfsreaddirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct _statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct _statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; /* ************************************************************************** * Tru64 5.1's autofs is not ported or tested yet... * For now, undefine it or define dummy entries. ************************************************************************** */ #ifdef MNTTYPE_AUTOFS # undef MNTTYPE_AUTOFS #endif /* MNTTYPE_AUTOFS */ #ifdef MNTTAB_TYPE_AUTOFS # undef MNTTAB_TYPE_AUTOFS #endif /* MNTTAB_TYPE_AUTOFS */ #ifdef HAVE_FS_AUTOFS # undef HAVE_FS_AUTOFS #endif /* HAVE_FS_AUTOFS */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_sunos3.h000066400000000000000000000257661157065440000224460ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_sunos3.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_SYS_ERRNO_H #include #endif /* HAVE_SYS_ERRNO_H */ #ifdef HAVE_RPC_RPC_H #include #endif /* HAVE_RPC_RPC_H */ #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ # ifdef HAVE_NFS_NFS_CLNT_H # include # endif /* HAVE_NFS_NFS_CLNT_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #ifndef NFS_PROGRAM # define NFS_PROGRAM ((u_long)100003) #endif /* not NFS_PROGRAM */ #ifndef NFS_VERSION # define NFS_VERSION ((u_long)2) #endif /* not NFS_VERSION */ /* complete missing definition that is actually used in SunOS 3.x */ #ifndef MNTOPT_DEV # define MNTOPT_DEV "dev" #endif /* not MNTOPT_DEV */ #define NFSPROC_NULL ((u_long)0) #define NFSPROC_GETATTR ((u_long)1) #define NFSPROC_SETATTR ((u_long)2) #define NFSPROC_ROOT ((u_long)3) #define NFSPROC_LOOKUP ((u_long)4) #define NFSPROC_READLINK ((u_long)5) #define NFSPROC_READ ((u_long)6) #define NFSPROC_WRITECACHE ((u_long)7) #define NFSPROC_WRITE ((u_long)8) #define NFSPROC_CREATE ((u_long)9) #define NFSPROC_REMOVE ((u_long)10) #define NFSPROC_RENAME ((u_long)11) #define NFSPROC_LINK ((u_long)12) #define NFSPROC_SYMLINK ((u_long)13) #define NFSPROC_MKDIR ((u_long)14) #define NFSPROC_RMDIR ((u_long)15) #define NFSPROC_READDIR ((u_long)16) #define NFSPROC_STATFS ((u_long)17) /* map field names */ #define ml_hostname ml_name #define ml_directory ml_path #define ml_next ml_nxt #define gr_next g_next #define gr_name g_name #define ex_dir ex_name #define na_fileid na_nodeid #define la_fhandle la_from #define ra_totalcount ra_totcount /* * TYPEDEFS: */ typedef char *dirpath; typedef char *filename; typedef char *name; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef char fhandle[NFS_FHSIZE]; typedef struct attrstat nfsattrstat; typedef struct nfscreateargs nfscreateargs; typedef struct nfsdirlist nfsdirlist; typedef struct nfsdiropargs nfsdiropargs; typedef struct nfsdiropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct nfsentry nfsentry; typedef struct exports *exports; typedef struct exports exportnode; typedef struct fattr nfsfattr; typedef struct nfsfhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct nfslinkargs nfslinkargs; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; typedef struct nfstime nfstime; typedef struct nfsreadargs nfsreadargs; typedef struct nfsreaddirargs nfsreaddirargs; typedef struct nfsreaddirres nfsreaddirres; typedef struct nfsreadlinkres nfsreadlinkres; typedef struct nfsreadokres nfsreadokres; typedef struct nfsreadres nfsreadres; typedef struct nfsrenameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct nfssattrargs nfssattrargs; typedef struct nfsstatfsokres nfsstatfsokres; typedef struct nfsstatfsres nfsstatfsres; typedef struct nfssymlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_getattr_2_svc(fhandle_t *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2_svc(fhandle_t *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(fhandle_t *, struct svc_req *); extern bool_t xdr_nfsstat(XDR *, nfsstat*); extern bool_t xdr_ftype(XDR *, nfsftype*); extern bool_t xdr_nfs_fh(XDR *, fhandle_t*); extern bool_t xdr_nfstime(XDR *, nfstime*); extern bool_t xdr_fattr(XDR *, nfsfattr*); extern bool_t xdr_sattr(XDR *, nfssattr*); extern bool_t xdr_filename(XDR *, filename*); extern bool_t xdr_nfspath(XDR *, nfspath*); extern bool_t xdr_attrstat(XDR *, nfsattrstat*); extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); extern bool_t xdr_diropres(XDR *, nfsdiropres*); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); extern bool_t xdr_readargs(XDR *, nfsreadargs*); extern bool_t xdr_readokres(XDR *, nfsreadokres*); extern bool_t xdr_readres(XDR *, nfsreadres*); extern bool_t xdr_writeargs(XDR *, nfswriteargs*); extern bool_t xdr_createargs(XDR *, nfscreateargs*); extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); extern bool_t xdr_linkargs(XDR *, nfslinkargs*); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); extern bool_t xdr_entry(XDR *, nfsentry*); extern bool_t xdr_dirlist(XDR *, nfsdirlist*); extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); /* * STRUCTURES: */ struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct nfssattrargs { fhandle_t sag_fhandle; nfssattr sag_attributes; }; struct _nfsdiropargs { fhandle_t da_fhandle; /* was dir */ filename da_name; }; struct nfsdiropokres { fhandle_t drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct nfsreadlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct _nfsreadargs { fhandle_t ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct nfsreadokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct nfsreadres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { fhandle_t wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct nfscreateargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct nfsrenameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct _nfslinkargs { fhandle_t la_fhandle; nfsdiropargs la_to; }; struct nfssymlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct nfsreaddirargs { fhandle_t rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct nfsentry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct nfsdirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct nfsreaddirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct nfsstatfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct nfsstatfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; struct nfsfhstatus { int fhs_status; fhandle fhs_fh; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_sunos4.h000066400000000000000000000257661157065440000224470ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_sunos4.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_SYS_ERRNO_H #include #endif /* HAVE_SYS_ERRNO_H */ #ifdef HAVE_RPC_RPC_H #include #endif /* HAVE_RPC_RPC_H */ #ifdef HAVE_NFS_NFSV2_H # include #endif /* HAVE_NFS_NFSV2_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ # ifdef HAVE_NFS_NFS_CLNT_H # include # endif /* HAVE_NFS_NFS_CLNT_H */ #ifdef HAVE_SYS_FS_NFS_H # include #endif /* HAVE_SYS_FS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #ifndef NFS_PROGRAM # define NFS_PROGRAM ((u_long)100003) #endif /* not NFS_PROGRAM */ #ifndef NFS_VERSION # define NFS_VERSION ((u_long)2) #endif /* not NFS_VERSION */ /* complete missing definition that is actually used in SunOS 4.x */ #ifndef MNTOPT_DEV # define MNTOPT_DEV "dev" #endif /* not MNTOPT_DEV */ #define NFSPROC_NULL ((u_long)0) #define NFSPROC_GETATTR ((u_long)1) #define NFSPROC_SETATTR ((u_long)2) #define NFSPROC_ROOT ((u_long)3) #define NFSPROC_LOOKUP ((u_long)4) #define NFSPROC_READLINK ((u_long)5) #define NFSPROC_READ ((u_long)6) #define NFSPROC_WRITECACHE ((u_long)7) #define NFSPROC_WRITE ((u_long)8) #define NFSPROC_CREATE ((u_long)9) #define NFSPROC_REMOVE ((u_long)10) #define NFSPROC_RENAME ((u_long)11) #define NFSPROC_LINK ((u_long)12) #define NFSPROC_SYMLINK ((u_long)13) #define NFSPROC_MKDIR ((u_long)14) #define NFSPROC_RMDIR ((u_long)15) #define NFSPROC_READDIR ((u_long)16) #define NFSPROC_STATFS ((u_long)17) /* map field names */ #define ml_hostname ml_name #define ml_directory ml_path #define ml_next ml_nxt #define gr_next g_next #define gr_name g_name #define ex_dir ex_name #define na_fileid na_nodeid #define la_fhandle la_from #define ra_totalcount ra_totcount /* * TYPEDEFS: */ typedef char *dirpath; typedef char *filename; typedef char *name; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef char fhandle[NFS_FHSIZE]; typedef struct attrstat nfsattrstat; typedef struct nfscreateargs nfscreateargs; typedef struct nfsdirlist nfsdirlist; typedef struct nfsdiropargs nfsdiropargs; typedef struct nfsdiropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct nfsentry nfsentry; typedef struct exports *exports; typedef struct exports exportnode; typedef struct fattr nfsfattr; typedef struct nfsfhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct nfslinkargs nfslinkargs; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; typedef struct nfstime nfstime; typedef struct nfsreadargs nfsreadargs; typedef struct nfsreaddirargs nfsreaddirargs; typedef struct nfsreaddirres nfsreaddirres; typedef struct nfsreadlinkres nfsreadlinkres; typedef struct nfsreadokres nfsreadokres; typedef struct nfsreadres nfsreadres; typedef struct nfsrenameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct nfssattrargs nfssattrargs; typedef struct nfsstatfsokres nfsstatfsokres; typedef struct nfsstatfsres nfsstatfsres; typedef struct nfssymlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_getattr_2_svc(fhandle_t *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2_svc(fhandle_t *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(fhandle_t *, struct svc_req *); extern bool_t xdr_nfsstat(XDR *, nfsstat*); extern bool_t xdr_ftype(XDR *, nfsftype*); extern bool_t xdr_nfs_fh(XDR *, fhandle_t*); extern bool_t xdr_nfstime(XDR *, nfstime*); extern bool_t xdr_fattr(XDR *, nfsfattr*); extern bool_t xdr_sattr(XDR *, nfssattr*); extern bool_t xdr_filename(XDR *, filename*); extern bool_t xdr_nfspath(XDR *, nfspath*); extern bool_t xdr_attrstat(XDR *, nfsattrstat*); extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); extern bool_t xdr_diropres(XDR *, nfsdiropres*); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); extern bool_t xdr_readargs(XDR *, nfsreadargs*); extern bool_t xdr_readokres(XDR *, nfsreadokres*); extern bool_t xdr_readres(XDR *, nfsreadres*); extern bool_t xdr_writeargs(XDR *, nfswriteargs*); extern bool_t xdr_createargs(XDR *, nfscreateargs*); extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); extern bool_t xdr_linkargs(XDR *, nfslinkargs*); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); extern bool_t xdr_entry(XDR *, nfsentry*); extern bool_t xdr_dirlist(XDR *, nfsdirlist*); extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); /* * STRUCTURES: */ struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct nfssattrargs { fhandle_t sag_fhandle; nfssattr sag_attributes; }; struct _nfsdiropargs { fhandle_t da_fhandle; /* was dir */ filename da_name; }; struct nfsdiropokres { fhandle_t drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct nfsreadlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct _nfsreadargs { fhandle_t ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct nfsreadokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct nfsreadres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { fhandle_t wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct nfscreateargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct nfsrenameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct _nfslinkargs { fhandle_t la_fhandle; nfsdiropargs la_to; }; struct nfssymlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct nfsreaddirargs { fhandle_t rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct nfsentry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct nfsdirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct nfsreaddirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct nfsstatfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct nfsstatfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; struct nfsfhstatus { int fhs_status; fhandle fhs_fh; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_sunos5_3.h000066400000000000000000000175031157065440000226600ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_sunos5_3.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H /* * Do not include because Solaris 2.3 really does not have NFS * V.3 support, despite what their header files claim. */ #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #ifndef fhandle_t # define fhandle_t nfs_fh #endif /* not fhandle_t */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ #ifdef HAVE_RPC_RPC_H #include #endif /* HAVE_RPC_RPC_H */ /* missing mntent definition for cachefs */ #ifndef MNTTYPE_CACHEFS # define MNTTYPE_CACHEFS "cachefs" /* Cache File System */ #endif /* not MNTTYPE_CACHEFS */ /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define FHSIZE 32 #define NFS_COOKIESIZE 4 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #define dr_drok_u diropres #define ca_attributes attributes #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_blocks blocks #define na_blocksize blocksize #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_gid gid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_rdev rdev #define na_size size #define na_type type #define na_uid uid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define ra_count count #define ra_fhandle file #define ra_offset offset #define ra_totalcount totalcount #define raok_attributes attributes #define raok_len_u data_len #define raok_u data #define raok_val_u data_val #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_reply_u reply #define rr_status status #define rr_u readres_u #define sa_atime atime #define sa_gid gid #define sa_mode mode #define sa_mtime mtime #define sa_size size #define sa_uid uid #define sag_attributes attributes #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_attributes attributes #define sla_from from #define sla_to to #define wra_beginoffset beginoffset #define wra_fhandle file #define wra_len_u data_len #define wra_offset offset #define wra_totalcount totalcount #define wra_u data #define wra_val_u data_val /* map field names */ #define ex_dir ex_name #define gr_name g_name #define gr_next g_next #define ml_directory ml_path #define ml_hostname ml_name #define ml_next ml_nxt /* * TYPEDEFS: */ typedef char *dirpath; typedef char *name; typedef char fhandle[FHSIZE]; typedef enum ftype nfsftype; typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct exports *exports; typedef struct exports exportnode; typedef struct fattr nfsfattr; typedef struct nfsfhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct linkargs nfslinkargs; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern bool_t xdr_createargs(XDR *, nfscreateargs *); extern bool_t xdr_dirlist(XDR *, nfsdirlist *); extern bool_t xdr_diropokres(XDR *, nfsdiropokres *); extern bool_t xdr_entry(XDR *, nfsentry *); extern bool_t xdr_filename(XDR *, filename *); extern bool_t xdr_ftype(XDR *, nfsftype *); extern bool_t xdr_nfs_fh(XDR *, nfs_fh *); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_nfspath(XDR *, nfspath *); extern bool_t xdr_nfsstat(XDR *, nfsstat *); extern bool_t xdr_nfstime(XDR *, nfstime *); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *); extern bool_t xdr_readdirres(XDR *, nfsreaddirres *); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *); extern bool_t xdr_readokres(XDR *, nfsreadokres *); extern bool_t xdr_readres(XDR *, nfsreadres *); extern bool_t xdr_renameargs(XDR *, nfsrenameargs *); extern bool_t xdr_sattrargs(XDR *, nfssattrargs *); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *); extern bool_t xdr_statfsres(XDR *, nfsstatfsres *); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *); /* * ENUMS: */ /* * STRUCTURES: */ struct nfsfhstatus { int fhs_status; fhandle fhs_fh; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_sunos5_4.h000066400000000000000000000176531157065440000226670ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_sunos5_4.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H /* * Do not include because Solaris 2.4 really does not have NFS * V.3 support, despite what their header files claim. */ #ifdef HAVE_RPCSVC_NFS_PROT_H # include #endif /* HAVE_RPCSVC_NFS_PROT_H */ #define FHSIZE 32 typedef char fhandle[FHSIZE]; #define fhandle_t fhandle #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ #ifdef HAVE_RPC_RPC_H #include #endif /* HAVE_RPC_RPC_H */ /* missing mntent definition for cachefs */ #ifndef MNTTYPE_CACHEFS # define MNTTYPE_CACHEFS "cachefs" /* Cache File System */ #endif /* not MNTTYPE_CACHEFS */ /* * Solaris 2.4 has header definitions for NFS V.3, but does not really * have NFS V.3 support in the kernel. So I must undefine these. */ #ifdef MNTTYPE_NFS3 # undef MNTTYPE_NFS3 #endif /* MNTTYPE_NFS3 */ /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #define dr_drok_u diropres #define ca_attributes attributes #define ca_where where #define da_fhandle dir #define da_name name #define dl_entries entries #define dl_eof eof #define dr_status status #define dr_u diropres_u #define drok_attributes attributes #define drok_fhandle file #define fh_data data #define la_fhandle from #define la_to to #define na_atime atime #define na_blocks blocks #define na_blocksize blocksize #define na_ctime ctime #define na_fileid fileid #define na_fsid fsid #define na_gid gid #define na_mode mode #define na_mtime mtime #define na_nlink nlink #define na_rdev rdev #define na_size size #define na_type type #define na_uid uid #define ne_cookie cookie #define ne_fileid fileid #define ne_name name #define ne_nextentry nextentry #define ns_attr_u attributes #define ns_status status #define ns_u attrstat_u #define nt_seconds seconds #define nt_useconds useconds #define ra_count count #define ra_fhandle file #define ra_offset offset #define ra_totalcount totalcount #define raok_attributes attributes #define raok_len_u data_len #define raok_u data #define raok_val_u data_val #define rda_cookie cookie #define rda_count count #define rda_fhandle dir #define rdr_reply_u reply #define rdr_status status #define rdr_u readdirres_u #define rlr_data_u data #define rlr_status status #define rlr_u readlinkres_u #define rna_from from #define rna_to to #define rr_reply_u reply #define rr_status status #define rr_u readres_u #define sa_atime atime #define sa_gid gid #define sa_mode mode #define sa_mtime mtime #define sa_size size #define sa_uid uid #define sag_attributes attributes #define sag_fhandle file #define sfr_reply_u reply #define sfr_status status #define sfr_u statfsres_u #define sfrok_bavail bavail #define sfrok_bfree bfree #define sfrok_blocks blocks #define sfrok_bsize bsize #define sfrok_tsize tsize #define sla_attributes attributes #define sla_from from #define sla_to to #define wra_beginoffset beginoffset #define wra_fhandle file #define wra_len_u data_len #define wra_offset offset #define wra_totalcount totalcount #define wra_u data #define wra_val_u data_val /* map field names */ #define ex_dir ex_name #define gr_name g_name #define gr_next g_next #define ml_directory ml_path #define ml_hostname ml_name #define ml_next ml_nxt /* * TYPEDEFS: */ typedef char *dirpath; typedef char *name; typedef enum ftype nfsftype; typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct exports *exports; typedef struct exports exportnode; typedef struct fattr nfsfattr; typedef struct fhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct linkargs nfslinkargs; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern bool_t xdr_createargs(XDR *, nfscreateargs *); extern bool_t xdr_dirlist(XDR *, nfsdirlist *); extern bool_t xdr_diropokres(XDR *, nfsdiropokres *); extern bool_t xdr_entry(XDR *, nfsentry *); extern bool_t xdr_filename(XDR *, filename *); extern bool_t xdr_ftype(XDR *, nfsftype *); extern bool_t xdr_nfs_fh(XDR *, nfs_fh *); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_nfspath(XDR *, nfspath *); extern bool_t xdr_nfsstat(XDR *, nfsstat *); extern bool_t xdr_nfstime(XDR *, nfstime *); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *); extern bool_t xdr_readdirres(XDR *, nfsreaddirres *); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *); extern bool_t xdr_readokres(XDR *, nfsreadokres *); extern bool_t xdr_readres(XDR *, nfsreadres *); extern bool_t xdr_renameargs(XDR *, nfsrenameargs *); extern bool_t xdr_sattrargs(XDR *, nfssattrargs *); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *); extern bool_t xdr_statfsres(XDR *, nfsstatfsres *); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *); /* * ENUMS: */ /* * STRUCTURES: */ #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_sunos5_5.h000066400000000000000000000260161157065440000226610ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_sunos5_5.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H /* * Do NOT include to get NFS V2 specs, because * it will result in conflicts with . The latter is a must * for NFS V3 specs. */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #define NFSPROC_NULL ((unsigned long)(0)) #define NFSPROC_GETATTR ((unsigned long)(1)) #define NFSPROC_SETATTR ((unsigned long)(2)) #define NFSPROC_ROOT ((unsigned long)(3)) #define NFSPROC_LOOKUP ((unsigned long)(4)) #define NFSPROC_READLINK ((unsigned long)(5)) #define NFSPROC_READ ((unsigned long)(6)) #define NFSPROC_WRITECACHE ((unsigned long)(7)) #define NFSPROC_WRITE ((unsigned long)(8)) #define NFSPROC_CREATE ((unsigned long)(9)) #define NFSPROC_REMOVE ((unsigned long)(10)) #define NFSPROC_RENAME ((unsigned long)(11)) #define NFSPROC_LINK ((unsigned long)(12)) #define NFSPROC_SYMLINK ((unsigned long)(13)) #define NFSPROC_MKDIR ((unsigned long)(14)) #define NFSPROC_RMDIR ((unsigned long)(15)) #define NFSPROC_READDIR ((unsigned long)(16)) #define NFSPROC_STATFS ((unsigned long)(17)) #define AUTOFS_CONFTYPE "ticlts" /* * TYPEDEFS: */ typedef char *filename; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct fattr nfsfattr; typedef struct linkargs nfslinkargs; typedef struct nfs_fh nfs_fh; typedef struct nfstime nfstime; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern bool_t xdr_nfsstat(XDR *, nfsstat *); extern bool_t xdr_ftype(XDR *, nfsftype *); extern bool_t xdr_nfs_fh(XDR *, nfs_fh *); extern bool_t xdr_nfstime(XDR *, nfstime *); extern bool_t xdr_fattr(XDR *, nfsfattr *); extern bool_t xdr_sattr(XDR *, nfssattr *); extern bool_t xdr_filename(XDR *, filename *); extern bool_t xdr_nfspath(XDR *, nfspath *); extern bool_t xdr_attrstat(XDR *, nfsattrstat *); extern bool_t xdr_sattrargs(XDR *, nfssattrargs *); extern bool_t xdr_diropargs(XDR *, nfsdiropargs *); extern bool_t xdr_diropokres(XDR *, nfsdiropokres *); extern bool_t xdr_diropres(XDR *, nfsdiropres *); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *); extern bool_t xdr_readargs(XDR *, nfsreadargs *); extern bool_t xdr_readokres(XDR *, nfsreadokres *); extern bool_t xdr_readres(XDR *, nfsreadres *); extern bool_t xdr_writeargs(XDR *, nfswriteargs *); extern bool_t xdr_createargs(XDR *, nfscreateargs *); extern bool_t xdr_renameargs(XDR *, nfsrenameargs *); extern bool_t xdr_linkargs(XDR *, nfslinkargs *); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *); extern bool_t xdr_entry(XDR *, nfsentry *); extern bool_t xdr_dirlist(XDR *, nfsdirlist *); extern bool_t xdr_readdirres(XDR *, nfsreaddirres *); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *); extern bool_t xdr_statfsres(XDR *, nfsstatfsres *); extern nfsattrstat *nfsproc_getattr_2(nfs_fh *, CLIENT *); extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2(nfssattrargs *, CLIENT *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern nfsattrstat *nfsproc_write_2(nfswriteargs *, CLIENT *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2(nfscreateargs *, CLIENT *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2(nfsdiropargs *, CLIENT *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2(nfscreateargs *, CLIENT *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_link_2(nfslinkargs *, CLIENT *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2(nfsdiropargs *, CLIENT *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2(nfsrenameargs *, CLIENT *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2(nfsdiropargs *, CLIENT *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2(nfssymlinkargs *, CLIENT *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2(nfsreaddirargs *, CLIENT *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2(nfs_fh *, CLIENT *); extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); extern nfsreadres *nfsproc_read_2(nfsreadargs *, CLIENT *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2(nfs_fh *, CLIENT *); extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); extern void *nfsproc_null_2(void *, CLIENT *); extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern void *nfsproc_root_2(void *, CLIENT *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern void *nfsproc_writecache_2(void *, CLIENT *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t); /* * ENUMS: */ /* * STRUCTURES: */ struct nfs_fh { char fh_data[NFS_FHSIZE]; }; struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct sattrargs { nfs_fh sag_fhandle; nfssattr sag_attributes; }; struct diropargs { nfs_fh da_fhandle; /* was dir */ filename da_name; }; struct diropokres { nfs_fh drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct readlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct readargs { nfs_fh ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct readokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct readres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { nfs_fh wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct createargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct renameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct linkargs { nfs_fh la_fhandle; nfsdiropargs la_to; }; struct symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct readdirargs { nfs_fh rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct entry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct dirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct readdirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_sunos5_6.h000066400000000000000000000261321157065440000226610ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_sunos5_6.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H /* * Do NOT include to get NFS V2 specs, because * it will result in conflicts with . The latter is a must * for NFS V3 specs. */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #define NFSPROC_NULL ((unsigned long)(0)) #define NFSPROC_GETATTR ((unsigned long)(1)) #define NFSPROC_SETATTR ((unsigned long)(2)) #define NFSPROC_ROOT ((unsigned long)(3)) #define NFSPROC_LOOKUP ((unsigned long)(4)) #define NFSPROC_READLINK ((unsigned long)(5)) #define NFSPROC_READ ((unsigned long)(6)) #define NFSPROC_WRITECACHE ((unsigned long)(7)) #define NFSPROC_WRITE ((unsigned long)(8)) #define NFSPROC_CREATE ((unsigned long)(9)) #define NFSPROC_REMOVE ((unsigned long)(10)) #define NFSPROC_RENAME ((unsigned long)(11)) #define NFSPROC_LINK ((unsigned long)(12)) #define NFSPROC_SYMLINK ((unsigned long)(13)) #define NFSPROC_MKDIR ((unsigned long)(14)) #define NFSPROC_RMDIR ((unsigned long)(15)) #define NFSPROC_READDIR ((unsigned long)(16)) #define NFSPROC_STATFS ((unsigned long)(17)) #define AUTOFS_CONFTYPE "ticotsord" /* * TYPEDEFS: */ typedef char *filename; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct fattr nfsfattr; typedef struct linkargs nfslinkargs; typedef struct nfs_fh nfs_fh; typedef struct nfstime nfstime; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern bool_t xdr_nfsstat(XDR *, nfsstat *); extern bool_t xdr_ftype(XDR *, nfsftype *); extern bool_t xdr_nfs_fh(XDR *, nfs_fh *); extern bool_t xdr_nfstime(XDR *, nfstime *); extern bool_t xdr_fattr(XDR *, nfsfattr *); extern bool_t xdr_sattr(XDR *, nfssattr *); extern bool_t xdr_filename(XDR *, filename *); extern bool_t xdr_nfspath(XDR *, nfspath *); extern bool_t xdr_attrstat(XDR *, nfsattrstat *); extern bool_t xdr_sattrargs(XDR *, nfssattrargs *); extern bool_t xdr_diropargs(XDR *, nfsdiropargs *); extern bool_t xdr_diropokres(XDR *, nfsdiropokres *); extern bool_t xdr_diropres(XDR *, nfsdiropres *); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *); extern bool_t xdr_readargs(XDR *, nfsreadargs *); extern bool_t xdr_readokres(XDR *, nfsreadokres *); extern bool_t xdr_readres(XDR *, nfsreadres *); extern bool_t xdr_writeargs(XDR *, nfswriteargs *); extern bool_t xdr_createargs(XDR *, nfscreateargs *); extern bool_t xdr_renameargs(XDR *, nfsrenameargs *); extern bool_t xdr_linkargs(XDR *, nfslinkargs *); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *); extern bool_t xdr_entry(XDR *, nfsentry *); extern bool_t xdr_dirlist(XDR *, nfsdirlist *); extern bool_t xdr_readdirres(XDR *, nfsreaddirres *); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *); extern bool_t xdr_statfsres(XDR *, nfsstatfsres *); extern nfsattrstat *nfsproc_getattr_2(nfs_fh *, CLIENT *); extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2(nfssattrargs *, CLIENT *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern nfsattrstat *nfsproc_write_2(nfswriteargs *, CLIENT *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2(nfscreateargs *, CLIENT *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2(nfsdiropargs *, CLIENT *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2(nfscreateargs *, CLIENT *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_link_2(nfslinkargs *, CLIENT *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2(nfsdiropargs *, CLIENT *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2(nfsrenameargs *, CLIENT *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2(nfsdiropargs *, CLIENT *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2(nfssymlinkargs *, CLIENT *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2(nfsreaddirargs *, CLIENT *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2(nfs_fh *, CLIENT *); extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); extern nfsreadres *nfsproc_read_2(nfsreadargs *, CLIENT *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2(nfs_fh *, CLIENT *); extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); extern void *nfsproc_null_2(void *, CLIENT *); extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern void *nfsproc_root_2(void *, CLIENT *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern void *nfsproc_writecache_2(void *, CLIENT *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t); /* * ENUMS: */ /* * STRUCTURES: */ struct nfs_fh { char fh_data[NFS_FHSIZE]; }; struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct sattrargs { nfs_fh sag_fhandle; nfssattr sag_attributes; }; struct diropargs { nfs_fh da_fhandle; /* was dir */ filename da_name; }; struct diropokres { nfs_fh drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct readlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct readargs { nfs_fh ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct readokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct readres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { nfs_fh wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct createargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct renameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct linkargs { nfs_fh la_fhandle; nfsdiropargs la_to; }; struct symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct readdirargs { nfs_fh rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct entry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct dirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct readdirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_sunos5_7.h000066400000000000000000000266261157065440000226720ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_sunos5_7.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H /* * Do NOT include to get NFS V2 specs, because * it will result in conflicts with . The latter is a must * for NFS V3 specs. */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #define NFSPROC_NULL ((unsigned long)(0)) #define NFSPROC_GETATTR ((unsigned long)(1)) #define NFSPROC_SETATTR ((unsigned long)(2)) #define NFSPROC_ROOT ((unsigned long)(3)) #define NFSPROC_LOOKUP ((unsigned long)(4)) #define NFSPROC_READLINK ((unsigned long)(5)) #define NFSPROC_READ ((unsigned long)(6)) #define NFSPROC_WRITECACHE ((unsigned long)(7)) #define NFSPROC_WRITE ((unsigned long)(8)) #define NFSPROC_CREATE ((unsigned long)(9)) #define NFSPROC_REMOVE ((unsigned long)(10)) #define NFSPROC_RENAME ((unsigned long)(11)) #define NFSPROC_LINK ((unsigned long)(12)) #define NFSPROC_SYMLINK ((unsigned long)(13)) #define NFSPROC_MKDIR ((unsigned long)(14)) #define NFSPROC_RMDIR ((unsigned long)(15)) #define NFSPROC_READDIR ((unsigned long)(16)) #define NFSPROC_STATFS ((unsigned long)(17)) #define AUTOFS_CONFTYPE "ticotsord" /* Sun has incomplete ldap headers, but libraries are ok */ #ifndef LDAP_VERSION_MAX #define LDAP_VERSION_MAX LDAP_VERSION3 #endif /* LDAP_VERSION_MAX */ /* * TYPEDEFS: */ typedef char *filename; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct fattr nfsfattr; typedef struct linkargs nfslinkargs; typedef struct nfs_fh nfs_fh; typedef struct nfstime nfstime; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern bool_t xdr_nfsstat(XDR *, nfsstat *); extern bool_t xdr_ftype(XDR *, nfsftype *); extern bool_t xdr_nfs_fh(XDR *, nfs_fh *); extern bool_t xdr_nfstime(XDR *, nfstime *); extern bool_t xdr_fattr(XDR *, nfsfattr *); extern bool_t xdr_sattr(XDR *, nfssattr *); extern bool_t xdr_filename(XDR *, filename *); extern bool_t xdr_nfspath(XDR *, nfspath *); extern bool_t xdr_attrstat(XDR *, nfsattrstat *); extern bool_t xdr_sattrargs(XDR *, nfssattrargs *); extern bool_t xdr_diropargs(XDR *, nfsdiropargs *); extern bool_t xdr_diropokres(XDR *, nfsdiropokres *); extern bool_t xdr_diropres(XDR *, nfsdiropres *); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *); extern bool_t xdr_readargs(XDR *, nfsreadargs *); extern bool_t xdr_readokres(XDR *, nfsreadokres *); extern bool_t xdr_readres(XDR *, nfsreadres *); extern bool_t xdr_writeargs(XDR *, nfswriteargs *); extern bool_t xdr_createargs(XDR *, nfscreateargs *); extern bool_t xdr_renameargs(XDR *, nfsrenameargs *); extern bool_t xdr_linkargs(XDR *, nfslinkargs *); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *); extern bool_t xdr_entry(XDR *, nfsentry *); extern bool_t xdr_dirlist(XDR *, nfsdirlist *); extern bool_t xdr_readdirres(XDR *, nfsreaddirres *); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *); extern bool_t xdr_statfsres(XDR *, nfsstatfsres *); extern nfsattrstat *nfsproc_getattr_2(nfs_fh *, CLIENT *); extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2(nfssattrargs *, CLIENT *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern nfsattrstat *nfsproc_write_2(nfswriteargs *, CLIENT *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2(nfscreateargs *, CLIENT *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2(nfsdiropargs *, CLIENT *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2(nfscreateargs *, CLIENT *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_link_2(nfslinkargs *, CLIENT *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2(nfsdiropargs *, CLIENT *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2(nfsrenameargs *, CLIENT *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2(nfsdiropargs *, CLIENT *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2(nfssymlinkargs *, CLIENT *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2(nfsreaddirargs *, CLIENT *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2(nfs_fh *, CLIENT *); extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); extern nfsreadres *nfsproc_read_2(nfsreadargs *, CLIENT *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2(nfs_fh *, CLIENT *); extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); extern void *nfsproc_null_2(void *, CLIENT *); extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern void *nfsproc_root_2(void *, CLIENT *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern void *nfsproc_writecache_2(void *, CLIENT *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t); /* Sun has incomplete ldap headers, but libraries are ok */ #ifdef HAVE_LDAP_H extern int ldap_set_option(LDAP *, int, const void *); #endif /* HAVE_LDAP_H */ /* * ENUMS: */ /* * STRUCTURES: */ struct nfs_fh { char fh_data[NFS_FHSIZE]; }; struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct sattrargs { nfs_fh sag_fhandle; nfssattr sag_attributes; }; struct diropargs { nfs_fh da_fhandle; /* was dir */ filename da_name; }; struct diropokres { nfs_fh drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct readlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct readargs { nfs_fh ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct readokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct readres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { nfs_fh wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct createargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct renameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct linkargs { nfs_fh la_fhandle; nfsdiropargs la_to; }; struct symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct readdirargs { nfs_fh rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct entry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct dirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct readdirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_sunos5_8.h000066400000000000000000000260741157065440000226700ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_sunos5_8.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H /* * Do NOT include to get NFS V2 specs, because * it will result in conflicts with . The latter is a must * for NFS V3 specs. */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #define NFSPROC_NULL ((unsigned long)(0)) #define NFSPROC_GETATTR ((unsigned long)(1)) #define NFSPROC_SETATTR ((unsigned long)(2)) #define NFSPROC_ROOT ((unsigned long)(3)) #define NFSPROC_LOOKUP ((unsigned long)(4)) #define NFSPROC_READLINK ((unsigned long)(5)) #define NFSPROC_READ ((unsigned long)(6)) #define NFSPROC_WRITECACHE ((unsigned long)(7)) #define NFSPROC_WRITE ((unsigned long)(8)) #define NFSPROC_CREATE ((unsigned long)(9)) #define NFSPROC_REMOVE ((unsigned long)(10)) #define NFSPROC_RENAME ((unsigned long)(11)) #define NFSPROC_LINK ((unsigned long)(12)) #define NFSPROC_SYMLINK ((unsigned long)(13)) #define NFSPROC_MKDIR ((unsigned long)(14)) #define NFSPROC_RMDIR ((unsigned long)(15)) #define NFSPROC_READDIR ((unsigned long)(16)) #define NFSPROC_STATFS ((unsigned long)(17)) #define AUTOFS_CONFTYPE "ticotsord" /* * TYPEDEFS: */ typedef char *filename; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct fattr nfsfattr; typedef struct linkargs nfslinkargs; typedef struct nfs_fh nfs_fh; typedef struct nfstime nfstime; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern bool_t xdr_nfsstat(XDR *, nfsstat *); extern bool_t xdr_ftype(XDR *, nfsftype *); extern bool_t xdr_nfs_fh(XDR *, nfs_fh *); extern bool_t xdr_nfstime(XDR *, nfstime *); extern bool_t xdr_fattr(XDR *, nfsfattr *); extern bool_t xdr_sattr(XDR *, nfssattr *); extern bool_t xdr_filename(XDR *, filename *); extern bool_t xdr_nfspath(XDR *, nfspath *); extern bool_t xdr_attrstat(XDR *, nfsattrstat *); extern bool_t xdr_sattrargs(XDR *, nfssattrargs *); extern bool_t xdr_diropargs(XDR *, nfsdiropargs *); extern bool_t xdr_diropokres(XDR *, nfsdiropokres *); extern bool_t xdr_diropres(XDR *, nfsdiropres *); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *); extern bool_t xdr_readargs(XDR *, nfsreadargs *); extern bool_t xdr_readokres(XDR *, nfsreadokres *); extern bool_t xdr_readres(XDR *, nfsreadres *); extern bool_t xdr_writeargs(XDR *, nfswriteargs *); extern bool_t xdr_createargs(XDR *, nfscreateargs *); extern bool_t xdr_renameargs(XDR *, nfsrenameargs *); extern bool_t xdr_linkargs(XDR *, nfslinkargs *); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *); extern bool_t xdr_entry(XDR *, nfsentry *); extern bool_t xdr_dirlist(XDR *, nfsdirlist *); extern bool_t xdr_readdirres(XDR *, nfsreaddirres *); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *); extern bool_t xdr_statfsres(XDR *, nfsstatfsres *); extern nfsattrstat *nfsproc_getattr_2(nfs_fh *, CLIENT *); extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2(nfssattrargs *, CLIENT *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern nfsattrstat *nfsproc_write_2(nfswriteargs *, CLIENT *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2(nfscreateargs *, CLIENT *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2(nfsdiropargs *, CLIENT *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2(nfscreateargs *, CLIENT *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_link_2(nfslinkargs *, CLIENT *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2(nfsdiropargs *, CLIENT *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2(nfsrenameargs *, CLIENT *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2(nfsdiropargs *, CLIENT *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2(nfssymlinkargs *, CLIENT *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2(nfsreaddirargs *, CLIENT *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2(nfs_fh *, CLIENT *); extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); extern nfsreadres *nfsproc_read_2(nfsreadargs *, CLIENT *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2(nfs_fh *, CLIENT *); extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); extern void *nfsproc_null_2(void *, CLIENT *); extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern void *nfsproc_root_2(void *, CLIENT *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern void *nfsproc_writecache_2(void *, CLIENT *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t); /* * ENUMS: */ /* * STRUCTURES: */ struct nfs_fh { char fh_data[NFS_FHSIZE]; }; struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct sattrargs { nfs_fh sag_fhandle; nfssattr sag_attributes; }; struct diropargs { nfs_fh da_fhandle; /* was dir */ filename da_name; }; struct diropokres { nfs_fh drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct readlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct readargs { nfs_fh ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct readokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct readres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { nfs_fh wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct createargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct renameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct linkargs { nfs_fh la_fhandle; nfsdiropargs la_to; }; struct symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct readdirargs { nfs_fh rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct entry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct dirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct readdirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_svr4.h000066400000000000000000000270221157065440000220750ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_svr4.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H /* * Do NOT include to get NFS V2 specs, because * it will result in conflicts with . The latter is a must * for NFS V3 specs. */ #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ /* * MACROS */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #define NFSPROC_NULL ((unsigned long)(0)) #define NFSPROC_GETATTR ((unsigned long)(1)) #define NFSPROC_SETATTR ((unsigned long)(2)) #define NFSPROC_ROOT ((unsigned long)(3)) #define NFSPROC_LOOKUP ((unsigned long)(4)) #define NFSPROC_READLINK ((unsigned long)(5)) #define NFSPROC_READ ((unsigned long)(6)) #define NFSPROC_WRITECACHE ((unsigned long)(7)) #define NFSPROC_WRITE ((unsigned long)(8)) #define NFSPROC_CREATE ((unsigned long)(9)) #define NFSPROC_REMOVE ((unsigned long)(10)) #define NFSPROC_RENAME ((unsigned long)(11)) #define NFSPROC_LINK ((unsigned long)(12)) #define NFSPROC_SYMLINK ((unsigned long)(13)) #define NFSPROC_MKDIR ((unsigned long)(14)) #define NFSPROC_RMDIR ((unsigned long)(15)) #define NFSPROC_READDIR ((unsigned long)(16)) #define NFSPROC_STATFS ((unsigned long)(17)) /* map field names */ #define ml_hostname ml_name #define ml_directory ml_path #define ml_next ml_nxt #define gr_next g_next #define gr_name g_name #define ex_dir ex_name /* * TYPEDEFS: */ typedef char *dirpath; typedef char *filename; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef struct attrstat nfsattrstat; typedef struct createargs nfscreateargs; typedef struct dirlist nfsdirlist; typedef struct diropargs nfsdiropargs; typedef struct diropokres nfsdiropokres; typedef struct diropres nfsdiropres; typedef struct entry nfsentry; typedef struct fattr nfsfattr; typedef struct linkargs nfslinkargs; typedef struct nfs_fh nfs_fh; typedef struct nfstime nfstime; typedef struct readargs nfsreadargs; typedef struct readdirargs nfsreaddirargs; typedef struct readdirres nfsreaddirres; typedef struct readlinkres nfsreadlinkres; typedef struct readokres nfsreadokres; typedef struct readres nfsreadres; typedef struct renameargs nfsrenameargs; typedef struct sattr nfssattr; typedef struct sattrargs nfssattrargs; typedef struct statfsokres nfsstatfsokres; typedef struct statfsres nfsstatfsres; typedef struct symlinkargs nfssymlinkargs; typedef struct writeargs nfswriteargs; typedef char *name; typedef fhandle_t fhandle; typedef struct exports *exports; typedef struct exports exportnode; typedef struct fhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; /* * EXTERNALS: */ extern bool_t xdr_nfsstat(XDR *, nfsstat *); extern bool_t xdr_ftype(XDR *, nfsftype *); extern bool_t xdr_nfs_fh(XDR *, nfs_fh *); extern bool_t xdr_nfstime(XDR *, nfstime *); extern bool_t xdr_fattr(XDR *, nfsfattr *); extern bool_t xdr_sattr(XDR *, nfssattr *); extern bool_t xdr_filename(XDR *, filename *); extern bool_t xdr_nfspath(XDR *, nfspath *); extern bool_t xdr_attrstat(XDR *, nfsattrstat *); extern bool_t xdr_sattrargs(XDR *, nfssattrargs *); extern bool_t xdr_diropargs(XDR *, nfsdiropargs *); extern bool_t xdr_diropokres(XDR *, nfsdiropokres *); extern bool_t xdr_diropres(XDR *, nfsdiropres *); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres *); extern bool_t xdr_readargs(XDR *, nfsreadargs *); extern bool_t xdr_readokres(XDR *, nfsreadokres *); extern bool_t xdr_readres(XDR *, nfsreadres *); extern bool_t xdr_writeargs(XDR *, nfswriteargs *); extern bool_t xdr_createargs(XDR *, nfscreateargs *); extern bool_t xdr_renameargs(XDR *, nfsrenameargs *); extern bool_t xdr_linkargs(XDR *, nfslinkargs *); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs *); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs *); extern bool_t xdr_entry(XDR *, nfsentry *); extern bool_t xdr_dirlist(XDR *, nfsdirlist *); extern bool_t xdr_readdirres(XDR *, nfsreaddirres *); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres *); extern bool_t xdr_statfsres(XDR *, nfsstatfsres *); extern nfsattrstat *nfsproc_getattr_2(nfs_fh *, CLIENT *); extern nfsattrstat *nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2(nfssattrargs *, CLIENT *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern nfsattrstat *nfsproc_write_2(nfswriteargs *, CLIENT *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2(nfscreateargs *, CLIENT *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2(nfsdiropargs *, CLIENT *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2(nfscreateargs *, CLIENT *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_link_2(nfslinkargs *, CLIENT *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2(nfsdiropargs *, CLIENT *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2(nfsrenameargs *, CLIENT *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2(nfsdiropargs *, CLIENT *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2(nfssymlinkargs *, CLIENT *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2(nfsreaddirargs *, CLIENT *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2(nfs_fh *, CLIENT *); extern nfsreadlinkres *nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); extern nfsreadres *nfsproc_read_2(nfsreadargs *, CLIENT *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2(nfs_fh *, CLIENT *); extern nfsstatfsres *nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); extern void *nfsproc_null_2(void *, CLIENT *); extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern void *nfsproc_root_2(void *, CLIENT *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern void *nfsproc_writecache_2(void *, CLIENT *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern int nfs_program_2_freeresult(SVCXPRT *, xdrproc_t, caddr_t); /* * ENUMS: */ /* * STRUCTURES: */ struct nfs_fh { char fh_data[NFS_FHSIZE]; }; struct nfstime { u_int nt_seconds; u_int nt_useconds; }; struct fattr { nfsftype na_type; u_int na_mode; u_int na_nlink; u_int na_uid; u_int na_gid; u_int na_size; u_int na_blocksize; u_int na_rdev; u_int na_blocks; u_int na_fsid; u_int na_fileid; nfstime na_atime; nfstime na_mtime; nfstime na_ctime; }; struct sattr { u_int sa_mode; u_int sa_uid; u_int sa_gid; u_int sa_size; nfstime sa_atime; nfstime sa_mtime; }; struct attrstat { nfsstat ns_status; union { nfsfattr ns_attr_u; } ns_u; }; struct sattrargs { nfs_fh sag_fhandle; nfssattr sag_attributes; }; struct diropargs { nfs_fh da_fhandle; /* was dir */ filename da_name; }; struct diropokres { nfs_fh drok_fhandle; nfsfattr drok_attributes; }; struct diropres { nfsstat dr_status; /* was status */ union { nfsdiropokres dr_drok_u; /* was diropres */ } dr_u; /* was diropres_u */ }; struct readlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct readargs { nfs_fh ra_fhandle; u_int ra_offset; u_int ra_count; u_int ra_totalcount; }; struct readokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct readres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { nfs_fh wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct createargs { nfsdiropargs ca_where; nfssattr ca_attributes; }; struct renameargs { nfsdiropargs rna_from; nfsdiropargs rna_to; }; struct linkargs { nfs_fh la_fhandle; nfsdiropargs la_to; }; struct symlinkargs { nfsdiropargs sla_from; nfspath sla_to; nfssattr sla_attributes; }; struct readdirargs { nfs_fh rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct entry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct dirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct readdirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct statfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct statfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/nfs_prot/nfs_prot_ultrix.h000066400000000000000000000226301157065440000225260ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/nfs_prot/nfs_prot_ultrix.h * */ #ifndef _AMU_NFS_PROT_H #define _AMU_NFS_PROT_H #ifdef HAVE_NFS_NFS_H # include #endif /* HAVE_NFS_NFS_H */ /* * MACROS */ #if 0 /* */ #define NFS_PORT 2049 #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 #define NFS_FHSIZE 32 #endif /* 0 */ /* sizeof(u_long) */ #define NFS_COOKIESIZE 4 #if 0 /* defaults: libamu/amu.h */ #define MNTPATHLEN 1024 #define MNTNAMLEN 255 #endif /* 0 */ #define NFSMODE_FMT 0170000 #define NFSMODE_DIR 0040000 #define NFSMODE_CHR 0020000 #define NFSMODE_BLK 0060000 #define NFSMODE_REG 0100000 #define NFSMODE_LNK 0120000 #define NFSMODE_SOCK 0140000 #define NFSMODE_FIFO 0010000 #if 0 /* */ #ifndef NFS_PROGRAM # define NFS_PROGRAM ((u_long)100003) #endif /* not NFS_PROGRAM */ #ifndef NFS_VERSION # define NFS_VERSION ((u_long)2) #endif /* not NFS_VERSION */ #endif /* 0 */ /* could use (u_long)RFS_* with RFS_* from */ #define NFSPROC_NULL ((u_long)0) #define NFSPROC_GETATTR ((u_long)1) #define NFSPROC_SETATTR ((u_long)2) #define NFSPROC_ROOT ((u_long)3) #define NFSPROC_LOOKUP ((u_long)4) #define NFSPROC_READLINK ((u_long)5) #define NFSPROC_READ ((u_long)6) #define NFSPROC_WRITECACHE ((u_long)7) #define NFSPROC_WRITE ((u_long)8) #define NFSPROC_CREATE ((u_long)9) #define NFSPROC_REMOVE ((u_long)10) #define NFSPROC_RENAME ((u_long)11) #define NFSPROC_LINK ((u_long)12) #define NFSPROC_SYMLINK ((u_long)13) #define NFSPROC_MKDIR ((u_long)14) #define NFSPROC_RMDIR ((u_long)15) #define NFSPROC_READDIR ((u_long)16) #define NFSPROC_STATFS ((u_long)17) /* map field names */ #define ml_hostname ml_name #define ml_directory ml_path #define ml_next ml_nxt #define gr_next g_next #define gr_name g_name #define ex_dir ex_name #define ca_where ca_da #define ca_attributes ca_sa #define drok_attributes drok_attr #define fh_data fh_pad #define na_fileid na_nodeid #define la_fhandle la_from #define nt_seconds tv_sec #define nt_useconds tv_usec #define ra_totalcount ra_totcount #define rlr_status rl_status #define rlr_u rl_u #define sla_to sla_tnm #define sla_attributes sla_sa #define sag_fhandle saa_fh #define sag_attributes saa_sa /* * TYPEDEFS: */ typedef char *dirpath; typedef char *filename; typedef char *name; typedef char *nfspath; typedef char nfscookie[NFS_COOKIESIZE]; typedef enum nfsftype nfsftype; typedef enum nfsstat nfsstat; typedef fhandle_t fhandle; typedef struct nfsattrstat nfsattrstat; typedef struct nfscreatargs nfscreateargs; typedef struct nfsdirlist nfsdirlist; typedef struct nfsdiropargs nfsdiropargs; typedef struct nfsdrok nfsdiropokres; typedef struct nfsdiropres nfsdiropres; typedef struct nfsentry nfsentry; typedef struct exports *exports; typedef struct exports exportnode; typedef struct nfsfattr nfsfattr; typedef struct fhstatus fhstatus; typedef struct groups *groups; typedef struct groups groupnode; typedef struct nfslinkargs nfslinkargs; typedef struct mountlist *mountlist; typedef struct mountlist mountbody; typedef struct timeval nfstime; typedef struct nfsreadargs nfsreadargs; typedef struct nfsreaddirargs nfsreaddirargs; typedef struct nfsreaddirres nfsreaddirres; typedef struct nfsreadlinkres nfsreadlinkres; typedef struct nfsreadokres nfsreadokres; typedef struct nfsreadres nfsreadres; typedef struct nfsrnmargs nfsrenameargs; typedef struct nfssattr nfssattr; typedef struct nfssaargs nfssattrargs; typedef struct nfsstatfsokres nfsstatfsokres; typedef struct nfsstatfsres nfsstatfsres; typedef struct nfsslargs nfssymlinkargs; typedef struct writeargs nfswriteargs; /* * EXTERNALS: */ extern void *nfsproc_null_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_getattr_2_svc(fhandle_t *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern void *nfsproc_root_2_svc(void *, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2_svc(fhandle_t *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern void *nfsproc_writecache_2_svc(void *, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(fhandle_t *, struct svc_req *); extern bool_t xdr_nfsstat(XDR *, nfsstat*); extern bool_t xdr_ftype(XDR *, nfsftype*); extern bool_t xdr_nfs_fh(XDR *, fhandle_t*); extern bool_t xdr_nfstime(XDR *, nfstime*); extern bool_t xdr_fattr(XDR *, nfsfattr*); extern bool_t xdr_sattr(XDR *, nfssattr*); extern bool_t xdr_filename(XDR *, filename*); extern bool_t xdr_nfspath(XDR *, nfspath*); extern bool_t xdr_attrstat(XDR *, nfsattrstat*); extern bool_t xdr_sattrargs(XDR *, nfssattrargs*); extern bool_t xdr_diropargs(XDR *, nfsdiropargs*); extern bool_t xdr_diropokres(XDR *, nfsdiropokres*); extern bool_t xdr_diropres(XDR *, nfsdiropres*); extern bool_t xdr_readlinkres(XDR *, nfsreadlinkres*); extern bool_t xdr_readargs(XDR *, nfsreadargs*); extern bool_t xdr_readokres(XDR *, nfsreadokres*); extern bool_t xdr_readres(XDR *, nfsreadres*); extern bool_t xdr_writeargs(XDR *, nfswriteargs*); extern bool_t xdr_createargs(XDR *, nfscreateargs*); extern bool_t xdr_renameargs(XDR *, nfsrenameargs*); extern bool_t xdr_linkargs(XDR *, nfslinkargs*); extern bool_t xdr_symlinkargs(XDR *, nfssymlinkargs*); extern bool_t xdr_nfscookie(XDR *, nfscookie); extern bool_t xdr_readdirargs(XDR *, nfsreaddirargs*); extern bool_t xdr_entry(XDR *, nfsentry*); extern bool_t xdr_dirlist(XDR *, nfsdirlist*); extern bool_t xdr_readdirres(XDR *, nfsreaddirres*); extern bool_t xdr_statfsokres(XDR *, nfsstatfsokres*); extern bool_t xdr_statfsres(XDR *, nfsstatfsres*); /* * STRUCTURES: */ struct nfsreadlinkres { nfsstat rlr_status; union { nfspath rlr_data_u; } rlr_u; }; struct nfsreadokres { nfsfattr raok_attributes; struct { u_int raok_len_u; char *raok_val_u; } raok_u; }; struct nfsreadres { nfsstat rr_status; union { nfsreadokres rr_reply_u; } rr_u; }; struct writeargs { fhandle_t wra_fhandle; u_int wra_beginoffset; u_int wra_offset; u_int wra_totalcount; struct { u_int wra_len_u; char *wra_val_u; } wra_u; }; struct nfsreaddirargs { fhandle_t rda_fhandle; nfscookie rda_cookie; u_int rda_count; }; struct nfsentry { u_int ne_fileid; filename ne_name; nfscookie ne_cookie; nfsentry *ne_nextentry; }; struct nfsdirlist { nfsentry *dl_entries; bool_t dl_eof; }; struct nfsreaddirres { nfsstat rdr_status; union { nfsdirlist rdr_reply_u; } rdr_u; }; struct nfsstatfsokres { u_int sfrok_tsize; u_int sfrok_bsize; u_int sfrok_blocks; u_int sfrok_bfree; u_int sfrok_bavail; }; struct nfsstatfsres { nfsstat sfr_status; union { nfsstatfsokres sfr_reply_u; } sfr_u; }; #endif /* not _AMU_NFS_PROT_H */ am-utils-6.2+rc20110530/conf/sa_dref/000077500000000000000000000000001157065440000166625ustar00rootroot00000000000000am-utils-6.2+rc20110530/conf/sa_dref/sa_dref_386bsd.h000066400000000000000000000002431157065440000215260ustar00rootroot00000000000000/* $srcdir/conf/sa_dref/sa_dref_386bsd.h */ #define NFS_SA_DREF(dst, src) { \ (dst)->addr = (struct sockaddr *) (src); \ } #define NFS_ARGS_T_ADDR_IS_POINTER 1 am-utils-6.2+rc20110530/conf/sa_dref/sa_dref_aix3.h000066400000000000000000000002051157065440000213570ustar00rootroot00000000000000/* $srcdir/conf/sa_dref/sa_dref_aix3.h */ #define NFS_SA_DREF(dst, src) (dst)->addr = *(src) /* #undef NFS_ARGS_T_ADDR_IS_POINTER */ am-utils-6.2+rc20110530/conf/sa_dref/sa_dref_aoi.h000066400000000000000000000004031157065440000212630ustar00rootroot00000000000000/* $srcdir/conf/sa_dref/sa_dref_aoi.h */ #define NFS_SA_DREF(dst, src) { \ (dst)->addr->buf = (char *) (src); \ (dst)->addr->len = sizeof(struct sockaddr_in); \ (dst)->addr->maxlen = sizeof(struct sockaddr_in); \ } #define NFS_ARGS_T_ADDR_IS_POINTER 1 am-utils-6.2+rc20110530/conf/sa_dref/sa_dref_bsd44.h000066400000000000000000000003051157065440000214340ustar00rootroot00000000000000/* $srcdir/conf/sa_dref/sa_dref_bsd44.h */ #define NFS_SA_DREF(dst, src) { \ (dst)->addr = (struct sockaddr *) (src); \ (dst)->addrlen = sizeof(*src); \ } #define NFS_ARGS_T_ADDR_IS_POINTER 1 am-utils-6.2+rc20110530/conf/sa_dref/sa_dref_default.h000066400000000000000000000002041157065440000221360ustar00rootroot00000000000000/* $srcdir/conf/sa_dref/sa_dref_default.h */ #define NFS_SA_DREF(dst, src) (dst)->addr = (src) #define NFS_ARGS_T_ADDR_IS_POINTER 1 am-utils-6.2+rc20110530/conf/sa_dref/sa_dref_isc3.h000066400000000000000000000003471157065440000213630ustar00rootroot00000000000000/* $srcdir/conf/sa_dref/sa_dref_isc3.h */ #define NFS_SA_DREF(dst, src) { \ (dst)->raddr.buf = (char *) (src); \ (dst)->raddr.len = sizeof(struct sockaddr_in); \ (dst)->trans = 1; \ } /* #undef NFS_ARGS_T_ADDR_IS_POINTER */ am-utils-6.2+rc20110530/conf/sa_dref/sa_dref_linux.h000066400000000000000000000002671157065440000216620ustar00rootroot00000000000000/* $srcdir/conf/sa_dref/sa_dref_linux.h */ #define NFS_SA_DREF(dst, src) memmove((char *)&dst->addr, (char *) src, sizeof(struct sockaddr_in)) /* #undef NFS_ARGS_T_ADDR_IS_POINTER */ am-utils-6.2+rc20110530/conf/sa_dref/sa_dref_svr4.h000066400000000000000000000004041157065440000214120ustar00rootroot00000000000000/* $srcdir/conf/sa_dref/sa_dref_svr4.h */ #define NFS_SA_DREF(dst, src) { \ (dst)->addr->buf = (char *) (src); \ (dst)->addr->len = sizeof(struct sockaddr_in); \ (dst)->addr->maxlen = sizeof(struct sockaddr_in); \ } #define NFS_ARGS_T_ADDR_IS_POINTER 1 am-utils-6.2+rc20110530/conf/transp/000077500000000000000000000000001157065440000165665ustar00rootroot00000000000000am-utils-6.2+rc20110530/conf/transp/transp_sockets.c000066400000000000000000000362771157065440000220130ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/transp/transp_sockets.c * * Socket specific utilities. * -Erez Zadok */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * find the IP address that can be used to connect to the local host */ void amu_get_myaddress(struct in_addr *iap, const char *preferred_localhost) { struct hostent *hp; char dq[20]; #ifdef DEBUG_off #error this code is old and probably not useful any longer. #error Erez, Jan 21, 2004. struct sockaddr_in sin; /* * Most modern systems should use 127.0.0.1 as the localhost address over * which you can do NFS mounts. In the past we found that some NFS * clients may not allow mounts from localhost. So we used * get_myaddress() and that seemed to work. Alas, on some other systems, * get_myaddress() may return one of the interface addresses at random, * and thus use a less efficient IP address than 127.0.0.1. The solution * is to hard-code 127.0.0.1, but still check if get_myaddress() returns a * different value and warn about it. */ memset((char *) &sin, 0, sizeof(sin)); get_myaddress(&sin); if (sin.sin_addr.s_addr != htonl(INADDR_LOOPBACK)) dlog("amu_get_myaddress: myaddress conflict (0x%x vs. 0x%lx)", sin.sin_addr.s_addr, (u_long) htonl(INADDR_LOOPBACK)); #endif /* DEBUG_off */ if (preferred_localhost == NULL) goto out; /* if specified preferred locahost, then try to use it */ hp = gethostbyname(preferred_localhost); if (hp == NULL) { /* XXX: if hstrerror()/h_errno aren't portable, then need to port the next statement */ plog(XLOG_ERROR, "Unable to resolve localhost_address \"%s\" (%s): using default", preferred_localhost, hstrerror(h_errno)); goto out; } if (hp->h_addr_list == NULL) { plog(XLOG_ERROR, "localhost_address \"%s\" has no IP addresses: using default", preferred_localhost); goto out; } if (hp->h_addr_list[1] != NULL) { plog(XLOG_ERROR, "localhost_address \"%s\" has more than one IP addresses: using first", preferred_localhost); goto out; } memmove((voidp) &iap->s_addr, (voidp) hp->h_addr_list[0], sizeof(iap->s_addr)); plog(XLOG_INFO, "localhost_address \"%s\" requested, using %s", preferred_localhost, inet_dquad(dq, sizeof(dq), iap->s_addr)); return; out: iap->s_addr = htonl(INADDR_LOOPBACK); } /* * How to bind to reserved ports. * Note: if *pp is non-null and is greater than 0, then *pp will not be modified. */ int bind_resv_port(int so, u_short *pp) { struct sockaddr_in sin; int rc; u_short port; memset((voidp) &sin, 0, sizeof(sin)); sin.sin_family = AF_INET; if (pp && *pp > 0) { sin.sin_port = htons(*pp); rc = bind(so, (struct sockaddr *) &sin, sizeof(sin)); } else { port = IPPORT_RESERVED; do { --port; sin.sin_port = htons(port); rc = bind(so, (struct sockaddr *) &sin, sizeof(sin)); } while (rc < 0 && (int) port > IPPORT_RESERVED / 2); if (pp && rc == 0) *pp = port; } return rc; } /* * close a descriptor, Sockets style */ int amu_close(int fd) { return close(fd); } /* * Create an rpc client attached to the mount daemon. */ CLIENT * get_mount_client(char *unused_host, struct sockaddr_in *sin, struct timeval *tv, int *sock, u_long mnt_version) { CLIENT *client; /* * First try a TCP socket */ if ((*sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) > 0) { /* * Bind to a privileged port */ if (bind_resv_port(*sock, (u_short *) NULL) < 0) plog(XLOG_ERROR, "can't bind privileged port (socket)"); /* * Find mountd port to connect to. * Connect to mountd. * Create a tcp client. */ if ((sin->sin_port = htons(pmap_getport(sin, MOUNTPROG, mnt_version, IPPROTO_TCP))) != 0) { if (connect(*sock, (struct sockaddr *) sin, sizeof(*sin)) >= 0 && ((client = clnttcp_create(sin, MOUNTPROG, mnt_version, sock, 0, 0)) != NULL)) return client; } /* * Failed so close socket */ (void) close(*sock); } /* tcp socket opened */ /* TCP failed so try UDP */ if ((*sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { plog(XLOG_ERROR, "Can't create socket to connect to mountd: %m"); *sock = RPC_ANYSOCK; return NULL; } /* * Bind to a privileged port */ if (bind_resv_port(*sock, (u_short *) NULL) < 0) plog(XLOG_ERROR, "can't bind privileged port"); /* * Zero out the port - make sure we recompute */ sin->sin_port = 0; /* * Make a UDP client */ if ((client = clntudp_create(sin, MOUNTPROG, mnt_version, *tv, sock)) == NULL) { (void) close(*sock); *sock = RPC_ANYSOCK; return NULL; } dlog("get_mount_client: Using udp, port %d", sin->sin_port); return client; } /* * find the address of the caller of an RPC procedure. */ struct sockaddr_in * amu_svc_getcaller(SVCXPRT *xprt) { /* glibc 2.2 returns a sockaddr_storage ??? */ return (struct sockaddr_in *) svc_getcaller(xprt); } /* * Register an RPC server: * return 1 on success, 0 otherwise. */ int amu_svc_register(SVCXPRT *xprt, u_long prognum, u_long versnum, void (*dispatch)(struct svc_req *rqstp, SVCXPRT *transp), u_long protocol, struct netconfig *dummy) { /* on Sockets: svc_register returns 1 on success, 0 otherwise */ return svc_register(xprt, prognum, versnum, dispatch, protocol); } /* * Create the nfs service for amd */ int create_nfs_service(int *soNFSp, u_short *nfs_portp, SVCXPRT **nfs_xprtp, void (*dispatch_fxn)(struct svc_req *rqstp, SVCXPRT *transp)) { *soNFSp = socket(AF_INET, SOCK_DGRAM, 0); if (*soNFSp < 0 || bind_resv_port(*soNFSp, nfs_portp) < 0) { plog(XLOG_FATAL, "Can't create privileged nfs port (socket)"); if (*soNFSp >= 0) close(*soNFSp); return 1; } if ((*nfs_xprtp = svcudp_create(*soNFSp)) == NULL) { plog(XLOG_FATAL, "cannot create rpc/udp service"); close(*soNFSp); return 2; } if ((*nfs_portp = (*nfs_xprtp)->xp_port) >= IPPORT_RESERVED) { plog(XLOG_FATAL, "Can't create privileged nfs port"); svc_destroy(*nfs_xprtp); close(*soNFSp); return 1; } if (!svc_register(*nfs_xprtp, NFS_PROGRAM, NFS_VERSION, dispatch_fxn, 0)) { plog(XLOG_FATAL, "unable to register (%ld, %ld, 0)", (u_long) NFS_PROGRAM, (u_long) NFS_VERSION); svc_destroy(*nfs_xprtp); close(*soNFSp); return 3; } return 0; /* all is well */ } /* * Create the amq service for amd (both TCP and UDP) */ int create_amq_service(int *udp_soAMQp, SVCXPRT **udp_amqpp, struct netconfig **dummy1, int *tcp_soAMQp, SVCXPRT **tcp_amqpp, struct netconfig **dummy2, u_short preferred_amq_port) { /* first create TCP service */ if (tcp_soAMQp) { *tcp_soAMQp = socket(AF_INET, SOCK_STREAM, 0); if (*tcp_soAMQp < 0) { plog(XLOG_FATAL, "cannot create tcp socket for amq service: %m"); return 1; } /* next, bind to a specific (TCP) port if asked for */ if (preferred_amq_port > 0) { /* * Note: if &preferred_amq_port is non-null and is greater than 0, * then the pointer will not be modified. We don't want it to be * modified because it was passed down to create_amq_service as a * non-pointer (a variable on the stack, not to be modified!) */ if (bind_resv_port(*tcp_soAMQp, &preferred_amq_port) < 0) { plog(XLOG_FATAL, "can't bind amq service to requested TCP port %d: %m)", preferred_amq_port); return 1; } } /* now create RPC service handle for amq */ if (tcp_amqpp && (*tcp_amqpp = svctcp_create(*tcp_soAMQp, AMQ_SIZE, AMQ_SIZE)) == NULL) { plog(XLOG_FATAL, "cannot create tcp service for amq: soAMQp=%d", *tcp_soAMQp); return 1; } #ifdef SVCSET_CONNMAXREC /* * This is *BSD at its best. * They just had to do things differently than everyone else * so they fixed a library DoS issue by forcing client-side changes... */ # ifndef RPC_MAXDATASIZE # define RPC_MAXDATASIZE 9000 # endif /* not RPC_MAXDATASIZE */ if (tcp_amqpp) { int maxrec = RPC_MAXDATASIZE; SVC_CONTROL(*tcp_amqpp, SVCSET_CONNMAXREC, &maxrec); } #endif /* not SVCSET_CONNMAXREC */ } /* next create UDP service */ if (udp_soAMQp) { *udp_soAMQp = socket(AF_INET, SOCK_DGRAM, 0); if (*udp_soAMQp < 0) { plog(XLOG_FATAL, "cannot create udp socket for amq service: %m"); return 1; } /* next, bind to a specific (UDP) port if asked for */ if (preferred_amq_port > 0) { /* * Note: see comment about using &preferred_amq_port above in this * function. */ if (bind_resv_port(*udp_soAMQp, &preferred_amq_port) < 0) { plog(XLOG_FATAL, "can't bind amq service to requested UDP port %d: %m)", preferred_amq_port); return 1; } } /* now create RPC service handle for amq */ if (udp_amqpp && (*udp_amqpp = svcudp_bufcreate(*udp_soAMQp, AMQ_SIZE, AMQ_SIZE)) == NULL) { plog(XLOG_FATAL, "cannot create udp service for amq: soAMQp=%d", *udp_soAMQp); return 1; } } return 0; /* all is well */ } /* * Check if the portmapper is running and reachable: 0==down, 1==up */ int check_pmap_up(char *host, struct sockaddr_in* sin) { CLIENT *client; enum clnt_stat clnt_stat = RPC_TIMEDOUT; /* assume failure */ int socket = RPC_ANYSOCK; struct timeval timeout; timeout.tv_sec = 2; timeout.tv_usec = 0; sin->sin_port = htons(PMAPPORT); client = clntudp_create(sin, PMAPPROG, PMAPVERS, timeout, &socket); if (client == (CLIENT *) NULL) { plog(XLOG_ERROR, "check_pmap_up: cannot create connection to contact portmapper on host \"%s\"%s", host, clnt_spcreateerror("")); return 0; } timeout.tv_sec = 6; /* Ping the portmapper on a remote system by calling the nullproc */ clnt_stat = clnt_call(client, PMAPPROC_NULL, (XDRPROC_T_TYPE) xdr_void, NULL, (XDRPROC_T_TYPE) xdr_void, NULL, timeout); clnt_destroy(client); close(socket); sin->sin_port = 0; if (clnt_stat == RPC_TIMEDOUT) { plog(XLOG_ERROR, "check_pmap_up: failed to contact portmapper on host \"%s\": %s", host, clnt_sperrno(clnt_stat)); return 0; } return 1; } /* * Find the best NFS version for a host and protocol. */ u_long get_nfs_version(char *host, struct sockaddr_in *sin, u_long nfs_version, const char *proto) { CLIENT *clnt; int again = 0; enum clnt_stat clnt_stat; struct timeval tv; int sock; char *errstr; /* * If not set or set wrong, then try from NFS_VERS_MAX on down. If * set, then try from nfs_version on down. */ if (nfs_version <= 0 || nfs_version > NFS_VERS_MAX) { nfs_version = NFS_VERS_MAX; again = 1; } tv.tv_sec = 2; /* retry every 2 seconds, but also timeout */ tv.tv_usec = 0; #ifdef HAVE_FS_NFS3 try_again: #endif /* HAVE_FS_NFS3 */ sock = RPC_ANYSOCK; errstr = NULL; if (STREQ(proto, "tcp")) clnt = clnttcp_create(sin, NFS_PROGRAM, nfs_version, &sock, 0, 0); else if (STREQ(proto, "udp")) clnt = clntudp_create(sin, NFS_PROGRAM, nfs_version, tv, &sock); else clnt = NULL; if (clnt != NULL) { /* Try three times (6/2=3) to verify the CLIENT handle. */ tv.tv_sec = 6; clnt_stat = clnt_call(clnt, NFSPROC_NULL, (XDRPROC_T_TYPE) xdr_void, 0, (XDRPROC_T_TYPE) xdr_void, 0, tv); if (clnt_stat != RPC_SUCCESS) errstr = clnt_sperrno(clnt_stat); close(sock); clnt_destroy(clnt); } else { #ifdef HAVE_CLNT_SPCREATEERROR errstr = clnt_spcreateerror(""); #else /* not HAVE_CLNT_SPCREATEERROR */ errstr = ""; #endif /* not HAVE_CLNT_SPCREATEERROR */ } if (errstr) { plog(XLOG_INFO, "get_nfs_version NFS(%d,%s) failed for %s%s", (int) nfs_version, proto, host, errstr); if (again) { #ifdef HAVE_FS_NFS3 if (nfs_version == NFS_VERSION3) { nfs_version = NFS_VERSION; again = 0; plog(XLOG_INFO, "get_nfs_version trying a lower version: NFS(%d,%s)", (int) nfs_version, proto); } goto try_again; #endif /* HAVE_FS_NFS3 */ } return 0; } plog(XLOG_INFO, "get_nfs_version: returning NFS(%d,%s) on host %s", (int) nfs_version, proto, host); return nfs_version; } #if defined(HAVE_FS_AUTOFS) && defined(AUTOFS_PROG) /* * Register the autofs service for amd */ int register_autofs_service(char *autofs_conftype, void (*autofs_dispatch)(struct svc_req *rqstp, SVCXPRT *transp)) { int autofs_socket; SVCXPRT *autofs_xprt = NULL; autofs_socket = socket(AF_INET, SOCK_DGRAM, 0); if (autofs_socket < 0 || bind_resv_port(autofs_socket, NULL) < 0) { plog(XLOG_FATAL, "Can't create privileged autofs port (socket)"); return 1; } if ((autofs_xprt = svcudp_create(autofs_socket)) == NULL) { plog(XLOG_FATAL, "Can't create autofs rpc/udp service"); return 2; } if (autofs_xprt->xp_port >= IPPORT_RESERVED) { plog(XLOG_FATAL, "Can't create privileged autofs port"); return 1; } if (!svc_register(autofs_xprt, AUTOFS_PROG, AUTOFS_VERS, autofs_dispatch, 0)) { plog(XLOG_FATAL, "unable to register (%ld, %ld, 0)", (u_long) AUTOFS_PROG, (u_long) AUTOFS_VERS); return 3; } return 0; /* all is well */ } int unregister_autofs_service(char *autofs_conftype) { svc_unregister(AUTOFS_PROG, AUTOFS_VERS); return 0; } #endif /* HAVE_FS_AUTOFS && AUTOFS_PROG */ am-utils-6.2+rc20110530/conf/transp/transp_tli.c000066400000000000000000000622121157065440000211140ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/transp/transp_tli.c * * TLI specific utilities. * -Erez Zadok */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include struct netconfig *nfsncp; /* * find the IP address that can be used to connect to the local host */ void amu_get_myaddress(struct in_addr *iap, const char *preferred_localhost) { int ret; voidp handlep; struct netconfig *ncp; struct nd_addrlist *addrs = (struct nd_addrlist *) NULL; struct nd_hostserv service; handlep = setnetconfig(); ncp = getnetconfig(handlep); service.h_host = (preferred_localhost ? (char *) preferred_localhost : HOST_SELF_CONNECT); service.h_serv = (char *) NULL; ret = netdir_getbyname(ncp, &service, &addrs); if (ret || !addrs || addrs->n_cnt < 1) { plog(XLOG_FATAL, "cannot get local host address. using 127.0.0.1"); iap->s_addr = htonl(INADDR_LOOPBACK); } else { /* * XXX: there may be more more than one address for this local * host. Maybe something can be done with those. */ struct sockaddr_in *sinp = (struct sockaddr_in *) addrs->n_addrs[0].buf; char dq[20]; if (preferred_localhost) plog(XLOG_INFO, "localhost_address \"%s\" requested, using %s", preferred_localhost, inet_dquad(dq, sizeof(dq), iap->s_addr)); iap->s_addr = sinp->sin_addr.s_addr; /* XXX: used to be htonl() */ } endnetconfig(handlep); /* free's up internal resources too */ netdir_free((voidp) addrs, ND_ADDRLIST); } /* * How to bind to reserved ports. * TLI handle (socket) and port version. */ int bind_resv_port(int td, u_short *pp) { int rc = -1, port; struct t_bind *treq, *tret; struct sockaddr_in *sin; treq = (struct t_bind *) t_alloc(td, T_BIND, T_ADDR); if (!treq) { plog(XLOG_ERROR, "t_alloc req"); return -1; } tret = (struct t_bind *) t_alloc(td, T_BIND, T_ADDR); if (!tret) { t_free((char *) treq, T_BIND); plog(XLOG_ERROR, "t_alloc ret"); return -1; } memset((char *) treq->addr.buf, 0, treq->addr.len); sin = (struct sockaddr_in *) treq->addr.buf; sin->sin_family = AF_INET; treq->qlen = 64; /* 0 is ok for udp, for tcp you need qlen>0 */ treq->addr.len = treq->addr.maxlen; errno = EADDRINUSE; port = IPPORT_RESERVED; do { --port; sin->sin_port = htons(port); rc = t_bind(td, treq, tret); if (rc < 0) { plog(XLOG_ERROR, "t_bind"); } else { if (memcmp(treq->addr.buf, tret->addr.buf, tret->addr.len) == 0) break; else t_unbind(td); } } while ((rc < 0 || errno == EADDRINUSE) && (int) port > IPPORT_RESERVED / 2); if (pp) { if (rc == 0) *pp = port; else plog(XLOG_ERROR, "could not t_bind to any reserved port"); } t_free((char *) tret, T_BIND); t_free((char *) treq, T_BIND); return rc; } /* * close a descriptor, TLI style */ int amu_close(int fd) { return t_close(fd); } /* * Create an rpc client attached to the mount daemon. */ CLIENT * get_mount_client(char *host, struct sockaddr_in *unused_sin, struct timeval *tv, int *sock, u_long mnt_version) { CLIENT *client; struct netbuf nb; struct netconfig *nc = NULL; struct sockaddr_in sin; nb.maxlen = sizeof(sin); nb.buf = (char *) &sin; /* * First try a TCP handler */ /* * Find mountd address on TCP */ if ((nc = getnetconfigent(NC_TCP)) == NULL) { plog(XLOG_ERROR, "getnetconfig for tcp failed: %s", nc_sperror()); goto tryudp; } if (!rpcb_getaddr(MOUNTPROG, mnt_version, nc, &nb, host)) { /* * don't print error messages here, since mountd might legitimately * serve udp only */ goto tryudp; } /* * Create privileged TCP socket */ *sock = t_open(nc->nc_device, O_RDWR, 0); if (*sock < 0) { plog(XLOG_ERROR, "t_open %s: %m", nc->nc_device); goto tryudp; } if (bind_resv_port(*sock, (u_short *) NULL) < 0) plog(XLOG_ERROR, "couldn't bind mountd socket to privileged port"); if ((client = clnt_vc_create(*sock, &nb, MOUNTPROG, mnt_version, 0, 0)) == (CLIENT *) NULL) { plog(XLOG_ERROR, "clnt_vc_create failed"); t_close(*sock); goto tryudp; } /* tcp succeeded */ dlog("get_mount_client: using tcp, port %d", sin.sin_port); if (nc) freenetconfigent(nc); return client; tryudp: /* first free possibly previously allocated netconfig entry */ if (nc) freenetconfigent(nc); /* * TCP failed so try UDP */ /* * Find mountd address on UDP */ if ((nc = getnetconfigent(NC_UDP)) == NULL) { plog(XLOG_ERROR, "getnetconfig for udp failed: %s", nc_sperror()); goto badout; } if (!rpcb_getaddr(MOUNTPROG, mnt_version, nc, &nb, host)) { plog(XLOG_ERROR, "%s", clnt_spcreateerror("couldn't get mountd address on udp")); goto badout; } /* * Create privileged UDP socket */ *sock = t_open(nc->nc_device, O_RDWR, 0); if (*sock < 0) { plog(XLOG_ERROR, "t_open %s: %m", nc->nc_device); goto badout; /* neither tcp not udp succeeded */ } if (bind_resv_port(*sock, (u_short *) NULL) < 0) plog(XLOG_ERROR, "couldn't bind mountd socket to privileged port"); if ((client = clnt_dg_create(*sock, &nb, MOUNTPROG, mnt_version, 0, 0)) == (CLIENT *) NULL) { plog(XLOG_ERROR, "clnt_dg_create failed"); t_close(*sock); goto badout; /* neither tcp not udp succeeded */ } if (clnt_control(client, CLSET_RETRY_TIMEOUT, (char *) tv) == FALSE) { plog(XLOG_ERROR, "clnt_control CLSET_RETRY_TIMEOUT for udp failed"); clnt_destroy(client); goto badout; /* neither tcp not udp succeeded */ } /* udp succeeded */ dlog("get_mount_client: using udp, port %d", sin.sin_port); return client; badout: /* failed */ if (nc) freenetconfigent(nc); return NULL; } #ifdef NOT_NEEDED_ON_TLI_SYSTEMS /* * find the address of the caller of an RPC procedure. */ struct sockaddr_in * amu_svc_getcaller(SVCXPRT *xprt) { /* * On TLI systems we don't use an INET network type, but a "ticlts" (see * /etc/netconfig). This means that packets could only come from the * loopback interface, and we don't need to check them and filter possibly * spoofed packets. Therefore we simply return NULL here, and the caller * will ignore the result. */ return NULL; /* tell called to ignore check */ } #endif /* NOT_NEEDED_ON_TLI_SYSTEMS */ /* * Register an RPC server: * return 1 on success, 0 otherwise. */ int amu_svc_register(SVCXPRT *xprt, u_long prognum, u_long versnum, void (*dispatch)(struct svc_req *rqstp, SVCXPRT *xprt), u_long protocol, struct netconfig *ncp) { /* on TLI: svc_reg returns 1 on success, 0 otherwise */ return svc_reg(xprt, prognum, versnum, dispatch, ncp); } /* * Bind to reserved UDP port, for NFS service only. * Port-only version. */ static int bind_resv_port_only_udp(u_short *pp) { int td, rc = -1, port; struct t_bind *treq, *tret; struct sockaddr_in *sin; extern char *t_errlist[]; extern int t_errno; struct netconfig *nc = (struct netconfig *) NULL; voidp nc_handle; if ((nc_handle = setnetconfig()) == (voidp) NULL) { plog(XLOG_ERROR, "Cannot rewind netconfig: %s", nc_sperror()); return -1; } /* * Search the netconfig table for INET/UDP. * This loop will terminate if there was an error in the /etc/netconfig * file or if you reached the end of the file without finding the udp * device. Either way your machine has probably far more problems (for * example, you cannot have nfs v2 w/o UDP). */ while (1) { if ((nc = getnetconfig(nc_handle)) == (struct netconfig *) NULL) { plog(XLOG_ERROR, "Error accessing getnetconfig: %s", nc_sperror()); endnetconfig(nc_handle); return -1; } if (STREQ(nc->nc_protofmly, NC_INET) && STREQ(nc->nc_proto, NC_UDP)) break; } /* * This is the primary reason for the getnetconfig code above: to get the * correct device name to udp, and t_open a descriptor to be used in * t_bind below. */ td = t_open(nc->nc_device, O_RDWR, (struct t_info *) NULL); endnetconfig(nc_handle); if (td < 0) { plog(XLOG_ERROR, "t_open failed: %d: %s", t_errno, t_errlist[t_errno]); return -1; } treq = (struct t_bind *) t_alloc(td, T_BIND, T_ADDR); if (!treq) { plog(XLOG_ERROR, "t_alloc req"); return -1; } tret = (struct t_bind *) t_alloc(td, T_BIND, T_ADDR); if (!tret) { t_free((char *) treq, T_BIND); plog(XLOG_ERROR, "t_alloc ret"); return -1; } memset((char *) treq->addr.buf, 0, treq->addr.len); sin = (struct sockaddr_in *) treq->addr.buf; sin->sin_family = AF_INET; treq->qlen = 64; /* 0 is ok for udp, for tcp you need qlen>0 */ treq->addr.len = treq->addr.maxlen; errno = EADDRINUSE; if (pp && *pp > 0) { sin->sin_port = htons(*pp); rc = t_bind(td, treq, tret); } else { port = IPPORT_RESERVED; do { --port; sin->sin_port = htons(port); rc = t_bind(td, treq, tret); if (rc < 0) { plog(XLOG_ERROR, "t_bind for port %d: %s", port, t_errlist[t_errno]); } else { if (memcmp(treq->addr.buf, tret->addr.buf, tret->addr.len) == 0) break; else t_unbind(td); } } while ((rc < 0 || errno == EADDRINUSE) && (int) port > IPPORT_RESERVED / 2); if (pp && rc == 0) *pp = port; } t_free((char *) tret, T_BIND); t_free((char *) treq, T_BIND); return rc; } /* * Bind NFS to a reserved port. */ static int bind_nfs_port(int unused_so, u_short *nfs_portp) { u_short port = 0; int error = bind_resv_port_only_udp(&port); if (error == 0) *nfs_portp = port; return error; } /* * Create the nfs service for amd * return 0 (TRUE) if OK, 1 (FALSE) if failed. */ int create_nfs_service(int *soNFSp, u_short *nfs_portp, SVCXPRT **nfs_xprtp, void (*dispatch_fxn)(struct svc_req *rqstp, SVCXPRT *transp)) { char *nettype = "ticlts"; nfsncp = getnetconfigent(nettype); if (nfsncp == NULL) { plog(XLOG_ERROR, "cannot getnetconfigent for %s", nettype); /* failed with ticlts, try plain udp (hpux11) */ nettype = "udp"; nfsncp = getnetconfigent(nettype); if (nfsncp == NULL) { plog(XLOG_ERROR, "cannot getnetconfigent for %s", nettype); return 1; } } *nfs_xprtp = svc_tli_create(RPC_ANYFD, nfsncp, NULL, 0, 0); if (*nfs_xprtp == NULL) { plog(XLOG_ERROR, "cannot create nfs tli service for amd"); return 1; } /* * Get the service file descriptor and check its number to see if * the t_open failed. If it succeeded, then go on to binding to a * reserved nfs port. */ *soNFSp = (*nfs_xprtp)->xp_fd; if (*soNFSp < 0 || bind_nfs_port(*soNFSp, nfs_portp) < 0) { plog(XLOG_ERROR, "Can't create privileged nfs port (TLI)"); svc_destroy(*nfs_xprtp); return 1; } if (svc_reg(*nfs_xprtp, NFS_PROGRAM, NFS_VERSION, dispatch_fxn, NULL) != 1) { plog(XLOG_ERROR, "could not register amd NFS service"); svc_destroy(*nfs_xprtp); return 1; } return 0; /* all is well */ } /* * Bind to preferred AMQ port. */ static int bind_preferred_amq_port(u_short pref_port, const struct netconfig *ncp, struct t_bind **tretpp) { int td = -1, rc = -1; struct t_bind *treq; struct sockaddr_in *sin, *sin2; extern char *t_errlist[]; extern int t_errno; if (!ncp) { plog(XLOG_ERROR, "null ncp"); return -1; } td = t_open(ncp->nc_device, O_RDWR, (struct t_info *) NULL); if (td < 0) { plog(XLOG_ERROR, "t_open failed: %d: %s", t_errno, t_errlist[t_errno]); return -1; } treq = (struct t_bind *) t_alloc(td, T_BIND, T_ADDR); if (!treq) { plog(XLOG_ERROR, "t_alloc req"); return -1; } *tretpp = (struct t_bind *) t_alloc(td, T_BIND, T_ADDR); if (!*tretpp) { t_free((char *) treq, T_BIND); plog(XLOG_ERROR, "t_alloc tretpp"); return -1; } memset((char *) treq->addr.buf, 0, treq->addr.len); sin = (struct sockaddr_in *) treq->addr.buf; sin->sin_family = AF_INET; treq->qlen = 64; /* must be greater than 0 to work for TCP connections */ treq->addr.len = treq->addr.maxlen; if (pref_port > 0) { sin->sin_port = htons(pref_port); sin->sin_addr.s_addr = htonl(INADDR_LOOPBACK); /* XXX: may not be needed */ rc = t_bind(td, treq, *tretpp); if (rc < 0) { plog(XLOG_ERROR, "t_bind return err %d", rc); goto out; } /* check if we got the port we asked for */ sin2 = (struct sockaddr_in *) (*tretpp)->addr.buf; if (sin->sin_port != sin2->sin_port) { plog(XLOG_ERROR, "asked for port %d, got different one (%d)", ntohs(sin->sin_port), ntohs(sin2->sin_port)); t_errno = TNOADDR; /* XXX: is this correct? */ rc = -1; goto out; } if (sin->sin_addr.s_addr != sin2->sin_addr.s_addr) { plog(XLOG_ERROR, "asked for address %x, got different one (%x)", (int) ntohl(sin->sin_addr.s_addr), (int) ntohl(sin2->sin_addr.s_addr)); t_errno = TNOADDR; /* XXX: is this correct? */ rc = -1; goto out; } } out: t_free((char *) treq, T_BIND); return (rc < 0 ? rc : td); } /* * Create the amq service for amd (both TCP and UDP) */ int create_amq_service(int *udp_soAMQp, SVCXPRT **udp_amqpp, struct netconfig **udp_amqncpp, int *tcp_soAMQp, SVCXPRT **tcp_amqpp, struct netconfig **tcp_amqncpp, u_short preferred_amq_port) { /* * (partially) create the amq service for amd * to be completed further in by caller. * XXX: is this "partially" still true?! See amd/nfs_start.c. -Erez */ /* first create the TCP service */ if (tcp_amqncpp) if ((*tcp_amqncpp = getnetconfigent(NC_TCP)) == NULL) { plog(XLOG_ERROR, "cannot getnetconfigent for %s", NC_TCP); return 1; } if (tcp_amqpp) { if (preferred_amq_port > 0) { struct t_bind *tbp = NULL; int sock; plog(XLOG_INFO, "requesting preferred amq TCP port %d", preferred_amq_port); sock = bind_preferred_amq_port(preferred_amq_port, *tcp_amqncpp, &tbp); if (sock < 0) { plog(XLOG_ERROR, "bind_preferred_amq_port failed for TCP port %d: %s", preferred_amq_port, t_errlist[t_errno]); return 1; } *tcp_amqpp = svc_tli_create(sock, *tcp_amqncpp, tbp, 0, 0); if (*tcp_amqpp != NULL) plog(XLOG_INFO, "amq service bound to TCP port %d", preferred_amq_port); t_free((char *) tbp, T_BIND); } else { /* select any port */ *tcp_amqpp = svc_tli_create(RPC_ANYFD, *tcp_amqncpp, NULL, 0, 0); } if (*tcp_amqpp == NULL) { plog(XLOG_ERROR, "cannot create (tcp) tli service for amq"); return 1; } } if (tcp_soAMQp && tcp_amqpp) *tcp_soAMQp = (*tcp_amqpp)->xp_fd; /* next create the UDP service */ if (udp_amqncpp) if ((*udp_amqncpp = getnetconfigent(NC_UDP)) == NULL) { plog(XLOG_ERROR, "cannot getnetconfigent for %s", NC_UDP); return 1; } if (udp_amqpp) { if (preferred_amq_port > 0) { struct t_bind *tbp = NULL; int sock; plog(XLOG_INFO, "requesting preferred amq UDP port %d", preferred_amq_port); sock = bind_preferred_amq_port(preferred_amq_port, *udp_amqncpp, &tbp); if (sock < 0) { plog(XLOG_ERROR, "bind_preferred_amq_port failed for UDP port %d: %s", preferred_amq_port, t_errlist[t_errno]); return 1; } *udp_amqpp = svc_tli_create(sock, *udp_amqncpp, tbp, 0, 0); if (*udp_amqpp != NULL) plog(XLOG_INFO, "amq service bound to UDP port %d", preferred_amq_port); t_free((char *) tbp, T_BIND); } else { /* select any port */ *udp_amqpp = svc_tli_create(RPC_ANYFD, *udp_amqncpp, NULL, 0, 0); } if (*udp_amqpp == NULL) { plog(XLOG_ERROR, "cannot create (udp) tli service for amq"); return 1; } } if (udp_soAMQp && udp_amqpp) *udp_soAMQp = (*udp_amqpp)->xp_fd; return 0; /* all is well */ } /* * Find netconfig info for TCP/UDP device, and fill in the knetconfig * structure. If in_ncp is not NULL, use that instead of defaulting * to a TCP/UDP service. If in_ncp is NULL, then use the service type * specified in nc_protoname (which may be either "tcp" or "udp"). If * nc_protoname is NULL, default to UDP. */ int get_knetconfig(struct knetconfig **kncpp, struct netconfig *in_ncp, char *nc_protoname) { struct netconfig *ncp = NULL; struct stat statbuf; if (in_ncp) ncp = in_ncp; else { if (nc_protoname) ncp = getnetconfigent(nc_protoname); else ncp = getnetconfigent(NC_UDP); } if (!ncp) return -2; *kncpp = (struct knetconfig *) xzalloc(sizeof(struct knetconfig)); if (*kncpp == (struct knetconfig *) NULL) { if (!in_ncp) freenetconfigent(ncp); return -3; } (*kncpp)->knc_semantics = ncp->nc_semantics; (*kncpp)->knc_protofmly = strdup(ncp->nc_protofmly); (*kncpp)->knc_proto = strdup(ncp->nc_proto); if (stat(ncp->nc_device, &statbuf) < 0) { plog(XLOG_ERROR, "could not stat() %s: %m", ncp->nc_device); XFREE(*kncpp); *kncpp = NULL; if (!in_ncp) freenetconfigent(ncp); return -3; /* amd will end (free not needed) */ } (*kncpp)->knc_rdev = (dev_t) statbuf.st_rdev; if (!in_ncp) { /* free only if argument not passed */ freenetconfigent(ncp); ncp = NULL; } return 0; } /* * Free a previously allocated knetconfig structure. */ void free_knetconfig(struct knetconfig *kncp) { if (kncp) { if (kncp->knc_protofmly) XFREE(kncp->knc_protofmly); if (kncp->knc_proto) XFREE(kncp->knc_proto); XFREE(kncp); kncp = (struct knetconfig *) NULL; } } /* * Check if the portmapper is running and reachable: 0==down, 1==up */ int check_pmap_up(char *host, struct sockaddr_in* sin) { CLIENT *client; enum clnt_stat clnt_stat = RPC_TIMEDOUT; /* assume failure */ int socket = RPC_ANYSOCK; struct timeval timeout; timeout.tv_sec = 2; timeout.tv_usec = 0; sin->sin_port = htons(PMAPPORT); client = clntudp_create(sin, PMAPPROG, PMAPVERS, timeout, &socket); if (client == (CLIENT *) NULL) { plog(XLOG_ERROR, "check_pmap_up: cannot create connection to contact portmapper on host \"%s\"%s", host, clnt_spcreateerror("")); return 0; } timeout.tv_sec = 6; /* Ping the portmapper on a remote system by calling the nullproc */ clnt_stat = clnt_call(client, PMAPPROC_NULL, (XDRPROC_T_TYPE) xdr_void, NULL, (XDRPROC_T_TYPE) xdr_void, NULL, timeout); clnt_destroy(client); close(socket); sin->sin_port = 0; if (clnt_stat == RPC_TIMEDOUT) { plog(XLOG_ERROR, "check_pmap_up: failed to contact portmapper on host \"%s\": %s", host, clnt_sperrno(clnt_stat)); return 0; } return 1; } /* * Find the best NFS version for a host. */ u_long get_nfs_version(char *host, struct sockaddr_in *sin, u_long nfs_version, const char *proto) { CLIENT *clnt = NULL; rpcvers_t versout; struct timeval tv; /* * If not set or set wrong, then try from NFS_VERS_MAX on down. If * set, then try from nfs_version on down. */ if (nfs_version <= 0 || nfs_version > NFS_VERS_MAX) { nfs_version = NFS_VERS_MAX; } if (nfs_version == NFS_VERSION) { dlog("get_nfs_version trying NFS(%d,%s) for %s", (int) nfs_version, proto, host); } else { dlog("get_nfs_version trying NFS(%d-%d,%s) for %s", (int) NFS_VERSION, (int) nfs_version, proto, host); } /* 3 seconds is more than enough for a LAN */ memset(&tv, 0, sizeof(tv)); tv.tv_sec = 3; tv.tv_usec = 0; #ifdef HAVE_CLNT_CREATE_VERS_TIMED clnt = clnt_create_vers_timed(host, NFS_PROGRAM, &versout, NFS_VERSION, nfs_version, proto, &tv); #else /* not HAVE_CLNT_CREATE_VERS_TIMED */ clnt = clnt_create_vers(host, NFS_PROGRAM, &versout, NFS_VERSION, nfs_version, proto); #endif /* not HAVE_CLNT_CREATE_VERS_TIMED */ if (clnt == NULL) { if (nfs_version == NFS_VERSION) plog(XLOG_INFO, "get_nfs_version NFS(%d,%s) failed for %s: %s", (int) nfs_version, proto, host, clnt_spcreateerror("")); else plog(XLOG_INFO, "get_nfs_version NFS(%d-%d,%s) failed for %s: %s", (int) NFS_VERSION, (int) nfs_version, proto, host, clnt_spcreateerror("")); return 0; } clnt_destroy(clnt); return versout; } #if defined(HAVE_FS_AUTOFS) && defined(AUTOFS_PROG) /* * find the IP address that can be used to connect autofs service to. */ static int get_autofs_address(struct netconfig *ncp, struct t_bind *tbp) { int ret; struct nd_addrlist *addrs = (struct nd_addrlist *) NULL; struct nd_hostserv service; service.h_host = HOST_SELF_CONNECT; service.h_serv = "autofs"; ret = netdir_getbyname(ncp, &service, &addrs); if (ret) { plog(XLOG_FATAL, "get_autofs_address: cannot get local host address: %s", netdir_sperror()); goto out; } /* * XXX: there may be more more than one address for this local * host. Maybe something can be done with those. */ tbp->addr.len = addrs->n_addrs->len; tbp->addr.maxlen = addrs->n_addrs->len; memcpy(tbp->addr.buf, addrs->n_addrs->buf, addrs->n_addrs->len); /* * qlen should not be zero for TCP connections. It's not clear what it * should be for UDP connections, but setting it to something like 64 seems * to be the safe value that works. */ tbp->qlen = 64; /* all OK */ netdir_free((voidp) addrs, ND_ADDRLIST); out: return ret; } /* * Register the autofs service for amd */ int register_autofs_service(char *autofs_conftype, void (*autofs_dispatch)(struct svc_req *rqstp, SVCXPRT *xprt)) { struct t_bind *tbp = NULL; struct netconfig *autofs_ncp; SVCXPRT *autofs_xprt = NULL; int fd = -1, err = 1; /* assume failed */ plog(XLOG_INFO, "registering autofs service: %s", autofs_conftype); autofs_ncp = getnetconfigent(autofs_conftype); if (autofs_ncp == NULL) { plog(XLOG_ERROR, "register_autofs_service: cannot getnetconfigent for %s", autofs_conftype); goto out; } fd = t_open(autofs_ncp->nc_device, O_RDWR, NULL); if (fd < 0) { plog(XLOG_ERROR, "register_autofs_service: t_open failed (%s)", t_errlist[t_errno]); goto out; } tbp = (struct t_bind *) t_alloc(fd, T_BIND, T_ADDR); if (!tbp) { plog(XLOG_ERROR, "register_autofs_service: t_alloc failed"); goto out; } if (get_autofs_address(autofs_ncp, tbp) != 0) { plog(XLOG_ERROR, "register_autofs_service: get_autofs_address failed"); goto out; } autofs_xprt = svc_tli_create(fd, autofs_ncp, tbp, 0, 0); if (autofs_xprt == NULL) { plog(XLOG_ERROR, "cannot create autofs tli service for amd"); goto out; } rpcb_unset(AUTOFS_PROG, AUTOFS_VERS, autofs_ncp); if (svc_reg(autofs_xprt, AUTOFS_PROG, AUTOFS_VERS, autofs_dispatch, autofs_ncp) == FALSE) { plog(XLOG_ERROR, "could not register amd AUTOFS service"); goto out; } err = 0; goto really_out; out: if (autofs_ncp) freenetconfigent(autofs_ncp); if (autofs_xprt) SVC_DESTROY(autofs_xprt); else { if (fd > 0) t_close(fd); } really_out: if (tbp) t_free((char *) tbp, T_BIND); dlog("register_autofs_service: returning %d\n", err); return err; } int unregister_autofs_service(char *autofs_conftype) { struct netconfig *autofs_ncp; int err = 1; plog(XLOG_INFO, "unregistering autofs service listener: %s", autofs_conftype); autofs_ncp = getnetconfigent(autofs_conftype); if (autofs_ncp == NULL) { plog(XLOG_ERROR, "destroy_autofs_service: cannot getnetconfigent for %s", autofs_conftype); goto out; } out: rpcb_unset(AUTOFS_PROG, AUTOFS_VERS, autofs_ncp); return err; } #endif /* HAVE_FS_AUTOFS && AUTOFS_PROG */ am-utils-6.2+rc20110530/conf/trap/000077500000000000000000000000001157065440000162255ustar00rootroot00000000000000am-utils-6.2+rc20110530/conf/trap/trap_aix3.h000066400000000000000000000006061157065440000202720ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_aix3.h */ extern int mount_aix3(char *fsname, char *dir, int flags, int type, void *data, char *mnt_opts); #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount_aix3(mnt->mnt_fsname, mnt->mnt_dir, flags, type, mnt_data, mnt->mnt_opts) /* there is no other better place for this missing external definition */ extern int uvmount(int VirtualFileSystemID, int Flag); am-utils-6.2+rc20110530/conf/trap/trap_aux.h000066400000000000000000000002001157065440000202110ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_aux.h */ #define MOUNT_TRAP(type, mnt, flags, mnt_data) fsmount(type, mnt->mnt_dir, flags, mnt_data) am-utils-6.2+rc20110530/conf/trap/trap_default.h000066400000000000000000000002011157065440000210410ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_default.h */ #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount(type, mnt->mnt_dir, flags, mnt_data) am-utils-6.2+rc20110530/conf/trap/trap_dgux.h000066400000000000000000000002041157065440000203670ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_dgux.h */ #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount_dgux(type, mnt->mnt_dir, flags, mnt_data) am-utils-6.2+rc20110530/conf/trap/trap_hcx.h000066400000000000000000000002051157065440000202030ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_hcx.h */ #define MOUNT_TRAP(type, mnt, flags, mnt_data) mountsyscall(type, mnt->mnt_dir, flags, mnt_data) am-utils-6.2+rc20110530/conf/trap/trap_hpux.h000066400000000000000000000011041157065440000204040ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_hpux.h */ extern int mount_hpux(MTYPE_TYPE type, const char *dir, int flags, caddr_t data); #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount_hpux(type, mnt->mnt_dir, flags, mnt_data) /* * HPUX 9.x does is not even consistently inconsistent with itself. * It defines an integer mount type for PCFS, but not a string type as * with all other mount types. * * XXX: remove this ugly hack when HPUX 9.0 is defunct. */ #if MOUNT_TYPE_PCFS == MOUNT_PC # undef MOUNT_TYPE_PCFS # define MOUNT_TYPE_PCFS "pcfs" #endif /* MOUNT_TYPE_PCFS == MOUNT_PC */ am-utils-6.2+rc20110530/conf/trap/trap_irix.h000066400000000000000000000003551157065440000204020ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_irix.h */ extern int mount_irix(char *fsname, char *dir, int flags, MTYPE_TYPE type, voidp data); #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount_irix(mnt->mnt_fsname, mnt->mnt_dir, flags, type, mnt_data) am-utils-6.2+rc20110530/conf/trap/trap_isc3.h000066400000000000000000000003461157065440000202700ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_isc3.h */ extern int mount_isc3(char *fsname, char *dir, int flags, int type, void *data); #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount_isc3(mnt->mnt_fsname, mnt->mnt_dir, flags, type, mnt_data) am-utils-6.2+rc20110530/conf/trap/trap_linux.h000066400000000000000000000003161157065440000205630ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_linux.h */ extern int mount_linux(MTYPE_TYPE type, mntent_t *mnt, int flags, caddr_t data); #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount_linux(type, mnt, flags, mnt_data) am-utils-6.2+rc20110530/conf/trap/trap_mach3.h000066400000000000000000000003101157065440000204110ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_mach3.h */ extern int mount_mach3(char *type, char *mnt, int flags, caddr_t mnt_data); #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount_mach(type, mnt, flags, mnt_data) am-utils-6.2+rc20110530/conf/trap/trap_netbsd.h000066400000000000000000000004161157065440000207040ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_netbsd.h */ #if __NetBSD_Version__ >= 499002300 #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount(type, mnt->mnt_dir, flags, mnt_data, 0) #else #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount(type, mnt->mnt_dir, flags, mnt_data) #endif am-utils-6.2+rc20110530/conf/trap/trap_news4.h000066400000000000000000000002231157065440000204610ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_news4.h */ #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount(type, mnt->mnt_dir, M_NEWTYPE | flags, mnt_data) am-utils-6.2+rc20110530/conf/trap/trap_rtu6.h000066400000000000000000000002001157065440000203140ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_rtu6.h */ #define MOUNT_TRAP(type, mnt, flags, mnt_data) vmount(type, mnt->mnt_dir, flags, mnt_data) am-utils-6.2+rc20110530/conf/trap/trap_stellix.h000066400000000000000000000003571157065440000211150ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_stellix.h */ extern int mount_stellix(char *fsname, char *dir, int flags, int type, void *data); #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount_stellix(mnt->mnt_fsname, mnt->mnt_dir, flags, type, mnt_data) am-utils-6.2+rc20110530/conf/trap/trap_svr4.h000066400000000000000000000004221157065440000203200ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_svr4.h */ extern int mount_svr4(char *fsname, char *dir, int flags, MTYPE_TYPE type, caddr_t data, const char *optstr); #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount_svr4(mnt->mnt_fsname, mnt->mnt_dir, flags, type, mnt_data, mnt->mnt_opts) am-utils-6.2+rc20110530/conf/trap/trap_ultrix.h000066400000000000000000000003111157065440000207460ustar00rootroot00000000000000/* $srcdir/conf/trap/trap_ultrix.h */ /* arg 3 to mount(2) is rwflag */ #define MOUNT_TRAP(type, mnt, flags, mnt_data) mount(mnt->mnt_fsname, mnt->mnt_dir, flags & MNT2_GEN_OPT_RONLY, type, mnt_data) am-utils-6.2+rc20110530/conf/umount/000077500000000000000000000000001157065440000166065ustar00rootroot00000000000000am-utils-6.2+rc20110530/conf/umount/umount_aix.c000066400000000000000000000141741157065440000211510ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/umount/umount_aix.c * */ /* * AIX method of unmounting filesystems. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include int umount_fs(char *mntdir, const char *mnttabname, u_int unmount_flags) { mntlist *mlist, *mp, *mp_save = NULL; int error = 0; mp = mlist = read_mtab(mntdir, mnttabname); /* * Search the mount table looking for * the correct (ie last) matching entry */ while (mp) { if (STREQ(mp->mnt->mnt_dir, mntdir)) mp_save = mp; mp = mp->mnext; } if (mp_save) { dlog("Trying unmount(%s)", mp_save->mnt->mnt_dir); #ifdef MOUNT_TABLE_ON_FILE /* * This unmount may hang leaving this process with an exclusive lock on * /etc/mtab. Therefore it is necessary to unlock mtab, do the unmount, * then lock mtab (again) and reread it and finally update it. */ unlock_mntlist(); #endif /* MOUNT_TABLE_ON_FILE */ #ifdef NEED_AUTOFS_SPACE_HACK if (unmount_flags & AMU_UMOUNT_AUTOFS) { char *mnt_dir_save = mp_save->mnt->mnt_dir; mp_save->mnt->mnt_dir = autofs_strdup_space_hack(mnt_dir_save); error = UNMOUNT_TRAP(mp_save->mnt); XFREE(mp_save->mnt->mnt_dir); mp_save->mnt->mnt_dir = mnt_dir_save; } else #endif /* NEED_AUTOFS_SPACE_HACK */ error = UNMOUNT_TRAP(mp_save->mnt); if (error < 0) { switch ((error = errno)) { case EINVAL: case ENOTBLK: plog(XLOG_WARNING, "unmount: %s is not mounted", mp_save->mnt->mnt_dir); error = 0; /* Not really an error */ break; case ENOENT: /* * This could happen if the kernel insists on following symlinks * when we try to unmount a direct mountpoint. We need to propagate * the error up so that the top layers know it failed and don't * try to rmdir() the mountpoint or other silly things. */ plog(XLOG_ERROR, "mount point %s: %m", mp_save->mnt->mnt_dir); break; #if defined(MNT2_GEN_OPT_FORCE) && defined(HAVE_UVMOUNT) case EBUSY: case EIO: case ESTALE: /* caller determines if forced unmounts should be used */ if (unmount_flags & AMU_UMOUNT_FORCE) { error = umount2_fs(mntdir, unmount_flags); if (error < 0) error = errno; else break; /* all is OK */ } /* fallthrough */ #endif /* MNT2_GEN_OPT_FORCE && HAVE_UVMOUNT */ default: dlog("%s: unmount: %m", mp_save->mnt->mnt_dir); break; } } dlog("Finished unmount(%s)", mp_save->mnt->mnt_dir); if (!error) { #ifdef MOUNT_TABLE_ON_FILE free_mntlist(mlist); mp = mlist = read_mtab(mntdir, mnttabname); /* * Search the mount table looking for * the correct (ie last) matching entry */ mp_save = NULL; while (mp) { if (STREQ(mp->mnt->mnt_dir, mntdir)) mp_save = mp; mp = mp->mnext; } if (mp_save) { mnt_free(mp_save->mnt); mp_save->mnt = NULL; rewrite_mtab(mlist, mnttabname); } #endif /* MOUNT_TABLE_ON_FILE */ } } else { plog(XLOG_ERROR, "Couldn't find how to unmount %s", mntdir); /* * Assume it is already unmounted */ error = 0; } /* end of "if (mp_save)" statement */ free_mntlist(mlist); return error; } #if defined(MNT2_GEN_OPT_FORCE) && defined(HAVE_UVMOUNT) /* force unmount, no questions asked, without touching mnttab file */ int umount2_fs(const char *mntdir, u_int unmount_flags) { int error = 0; #if 0 u_int vfs_id = 0; #endif /* 0 */ if (unmount_flags & AMU_UMOUNT_FORCE) { plog(XLOG_INFO, "**UNIMPLEMENTED**: umount2_fs: trying unmount/forced on %s", mntdir); #if 0 /* * XXX: need to implement. Call read_mtab and search mntlist for VFS ID * of mntdir, then pass that ID to uvmount(), then call free_mntlist(). */ error = uvmount(vfs_id, MNT2_GEN_OPT_FORCE); /* AIX */ if (error < 0 && (errno == EINVAL || errno == ENOENT)) error = 0; /* ignore EINVAL/ENOENT */ if (error < 0) plog(XLOG_WARNING, "%u: unmount/force: %m", vfs_id); else dlog("%s: unmount/force: OK", mntdir); #endif /* 0 */ } return error; } #endif /* MNT2_GEN_OPT_FORCE && HAVE_UVMOUNT */ am-utils-6.2+rc20110530/conf/umount/umount_bsd44.c000066400000000000000000000074141157065440000213070ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/umount/umount_bsd44.c * */ /* * Unmounting filesystems under BSD 4.4. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include int umount_fs(char *mntdir, const char *mnttabname, u_int unmount_flags) { int error; eintr: error = unmount(mntdir, 0); if (error < 0) error = errno; switch (error) { case EINVAL: case ENOTBLK: case ENOENT: plog(XLOG_WARNING, "unmount: %s is not mounted", mntdir); error = 0; /* Not really an error */ break; case EINTR: /* not sure why this happens, but it does. ask kirk one day... */ dlog("%s: unmount: %m", mntdir); goto eintr; #ifdef MNT2_GEN_OPT_FORCE case EBUSY: case EIO: case ESTALE: /* caller determines if forced unmounts should be used */ if (unmount_flags & AMU_UMOUNT_FORCE) { error = umount2_fs(mntdir, unmount_flags); if (error < 0) error = errno; else return error; } /* fallthrough */ #endif /* MNT2_GEN_OPT_FORCE */ default: dlog("%s: unmount: %m", mntdir); break; } return error; } #ifdef MNT2_GEN_OPT_FORCE /* force unmount, no questions asked, without touching mnttab file */ int umount2_fs(const char *mntdir, u_int unmount_flags) { int error = 0; if (unmount_flags & AMU_UMOUNT_FORCE) { plog(XLOG_INFO, "umount2_fs: trying unmount/forced on %s", mntdir); error = unmount(mntdir, MNT2_GEN_OPT_FORCE); if (error < 0 && (errno == EINVAL || errno == ENOENT)) error = 0; /* ignore EINVAL/ENOENT */ if (error < 0) plog(XLOG_WARNING, "%s: unmount/force: %m", mntdir); else dlog("%s: unmount/force: OK", mntdir); } return error; } #endif /* MNT2_GEN_OPT_FORCE */ am-utils-6.2+rc20110530/conf/umount/umount_default.c000066400000000000000000000136151157065440000220130ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/umount/umount_default.c * */ /* * Default method of unmounting filesystems. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include int umount_fs(char *mntdir, const char *mnttabname, u_int unmount_flags) { mntlist *mlist, *mp, *mp_save = NULL; int error = 0; mp = mlist = read_mtab(mntdir, mnttabname); /* * Search the mount table looking for * the correct (ie last) matching entry */ while (mp) { if (STREQ(mp->mnt->mnt_dir, mntdir)) mp_save = mp; mp = mp->mnext; } if (mp_save) { dlog("Trying unmount(%s)", mp_save->mnt->mnt_dir); #ifdef MOUNT_TABLE_ON_FILE /* * This unmount may hang leaving this process with an exclusive lock on * /etc/mtab. Therefore it is necessary to unlock mtab, do the unmount, * then lock mtab (again) and reread it and finally update it. */ unlock_mntlist(); #endif /* MOUNT_TABLE_ON_FILE */ #ifdef NEED_AUTOFS_SPACE_HACK if (unmount_flags & AMU_UMOUNT_AUTOFS) { char *mnt_dir_save = mp_save->mnt->mnt_dir; mp_save->mnt->mnt_dir = autofs_strdup_space_hack(mnt_dir_save); error = UNMOUNT_TRAP(mp_save->mnt); XFREE(mp_save->mnt->mnt_dir); mp_save->mnt->mnt_dir = mnt_dir_save; } else #endif /* NEED_AUTOFS_SPACE_HACK */ error = UNMOUNT_TRAP(mp_save->mnt); if (error < 0) { switch ((error = errno)) { case EINVAL: case ENOTBLK: plog(XLOG_WARNING, "unmount: %s is not mounted", mp_save->mnt->mnt_dir); error = 0; /* Not really an error */ break; case ENOENT: /* * This could happen if the kernel insists on following symlinks * when we try to unmount a direct mountpoint. We need to propagate * the error up so that the top layers know it failed and don't * try to rmdir() the mountpoint or other silly things. */ plog(XLOG_ERROR, "mount point %s: %m", mp_save->mnt->mnt_dir); break; #if defined(MNT2_GEN_OPT_FORCE) && defined(HAVE_UMOUNT2) case EBUSY: case EIO: case ESTALE: /* caller determines if forced unmounts should be used */ if (unmount_flags & AMU_UMOUNT_FORCE) { error = umount2_fs(mntdir, unmount_flags); if (error < 0) error = errno; else break; /* all is OK */ } /* fallthrough */ #endif /* MNT2_GEN_OPT_FORCE && HAVE_UMOUNT2 */ default: dlog("%s: unmount: %m", mp_save->mnt->mnt_dir); break; } } dlog("Finished unmount(%s)", mp_save->mnt->mnt_dir); if (!error) { #ifdef MOUNT_TABLE_ON_FILE free_mntlist(mlist); mp = mlist = read_mtab(mntdir, mnttabname); /* * Search the mount table looking for * the correct (ie last) matching entry */ mp_save = NULL; while (mp) { if (STREQ(mp->mnt->mnt_dir, mntdir)) mp_save = mp; mp = mp->mnext; } if (mp_save) { mnt_free(mp_save->mnt); mp_save->mnt = NULL; rewrite_mtab(mlist, mnttabname); } #endif /* MOUNT_TABLE_ON_FILE */ } } else { plog(XLOG_ERROR, "Couldn't find how to unmount %s", mntdir); /* * Assume it is already unmounted */ error = 0; } /* end of "if (mp_save)" statement */ free_mntlist(mlist); return error; } #if defined(MNT2_GEN_OPT_FORCE) && defined(HAVE_UMOUNT2) /* force unmount, no questions asked, without touching mnttab file */ int umount2_fs(const char *mntdir, u_int unmount_flags) { int error = 0; if (unmount_flags & AMU_UMOUNT_FORCE) { plog(XLOG_INFO, "umount2_fs: trying unmount/forced on %s", mntdir); error = umount2(mntdir, MNT2_GEN_OPT_FORCE); /* Solaris */ if (error < 0 && (errno == EINVAL || errno == ENOENT)) error = 0; /* ignore EINVAL/ENOENT */ if (error < 0) plog(XLOG_WARNING, "%s: unmount/force: %m", mntdir); else dlog("%s: unmount/force: OK", mntdir); } return error; } #endif /* MNT2_GEN_OPT_FORCE && HAVE_UMOUNT2 */ am-utils-6.2+rc20110530/conf/umount/umount_linux.c000066400000000000000000000205431157065440000215240ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/umount/umount_linux.c * */ /* * Linux method of unmounting filesystems: if umount(2) failed with EIO or * ESTALE, try umount2(2) with MNT_FORCE+MNT_DETACH. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include int umount_fs(char *mntdir, const char *mnttabname, u_int unmount_flags) { mntlist *mlist, *mp, *mp_save = NULL; int error = 0; #ifdef HAVE_LOOP_DEVICE char *opt, *xopts = NULL; char loopstr[] = "loop="; char *loopdev; #endif /* HAVE_LOOP_DEVICE */ mp = mlist = read_mtab(mntdir, mnttabname); /* * Search the mount table looking for * the correct (ie last) matching entry */ while (mp) { if (STREQ(mp->mnt->mnt_dir, mntdir)) mp_save = mp; mp = mp->mnext; } if (!mp_save) { plog(XLOG_ERROR, "Couldn't find how to unmount %s", mntdir); /* Assume it is already unmounted */ error = 0; goto out; } dlog("Trying unmount(%s)", mp_save->mnt->mnt_dir); #ifdef MOUNT_TABLE_ON_FILE /* * This unmount may hang leaving this process with an exclusive lock on * /etc/mtab. Therefore it is necessary to unlock mtab, do the unmount, * then lock mtab (again) and reread it and finally update it. */ unlock_mntlist(); #endif /* MOUNT_TABLE_ON_FILE */ #if defined(HAVE_UMOUNT2) && defined(MNT2_GEN_OPT_DETACH) /* * If user asked to try forced unmounts, then do a quick check to see if * the mount point is hung badly. If so, then try to detach it by * force; if the latter works, we're done. */ if (unmount_flags & AMU_UMOUNT_DETACH) { /* * Note: we pass both DETACH and FORCE flags, because umount2_fs below * (on Linux), should try FORCE before DETACH (the latter always * succeeds). */ error = umount2_fs(mp_save->mnt->mnt_dir, unmount_flags & (AMU_UMOUNT_DETACH|AMU_UMOUNT_FORCE)); } else #endif /* defined(HAVE_UMOUNT2) && defined(MNT2_GEN_OPT_DETACH) */ error = UNMOUNT_TRAP(mp_save->mnt); if (error < 0) { plog(XLOG_WARNING, "unmount(%s) failed: %m", mp_save->mnt->mnt_dir); switch ((error = errno)) { case EINVAL: case ENOTBLK: plog(XLOG_WARNING, "unmount: %s is not mounted", mp_save->mnt->mnt_dir); error = 0; /* Not really an error */ break; case ENOENT: /* * This could happen if the kernel insists on following symlinks * when we try to unmount a direct mountpoint. We need to propagate * the error up so that the top layers know it failed and don't * try to rmdir() the mountpoint or other silly things. */ plog(XLOG_ERROR, "mount point %s: %m", mp_save->mnt->mnt_dir); break; #if defined(HAVE_UMOUNT2) && defined(MNT2_GEN_OPT_FORCE) case EBUSY: /* * Caller determines if forced unmounts should be used now (for * EBUSY). If caller asked to force an unmount, *and* the above * "trivial" unmount attempt failed with EBUSY, then try to force * the unmount. */ if (unmount_flags & AMU_UMOUNT_FORCE) { error = umount2_fs(mp_save->mnt->mnt_dir, unmount_flags & AMU_UMOUNT_FORCE); if (error < 0) { plog(XLOG_WARNING, "%s: unmount/force: %m", mp_save->mnt->mnt_dir); error = errno; } } break; #endif /* defined(HAVE_UMOUNT2) && defined(MNT2_GEN_OPT_FORCE) */ default: dlog("%s: unmount: %m", mp_save->mnt->mnt_dir); break; } } else { dlog("unmount(%s) succeeded", mp_save->mnt->mnt_dir); } dlog("Finished unmount(%s)", mp_save->mnt->mnt_dir); /* * If we are successful or there was an ENOENT, remove * the mount entry from the mtab file. */ if (error && error != ENOENT) goto out; #ifdef HAVE_LOOP_DEVICE /* look for loop=/dev/loopX in mnt_opts */ xopts = strdup(mp_save->mnt->mnt_opts); /* b/c strtok is destructive */ for (opt = strtok(xopts, ","); opt; opt = strtok(NULL, ",")) if (NSTREQ(opt, loopstr, sizeof(loopstr) - 1)) { loopdev = opt + sizeof(loopstr) - 1; if (delete_loop_device(loopdev) < 0) plog(XLOG_WARNING, "unmount() failed to release loop device %s: %m", loopdev); else plog(XLOG_INFO, "unmount() released loop device %s OK", loopdev); break; } if (xopts) XFREE(xopts); #endif /* HAVE_LOOP_DEVICE */ #ifdef MOUNT_TABLE_ON_FILE free_mntlist(mlist); mp = mlist = read_mtab(mntdir, mnttabname); /* * Search the mount table looking for * the correct (ie last) matching entry */ mp_save = NULL; while (mp) { if (STREQ(mp->mnt->mnt_dir, mntdir)) mp_save = mp; mp = mp->mnext; } if (mp_save) { mnt_free(mp_save->mnt); mp_save->mnt = NULL; rewrite_mtab(mlist, mnttabname); } #endif /* MOUNT_TABLE_ON_FILE */ out: free_mntlist(mlist); return error; } #if defined(HAVE_UMOUNT2) && (defined(MNT2_GEN_OPT_FORCE) || defined(MNT2_GEN_OPT_DETACH)) /* * Force unmount, no questions asked, without touching mnttab file. Try * detach first because it is safer: will remove the hung mnt point without * affecting hung applications. "Force" is more risky: it will cause the * kernel to return EIO to applications stuck on a stat(2) of Amd. */ int umount2_fs(const char *mntdir, u_int unmount_flags) { int error = 0; #ifdef MNT2_GEN_OPT_DETACH if (unmount_flags & AMU_UMOUNT_DETACH) { error = umount2(mntdir, MNT2_GEN_OPT_DETACH); if (error < 0 && (errno == EINVAL || errno == ENOENT)) error = 0; /* ignore EINVAL/ENOENT */ if (error < 0) { /* don't try FORCE if detach succeeded */ plog(XLOG_WARNING, "%s: unmount/detach: %m", mntdir); /* fall through to try "force" (if flag specified) */ } else { dlog("%s: unmount/detach: OK", mntdir); return error; } } #endif /* MNT2_GEN_OPT_DETACH */ #ifdef MNT2_GEN_OPT_FORCE if (unmount_flags & AMU_UMOUNT_FORCE) { plog(XLOG_INFO, "umount2_fs: trying unmount/forced on %s", mntdir); error = umount2(mntdir, MNT2_GEN_OPT_FORCE); if (error < 0 && (errno == EINVAL || errno == ENOENT)) error = 0; /* ignore EINVAL/ENOENT */ if (error < 0) plog(XLOG_WARNING, "%s: unmount/force: %m", mntdir); else dlog("%s: unmount/force: OK", mntdir); /* fall through to return whatever error we got (if any) */ } #endif /* MNT2_GEN_OPT_FORCE */ return error; } #endif /* HAVE_UMOUNT2 && (MNT2_GEN_OPT_FORCE || MNT2_GEN_OPT_DETACH) */ am-utils-6.2+rc20110530/conf/umount/umount_osf.c000066400000000000000000000075741157065440000211650ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/conf/umount/umount_osf.c * */ /* * Unmounting filesystems under OSF. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include int umount_fs(char *mntdir, const char *mnttabname, u_int unmount_flags) { int error; eintr: error = umount(mntdir, MNT_NOFORCE); if (error < 0) error = errno; switch (error) { case EINVAL: case ENOTBLK: plog(XLOG_WARNING, "unmount: %s is not mounted", mntdir); error = 0; /* Not really an error */ break; case ENOENT: plog(XLOG_ERROR, "mount point %s: %m", mntdir); break; case EINTR: /* not sure why this happens, but it does. ask kirk one day... */ dlog("%s: unmount: %m", mntdir); goto eintr; #ifdef MNT2_GEN_OPT_FORCE case EBUSY: case EIO: case ESTALE: /* caller determines if forced unmounts should be used */ if (unmount_flags & AMU_UMOUNT_FORCE) { error = umount2_fs(mntdir, unmount_flags); if ((error = umount2_fs(mntdir, unmount_flags)) < 0) error = errno; else return error; } /* fallthrough */ #endif /* MNT2_GEN_OPT_FORCE */ default: dlog("%s: unmount: %m", mntdir); break; } return error; } #ifdef MNT2_GEN_OPT_FORCE /* force unmount, no questions asked, without touching mnttab file */ int umount2_fs(const char *mntdir, u_int unmount_flags) { int error = 0; if (unmount_flags & AMU_UMOUNT_FORCE) { plog(XLOG_INFO, "umount2_fs: trying unmount/forced on %s", mntdir); error = umount((char *)mntdir, MNT2_GEN_OPT_FORCE); if (error < 0 && (errno == EINVAL || errno == ENOENT)) error = 0; /* ignore EINVAL/ENOENT */ if (error < 0) plog(XLOG_WARNING, "%s: unmount/force: %m", mntdir); else dlog("%s: unmount/force: OK", mntdir); } return error; } #endif /* MNT2_GEN_OPT_FORCE */ am-utils-6.2+rc20110530/config.guess000077500000000000000000001276151157065440000166660ustar00rootroot00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # Free Software Foundation, Inc. timestamp='2009-11-20' # This file 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 of the License, 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., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[456]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) case ${UNAME_MACHINE} in pc98) echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else echo ${UNAME_MACHINE}-unknown-linux-gnueabi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: am-utils-6.2+rc20110530/config.guess.long000077500000000000000000000041361157065440000176140ustar00rootroot00000000000000#!/bin/sh # generate long version of output from config.guess # part of am-utils-6.x # Erez Zadok # #set -x # find a single word that prints the version number of the release getver () { l=`head $1` set $l for i in $* do case "$i" in # look for one digit followed by a sequence of non-spaces # so it'll catch 7.3 as well as 2.1AW *[0-9]* ) echo $i; return ;; esac done } if test "x$GCONFIG" = "x" ; then # find dirname of this script base=`echo $0 | sed 's/\/[^\/]*$//' 2>/dev/null` PATH=$base:$PATH export PATH GCONFIG=`config.guess || echo unknown-config` fi case "${GCONFIG}" in *linux* ) GCONFIG=`echo ${GCONFIG} | sed -e 's/i.86/i386/' -e 's/linux-gnu/linux/'` if test -f /etc/redhat-release ; then long=`getver /etc/redhat-release` if grep 'Red Hat Enterprise Linux' /etc/redhat-release > /dev/null 2>&1 ; then echo ${GCONFIG}-rhel${long} elif grep 'Fedora ' /etc/redhat-release > /dev/null 2>&1 ; then echo ${GCONFIG}-fc${long} elif grep 'CentOS' /etc/redhat-release > /dev/null 2>&1 ; then echo ${GCONFIG}-centos${long} else echo ${GCONFIG}-rh${long} fi exit 0 elif test -f /etc/SuSE-release ; then long=`getver /etc/SuSE-release` if grep 'Enterprise Server' /etc/SuSE-release > /dev/null 2>&1 ; then echo ${GCONFIG}-sles${long} else echo ${GCONFIG}-suse${long} fi exit 0 elif test -f /etc/debian_version ; then long=`getver /etc/debian_version` echo ${GCONFIG}-deb${long} exit 0 elif test -f /etc/gentoo-release ; then long=`getver /etc/gentoo-release` echo ${GCONFIG}-gentoo${long} exit 0 elif test -f /etc/yellowdog-release ; then long=`getver /etc/yellowdog-release` echo ${GCONFIG}-yellowdog${long} exit 0 else echo ${GCONFIG} fi ;; *netbsdelf3* ) # remove trailing '.' from beta echo ${GCONFIG} | sed 's/\.$//g' ;; *solaris* ) if grep -i nexentaos /etc/release > /dev/null 2>&1 ; then echo ${GCONFIG}-nexentaos else echo ${GCONFIG} fi ;; * ) echo ${GCONFIG} ;; esac exit 0 am-utils-6.2+rc20110530/config.sub000077500000000000000000001031671157065440000163250ustar00rootroot00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # Free Software Foundation, Inc. timestamp='2009-11-20' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file 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 of the License, 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., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nios | nios2 \ | ns16k | ns32k \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | ubicom32 \ | v850 | v850e \ | we32k \ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | picochip) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tile*) basic_machine=tile-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: am-utils-6.2+rc20110530/configure.in000066400000000000000000001222061157065440000166460ustar00rootroot00000000000000dnl configure.in file for am-utils-6.x dnl Contains general GNU-autoconf macros. dnl Author: Erez Zadok dnl dnl ###################################################################### dnl UNCOMMENT THE NEXT FEW LINES FOR DEBUGGING CONFIGURE dnl define([AC_CACHE_LOAD], )dnl dnl define([AC_CACHE_SAVE], )dnl dnl ====================================================================== dnl ###################################################################### dnl INITIALIZATION dnl AC_INIT dnl new init style: PACKAGE, VERSION, BUG-REPORTING-ADDRESS AC_INIT([am-utils], sinclude([vers.m4]), [https://bugzilla.am-utils.org/ or am-utils@am-utils.org]) AC_MSG_NOTICE(*** INITIALIZATION ***) AC_CONFIG_SRCDIR([amd/amd.c]) AC_CONFIG_MACRO_DIR([m4]) AM_CONFIG_HEADER(config.h) AH_TOP([ /* * Start of am-utils-6.x config.h file. * Erez Zadok * * DO NOT EDIT BY HAND. * Note: generated by autoheader from configure.in. */ #ifndef _CONFIG_H #define _CONFIG_H ]) dnl add actual "#undef" commands into m4/macros/header_templates.m4 AH_BOTTOM([ /****************************************************************************/ /*** INCLUDE localconfig.h if it exists, to allow users to make some ***/ /*** compile time configuration changes. ***/ /****************************************************************************/ /* does a local configuration file exist? */ #undef HAVE_LOCALCONFIG_H #ifdef HAVE_LOCALCONFIG_H # include #endif /* HAVE_LOCALCONFIG_H */ #endif /* not _CONFIG_H */ /* * Local Variables: * mode: c * End: */ /* End of am-utils-6.x config.h file */ ]) dnl dnl AC_CONFIG_AUX_DIR(m4) AC_PREREQ(2.52) AC_REVISION($Revision: 1.134 $) AC_COPYRIGHT([Copyright (c) 1997-2011 Erez Zadok]) dnl find out system type AC_MSG_NOTICE(*** SYSTEM TYPES ***) dnl run by libtool, but must be kept here because HOST_MACROS depends on it AC_CANONICAL_HOST AMU_HOST_MACROS dnl ====================================================================== dnl ###################################################################### dnl PACKAGE NAME AND VERSION AC_MSG_NOTICE(*** PACKAGE NAME AND VERSION ***) AMU_PACKAGE_NAME($PACKAGE_NAME) AMU_PACKAGE_VERSION($PACKAGE_VERSION) AMU_PACKAGE_BUGREPORT($PACKAGE_BUGREPORT) AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION) dnl SET (shared) library version. Update it only before major release! dnl Clarification: dnl The major number should change when an incompatible change is made to dnl the API; the minor number should change when an API is added; the patch dnl level should change when an internal implementation change is made that dnl does not affect the API. dnl dnl In other words: if the major changes, the library is incompatible with dnl older ones; if the minor changes, the library is backwards compatible dnl with libraries using the same major; if the patchlevel changes, the dnl library is backward and forward compatible with libraries using the same dnl major and minor. dnl dnl For sanity, the lower numbers should be set to 0 when a higher number dnl is changed. dnl last version info was 3:2:1 (am-utils-6.0.2) dnl last version info was 4:0:2 (am-utils-6.0.3) dnl last version info was 4:1:2 (am-utils-6.0.4) dnl last version info was 3:0:0 (am-utils-6.1, should have been updated) dnl dnl We increase the major number for am-utils-6.1, because it has new API's dnl and removes some old API's. LIBTOOL_LDFLAGS="-version-info 4:0:0" AC_SUBST(LIBTOOL_LDFLAGS) dnl ====================================================================== dnl ###################################################################### dnl ALTERNATIVE PROGRAMS dnl Part 1: these are required before "unix variants" dnl ====================================================================== dnl Particular Program Checks AC_MSG_NOTICE(*** PARTICULAR PROGRAMS (part 1) ***) dnl AC-PROG-LIBTOOL will run this, but we need this to squelch warnings dnl from autoconf about AMU_TRY_COMPILE running before AC_AIX/AC_ISC_POSIX AC_PROG_CC AC_PROG_CPP AC_PROG_CC_C_O AC_PROG_GCC_TRADITIONAL AC_PROG_MAKE_SET AC_ISC_POSIX AC_AIX dnl XXX: available in autoconf-2.14 dnl AC_PROG_CC_STDC dnl ====================================================================== dnl ###################################################################### dnl OPTION PROCESSING AC_MSG_NOTICE(*** OPTION PROCESSING ***) dnl Do we want LDAP support ? AMU_WITH_ADDON(ldap, LDAP) dnl Do we want HESIOD support ? AMU_WITH_ADDON(hesiod, HESIOD) dnl Do we want NDBM support ? AMU_WITH_ADDON(ndbm, NDBM) dnl Debugging options (yes, mem, or no) AMU_OPT_DEBUG dnl additional preprocessor options for configuration/compilation AMU_OPT_CPPFLAGS dnl additional linker -l options for configuration/compilation AMU_OPT_LIBS dnl additional linker -L options for configuration/compilation AMU_OPT_LDFLAGS dnl Which options to add to CFLAGS for compilation only? AMU_OPT_AMU_CFLAGS dnl check if a local configuration file exists AMU_LOCALCONFIG dnl turn off maintainer-mode Makefile rules, unless using --enable-maintainer-mode AM_MAINTAINER_MODE dnl ====================================================================== dnl ###################################################################### AC_MSG_NOTICE(*** LIBTOOL ***) dnl my version of prog_libtool will not build shared by default dnl AM_PROG_LIBTOOL2 dnl build static libraries by default AC_DISABLE_SHARED dnl XXX: for autoconf-2.14: use AC_PROG_LIBTOOL, not AM_PROG_LIBTOOL case ${host_os} in # Temporarily undo renaming of "linux-gnu" to "linux", because # libtool only looks for "linux-gnu". Sigh. linux ) host_os=linux-gnu ;; esac dnl this line must appear only once and on its own line dnl (hence the double case statements above and below) AC_PROG_LIBTOOL case ${host_os} in # end temporary renaming of "linux-gnu" to "linux" linux-gnu ) host_os=linux ;; esac dnl ====================================================================== dnl ###################################################################### dnl ADDITIONAL OPTION PROCESSING (must be done after CC is defined) AC_MSG_NOTICE(*** EXTRA OPTION PROCESSING ***) AMU_OS_CPPFLAGS AMU_OS_CFLAGS AMU_OS_LDFLAGS dnl ====================================================================== dnl ###################################################################### dnl Some of these macros must be called before any call to the C compiler AC_MSG_NOTICE(*** UNIX VARIANTS ***) dnl UNIX VARIANTS dnl AC_AIX dnl AC_ISC_POSIX AMU_LINUX_HEADERS dnl ====================================================================== dnl ###################################################################### dnl ALTERNATIVE PROGRAMS dnl Part 2: these are required after "unix variants" dnl ====================================================================== dnl Particular Program Checks (part 2) AC_MSG_NOTICE(*** PARTICULAR PROGRAMS (part 2) ***) AC_PROG_INSTALL dnl the next two are run or supported natively by libtool dnl AC_PROG_LN_S dnl AC_PROG_RANLIB dnl AC_PROG_YACC AMU_PROG_YACC AMU_PROG_LEX dnl I have to keep a unused dummy AM_PROG_LEX here, because old Automake dnl (1.6.3) looks for it if you refer to LEX in your Makefile.am files. dnl Silly thing, fixed in newer versions of Automake (1.9.2). if test 0 != 0 ; then AM_PROG_LEX fi dnl ====================================================================== dnl Generic Program Checks AC_MSG_NOTICE(*** GENERIC PROGRAMS ***) AC_PATH_PROGS(AR, ar, :) AC_PATH_PROGS(PERL, perl5 perl4 perl, /usr/bin/perl) AC_PATH_PROGS(UNMOUNT_PROGRAM, umount unmount, /bin/umount) dnl ====================================================================== dnl ###################################################################### dnl LIBRARY FILES dnl ====================================================================== dnl Note that the configuration order of libraries is in reverse of linkage dnl for example, linking of the first two is -lc -lnsl. AC_MSG_NOTICE(*** LIBRARY FILES ***) dnl libnsl/libsocket are needed only on solaris and some svr4 systems. dnl Using a typical macro has proven unsuccesful, because on some other dnl systems such as irix, including libnsl and or libsocket actually breaks dnl lots of code. So I am forced to use a special purpose macro that sets dnl the libraries based on the OS. Sigh. -Erez. AMU_CHECK_OS_LIBS dnl librpc and librpcsvc are needed on Solaris AC_CHECK_LIB(rpc, clnt_sperrno) AC_CHECK_LIB(rpcsvc, xdr_fhandle) dnl libresolv is needed on Solaris/HPUX-11 for hstrerror() AC_CHECK_FUNC(hstrerror,,AC_CHECK_LIB(resolv, hstrerror)) dnl Linux RedHat 5.1 puts yp functions only in libnsl (libnsl broken on aix) AC_CHECK_FUNC(yp_all,,AC_CHECK_LIB(nsl, yp_all)) dnl hesiod library may not link unless libresolv is included if test "$with_hesiod" = "yes"; then AMU_CHECK_LIB2(hesiod, hes_init,,, -lresolv) fi if test "$with_ldap" = "yes"; then AMU_CHECK_LIB2(ldap, ldap_open,,, -llber) AC_CHECK_FUNCS(ldap_enable_cache) fi dnl Digital UNIX V4.0 and Solaris 7 have POSIX.1c functions in -lrt dnl Solaris 2.6 only has -lposix4; in Solaris 7, this is a symlink to -lrt, dnl so only use one of them case "$ac_cv_opt_debug" in yes | mem ) AC_CHECK_LIB(rt, clock_gettime,, AC_CHECK_LIB(posix4, clock_gettime)) ;; esac dnl ###################################################################### dnl LIBRARY FUNCTIONS dnl ====================================================================== dnl Particular Function Checks AC_MSG_NOTICE(*** PARTICULAR LIBRARY FUNCTIONS ***) dnl AC_FUNC_ALLOCA dnl This GETMNTENT test will add -lgen to LIBS if needed. We may need it dnl if we have to build am-utils on Irix 4, PTX, or Unixware. dnl AC_FUNC_GETMNTENT AMU_FUNC_BAD_MEMCMP AMU_FUNC_BAD_YP_ALL AC_FUNC_FORK([]) AC_FUNC_WAIT3 AC_FUNC_GETPGRP AC_FUNC_SETPGRP dnl if you get AIX link error related to rpl_malloc, turn off next test dnl AC_FUNC_MALLOC dnl ====================================================================== dnl Generic Function Checks AC_MSG_NOTICE(*** GENERIC LIBRARY FUNCTIONS ***) AC_CHECK_FUNCS( \ __rpc_get_local_uid \ __seterr_reply \ _seterr_reply \ bcmp \ bcopy \ bzero \ clnt_create \ clnt_create_vers \ clnt_create_vers_timed \ clnt_spcreateerror \ clock_gettime \ cnodeid \ dg_mount \ flock \ fsmount \ get_myaddress \ getccent \ getcwd \ getdomainname \ getdtablesize \ gethostname \ getifaddrs \ getmntinfo \ getmountent \ getpagesize \ gettimeofday \ hasmntopt \ hstrerror \ madvise \ memcmp \ memcpy \ memmove \ memset \ mkdir \ mkstemp \ mntctl \ mlockall \ mount \ mountsyscall \ plock \ regcomp \ regexec \ rmdir \ select \ seteuid \ setitimer \ setresuid \ setsid \ sigaction \ signal \ sigsuspend \ socket \ statfs \ statvfs \ strcasecmp \ strchr \ strcspn \ strdup \ strerror \ strlcat \ strlcpy \ strspn \ strstr \ svc_getreq \ svc_getreqset \ sysfs \ syslog \ uname \ umount \ umount2 \ unmount \ uvmount \ vfork \ vfsmount \ vmount \ vsnprintf \ wait3 \ waitpid \ ) dnl optional functions if test "$with_hesiod" = "yes"; then AC_CHECK_FUNCS( \ hes_init \ hesiod_init \ hesiod_reload \ hesiod_to_bind \ ) fi AC_REPLACE_FUNCS( \ clnt_sperrno \ hasmntopt \ strcasecmp \ strdup \ strerror \ strlcat \ strlcpy \ strstr \ ualarm \ ) dnl all xdr_* functions are implemented in libamu/xdr_func.c AC_CHECK_FUNCS( \ xdr_attrstat \ xdr_createargs \ xdr_dirlist \ xdr_diropargs \ xdr_diropokres \ xdr_diropres \ xdr_dirpath \ xdr_entry \ xdr_exportnode \ xdr_exports \ xdr_fattr \ xdr_fhandle \ xdr_fhstatus \ xdr_filename \ xdr_ftype \ xdr_groupnode \ xdr_groups \ xdr_linkargs \ xdr_mountbody \ xdr_mountlist \ xdr_name \ xdr_nfs_fh \ xdr_nfscookie \ xdr_nfspath \ xdr_nfsstat \ xdr_nfstime \ xdr_pointer \ xdr_readargs \ xdr_readdirargs \ xdr_readdirres \ xdr_readlinkres \ xdr_readokres \ xdr_readres \ xdr_renameargs \ xdr_sattr \ xdr_sattrargs \ xdr_statfsokres \ xdr_statfsres \ xdr_symlinkargs \ xdr_writeargs \ ) dnl ====================================================================== dnl ********* AMU_SAVE_STATE dnl ********* dnl ###################################################################### dnl HEADER FILES dnl ====================================================================== dnl Particular Header Checks AC_MSG_NOTICE(*** PARTICULAR HEADER FILES ***) AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_SYS_WAIT dnl ====================================================================== dnl Generic Header Checks AC_MSG_NOTICE(*** GENERIC HEADER FILES ***) AC_CHECK_HEADERS( \ arpa/nameser.h \ arpa/inet.h \ bsd/rpc/rpc.h \ cdfs/cdfsmount.h \ cdfs/cdfs_mount.h \ fs/udf/udf_mount.h \ db1/ndbm.h \ fs/efs/efs_mount.h \ fs/msdosfs/msdosfsmount.h \ fs/tmpfs/tmpfs_args.h \ gdbm/ndbm.h \ hsfs/hsfs.h \ linux/fs.h \ linux/kdev_t.h \ linux/list.h \ linux/nfs.h \ linux/nfs2.h \ linux/posix_types.h \ linux/socket.h \ machine/endian.h \ net/errno.h \ net/if.h \ net/if_var.h \ net/route.h \ netinet/in.h \ nfs/export.h \ nfs/mount.h \ nfs/nfs_clnt.h \ nfs/nfs_gfs.h \ nfs/nfs_mount.h \ nfs/nfsmount.h \ nfs/nfsproto.h \ nfs/nfsv2.h \ nfs/pathconf.h \ nfs/rpcv2.h \ nfsclient/nfsargs.h \ rpc/rpc.h \ rpc/types.h \ rpcsvc/autofs_prot.h \ rpcsvc/mount.h \ rpcsvc/mountv3.h \ rpcsvc/nfs_prot.h \ rpcsvc/nis.h \ rpcsvc/ypclnt.h \ sys/config.h \ sys/dg_mount.h \ sys/dir.h \ sys/errno.h \ sys/file.h \ sys/fs/autofs.h \ sys/fs/autofs_prot.h \ sys/fs/cachefs_fs.h \ sys/fs/efs_clnt.h \ sys/fs/nfs.h \ sys/fs/nfs/mount.h \ sys/fs/nfs/nfs_clnt.h \ sys/fs/nfs_clnt.h \ sys/fs/pc_fs.h \ sys/fs/tmp.h \ sys/fs/ufs_mount.h \ sys/fs/xfs_clnt.h \ sys/fs_types.h \ sys/fsid.h \ sys/fstyp.h \ sys/ioctl.h \ sys/immu.h \ sys/lock.h \ sys/machine.h \ sys/mman.h \ sys/mntctl.h \ sys/mntent.h \ sys/mnttab.h \ sys/mount.h \ sys/ndir.h \ sys/netconfig.h \ sys/param.h \ sys/pathconf.h \ sys/resource.h \ sys/sema.h \ sys/signal.h \ sys/socket.h \ sys/sockio.h \ sys/stat.h \ sys/statfs.h \ sys/statvfs.h \ sys/syscall.h \ sys/syslimits.h \ sys/syslog.h \ sys/time.h \ sys/tiuser.h \ sys/types.h \ sys/ucred.h \ sys/uio.h \ sys/utsname.h \ sys/vfs.h \ sys/vmount.h \ sys/vnode.h \ dnl sys/wait.h \ ufs/ufs/extattr.h \ ufs/ufs/ufsmount.h \ ufs/ufs_mount.h \ \ assert.h \ dnl cfs.h \ cluster.h \ ctype.h \ dnl dirent.h \ errno.h \ fcntl.h \ ifaddrs.h \ irs.h \ grp.h \ libgen.h \ limits.h \ malloc.h \ memory.h \ mntent.h \ mnttab.h \ mount.h \ ndbm.h \ ndir.h \ netconfig.h \ netdb.h \ netdir.h \ nsswitch.h \ pwd.h \ regex.h \ setjmp.h \ signal.h \ socketbits.h \ statbuf.h \ stdarg.h \ stdlib.h \ stdio.h \ string.h \ strings.h \ syslog.h \ tcpd.h \ time.h \ tiuser.h \ varargs.h \ unistd.h \ ) dnl optional headers if test "$with_ldap" = "yes"; then AC_CHECK_HEADERS( \ lber.h \ ldap.h \ ) fi if test "$with_hesiod" = "yes"; then AC_CHECK_HEADERS( \ hesiod.h \ ) fi dnl headers which depend on others, else you get an configure error AC_CHECK_HEADERS([ \ isofs/cd9660/cd9660_mount.h \ msdosfs/msdosfsmount.h \ netinet/if_ether.h \ nfs/nfs.h \ rpc/auth.h \ rpc/auth_des.h \ rpc/pmap_clnt.h \ rpc/pmap_prot.h \ rpcsvc/yp_prot.h \ sys/mbuf.h \ sys/proc.h \ resolv.h \ ], [], [], [ #ifdef HAVE_SYS_TYPES_H # include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_PARAM_H # include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_QUEUE_H # include #endif /* HAVE_SYS_QUEUE_H */ #ifdef HAVE_NET_IF_H # include #endif /* HAVE_NET_IF_H */ #ifdef HAVE_NETINET_IN_H # include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_SYS_MOUNT_H # include #endif /* HAVE_SYS_MOUNT_H */ #ifdef HAVE_NFS_NFSMOUNT_H # include #endif /* HAVE_NFS_NFSMOUNT_H */ #ifdef HAVE_RPC_TYPES_H # include #endif /* HAVE_RPC_TYPES_H */ #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ #ifdef HAVE_NFS_RPCV2_H # include #endif /* HAVE_NFS_RPCV2_H */ ]) AC_CHECK_HEADERS([ \ linux/auto_fs.h \ linux/auto_fs4.h \ linux/loop.h \ ], [], [], [ #ifdef HAVE_SYS_SOCKET_H # include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_LIMITS_H # include #endif /* HAVE_LIMITS_H */ #ifdef HAVE_LINUX_POSIX_TYPES_H # include #endif /* HAVE_LINUX_POSIX_TYPES_H */ /* next dev_t lines needed due to changes in kernel code */ #undef dev_t #define dev_t unsigned short /* compatible with Red Hat and SuSE */ ]) dnl even more special checks for Linux nfs headers AC_CHECK_HEADERS([ \ linux/nfs_mount.h \ ], [], [], [ /* * Needed to find nfs2_fh and nfs_fh on older systems (yellowdog2.3, gentoo, * etc.) * Needs to be defined before so u32 is available for * . */ #ifdef HAVE_SYS_TYPES_H # include #endif /* HAVE_SYS_TYPES_H */ /* * It used to be the case that linux/socket.h would define sa_family_t, * but as of FC15, this is not the case anymore (although the comments * in some headers say that is true! So we include too. */ #ifdef HAVE_LINUX_SOCKET_H # include #endif /* HAVE_LINUX_SOCKET_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_LIMITS_H # include #endif /* HAVE_LIMITS_H */ #ifdef HAVE_LINUX_POSIX_TYPES_H # include #endif /* HAVE_LINUX_POSIX_TYPES_H */ #ifdef HAVE_LINUX_NFS2_H # if !defined(FHSIZE) && defined(NFS2_FHSIZE) # define FHSIZE NFS2_FHSIZE # endif #ifdef HAVE_LINUX_NFS_H # include # if !defined(FHSIZE) && defined(NFS_FHSIZE) # define FHSIZE NFS_FHSIZE # endif #endif struct nfs2_fh { char data[[FHSIZE]]; }; # define _LINUX_NFS2_H #endif /* HAVE_LINUX_NFS2_H */ /* next dev_t lines needed due to changes in kernel code */ #undef dev_t #define dev_t unsigned short /* compatible with Red Hat and SuSE */ ]) dnl ====================================================================== dnl db/ndbm/gdbm: This is serious autoconf-fu... dnl ====================================================================== if test "$with_ndbm" = "yes" then if test "$ac_cv_lib_new_dbm" = "" -a "$ac_cv_header_ndbm_h" = "yes"; then AC_CHECK_LIB(ndbm, dbm_open, dnl some systems replaced old ndbm.h include with GNU ndbm.h, which requires dnl libgdbm for dbm_pagfno, so check for this. AC_CHECK_LIB(ndbm, dbm_pagfno, ac_cv_header_new_dbm="ndbm.h"; ac_cv_lib_new_dbm="ndbm", AC_CHECK_LIB(gdbm, dbm_pagfno, ac_cv_header_new_dbm="ndbm.h"; ac_cv_lib_new_dbm="ndbm -lgdbm"))) fi dnl check if dbm_open is part of libc if test "$ac_cv_lib_new_dbm" = "" -a "$ac_cv_header_ndbm_h" = "yes"; then AC_CHECK_LIB(c, dbm_open, ac_cv_header_new_dbm="ndbm.h"; ac_cv_lib_new_dbm="c") fi if test "$ac_cv_lib_new_dbm" = "" -a "$ac_cv_header_db1_ndbm_h" = "yes"; then AC_CHECK_LIB(db1, dbm_open, ac_cv_header_new_dbm="db1/ndbm.h"; ac_cv_lib_new_dbm="db1") fi dnl nasty workaround: and map to the same ac_cv_ variable name if test "$ac_cv_lib_new_dbm" = "" -a "$ac_cv_header_gdbm_ndbm_h" = "yes"; then AC_CHECK_LIB(gdbm, dbm_open, ac_cv_header_new_dbm="gdbm/ndbm.h"; ac_cv_lib_new_dbm="gdbm") else # reset any previous knowledge and retest for different header name # check also gdbm_compat library (Debian 3.1) unset ac_cv_header_gdbm_ndbm_h AC_CHECK_HEADERS(gdbm-ndbm.h) if test "$ac_cv_lib_new_dbm" = "" -a "$ac_cv_header_gdbm_ndbm_h" = "yes"; then AC_CHECK_LIB(gdbm, dbm_open, ac_cv_header_new_dbm="gdbm-ndbm.h"; ac_cv_lib_new_dbm="gdbm", AC_CHECK_LIB(gdbm_compat, dbm_open, ac_cv_header_new_dbm="gdbm-ndbm.h"; ac_cv_lib_new_dbm="gdbm -lgdbm_compat") ) fi fi if test "$ac_cv_header_new_dbm" != "" -a "$ac_cv_lib_new_dbm" != ""; then AC_DEFINE_UNQUOTED(NEW_DBM_H, "$ac_cv_header_new_dbm") dnl don't bother adding "-lc" when it's the default anyway if test "$ac_cv_lib_new_dbm" != "c" ; then LIBS="-l$ac_cv_lib_new_dbm $LIBS" fi fi fi dnl ====================================================================== dnl ********* AMU_SAVE_STATE dnl ********* dnl ###################################################################### dnl STRUCTURES AC_MSG_NOTICE(*** PARTICULAR STRUCTURES ***) AC_HEADER_STAT AC_HEADER_TIME AC_STRUCT_TM dnl ====================================================================== AC_MSG_NOTICE(*** GENERIC STRUCTURES ***) dnl before any use of macros that need nfs/mount headers, must define O/S dnl specific header to include. AMU_CHECK_NFS_PROT_HEADERS AMU_STRUCT_MNTENT AMU_STRUCT_MNTTAB dnl ----------------------------------------------------------------------- dnl check for bad hasmntopt() function after struct mntent/mnttab dnl but only if hasmntopt() is actually defined. if test $ac_cv_func_hasmntopt = yes then AMU_FUNC_BAD_HASMNTOPT fi dnl ----------------------------------------------------------------------- AMU_STRUCT_NFS_ARGS AMU_STRUCT_NFS_GFS_MOUNT dnl ----------------------------------------------------------------------- dnl cannot proceed if struct nfs_args/gfs_mount is not found! if test "$ac_cv_have_struct_nfs_args" = notfound && test "$ac_cv_have_struct_nfs_gfs_mount" = no then AC_MSG_ERROR( [Cannot find any definition for struct nfs_args! This can be due to several reasons: a misconfigured system, a system that is missing some vital NFS-related headers or libraries, one for which am-utils was not ported to yet, or even a bug in the am-utils sources. Check the BUGS file in this distribution and see if there is any mention relevant to your system. If that does not help, check the config.log and config.cache files in this build for details and report them to https://bugzilla.am-utils.org/ or am-utils@am-utils.org please. ]) fi dnl ----------------------------------------------------------------------- dnl NFS related tests need to happen earlier: many things depend on them AMU_STRUCT_FIELD_NFS_FH AMU_STRUCT_NFS_FH AMU_STRUCT_NFS_FH3 AMU_CHECK_FS_MNTENT(nfs3) dnl ====================================================================== dnl ********* AMU_SAVE_STATE dnl ********* dnl ###################################################################### dnl TYPEDEFS dnl ====================================================================== dnl Particular Typedef Checks AC_MSG_NOTICE(*** PARTICULAR TYPEDEFS ***) AC_TYPE_GETGROUPS AC_TYPE_MODE_T AC_TYPE_PID_T AC_TYPE_SIGNAL AC_TYPE_SIZE_T AC_TYPE_UID_T dnl ====================================================================== dnl Generic Typedef Checks AC_MSG_NOTICE(*** GENERIC TYPEDEFS ***) AMU_TYPE_TIME_T AMU_TYPE_RPCVERS_T case "${host_os}" in irix6* ) AMU_TYPE_PTE_T ;; esac AMU_CHECK_FHANDLE AMU_CHECK_MTYPE_TYPE AMU_CHECK_MTYPE_PRINTF_TYPE AMU_TYPE_YP_ORDER_OUTORDER AMU_TYPE_RECVFROM_FROMLEN AMU_TYPE_AUTH_CREATE_GIDLIST AMU_TYPE_SVC_IN_ARG AMU_TYPE_AUTOFS_ARGS AMU_TYPE_CACHEFS_ARGS AMU_TYPE_CDFS_ARGS AMU_TYPE_UDF_ARGS AMU_TYPE_LOFS_ARGS AMU_TYPE_MFS_ARGS AMU_TYPE_PCFS_ARGS AMU_TYPE_RFS_ARGS AMU_TYPE_TMPFS_ARGS AMU_TYPE_UFS_ARGS AMU_TYPE_XFS_ARGS AMU_TYPE_EFS_ARGS AMU_TYPE_XDRPROC_T dnl ====================================================================== dnl ###################################################################### dnl Particular Compiler Characteristics AC_MSG_NOTICE(*** PARTICULAR COMPILER CHARACTERISTICS ***) AC_C_BIGENDIAN AC_C_CONST AC_C_INLINE AC_C_VOLATILE dnl AC_CHECK_SIZEOF(void *, 0) dnl ====================================================================== dnl Generic Compiler Characteristics AC_MSG_NOTICE(*** GENERIC COMPILER CHARACTERISTICS ***) AMU_C_VOID_P AMU_VARARGS_MACROS dnl ====================================================================== dnl ********* AMU_SAVE_STATE dnl ********* dnl ###################################################################### AC_MSG_NOTICE(*** EXTERNAL DEFINITIONS ***) AMU_EXTERN_SYS_ERRLIST AMU_EXTERN_OPTARG AMU_CHECK_EXTERNS( clnt_spcreateerror \ clnt_sperrno \ free \ get_myaddress \ getccent \ getdomainname \ getdtablesize \ gethostname \ getlogin \ getpagesize \ getwd \ hosts_ctl \ innetgr \ mkstemp \ mntctl \ sbrk \ seteuid \ setitimer \ sleep \ strcasecmp \ strdup \ strlcat \ strlcpy \ strstr \ ualarm \ usleep \ wait3 \ vsnprintf \ xdr_callmsg \ xdr_opaque_auth \ ) dnl Different macro to check for LDAP externs, so as to avoid dnl breaking the basic extern-checking macro. if test "$with_ldap" = "yes"; then AMU_CHECK_EXTERN_LDAP(ldap_enable_cache) fi dnl ====================================================================== dnl ###################################################################### dnl C PREPROCESSOR MACROS AC_MSG_NOTICE(*** C PREPROCESSOR MACROS ***) dnl ====================================================================== dnl ###################################################################### dnl SYSTEM SERVICES AC_MSG_NOTICE(*** SYSTEM SERVICES ***) AC_SYS_LONG_FILE_NAMES AC_SYS_LARGEFILE AC_SYS_RESTARTABLE_SYSCALLS AMU_CHECK_NETWORK_TRANSPORT_TYPE dnl ====================================================================== dnl ********* AMU_SAVE_STATE dnl ********* dnl ###################################################################### AC_MSG_NOTICE(*** FIELDS WITHIN STRUCTURES ***) AMU_CHECK_FIELD(fd_set.fds_bits) AMU_CHECK_FIELD(mntent_t.mnt_cnode) AMU_CHECK_FIELD(mntent_t.mnt_ro) AMU_CHECK_FIELD(mntent_t.mnt_time) AMU_FIELD_MNTENT_T_MNT_TIME_STRING AMU_CHECK_FIELD(cdfs_args_t.flags) AMU_CHECK_FIELD(cdfs_args_t.fspec) AMU_CHECK_FIELD(cdfs_args_t.iso_flags) AMU_CHECK_FIELD(cdfs_args_t.iso_pgthresh) AMU_CHECK_FIELD(cdfs_args_t.norrip) AMU_CHECK_FIELD(cdfs_args_t.ssector) AMU_CHECK_FIELD(udf_args_t.version) AMU_CHECK_FIELD(udf_args_t.fspec) AMU_CHECK_FIELD(udf_args_t.sessionnr) AMU_CHECK_FIELD(udf_args_t.udfmflags) AMU_CHECK_FIELD(udf_args_t.gmtoff) AMU_CHECK_FIELD(udf_args_t.anon_uid) AMU_CHECK_FIELD(udf_args_t.anon_gid) AMU_CHECK_FIELD(udf_args_t.nobody_uid) AMU_CHECK_FIELD(udf_args_t.nobody_gid) AMU_CHECK_FIELD(udf_args_t.sector_size) AMU_CHECK_FIELD(pcfs_args_t.dirmask) AMU_CHECK_FIELD(pcfs_args_t.dsttime) AMU_CHECK_FIELD(pcfs_args_t.fspec) AMU_CHECK_FIELD(pcfs_args_t.gid) AMU_CHECK_FIELD(pcfs_args_t.mask) AMU_CHECK_FIELD(pcfs_args_t.secondswest) AMU_CHECK_FIELD(pcfs_args_t.uid) AMU_CHECK_FIELD(ufs_args_t.flags) AMU_CHECK_FIELD(ufs_args_t.fspec) AMU_CHECK_FIELD(ufs_args_t.ufs_flags) AMU_CHECK_FIELD(ufs_args_t.ufs_pgthresh) AMU_CHECK_FIELD(efs_args_t.flags) AMU_CHECK_FIELD(efs_args_t.fspec) AMU_CHECK_FIELD(efs_args_t.version) AMU_CHECK_FIELD(xfs_args_t.flags) AMU_CHECK_FIELD(xfs_args_t.fspec) AMU_CHECK_FIELD(tmpfs_args_t.ta_version) AMU_CHECK_FIELD(tmpfs_args_t.ta_nodes_max) AMU_CHECK_FIELD(tmpfs_args_t.ta_size_max) AMU_CHECK_FIELD(tmpfs_args_t.ta_root_uid) AMU_CHECK_FIELD(tmpfs_args_t.ta_root_gid) AMU_CHECK_FIELD(tmpfs_args_t.ta_root_mode) AMU_CHECK_FIELD(struct fhstatus.fhs_fh) AMU_CHECK_FIELD(struct statfs.f_fstypename) AMU_CHECK_FIELD(nfs_args_t.acdirmin) AMU_CHECK_FIELD(nfs_args_t.acdirmax) AMU_CHECK_FIELD(nfs_args_t.acregmin) AMU_CHECK_FIELD(nfs_args_t.acregmax) AMU_CHECK_FIELD(nfs_args_t.addrlen) AMU_CHECK_FIELD(nfs_args_t.bsize) AMU_CHECK_FIELD(nfs_args_t.fh_len) AMU_CHECK_FIELD(nfs_args_t.fhsize) AMU_CHECK_FIELD(nfs_args_t.gfs_flags) AMU_CHECK_FIELD(nfs_args_t.namlen) AMU_CHECK_FIELD(nfs_args_t.optstr) AMU_CHECK_FIELD(nfs_args_t.pathconf) AMU_CHECK_FIELD(nfs_args_t.proto) AMU_CHECK_FIELD(nfs_args_t.sotype) AMU_CHECK_FIELD(nfs_args_t.version) AMU_CHECK_FIELD(nfs_args_t.pseudoflavor) AMU_CHECK_FIELD(nfs_args_t.context) AMU_CHECK_FIELD(struct ifreq.ifr_addr) AMU_CHECK_FIELD(struct ifaddrs.ifa_next) AMU_CHECK_FIELD(struct sockaddr.sa_len) AMU_CHECK_FIELD(struct umntrequest.devid) dnl This one is for Irix AMU_CHECK_FIELD(autofs_args_t.addr) dnl For Solaris 2.8+ AMU_CHECK_FIELD(mounta.optptr) dnl ====================================================================== dnl ###################################################################### dnl MAP TYPES AC_MSG_NOTICE(*** MAP TYPES ***) dnl DBM is obsolete, use NDBM dnl AMU_CHECK_MAP_FUNCS(dbminit dbmopen, dbm) AMU_CHECK_MAP_FUNCS(fgets, file) AMU_CHECK_MAP_FUNCS(fgets, sun) AMU_CHECK_MAP_FUNCS(waitpid, exec) dnl Define HESIOD map if user wanted it, and both headers and libraries exist if test "$with_hesiod" = "yes" && test "$ac_cv_header_hesiod_h" = "yes" then AMU_CHECK_MAP_FUNCS(hes_init hesiod_init, hesiod) fi dnl Define LDAP map if user wanted it, and both headers and libraries exist if test "$with_ldap" = "yes" && test "$ac_cv_header_ldap_h" = "yes" then AMU_CHECK_MAP_FUNCS(ldap_open, ldap) fi if test "$with_ndbm" = "yes" -a "$ac_cv_lib_new_dbm" != "" then AMU_CHECK_MAP_FUNCS(dbm_open, $ac_cv_lib_new_dbm, ndbm) fi AMU_CHECK_MAP_FUNCS(yp_get_default_domain yp_all, nis) AMU_CHECK_MAP_FUNCS(nis_domain_of, nisplus, nisplus) AMU_CHECK_MAP_FUNCS(getpwnam, passwd) AMU_CHECK_MAP_FUNCS(opendir, union) dnl ====================================================================== dnl ********* AMU_SAVE_STATE dnl ********* dnl ###################################################################### dnl FILESYSTEM TYPES AC_MSG_NOTICE(*** FILESYSTEM TYPES ***) dnl check for filesystem existence if MNTTYPE_ exists, then if dnl MOUNT_, then MNT_, then in /proc/filesystems, and getvfsbyname() AMU_CHECK_FS_MNTENT(autofs) AMU_CHECK_FS_MNTENT(cdfs hsfs cd9660 iso9660 isofs cdrom, cdfs) AMU_CHECK_FS_MNTENT(udf) AMU_CHECK_FS_MNTENT(cache) AMU_CHECK_FS_MNTENT(lofs lo, lofs) AMU_CHECK_FS_MNTENT(mfs) AMU_CHECK_FS_MNTENT(nfs) dnl This test for nfs3 was moved up, because other tests depend on it dnl especially checking for nfsv3 file handle structure types dnl AMU_CHECK_FS_MNTENT(nfs3) AMU_CHECK_FS_MNTENT(vfat pcfs pc msdos msdosfs fat, pcfs) AMU_CHECK_FS_MNTENT(tfs) AMU_CHECK_FS_MNTENT(tmpfs) AMU_CHECK_FS_MNTENT(ext3 ext2 ffs ufs 42 43 44 efs xfs jfs ultrix, ufs) dnl openbsd 2.4 introduce a new file system called xfs, which is not dnl the same as irix-s xfs. Sigh, why did openbsd have to use such a name! case "${host_os_name}" in openbsd* ) ;; * ) AMU_CHECK_FS_MNTENT(xfs) ;; esac AMU_CHECK_FS_MNTENT(efs) dnl new ones in bsd44 AMU_CHECK_FS_MNTENT(null nullfs, nullfs) AMU_CHECK_FS_MNTENT(union unionfs, unionfs) AMU_CHECK_FS_MNTENT(umap umapfs, umapfs) dnl check for filesystem existence if their headers exist dnl AMU_CHECK_FS_HEADERS(cfs.h, cfs) AMU_CHECK_FS_HEADERS(hsfs/hsfs.h, cdfs) AMU_CHECK_FS_HEADERS(fs/udf/udf_mount.h, udf) AMU_CHECK_FS_HEADERS(tmpfs/tmp.h, tmpfs) AMU_CHECK_FS_HEADERS(fs/tmpfs/tmpfs_args.h, tmpfs) AMU_CHECK_FS_HEADERS(fs/efs/efs_mount.h, efs) AMU_CHECK_FS_HEADERS(sys/fs/autofs.h, autofs) AMU_CHECK_FS_HEADERS(sys/fs/cachefs_fs.h, cachefs) dnl AMU_CHECK_FS_HEADERS(jfs/jfsmount.h, ufs) dnl ====================================================================== dnl AUTOMOUNTER FILESYSTEM TYPES AC_MSG_NOTICE(*** AUTOMOUNTER FILESYSTEM TYPES ***) AMU_CHECK_AMU_FS(auto, automounter) AMU_CHECK_AMU_FS(direct, direct automount) AMU_CHECK_AMU_FS(toplvl, top-level) AMU_CHECK_AMU_FS(error, error) dnl AMU_CHECK_AMU_FS(inherit, inheritance) AMU_CHECK_AMU_FS(program, program) AMU_CHECK_AMU_FS(link, symlink) AMU_CHECK_AMU_FS(linkx, symlink with existence check) AMU_CHECK_AMU_FS(host, host (nfs), nfs) AMU_CHECK_AMU_FS(nfsx, multi-nfs mount, nfs) AMU_CHECK_AMU_FS(nfsl, NFS with local existence check) AMU_CHECK_AMU_FS(union, union) dnl AMU_CHECK_AMU_FS(autofs, Sun AutoFS, autofs) dnl ====================================================================== dnl ********* AMU_SAVE_STATE dnl ********* dnl ###################################################################### dnl MOUNTING TYPES AND NAMES FOR MOUNTING TABLE dnl check for mount(2) type/name for filesystem (MNTTYPE_*, MOUNT_*) AC_MSG_NOTICE(*** MOUNTING TYPES ***) AMU_CHECK_MOUNT_TYPE(nfs) AMU_CHECK_MOUNT_TYPE(nfs3) AMU_CHECK_MOUNT_TYPE(ext3 ext2 ffs ufs 4.2 4.3 4.4 efs xfs jfs ultrix, ufs) AMU_CHECK_MOUNT_TYPE(xfs) AMU_CHECK_MOUNT_TYPE(efs) AMU_CHECK_MOUNT_TYPE(cdfs hsfs cd9660 iso9660 isofs cdrom, cdfs) AMU_CHECK_MOUNT_TYPE(udf) AMU_CHECK_MOUNT_TYPE(vfat pcfs pc msdos msdosfs fat, pcfs) AMU_CHECK_MOUNT_TYPE(mfs) AMU_CHECK_MOUNT_TYPE(tmpfs tmp, tmpfs) AMU_CHECK_MOUNT_TYPE(lofs lo, lofs) AMU_CHECK_MOUNT_TYPE(lfs) AMU_CHECK_MOUNT_TYPE(afs) AMU_CHECK_MOUNT_TYPE(autofs) AMU_CHECK_MOUNT_TYPE(tfs) AMU_CHECK_MOUNT_TYPE(cachefs) AMU_CHECK_MOUNT_TYPE(ignore) dnl new ones in bsd44 AMU_CHECK_MOUNT_TYPE(null nullfs, nullfs) AMU_CHECK_MOUNT_TYPE(union unionfs, unionfs) AMU_CHECK_MOUNT_TYPE(umap umapfs, umapfs) dnl ###################################################################### dnl check for mnttab name for filesystem AC_MSG_NOTICE(*** MOUNTING TABLE NAMES ***) AMU_CHECK_MNTTAB_TYPE(nfs) AMU_CHECK_MNTTAB_TYPE(nfs3) AMU_CHECK_MNTTAB_TYPE(ext3 ext2 ffs ufs 4.2 4.3 4.4 efs xfs jfs ultrix, ufs) AMU_CHECK_MNTTAB_TYPE(xfs) AMU_CHECK_MNTTAB_TYPE(efs) AMU_CHECK_MNTTAB_TYPE(cdfs hsfs cd9660 iso9660 isofs cdrom, cdfs) AMU_CHECK_MNTTAB_TYPE(udf) AMU_CHECK_MNTTAB_TYPE(vfat pcfs pc msdos msdosfs fat, pcfs) AMU_CHECK_MNTTAB_TYPE(mfs) AMU_CHECK_MNTTAB_TYPE(tmpfs tmp, tmpfs) AMU_CHECK_MNTTAB_TYPE(lofs lo, lofs) AMU_CHECK_MNTTAB_TYPE(lfs) AMU_CHECK_MNTTAB_TYPE(afs) AMU_CHECK_MNTTAB_TYPE(autofs) AMU_CHECK_MNTTAB_TYPE(tfs) AMU_CHECK_MNTTAB_TYPE(cachefs) dnl new ones in bsd44 AMU_CHECK_MNTTAB_TYPE(null nullfs, nullfs) AMU_CHECK_MNTTAB_TYPE(union unionfs, unionfs) AMU_CHECK_MNTTAB_TYPE(umap umapfs, umapfs) dnl ====================================================================== dnl ********* AMU_SAVE_STATE dnl ********* dnl ###################################################################### dnl Mount Table option name strings like MNTOPT_* dnl if found, defines MNTTAB_OPT_* AC_MSG_NOTICE(*** MOUNT TABLE OPTION NAME STRINGS ***) AMU_CHECK_MNTTAB_OPTS( \ acdirmax \ acdirmin \ acregmax \ acregmin \ actimeo \ compress \ dev \ fsid \ grpid \ ignore \ intr \ longname \ maxgroups \ multi \ noac \ noauto \ noconn \ nocto \ nosub \ nosuid \ nowin95 \ pgthresh \ port \ posix \ private \ proplist \ proto \ public \ retrans \ retry \ ro \ rsize \ rw \ shortname \ soft \ spongy \ suid \ symttl \ timeo \ vers \ wsize \ ) dnl ====================================================================== dnl ********* AMU_SAVE_STATE dnl ********* dnl ###################################################################### dnl Generic mount(2) system call flags (hex/int numbers) like M_*/MS_*/MNT_* dnl if found, defines MNT2_GEN_OPT_* AC_MSG_NOTICE(*** GENERIC MOUNT(2) OPTIONS ***) AMU_CHECK_MNT2_GEN_OPTS( \ async \ automntfs \ bind \ cache \ data \ detach \ force \ fss \ grpid \ ignore \ jfs \ log \ multi \ newtype \ nfs \ noatime \ nocache \ nocoredump \ nodev \ nodevmtime \ noexec \ nomnttab \ nosub \ nosuid \ optionstr \ overlay \ quota \ rdonly \ ronly \ softdep \ sync \ synchronous \ symperm \ union \ ) dnl ====================================================================== dnl ********* AMU_SAVE_STATE dnl ********* dnl ###################################################################### dnl NFS-specific mount(2) options (hex numbers) like NFSMNT_*/NFS_MOUNT_* AC_MSG_NOTICE(*** NFS-SPECIFIC MOUNT(2) OPTIONS ***) dnl if found, defines MNT2_NFS_OPT_* AMU_CHECK_MNT2_NFS_OPTS( \ acdirmax \ acdirmin \ acregmax \ acregmin \ auto \ deadthresh \ dumbtimr \ fsname \ grpid \ hostname \ ignore \ int \ intr \ kerb \ knconf \ leaseterm \ maxgrps \ nfsv3 \ noac \ noconn \ nocto \ noint \ nonlm \ nqnfs \ pgthresh \ posix \ private \ proplist \ rdirplus \ readahead \ readdirsize \ resvport \ retrans \ ronly \ rsize \ soft \ spongy \ symttl \ tcp \ timeo \ ver3 \ wsize \ xlatecookie \ ) dnl ====================================================================== dnl ###################################################################### dnl CDFS-specific mount(2) options (hex numbers) like M_* AC_MSG_NOTICE(*** CDFS-SPECIFIC MOUNT(2) OPTIONS ***) dnl if found, defines MNT2_CDFS_OPT_* AMU_CHECK_MNT2_CDFS_OPTS(\ defperm \ extatt \ gens \ nocasetrans \ nodefperm \ nojoliet \ norrip \ noversion \ rrcaseins \ rrip \ ) dnl ====================================================================== dnl ###################################################################### dnl UDF-specific mount(2) options (hex numbers) like M_* AC_MSG_NOTICE(*** UDF-SPECIFIC MOUNT(2) OPTIONS ***) dnl if found, defines MNT2_UDF_OPT_* AMU_CHECK_MNT2_UDF_OPTS(\ closesession \ ) dnl ====================================================================== dnl ###################################################################### dnl PCFS-specific mount(2) options (hex numbers) like M_* AC_MSG_NOTICE(*** PCFS-SPECIFIC MOUNT(2) OPTIONS ***) dnl if found, defines MNT2_PCFS_OPT_* AMU_CHECK_MNT2_PCFS_OPTS(\ longname \ nowin95 \ shortname \ ) dnl ====================================================================== dnl ********* AMU_SAVE_STATE dnl ********* dnl ###################################################################### dnl SYSTEM-SPECIFIC TESTS AC_MSG_NOTICE(*** SYSTEM-SPECIFIC TESTS ***) dnl ====================================================================== dnl Mount table style AMU_CHECK_MNTTAB_STYLE AMU_CHECK_HIDE_MOUNT_TYPE AMU_CHECK_MNTTAB_LOCATION dnl ----------------------------------------------------------------------- dnl check if has mnttab/mntent or in-kernel mount tables dnl this test must follow AMU_CHECK_MNTTAB_LOCATION and dnl AMU_CHECK_MNT2_GEN_OPTS(nomnttab) if test "$ac_cv_have_struct_mnttab" != yes && test "$ac_cv_have_struct_mntent" != yes && test "$ac_cv_mnttab_location" = file then AC_MSG_ERROR( [No definition found for struct mnttab or struct mntent and this system stores its mount tables on files (not in kernel). This can be due to a misconfigured system, one for which am-utils was not ported to yet, or a bug in the am-utils sources. Check config.log for details and report them to am-utils@am-utils.org please.]) fi dnl ----------------------------------------------------------------------- AMU_CHECK_MNTTAB_FILE_NAME AMU_CHECK_MOUNT_TRAP AMU_CHECK_MOUNT_STYLE AMU_CHECK_UMOUNT_STYLE AMU_CHECK_AUTOFS_STYLE AMU_CHECK_UNMOUNT_CALL AMU_CHECK_UNMOUNT_ARGS AMU_CHECK_NFS_SA_DREF AMU_CHECK_NFS_HN_DREF AMU_CHECK_NFS_FH_DREF AMU_CHECK_NFS_SOCKET_CONNECTION AMU_CHECK_CHECKMOUNT_STYLE AMU_CHECK_RESTARTABLE_SIGNAL_HANDLER AMU_CHECK_GNU_GETOPT dnl ====================================================================== dnl ###################################################################### dnl Check for tcpwrappers dnl This check is moved this far down because on modern tcpwrapper systems dnl such as openbsd, the caller must provide two symbols: deny_severity and dnl allow_severity, which determine the logging level of rejected and dnl requested requests, respectively. If this check happens too early, then dnl $LIBS includes -lwrap, which causes many subsequent tests to fail with dnl missing symbols. AC_CHECK_LIB(wrap, hosts_ctl, [ AC_DEFINE(HAVE_LIBWRAP) WRAPLIB="-lwrap" ]) dnl replace value of WRAPLIB in specific Makefiles AC_SUBST(WRAPLIB) dnl next, check if libwrap defines allow/deny_severity or expects the caller to define it if test "$ac_cv_lib_wrap_hosts_ctl" = "yes" then AMU_CHECK_LIBWRAP_SEVERITY fi dnl ====================================================================== dnl ********* AMU_SAVE_STATE dnl ********* dnl ###################################################################### dnl output files AC_MSG_NOTICE(*** OUTPUT FILES ***) dnl The am_utils_link_files variable is set in macros in aclocal.m4 AC_CONFIG_LINKS(${am_utils_link_files}) dnl ========================================================================== dnl This is necessary so that .o files in LIBOBJS are also built via dnl the ANSI2KNR-filtering rules. LIB@&t@OBJS=`echo "$LIB@&t@OBJS" | sed 's,\.[[^.]]* ,$U&,g;s,\.[[^.]]*$,$U&,'` LTLIBOBJS=`echo "$LIB@&t@OBJS" | sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'` AC_SUBST(LTLIBOBJS) dnl XXX: next two lines are temp hack until automake newer than 1.4 comes out AMU_LIB_OBJS="${LTLIBOBJS}" AC_SUBST(AMU_LIB_OBJS) dnl for Makefile rule to regenerate libtool AC_SUBST(LIBTOOL_DEPS) dnl ========================================================================== AC_CONFIG_FILES( \ aux_conf.h \ \ Makefile \ amd/Makefile \ amq/Makefile \ \ fixmount/Makefile \ fsinfo/Makefile \ hlfsd/Makefile \ libamu/Makefile \ mk-amd-map/Makefile \ wire-test/Makefile \ \ scripts/Makefile \ doc/Makefile \ \ scripts/am-eject \ scripts/amd2ldif \ scripts/amd2sun \ scripts/automount2amd \ scripts/ctl-amd \ scripts/ctl-hlfsd \ scripts/expn \ scripts/fix-amd-map \ scripts/fixrmtab \ scripts/lostaltmail \ scripts/redhat-ctl-amd \ scripts/test-attrcache \ scripts/wait4amd \ scripts/wait4amd2die \ ) AC_OUTPUT # chmod some scripts that are built but not installed test -f scripts/test-attrcache && chmod +x scripts/test-attrcache dnl ====================================================================== dnl ###################################################################### AC_MSG_NOTICE(*** END OF CONFIGURATION ***) dnl end of configure.in for am-utils-6.x am-utils-6.2+rc20110530/cvs-server.txt000066400000000000000000000030461157065440000171750ustar00rootroot00000000000000############################################################################## Here are generic CVS server instructions: (1) Get an SSH Public key installed on cvs.am-utils.org. You can generate a public/private key pair using ssh-keygen(1). Then copy the key into your ~/.ssh/authorized_keys file on cvs.am-utils.org. If you don't have login access on cvs.am-utils.org, then email am-utils-developers@am-utils.org. (2) Then, check out a fresh copy of 6.2 (development branch) $ export CVS_RSH=ssh $ cvs -d ${USER}@cvs.am-utils.org:/home/cvsroot checkout am-utils Or, to checkout the stable branch: $ cvs -d ${USER}@cvs.am-utils.org:/home/cvsroot checkout -r amd-6-1-stable am-utils Or, to checkout the legacy branch: $ cvs -d ${USER}@cvs.am-utils.org:/home/cvsroot checkout -r amd-6-0-stable am-utils (3) Then you can do normal edit, commit, update, etc. without having to worry about your $CVSROOT or the -d option. Just remember to keep setting CVS_RSH=ssh in your environment (or put it in your .profile/.login file). ############################################################################## To merge changes from the stable branch into the main (development) branch: $ cvs update -j amd-6-1-stable -kk - don't worry about all the files that change; it's probably because of cvs keywords in the sources - after the merge, do a 'cvs update -d' and resolve any conflicts Nevertheless, please exercise caution when merging branches. ############################################################################## am-utils-6.2+rc20110530/depcomp000077500000000000000000000442671157065440000157240ustar00rootroot00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2009-04-28.21; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 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, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputing dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u="sed s,\\\\\\\\,/,g" depmode=msvisualcpp fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: am-utils-6.2+rc20110530/doc/000077500000000000000000000000001157065440000150775ustar00rootroot00000000000000am-utils-6.2+rc20110530/doc/.cvsignore000066400000000000000000000002411157065440000170740ustar00rootroot00000000000000Makefile.in version.texi stamp-vti am-utils.info am-utils.info-1 am-utils.info-2 am-utils.info-3 am-utils.info-4 am-utils.info-5 am-utils.info-6 am-utils.info-7 am-utils-6.2+rc20110530/doc/Makefile.am000066400000000000000000000073061157065440000171410ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in # Package: am-utils # Level: Makefile for doc/ directory # Author: Erez Zadok @SET_MAKE@ info_TEXINFOS = am-utils.texi EXTRA_DIST = hlfsd.ps # force generation of 'letter' format PS and embed Type-3 fonts # (our European allies may object...) DVIPS = dvips -t letter -Pcmz # Force version.texi to be rebuilt regardless of maintainer mode $(srcdir)/version.texi: am-utils.texi $(top_srcdir)/configure.in @(set `$(SHELL) $(srcdir)/mdate-sh $(srcdir)/am-utils.texi`; \ echo "@set UPDATED $$1 $$2 $$3"; \ echo "@set UPDATED-MONTH $$2 $$3"; \ echo "@set EDITION $(VERSION)"; \ echo "@set VERSION $(VERSION)") > vti.tmp @cmp -s vti.tmp $(srcdir)/version.texi \ || (echo "Updating $(srcdir)/version.texi"; \ cp vti.tmp $(srcdir)/version.texi) -@rm -f vti.tmp # include dvi/ps in distribution dist-hook: $(distdir)/am-utils.dvi $(distdir)/am-utils.ps $(distdir)/am-utils.dvi: am-utils.dvi install -c -m 644 $< $@ $(distdir)/am-utils.ps: am-utils.ps install -c -m 644 $< $@ # a special target for making Postscript files ps: am-utils.dvi am-utils.ps am-utils-clean: clean maintainer-clean-aminfo maintainer-clean-vti # personal rule for Erez Zadok to generate and install html docs alldocs: ps install-NEWS install-INSTALL install-ChangeLog install-AUTHORS install-tasks install-autofs install-y2k install-ldap install-osx install-BUGS install-FAQ install-html install-ps install-MIRRORS install-attrcache install-sun2amd AMU_HTML_TOP=$(HOME)/proj/www/docs/am-utils install-html: $(AMU_HTML_TOP)/am-utils-all.html $(AMU_HTML_TOP)/am-utils-all.html: am-utils.texi texi2html -Verbose -expand info -number -out_file am-utils-all.html $< texi2html -frames -Verbose -expand info -number -split chapter $< mv am-utils-all.html am-utils/*.html $(AMU_HTML_TOP) chmod -R a+r $(AMU_HTML_TOP) install-ps: $(AMU_HTML_TOP)/am-utils.ps $(AMU_HTML_TOP)/am-utils.ps: am-utils.ps install -c -m 644 $< $@ install-NEWS: $(AMU_HTML_TOP)/NEWS.txt $(AMU_HTML_TOP)/NEWS.txt: $(top_srcdir)/NEWS install -c -m 644 $< $@ install-INSTALL: $(AMU_HTML_TOP)/INSTALL.txt $(AMU_HTML_TOP)/INSTALL.txt: $(top_srcdir)/INSTALL install -c -m 644 $< $@ install-ChangeLog: $(AMU_HTML_TOP)/ChangeLog.txt $(AMU_HTML_TOP)/ChangeLog.txt: $(top_srcdir)/ChangeLog sed 's/@.*>$$/@...>/g' < $< > $@ chmod 644 $@ install-AUTHORS: $(AMU_HTML_TOP)/AUTHORS.txt $(AMU_HTML_TOP)/AUTHORS.txt: $(top_srcdir)/AUTHORS install -c -m 644 $< $@ install-tasks: $(AMU_HTML_TOP)/tasks.txt $(AMU_HTML_TOP)/tasks.txt: $(top_srcdir)/tasks install -c -m 644 $< $@ install-autofs: $(AMU_HTML_TOP)/autofs.txt $(AMU_HTML_TOP)/autofs.txt: $(top_srcdir)/README.autofs install -c -m 644 $< $@ install-y2k: $(AMU_HTML_TOP)/y2k.txt $(AMU_HTML_TOP)/y2k.txt: $(top_srcdir)/README.y2k install -c -m 644 $< $@ install-attrcache: $(AMU_HTML_TOP)/attrcache.txt $(AMU_HTML_TOP)/attrcache.txt: $(top_srcdir)/README.attrcache install -c -m 644 $< $@ install-sun2amd: $(AMU_HTML_TOP)/sun2amd.txt $(AMU_HTML_TOP)/sun2amd.txt: $(top_srcdir)/README.sun2amd install -c -m 644 $< $@ install-ldap: $(AMU_HTML_TOP)/ldap.txt $(AMU_HTML_TOP)/ldap.txt: $(top_srcdir)/README.ldap install -c -m 644 $< $@ install-osx: $(AMU_HTML_TOP)/osx.txt $(AMU_HTML_TOP)/osx.txt: $(top_srcdir)/README.osx install -c -m 644 $< $@ install-BUGS: $(AMU_HTML_TOP)/BUGS.txt $(AMU_HTML_TOP)/BUGS.txt: $(top_srcdir)/BUGS install -c -m 644 $< $@ install-FAQ: $(AMU_HTML_TOP)/FAQ.txt $(AMU_HTML_TOP)/FAQ.txt: $(top_srcdir)/FAQ install -c -m 644 $< $@ install-MIRRORS: $(AMU_HTML_TOP)/MIRRORS.txt $(AMU_HTML_TOP)/MIRRORS.html $(AMU_HTML_TOP)/MIRRORS.txt: $(top_srcdir)/MIRRORS.txt install -c -m 644 $< $@ $(AMU_HTML_TOP)/MIRRORS.html: $(top_srcdir)/MIRRORS.html install -c -m 644 $< $@ am-utils-6.2+rc20110530/doc/am-utils.texi000066400000000000000000012451521157065440000175370ustar00rootroot00000000000000\input texinfo @c -*-texinfo-*- @c @c Copyright (c) 1997-2011 Erez Zadok @c Copyright (c) 1989 Jan-Simon Pendry @c Copyright (c) 1989 Imperial College of Science, Technology & Medicine @c Copyright (c) 1989 The Regents of the University of California. @c All rights reserved. @c @c This code is derived from software contributed to Berkeley by @c Jan-Simon Pendry at Imperial College, London. @c @c Redistribution and use in source and binary forms, with or without @c modification, are permitted provided that the following conditions @c are met: @c 1. Redistributions of source code must retain the above copyright @c notice, this list of conditions and the following disclaimer. @c 2. Redistributions in binary form must reproduce the above copyright @c notice, this list of conditions and the following disclaimer in the @c documentation and/or other materials provided with the distribution. @c 3. All advertising materials mentioning features or use of this software @c must display the following acknowledgment: @c This product includes software developed by the University of @c California, Berkeley and its contributors. @c 4. Neither the name of the University nor the names of its contributors @c may be used to endorse or promote products derived from this software @c without specific prior written permission. @c @c THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND @c ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @c IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @c ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE @c FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL @c DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS @c OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) @c HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT @c LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY @c OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF @c @c @c File: am-utils/doc/am-utils.texi @c @setfilename am-utils.info @include version.texi @c info directory entry @dircategory Administration @direntry * Am-utils: (am-utils). The Amd automounter suite of utilities @end direntry @settitle Am-utils (4.4BSD Automounter Utilities) @setchapternewpage odd @titlepage @title Am-utils (4.4BSD Automounter Utilities) @subtitle For version @value{VERSION}, @value{UPDATED} @author Erez Zadok (Originally by Jan-Simon Pendry and Nick Williams) @page Copyright @copyright{} 1997-2011 Erez Zadok @* Copyright @copyright{} 1989 Jan-Simon Pendry @* Copyright @copyright{} 1989 Imperial College of Science, Technology & Medicine @* Copyright @copyright{} 1989 The Regents of the University of California. @sp All Rights Reserved. @vskip 1ex Permission to copy this document, or any portion of it, as necessary for use of this software is granted provided this copyright notice and statement of permission are included. @end titlepage @page @c Define a new index for options. @syncodeindex pg cp @syncodeindex vr cp @ifinfo @c ################################################################ @node Top, License, , (DIR) @b{Am-utils (4.4BSD Automounter Utilities) User Manual} @* For version @value{VERSION}, @value{UPDATED} @b{Erez Zadok} @* (Originally by Jan-Simon Pendry and Nick Williams) Copyright @copyright{} 1997-2011 Erez Zadok @* Copyright @copyright{} 1989 Jan-Simon Pendry @* Copyright @copyright{} 1989 Imperial College of Science, Technology & Medicine @* Copyright @copyright{} 1989 The Regents of the University of California. @* All Rights Reserved. Permission to copy this document, or any portion of it, as necessary for use of this software is granted provided this copyright notice and statement of permission are included. Am-utils is the 4.4BSD Automounter Tool Suite, which includes the Amd automounter, the Amq query and control program, the Hlfsd daemon, and other tools. This Info file describes how to use and understand the tools within Am-utils. @end ifinfo @menu * License:: Explains the terms and conditions for using and distributing Am-utils. * Distrib:: How to get the latest Am-utils distribution. * AddInfo:: How to get additional information. * Intro:: An introduction to Automounting concepts. * History:: History of am-utils' development. * Overview:: An overview of Amd. * Supported Platforms:: Machines and Systems supported by Amd. * Mount Maps:: Details of mount maps. * Amd Command Line Options:: All the Amd command line options explained. * Filesystem Types:: The different mount types supported by Amd. * Amd Configuration File:: The amd.conf file syntax and meaning. * Run-time Administration:: How to start, stop and control Amd. * FSinfo:: The FSinfo filesystem management tool. * Hlfsd:: The Home-Link Filesystem server. * Assorted Tools:: Other tools which come with am-utils. * Examples:: Some examples showing how Amd might be used. * Internals:: Implementation details. * Acknowledgments & Trademarks:: Legal Notes. Indexes * Index:: An item for each concept. @end menu @iftex @unnumbered Preface This manual documents the use of the 4.4BSD automounter tool suite, which includes @i{Amd}, @i{Amq}, @i{Hlfsd}, and other programs. This is primarily a reference manual. While no tutorial exists, there are examples available. @xref{Examples}. This manual comes in two forms: the published form and the Info form. The Info form is for on-line perusal with the INFO program which is distributed along with GNU texinfo package (a version of which is available for GNU Emacs).@footnote{GNU packages can be found in @url{ftp://ftp.gnu.org/pub/gnu/}.} Both forms contain substantially the same text and are generated from a common source file, which is distributed with the @i{Am-utils} source. @end iftex @c ################################################################ @node License, Distrib, Top, Top @unnumbered License @cindex License Information @i{Am-utils} is not in the public domain; it is copyrighted and there are restrictions on its distribution. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @enumerate @item Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. @item 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. @item All advertising materials mentioning features or use of this software must display the following acknowledgment: @cartouche ``This product includes software developed by the University of California, Berkeley and its contributors, as well as the Trustees of Columbia University.'' @end cartouche @item 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. @end enumerate 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. @c ################################################################ @node Distrib, AddInfo, License, Top @unnumbered Source Distribution @cindex Source code distribution @cindex Obtaining the source code The @i{Am-utils} home page is located in @example @url{http://www.am-utils.org/} @end example You can get the latest distribution version of @i{Am-utils} from @example @url{ftp://ftp.am-utils.org/pub/am-utils/am-utils.tar.gz} @end example Additional alpha, beta, and release distributions are available in @example @url{ftp://ftp.am-utils.org/pub/am-utils/}. @end example Revision 5.2 was part of the 4.3BSD Reno distribution. Revision 5.3bsdnet, a late alpha version of 5.3, was part of the BSD network version 2 distribution Revision 6.0 was made independently by Erez Zadok at the Computer Science Department of @uref{http://www.cs.columbia.edu/,Columbia University}, as part of his @uref{http://www.fsl.cs.sunysb.edu/docs/zadok-thesis-proposal/,PhD thesis work}. Am-utils (especially version 6.1) continues to be developed and maintained at the @uref{http://www.cs.sunysb.edu/,Computer Science Department} of @uref{http://www.stonybrook.edu/,Stony Brook University}, as a service to the user community. @xref{History}, for more details. @c ################################################################ @node AddInfo, Intro, Distrib, Top @unnumbered Getting Additional Information @cindex Getting Additional Information @unnumberedsec Bug Reports @cindex Bug reports Before reporting a bug, see if it is a known one in the @uref{http://www.am-utils.org/docs/am-utils/BUGS.txt,bugs} file. If you find a problem and hopefully you can reproduce it, please describe it in detail and @uref{https://bugzilla.filesystems.org/,submit a bug report} via @uref{http://www.bugzilla.org/,Bugzilla}. Alternatively, you can send your bug report to the ``am-utils'' list (see @url{http://www.am-utils.org/} under ``Mailing Lists'') quoting the details of the release and your configuration. These details can be obtained by running the command @samp{amd -v}. It would greatly help if you could provide a reproducible procedure for detecting the bug you are reporting. Providing working patches is highly encouraged. Every patch incorporated, however small, will get its author an honorable mention in the @uref{http://www.am-utils.org/docs/am-utils/AUTHORS.txt,authors file}. @unnumberedsec Mailing Lists @cindex Mailing lists There are several mailing lists for people interested in keeping up-to-date with developments. @c ############### @enumerate @item The users mailing list, @samp{am-utils} is for @itemize @minus @item announcements of alpha and beta releases of am-utils @item reporting of bugs and patches @item discussions of new features for am-utils @item implementation and porting issues @end itemize To subscribe, visit @url{http://www.am-utils.org/} under ``Mailing Lists.'' After subscribing, you can post a message to this list. To avoid as much spam as possible, only subscribers to this list may post to it. Subscribers of @samp{am-utils} are most helpful if they have the time and resources to test new and development versions of amd, on as many different platforms as possible. They should also be prepared to learn and use the GNU Autoconf, Automake, and Libtool packages, as needed; and of course, become familiar with the complex code in the am-utils package. In other words, subscribers on this list should hopefully be able to contribute meaningfully to the development of amd. Note that this @samp{am-utils} list used to be called @samp{amd-dev} before January 1st, 2004. Please use the new name, @samp{am-utils}. @item The announcements mailing list, @samp{am-utils-announce} is for announcements only (mostly new releases). To subscribe, visit @url{http://www.am-utils.org/} under ``Mailing Lists.'' This list is read-only: only am-utils developers may post to it. @item We distribute nightly CVS snapshots in @url{ftp://ftp.am-utils.org/pub/am-utils/snapshots/daily/}. If you like to get email notices of commits to the am-utils CVS repository, subscribe to the CVS logs mailing list, @samp{am-utils-cvs} at @url{http://www.am-utils.org/} under ``Mailing Lists.'' @item The older list which was used to user discussions, @samp{amd-workers}, is defunct as of January 2004. (Its last address was @email{amd-workers AT majordomo.glue.umd.edu}.) Don't use @samp{amd-workers}: use the newer, more active @samp{am-utils} list. @item For completeness, there's a developers-only closed list called @samp{am-utils-developers} (see @url{http://www.am-utils.org/} under ``Mailing Lists''). @end enumerate @unnumberedsec Am-utils Book @cindex Am-utils book @cindex Amd book @cindex Automounter book @cindex book @uref{http://www.cs.sunysb.edu/~ezk,Erez Zadok} wrote a @uref{http://www.fsl.cs.sunysb.edu/docs/amd-book/,book}, titled @i{Linux NFS and Automounter Administration}, ISBN 0-7821-2739-8, (Sybex, 2001). The book is full of details and examples that go beyond what this manual has. The book also covers NFS in great detail. Although the book is geared toward Linux users, it is general enough for any Unix administrator and contains specific sections for non-Linux systems. @c ################################################################ @node Intro, History, AddInfo, Top @unnumbered Introduction @cindex Introduction An @dfn{automounter} maintains a cache of mounted filesystems. Filesystems are mounted on demand when they are first referenced, and unmounted after a period of inactivity. @i{Amd} may be used as a replacement for Sun's automounter. The choice of which filesystem to mount can be controlled dynamically with @dfn{selectors}. Selectors allow decisions of the form ``hostname is @var{this},'' or ``architecture is not @var{that}.'' Selectors may be combined arbitrarily. @i{Amd} also supports a variety of filesystem types, including NFS, UFS and the novel @dfn{program} filesystem. The combination of selectors and multiple filesystem types allows identical configuration files to be used on all machines thus reducing the administrative overhead. @i{Amd} ensures that it will not hang if a remote server goes down. Moreover, @i{Amd} can determine when a remote server has become inaccessible and then mount replacement filesystems as and when they become available. @i{Amd} contains no proprietary source code and has been ported to numerous flavors of Unix. @c ################################################################ @node History, Overview, Intro, Top @unnumbered History @cindex History The @i{Amd} package has been without an official maintainer since 1992. Several people have stepped in to maintain it unofficially. Most notable were the `upl' (Unofficial Patch Level) releases of @i{Amd}, created by me (@uref{http://www.cs.sunysb.edu/~ezk,Erez Zadok}), and available from @url{ftp://ftp.am-utils.org/pub/amd/}. The last such unofficial release was `upl102'. Through the process of patching and aging, it was becoming more and more apparent that @i{Amd} was in much need of revitalizing. Maintaining @i{Amd} had become a difficult task. I took it upon myself to cleanup the code, so that it would be easier to port to new platforms, add new features, keep up with the many new feature requests, and deal with the never ending stream of bug reports. I have been working on such a release of @i{Amd} on and off since January of 1996. The new suite of tools is currently named "am-utils" (AutoMounter Utilities), in line with GNU naming conventions, befitting the contents of the package. In October of 1996 I had received enough offers to help me with this task that I decided to make a mailing list for this group of people. Around the same time, @i{Amd} had become a necessary part of my PhD thesis work, resulting in more work performed on am-utils. Am-utils version 6.0 was numbered with a major new release number to distinguish it from the last official release of @i{Amd} (5.x). Many new features have been added such as a GNU @code{configure} system, NFS Version 3, a run-time configuration file (`amd.conf'), many new ports, more scripts and programs, as well as numerous bug fixes. Another reason for the new major release number was to alert users of am-utils that user-visible interfaces may have changed. In order to make @i{Amd} work well for the next 10 years, and be easier to maintain, it was necessary to remove old or unused features, change various syntax files, etc. However, great care was taken to ensure the maximum possible backwards compatibility. Am-utils version 6.1 has autofs support for Linux and Solaris 2.5+ as @i{the} major new feature, in addition to several other minor new features. The autofs support is completely transparent to the end-user, aside from the fact that @code{/bin/pwd} now always returns the correct amd-ified path. The administrator can easily switch between NFS and autofs mounts by changing one parameter in @code{amd.conf}. Autofs support and maintenance was developed in conjunction with @email{ionut AT badula.org,Ion Badulescu}. @c ################################################################ @node Overview, Supported Platforms, History, Top @chapter Overview @i{Amd} maintains a cache of mounted filesystems. Filesystems are @dfn{demand-mounted} when they are first referenced, and unmounted after a period of inactivity. @i{Amd} may be used as a replacement for Sun's @b{automount}(8) program. It contains no proprietary source code and has been ported to numerous flavors of Unix. @xref{Supported Platforms}.@refill @i{Amd} was designed as the basis for experimenting with filesystem layout and management. Although @i{Amd} has many direct applications it is loaded with additional features which have little practical use. At some point the infrequently used components may be removed to streamline the production system. @i{Amd} supports the notion of @dfn{replicated} filesystems by evaluating each member of a list of possible filesystem locations one by one. @i{Amd} checks that each cached mapping remains valid. Should a mapping be lost -- such as happens when a fileserver goes down -- @i{Amd} automatically selects a replacement should one be available. @menu * Fundamentals:: * Filesystems and Volumes:: * Volume Naming:: * Volume Binding:: * Operational Principles:: * Mounting a Volume:: * Automatic Unmounting:: * Keep-alives:: * Non-blocking Operation:: @end menu @node Fundamentals, Filesystems and Volumes, Overview, Overview @comment node-name, next, previous, up @section Fundamentals @cindex Automounter fundamentals The fundamental concept behind @i{Amd} is the ability to separate the name used to refer to a file from the name used to refer to its physical storage location. This allows the same files to be accessed with the same name regardless of where in the network the name is used. This is very different from placing @file{/n/hostname} in front of the pathname since that includes location dependent information which may change if files are moved to another machine. By placing the required mappings in a centrally administered database, filesystems can be re-organized without requiring changes to configuration files, shell scripts and so on. @node Filesystems and Volumes, Volume Naming, Fundamentals, Overview @comment node-name, next, previous, up @section Filesystems and Volumes @cindex Filesystem @cindex Volume @cindex Fileserver @cindex sublink @i{Amd} views the world as a set of fileservers, each containing one or more filesystems where each filesystem contains one or more @dfn{volumes}. Here the term @dfn{volume} is used to refer to a coherent set of files such as a user's home directory or a @TeX{} distribution.@refill In order to access the contents of a volume, @i{Amd} must be told in which filesystem the volume resides and which host owns the filesystem. By default the host is assumed to be local and the volume is assumed to be the entire filesystem. If a filesystem contains more than one volume, then a @dfn{sublink} is used to refer to the sub-directory within the filesystem where the volume can be found. @node Volume Naming, Volume Binding, Filesystems and Volumes, Overview @comment node-name, next, previous, up @section Volume Naming @cindex Volume names @cindex Network-wide naming @cindex Replicated volumes @cindex Duplicated volumes @cindex Replacement volumes Volume names are defined to be unique across the entire network. A volume name is the pathname to the volume's root as known by the users of that volume. Since this name uniquely identifies the volume contents, all volumes can be named and accessed from each host, subject to administrative controls. Volumes may be replicated or duplicated. Replicated volumes contain identical copies of the same data and reside at two or more locations in the network. Each of the replicated volumes can be used interchangeably. Duplicated volumes each have the same name but contain different, though functionally identical, data. For example, @samp{/vol/tex} might be the name of a @TeX{} distribution which varied for each machine architecture.@refill @i{Amd} provides facilities to take advantage of both replicated and duplicated volumes. Configuration options allow a single set of configuration data to be shared across an entire network by taking advantage of replicated and duplicated volumes. @i{Amd} can take advantage of replacement volumes by mounting them as required should an active fileserver become unavailable. @node Volume Binding, Operational Principles, Volume Naming, Overview @comment node-name, next, previous, up @section Volume Binding @cindex Volume binding @cindex Unix namespace @cindex Namespace @cindex Binding names to filesystems Unix implements a namespace of hierarchically mounted filesystems. Two forms of binding between names and files are provided. A @dfn{hard link} completes the binding when the name is added to the filesystem. A @dfn{soft link} delays the binding until the name is accessed. An @dfn{automounter} adds a further form in which the binding of name to filesystem is delayed until the name is accessed.@refill The target volume, in its general form, is a tuple (host, filesystem, sublink) which can be used to name the physical location of any volume in the network. When a target is referenced, @i{Amd} ignores the sublink element and determines whether the required filesystem is already mounted. This is done by computing the local mount point for the filesystem and checking for an existing filesystem mounted at the same place. If such a filesystem already exists then it is assumed to be functionally identical to the target filesystem. By default there is a one-to-one mapping between the pair (host, filesystem) and the local mount point so this assumption is valid. @node Operational Principles, Mounting a Volume, Volume Binding, Overview @comment node-name, next, previous, up @section Operational Principles @cindex Operational principles @i{Amd} operates by introducing new mount points into the namespace. These are called @dfn{automount} points. The kernel sees these automount points as NFS filesystems being served by @i{Amd}. Having attached itself to the namespace, @i{Amd} is now able to control the view the rest of the system has of those mount points. RPC calls are received from the kernel one at a time. When a @dfn{lookup} call is received @i{Amd} checks whether the name is already known. If it is not, the required volume is mounted. A symbolic link pointing to the volume root is then returned. Once the symbolic link is returned, the kernel will send all other requests direct to the mounted filesystem. If a volume is not yet mounted, @i{Amd} consults a configuration @dfn{mount-map} corresponding to the automount point. @i{Amd} then makes a runtime decision on what and where to mount a filesystem based on the information obtained from the map. @i{Amd} does not implement all the NFS requests; only those relevant to name binding such as @dfn{lookup}, @dfn{readlink} and @dfn{readdir}. Some other calls are also implemented but most simply return an error code; for example @dfn{mkdir} always returns ``read-only filesystem''. @node Mounting a Volume, Automatic Unmounting, Operational Principles, Overview @comment node-name, next, previous, up @section Mounting a Volume @cindex Mounting a volume @cindex Location lists @cindex Alternate locations @cindex Mount retries @cindex Background mounts Each automount point has a corresponding mount map. The mount map contains a list of key--value pairs. The key is the name of the volume to be mounted. The value is a list of locations describing where the filesystem is stored in the network. In the source for the map the value would look like @display location1 location2 @dots{} locationN @end display @i{Amd} examines each location in turn. Each location may contain @dfn{selectors} which control whether @i{Amd} can use that location. For example, the location may be restricted to use by certain hosts. Those locations which cannot be used are ignored. @i{Amd} attempts to mount the filesystem described by each remaining location until a mount succeeds or @i{Amd} can no longer proceed. The latter can occur in three ways: @itemize @bullet @item If none of the locations could be used, or if all of the locations caused an error, then the last error is returned. @item If a location could be used but was being mounted in the background then @i{Amd} marks that mount as being ``in progress'' and continues with the next request; no reply is sent to the kernel. @item Lastly, one or more of the mounts may have been @dfn{deferred}. A mount is deferred if extra information is required before the mount can proceed. When the information becomes available the mount will take place, but in the mean time no reply is sent to the kernel. If the mount is deferred, @i{Amd} continues to try any remaining locations. @end itemize Once a volume has been mounted, @i{Amd} establishes a @dfn{volume mapping} which is used to satisfy subsequent requests.@refill @node Automatic Unmounting, Keep-alives, Mounting a Volume, Overview @comment node-name, next, previous, up @section Automatic Unmounting To avoid an ever increasing number of filesystem mounts, @i{Amd} removes volume mappings which have not been used recently. A time-to-live interval is associated with each mapping and when that expires the mapping is removed. When the last reference to a filesystem is removed, that filesystem is unmounted. If the unmount fails, for example the filesystem is still busy, the mapping is re-instated and its time-to-live interval is extended. The global default for this grace period is controlled by the @code{-w} command-line option (@pxref{-w Option, -w}) or the @i{amd.conf} parameter @samp{dismount_interval} (@pxref{dismount_interval Parameter}). It is also possible to set this value on a per-mount basis (@pxref{opts Option, opts, opts}). Filesystems can be forcefully timed out using the @i{Amq} command. @xref{Run-time Administration}. Note that on new enough systems that support forced unmounts, such as Linux, @i{Amd} can try to use the @b{umount2}(2) system call to force the unmount, if the regular @b{umount}(2) system call failed in a way that indicates that the mount point is hung or stale. @xref{forced_unmounts Parameter}. @node Keep-alives, Non-blocking Operation, Automatic Unmounting, Overview @comment node-name, next, previous, up @section Keep-alives @cindex Keep-alives @cindex Server crashes @cindex NFS ping Use of some filesystem types requires the presence of a server on another machine. If a machine crashes then it is of no concern to processes on that machine that the filesystem is unavailable. However, to processes on a remote host using that machine as a fileserver this event is important. This situation is most widely recognized when an NFS server crashes and the behavior observed on client machines is that more and more processes hang. In order to provide the possibility of recovery, @i{Amd} implements a @dfn{keep-alive} interval timer for some filesystem types. Currently only NFS makes use of this service. The basis of the NFS keep-alive implementation is the observation that most sites maintain replicated copies of common system data such as manual pages, most or all programs, system source code and so on. If one of those servers goes down it would be reasonable to mount one of the others as a replacement. The first part of the process is to keep track of which fileservers are up and which are down. @i{Amd} does this by sending RPC requests to the servers' NFS @code{NullProc} and checking whether a reply is returned. While the server state is uncertain the requests are re-transmitted at three second intervals and if no reply is received after four attempts the server is marked down. If a reply is received the fileserver is marked up and stays in that state for 30 seconds at which time another NFS ping is sent. This interval is configurable and can even be turned off using the @i{ping} option. @xref{opts Option}. Once a fileserver is marked down, requests continue to be sent every 30 seconds in order to determine when the fileserver comes back up. During this time any reference through @i{Amd} to the filesystems on that server fail with the error ``Operation would block''. If a replacement volume is available then it will be mounted, otherwise the error is returned to the user. @c @i{Amd} keeps track of which servers are up and which are down. @c It does this by sending RPC requests to the servers' NFS {\sc NullProc} and @c checking whether a reply is returned. If no replies are received after a @c short period, @i{Amd} marks the fileserver @dfn{down}. @c RPC requests continue to be sent so that it will notice when a fileserver @c comes back up. @c ICMP echo packets \cite{rfc:icmp} are not used because it is the availability @c of the NFS service that is important, not the existence of a base kernel. @c Whenever a reference to a fileserver which is down is made via @i{Amd}, an alternate @c filesystem is mounted if one is available. @c Although this action does not protect user files, which are unique on the network, or processes which do not access files via @i{Amd} or already have open files on the hung filesystem, it can prevent most new processes from hanging. @c @c With a suitable combination of filesystem management and mount-maps, @c machines can be protected against most server downtime. This can be @c enhanced by allocating boot-servers dynamically which allows a diskless @c workstation to be quickly restarted if necessary. Once the root filesystem @c is mounted, @i{Amd} can be started and allowed to mount the remainder of @c the filesystem from whichever fileservers are available. @node Non-blocking Operation, , Keep-alives, Overview @comment node-name, next, previous, up @section Non-blocking Operation @cindex Non-blocking operation @cindex Multiple-threaded server @cindex RPC retries Since there is only one instance of @i{Amd} for each automount point, and usually only one instance on each machine, it is important that it is always available to service kernel calls. @i{Amd} goes to great lengths to ensure that it does not block in a system call. As a last resort @i{Amd} will fork before it attempts a system call that may block indefinitely, such as mounting an NFS filesystem. Other tasks such as obtaining filehandle information for an NFS filesystem, are done using a purpose built non-blocking RPC library which is integrated with @i{Amd}'s task scheduler. This library is also used to implement NFS keep-alives (@pxref{Keep-alives}). Whenever a mount is deferred or backgrounded, @i{Amd} must wait for it to complete before replying to the kernel. However, this would cause @i{Amd} to block waiting for a reply to be constructed. Rather than do this, @i{Amd} simply @dfn{drops} the call under the assumption that the kernel RPC mechanism will automatically retry the request. @c ################################################################ @node Supported Platforms, Mount Maps, Overview, Top @comment node-name, next, previous, up @chapter Supported Platforms @cindex Supported Platforms @cindex shared libraries @cindex NFS V.3 support @i{Am-utils} has been ported to a wide variety of machines and operating systems. @i{Am-utils}'s code works for little-endian and big-endian machines, as well as 32 bit and 64 bit architectures. Furthermore, when @i{Am-utils} ports to an Operating System on one architecture, it is generally readily portable to the same Operating System on all platforms on which it is available. See the @file{INSTALL} in the distribution for more specific details on building and/or configuring for some systems. @c ################################################################ @node Mount Maps, Amd Command Line Options, Supported Platforms, Top @comment node-name, next, previous, up @chapter Mount Maps @cindex Mount maps @cindex Automounter configuration maps @cindex Mount information @i{Amd} has no built-in knowledge of machines or filesystems. External @dfn{mount-maps} are used to provide the required information. Specifically, @i{Amd} needs to know when and under what conditions it should mount filesystems. The map entry corresponding to the requested name contains a list of possible locations from which to resolve the request. Each location specifies filesystem type, information required by that filesystem (for example the block special device in the case of UFS), and some information describing where to mount the filesystem (@pxref{fs Option}). A location may also contain @dfn{selectors} (@pxref{Selectors}).@refill @menu * Map Types:: * Key Lookup:: * Location Format:: @end menu @node Map Types, Key Lookup, Mount Maps, Mount Maps @comment node-name, next, previous, up @section Map Types @cindex Mount map types @cindex Map types @cindex Configuration map types @cindex Types of mount map @cindex Types of configuration map @cindex Determining the map type A mount-map provides the run-time configuration information to @i{Amd}. Maps can be implemented in many ways. Some of the forms supported by @i{Amd} are regular files, ndbm databases, NIS maps, the @dfn{Hesiod} name server, and even the password file. A mount-map @dfn{name} is a sequence of characters. When an automount point is created a handle on the mount-map is obtained. For each map type configured, @i{Amd} attempts to reference the map of the appropriate type. If a map is found, @i{Amd} notes the type for future use and deletes the reference, for example closing any open file descriptors. The available maps are configured when @i{Amd} is built and can be displayed by running the command @samp{amd -v}. When using an @i{Amd} configuration file (@pxref{Amd Configuration File}) and the keyword @samp{map_type} (@pxref{map_type Parameter}), you may force the map used to any type. By default, @i{Amd} caches data in a mode dependent on the type of map. This is the same as specifying @samp{cache:=mapdefault} and selects a suitable default cache mode depending on the map type. The individual defaults are described below. The @var{cache} option can be specified on automount points to alter the caching behavior (@pxref{Automount Filesystem}).@refill The following map types have been implemented, though some are not available on all machines. Run the command @samp{amd -v} to obtain a list of map types configured on your machine. @menu * File maps:: * ndbm maps:: * NIS maps:: * NIS+ maps:: * Hesiod maps:: * Password maps:: * Union maps:: * LDAP maps:: * Executable maps:: @end menu @c ---------------------------------------------------------------- @node File maps, ndbm maps, Map Types, Map Types @comment node-name, next, previous, up @subsection File maps @cindex File maps @cindex Flat file maps @cindex File map syntactic conventions When @i{Amd} searches a file for a map entry it does a simple scan of the file and supports both comments and continuation lines. Continuation lines are indicated by a backslash character (@samp{\}) as the last character of a line in the file. The backslash, newline character @emph{and any leading white space on the following line} are discarded. A maximum line length of 2047 characters is enforced after continuation lines are read but before comments are stripped. Each line must end with a newline character; that is newlines are terminators, not separators. The following examples illustrate this: @example key valA valB; \ valC @end example specifies @emph{three} locations, and is identical to @example key valA valB; valC @end example However, @example key valA valB;\ valC @end example specifies only @emph{two} locations, and is identical to @example key valA valB;valC @end example After a complete line has been read from the file, including continuations, @i{Amd} determines whether there is a comment on the line. A comment begins with a hash (``@samp{#}'') character and continues to the end of the line. There is no way to escape or change the comment lead-in character. Note that continuation lines and comment support @dfn{only} apply to file maps, or ndbm maps built with the @code{mk-amd-map} program. When caching is enabled, file maps have a default cache mode of @code{all} (@pxref{Automount Filesystem}). @c ---------------------------------------------------------------- @node ndbm maps, NIS maps, File maps, Map Types @comment node-name, next, previous, up @subsection ndbm maps @cindex ndbm maps An ndbm map may be used as a fast access form of a file map. The program, @code{mk-amd-map}, converts a normal map file into an ndbm database. This program supports the same continuation and comment conventions that are provided for file maps. Note that ndbm format files may @emph{not} be sharable across machine architectures. The notion of speed generally only applies to large maps; a small map, less than a single disk block, is almost certainly better implemented as a file map. ndbm maps have a default cache mode of @samp{all} (@pxref{Automount Filesystem}). @c ---------------------------------------------------------------- @node NIS maps, NIS+ maps, ndbm maps, Map Types @comment node-name, next, previous, up @subsection NIS maps @cindex NIS (YP) maps When using NIS (formerly YP), an @i{Amd} map is implemented directly by the underlying NIS map. Comments and continuation lines are @emph{not} supported in the automounter and must be stripped when constructing the NIS server's database. NIS maps have a default cache mode of @code{all} (@pxref{Automount Filesystem}). The following rule illustrates what could be added to your NIS @file{Makefile}, in this case causing the @file{amd.home} map to be rebuilt: @example $(YPTSDIR)/amd.home.time: $(ETCDIR)/amd.home -@@sed -e "s/#.*$$//" -e "/^$$/d" $(ETCDIR)/amd.home | \ awk '@{ \ for (i = 1; i <= NF; i++) \ if (i == NF) @{ \ if (substr($$i, length($$i), 1) == "\\") \ printf("%s", substr($$i, 1, length($$i) - 1)); \ else \ printf("%s\n", $$i); \ @} \ else \ printf("%s ", $$i); \ @}' | \ $(MAKEDBM) - $(YPDBDIR)/amd.home; \ touch $(YPTSDIR)/amd.home.time; \ echo "updated amd.home"; \ if [ ! $(NOPUSH) ]; then \ $(YPPUSH) amd.home; \ echo "pushed amd.home"; \ else \ : ; \ fi @end example Here @code{$(YPTSDIR)} contains the time stamp files, and @code{$(YPDBDIR)} contains the dbm format NIS files. @c ---------------------------------------------------------------- @node NIS+ maps, Hesiod maps, NIS maps, Map Types @comment node-name, next, previous, up @subsection NIS+ maps @cindex NIS+ maps NIS+ maps do not support cache mode @samp{all} and, when caching is enabled, have a default cache mode of @samp{inc}. XXX: FILL IN WITH AN EXAMPLE. @c ---------------------------------------------------------------- @node Hesiod maps, Password maps, NIS+ maps, Map Types @comment node-name, next, previous, up @subsection Hesiod maps @cindex Hesiod maps When the map name begins with the string @samp{hesiod.} lookups are made using the @dfn{Hesiod} name server. The string following the dot is used as a name qualifier and is prepended with the key being located. The entire string is then resolved in the @code{automount} context, or the @i{amd.conf} parameter @samp{hesiod_base} (@pxref{hesiod_base Parameter}). For example, if the key is @samp{jsp} and map name is @samp{hesiod.homes} then @dfn{Hesiod} is asked to resolve @samp{jsp.homes.automount}. Hesiod maps do not support cache mode @samp{all} and, when caching is enabled, have a default cache mode of @samp{inc} (@pxref{Automount Filesystem}). The following is an example of a @dfn{Hesiod} map entry: @example jsp.homes.automount HS TXT "rfs:=/home/charm;rhost:=charm;sublink:=jsp" njw.homes.automount HS TXT "rfs:=/home/dylan/dk2;rhost:=dylan;sublink:=njw" @end example @c ---------------------------------------------------------------- @node Password maps, Union maps, Hesiod maps, Map Types @comment node-name, next, previous, up @subsection Password maps @cindex Password file maps @cindex /etc/passwd maps @cindex User maps, automatic generation @cindex Automatic generation of user maps @cindex Using the password file as a map The password map support is unlike the four previous map types. When the map name is the string @file{/etc/passwd} @i{Amd} can lookup a user name in the password file and re-arrange the home directory field to produce a usable map entry. @i{Amd} assumes the home directory has the format `@t{/}@i{anydir}@t{/}@i{dom1}@t{/../}@i{domN}@t{/}@i{login}'. @c @footnote{This interpretation is not necessarily exactly what you want.} It breaks this string into a map entry where @code{$@{rfs@}} has the value `@t{/}@i{anydir}@t{/}@i{domN}', @code{$@{rhost@}} has the value `@i{domN}@t{.}@i{...}@t{.}@i{dom1}', and @code{$@{sublink@}} has the value @i{login}.@refill Thus if the password file entry was @example /home/achilles/jsp @end example the map entry used by @i{Amd} would be @example rfs:=/home/achilles;rhost:=achilles;sublink:=jsp @end example Similarly, if the password file entry was @example /home/cc/sugar/mjh @end example the map entry used by @i{Amd} would be @example rfs:=/home/sugar;rhost:=sugar.cc;sublink:=mhj @end example @c ---------------------------------------------------------------- @node Union maps, LDAP maps, Password maps, Map Types @comment node-name, next, previous, up @subsection Union maps @cindex Union file maps The union map support is provided specifically for use with the union filesystem, @pxref{Union Filesystem}. It is identified by the string @samp{union:} which is followed by a colon separated list of directories. The directories are read in order, and the names of all entries are recorded in the map cache. Later directories take precedence over earlier ones. The union filesystem type then uses the map cache to determine the union of the names in all the directories. @c ---------------------------------------------------------------- @node LDAP maps, Executable maps, Union maps, Map Types @comment node-name, next, previous, up @subsection LDAP maps @cindex LDAP maps @cindex Lightweight Directory Access Protocol LDAP (Lightweight Directory Access Protocol) maps do not support cache mode @samp{all} and, when caching is enabled, have a default cache mode of @samp{inc}. For example, an @i{Amd} map @samp{amd.home} that looks as follows: @example /defaults opts:=rw,intr;type:=link zing -rhost:=shekel \ host==shekel \ host!=shekel;type:=nfs @end example @noindent when converted to LDAP (@pxref{amd2ldif}), will result in the following LDAP database: @example $ amd2ldif amd.home CUCS < amd.home dn: cn=amdmap timestamp, CUCS cn : amdmap timestamp objectClass : amdmapTimestamp amdmapTimestamp: 873071363 dn: cn=amdmap amd.home[/defaults], CUCS cn : amdmap amd.home[/defaults] objectClass : amdmap amdmapName : amd.home amdmapKey : /defaults amdmapValue : opts:=rw,intr;type:=link dn: cn=amdmap amd.home[], CUCS cn : amdmap amd.home[] objectClass : amdmap amdmapName : amd.home amdmapKey : amdmapValue : dn: cn=amdmap amd.home[zing], CUCS cn : amdmap amd.home[zing] objectClass : amdmap amdmapName : amd.home amdmapKey : zing amdmapValue : -rhost:=shekel host==shekel host!=shekel;type:=nfs @end example @c ---------------------------------------------------------------- @node Executable maps, , LDAP maps, Map Types @comment node-name, next, previous, up @subsection Executable maps @cindex Executable maps An executable map is a dynamic map in which the keys and values for the maps are generated on the fly by a program or script. The program is expected to take a single parameter argument which is the key to lookup. If the key is found, the program should print on stdout the key-value pair that were found; if the key was not found, nothing should be printed out. Below is an sample of such a map script: @example #!/bin/sh # executable map example case "$1" in "/defaults" ) echo "/defaults type:=nfs;rfs:=filer" ;; "a" ) echo "a type:=nfs;fs:=/tmp" ;; "b" ) echo "b type:=link;fs:=/usr/local" ;; * ) # no match, echo nothing ;; esac @end example @xref{exec_map_timeout Parameter}. @c ---------------------------------------------------------------- @c subsection Gdbm @c ---------------------------------------------------------------- @node Key Lookup, Location Format, Map Types, Mount Maps @comment node-name, next, previous, up @section How keys are looked up @cindex Key lookup @cindex Map lookup @cindex Looking up keys @cindex How keys are looked up @cindex Wildcards in maps The key is located in the map whose type was determined when the automount point was first created. In general the key is a pathname component. In some circumstances this may be modified by variable expansion (@pxref{Variable Expansion}) and prefixing. If the automount point has a prefix, specified by the @var{pref} option, then that is prepended to the search key before the map is searched. If the map cache is a @samp{regexp} cache then the key is treated as an egrep-style regular expression, otherwise a normal string comparison is made. If the key cannot be found then a @dfn{wildcard} match is attempted. @i{Amd} repeatedly strips the basename from the key, appends @samp{/*} and attempts a lookup. Finally, @i{Amd} attempts to locate the special key @samp{*}. For example, the following sequence would be checked if @file{home/dylan/dk2} was being located: @example home/dylan/dk2 home/dylan/* home/* * @end example At any point when a wildcard is found, @i{Amd} proceeds as if an exact match had been found and the value field is then used to resolve the mount request, otherwise an error code is propagated back to the kernel. (@pxref{Filesystem Types}).@refill @node Location Format, , Key Lookup, Mount Maps @comment node-name, next, previous, up @section Location Format @cindex Location format @cindex Map entry format @cindex How locations are parsed The value field from the lookup provides the information required to mount a filesystem. The information is parsed according to the syntax shown below. @display @i{location-list}: @i{location-selection} @i{location-list} @i{white-space} @t{||} @i{white-space} @i{location-selection} @i{location-selection}: @i{location} @i{location-selection} @i{white-space} @i{location} @i{location}: @i{location-info} @t{-}@i{location-info} @t{-} @i{location-info}: @i{sel-or-opt} @i{location-info}@t{;}@i{sel-or-opt} @t{;} @i{sel-or-opt}: @i{selection} @i{opt-ass} @i{selection}: selector@t{==}@i{value} selector@t{!=}@i{value} @i{opt-ass}: option@t{:=}@i{value} @i{white-space}: space tab @end display Note that unquoted whitespace is not allowed in a location description. White space is only allowed, and is mandatory, where shown with non-terminal @i{white-space}. A @dfn{location-selection} is a list of possible volumes with which to satisfy the request. Each @dfn{location-selection} is tried sequentially, until either one succeeds or all fail. This, by the way, is different from the historically documented behavior, which claimed (falsely, at least for last 3 years) that @i{Amd} would attempt to mount all @dfn{location-selection}s in parallel and the first one to succeed would be used. @dfn{location-selection}s are optionally separated by the @samp{||} operator. The effect of this operator is to prevent use of location-selections to its right if any of the location-selections on its left were selected, whether or not any of them were successfully mounted (@pxref{Selectors}).@refill The location-selection, and singleton @dfn{location-list}, @samp{type:=ufs;dev:=/dev/xd1g} would inform @i{Amd} to mount a UFS filesystem from the block special device @file{/dev/xd1g}. The @dfn{sel-or-opt} component is either the name of an option required by a specific filesystem, or it is the name of a built-in, predefined selector such as the architecture type. The value may be quoted with double quotes @samp{"}, for example @samp{type:="ufs";dev:="/dev/xd1g"}. These quotes are stripped when the value is parsed and there is no way to get a double quote into a value field. Double quotes are used to get white space into a value field, which is needed for the program filesystem (@pxref{Program Filesystem}).@refill @menu * Map Defaults:: * Variable Expansion:: * Selectors:: * Map Options:: @end menu @node Map Defaults, Variable Expansion, Location Format, Location Format @comment node-name, next, previous, up @subsection Map Defaults @cindex Map defaults @cindex How to set default map parameters @cindex Setting default map parameters A location beginning with a dash @samp{-} is used to specify default values for subsequent locations. Any previously specified defaults in the location-list are discarded. The default string can be empty in which case no defaults apply. The location @samp{-fs:=/mnt;opts:=ro} would set the local mount point to @file{/mnt} and cause mounts to be read-only by default. Defaults specified this way are appended to, and so override, any global map defaults given with @samp{/defaults}). @c @c A @samp{/defaults} value @dfn{gdef} and a location list @c \begin{quote} @c $@samp{-}@dfn{def}_a $\verb*+ +$ @dfn{loc}_{a_1} $\verb*+ +$ @dfn{loc}_{a_2} $\verb*+ +$ @samp{-}@dfn{def}_b $\verb*+ +$ @dfn{loc}_{b_1} \ldots$ @c \end{quote} @c is equivalent to @c \begin{quote} @c $@samp{-}@dfn{gdef}@samp{;}@dfn{def}_a $\verb*+ +$ @dfn{loc}_{a_1} $\verb*+ +$ @dfn{loc}_{a_2} $\verb*+ +$ @samp{-}@dfn{gdef}@samp{;}@dfn{def}_b $\verb*+ +$ @dfn{loc}_{b_1} \ldots$ @c \end{quote} @c which is equivalent to @c \begin{quote} @c $@dfn{gdef}@samp{;}@dfn{def}_a@samp{;}@dfn{loc}_{a_1} $\verb*+ +$@dfn{gdef}@samp{;}@dfn{def}_a@samp{;}@dfn{loc}_{a_2} $\verb*+ +$@dfn{gdef}@samp{;}@dfn{def}_b@samp{;}@dfn{loc}_{b_1} \ldots$ @c \end{quote} @node Variable Expansion, Selectors, Map Defaults, Location Format @comment node-name, next, previous, up @subsection Variable Expansion @cindex Variable expansion @cindex How variables are expanded @cindex Pathname operators @cindex Domain stripping @cindex Domainname operators @cindex Stripping the local domain name @cindex Environment variables @cindex How to access environment variables in maps To allow generic location specifications @i{Amd} does variable expansion on each location and also on some of the option strings. Any option or selector appearing in the form @code{$@dfn{var}} is replaced by the current value of that option or selector. For example, if the value of @code{$@{key@}} was @samp{bin}, @code{$@{autodir@}} was @samp{/a} and @code{$@{fs@}} was `@t{$@{autodir@}}@t{/local/}@t{$@{key@}}' then after expansion @code{$@{fs@}} would have the value @samp{/a/local/bin}. Any environment variable can be accessed in a similar way.@refill Two pathname operators are available when expanding a variable. If the variable name begins with @samp{/} then only the last component of the pathname is substituted. For example, if @code{$@{path@}} was @samp{/foo/bar} then @code{$@{/path@}} would be expanded to @samp{bar}. Similarly, if the variable name ends with @samp{/} then all but the last component of the pathname is substituted. In the previous example, @code{$@{path/@}} would be expanded to @samp{/foo}.@refill Two domain name operators are also provided. If the variable name begins with @samp{.} then only the domain part of the name is substituted. For example, if @code{$@{rhost@}} was @samp{swan.doc.ic.ac.uk} then @code{$@{.rhost@}} would be expanded to @samp{doc.ic.ac.uk}. Similarly, if the variable name ends with @samp{.} then only the host component is substituted. In the previous example, @code{$@{rhost.@}} would be expanded to @samp{swan}.@refill Variable expansion is a two phase process. Before a location is parsed, all references to selectors, @i{eg} @code{$@{path@}}, are expanded. The location is then parsed, selections are evaluated and option assignments recorded. If there were no selections or they all succeeded the location is used and the values of the following options are expanded in the order given: @var{sublink}, @var{rfs}, @var{fs}, @var{opts}, @var{remopts}, @var{mount} and @var{unmount}. Note that expansion of option values is done after @dfn{all} assignments have been completed and not in a purely left to right order as is done by the shell. This generally has the desired effect but care must be taken if one of the options references another, in which case the ordering can become significant. There are two special cases concerning variable expansion: @enumerate @item before a map is consulted, any selectors in the name received from the kernel are expanded. For example, if the request from the kernel was for `@t{$@{arch@}}@t{.bin}' and the machine architecture was @samp{vax}, the value given to @code{$@{key@}} would be @samp{vax.bin}.@refill @item the value of @code{$@{rhost@}} is expanded and normalized before the other options are expanded. The normalization process strips any local sub-domain components. For example, if @code{$@{domain@}} was @samp{Berkeley.EDU} and @code{$@{rhost@}} was initially @samp{snow.Berkeley.EDU}, after the normalization it would simply be @samp{snow}. Hostname normalization is currently done in a @emph{case-dependent} manner.@refill @end enumerate @c====================================================================== @node Selectors, Map Options, Variable Expansion, Location Format @comment node-name, next, previous, up @subsection Selectors @cindex Selectors Selectors are used to control the use of a location. It is possible to share a mount map between many machines in such a way that filesystem location, architecture and operating system differences are hidden from the users. A selector of the form @samp{arch==sun3;os==sunos4} would only apply on Sun-3s running SunOS 4.x. Selectors can be negated by using @samp{!=} instead of @samp{==}. For example to select a location on all non-Vax machines the selector @samp{arch!=vax} would be used. Selectors are evaluated left to right. If a selector fails then that location is ignored. Thus the selectors form a conjunction and the locations form a disjunction. If all the locations are ignored or otherwise fail then @i{Amd} uses the @dfn{error} filesystem (@pxref{Error Filesystem}). This is equivalent to having a location @samp{type:=error} at the end of each mount-map entry.@refill The default value of many of the selectors listed here can be overridden by an @i{Amd} command line switch or in an @i{Amd} configuration file. @xref{Amd Configuration File}. The following selectors are currently implemented. @menu * arch Selector Variable:: * autodir Selector Variable:: * byte Selector Variable:: * cluster Selector Variable:: * domain Selector Variable:: * dollar Selector Variable:: * host Selector Variable:: * hostd Selector Variable:: * karch Selector Variable:: * os Selector Variable:: * osver Selector Variable:: * full_os Selector Variable:: * vendor Selector Variable:: * key Selector Variable:: * map Selector Variable:: * netnumber Selector Variable:: * network Selector Variable:: * path Selector Variable:: * wire Selector Variable:: * uid Selector Variable:: * gid Selector Variable:: * exists Selector Function:: * false Selector Function:: * netgrp Selector Function:: * netgrpd Selector Function:: * in_network Selector Function:: * true Selector Function:: * xhost Selector Function:: @end menu @c ---------------------------------------------------------------- @node arch Selector Variable, autodir Selector Variable, Selectors, Selectors @comment node-name, next, previous, up @subsubsection arch Selector Variable @cindex arch Selector Variable @cindex arch, mount selector @cindex Mount selector; arch @cindex Selector; arch The machine architecture which was automatically determined at compile time. The architecture type can be displayed by running the command @samp{amd -v}. You can override this value also using the @code{-A} command line option. @xref{Supported Platforms}.@refill @c ---------------------------------------------------------------- @node autodir Selector Variable, byte Selector Variable, arch Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection autodir Selector Variable @cindex autodir Selector Variable @cindex autodir, mount selector @cindex Mount selector; autodir @cindex Selector; autodir The default directory under which to mount filesystems. This may be changed by the @code{-a} command line option. @xref{fs Option}. @c ---------------------------------------------------------------- @node byte Selector Variable, cluster Selector Variable, autodir Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection byte Selector Variable @cindex byte Selector Variable @cindex byte, mount selector @cindex Mount selector; byte @cindex Selector; byte The machine's byte ordering. This is either @samp{little}, indicating little-endian, or @samp{big}, indicating big-endian. One possible use is to share @samp{rwho} databases (@pxref{rwho servers}). Another is to share ndbm databases, however this use can be considered a courageous juggling act. @c ---------------------------------------------------------------- @node cluster Selector Variable, domain Selector Variable, byte Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection cluster Selector Variable @cindex cluster Selector Variable @cindex cluster, mount selector @cindex Mount selector; cluster @cindex Selector; cluster This is provided as a hook for the name of the local cluster. This can be used to decide which servers to use for copies of replicated filesystems. @code{$@{cluster@}} defaults to the value of @code{$@{domain@}} unless a different value is set with the @code{-C} command line option. @c ---------------------------------------------------------------- @node domain Selector Variable, dollar Selector Variable, cluster Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection domain Selector Variable @cindex domain Selector Variable @cindex domain, mount selector @cindex Mount selector; domain @cindex Selector; domain The local domain name as specified by the @code{-d} command line option. @xref{host Selector Variable}. @c ---------------------------------------------------------------- @node dollar Selector Variable, host Selector Variable, domain Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection dollar Selector Variable @cindex dollar Selector Variable This is a special variable, whose sole purpose is to produce a literal dollar sign in the value of another variable. For example, if you have a remote file system whose name is @samp{/disk$s}, you can mount it by setting the remote file system variable as follows: @example rfs:=/disk$@{dollar@}s @end example @c ---------------------------------------------------------------- @node host Selector Variable, hostd Selector Variable, dollar Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection host Selector Variable @cindex host Selector Variable @cindex host, mount selector @cindex Mount selector; host @cindex Selector; host The local hostname as determined by @b{gethostname}(2). If no domain name was specified on the command line and the hostname contains a period @samp{.} then the string before the period is used as the host name, and the string after the period is assigned to @code{$@{domain@}}. For example, if the hostname is @samp{styx.doc.ic.ac.uk} then @code{host} would be @samp{styx} and @code{domain} would be @samp{doc.ic.ac.uk}. @code{hostd} would be @samp{styx.doc.ic.ac.uk}.@refill @c ---------------------------------------------------------------- @node hostd Selector Variable, karch Selector Variable, host Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection hostd Selector Variable @cindex hostd Selector Variable @cindex hostd, mount selector @cindex Mount selector; hostd @cindex Selector; hostd This resolves to the @code{$@{host@}} and @code{$@{domain@}} concatenated with a @samp{.} inserted between them if required. If @code{$@{domain@}} is an empty string then @code{$@{host@}} and @code{$@{hostd@}} will be identical. @c ---------------------------------------------------------------- @node karch Selector Variable, os Selector Variable, hostd Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection karch Selector Variable @cindex karch Selector Variable @cindex karch, mount selector @cindex Mount selector; karch @cindex Selector; karch This is provided as a hook for the kernel architecture. This is used on SunOS 4 and SunOS 5, for example, to distinguish between different @samp{/usr/kvm} volumes. @code{$@{karch@}} defaults to the ``machine'' value gotten from @b{uname}(2). If the @b{uname}(2) system call is not available, the value of @code{$@{karch@}} defaults to that of @code{$@{arch@}}. Finally, a different value can be set with the @code{-k} command line option. @c ---------------------------------------------------------------- @node os Selector Variable, osver Selector Variable, karch Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection os Selector Variable @cindex os Selector Variable @cindex os, mount selector @cindex Mount selector; os @cindex Selector; os The operating system. Like the machine architecture, this is automatically determined at compile time. The operating system name can be displayed by running the command @samp{amd -v}. @xref{Supported Platforms}.@refill @c ---------------------------------------------------------------- @node osver Selector Variable, full_os Selector Variable, os Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection osver Selector Variable @cindex osver Selector Variable @cindex osver, mount selector @cindex Mount selector; osver @cindex Selector; osver The operating system version. Like the machine architecture, this is automatically determined at compile time. The operating system name can be displayed by running the command @samp{amd -v}. @xref{Supported Platforms}.@refill @c ---------------------------------------------------------------- @node full_os Selector Variable, vendor Selector Variable, osver Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection full_os Selector Variable @cindex full_os Selector Variable @cindex full_os, mount selector @cindex Mount selector; full_os @cindex Selector; full_os The full name of the operating system, including its version. This value is automatically determined at compile time. The full operating system name and version can be displayed by running the command @samp{amd -v}. @xref{Supported Platforms}.@refill @c ---------------------------------------------------------------- @node vendor Selector Variable, key Selector Variable, full_os Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection vendor Selector Variable @cindex vendor Selector Variable @cindex vendor, mount selector @cindex Mount selector; vendor @cindex Selector; vendor The name of the vendor of the operating system. This value is automatically determined at compile time. The name of the vendor can be displayed by running the command @samp{amd -v}. @xref{Supported Platforms}.@refill @c ---------------------------------------------------------------- @ifhtml
@end ifhtml @sp 3 The following selectors are also provided. Unlike the other selectors, they vary for each lookup. Note that when the name from the kernel is expanded prior to a map lookup, these selectors are all defined as empty strings. @c ---------------------------------------------------------------- @node key Selector Variable, map Selector Variable, vendor Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection key Selector Variable @cindex key Selector Variable @cindex key, mount selector @cindex Mount selector; key @cindex Selector; key The name being resolved. For example, if @file{/home} is an automount point, then accessing @file{/home/foo} would set @code{$@{key@}} to the string @samp{foo}. The key is prefixed by the @var{pref} option set in the parent mount point. The default prefix is an empty string. If the prefix was @file{blah/} then @code{$@{key@}} would be set to @file{blah/foo}.@refill @c ---------------------------------------------------------------- @node map Selector Variable, netnumber Selector Variable, key Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection map Selector Variable @cindex map Selector Variable @cindex map, mount selector @cindex Mount selector; map @cindex Selector; map The name of the mount map being used. @c ---------------------------------------------------------------- @node netnumber Selector Variable, network Selector Variable, map Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection netnumber Selector Variable @cindex netnumber Selector Variable @cindex netnumber, mount selector @cindex Mount selector; netnumber @cindex Selector; netnumber This selector is identical to the @samp{in_network} selector function, see @ref{in_network Selector Function}. It will match either the name or number of @i{any} network interface on which this host is connected to. The names and numbers of all attached interfaces are available from the output of @samp{amd -v}. @c ---------------------------------------------------------------- @node network Selector Variable, path Selector Variable, netnumber Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection network Selector Variable @cindex network Selector Variable @cindex network, mount selector @cindex Mount selector; network @cindex Selector; network This selector is identical to the @samp{in_network} selector function, see @ref{in_network Selector Function}. It will match either the name or number of @i{any} network interface on which this host is connected to. The names and numbers of all attached interfaces are available from the output of @samp{amd -v}. @c ---------------------------------------------------------------- @node path Selector Variable, wire Selector Variable, network Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection path Selector Variable @cindex path Selector Variable @cindex path, mount selector @cindex Mount selector; path @cindex Selector; path The full pathname of the name being resolved. For example @file{/home/foo} in the example above. @c ---------------------------------------------------------------- @node wire Selector Variable, uid Selector Variable, path Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection wire Selector Variable @cindex wire Selector Variable @cindex wire, mount selector @cindex Mount selector; wire @cindex Selector; wire This selector is identical to the @samp{in_network} selector function, see @ref{in_network Selector Function}. It will match either the name or number of @i{any} network interface on which this host is connected to. The names and numbers of all attached interfaces are available from the output of @samp{amd -v}. @c ---------------------------------------------------------------- @node uid Selector Variable, gid Selector Variable, wire Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection uid Selector Variable @cindex uid Selector Variable @cindex uid, mount selector @cindex Mount selector; uid @cindex Selector; uid This selector provides the numeric effective user ID (UID) of the user which last accessed an automounted path name. This simple example shows how floppy mounting can be assigned only to machine owners: @example floppy -type:=pcfs \ uid==2301;host==shekel;dev:=/dev/floppy \ uid==6712;host==titan;dev=/dev/fd0 \ uid==0;dev:=/dev/fd0c \ type:=error @end example The example allows two machine owners to mount floppies on their designated workstations, allows the root user to mount on any host, and otherwise forces an error. @c ---------------------------------------------------------------- @node gid Selector Variable, exists Selector Function, uid Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection gid Selector Variable @cindex gid Selector Variable @cindex gid, mount selector @cindex Mount selector; gid @cindex Selector; gid This selector provides the numeric effective group ID (GID) of the user which last accessed an automounted path name. @c ---------------------------------------------------------------- @ifhtml
@end ifhtml @sp 2 The following boolean functions are selectors which take an argument @i{ARG}. They return a value of true or false, and thus do not need to be compared with a value. Each of these may be negated by prepending @samp{!} to their name. @c ---------------------------------------------------------------- @node exists Selector Function, false Selector Function, gid Selector Variable, Selectors @comment node-name, next, previous, up @subsubsection exists Selector Function @cindex exists Selector Function @cindex exists, boolean mount selector @cindex !exists, boolean mount selector @cindex Mount selector; exists @cindex Selector; exists If the file listed by @i{ARG} exists (via @b{lstat}(2)), this function evaluates to true. Otherwise it evaluates to false. @c ---------------------------------------------------------------- @node false Selector Function, netgrp Selector Function, exists Selector Function, Selectors @comment node-name, next, previous, up @subsubsection false Selector Function @cindex false Selector Function @cindex false, boolean mount selector @cindex !false, boolean mount selector @cindex Mount selector; false @cindex Selector; false Always evaluates to false. @i{ARG} is ignored. @c ---------------------------------------------------------------- @node netgrp Selector Function, netgrpd Selector Function, false Selector Function, Selectors @comment node-name, next, previous, up @subsubsection netgrp Selector Function @cindex netgrp Selector Function @cindex netgrp, boolean mount selector @cindex !netgrp, boolean mount selector @cindex Mount selector; netgrp @cindex Selector; netgrp The argument @i{ARG} of this selector is a netgroup name followed optionally by a comma and a host name. If the host name is not specified, it defaults to @code{$@{host@}}. If the host name (short name) is a member of the netgroup, this selector evaluates to true. Otherwise it evaluates to false. For example, suppose you have a netgroup @samp{ppp-hosts}, and for reasons of performance, these have a local @file{/home} partition, while all other clients on the faster network can access a shared home directory. A common map to use for both might look like the following: @example home/* netgrp(ppp-hosts);type:=link;fs:=/local/$@{key@} \ !netgrp(ppp-hosts);type:=nfs;rhost:=serv1;rfs:=/remote/$@{key@} @end example A more complex example that takes advantage of the two argument netgrp mount selector is given in the following scenario. Suppose one wants to mount the local scratch space from a each host under @file{scratch/} and some hosts have their scratch space in a different path than others. Hosts in the netgroup @samp{apple-hosts} have their scratch space in the @file{/apple} path, where hosts in the netgroup @samp{cherry-hosts} have their scratch space in the @file{/cherry} path. For hosts that are neither in the @samp{apple-hosts} or @samp{cherry-hosts} netgroups we want to make a symlink pointing to nowhere but provide a descriptive error message in the link destination: @example scratch/* netgrp(apple-hosts,$@{/key@});type:=nfs;rhost:=$@{/key@};\ rfs:="/apple" \ netgrp(cherry-hosts,$@{/key@});type:=nfs;rhost:=$@{/key@};\ rfs:="/cherry" \ type:=link;rfs:="no local partition for $@{/key@}" @end example @c ---------------------------------------------------------------- @node netgrpd Selector Function, in_network Selector Function, netgrp Selector Function, Selectors @comment node-name, next, previous, up @subsubsection netgrpd Selector Function @cindex netgrpd Selector Function @cindex netgrpd, boolean mount selector @cindex !netgrpd, boolean mount selector @cindex Mount selector; netgrpd @cindex Selector; netgrpd The argument @i{ARG} of this selector is a netgroup name followed optionally by a comma and a host name. If the host name is not specified, it defaults to @code{$@{hostd@}}. If the host name (fully-qualified name) is a member of the netgroup, this selector evaluates to true. Otherwise it evaluates to false. The @samp{netgrpd} function uses fully-qualified host names to match netgroup names, while the @samp{netgrp} function (@pxref{netgrp Selector Function}) uses short host names. @c ---------------------------------------------------------------- @node in_network Selector Function, true Selector Function, netgrpd Selector Function, Selectors @comment node-name, next, previous, up @subsubsection in_network Selector Function @cindex in_network Selector Function @cindex in_network, boolean mount selector @cindex !in_network, boolean mount selector @cindex Mount selector; in_network @cindex Selector; in_network This selector matches against any network name or number with an optional netmask. First, if the current host has any network interface that is locally attached to the network specified in @i{ARG} (either via name or number), this selector evaluates to true. Second, @samp{in_network} supports a network/netmask syntax such as @samp{128.59.16.0/255.255.255.0}, @samp{128.59.16.0/24}, @samp{128.59.16.0/0xffffff00}, or @samp{128.59.16.0/}. Using the last form, @i{Amd} will match the specified network number against the default netmasks of each of the locally attached interfaces. If the selector does not match, it evaluates to false. For example, suppose you have two servers that have an exportable @file{/opt} that smaller clients can NFS mount. The two servers are say, @samp{serv1} on network @samp{foo-net.site.com} and @samp{serv2} on network @samp{123.4.5.0}. You can write a map to be used by all clients that will attempt to mount the closest one as follows: @example opt in_network(foo-net.site.com);rhost:=serv1;rfs:=/opt \ in_network(123.4.5.0);rhost:=serv2;rfs:=/opt \ rhost:=fallback-server @end example @c ---------------------------------------------------------------- @node true Selector Function, xhost Selector Function, in_network Selector Function, Selectors @comment node-name, next, previous, up @subsubsection true Selector Function @cindex true Selector Function @cindex true, boolean mount selector @cindex !true, boolean mount selector @cindex Mount selector; true @cindex Selector; true Always evaluates to true. @i{ARG} is ignored. @c ---------------------------------------------------------------- @node xhost Selector Function, , true Selector Function, Selectors @comment node-name, next, previous, up @subsubsection xhost Selector Function @cindex xhost Selector Function @cindex xhost, boolean mount selector @cindex !xhost, boolean mount selector @cindex Mount selector; xhost @cindex Selector; xhost @cindex CNAMEs This function compares @i{ARG} against the current hostname, similarly to the @ref{host Selector Variable}. However, this function will also match if @i{ARG} is a CNAME (DNS Canonical Name, or alias) for the current host's name. @c ================================================================ @node Map Options, , Selectors, Location Format @comment node-name, next, previous, up @subsection Map Options @cindex Map options @cindex Setting map options Options are parsed concurrently with selectors. The difference is that when an option is seen the string following the @samp{:=} is recorded for later use. As a minimum the @var{type} option must be specified. Each filesystem type has other options which must also be specified. @xref{Filesystem Types}, for details on the filesystem specific options.@refill Superfluous option specifications are ignored and are not reported as errors. The following options apply to more than one filesystem type. @menu * addopts Option:: * delay Option:: * fs Option:: * opts Option:: * remopts Option:: * sublink Option:: * type Option:: @end menu @node addopts Option, delay Option, Map Options, Map Options @comment node-name, next, previous, up @subsubsection addopts Option @cindex Setting additional options on a mount location @cindex Overriding or adding options to a mount @cindex addopts, mount option @cindex Mount option; addopts This option adds additional options to default options normally specified in the @samp{/defaults} entry or the defaults of the key entry being processed (@pxref{opts Option}). Normally when you specify @samp{opts} in both the @samp{/defaults} and the map entry, the latter overrides the former completely. But with @samp{addopts} it will append the options and override any conflicting ones. @samp{addopts} also overrides the value of the @samp{remopts} option (@pxref{remopts Option}), which unless specified defaults to the value of @samp{opts}. Options which start with @samp{no} will override those with the same name that do not start with @samp{no} and vice verse. Special handling is given to inverted options such as @samp{soft} and @samp{hard}, @samp{bg} and @samp{fg}, @samp{ro} and @samp{rw}, etc. For example, if the default options specified were @example opts:=rw,nosuid,intr,rsize=1024,wsize=1024,quota,posix @end example and the ones specified in a map entry were @example addopts:=grpid,suid,ro,rsize=2048,quota,nointr @end example then the actual options used would be @example wsize=1024,posix,grpid,suid,ro,rsize=2048,quota,nointr @end example @node delay Option, fs Option, addopts Option, Map Options @comment node-name, next, previous, up @subsubsection delay Option @cindex Setting a delay on a mount location @cindex Delaying mounts from specific locations @cindex Primary server @cindex Secondary server @cindex delay, mount option @cindex Mount option; delay The delay, in seconds, before an attempt will be made to mount from the current location. Auxiliary data, such as network address, file handles and so on are computed regardless of this value. A delay can be used to implement the notion of primary and secondary file servers. The secondary servers would have a delay of a few seconds, thus giving the primary servers a chance to respond first. @node fs Option, opts Option, delay Option, Map Options @comment node-name, next, previous, up @subsubsection fs Option @cindex Setting the local mount point @cindex Overriding the default mount point @cindex fs, mount option @cindex Mount option; fs The local mount point. The semantics of this option vary between filesystems. For NFS and UFS filesystems the value of @code{$@{fs@}} is used as the local mount point. For other filesystem types it has other meanings which are described in the section describing the respective filesystem type. It is important that this string uniquely identifies the filesystem being mounted. To satisfy this requirement, it should contain the name of the host on which the filesystem is resident and the pathname of the filesystem on the local or remote host. The reason for requiring the hostname is clear if replicated filesystems are considered. If a fileserver goes down and a replacement filesystem is mounted then the @dfn{local} mount point @dfn{must} be different from that of the filesystem which is hung. Some encoding of the filesystem name is required if more than one filesystem is to be mounted from any given host. If the hostname is first in the path then all mounts from a particular host will be gathered below a single directory. If that server goes down then the hung mount points are less likely to be accidentally referenced, for example when @b{getcwd}(3) traverses the namespace to find the pathname of the current directory. The @samp{fs} option defaults to @code{$@{autodir@}/$@{rhost@}$@{rfs@}}. In addition, @samp{rhost} defaults to the local host name (@code{$@{host@}}) and @samp{rfs} defaults to the value of @code{$@{path@}}, which is the full path of the requested file; @samp{/home/foo} in the example above (@pxref{Selectors}). @code{$@{autodir@}} defaults to @samp{/a} but may be changed with the @code{-a} command line option. Sun's automounter defaults to @samp{/tmp_mnt}. Note that there is no @samp{/} between the @code{$@{rhost@}} and @code{$@{rfs@}} since @code{$@{rfs@}} begins with a @samp{/}.@refill @node opts Option, remopts Option, fs Option, Map Options @comment node-name, next, previous, up @subsubsection opts Option @cindex Setting system mount options @cindex Passing parameters to the mount system call @cindex mount system call @cindex mount system call flags @cindex The mount system call @cindex opts, mount option @cindex Mount option; opts The options to pass to the mount system call. A leading @samp{-} is silently ignored. The mount options supported generally correspond to those used by @b{mount}(8) and are listed below. Some additional pseudo-options are interpreted by @i{Amd} and are also listed. Unless specifically overridden, each of the system default mount options applies. Any options not recognized are ignored. If no options list is supplied the string @samp{rw,defaults} is used and all the system default mount options apply. Options which are not applicable for a particular operating system are silently ignored. For example, only 4.4BSD is known to implement the @code{compress} and @code{spongy} options. @table @code @item acdirmax=@var{n} @cindex Mount flags; acdirmax Set the maximum directory attribute cache timeout to @var{n}. @item acdirmin=@var{n} @cindex Mount flags; acdirmin Set the minimum directory attribute cache timeout to @var{n}. @item acregmax=@var{n} @cindex Mount flags; acregmax Set the maximum file attribute cache timeout to @var{n}. @item acregmin=@var{n} @cindex Mount flags; acregmin Set the minimum file attribute cache timeout to @var{n}. @item actimeo=@var{n} @cindex Mount flags; actimeo Set the overall attribute cache timeout to @var{n}. @item auto @cindex Mount flags; auto @itemx ignore @cindex Mount flags; ignore Ignore this mount by @b{df}(1). @item cache @cindex Mount flags; cache Allow data to be cached from a remote server for this mount. @item closesession @cindex Mount flags; closesession For UDF mounts, close the session when unmounting. @item compress @cindex Mount flags; compress Use NFS compression protocol. @item defperm @cindex Mount flags; defperm Ignore the permission mode bits, and default file permissions to 0555, UID 0, and GID 0. Useful for CD-ROMs formatted as ISO-9660. @item dev @cindex Mount flags; dev Allow local special devices on this filesystem. @item dirmask=@var{n} @cindex Mount flags; dirmask For PCFS mounts, specify the maximum file permissions for directories in the file system. See the @samp{mask} option's description for more details. The mask value of @var{n} can be specified in decimal, octal, or hexadecimal. @item dumbtimr @cindex Mount flags; dumbtimr Turn off the dynamic retransmit timeout estimator. This may be useful for UDP mounts that exhibit high retry rates, since it is possible that the dynamically estimated timeout interval is too short. @item extatt @cindex Mount flags; extatt Enable extended attributes in ISO-9660 file systems. @item fsid @cindex Mount flags; fsid Set ID of filesystem. @item gens @cindex Mount flags; gens Enable generations in ISO-9660 file systems. Generations allow you to see all versions of a given file. @item gmtoff=@var{n} @cindex Mount flags; gmtoff For UDF mounts, set the time zone offset from UTC to @var{n} seconds, with positive values indicating east of the Prime Meridian. If not set, the user's current time zone will be used. @item group=@var{n} @cindex Mount flags; group For PCFS and UDF mounts, set the group of the files in the file system to @var{n} (which can either be a group name or a GID number). The default group is the group of the directory on which the file system is being mounted. @item grpid @cindex Mount flags; grpid Use BSD directory group-id semantics. @item int @cindex Mount flags; int @itemx intr @cindex Mount flags; intr Allow keyboard interrupts on hard mounts. @item lock @cindex Mount flags; lock Use the NFS locking protocol (default) @item longname @cindex Mount Flags; longname For PCFS mounts, force Win95 long names. @item mask=@var{n} @cindex Mount flags; mask For PCFS mounts, specify the maximum file permissions for files in the file system. For example, a mask of 755 specifies that, by default, the owner should have read, write, and execute permissions for files, but others should only have read and execute permissions. Only the nine low-order bits of mask are used. The default mask is taken from the directory on which the file system is being mounted. The mask value of @var{n} can be specified in decimal, octal, or hexadecimal. @item multi @cindex Mount flags; multi Perform multi-component lookup on files. @item maxgroups @cindex Mount flags; maxgroups Set the maximum number of groups to allow for this mount. @item nfsv3 @cindex Mount flags; nfsv3 Use NFS Version 3 for this mount. @item noac @cindex Mount flags; noac Turn off the attribute cache. @item noauto @cindex Mount flags; noauto This option is used by the mount command in @samp{/etc/fstab} or @samp{/etc/vfstab} and means not to mount this file system when mount -a is used. @item nocache @cindex Mount flags; nocache Do not allow data to be cached from a remote server for this mount. @item nocasetrans @cindex Mount flags; nocasetrans Don't do case translation. Useful for CD-ROMS formatted as ISO-9660. @item noconn @cindex Mount flags; noconn Don't make a connection on datagram transports. @item nocto @cindex Mount flags; nocto No close-to-open consistency. @item nodefperm @cindex Mount flags; nodefperm Do not ignore the permission mode bits. Useful for CD-ROMS formatted as ISO-9660. @item nodev @cindex Mount flags; nodev @itemx nodevs @cindex Mount flags; nodevs Don't allow local special devices on this filesystem. @item noexec @cindex Mount flags; noexec Don't allow program execution. @item noint @cindex Mount flags; noint Do not allow keyboard interrupts for this mount @item nojoliet @cindex Mount flags; nojoliet Turn off the Joliet extensions. Useful for CD-ROMS formatted as ISO-9660. @item nolock @cindex Mount flags; nolock Do not use the NFS locking protocol @item nomnttab @cindex Mount flags; nomnttab This option is used internally to tell Amd that a Solaris 8 system using mntfs is in use. @item norrip @cindex Mount flags; norrip Turn off using of the Rock Ridge Interchange Protocol (RRIP) extensions to ISO-9660. @item nosub @cindex Mount flags; nosub Disallow mounts beneath this mount. @item nosuid @cindex Mount flags; nosuid Don't allow set-uid or set-gid executables on this filesystem. @item noversion @cindex Mount flags; noversion Strip the extension @samp{;#} from the version string of files recorded on an ISO-9660 CD-ROM. @item nowin95 @cindex Mount Flags; nowin95 For PCFS mounts, completely ignore Win95 entries. @item optionstr @cindex Mount flags; optionstr Under Solaris 8, provide the kernel a string of options to parse and show as part of the special in-kernel mount file system. @item overlay @cindex Mount flags; overlay Overlay this mount on top of an existing mount, if any. @item pgthresh=@var{n} @cindex Mount flags; pgthresh Set the paging threshold to @var{n} kilobytes. @item port=@var{n} @cindex Mount flags; port Set the NFS port to @var{n}. @item posix @cindex Mount flags; posix Turn on POSIX static pathconf for mounts. @item private @cindex Mount flags; private Use local locking instead of the NLM protocol, useful for IRIX 6 only. @item proplist @cindex Mount flags; proplist Support property lists (ACLs) for this mount, useful primarily for Tru64 UNIX. @item proto=@var{s} @cindex Mount flags; proto Use transport protocol @var{s} for NFS (can be @code{"tcp"} or @code{"udp"}). @item quota @cindex Mount flags; quota Enable quota checking on this mount. @item rdonly @cindex Mount flags; rdonly @itemx ro @cindex Mount flags; ro Mount this filesystem readonly. @item resvport @cindex Mount flags; resvport Use a reserved port (smaller than 1024) for remote NFS mounts. Most systems assume that, but some allow for mounts to occur on non-reserved ports. This causes problems when such a system tries to NFS mount one that requires reserved ports. It is recommended that this option always be on. @item retrans=@i{n} @cindex Mount flags; retrans The number of NFS retransmits made before a user error is generated by a @samp{soft} mounted filesystem, and before a @samp{hard} mounted filesystem reports @samp{NFS server @dfn{yoyo} not responding still trying}. @item retry @cindex Mount flags; retry Set the NFS retry counter. @item rrcaseins @cindex Mount flags; rrcaseins Enable the Rock Ridge Interchange Protocol (RRIP) case insensitive extensions. Useful for CD-ROMS formatted as ISO-9660. @item rrip @cindex Mount flags; rrip Uses the Rock Ridge Interchange Protocol (RRIP) extensions to ISO-9660. @item rsize=@var{n} @cindex Mount flags; rsize The NFS read packet size. You may need to set this if you are using NFS/UDP through a gateway or a slow link. @item rw @cindex Mount flags; rw Allow reads and writes on this filesystem. @item sessionnr=@var{n} @cindex Mount Flags; sessionnr For multisession UDF mounts, use session number @var{n} when mounting. @item shortname @cindex Mount Flags; longname For PCFS mounts, force old DOS short names only. @item soft @cindex Mount flags; soft Give up after @dfn{retrans} retransmissions. @item spongy @cindex Mount flags; spongy Like @samp{soft} for status requests, and @samp{hard} for data transfers. @item suid @cindex Mount flags; suid Allow set-uid programs on this mount. @item symttl @cindex Mount flags; symttl Turn off the symbolic link cache time-to-live. @item sync @cindex Mount flags; sync Perform synchronous filesystem operations on this mount. @item tcp @cindex Mount flags; tcp Use TCP/IP instead of UDP/IP, ignored if the NFS implementation does not support TCP/IP mounts. @item timeo=@var{n} @cindex Mount flags; timeo The NFS timeout, in tenth-seconds, before a request is retransmitted. @item user=@var{n} @cindex Mount flags; user For PCFS and UDF mounts, set the owner of the files in the file system to @var{n} (which can either be a user name or a UID number). The default owner is the owner of the directory on which the file system is being mounted. @item vers=@var{n} @cindex Mount flags; vers Use NFS protocol version number @var{n} (can be 2 or 3). @item wsize=@var{n} @cindex Mount flags; wsize The NFS write packet size. You may need to set this if you are using NFS/UDP through a gateway or a slow link. @end table The following options are implemented by @i{Amd}, rather than being passed to the kernel. @table @code @item nounmount @cindex Mount flags; nounmount Configures the mount so that its time-to-live will never expire. This is the default for non-network based filesystem types (such as mounting local disks, floppies, and CD-ROMs). See also the related @i{unmount} option. @c @c Implementation broken: @item ping=@var{n} @cindex Mount flags; ping The interval, in seconds, between keep-alive pings. When four consecutive pings have failed the mount point is marked as hung. This interval defaults to 30 seconds; if the ping interval is set to zero, @i{Amd} will use the default 30-second interval. If the interval is set to -1 (or any other negative value), no pings are sent and the host is assumed to be always up, which can cause unmounts to hang See the @i{softlookup} option for a better alternative. Turning pings off can be useful in NFS-HA (High-Availability) sites where the NFS service rarely goes down. Setting the ping value to a large value can reduce the amount of NFS_NULL chatter on your network considerably, especially in large sites. Note that if you have multiple @i{Amd} entries using the same file server, and each entry sets a different value of N, then each time Amd mounts a new entry, the ping value will be re-evaluated (and updated, turned off, or turned back on as needed). Finally, note that NFS_NULL pings are sent for both UDP and TCP mounts, because even a hung TCP mount can cause user processes to hang. @item public @cindex Mount flags; public Use WebNFS multi-component lookup on the public file handle instead of the mount protocol to obtain NFS file handles, as documented in the WebNFS Client Specification, RFC 2054. This means that @i{Amd} will not attempt to contact the remote portmapper or remote mountd daemon, and will only connect to the well-known NFS port 2049 or the port specified with the @i{port} mount option, thus making it easier to use NFS through a firewall. @item retry=@var{n} @cindex Mount flags; retry=@var{n} The number of times to retry the mount system call. @item softlookup @cindex Mount flags; softlookup Configures @i{Amd}'s behavior with respect to already-mounted shares from NFS fileservers that are unreachable. If softlookup is specified, trying to access such a share will result in an error (EIO, which is changed from the ENOENT 6.0 used to return). If it is not specified, a regular symlink is provided and the access will probably hang in the NFS filesystem. The default behavior depends on whether the mount is 'soft' or 'hard'; softlookup can be used to change this default. This is changed from 6.0 which always behaved as if softlookup was specified. @item unmount @cindex Mount flags; unmount Configures the mount so that its time-to-live will indeed expire (and thus may be automatically unmounted). This is also the default for network-based filesystem types (e.g., NFS). This option is useful for removable local media such as CD-ROMs, USB drives, etc. so they can expire when not in use, and get unmounted (such drives can get work out when they keep spinning). See also the related @i{nounmount} option. @item utimeout=@var{n} @cindex Mount flags; utimeout=@var{n} The interval, in seconds, that looked up and mounted map entries are cached. After that period of time, @i{Amd} will attempt to unmount the entries. If, however, the unmount fails (with EBUSY), then @i{Amd} will extend the mount's time-to-live by the @i{utimeout} value before the next unmount attempt is made. In fact the interval is extended before the unmount is attempted, to avoid thrashing. The default value is 120 seconds (two minutes) or as set by the @code{-w} command line option. @item xlatecookie @cindex Mount flags; xlatecookie Translate directory cookies between 32-long and 64-long lengths. @end table @node remopts Option, sublink Option, opts Option, Map Options @comment node-name, next, previous, up @subsubsection remopts Option @cindex Setting system mount options for non-local networks @cindex remopts, mount option @cindex Mount option; remopts This option has the same use as @code{$@{opts@}} but applies only when the remote host is on a non-local network. For example, when using NFS across a gateway it is often necessary to use smaller values for the data read and write sizes. This can simply be done by specifying the small values in @var{remopts}. When a non-local host is accessed, the smaller sizes will automatically be used. @i{Amd} determines whether a host is local by examining the network interface configuration at startup. Any interface changes made after @i{Amd} has been started will not be noticed. The likely effect will be that a host may incorrectly be declared non-local. Unless otherwise set, the value of @code{$@{remopts@}} is the same as the value of @code{$@{opts@}}. @node sublink Option, type Option, remopts Option, Map Options @comment node-name, next, previous, up @subsubsection sublink Option @cindex Setting the sublink option @cindex sublink, mount option @cindex Mount option; sublink The subdirectory within the mounted filesystem to which the reference should point. This can be used to prevent duplicate mounts in cases where multiple directories in the same mounted filesystem are used. @node type Option, , sublink Option, Map Options @comment node-name, next, previous, up @subsubsection type Option @cindex Setting the filesystem type option @cindex type, mount option @cindex Mount option; type The filesystem type to be used. @xref{Filesystem Types}, for a full description of each type.@refill @c ################################################################ @node Amd Command Line Options, Filesystem Types, Mount Maps, Top @comment node-name, next, previous, up @chapter @i{Amd} Command Line Options @cindex Command line options, Amd @cindex Amd command line options @cindex Overriding defaults on the command line Many of @i{Amd}'s parameters can be set from the command line. The command line is also used to specify automount points and maps. The general format of a command line is @example amd [@i{options}] [@{ @i{directory} @i{map-name} [-@i{map-options}] @} ...] @end example For each directory and map-name given or specified in the @file{amd.conf} file, @i{Amd} establishes an automount point. The @dfn{map-options} may be any sequence of options or selectors---@pxref{Location Format}. The @dfn{map-options} apply only to @i{Amd}'s mount point. @samp{type:=toplvl;cache:=mapdefault;fs:=$@{map@}} is the default value for the map options. Default options for a map are read from a special entry in the map whose key is the string @samp{/defaults}. When default options are given they are prepended to any options specified in the mount-map locations as explained in @ref{Map Defaults}. The @dfn{options} are any combination of those listed below. Once the command line has been parsed, the automount points are mounted. The mount points are created if they do not already exist, in which case they will be removed when @i{Amd} exits. Finally, @i{Amd} disassociates itself from its controlling terminal and forks into the background. Note: Even if @i{Amd} has been built with @samp{-DDEBUG} (via @code{configure --enable-debug}), it will still background itself and disassociate itself from the controlling terminal. To use a debugger it is necessary to specify @samp{-D daemon} on the command line. However, even with all of this, mounts and unmounts are performed in the background, and @i{Amd} will always fork before doing them. Therefore, debugging what happens closely during un/mounts is more challenging. @emph{All} of @i{Amd}'s command options (save @code{-F} and @code{-T}) can be specified in the @file{amd.conf} file. @xref{Amd Configuration File}. If @i{Amd} is invoked without any command line options, it will default to using the configuration file @file{/etc/amd.conf}, if one exists. @menu * -a Option:: Automount directory. * -c Option:: Cache timeout interval. * -d Option:: Domain name. * -k Option:: Kernel architecture. * -l Option:: Log file. * -n Option:: Hostname normalization. * -o Option:: Operating system version. * -p Option:: Output process id. * -r Option:: Restart existing mounts. * -t Option:: Kernel RPC timeout. * -v Option:: Version information. * -w Option:: Wait interval after failed unmount. * -x Option:: Log options. * -y Option:: NIS domain. * -A Option:: Operating system Architecture. * -C Option:: Cluster name. * -D Option:: Debug flags. * -F Option:: Amd configuration file. * -H Option:: Show brief help. * -O Option:: Operating system name. * -S Option:: Lock executable pages in memory. * -T Option:: Set tag for configuration file. @end menu @c ---------------------------------------------------------------- @node -a Option, -c Option, Amd Command Line Options, Amd Command Line Options @comment node-name, next, previous, up @section @code{-a} @var{directory} @cindex Automount directory @cindex Setting the default mount directory Specifies the default mount directory. This option changes the variable @code{$@{autodir@}} which otherwise defaults to @file{/a}. For example, some sites prefer @file{/amd} or @file{/n}. @example amd -a /amd ... @end example @c ---------------------------------------------------------------- @node -c Option, -d Option, -a Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-c} @var{cache-interval} @cindex Cache interval @cindex Interval before a filesystem times out @cindex Setting the interval before a filesystem times out @cindex Changing the interval before a filesystem times out Selects the period, in seconds, for which a name is cached by @i{Amd}. If no reference is made to the volume in this period, @i{Amd} discards the volume name to filesystem mapping. Once the last reference to a filesystem has been removed, @i{Amd} attempts to unmount the filesystem. If the unmount fails the interval is extended by a further period as specified by the @samp{-w} command line option or by the @samp{utimeout} mount option. The default @dfn{cache-interval} is 300 seconds (five minutes). @c ---------------------------------------------------------------- @node -d Option, -k Option, -c Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-d} @var{domain} @cindex Domain name @cindex Setting the local domain name @cindex Overriding the local domain name Specifies the host's domain. This sets the internal variable @code{$@{domain@}} and affects the @code{$@{hostd@}} variable. If this option is not specified and the hostname already contains the local domain then that is used, otherwise the default value of @code{$@{domain@}} is @samp{unknown.domain}. For example, if the local domain was @samp{doc.ic.ac.uk}, @i{Amd} could be started as follows: @example amd -d doc.ic.ac.uk ... @end example @c ---------------------------------------------------------------- @node -k Option, -l Option, -d Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-k} @var{kernel-architecture} @cindex Setting the Kernel architecture Specifies the kernel architecture of the system. This is usually the output of @samp{uname -m} (the ``machine'' value gotten from @b{uname}(2)). If the @b{uname}(2) system call is not available, the value of @code{$@{karch@}} defaults to that of @code{$@{arch@}}. The only effect of this option is to set the variable @code{$@{karch@}}. This option would be used as follows: @example amd -k `arch -k` ... @end example @c ---------------------------------------------------------------- @node -l Option, -n Option, -k Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-l} @var{log-option} @cindex Log filename @cindex Setting the log file @cindex Using syslog to log errors @cindex syslog Selects the form of logging to be made. Several special @dfn{log-options} are recognized. @enumerate @item If @dfn{log-option} is the string @samp{syslog}, @i{Amd} will use the @b{syslog}(3) mechanism. If your system supports syslog facilities, then the default facility used is @samp{LOG_DAEMON}. @item @cindex syslog facility; specifying an alternate When using syslog, if you wish to change the facility, append its name to the log option name, delimited by a single colon. For example, if @dfn{log-options} is the string @samp{syslog:local7} then @b{Amd} will log messages via @b{syslog}(3) using the @samp{LOG_LOCAL7} facility. If the facility name specified is not recognized, @i{Amd} will default to @samp{LOG_DAEMON}. Note: while you can use any syslog facility available on your system, it is generally a bad idea to use those reserved for other services such as @samp{kern}, @samp{lpr}, @samp{cron}, etc. @item If @dfn{log-option} is the string @samp{/dev/stderr}, @i{Amd} will use standard error, which is also the default target for log messages. To implement this, @i{Amd} simulates the effect of the @samp{/dev/fd} driver. @end enumerate Any other string is taken as a filename to use for logging. Log messages are appended to the file if it already exists, otherwise a new file is created. The file is opened once and then held open, rather than being re-opened for each message. Normally, when long-running daemons hold an open file descriptor on a log file, it is impossible to ``rotate'' the log file and compress older logs on a daily basis. The daemon needs to be told to discard (via @b{close}(2)) its file handle, and re-open the log file. This is done using @code{amq -l} @i{log-option}. @xref{Amq -l option}. If the @samp{syslog} option is specified but the system does not support syslog or if the named file cannot be opened or created, @i{Amd} will use standard error. Error messages generated before @i{Amd} has finished parsing the command line are printed on standard error. Since @i{Amd} tends to generate a lot of logging information (especially if debugging was turned on), and due to it being an important program running on the system, it is usually best to log to a separate disk file. In that case @i{Amd} would be started as follows: @example amd -l /var/log/amd ... @end example @c ---------------------------------------------------------------- @node -n Option, -o Option, -l Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-n} @cindex Hostname normalization @cindex Aliased hostnames @cindex Resolving aliased hostnames @cindex Normalizing hostnames Normalizes the remote hostname before using it. Normalization is done by replacing the value of @code{$@{rhost@}} with the (generally fully qualified) primary name returned by a hostname lookup. This option should be used if several names are used to refer to a single host in a mount map. @c ---------------------------------------------------------------- @node -o Option, -p Option, -n Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-o} @var{op-sys-ver} @cindex Operating System version @cindex Setting the Operating System version Overrides the compiled-in version number of the operating system, with @var{op-sys-ver}. Useful when the built-in version is not desired for backward compatibility reasons. For example, if the built-in version is @samp{2.5.1}, you can override it to @samp{5.5.1}, and use older maps that were written with the latter in mind. @c ---------------------------------------------------------------- @node -p Option, -r Option, -o Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-p} @cindex Process id @cindex Displaying the process id @cindex process id of Amd daemon @cindex pid file, creating with -p option @cindex Creating a pid file Causes @i{Amd}'s process id to be printed on standard output. This can be redirected to a suitable file for use with kill: @example amd -p > /var/run/amd.pid ... @end example This option only has an affect if @i{Amd} is running in daemon mode. If @i{Amd} is started with the @code{-D daemon} debug flag, this option is ignored. @c ---------------------------------------------------------------- @node -r Option, -t Option, -p Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-r} @cindex Restarting existing mounts @cindex Picking up existing mounts Tells @i{Amd} to restart existing mounts (@pxref{Inheritance Filesystem}). @c @dfn{This option will be made the default in the next release.} @c ---------------------------------------------------------------- @node -t Option, -v Option, -r Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-t} @var{timeout.retransmit} @cindex Setting Amd's RPC parameters Specifies the RPC @dfn{timeout} interval and the @dfn{retransmit} counter used by the kernel to communicate to @i{Amd}. These are used to set the @samp{timeo} and @samp{retrans} mount options, respectively. The default timeout is 0.8 seconds, and the default number of retransmissions is 11. @i{Amd} relies on the kernel RPC retransmit mechanism to trigger mount retries. The values of these parameters change the overall retry interval. Too long an interval gives poor interactive response; too short an interval causes excessive retries. @c ---------------------------------------------------------------- @node -v Option, -w Option, -t Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-v} @cindex Version information @cindex Discovering version information @cindex How to discover your version of Amd Print version information on standard error and then exit. The output is of the form: @example Copyright (c) 1997-1999 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. am-utils version 6.0a15 (build 61). Built by ezk@@example.com on date Wed Oct 22 15:21:03 EDT 1997. cpu=sparc (big-endian), arch=sun4, karch=sun4u. full_os=solaris2.5.1, os=sos5, osver=5.5.1, vendor=sun. Map support for: root, passwd, union, nisplus, nis, ndbm, file, error. AMFS: nfs, link, nfsx, nfsl, host, linkx, program, union, inherit, ufs, lofs, hsfs, pcfs, auto, direct, toplvl, error. FS: autofs, cachefs, cdfs, lofs, nfs, nfs3, pcfs, tfs, tmpfs, udf, ufs. Network 1: wire="mcl-lab-net.cs.columbia.edu" (netnumber=128.59.13). Network 2: wire="14-net.cs.columbia.edu" (netnumber=128.59.14). Network 3: wire="old-net.cs.columbia.edu" (netnumber=128.59.16). @end example The information includes the version number, number of times @i{Amd} was compiled on the local system, release date and name of the release. Following come the cpu type, byte ordering, and the architecture and kernel architecture as @code{$@{arch@}} and @code{$@{karch@}}, respectively. The next line lists the operating system full name, short name, version, and vendor. These four values correspond to the variables @code{$@{full_os@}}, @code{$@{os@}}, @code{$@{osver@}}, and @code{$@{vendor@}}, respectively. @xref{Supported Platforms}. Then come a list of map types supported, filesystems internally supported by @i{Amd} (AMFS), and generic filesystems available (FS). Finally all known networks (if any) of this host are listed by name and number. They are available via the variables @code{$@{wire@}} or @code{$@{network@}}, and @code{$@{netnumber@}} (@pxref{Selectors}) or the @samp{in_network} selector function (@pxref{in_network Selector Function}). @c ---------------------------------------------------------------- @node -w Option, -x Option, -v Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-w} @var{wait-timeout} @cindex Setting the interval between unmount attempts @cindex unmount attempt backoff interval Selects the interval in seconds between unmount attempts after the initial time-to-live has expired. This defaults to 120 seconds (two minutes). @c ---------------------------------------------------------------- @node -x Option, -y Option, -w Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-x} @var{opts} @cindex Log message selection @cindex Selecting specific log messages @cindex How to select log messages @cindex syslog priorities Specifies the type and verbosity of log messages. @dfn{opts} is a comma separated list selected from the following options: @table @code @item fatal Fatal errors (cannot be turned off) @item error Non-fatal errors (cannot be turned off) @item user Non-fatal user errors @item warn Recoverable errors @item warning Alias for @code{warn} @item info Information messages @item map Mount map usage @item stats Additional statistics @item all All of the above @item defaults An alias for "fatal,error,user,warning,info". @end table Initially a set of default logging flags is enabled. This is as if @samp{-x defaults} or @samp{-x fatal,error,user,warning,info} had been selected. The command line is parsed and logging is controlled by the @code{-x} option. The very first set of logging flags is saved and can not be subsequently disabled using @i{Amq}. This default set of options is useful for general production use.@refill The @samp{info} messages include details of what is mounted and unmounted and when filesystems have timed out. If you want to have the default set of messages without the @samp{info} messages then you simply need @samp{-x noinfo}. The messages given by @samp{user} relate to errors in the mount maps, so these are useful when new maps are installed. The following table lists the syslog priorities used for each of the message types.@refill @table @code @item fatal @samp{LOG_CRIT} @item error @samp{LOG_ERR} @item user @samp{LOG_WARNING} @item warning @samp{LOG_WARNING} @item info @samp{LOG_INFO} @item debug @samp{LOG_DEBUG} @item map @samp{LOG_DEBUG} @item stats @samp{LOG_INFO} @end table The options can be prefixed by the string @samp{no} to indicate that this option should be turned off. For example, to obtain all but @samp{info} messages the option @samp{-x all,noinfo} would be used. If @i{Amd} was built with debugging enabled the @code{debug} option is automatically enabled regardless of the command line options. @c ---------------------------------------------------------------- @node -y Option, -A Option, -x Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-y} @var{NIS-domain} @cindex NIS (YP) domain name @cindex Overriding the NIS (YP) domain name @cindex Setting the NIS (YP) domain name @cindex YP domain name Selects an alternate NIS domain. This is useful for debugging and cross-domain shared mounting. If this flag is specified, @i{Amd} immediately attempts to bind to a server for this domain. @c @i{Amd} refers to NIS maps when it starts, unless the @code{-m} option @c is specified, and whenever required in a mount map. @c ---------------------------------------------------------------- @node -A Option, -C Option, -y Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-A} @var{architecture} @cindex Setting the operating system architecture Specifies the OS architecture of the system. The only effect of this option is to set the variable @code{$@{arch@}}. This option would be used as follows: @example amd -A i386 ... @end example @c ---------------------------------------------------------------- @node -C Option, -D Option, -A Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-C} @var{cluster-name} @cindex Cluster names @cindex Setting the cluster name Specifies the name of the cluster of which the local machine is a member. The only effect is to set the variable @code{$@{cluster@}}. The @dfn{cluster-name} is will usually obtained by running another command which uses a database to map the local hostname into a cluster name. @code{$@{cluster@}} can then be used as a selector to restrict mounting of replicated data. If this option is not given, @code{$@{cluster@}} has the same value as @code{$@{domain@}}. This would be used as follows: @example amd -C `clustername` ... @end example @c ---------------------------------------------------------------- @node -D Option, -F Option, -C Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-D} @var{opts} @cindex Debug options @cindex Setting debug flags Controls the verbosity and coverage of the debugging trace; @dfn{opts} is a comma separated list of debugging options. The @code{-D} option is only available if @i{Amd} was compiled with @samp{-DDEBUG}, or configured with @code{configure --enable-debug}. The memory debugging facilities (@samp{mem}) are only available if @i{Amd} was compiled with @samp{-DDEBUG_MEM} (in addition to @samp{-DDEBUG}), or configured with @code{configure --enable-debug=mem}. The most common options to use are @samp{-D trace} and @samp{-D test} (which turns on all the useful debug options). As usual, every option can be prefixed with @samp{no} to turn it off. @table @code @item all all options (excluding hrtime and mtab) @item defaults ``sensible'' default options (all--excluding hrtime, mtab, and xdrtrace) @item test full debug options plus mtab,nodaemon,nofork,noamq @item amq register @i{Amd} with the RPC portmapper, for @i{Amq} @item daemon enter daemon mode @item fork fork child worker (hlfsd only) @item full program trace @item hrtime print high resolution time stamps (only if @b{syslog}(3) is not used) @item info @cindex debugging hesiod resolver service @cindex Hesiod; turning on RES_DEBUG info service specific debugging (hesiod, nis, etc.) In the case of hesiod maps, turns on the hesiod RES_DEBUG internal debugging option. @item mem trace memory allocations. Needs to be explicitly enabled at compile time with --enable-debug=mem. @item mtab use local mount-table file (defaults to @file{/tmp/mtab}, @pxref{debug_mtab_file Parameter}) @item readdir show readdir progress @item str debug string munging @item trace trace RPC protocol and NFS mount arguments @item xdrtrace trace XDR routines @end table You may also refer to the program source for a more detailed explanation of the available options. @c ---------------------------------------------------------------- @node -F Option, -H Option, -D Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-F} @var{conf-file} @cindex Amd configuration file; specifying name @cindex Amd configuration file @cindex amd.conf file Specify an @i{Amd} configuration file @var{conf-file} to use. For a description of the format and syntax, @pxref{Amd Configuration File}. This configuration file is used to specify any options in lieu of typing many of them on the command line. The @file{amd.conf} file includes directives for every command line option @i{Amd} has, and many more that are only available via the configuration file facility. The configuration file specified by this option is processed after all other options had been processed, regardless of the actual location of this option on the command line. @c ---------------------------------------------------------------- @node -H Option, -O Option, -F Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-H} @cindex Displaying brief help @cindex Help; showing from Amd Print a brief help and usage string. @c ---------------------------------------------------------------- @node -O Option, -S Option, -H Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-O} @var{op-sys-name} @cindex Operating System name @cindex Setting the Operating System name Overrides the compiled-in name of the operating system, with @var{op-sys-name}. Useful when the built-in name is not desired for backward compatibility reasons. For example, if the build in name is @samp{sunos5}, you can override it to the old name @samp{sos5}, and use older maps which were written with the latter in mind. @c ---------------------------------------------------------------- @node -S Option, -T Option, -O Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-S} @cindex plock; using @cindex mlockall; using @cindex locking executable pages in memory Do @emph{not} lock the running executable pages of @i{Amd} into memory. To improve @i{Amd}'s performance, systems that support the @b{plock}(3) or @b{mlockall}(2) call lock the @i{Amd} process into memory. This way there is less chance the operating system will schedule, page out, and swap the @i{Amd} process as needed. This tends to improve @i{Amd}'s performance, at the cost of reserving the memory used by the @i{Amd} process (making it unavailable for other processes). If this behavior is not desired, use the @code{-S} option. @c ---------------------------------------------------------------- @node -T Option, , -S Option, Amd Command Line Options @comment node-name, next, previous, up @section @code{-T} @var{tag} @cindex Tags for Amd configuration file @cindex Configuration file; tags Specify a tag to use with @file{amd.conf}. All map entries tagged with @var{tag} will be processed. Map entries that are not tagged are always processed. Map entries that are tagged with a tag other than @var{tag} will not be processed. @c ################################################################ @node Filesystem Types, Amd Configuration File, Amd Command Line Options, Top @comment node-name, next, previous, up @chapter Filesystem Types @cindex Filesystem types @cindex Mount types @cindex Types of filesystem To mount a volume, @i{Amd} must be told the type of filesystem to be used. Each filesystem type typically requires additional information such as the fileserver name for NFS. From the point of view of @i{Amd}, a @dfn{filesystem} is anything that can resolve an incoming name lookup. An important feature is support for multiple filesystem types. Some of these filesystems are implemented in the local kernel and some on remote fileservers, whilst the others are implemented internally by @i{Amd}.@refill The two common filesystem types are UFS and NFS. Four other user accessible filesystems (@samp{link}, @samp{program}, @samp{auto} and @samp{direct}) are also implemented internally by @i{Amd} and these are described below. There are two additional filesystem types internal to @i{Amd} which are not directly accessible to the user (@samp{inherit} and @samp{error}). Their use is described since they may still have an effect visible to the user.@refill @menu * Network Filesystem:: A single NFS filesystem. * Network Host Filesystem:: NFS mount a host's entire export tree. * Network Filesystem Group:: An atomic group of NFS filesystems. * Unix Filesystem:: Native disk filesystem. * Caching Filesystem:: Caching from remote server filesystem. * CD-ROM Filesystem:: ISO9660 CD ROM. * UDF Filesystem:: Universal Disk Format filesystem. * Loopback Filesystem:: Local loopback-mount filesystem. * Memory/RAM Filesystem:: A memory or RAM-based filesystem. * Null Filesystem:: 4.4BSD's loopback-mount filesystem. * Floppy Filesystem:: MS-DOS Floppy filesystem. * Translucent Filesystem:: The directory merging filesystem. * Shared Memory+Swap Filesystem:: Sun's tmpfs filesystem. * User ID Mapping Filesystem:: 4.4BSD's umapfs filesystem. * Program Filesystem:: Generic Program mounts. * Symbolic Link Filesystem:: Local link. * Symbolic Link Filesystem II:: Local link referencing existing filesystem. * NFS-Link Filesystem:: Link if path exists, NFS otherwise. * Automount Filesystem:: * Direct Automount Filesystem:: * Union Filesystem:: * Error Filesystem:: * Top-level Filesystem:: * Root Filesystem:: * Inheritance Filesystem:: @end menu @c ---------------------------------------------------------------- @node Network Filesystem, Network Host Filesystem, Filesystem Types, Filesystem Types @comment node-name, next, previous, up @section Network Filesystem (@samp{nfs}) @cindex NFS @cindex Mounting an NFS filesystem @cindex How to mount and NFS filesystem @cindex nfs, filesystem type @cindex Filesystem type; nfs The @dfn{nfs} (@samp{type:=nfs}) filesystem type provides access to Sun's NFS. @noindent The following options must be specified: @table @code @cindex rhost, mount option @cindex Mount option; rhost @item rhost the remote fileserver. This must be an entry in the hosts database. IP addresses are not accepted. The default value is taken from the local host name (@code{$@{host@}}) if no other value is specified. @cindex rfs, mount option @cindex Mount option; rfs @item rfs the remote filesystem. If no value is specified for this option, an internal default of @code{$@{path@}} is used. @end table NFS mounts require a two stage process. First, the @dfn{file handle} of the remote file system must be obtained from the server. Then a mount system call must be done on the local system. @i{Amd} keeps a cache of file handles for remote file systems. The cache entries have a lifetime of a few minutes. If a required file handle is not in the cache, @i{Amd} sends a request to the remote server to obtain it. @c @i{Amd} @dfn{does not} wait for @c a response; it notes that one of the locations needs retrying, but @c continues with any remaining locations. When the file handle becomes @c available, and assuming none of the other locations was successfully @c mounted, @i{Amd} will retry the mount. This mechanism allows several @c NFS filesystems to be mounted in parallel. @c @footnote{The mechanism @c is general, however NFS is the only filesystem @c for which the required hooks have been written.} @c The first one which responds with a valid file handle will be used. Historically, this documentation has maintained that @i{Amd} will try all the locations in parallel and use the first one which responds with a valid file handle. This has not been the case for quite some time, however. Instead, @i{Amd} will go through each location, one by one, and will only skip to the next one if the previous one either fails or times out. @noindent An NFS entry might be: @example jsp host!=charm;type:=nfs;rhost:=charm;rfs:=/home/charm;sublink:=jsp @end example The mount system call and any unmount attempts are always done in a new task to avoid the possibility of blocking @i{Amd}. @c ---------------------------------------------------------------- @node Network Host Filesystem, Network Filesystem Group, Network Filesystem, Filesystem Types @comment node-name, next, previous, up @section Network Host Filesystem (@samp{host}) @cindex Network host filesystem @cindex Mounting entire export trees @cindex How to mount all NFS exported filesystems @cindex host, filesystem type @cindex Filesystem type; host @c NOTE: the current implementation of the @dfn{host} filesystem type @c sometimes fails to maintain a consistent view of the remote mount tree. @c This happens when the mount times out and only some of the remote mounts @c are successfully unmounted. To prevent this from occurring, use the @c @samp{nounmount} mount option. The @dfn{host} (@samp{type:=host}) filesystem allows access to the entire export tree of an NFS server. The implementation is layered above the @samp{nfs} implementation so keep-alives work in the same way. The only option which needs to be specified is @samp{rhost} which is the name of the fileserver to mount. The @samp{host} filesystem type works by querying the mount daemon on the given fileserver to obtain its export list. @i{Amd} then obtains filehandles for each of the exported filesystems. Any errors at this stage cause that particular filesystem to be ignored. Finally each filesystem is mounted. Again, errors are logged but ignored. One common reason for mounts to fail is that the mount point does not exist. Although @i{Amd} attempts to automatically create the mount point, it may be on a remote filesystem to which @i{Amd} does not have write permission. When an attempt to unmount a @samp{host} filesystem mount fails, @i{Amd} remounts any filesystems which had successfully been unmounted. To do this @i{Amd} queries the mount daemon again and obtains a fresh copy of the export list. @i{Amd} then tries to mount any exported filesystems which are not currently mounted. Sun's automounter provides a special @samp{-hosts} map. To achieve the same effect with @i{Amd} requires two steps. First a mount map must be created as follows: @example * type:=host;rhost:=$@{key@};fs:=$@{autodir@}/$@{rhost@}/root @end example @noindent and then start @i{Amd} with the following command @example amd /net net.map @end example @noindent where @samp{net.map} is the name of map described above. Note that the value of @code{$@{fs@}} is overridden in the map. This is done to avoid a clash between the mount tree and any other filesystem already mounted from the same fileserver. If different mount options are needed for different hosts then additional entries can be added to the map, for example @example host2 opts:=ro,nosuid,soft @end example @noindent would soft mount @samp{host2} read-only. @c ---------------------------------------------------------------- @node Network Filesystem Group, Unix Filesystem, Network Host Filesystem, Filesystem Types @comment node-name, next, previous, up @section Network Filesystem Group (@samp{nfsx}) @cindex Network filesystem group @cindex Atomic NFS mounts @cindex Mounting an atomic group of NFS filesystems @cindex How to mount an atomic group of NFS filesystems @cindex nfsx, filesystem type @cindex Filesystem type; nfsx The @dfn{nfsx} (@samp{type:=nfsx}) filesystem allows a group of filesystems to be mounted from a single NFS server. The implementation is layered above the @samp{nfs} implementation so keep-alives work in the same way. @emph{WARNING}: @samp{nfsx} is meant to be a ``last resort'' kind of solution. It is racy and poorly supported. The authors @emph{highly} recommend that other solutions be considered before relying on it. The options are the same as for the @samp{nfs} filesystem with one difference for @samp{rfs}, as explained below. @noindent The following options should be specified: @table @code @item rhost the remote fileserver. The default value is taken from the local host name (@code{$@{host@}}) if no other value is specified. @item rfs is a list of filesystems to mount, and must be specified. The list is in the form of a comma separated strings. @end table @noindent For example: @example pub type:=nfsx;rhost:=gould;\ rfs:=/public,/,graphics,usenet;fs:=$@{autodir@}/$@{rhost@}/root @end example The first string defines the root of the tree, and is applied as a prefix to the remaining members of the list which define the individual filesystems. The first string is @emph{not} used as a filesystem name. A serial operation is used to determine the local mount points to ensure a consistent layout of a tree of mounts. Here, the @emph{three} filesystems, @samp{/public}, @samp{/public/graphics} and @samp{/public/usenet}, would be mounted.@refill A local mount point, @code{$@{fs@}}, @emph{must} be specified. The default local mount point will not work correctly in the general case. A suggestion is to use @samp{fs:=$@{autodir@}/$@{rhost@}/root}.@refill @c ---------------------------------------------------------------- @node Unix Filesystem, Caching Filesystem, Network Filesystem Group, Filesystem Types @comment node-name, next, previous, up @section Unix Filesystem (@samp{ufs}, @samp{xfs}, or @samp{efs}) @cindex Unix filesystem @cindex UFS @cindex XFS @cindex EFS @cindex Mounting a UFS filesystem @cindex Mounting a local disk @cindex How to mount a UFS filesystems @cindex How to mount a local disk @cindex Disk filesystems @cindex ufs, filesystem type @cindex Filesystem type; ufs @cindex xfs, filesystem type @cindex Filesystem type; xfs @cindex efs, filesystem type @cindex Filesystem type; efs The @dfn{ufs} (@samp{type:=ufs}) filesystem type provides access to the system's standard disk filesystem---usually a derivative of the Berkeley Fast Filesystem. @noindent The following option must be specified: @table @code @cindex dev, mount option @cindex Mount option; dev @item dev the block special device to be mounted. @end table A UFS entry might be: @example jsp host==charm;type:=ufs;dev:=/dev/sd0d;sublink:=jsp @end example UFS is the default Unix disk-based file system, which Am-utils picks up during the autoconfiguration phase. Some systems have more than one type, such as IRIX, that comes with EFS (Extent File System) and XFS (Extended File System). In those cases, you may explicitly set the file system type, by using entries such: @example ez1 type:=efs;dev:=/dev/xd0a ez2 type:=xfs;dev:=/dev/sd3c @end example The UFS/XFS/EFS filesystems are never timed out by default, i.e. they will never be unmounted by @i{Amd}. If automatic unmounting is desired, the ``unmount'' option should be added to the mount options for the entry. @c ---------------------------------------------------------------- @node Caching Filesystem, CD-ROM Filesystem, Unix Filesystem, Filesystem Types @comment node-name, next, previous, up @section Caching Filesystem (@samp{cachefs}) @cindex Caching Filesystem @cindex cachefs, filesystem type @cindex Filesystem type; cachefs The @dfn{cachefs} (@samp{type:=cachefs}) filesystem caches files from one location onto another, presumably providing faster access. It is particularly useful to cache from a larger and remote (slower) NFS partition to a smaller and local (faster) UFS directory. @noindent The following options must be specified: @table @code @cindex cachedir, mount option @cindex Mount option; cachedir @item cachedir the directory where the cache is stored. @item rfs the path name to the ``back file system'' to be cached from. @item fs the ``front file system'' mount point to the cached files, where @i{Amd} will set a symbolic link pointing to. @end table A CacheFS entry for, say, the @file{/import} @i{Amd} mount point, might be: @example copt type:=cachefs;cachedir:=/cache;rfs:=/import/opt;fs:=/n/import/copt @end example Access to the pathname @file{/import/copt} will follow a symbolic link to @file{/n/import/copt}. The latter is the mount point for a caching file system, that caches from @file{/import/opt} to @file{/cache}. The cachefs filesystem is never timed out by default, i.e. it will never be unmounted by @i{Amd}. If automatic unmounting is desired, the ``unmount'' option should be added to the mount options for the entry. @b{Caveats}: @enumerate @item This file system is currently only implemented for Solaris 2.x! @item Before being used for the first time, the cache directory @i{must} be initialized with @samp{cfsadmin -c @var{cachedir}}. See the manual page for @b{cfsadmin}(1M) for more information. @item The ``back file system'' mounted must be a complete file system, not a subdirectory thereof; otherwise you will get an error ``Invalid Argument''. @item If @i{Amd} aborts abnormally, the state of the cache may be inconsistent, requiring running the command @file{fsck -F cachefs @var{cachedir}}. Otherwise you will get the error ``No Space Left on Device''. @end enumerate @c ---------------------------------------------------------------- @node CD-ROM Filesystem, UDF Filesystem, Caching Filesystem, Filesystem Types @comment node-name, next, previous, up @section CD-ROM Filesystem (@samp{cdfs}) @cindex CD-ROM Filesystem @cindex cdfs, filesystem type @cindex Filesystem type; cdfs The @dfn{cdfs} (@samp{type:=cdfs}) filesystem mounts a CD-ROM with an ISO9660 format filesystem on it. @noindent The following option must be specified: @table @code @cindex dev, mount option @cindex Mount option; dev @item dev the block special device to be mounted. @end table Some operating systems will fail to mount read-only CDs unless the @samp{ro} option is specified. A cdfs entry might be: @example cdfs os==sunos4;type:=cdfs;dev:=/dev/sr0 \ os==sunos5;addopts:=ro;type:=cdfs;dev:=/dev/dsk/c0t6d0s2 @end example @c ---------------------------------------------------------------- @node UDF Filesystem, Loopback Filesystem, CD-ROM Filesystem, Filesystem Types @comment node-name, next, previous, up @section CD-ROM Filesystem (@samp{udf}) @cindex CD-ROM Filesystem @cindex udf, filesystem type @cindex Filesystem type; udf The @dfn{udf} (@samp{type:=udf}) filesystem mounts media with a Universal Disk Format (UDF) filesystem on it, e.g., a video DVD. @noindent The following option must be specified: @table @code @cindex dev, mount option @cindex Mount option; dev @item dev the block special device to be mounted. @end table Some operating systems will fail to mount read-only media unless the @samp{ro} option is specified. A udf entry might be: @example udf os==sunos4;type:=udf;dev:=/dev/sr0 \ os==sunos5;addopts:=ro;type:=udf;dev:=/dev/dsk/c0t6d0s2 @end example @c ---------------------------------------------------------------- @node Loopback Filesystem, Memory/RAM Filesystem, UDF Filesystem, Filesystem Types @comment node-name, next, previous, up @section Loopback Filesystem (@samp{lofs}) @cindex Loopback Filesystem @cindex lofs, filesystem type @cindex Filesystem type; lofs The @dfn{lofs} (@samp{type:=lofs}) filesystem is also called the loopback filesystem. It mounts a local directory on another, thus providing mount-time binding to another location (unlike symbolic links). The loopback filesystem is particularly useful within the context of a chroot-ed directory (via @b{chroot}(2)), to provide access to directories otherwise inaccessible. @noindent The following option must be specified: @table @code @cindex rfs, mount option @cindex Mount option; rfs @item rfs the pathname to be mounted on top of @code{$@{fs@}}. @end table Usually, the FTP server runs in a chroot-ed environment, for security reasons. In this example, lofs is used to provide a subdirectory within a user's home directory, also available for public ftp. @example lofs type:=lofs;rfs:=/home/ezk/myftpdir;fs:=/usr/ftp/pub/ezk @end example @c ---------------------------------------------------------------- @node Memory/RAM Filesystem, Null Filesystem, Loopback Filesystem, Filesystem Types @comment node-name, next, previous, up @section Memory/RAM Filesystem (@samp{mfs}) @cindex Memory/RAM Filesystem @cindex mfs, filesystem type @cindex Filesystem type; mfs The @dfn{mfs} (@samp{type:=mfs}) filesystem is available in 4.4BSD, Linux, and other systems. It creates a filesystem in a portion of the system's memory, thus providing very fast file (volatile) access. XXX: THIS FILESYSTEM IS NOT IMPLEMENTED YET! @c ---------------------------------------------------------------- @node Null Filesystem, Floppy Filesystem, Memory/RAM Filesystem, Filesystem Types @comment node-name, next, previous, up @section Null Filesystem (@samp{nullfs}) @cindex Null Filesystem @cindex nullfs, filesystem type @cindex Filesystem type; nullfs The @dfn{nullfs} (@samp{type:=nullfs}) filesystem is available from 4.4BSD, and is very similar to the loopback filesystem, @dfn{lofs}. XXX: THIS FILESYSTEM IS NOT IMPLEMENTED YET! @c ---------------------------------------------------------------- @node Floppy Filesystem, Translucent Filesystem, Null Filesystem, Filesystem Types @comment node-name, next, previous, up @section Floppy Filesystem (@samp{pcfs}) @cindex Floppy Filesystem @cindex pcfs, filesystem type @cindex Filesystem type; pcfs The @dfn{pcfs} (@samp{type:=pcfs}) filesystem mounts a floppy previously formatted for the MS-DOS format. @noindent The following option must be specified: @table @code @cindex dev, mount option @cindex Mount option; dev @item dev the block special device to be mounted. @end table A pcfs entry might be: @example pcfs os==sunos4;type:=pcfs;dev:=/dev/fd0 \ os==sunos5;type:=pcfs;dev:=/dev/diskette @end example @c ---------------------------------------------------------------- @node Translucent Filesystem, Shared Memory+Swap Filesystem, Floppy Filesystem, Filesystem Types @comment node-name, next, previous, up @section Translucent Filesystem (@samp{tfs}) @cindex Translucent Filesystem @cindex tfs, filesystem type @cindex Filesystem type; tfs The @dfn{tfs} (@samp{type:=tfs}) filesystem is an older version of the 4.4BSD @dfn{unionfs}. XXX: THIS FILESYSTEM IS NOT IMPLEMENTED YET! @c ---------------------------------------------------------------- @node Shared Memory+Swap Filesystem, User ID Mapping Filesystem, Translucent Filesystem, Filesystem Types @comment node-name, next, previous, up @section Shared Memory+Swap Filesystem (@samp{tmpfs}) @cindex Shared Memory and Swap Filesystem @cindex tmpfs, filesystem type @cindex Filesystem type; tmpfs The @dfn{tmpfs} (@samp{type:=tmpfs}) filesystem shares memory between a the swap device and the rest of the system. It is generally used to provide a fast access @file{/tmp} directory, one that uses memory that is otherwise unused. This filesystem is available in SunOS 4.x and 5.x. XXX: THIS FILESYSTEM IS NOT IMPLEMENTED YET! @c ---------------------------------------------------------------- @node User ID Mapping Filesystem, Program Filesystem, Shared Memory+Swap Filesystem, Filesystem Types @comment node-name, next, previous, up @section User ID Mapping Filesystem (@samp{umapfs}) @cindex User ID Mapping Filesystem @cindex umapfs, filesystem type @cindex Filesystem type; umapfs The @dfn{umapfs} (@samp{type:=umapfs}) filesystem maps User IDs of file ownership, and is available from 4.4BSD. XXX: THIS FILESYSTEM IS NOT IMPLEMENTED YET! @c ---------------------------------------------------------------- @node Program Filesystem, Symbolic Link Filesystem, User ID Mapping Filesystem, Filesystem Types @comment node-name, next, previous, up @section Program Filesystem (@samp{program}) @cindex Program filesystem @cindex Mount a filesystem under program control @cindex program, filesystem type @cindex Filesystem type; program The @dfn{program} (@samp{type:=program}) filesystem type allows a program to be run whenever a mount or unmount is required. This allows easy addition of support for other filesystem types, such as MIT's Remote Virtual Disk (RVD) which has a programmatic interface via the commands @samp{rvdmount} and @samp{rvdunmount}. @noindent Both of the following options must be specified: @table @code @cindex mount, mount option @cindex Mount option; mount @item mount the program which will perform the mount. @cindex unmount, mount option @cindex umount, mount option @cindex Mount option; unmount @cindex Mount option; umount @item unmount @item umount the program which will perform the unmount. For convenience, you may use either @samp{unmount} or @samp{umount} but not both. If neither is defined, @i{Amd} will default to @samp{umount $@{fs@}} (the actual unmount program pathname will be automatically determined at the time GNU @code{configure} runs.) @end table The exit code from these two programs is interpreted as a Unix error code. As usual, exit code zero indicates success. To execute the program, @i{Amd} splits the string on whitespace to create an array of substrings. Single quotes @samp{'} can be used to quote whitespace if that is required in an argument. There is no way to escape or change the single quote character. To run e.g. the program @samp{rvdmount} with a host name and filesystem as arguments, it would be specified by @samp{fs:=$@{autodir@}$@{path@};type:=program;mount:="/etc/rvdmount rvdmount fserver $@{fs@}";unmount:="/etc/rdvumount rvdumount $@{fs@}"}. The first element in the array is taken as the pathname of the program to execute. The other members of the array form the argument vector to be passed to the program, @dfn{including argument zero}. The array is exactly the same as the array passed to the execv() system call (man execv for details). The split string must have at least two elements. The programs are directly executed by @i{Amd}, not via a shell. Therefore, if a script is to be used as a mount/umount program, it @dfn{must} begin with a @code{#!} interpreter specification. Often, this program mount type is used for Samba mounts, where you need a double slash in pathnames. However, @i{Amd} normalizes sequences of slashes into one slash. Therefore, you must use an escaped slash, preceded by an escaped backslash. So to get a double slash in the mount command, you need the eight character sequence @samp{\\\/\\\/} in your map. For example: @samp{mount="/sbin/mount mount -r -t smbfs -o-N,-Ihostname \\\/\\\/guest@@venus/mp3"} If a filesystem type is to be heavily used, it may be worthwhile adding a new filesystem type into @i{Amd}, but for most uses the program filesystem should suffice. When the program is run, standard input and standard error are inherited from the current values used by @i{Amd}. Standard output is a duplicate of standard error. The value specified with the @code{-l} command line option has no effect on standard error. @i{Amd} guarantees that the mountpoint will be created before calling the mount program, and that it will be removed after the umount program returns success. @c ---------------------------------------------------------------- @node Symbolic Link Filesystem, Symbolic Link Filesystem II, Program Filesystem, Filesystem Types @comment node-name, next, previous, up @section Symbolic Link Filesystem (@samp{link}) @cindex Symbolic link filesystem @cindex Referencing part of the local name space @cindex Mounting part of the local name space @cindex How to reference part of the local name space @cindex link, filesystem type @cindex symlink, link filesystem type @cindex Filesystem type; link Each filesystem type creates a symbolic link to point from the volume name to the physical mount point. The @samp{link} filesystem does the same without any other side effects. This allows any part of the machines name space to be accessed via @i{Amd}. One common use for the symlink filesystem is @file{/homes} which can be made to contain an entry for each user which points to their (auto-mounted) home directory. Although this may seem rather expensive, it provides a great deal of administrative flexibility. @noindent The following option must be defined: @table @code @item fs The value of @var{fs} option specifies the destination of the link, as modified by the @var{sublink} option. If @var{sublink} is non-null, it is appended to @code{$@{fs@}}@code{/} and the resulting string is used as the target. @end table The @samp{link} filesystem can be thought of as identical to the @samp{ufs} filesystem but without actually mounting anything. An example entry might be: @example jsp host==charm;type:=link;fs:=/home/charm;sublink:=jsp @end example which would return a symbolic link pointing to @file{/home/charm/jsp}. @c ---------------------------------------------------------------- @node Symbolic Link Filesystem II, NFS-Link Filesystem, Symbolic Link Filesystem, Filesystem Types @comment node-name, next, previous, up @section Symbolic Link Filesystem II (@samp{linkx}) @cindex Symbolic link filesystem II @cindex Referencing an existing part of the local name space @cindex Mounting an existing part of the local name space @cindex How to reference an existing part of the local name space @cindex linkx, filesystem type @cindex symlink, linkx filesystem type @cindex Filesystem type; linkx The @dfn{linkx} (@samp{type:=linkx}) filesystem type is identical to @samp{link} with the exception that the target of the link must exist. Existence is checked with the @b{lstat}(2) system call. The @samp{linkx} filesystem type is particularly useful for wildcard map entries. In this case, a list of possible targets can be given and @i{Amd} will choose the first one which exists on the local machine. @c ---------------------------------------------------------------- @node NFS-Link Filesystem, Automount Filesystem, Symbolic Link Filesystem II, Filesystem Types @comment node-name, next, previous, up @section NFS-Link Filesystem (@samp{nfsl}) @cindex NFS-Link filesystem II @cindex Referencing an existing part of the name space if target exists @cindex Mounting a remote part of the name space if target is missing @cindex Symlink if target exists, NFS otherwise @cindex nfsl, filesystem type @cindex symlink, nfsl filesystem type @cindex Filesystem type; nfsl The @dfn{nfsl} (@samp{type:=nfsl}) filesystem type is a combination of two others: @samp{link} and @samp{nfs}. If the local host name is equal to the value of @code{$@{rhost@}} @emph{and} the target pathname listed in @code{$@{fs@}} exists, @samp{nfsl} will behave exactly as @samp{type:=link}, and refer to the target as a symbolic link. If the local host name is not equal to the value of @code{$@{rhost@}}, or if the target of the link does not exist, @i{Amd} will treat it as @samp{type:=nfs}, and will mount a remote pathname for it. The @samp{nfsl} filesystem type is particularly useful as a shorthand for the more cumbersome and yet one of the most popular @i{Amd} entries. For example, you can simplify all map entries that look like: @example zing -fs:=/n/shekel/u/zing \ host!=shekel;type:=nfs;rhost:=shekel;rfs:=$@{fs@} \ host==shekel;type:=link @end example or @example zing -fs:=/n/shekel/u/zing \ exists($@{fs@});type:=link \ !exists($@{fs@});type:=nfs;rhost:=shekel;rfs:=$@{fs@} @end example into a shorter form @example zing type:=nfsl;fs:=/n/shekel/u/zing;rhost:=shekel;rfs:=$@{fs@} @end example Not just does it make the maps smaller and simpler, but it avoids possible mistakes that often happen when forgetting to set up the two entries (one for @samp{type:=nfs} and the other for @samp{type:=link}) necessary to perform transparent mounts of existing or remote mounts. @c ---------------------------------------------------------------- @node Automount Filesystem, Direct Automount Filesystem, NFS-Link Filesystem, Filesystem Types @comment node-name, next, previous, up @section Automount Filesystem (@samp{auto}) @cindex Automount filesystem @cindex Map cache types @cindex Setting map cache parameters @cindex How to set map cache parameters @cindex How to start an indirect automount point @cindex auto, filesystem type @cindex Filesystem type; auto @cindex SIGHUP signal @cindex Map cache synchronizing @cindex Synchronizing the map cache @cindex Map cache options @cindex Regular expressions in maps The @dfn{auto} (@samp{type:=auto}) filesystem type creates a new automount point below an existing automount point. Top-level automount points appear as system mount points. An automount mount point can also appear as a sub-directory of an existing automount point. This allows some additional structure to be added, for example to mimic the mount tree of another machine. The following options may be specified: @table @code @cindex cache, mount map option @cindex Mount map option; cache @item cache specifies whether the data in this mount-map should be cached. The default value is @samp{none}, in which case no caching is done in order to conserve memory. However, better performance and reliability can be obtained by caching some or all of a mount-map. If the cache option specifies @samp{all}, the entire map is enumerated when the mount point is created. If the cache option specifies @samp{inc}, caching is done incrementally as and when data is required. Some map types do not support cache mode @samp{all}, in which case @samp{inc} is used whenever @samp{all} is requested. Caching can be entirely disabled by using cache mode @samp{none}. If the cache option specifies @samp{regexp} then the entire map will be enumerated and each key will be treated as an egrep-style regular expression. The order in which a cached map is searched does not correspond to the ordering in the source map so the regular expressions should be mutually exclusive to avoid confusion. Each mount map type has a default cache type, usually @samp{inc}, which can be selected by specifying @samp{mapdefault}. The cache mode for a mount map can only be selected on the command line. Starting @i{Amd} with the command: @example amd /homes hesiod.homes -cache:=inc @end example will cause @samp{/homes} to be automounted using the @dfn{Hesiod} name server with local incremental caching of all successfully resolved names. All cached data is forgotten whenever @i{Amd} receives a @samp{SIGHUP} signal and, if cache @samp{all} mode was selected, the cache will be reloaded. This can be used to inform @i{Amd} that a map has been updated. In addition, whenever a cache lookup fails and @i{Amd} needs to examine a map, the map's modify time is examined. If the cache is out of date with respect to the map then it is flushed as if a @samp{SIGHUP} had been received. An additional option (@samp{sync}) may be specified to force @i{Amd} to check the map's modify time whenever a cached entry is being used. For example, an incremental, synchronized cache would be created by the following command: @example amd /homes hesiod.homes -cache:=inc,sync @end example @item fs specifies the name of the mount map to use for the new mount point. Arguably this should have been specified with the @code{$@{rfs@}} option but we are now stuck with it due to historical accident. @c %If the string @samp{.} is used then the same map is used; @c %in addition the lookup prefix is set to the name of the mount point followed @c %by a slash @samp{/}. @c %This is the same as specifying @samp{fs:=\$@{map@};pref:=\$@{key@}/}. @c @item pref alters the name that is looked up in the mount map. If @code{$@{pref@}}, the @dfn{prefix}, is non-null then it is prepended to the name requested by the kernel @dfn{before} the map is searched. The default prefix is the prefix of the parent map (if any) with name of the auto node appended to it. That means if you want no prefix you must say so in the map: @samp{pref:=null}. @item opts Normally, @samp{auto} style maps are not browsable even if you turn on directory browsability (@pxref{browsable_dirs Parameter}). To enable browsing entries in @samp{auto} maps, specify @samp{opts:=browsable} or @samp{opts:=fullybrowsable} in the description of this map. @end table The server @samp{dylan.doc.ic.ac.uk} has two user disks: @samp{/dev/dsk/2s0} and @samp{/dev/dsk/5s0}. These are accessed as @samp{/home/dylan/dk2} and @samp{/home/dylan/dk5} respectively. Since @samp{/home} is already an automount point, this naming is achieved with the following map entries:@refill @example dylan type:=auto;fs:=$@{map@};pref:=$@{key@}/ dylan/dk2 type:=ufs;dev:=/dev/dsk/2s0 dylan/dk5 type:=ufs;dev:=/dev/dsk/5s0 @end example @c ---------------------------------------------------------------- @node Direct Automount Filesystem, Union Filesystem, Automount Filesystem, Filesystem Types @comment node-name, next, previous, up @section Direct Automount Filesystem (@samp{direct}) @cindex Direct automount filesystem @cindex How to start a direct automount point @cindex direct, filesystem type @cindex Filesystem type; direct The @dfn{direct} (@samp{type:=direct}) filesystem is almost identical to the automount filesystem. Instead of appearing to be a directory of mount points, it appears as a symbolic link to a mounted filesystem. The mount is done at the time the link is accessed. @xref{Automount Filesystem}, for a list of required options. Direct automount points are created by specifying the @samp{direct} filesystem type on the command line: @example amd ... /usr/man auto.direct -type:=direct @end example where @samp{auto.direct} would contain an entry such as: @example usr/man -type:=nfs;rfs:=/usr/man \ rhost:=man-server1 rhost:=man-server2 @end example In this example, @samp{man-server1} and @samp{man-server2} are file servers which export copies of the manual pages. Note that the key which is looked up is the name of the automount point without the leading @samp{/}. Note that the implementation of the traditional @dfn{direct} filesystem is essentially a hack (pretending that the root of an NFS filesystem is a symlink) and many modern operating systems get very unhappy about it. For example, Linux kernel 2.4+ completely disallows it, and Solaris 2.8 fails to unmount it when @i{Amd} shuts down. Therefore, the use of the traditional @dfn{direct} filesystem is strongly discouraged; it is only semi-supported, at best. The autofs implementations that permit direct mounts are fully supported, however. That currently includes all versions of Solaris. Linux autofs does NOT support direct mounts at all. @c ---------------------------------------------------------------- @node Union Filesystem, Error Filesystem, Direct Automount Filesystem, Filesystem Types @comment node-name, next, previous, up @section Union Filesystem (@samp{union}) @cindex Union filesystem @cindex union, filesystem type @cindex Filesystem type; union The @dfn{union} (@samp{type:=union}) filesystem type allows the contents of several directories to be merged and made visible in a single directory. This can be used to overcome one of the major limitations of the Unix mount mechanism which only allows complete directories to be mounted. For example, supposing @file{/tmp} and @file{/var/tmp} were to be merged into a new directory called @file{/mtmp}, with files in @file{/var/tmp} taking precedence. The following command could be used to achieve this effect: @example amd ... /mtmp union:/tmp:/var/tmp -type:=union @end example Currently, the unioned directories must @emph{not} be automounted. That would cause a deadlock. This seriously limits the current usefulness of this filesystem type and the problem will be addressed in a future release of @i{Amd}. Files created in the union directory are actually created in the last named directory. This is done by creating a wildcard entry which points to the correct directory. The wildcard entry is visible if the union directory is listed, so allowing you to see which directory has priority. The files visible in the union directory are computed at the time @i{Amd} is started, and are not kept up-to-date with respect to the underlying directories. Similarly, if a link is removed, for example with the @samp{rm} command, it will be lost forever. @c ---------------------------------------------------------------- @node Error Filesystem, Top-level Filesystem, Union Filesystem, Filesystem Types @comment node-name, next, previous, up @section Error Filesystem (@samp{error}) @cindex Error filesystem @cindex error, filesystem type @cindex Filesystem type; error The @dfn{error} (@samp{type:=error}) filesystem type is used internally as a catch-all in the case where none of the other filesystems was selected, or some other error occurred. Lookups and mounts always fail with ``No such file or directory''. All other operations trivially succeed. The error filesystem is not directly accessible. @c ---------------------------------------------------------------- @node Top-level Filesystem, Root Filesystem, Error Filesystem, Filesystem Types @comment node-name, next, previous, up @section Top-level Filesystem (@samp{toplvl}) @cindex Top level filesystem @cindex toplvl, filesystem type @cindex Filesystem type; toplvl The @dfn{toplvl} (@samp{type:=toplvl}) filesystems is derived from the @samp{auto} filesystem and is used to mount the top-level automount nodes. Requests of this type are automatically generated from the command line arguments. @c ---------------------------------------------------------------- @node Root Filesystem, Inheritance Filesystem, Top-level Filesystem, Filesystem Types @comment node-name, next, previous, up @section Root Filesystem (@samp{root}) @cindex Root filesystem @cindex root, filesystem type @cindex Filesystem type; root The @dfn{root} (@samp{type:=root}) filesystem type acts as an internal placeholder onto which @i{Amd} can pin @samp{toplvl} mounts. Only one node of this type need ever exist and one is created automatically during startup. The effect of having more than one root node is undefined. The root filesystem is not directly accessible. @c ---------------------------------------------------------------- @node Inheritance Filesystem, , Root Filesystem, Filesystem Types @comment node-name, next, previous, up @section Inheritance Filesystem (@samp{inherit}) @cindex Inheritance filesystem @cindex Nodes generated on a restart @cindex inherit, filesystem type @cindex Filesystem type; inherit The @dfn{inheritance} (@samp{type:=inherit}) filesystem is not directly accessible. Instead, internal mount nodes of this type are automatically generated when @i{Amd} is started with the @code{-r} option. At this time the system mount table is scanned to locate any filesystems which are already mounted. If any reference to these filesystems is made through @i{Amd} then instead of attempting to mount it, @i{Amd} simulates the mount and @dfn{inherits} the filesystem. This allows a new version of @i{Amd} to be installed on a live system simply by killing the old daemon with @samp{SIGTERM} and starting the new one.@refill This filesystem type is not generally visible externally, but it is possible that the output from @samp{amq -m} may list @samp{inherit} as the filesystem type. This happens when an inherit operation cannot be completed for some reason, usually because a fileserver is down. @c ################################################################ @node Amd Configuration File, Run-time Administration, Filesystem Types, Top @comment node-name, next, previous, up @chapter Amd Configuration File @cindex Amd Configuration File @cindex amd.conf The @samp{amd.conf} file is the configuration file for @i{Amd}, as part of the am-utils suite. This file contains runtime configuration information for the @i{Amd} automounter program. @menu * File Format:: * The Global Section:: * Regular Map Sections:: * Common Parameters:: * Global Parameters:: * Regular Map Parameters:: * amd.conf Examples:: @end menu @c ================================================================ @node File Format, The Global Section, Amd Configuration File, Amd Configuration File @comment node-name, next, previous, up @section File Format @cindex amd.conf file format The @samp{amd.conf} file consists of sections and parameters. A section begins with the name of the section in square brackets @samp{[]} and continues until the next section begins or the end of the file is reached. Sections contain parameters of the form @samp{name = value}. The file is line-based --- that is, each newline-terminated line represents either a comment, a section name or a parameter. No line-continuation syntax is available. Section names, parameter names and their values are case sensitive. Only the first equals sign in a parameter is significant. Whitespace before or after the first equals sign is discarded. Leading, trailing and internal whitespace in section and parameter names is irrelevant. Leading and trailing whitespace in a parameter value is discarded. Internal whitespace within a parameter value is not allowed, unless the whole parameter value is quoted with double quotes as in @samp{name = "some value"}. Any line beginning with a pound sign @samp{#} is ignored, as are lines containing only whitespace. The values following the equals sign in parameters are all either a string (no quotes needed if string does not include spaces) or a boolean, which may be given as @samp{yes}/@samp{no}. Case is significant in all values. Some items such as cache timeouts are numeric. @c ================================================================ @node The Global Section, Regular Map Sections, File Format, Amd Configuration File @comment node-name, next, previous, up @section The Global Section @cindex amd.conf global section The global section must be specified as @samp{[global]}. Parameters in this section either apply to @i{Amd} as a whole, or to all other regular map sections which follow. There should be only one global section defined in one configuration file. It is highly recommended that this section be specified first in the configuration file. If it is not, then regular map sections which precede it will not use global values defined later. @c ================================================================ @node Regular Map Sections, Common Parameters, The Global Section, Amd Configuration File @comment node-name, next, previous, up @section Regular Map Sections @cindex amd.conf regular map sections Parameters in regular (non-global) sections apply to a single map entry. For example, if the map section @samp{[/homes]} is defined, then all parameters following it will be applied to the @file{/homes} @i{Amd}-managed mount point. @c ================================================================ @node Common Parameters, Global Parameters, Regular Map Sections, Amd Configuration File @comment node-name, next, previous, up @section Common Parameters @cindex amd.conf common parameters These parameters can be specified either in the global or a map-specific section. Entries specified in a map-specific section override the default value or one defined in the global section. If such a common parameter is specified only in the global section, it is applicable to all regular map sections that follow. @menu * autofs_use_lofs Parameter:: * browsable_dirs Parameter:: * map_defaults Parameter:: * map_options Parameter:: * map_type Parameter:: * mount_type Parameter:: * search_path Parameter:: * selectors_in_defaults Parameter:: * sun_map_syntax Parameter:: @end menu @c ---------------------------------------------------------------- @node autofs_use_lofs Parameter, browsable_dirs Parameter, Common Parameters, Common Parameters @comment node-name, next, previous, up @subsection @t{autofs_use_lofs} Parameter @cindex autofs_use_lofs Parameter (type=string, default=@samp{yes}). When set to @samp{yes}, @i{Amd}'s autofs code will use lofs-type (loopback) mounts for @code{type:=link} mounts, as well as several other cases that require local references. This has the advantage that @i{Amd} does not use a secondary mount point and users do not see external pathnames (the infamous @code{/bin/pwd} problem, where it reports a different path than the user chdir'ed into). One of the disadvantages of using this option is that the autofs code is relatively new and the in-place mounts have not been throughly tested. If this option is set to @samp{no}, then @i{Amd}'s autofs code will use symlinks instead of lofs-type mounts for local references. This has the advantage of using simpler (more stable) code, but at the expense of negating one of autofs's big advantages: the hiding of @i{Amd}'s internal paths. Note that symlinks are not supported in all autofs implementations, especially those derived from Solaris Autofs v1. Also, on Solaris 2.6 and newer, autofs symlinks are not cached, resulting in repeated up-call requests to @i{Amd}. @c ---------------------------------------------------------------- @node browsable_dirs Parameter, map_defaults Parameter, autofs_use_lofs Parameter, Common Parameters @comment node-name, next, previous, up @subsection @t{browsable_dirs} Parameter @cindex browsable_dirs Parameter (type=string, default=@samp{no}). If @samp{yes}, then @i{Amd}'s top-level mount points will be browsable to @b{readdir}(3) calls. This means you could run for example @b{ls}(1) and see what keys are available to mount in that directory. Not all entries are made visible to @b{readdir}(3): the @samp{/defaults} entry, wildcard entries, and those with a @file{/} in them are not included. If you specify @samp{full} to this option, all but the @samp{/defaults} entry will be visible. Note that if you run a command which will attempt to @b{stat}(2) the entries, such as often done by @samp{ls -l} or @samp{ls -F}, @i{Amd} will attempt to mount @i{every} entry in that map. This is often called a ``mount storm''. Note that mount storms are mostly avoided by using autofs mounts (@samp{mount_type = autofs}). @c ---------------------------------------------------------------- @node map_defaults Parameter, map_options Parameter, browsable_dirs Parameter, Common Parameters @comment node-name, next, previous, up @subsection @t{map_defaults} Parameter @cindex map_defaults Parameter (type=string, default to empty). This option sets a string to be used as the map's @code{/defaults} entry, overriding any @code{/defaults} specified in the map. This allows local users to override a given map's defaults without modifying maps globally (which is impossible in sites where the maps are managed by a different administrative group). @c ---------------------------------------------------------------- @node map_options Parameter, map_type Parameter, map_defaults Parameter, Common Parameters @comment node-name, next, previous, up @subsection @t{map_options} Parameter @cindex map_options Parameter (type=string, default no options). This option is the same as specifying map options on the command line to @i{Amd}, such as @samp{cache:=all}. @c ---------------------------------------------------------------- @node map_type Parameter, mount_type Parameter, map_options Parameter, Common Parameters @comment node-name, next, previous, up @subsection @t{map_type} Parameter @cindex map_type Parameter (type=string, default search all map types). If specified, @i{Amd} will initialize the map only for the type given. This is useful to avoid the default map search type used by @i{Amd} which takes longer and can have undesired side-effects such as initializing NIS even if not used. Possible values are @table @samp @item file plain files @item hesiod Hesiod name service from MIT @item ldap Lightweight Directory Access Protocol @item ndbm (New) dbm style hash files @item nis Network Information Services (version 2) @item nisplus Network Information Services Plus (version 3) @item passwd local password files @item union union maps @end table @c ---------------------------------------------------------------- @node mount_type Parameter, search_path Parameter, map_type Parameter, Common Parameters @comment node-name, next, previous, up @subsection @t{mount_type} Parameter @cindex mount_type Parameter (type=string, default=@samp{nfs}). All @i{Amd} mount types default to NFS. That is, @i{Amd} is an NFS server on the map mount points, for the local host it is running on. If @samp{autofs} is specified, @i{Amd} will be an autofs server for those mount points. @c ---------------------------------------------------------------- @node search_path Parameter, selectors_in_defaults Parameter, mount_type Parameter, Common Parameters @comment node-name, next, previous, up @subsection @t{search_path} Parameter @cindex search_path Parameter (type=string, default no search path). This provides a (colon-delimited) search path for file maps. Using a search path, sites can allow for local map customizations and overrides, and can distributed maps in several locations as needed. @c ---------------------------------------------------------------- @node selectors_in_defaults Parameter, sun_map_syntax Parameter, search_path Parameter, Common Parameters @comment node-name, next, previous, up @subsection @t{selectors_in_defaults} Parameter @cindex selectors_in_defaults Parameter (type=boolean, default=@samp{no}). If @samp{yes}, then the @samp{/defaults} entry of maps will search for and process any selectors before setting defaults for all other keys in that map. Useful when you want to set different options for a complete map based on some parameters. For example, you may want to better the NFS performance over slow slip-based networks as follows: @example /defaults \ wire==slip-net;opts:=intr,rsize=1024,wsize=1024 \ wire!=slip-net;opts:=intr,rsize=8192,wsize=8192 @end example Deprecated form: selectors_on_default. @c ---------------------------------------------------------------- @node sun_map_syntax Parameter, , selectors_in_defaults Parameter, Common Parameters @comment node-name, next, previous, up @subsection @t{sun_map_syntax} Parameter @cindex sun_map_syntax Parameter (type=boolean, default=@samp{no}). If @samp{yes}, then @i{Amd} will parse the map according to the Sun Automount syntax. @c ================================================================ @node Global Parameters, Regular Map Parameters, Common Parameters, Amd Configuration File @comment node-name, next, previous, up @section Global Parameters @cindex amd.conf global parameters The following parameters are applicable to the @samp{[global]} section only. @menu * arch Parameter:: * auto_attrcache Parameter:: * auto_dir Parameter:: * cache_duration Parameter:: * cluster Parameter:: * debug_mtab_file Parameter:: * debug_options Parameter:: * dismount_interval Parameter:: * domain_strip Parameter:: * exec_map_timeout Parameter:: * forced_unmounts Parameter:: * full_os Parameter:: * fully_qualified_hosts Parameter:: * hesiod_base Parameter:: * karch Parameter:: * ldap_base Parameter:: * ldap_cache_maxmem Parameter:: * ldap_cache_seconds Parameter:: * ldap_hostports Parameter:: * ldap_proto_version Parameter:: * local_domain Parameter:: * localhost_address Parameter:: * log_file Parameter:: * log_options Parameter:: * map_reload_interval Parameter:: * nfs_allow_any_interface Parameter:: * nfs_allow_insecure_port Parameter:: * nfs_proto Parameter:: * nfs_retransmit_counter Parameter:: * nfs_retransmit_counter_udp Parameter:: * nfs_retransmit_counter_tcp Parameter:: * nfs_retransmit_counter_toplvl Parameter:: * nfs_retry_interval Parameter:: * nfs_retry_interval_udp Parameter:: * nfs_retry_interval_tcp Parameter:: * nfs_retry_interval_toplvl Parameter:: * nfs_vers Parameter:: * nis_domain Parameter:: * normalize_hostnames Parameter:: * normalize_slashes Parameter:: * os Parameter:: * osver Parameter:: * pid_file Parameter:: * plock Parameter:: * portmap_program Parameter:: * preferred_amq_port Parameter:: * print_pid Parameter:: * print_version Parameter:: * restart_mounts Parameter:: * show_statfs_entries Parameter:: * truncate_log Parameter:: * unmount_on_exit Parameter:: * use_tcpwrappers Parameter:: * vendor Parameter:: @end menu @c ---------------------------------------------------------------- @node arch Parameter, auto_attrcache Parameter, Global Parameters, Global Parameters @comment node-name, next, previous, up @subsection @t{arch} Parameter @cindex arch Parameter (type=string, default to compiled in value). Same as the @code{-A} option to @i{Amd}. Allows you to override the value of the @i{arch} @i{Amd} variable. @c ---------------------------------------------------------------- @node auto_attrcache Parameter, auto_dir Parameter, arch Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{auto_attrcache} Parameter @cindex auto_attrcache Parameter (type=numeric, default=0). Specify in seconds (or units of 0.1 seconds, depending on the OS), what is the (kernel-side) NFS attribute cache timeout for @i{Amd}'s own automount points. A value of 0 is supposed to turn off attribute caching, meaning that @i{Amd} will be consulted via a kernel-RPC each time someone stat()'s the mount point (which could be abused as a denial-of-service attack). @emph{WARNING}: @i{Amd} depends on being able to turn off the NFS attribute cache of the client OS. If it cannot be turned off, then users may get ESTALE errors or symlinks that point to the wrong places. This is more likely under heavy use of @i{Amd}, for example if your system is experiencing frequent map changes or frequent mounts/unmounts. Therefore, under normal circumstances, this parameter should remain set to 0, to ensure that the attribute cache is indeed off. Unfortunately, some kernels (e.g., certain BSDs) don't have a way to turn off the NFS attribute cache. Setting this parameter to 0 is supposed to turn off attribute caching entirely, but unfortunately it does not; instead, the attribute cache is set to some internal hard-coded default (usually anywhere from 5-30 seconds). If you suspect that your OS doesn't have a reliable way of turning off the attribute cache, then it is better to set this parameter to the smallest possible non-zero value (set @samp{auto_attrcache=1} in your @code{amd.conf}). This will not eliminate the problem, but reduce the risk window somewhat. The best solutions are (1) to use @i{Amd} in Autofs mode, if it's supported in your OS, and (2) talk to your OS vendor to support a true @samp{noac} flag. See the @uref{http://www.am-utils.org/docs/am-utils/attrcache.txt,README.attrcache} document for more details. If you are able to turn off the attribute cache on your OS, alas, @i{Amd}'s performance may degrade (when not using Autofs) because every traversal of an automounter-controlled pathname will result in a lookup request from the kernel to @i{Amd}. Under heavy loads, for example when using recursive tools like @samp{find}, @samp{rdist}, or @samp{rsync}, this performance degradation can be noticeable. There are two possible solutions that some administrators have chosen to improve performance: @enumerate @item First, you can turn off unmounting using the @samp{nounmount} mount option. This will ensure that no @i{Amd} symlink could ever change, thereby the kernel's attribute cache and @i{Amd} will always be in sync. However, this method will cause the number of mounts to keep growing, even if some are no longer in use; this has the disadvantage that your system could be more susceptible to hangs if even one of those accumulating mounts hangs due to a downed server. @item Second, you can turn on attribute caching carefully by setting a small automounter attribute cache value (say, one second), and a relatively large dismount interval (say, one hour). (@xref{dismount_interval Parameter}.) For example, you can set this in your @code{amd.conf}: @example [global] auto_attrcache = 1 dismount_interval = 3600 @end example This has the benefit of using the kernel's attribute cache and thus improving performance. The disadvantage with this option is that the window of vulnerability is not eliminated entirely: it is only made smaller. @end enumerate @c ---------------------------------------------------------------- @node auto_dir Parameter, cache_duration Parameter, auto_attrcache Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{auto_dir} Parameter @cindex auto_dir Parameter (type=string, default=@samp{/a}). Same as the @code{-a} option to @i{Amd}. This sets the private directory where @i{Amd} will create sub-directories for its real mount points. @c ---------------------------------------------------------------- @node cache_duration Parameter, cluster Parameter, auto_dir Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{cache_duration} Parameter @cindex cache_duration Parameter (type=numeric, default=300). Same as the @code{-c} option to @i{Amd}. Sets the duration in seconds that looked-up or mounted map entries remain in the cache. @c ---------------------------------------------------------------- @node cluster Parameter, debug_mtab_file Parameter, cache_duration Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{cluster} Parameter @cindex cluster Parameter (type=string, default no cluster). Same as the @code{-C} option to @i{Amd}. Specifies the alternate HP-UX cluster to use. @c ---------------------------------------------------------------- @node debug_mtab_file Parameter, debug_options Parameter, cluster Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{debug_mtab_file} Parameter @cindex debug_mtab_file Parameter (type=string, default="/tmp/mtab"). Path to mtab file that is used by @i{Amd} to store a list of mounted file systems during debug-mtab mode. This option only applies to systems that store mtab information on disk. @c ---------------------------------------------------------------- @node debug_options Parameter, dismount_interval Parameter, debug_mtab_file Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{debug_options} Parameter @cindex debug_options Parameter (type=string, default no debug options). Same as the @code{-D} option to @i{Amd}. Specify any debugging options for @i{Amd}. Works only if am-utils was configured for debugging using the @code{--enable-debug} option. The additional @samp{mem} option can be turned on via @code{--enable-debug=mem}. Otherwise debugging options are ignored. Options are comma delimited, and can be preceded by the string @samp{no} to negate their meaning. You can get the list of supported debugging and logging options by running @code{amd -H}. Possible values those listed for the -D option. @xref{-D Option}. @c ---------------------------------------------------------------- @node dismount_interval Parameter, domain_strip Parameter, debug_options Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{dismount_interval} Parameter @cindex dismount_interval Parameter (type=numeric, default=120). Same as the @code{-w} option to @i{Amd}. Specify in seconds, the time between attempts to dismount file systems that have exceeded their cached times. @c ---------------------------------------------------------------- @node domain_strip Parameter, exec_map_timeout Parameter, dismount_interval Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{domain_strip} Parameter @cindex domain_strip Parameter (type=boolean, default=@samp{yes}). If @samp{yes}, then the domain name part referred to by @code{$@{rhost@}} is stripped off. This is useful to keep logs and smaller. If @samp{no}, then the domain name part is left changed. This is useful when using multiple domains with the same maps (as you may have hosts whose domain-stripped name is identical). @c ---------------------------------------------------------------- @node exec_map_timeout Parameter, forced_unmounts Parameter, domain_strip Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{exec_map_timeout} Parameter @cindex exec_map_timeout Parameter (type=numeric, default=10). The timeout in seconds that @i{Amd} will wait for an executable map program before an answer is returned from that program (or script). This value should be set to as small as possible while still allowing normal replies to be returned before the timer expires, because during the time that the executable map program is queried, @i{Amd} is essentially waiting and is thus not responding to any other queries. @xref{Executable maps}. @c ---------------------------------------------------------------- @node forced_unmounts Parameter, full_os Parameter, exec_map_timeout Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{forced_unmounts} Parameter @cindex forced_unmounts Parameter (type=boolean, default=@samp{no}). Sometimes, mount points are hung due to unrecoverable conditions, such as when NFS servers migrate, change their IP address, are down permanently, or due to hardware failures, and more. In this case, attempting to unmount an existing mount point, or even just to @b{stat}(2) it, results in one of three fatal errors: EIO, ESTALE, or EBUSY. At that point, @i{Amd} can do little to recover that hung point (in fact, the OS cannot automatically recover either). For that reason, some OSs support special kinds of forced unmounts, which must be used very carefully: they will force an unmount immediately (or lazily on Linux), which could result in application data loss. However, that may be the only way to recover the entire host (without rebooting). Once a hung mount point is forced out, @i{Amd} can then re-mount a replacement one (if available), bringing a mostly-hung system back to operation and avoiding a potentially costly reboot. If the @samp{forced_unmounts} option is set to @samp{yes}, and the client OS supports forced or lazy unmounts, then @i{Amd} will attempt to use them if it gets any of the three serious error conditions listed above. Note that @i{Amd} will force the unmount of mount points that returned EBUSY only for @samp{type:=toplvl} mounts (@pxref{Top-level Filesystem}): that is, @i{Amd}'s own mount points. This is useful to recover from a previously hung @i{Amd}, and to ensure that an existing @i{Amd} can shutdown cleanly even if some processes are keeping its mount points busy (i.e., when a user's shell process uses @code{cd} to set its CWD to @i{Amd}'s own mount point). If this option is set to @samp{no} (the default), then @i{Amd} will not attempt this special recovery procedure. @c ---------------------------------------------------------------- @node full_os Parameter, fully_qualified_hosts Parameter, forced_unmounts Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{full_os} Parameter @cindex full_os Parameter (type=string, default to compiled in value). The full name of the operating system, along with its version. Allows you to override the compiled-in full name and version of the operating system. Useful when the compiled-in name is not desired. For example, the full operating system name on linux comes up as @samp{linux}, but you can override it to @samp{linux-2.2.5}. @c ---------------------------------------------------------------- @node fully_qualified_hosts Parameter, hesiod_base Parameter, full_os Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{fully_qualified_hosts} Parameter @cindex fully_qualified_hosts Parameter (type=string, default=@samp{no}). If @samp{yes}, @i{Amd} will perform RPC authentication using fully-qualified host names. This is necessary for some systems, and especially when performing cross-domain mounting. For this function to work, the @i{Amd} variable @samp{$@{hostd@}} is used, requiring that @samp{$@{domain@}} not be null. @c ---------------------------------------------------------------- @node hesiod_base Parameter, karch Parameter, fully_qualified_hosts Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{hesiod_base} Parameter @cindex hesiod_base Parameter (type=string, default=@samp{automount}). Specify the base name for hesiod maps. @c ---------------------------------------------------------------- @node karch Parameter, ldap_base Parameter, hesiod_base Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{karch} Parameter @cindex karch Parameter (type=string, default to karch of the system). Same as the @code{-k} option to @i{Amd}. Allows you to override the kernel-architecture of your system. Useful for example on Sun (Sparc) machines, where you can build one @i{Amd} binary, and run it on multiple machines, yet you want each one to get the correct @i{karch} variable set (for example, sun4c, sun4m, sun4u, etc.) Note that if not specified, @i{Amd} will use @b{uname}(2) to figure out the kernel architecture of the machine. @c ---------------------------------------------------------------- @node ldap_base Parameter, ldap_cache_maxmem Parameter, karch Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{ldap_base} Parameter @cindex ldap_base Parameter (type=string, default not set). Specify the base name for LDAP. This often includes LDAP-specific values such as country and organization. @c ---------------------------------------------------------------- @node ldap_cache_maxmem Parameter, ldap_cache_seconds Parameter, ldap_base Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{ldap_cache_maxmem} Parameter @cindex ldap_cache_maxmem Parameter (type=numeric, default=131072). Specify the maximum memory @i{Amd} should use to cache LDAP entries. @c ---------------------------------------------------------------- @node ldap_cache_seconds Parameter, ldap_hostports Parameter, ldap_cache_maxmem Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{ldap_cache_seconds} Parameter @cindex ldap_cache_seconds Parameter (type=numeric, default=0). Specify the number of seconds to keep entries in the cache. @c ---------------------------------------------------------------- @node ldap_hostports Parameter, ldap_proto_version Parameter, ldap_cache_seconds Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{ldap_hostports} Parameter @cindex ldap_hostports Parameter (type=string, default not set). Specify the LDAP host and port values. @c ---------------------------------------------------------------- @node ldap_proto_version Parameter, local_domain Parameter, ldap_hostports Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{ldap_proto_version} Parameter @cindex ldap_proto_version Parameter (type=numeric, default=2). Specify the LDAP protocol version to use. With a value of 3 will use LDAPv3 protocol. @c ---------------------------------------------------------------- @node local_domain Parameter, localhost_address Parameter, ldap_proto_version Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{local_domain} Parameter @cindex local_domain Parameter (type=string, default no sub-domain). Same as the @code{-d} option to @i{Amd}. Specify the local domain name. If this option is not given the domain name is determined from the hostname, by removing the first component of the fully-qualified host name. @c ---------------------------------------------------------------- @node localhost_address Parameter, log_file Parameter, local_domain Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{localhost_address} Parameter @cindex localhost_address Parameter (type=string, default to localhost or 127.0.0.1). Specify the name or IP address for @i{Amd} to use when connecting the sockets for the local NFS server and the RPC server. This defaults to 127.0.0.1 or whatever the host reports as its local address. This parameter is useful on hosts with multiple addresses where you want to force @i{Amd} to connect to a specific address. @c ---------------------------------------------------------------- @node log_file Parameter, log_options Parameter, localhost_address Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{log_file} Parameter @cindex log_file Parameter (type=string, default=@samp{stderr}). Same as the @code{-l} option to @i{Amd}. Specify a file name to log @i{Amd} events to. If the string @samp{/dev/stderr} is specified, @i{Amd} will send its events to the standard error file descriptor. If the string @samp{syslog} is given, @i{Amd} will record its events with the system logger @b{syslogd}(8). If your system supports syslog facilities, then the default facility used is @samp{LOG_DAEMON}. When using syslog, if you wish to change the facility, append its name to the option name, delimited by a single colon. For example, if it is the string @samp{syslog:local7} then @i{Amd} will log messages via @b{syslog}(3) using the @samp{LOG_LOCAL7} facility. If the facility name specified is not recognized, @i{Amd} will default to @samp{LOG_DAEMON}. Note: while you can use any syslog facility available on your system, it is generally a bad idea to use those reserved for other services such as @samp{kern}, @samp{lpr}, @samp{cron}, etc. @c ---------------------------------------------------------------- @node log_options Parameter, map_reload_interval Parameter, log_file Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{log_options} Parameter @cindex log_options Parameter (type=string, default=``defaults''). Same as the @code{-x} option to @i{Amd}. Specify any logging options for @i{Amd}. Options are comma delimited, and can be preceded by the string @samp{no} to negate their meaning. The @samp{debug} logging option is only available if am-utils was configured with @code{--enable-debug}. You can get the list of supported debugging options by running @code{amd -H}. Possible values are: @table @samp @item all all messages @item defaults an alias for "fatal,error,user,warning,info" @item debug debug messages @item error non-fatal system errors (cannot be turned off) @item fatal fatal errors (cannot be turned off) @item info information @item map map errors @item stats additional statistical information @item user non-fatal user errors @item warn warnings @item warning warnings @end table @c ---------------------------------------------------------------- @node map_reload_interval Parameter, nfs_allow_any_interface Parameter, log_options Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{map_reload_interval} Parameter @cindex map_reload_interval Parameter (type=numeric, default=3600). The number of seconds that @i{Amd} will wait before it checks to see if any maps have changed at their source (NIS servers, LDAP servers, files, etc.). @i{Amd} will reload only those maps that have changed. @c ---------------------------------------------------------------- @node nfs_allow_any_interface Parameter, nfs_allow_insecure_port Parameter, map_reload_interval Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{nfs_allow_any_interface} Parameter @cindex nfs_allow_any_interface Parameter (type=string, default=@samp{no}). Normally @i{Amd} accepts local NFS packets only from 127.0.0.1. If this parameter is set to @samp{yes}, then @i{amd} will accept local NFS packets from any local interface; this is useful on hosts that may have multiple interfaces where the system is forced to send all outgoing packets (even those bound to the same host) via an address other than 127.0.0.1. @c ---------------------------------------------------------------- @node nfs_allow_insecure_port Parameter, nfs_proto Parameter, nfs_allow_any_interface Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{nfs_allow_insecure_port} Parameter @cindex nfs_allow_insecure_port Parameter (type=string, default=@samp{no}). Normally @i{Amd} will refuse requests coming from unprivileged ports (i.e., ports >= 1024 on Unix systems), so that only privileged users and the kernel can send NFS requests to it. However, some kernels (certain versions of Darwin, MacOS X, and Linux) have bugs that cause them to use unprivileged ports in certain situations, which causes @i{Amd} to stop dead in its tracks. This parameter allows @i{Amd} to operate normally even on such systems, at the expense of a slight decrease in the security of its operations. If you see messages like ``ignoring request from foo:1234, port not reserved'' in your @i{Amd} log, try enabling this parameter and give it another go. @c ---------------------------------------------------------------- @node nfs_proto Parameter, nfs_retransmit_counter Parameter, nfs_allow_insecure_port Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{nfs_proto} Parameter @cindex nfs_proto Parameter (type=string, default to trying version tcp then udp). By default, @i{Amd} tries @code{tcp} and then @code{udp}. This option forces the overall NFS protocol used to TCP or UDP. It overrides what is in the @i{Amd} maps, and is useful when @i{Amd} is compiled with TCP support in NFSv2/NFSv3 that may not be stable. With this option you can turn off the complete usage of TCP for NFS dynamically (without having to recompile @i{Amd}), and use UDP only, until such time as TCP support is desired again. @c ---------------------------------------------------------------- @node nfs_retransmit_counter Parameter, nfs_retransmit_counter_udp Parameter, nfs_proto Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{nfs_retransmit_counter} Parameter @cindex nfs_retransmit_counter Parameter (type=numeric, default=11). Same as the @i{retransmit} part of the @code{-t} @i{timeout.retransmit} option to @i{Amd}. Specifies the number of NFS retransmissions that the kernel will use to communicate with @i{Amd} using either UDP or TCP mounts. @xref{-t Option}. @c ---------------------------------------------------------------- @node nfs_retransmit_counter_udp Parameter, nfs_retransmit_counter_tcp Parameter, nfs_retransmit_counter Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{nfs_retransmit_counter_udp} Parameter @cindex nfs_retransmit_counter_udp Parameter @cindex nfs_retransmit_counter Parameter @cindex UDP (type=numeric, default=11). Same as the @i{nfs_retransmit_counter} parameter, but applied globally only to UDP mounts. @xref{nfs_retransmit_counter Parameter}. @c ---------------------------------------------------------------- @node nfs_retransmit_counter_tcp Parameter, nfs_retransmit_counter_toplvl Parameter, nfs_retransmit_counter_udp Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{nfs_retransmit_counter_tcp} Parameter @cindex nfs_retransmit_counter_tcp Parameter @cindex nfs_retransmit_counter Parameter @cindex TCP (type=numeric, default=11). Same as the @i{nfs_retransmit_counter} parameter, but applied globally only to TCP mounts. @xref{nfs_retransmit_counter Parameter}. @c ---------------------------------------------------------------- @node nfs_retransmit_counter_toplvl Parameter, nfs_retry_interval Parameter, nfs_retransmit_counter_tcp Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{nfs_retransmit_counter_toplvl} Parameter @cindex nfs_retransmit_counter_toplvl Parameter @cindex nfs_retransmit_counter Parameter @cindex UDP (type=numeric, default=11). Same as the @i{nfs_retransmit_counter} parameter, applied only for @i{Amd}'s top-level UDP mounts. On some systems it is useful to set this differently than the OS default, so as to better tune @i{Amd}'s responsiveness under heavy scheduler loads. @xref{nfs_retransmit_counter Parameter}. @c ---------------------------------------------------------------- @node nfs_retry_interval Parameter, nfs_retry_interval_udp Parameter, nfs_retransmit_counter_toplvl Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{nfs_retry_interval} Parameter @cindex nfs_retry_interval Parameter (type=numeric, default=8). Same as the @i{timeout} part of the @code{-t} @i{timeout.retransmit} option to @i{Amd}. Specifies the NFS timeout interval, in @emph{tenths} of seconds, between NFS/RPC retries (for UDP or TCP). This is the value that the kernel will use to communicate with @i{Amd}. @xref{-t Option}. @i{Amd} relies on the kernel RPC retransmit mechanism to trigger mount retries. The values of the @i{nfs_retransmit_counter} and the @i{nfs_retry_interval} parameters change the overall retry interval. Too long an interval gives poor interactive response; too short an interval causes excessive retries. @c ---------------------------------------------------------------- @node nfs_retry_interval_udp Parameter, nfs_retry_interval_tcp Parameter, nfs_retry_interval Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{nfs_retry_interval_udp} Parameter @cindex nfs_retry_interval_udp Parameter @cindex nfs_retry_interval Parameter @cindex UDP (type=numeric, default=8). Same as the @i{nfs_retry_interval} parameter, but applied globally only to UDP mounts. @xref{nfs_retry_interval Parameter}. @c ---------------------------------------------------------------- @node nfs_retry_interval_tcp Parameter, nfs_retry_interval_toplvl Parameter, nfs_retry_interval_udp Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{nfs_retry_interval_tcp} Parameter @cindex nfs_retry_interval_tcp Parameter @cindex nfs_retry_interval Parameter @cindex TCP (type=numeric, default=8). Same as the @i{nfs_retry_interval} parameter, but applied globally only to TCP mounts. @xref{nfs_retry_interval Parameter}. @c ---------------------------------------------------------------- @node nfs_retry_interval_toplvl Parameter, nfs_vers Parameter, nfs_retry_interval_tcp Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{nfs_retry_interval_toplvl} Parameter @cindex nfs_retry_interval_toplvl Parameter @cindex nfs_retry_interval Parameter @cindex UDP (type=numeric, default=8). Same as the @i{nfs_retry_interval} parameter, applied only for @i{Amd}'s top-level UDP mounts. On some systems it is useful to set this differently than the OS default, so as to better tune @i{Amd}'s responsiveness under heavy scheduler loads. @xref{nfs_retry_interval Parameter}. @c ---------------------------------------------------------------- @node nfs_vers Parameter, nis_domain Parameter, nfs_retry_interval_toplvl Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{nfs_vers} Parameter @cindex nfs_vers Parameter (type=numeric, default to trying version 3 then 2). By default, @i{Amd} tries version 3 and then version 2. This option forces the overall NFS protocol used to version 3 or 2. It overrides what is in the @i{Amd} maps, and is useful when @i{Amd} is compiled with NFSv3 support that may not be stable. With this option you can turn off the complete usage of NFSv3 dynamically (without having to recompile @i{Amd}), and use NFSv2 only, until such time as NFSv3 support is desired again. @c ---------------------------------------------------------------- @node nis_domain Parameter, normalize_hostnames Parameter, nfs_vers Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{nis_domain} Parameter @cindex nis_domain Parameter (type=string, default to local NIS domain name). Same as the @code{-y} option to @i{Amd}. Specify an alternative NIS domain from which to fetch the NIS maps. The default is the system domain name. This option is ignored if NIS support is not available. @c ---------------------------------------------------------------- @node normalize_hostnames Parameter, normalize_slashes Parameter, nis_domain Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{normalize_hostnames} Parameter @cindex normalize_hostnames Parameter (type=boolean, default=@samp{no}). Same as the @code{-n} option to @i{Amd}. If @samp{yes}, then the name referred to by @code{$@{rhost@}} is normalized relative to the host database before being used. The effect is to translate aliases into ``official'' names. @c ---------------------------------------------------------------- @node normalize_slashes Parameter, os Parameter, normalize_hostnames Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{normalize_slashes} Parameter @cindex normalize_slashes Parameter (type=boolean, default=@samp{yes}). If @samp{yes} then amd will condense all multiple @code{/} (slash) characters into one and remove all trailing slashes. If @samp{no}, then amd will not touch strings that may contain repeated or trailing slashes. The latter is sometimes useful with SMB mounts, which often require multiple slash characters in pathnames. @c ---------------------------------------------------------------- @node os Parameter, osver Parameter, normalize_slashes Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{os} Parameter @cindex os Parameter (type=string, default to compiled in value). Same as the @code{-O} option to @i{Amd}. Allows you to override the compiled-in name of the operating system. Useful when the built-in name is not desired for backward compatibility reasons. For example, if the built-in name is @samp{sunos5}, you can override it to @samp{sos5}, and use older maps which were written with the latter in mind. @c ---------------------------------------------------------------- @node osver Parameter, pid_file Parameter, os Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{osver} Parameter @cindex osver Parameter (type=string, default to compiled in value). Same as the @code{-o} option to @i{Amd}. Allows you to override the compiled-in version number of the operating system. Useful when the built-in version is not desired for backward compatibility reasons. For example, if the build in version is @samp{2.5.1}, you can override it to @samp{5.5.1}, and use older maps that were written with the latter in mind. @c ---------------------------------------------------------------- @node pid_file Parameter, plock Parameter, osver Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{pid_file} Parameter @cindex pid_file Parameter (type=string, default=@samp{/dev/stdout}). Specify a file to store the process ID of the running daemon into. If not specified, @i{Amd} will print its process id onto the standard output. Useful for killing @i{Amd} after it had run. Note that the PID of a running @i{Amd} can also be retrieved via @i{Amq} (@pxref{Amq -p option}). This file is used only if the @samp{print_pid} option is on (@pxref{print_pid Parameter}). @c ---------------------------------------------------------------- @node plock Parameter, portmap_program Parameter, pid_file Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{plock} Parameter @cindex plock Parameter (type=boolean, default=@samp{yes}). Same as the @code{-S} option to @i{Amd}. If @samp{yes}, lock the running executable pages of @i{Amd} into memory. To improve @i{Amd}'s performance, systems that support the @b{plock}(3) or @b{mlockall}(2) call can lock the @i{Amd} process into memory. This way there is less chance the operating system will schedule, page out, and swap the @i{Amd} process as needed. This improves @i{Amd}'s performance, at the cost of reserving the memory used by the @i{Amd} process (making it unavailable for other processes). @c ---------------------------------------------------------------- @node portmap_program Parameter, preferred_amq_port Parameter, plock Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{portmap_program} Parameter @cindex portmap_program Parameter (type=numeric, default=300019). Specify an alternate Port-mapper RPC program number, other than the official number. This is useful when running multiple @i{Amd} processes. For example, you can run another @i{Amd} in ``test'' mode, without affecting the primary @i{Amd} process in any way. For safety reasons, the alternate program numbers that can be specified must be in the range 300019-300029, inclusive. @i{Amq} has an option @code{-P} which can be used to specify an alternate program number of an @i{Amd} to contact. In this way, amq can fully control any number of @i{Amd} processes running on the same host. @c ---------------------------------------------------------------- @node preferred_amq_port Parameter, print_pid Parameter, portmap_program Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{preferred_amq_port} Parameter @cindex preferred_amq_port Parameter (type=numeric, default=0). Specify an alternate Port-mapper RPC port number for @i{Amd}'s @i{Amq} service. This is used for both UDP and TCP. Setting this value to 0 (or not defining it) will cause @i{Amd} to select an arbitrary port number. Setting the @i{Amq} RPC service port to a specific number is useful in firewalled or NAT'ed environments, where you need to know which port @i{Amd} will listen on. @c ---------------------------------------------------------------- @node print_pid Parameter, print_version Parameter, preferred_amq_port Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{print_pid} Parameter @cindex print_pid Parameter (type=boolean, default=@samp{no}). Same as the @code{-p} option to @i{Amd}. If @samp{yes}, @i{Amd} will print its process ID upon starting. @c ---------------------------------------------------------------- @node print_version Parameter, restart_mounts Parameter, print_pid Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{print_version} Parameter @cindex print_version Parameter (type=boolean, default=@samp{no}). Same as the @code{-v} option to @i{Amd}, but the version prints and @i{Amd} continues to run. If @samp{yes}, @i{Amd} will print its version information string, which includes some configuration and compilation values. @c ---------------------------------------------------------------- @node restart_mounts Parameter, show_statfs_entries Parameter, print_version Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{restart_mounts} Parameter @cindex restart_mounts Parameter (type=boolean, default=@samp{no}). Same as the @code{-r} option to @i{Amd}. If @samp{yes} @i{Amd} will scan the mount table to determine which file systems are currently mounted. Whenever one of these would have been auto-mounted, @i{Amd} inherits it. @c ---------------------------------------------------------------- @node show_statfs_entries Parameter, truncate_log Parameter, restart_mounts Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{show_statfs_entries} Parameter @cindex show_statfs_entries Parameter (type=boolean), default=@samp{no}). If @samp{yes}, then all maps which are browsable will also show the number of entries (keys) they have when @b{df}(1) runs. (This is accomplished by returning non-zero values to the @b{statfs}(2) system call). @c ---------------------------------------------------------------- @node truncate_log Parameter, unmount_on_exit Parameter, show_statfs_entries Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{truncate_log} Parameter @cindex truncate_log Parameter (type=boolean), default=@samp{no}). If @samp{yes}, then @i{Amd} will truncate the log file (if it's a regular file) on startup. This could be useful when conducting extensive testing on @i{Amd} maps (or @i{Amd} itself) and you don't want to see log data from a previous run in the same file. @c ---------------------------------------------------------------- @node unmount_on_exit Parameter, use_tcpwrappers Parameter, truncate_log Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{unmount_on_exit} Parameter @cindex unmount_on_exit Parameter (type=boolean, default=@samp{no}). If @samp{yes}, then @i{Amd} will attempt to unmount all file systems which it knows about. Normally it leaves all (esp. NFS) mounted file systems intact. Note that @i{Amd} does not know about file systems mounted before it starts up, unless the @samp{restart_mounts} option is used (@pxref{restart_mounts Parameter}). @c ---------------------------------------------------------------- @node use_tcpwrappers Parameter, vendor Parameter, unmount_on_exit Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{use_tcpwrappers} Parameter @cindex use_tcpwrappers Parameter (type=boolean), default=@samp{yes}). If @samp{yes}, then amd will use the tcpwrappers (tcpd/librwap) library (if available) to control access to @i{Amd} via the @code{/etc/hosts.allow} and @code{/etc/hosts.deny} files. @i{Amd} will verify that the host running @i{Amq} is authorized to connect. The @code{amd} service name must used in the @code{/etc/hosts.allow} and @code{/etc/hosts.deny} files. For example, to allow only localhost to connect to @i{Amd}, add this line to @code{/etc/hosts.allow}: @example amd: localhost @end example and this line to @code{/etc/hosts.deny}: @example amd: ALL @end example Consult the man pages for @b{hosts_access}(5) for more information on using the tcpwrappers access-control library. Note that in particular, you should not configure your @code{hosts.allow} file to spawn a command for @i{Amd}: that will cause @i{Amd} to not be able to @code{waitpid} on the child process ID of any background un/mount that @i{Amd} issued, resulting in a confused @i{Amd} that does not know what happened to those background un/mount requests. @c ---------------------------------------------------------------- @node vendor Parameter, , use_tcpwrappers Parameter, Global Parameters @comment node-name, next, previous, up @subsection @t{vendor} Parameter @cindex vendor Parameter (type=string, default to compiled in value). The name of the vendor of the operating system. Overrides the compiled-in vendor name. Useful when the compiled-in name is not desired. For example, most Intel based systems set the vendor name to @samp{unknown}, but you can set it to @samp{redhat}. @c ================================================================ @node Regular Map Parameters, amd.conf Examples, Global Parameters, Amd Configuration File @comment node-name, next, previous, up @section Regular Map Parameters @cindex amd.conf regular map parameters The following parameters are applicable only to regular map sections. @menu * map_name Parameter:: * tag Parameter:: @end menu @c ---------------------------------------------------------------- @node map_name Parameter, tag Parameter, Regular Map Parameters, Regular Map Parameters @comment node-name, next, previous, up @subsection map_name Parameter @cindex map_name Parameter (type=string, must be specified). Name of the map where the keys are located. @c ---------------------------------------------------------------- @node tag Parameter, , map_name Parameter, Regular Map Parameters @comment node-name, next, previous, up @subsection tag Parameter @cindex tag Parameter (type=string, default no tag). Each map entry in the configuration file can be tagged. If no tag is specified, that map section will always be processed by @i{Amd}. If it is specified, then @i{Amd} will process the map if the @code{-T} option was given to @i{Amd}, and the value given to that command-line option matches that in the map section. @c ================================================================ @node amd.conf Examples, , Regular Map Parameters, Amd Configuration File @comment node-name, next, previous, up @section amd.conf Examples @cindex amd.conf examples The following is the actual @code{amd.conf} file I used at the Computer Science Department of Columbia University. @example # GLOBAL OPTIONS SECTION [ global ] normalize_hostnames = no print_pid = no #pid_file = /var/run/amd.pid restart_mounts = yes #unmount_on_exit = yes auto_dir = /n log_file = /var/log/amd log_options = all #debug_options = defaults plock = no selectors_in_defaults = yes # config.guess picks up "sunos5" and I don't want to edit my maps yet os = sos5 # if you print_version after setting up "os", it will show it. print_version = no map_type = file search_path = /etc/amdmaps:/usr/lib/amd:/usr/local/AMD/lib browsable_dirs = yes fully_qualified_hosts = no # DEFINE AN AMD MOUNT POINT [ /u ] map_name = amd.u [ /proj ] map_name = amd.proj [ /src ] map_name = amd.src [ /misc ] map_name = amd.misc [ /import ] map_name = amd.import [ /tftpboot/.amd ] tag = tftpboot map_name = amd.tftpboot @end example @c ################################################################ @node Run-time Administration, FSinfo, Amd Configuration File, Top @comment node-name, next, previous, up @chapter Run-time Administration @cindex Run-time administration @cindex Amq command @menu * Starting Amd:: * Stopping Amd:: * Restarting Amd:: * Controlling Amd:: @end menu @node Starting Amd, Stopping Amd, Run-time Administration, Run-time Administration @comment node-name, next, previous, up @section Starting @i{Amd} @cindex Starting Amd @cindex Additions to /etc/rc.local @cindex /etc/rc.local additions @cindex ctl-amd @i{Amd} is best started from @samp{/etc/rc.local} on BSD systems, or from the appropriate start-level script in @samp{/etc/init.d} on System V systems. @example if [ -f /usr/local/sbin/ctl-amd ]; then /usr/local/sbin/ctl-amd start; (echo -n ' amd') > /dev/console fi @end example @noindent The shell script, @samp{ctl-amd} is used to start, stop, or restart @i{Amd}. It is a relatively generic script. All options you want to set should not be made in this script, but rather updated in the @file{amd.conf} file. @xref{Amd Configuration File}. If you do not wish to use an @i{Amd} configuration file, you may start @i{Amd} manually. For example, getting the map entries via NIS: @example amd -r -l /var/log/amd `ypcat -k auto.master` @end example @node Stopping Amd, Restarting Amd, Starting Amd, Run-time Administration @comment node-name, next, previous, up @section Stopping @i{Amd} @cindex Stopping Amd @cindex SIGTERM signal @cindex SIGINT signal @i{Amd} stops in response to two signals. @table @samp @item SIGTERM causes the top-level automount points to be unmounted and then @i{Amd} to exit. Any automounted filesystems are left mounted. They can be recovered by restarting @i{Amd} with the @code{-r} command line option.@refill @item SIGINT causes @i{Amd} to attempt to unmount any filesystems which it has automounted, in addition to the actions of @samp{SIGTERM}. This signal is primarily used for debugging.@refill @end table Actions taken for other signals are undefined. The easiest and safest way to stop @i{Amd}, without having to find its process ID by hand, is to use the @file{ctl-amd} script, as with: @example ctl-amd stop @end example @node Restarting Amd, Controlling Amd, Stopping Amd, Run-time Administration @comment node-name, next, previous, up @section Restarting @i{Amd} @cindex Restarting Amd @cindex Killing and starting Amd Before @i{Amd} can be started, it is vital to ensure that no other @i{Amd} processes are managing any of the mount points, and that the previous process(es) have terminated cleanly. When a terminating signal is set to @i{Amd}, the automounter does @emph{not} terminate right then. Rather, it starts by unmounting all of its managed mount mounts in the background, and then terminates. It usually takes a few seconds for this process to happen, but it can take an arbitrarily longer time. If two or more @i{Amd} processes attempt to manage the same mount point, it usually will result in a system lockup. The easiest and safest way to restart @i{Amd}, without having to find its process ID by hand, sending it the @samp{SIGTERM} signal, waiting for @i{Amd} to die cleanly, and verifying so, is to use the @file{ctl-amd} script, as with: @example ctl-amd restart @end example The script will locate the process ID of @i{Amd}, kill it, and wait for it to die cleanly before starting a new instance of the automounter. @file{ctl-amd} will wait for a total of 30 seconds for @i{Amd} to die, and will check once every 5 seconds if it had. @node Controlling Amd, , Restarting Amd, Run-time Administration @comment node-name, next, previous, up @section Controlling @i{Amd} @cindex Controlling Amd @cindex Discovering what is going on at run-time @cindex Listing currently mounted filesystems It is sometimes desirable or necessary to exercise external control over some of @i{Amd}'s internal state. To support this requirement, @i{Amd} implements an RPC interface which is used by the @dfn{Amq} program. A variety of information is available. @i{Amq} generally applies an operation, specified by a single letter option, to a list of mount points. The default operation is to obtain statistics about each mount point. This is similar to the output shown above but includes information about the number and type of accesses to each mount point. @menu * Amq default:: Default command behavior. * Amq -f option:: Flushing the map cache. * Amq -h option:: Controlling a non-local host. * Amq -H option:: Print help message. * Amq -l option:: Controlling the log file. * Amq -m option:: Obtaining mount statistics. * Amq -p option:: Getting Amd's process ID. * Amq -P option:: Contacting alternate Amd processes. * Amq -q option:: Suppress synchronous unmounting errors. * Amq -s option:: Obtaining global statistics. * Amq -T option:: Use TCP transport. * Amq -U option:: Use UDP transport. * Amq -u option:: Forcing volumes to time out. * Amq -v option:: Version information. * Amq -w option:: Print Amd current working directory. * Other Amq options:: Three other special options. @end menu @c ---------------------------------------------------------------- @node Amq default, Amq -f option, Controlling Amd, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} default information With no arguments, @dfn{Amq} obtains a brief list of all existing mounts created by @i{Amd}. This is different from the list displayed by @b{df}(1) since the latter only includes system mount points. @noindent The output from this option includes the following information: @itemize @bullet @item the automount point, @item the filesystem type, @item the mount map or mount information, @item the internal, or system mount point. @end itemize @noindent For example: @example / root "root" sky:(pid75) /homes toplvl /usr/local/etc/amd.homes /homes /home toplvl /usr/local/etc/amd.home /home /homes/jsp nfs charm:/home/charm /a/charm/home/charm/jsp /homes/phjk nfs toytown:/home/toytown /a/toytown/home/toytown/ai/phjk @end example @noindent If an argument is given then statistics for that volume name will be output. For example: @example What Uid Getattr Lookup RdDir RdLnk Statfs Mounted@@ /homes 0 1196 512 22 0 30 90/09/14 12:32:55 /homes/jsp 0 0 0 0 1180 0 90/10/13 12:56:58 @end example @table @code @item What the volume name. @item Uid ignored. @item Getattr the count of NFS @dfn{getattr} requests on this node. This should only be non-zero for directory nodes. @item Lookup the count of NFS @dfn{lookup} requests on this node. This should only be non-zero for directory nodes. @item RdDir the count of NFS @dfn{readdir} requests on this node. This should only be non-zero for directory nodes. @item RdLnk the count of NFS @dfn{readlink} requests on this node. This should be zero for directory nodes. @item Statfs the count of NFS @dfn{statfs} requests on this node. This should only be non-zero for top-level automount points. @item Mounted@@ the date and time the volume name was first referenced. @end table @c ---------------------------------------------------------------- @node Amq -f option, Amq -h option, Amq default, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-f} option @cindex Flushing the map cache @cindex Map cache, flushing The @code{-f} option causes @i{Amd} to flush the internal mount map cache. This is useful for example in Hesiod maps since @i{Amd} will not automatically notice when they have been updated. The map cache can also be synchronized with the map source by using the @samp{sync} option (@pxref{Automount Filesystem}).@refill @c ---------------------------------------------------------------- @node Amq -h option, Amq -H option, Amq -f option, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-h} option @cindex Querying an alternate host By default the local host is used. In an HP-UX cluster the root server is used since that is the only place in the cluster where @i{Amd} will be running. To query @i{Amd} on another host the @code{-h} option should be used. @c ---------------------------------------------------------------- @node Amq -H option, Amq -l option, Amq -h option, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-H} option @cindex Displaying brief help @cindex Help; showing from Amq Print a brief help and usage string. @c ---------------------------------------------------------------- @node Amq -l option, Amq -m option, Amq -H option, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-l} option @cindex Resetting the Amd log file @cindex Setting the Amd log file via Amq @cindex Log file, resetting Tell @i{Amd} to use @i{log_file} as the log file name. For security reasons, this @emph{must} be the same log file which @i{Amd} used when started. This option is therefore only useful to refresh @i{Amd}'s open file handle on the log file, so that it can be rotated and compressed via daily cron jobs. @c ---------------------------------------------------------------- @node Amq -m option, Amq -p option, Amq -l option, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-m} option The @code{-m} option displays similar information about mounted filesystems, rather than automount points. The output includes the following information: @itemize @bullet @item the mount information, @item the mount point, @item the filesystem type, @item the number of references to this filesystem, @item the server hostname, @item the state of the file server, @item any error which has occurred. @end itemize For example: @example "root" truth:(pid602) root 1 localhost is up hesiod.home /home toplvl 1 localhost is up hesiod.vol /vol toplvl 1 localhost is up hesiod.homes /homes toplvl 1 localhost is up amy:/home/amy /a/amy/home/amy nfs 5 amy is up swan:/home/swan /a/swan/home/swan nfs 0 swan is up (Permission denied) ex:/home/ex /a/ex/home/ex nfs 0 ex is down @end example When the reference count is zero the filesystem is not mounted but the mount point and server information is still being maintained by @i{Amd}. @c ---------------------------------------------------------------- @ignore @comment Retained for future consideration: from the description of the @comment amq -M option removed in amd 6.0.5. A future release of @i{Amd} will include code to allow the @b{mount}(8) command to mount automount points: @example mount -t amd /vol hesiod.vol @end example This will then allow @i{Amd} to be controlled from the standard system filesystem mount list. @end ignore @c ---------------------------------------------------------------- @node Amq -p option, Amq -P option, Amq -m option, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-p} option @cindex Process ID; Amd @cindex Amd's process ID @cindex Amd's PID @cindex PID; Amd Return the process ID of the remote or locally running @i{Amd}. Useful when you need to send a signal to the local @i{Amd} process, and would rather not have to search through the process table. This option is used in the @file{ctl-amd} script. @c ---------------------------------------------------------------- @node Amq -P option, Amq -q option, Amq -p option, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-P} option @cindex Multiple Amd processes @cindex Running multiple Amd @cindex Debugging a new Amd configuration @cindex RPC Program numbers; Amd Contact an alternate running @i{Amd} that had registered itself on a different RPC @var{program_number} and apply all other operations to that instance of the automounter. This is useful when you run multiple copies of @i{Amd}, and need to manage each one separately. If not specified, @i{Amq} will use the default program number for @i{Amd}, 300019. For security reasons, the only alternate program numbers @i{Amd} can use range from 300019 to 300029, inclusive. For example, to kill an alternate running @i{Amd}: @example kill `amq -p -P 300020` @end example @c ---------------------------------------------------------------- @node Amq -q option, Amq -s option, Amq -P option, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-q} option @cindex Unmounting a filesystem Suppress any error messages produced when a synchronous unmount fails. See @ref{Amq -u option}. @c ---------------------------------------------------------------- @node Amq -s option, Amq -T option, Amq -q option, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-s} option @cindex Global statistics @cindex Statistics The @code{-s} option displays global statistics. If any other options are specified or any filesystems named then this option is ignored. For example: @example requests stale mount mount unmount deferred fhandles ok failed failed 1054 1 487 290 7017 @end example @table @samp @item Deferred requests are those for which an immediate reply could not be constructed. For example, this would happen if a background mount was required. @item Stale filehandles counts the number of times the kernel passes a stale filehandle to @i{Amd}. Large numbers indicate problems. @item Mount ok counts the number of automounts which were successful. @item Mount failed counts the number of automounts which failed. @item Unmount failed counts the number of times a filesystem could not be unmounted. Very large numbers here indicate that the time between unmount attempts should be increased. @end table @c ---------------------------------------------------------------- @node Amq -T option, Amq -U option, Amq -s option, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-T} option @cindex Forcing Amq to use a TCP transport @cindex TCP; using with Amq The @code{-T} option causes the @i{Amq} to contact @i{Amd} using the TCP transport only (connection oriented). Normally, @i{Amq} will use TCP first, and if that failed, will try UDP. @c ---------------------------------------------------------------- @node Amq -U option, Amq -u option, Amq -T option, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-U} option @cindex Forcing Amq to use a UDP transport @cindex UDP; using with Amq The @code{-U} option causes the @i{Amq} to contact @i{Amd} using the UDP transport only (connectionless). Normally, @i{Amq} will use TCP first, and if that failed, will try UDP. @c ---------------------------------------------------------------- @node Amq -u option, Amq -v option, Amq -U option, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-u} option @cindex Forcing filesystem to time out @cindex Unmounting a filesystem The @code{-u} option causes the time-to-live interval of the named mount points to be expired, thus causing an unmount attempt. This is the only safe way to unmount an automounted filesystem. If @code{-u} is repeated, then @i{Amd} will attempt to unmount the filesystem synchronously. This makes things like @example amq -uu /t/cd0d && eject cd0 @end example @noindent work as expected. Any error messages this might produce can be suppressed with the @code{-q} option. See @ref{Amq -q option}. @c The @code{-H} option informs @i{Amd} that the specified mount point @c has hung - as if its keepalive timer had expired. @c ---------------------------------------------------------------- @node Amq -v option, Amq -w option, Amq -u option, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-v} option @cindex Version information at run-time The @code{-v} option displays the version of @i{Amd} in a similar way to @i{Amd}'s @code{-v} option. @c ---------------------------------------------------------------- @node Amq -w option, Other Amq options, Amq -v option, Controlling Amd @comment node-name, next, previous, up @subsection @i{Amq} @code{-w} option @cindex Getting real working directory The @code{-w} option translates a full pathname as returned by @b{getpwd}(3) into a short @i{Amd} pathname that goes through its mount points. This option requires that @i{Amd} is running. @c ---------------------------------------------------------------- @node Other Amq options, , Amq -w option, Controlling Amd @comment node-name, next, previous, up @subsection Other @i{Amq} options @cindex Logging options via Amq @cindex Debugging options via Amq Two other operations are implemented. These modify the state of @i{Amd} as a whole, rather than any particular filesystem. The @code{-x} and @code{-D} options have exactly the same effect as @i{Amd}'s corresponding command line options. When @i{Amd} receives the @code{-x} flag, it disallows turning off the @samp{fatal} or @samp{error} flags. Both are on by default. They are mandatory so that @i{Amd} could report important errors, including errors relating to turning flags on/off. @c ################################################################ @node FSinfo, Hlfsd, Run-time Administration, Top @comment node-name, next, previous, up @chapter FSinfo @cindex FSinfo @cindex Filesystem info package XXX: this chapter should be reviewed by someone knowledgeable with fsinfo. @menu * FSinfo Overview:: Introduction to FSinfo. * Using FSinfo:: Basic concepts. * FSinfo Grammar:: Language syntax, semantics and examples. * FSinfo host definitions:: Defining a new host. * FSinfo host attributes:: Definable host attributes. * FSinfo filesystems:: Defining locally attached filesystems. * FSinfo static mounts:: Defining additional static mounts. * FSinfo automount definitions:: * FSinfo Command Line Options:: * FSinfo errors:: @end menu @node FSinfo Overview, Using FSinfo, FSinfo, FSinfo @comment node-name, next, previous, up @section @i{FSinfo} overview @cindex FSinfo overview @i{FSinfo} is a filesystem management tool. It has been designed to work with @i{Amd} to help system administrators keep track of the ever increasing filesystem namespace under their control. The purpose of @i{FSinfo} is to generate all the important standard filesystem data files from a single set of input data. Starting with a single data source guarantees that all the generated files are self-consistent. One of the possible output data formats is a set of @i{Amd} maps which can be used among the set of hosts described in the input data. @i{FSinfo} implements a declarative language. This language is specifically designed for describing filesystem namespace and physical layouts. The basic declaration defines a mounted filesystem including its device name, mount point, and all the volumes and access permissions. @i{FSinfo} reads this information and builds an internal map of the entire network of hosts. Using this map, many different data formats can be produced including @file{/etc/fstab}, @file{/etc/exports}, @i{Amd} mount maps and @file{/etc/bootparams}.@refill @node Using FSinfo, FSinfo Grammar, FSinfo Overview, FSinfo @comment node-name, next, previous, up @section Using @i{FSinfo} @cindex Using FSinfo The basic strategy when using @i{FSinfo} is to gather all the information about all disks on all machines into one set of declarations. For each machine being managed, the following data is required: @itemize @bullet @item Hostname @item List of all filesystems and, optionally, their mount points. @item Names of volumes stored on each filesystem. @item NFS export information for each volume. @item The list of static filesystem mounts. @end itemize The following information can also be entered into the same configuration files so that all data can be kept in one place. @itemize @bullet @item List of network interfaces @item IP address of each interface @item Hardware address of each interface @item Dumpset to which each filesystem belongs @item and more @dots{} @end itemize To generate @i{Amd} mount maps, the automount tree must also be defined (@pxref{FSinfo automount definitions}). This will have been designed at the time the volume names were allocated. Some volume names will not be automounted, so @i{FSinfo} needs an explicit list of which volumes should be automounted.@refill Hostnames are required at several places in the @i{FSinfo} language. It is important to stick to either fully qualified names or unqualified names. Using a mixture of the two will inevitably result in confusion. Sometimes volumes need to be referenced which are not defined in the set of hosts being managed with @i{FSinfo}. The required action is to add a dummy set of definitions for the host and volume names required. Since the files generated for those particular hosts will not be used on them, the exact values used is not critical. @node FSinfo Grammar, FSinfo host definitions, Using FSinfo, FSinfo @comment node-name, next, previous, up @section @i{FSinfo} grammar @cindex FSinfo grammar @cindex Grammar, FSinfo @i{FSinfo} has a relatively simple grammar. Distinct syntactic constructs exist for each of the different types of data, though they share a common flavor. Several conventions are used in the grammar fragments below. The notation, @i{list(}@t{xxx}@i{)}, indicates a list of zero or more @t{xxx}'s. The notation, @i{opt(}@t{xxx}@i{)}, indicates zero or one @t{xxx}. Items in double quotes, @i{eg} @t{"host"}, represent input tokens. Items in angle brackets, @i{eg} @var{}, represent strings in the input. Strings need not be in double quotes, except to differentiate them from reserved words. Quoted strings may include the usual set of C ``@t{\}'' escape sequences with one exception: a backslash-newline-whitespace sequence is squashed into a single space character. To defeat this feature, put a further backslash at the start of the second line. At the outermost level of the grammar, the input consists of a sequence of host and automount declarations. These declarations are all parsed before they are analyzed. This means they can appear in any order and cyclic host references are possible. @example fsinfo : @i{list(}fsinfo_attr@i{)} ; fsinfo_attr : host | automount ; @end example @menu * FSinfo host definitions:: * FSinfo automount definitions:: @end menu @node FSinfo host definitions, FSinfo host attributes, FSinfo Grammar, FSinfo @comment node-name, next, previous, up @section @i{FSinfo} host definitions @cindex FSinfo host definitions @cindex Defining a host, FSinfo A host declaration consists of three parts: a set of machine attribute data, a list of filesystems physically attached to the machine, and a list of additional statically mounted filesystems. @example host : "host" host_data @i{list(}filesystem@i{@i{)}} @i{list(}mount@i{@i{)}} ; @end example Each host must be declared in this way exactly once. Such things as the hardware address, the architecture and operating system types and the cluster name are all specified within the @dfn{host data}. All the disks the machine has should then be described in the @dfn{list of filesystems}. When describing disks, you can specify what @dfn{volname} the disk/partition should have and all such entries are built up into a dictionary which can then be used for building the automounter maps. The @dfn{list of mounts} specifies all the filesystems that should be statically mounted on the machine. @menu * FSinfo host attributes:: * FSinfo filesystems:: * FSinfo static mounts:: @end menu @node FSinfo host attributes, FSinfo filesystems, FSinfo host definitions , FSinfo host definitions @comment node-name, next, previous, up @section @i{FSinfo} host attributes @cindex FSinfo host attributes @cindex Defining host attributes, FSinfo The host data, @dfn{host_data}, always includes the @dfn{hostname}. In addition, several other host attributes can be given. @example host_data : @var{} | "@{" @i{list(}host_attrs@i{)} "@}" @var{} ; host_attrs : host_attr "=" @var{} | netif ; host_attr : "config" | "arch" | "os" | "cluster" ; @end example The @dfn{hostname} is, typically, the fully qualified hostname of the machine. Examples: @example host dylan.doc.ic.ac.uk host @{ os = hpux arch = hp300 @} dougal.doc.ic.ac.uk @end example The options that can be given as host attributes are shown below. @menu * FSinfo netif Option:: FSinfo host netif. * FSinfo config Option:: FSinfo host config. * FSinfo arch Option:: FSinfo host arch. * FSinfo os Option:: FSinfo host os. * FSinfo cluster Option:: FSinfo host cluster. @end menu @node FSinfo netif Option, FSinfo config Option, , FSinfo host attributes @comment node-name, next, previous, up @subsection netif Option This defines the set of network interfaces configured on the machine. The interface attributes collected by @i{FSinfo} are the IP address, subnet mask and hardware address. Multiple interfaces may be defined for hosts with several interfaces by an entry for each interface. The values given are sanity checked, but are currently unused for anything else. @example netif : "netif" @var{} "@{" @i{list(}netif_attrs@i{)} "@}" ; netif_attrs : netif_attr "=" @var{} ; netif_attr : "inaddr" | "netmask" | "hwaddr" ; @end example Examples: @example netif ie0 @{ inaddr = 129.31.81.37 netmask = 0xfffffe00 hwaddr = "08:00:20:01:a6:a5" @} netif ec0 @{ @} @end example @node FSinfo config Option, FSinfo arch Option, FSinfo netif Option, FSinfo host attributes @comment node-name, next, previous, up @subsection config Option @cindex FSinfo config host attribute @cindex config, FSinfo host attribute This option allows you to specify configuration variables for the startup scripts (@file{rc} scripts). A simple string should immediately follow the keyword. Example: @example config "NFS_SERVER=true" config "ZEPHYR=true" @end example This option is currently unsupported. @node FSinfo arch Option, FSinfo os Option, FSinfo config Option, FSinfo host attributes @comment node-name, next, previous, up @subsection arch Option @cindex FSinfo arch host attribute @cindex arch, FSinfo host attribute This defines the architecture of the machine. For example: @example arch = hp300 @end example This is intended to be of use when building architecture specific mountmaps, however, the option is currently unsupported. @node FSinfo os Option, FSinfo cluster Option, FSinfo arch Option, FSinfo host attributes @comment node-name, next, previous, up @subsection os Option @cindex FSinfo os host attribute @cindex os, FSinfo host attribute This defines the operating system type of the host. For example: @example os = hpux @end example This information is used when creating the @file{fstab} files, for example in choosing which format to use for the @file{fstab} entries within the file. @node FSinfo cluster Option, , FSinfo os Option, FSinfo host attributes @comment node-name, next, previous, up @subsection cluster Option @cindex FSinfo cluster host attribute @cindex cluster, FSinfo host attribute This is used for specifying in which cluster the machine belongs. For example: @example cluster = "theory" @end example The cluster is intended to be used when generating the automount maps, although it is currently unsupported. @node FSinfo filesystems, FSinfo static mounts, FSinfo host attributes, FSinfo host definitions @comment node-name, next, previous, up @section @i{FSinfo} filesystems @cindex FSinfo filesystems The list of physically attached filesystems follows the machine attributes. These should define all the filesystems available from this machine, whether exported or not. In addition to the device name, filesystems have several attributes, such as filesystem type, mount options, and @samp{fsck} pass number which are needed to generate @file{fstab} entries. @example filesystem : "fs" @var{} "@{" @i{list(}fs_data@i{)} "@}" ; fs_data : fs_data_attr "=" @var{} | mount ; fs_data_attr : "fstype" | "opts" | "passno" | "freq" | "dumpset" | "log" ; @end example Here, @var{} is the device name of the disk (for example, @file{/dev/dsk/2s0}). The device name is used for building the mount maps and for the @file{fstab} file. The attributes that can be specified are shown in the following section. The @i{FSinfo} configuration file for @code{dylan.doc.ic.ac.uk} is listed below. @example host dylan.doc.ic.ac.uk fs /dev/dsk/0s0 @{ fstype = swap @} fs /dev/dsk/0s0 @{ fstype = hfs opts = rw,noquota,grpid passno = 0; freq = 1; mount / @{ @} @} fs /dev/dsk/1s0 @{ fstype = hfs opts = defaults passno = 1; freq = 1; mount /usr @{ local @{ exportfs "dougal eden dylan zebedee brian" volname /nfs/hp300/local @} @} @} fs /dev/dsk/2s0 @{ fstype = hfs opts = defaults passno = 1; freq = 1; mount default @{ exportfs "toytown_clients hangers_on" volname /home/dylan/dk2 @} @} fs /dev/dsk/3s0 @{ fstype = hfs opts = defaults passno = 1; freq = 1; mount default @{ exportfs "toytown_clients hangers_on" volname /home/dylan/dk3 @} @} fs /dev/dsk/5s0 @{ fstype = hfs opts = defaults passno = 1; freq = 1; mount default @{ exportfs "toytown_clients hangers_on" volname /home/dylan/dk5 @} @} @end example @menu * FSinfo fstype Option:: FSinfo filesystems fstype. * FSinfo opts Option:: FSinfo filesystems opts. * FSinfo passno Option:: FSinfo filesystems passno. * FSinfo freq Option:: FSinfo filesystems freq. * FSinfo mount Option:: FSinfo filesystems mount. * FSinfo dumpset Option:: FSinfo filesystems dumpset. * FSinfo log Option:: FSinfo filesystems log. @end menu @node FSinfo fstype Option, FSinfo opts Option, , FSinfo filesystems @comment node-name, next, previous, up @subsection fstype Option @cindex FSinfo fstype filesystems option @cindex fstype, FSinfo filesystems option @cindex export, FSinfo special fstype This specifies the type of filesystem being declared and will be placed into the @file{fstab} file as is. The value of this option will be handed to @code{mount} as the filesystem type---it should have such values as @code{4.2}, @code{nfs} or @code{swap}. The value is not examined for correctness. There is one special case. If the filesystem type is specified as @samp{export} then the filesystem information will not be added to the host's @file{fstab} information, but it will still be visible on the network. This is useful for defining hosts which contain referenced volumes but which are not under full control of @i{FSinfo}. Example: @example fstype = swap @end example @node FSinfo opts Option, FSinfo passno Option, FSinfo fstype Option, FSinfo filesystems @comment node-name, next, previous, up @subsection opts Option @cindex FSinfo opts filesystems option @cindex opts, FSinfo filesystems option This defines any options that should be given to @b{mount}(8) in the @file{fstab} file. For example: @example opts = rw,nosuid,grpid @end example @node FSinfo passno Option, FSinfo freq Option, FSinfo opts Option, FSinfo filesystems @comment node-name, next, previous, up @subsection passno Option @cindex FSinfo passno filesystems option @cindex passno, FSinfo filesystems option This defines the @b{fsck}(8) pass number in which to check the filesystem. This value will be placed into the @file{fstab} file. Example: @example passno = 1 @end example @node FSinfo freq Option, FSinfo mount Option, FSinfo passno Option, FSinfo filesystems @comment node-name, next, previous, up @subsection freq Option @cindex FSinfo freq filesystems option @cindex freq, FSinfo filesystems option This defines the interval (in days) between dumps. The value is placed as is into the @file{fstab} file. Example: @example freq = 3 @end example @node FSinfo mount Option, FSinfo dumpset Option, FSinfo freq Option, FSinfo filesystems @comment node-name, next, previous, up @subsection mount Option @cindex FSinfo mount filesystems option @cindex mount, FSinfo filesystems option @cindex exportfs, FSinfo mount option @cindex volname, FSinfo mount option @cindex sel, FSinfo mount option This defines the mountpoint at which to place the filesystem. If the mountpoint of the filesystem is specified as @code{default}, then the filesystem will be mounted in the automounter's tree under its volume name and the mount will automatically be inherited by the automounter. Following the mountpoint, namespace information for the filesystem may be described. The options that can be given here are @code{exportfs}, @code{volname} and @code{sel}. The format is: @example mount : "mount" vol_tree ; vol_tree : @i{list(}vol_tree_attr@i{)} ; vol_tree_attr : @var{} "@{" @i{list(}vol_tree_info@i{)} vol_tree "@}" ; vol_tree_info : "exportfs" @var{} | "volname" @var{} | "sel" @var{} ; @end example Example: @example mount default @{ exportfs "dylan dougal florence zebedee" volname /vol/andrew @} @end example In the above example, the filesystem currently being declared will have an entry placed into the @file{exports} file allowing the filesystem to be exported to the machines @code{dylan}, @code{dougal}, @code{florence} and @code{zebedee}. The volume name by which the filesystem will be referred to remotely, is @file{/vol/andrew}. By declaring the mountpoint to be @code{default}, the filesystem will be mounted on the local machine in the automounter tree, where @i{Amd} will automatically inherit the mount as @file{/vol/andrew}.@refill @table @samp @item exportfs a string defining which machines the filesystem may be exported to. This is copied, as is, into the @file{exports} file---no sanity checking is performed on this string.@refill @item volname a string which declares the remote name by which to reference the filesystem. The string is entered into a dictionary and allows you to refer to this filesystem in other places by this volume name.@refill @item sel a string which is placed into the automounter maps as a selector for the filesystem.@refill @end table @node FSinfo dumpset Option, FSinfo log Option, FSinfo mount Option, FSinfo filesystems @comment node-name, next, previous, up @subsection dumpset Option @cindex FSinfo dumpset filesystems option @cindex dumpset, FSinfo filesystems option This provides support for Imperial College's local file backup tools and is not documented further here. @node FSinfo log Option, , FSinfo dumpset Option, FSinfo filesystems @comment node-name, next, previous, up @subsection log Option @cindex FSinfo log filesystems option @cindex log, FSinfo filesystems option Specifies the log device for the current filesystem. This is ignored if not required by the particular filesystem type. @node FSinfo static mounts, FSinfo automount definitions , FSinfo filesystems, FSinfo host definitions @comment node-name, next, previous, up @section @i{FSinfo} static mounts @cindex FSinfo static mounts @cindex Statically mounts filesystems, FSinfo Each host may also have a number of statically mounted filesystems. For example, the host may be a diskless workstation in which case it will have no @code{fs} declarations. In this case the @code{mount} declaration is used to determine from where its filesystems will be mounted. In addition to being added to the @file{fstab} file, this information can also be used to generate a suitable @file{bootparams} file.@refill @example mount : "mount" @var{} @i{list(}localinfo@i{)} ; localinfo : localinfo_attr @var{} ; localinfo_attr : "as" | "from" | "fstype" | "opts" ; @end example The filesystem specified to be mounted will be searched for in the dictionary of volume names built when scanning the list of hosts' definitions. The attributes have the following semantics: @table @samp @item from @var{machine} mount the filesystem from the machine with the hostname of @dfn{machine}.@refill @item as @var{mountpoint} mount the filesystem locally as the name given, in case this is different from the advertised volume name of the filesystem. @item opts @var{options} native @b{mount}(8) options. @item fstype @var{type} type of filesystem to be mounted. @end table An example: @example mount /export/exec/hp300/local as /usr/local @end example If the mountpoint specified is either @file{/} or @file{swap}, the machine will be considered to be booting off the net and this will be noted for use in generating a @file{bootparams} file for the host which owns the filesystems. @node FSinfo automount definitions, FSinfo Command Line Options, FSinfo static mounts, FSinfo @comment node-name, next, previous, up @section Defining an @i{Amd} Mount Map in @i{FSinfo} @cindex FSinfo automount definitions @cindex Defining an Amd mount map, FSinfo The maps used by @i{Amd} can be constructed from @i{FSinfo} by defining all the automount trees. @i{FSinfo} takes all the definitions found and builds one map for each top level tree. The automount tree is usually defined last. A single automount configuration will usually apply to an entire management domain. One @code{automount} declaration is needed for each @i{Amd} automount point. @i{FSinfo} determines whether the automount point is @dfn{direct} (@pxref{Direct Automount Filesystem}) or @dfn{indirect} (@pxref{Top-level Filesystem}). Direct automount points are distinguished by the fact that there is no underlying @dfn{automount_tree}.@refill @example automount : "automount" @i{opt(}auto_opts@i{)} automount_tree ; auto_opts : "opts" @var{} ; automount_tree : @i{list(}automount_attr@i{)} ; automount_attr : @var{} "=" @var{} | @var{} "->" @var{} | @var{} "@{" automount_tree "@}" ; @end example If @var{} is given, then it is the string to be placed in the maps for @i{Amd} for the @code{opts} option. A @dfn{map} is typically a tree of filesystems, for example @file{home} normally contains a tree of filesystems representing other machines in the network. A map can either be given as a name representing an already defined volume name, or it can be a tree. A tree is represented by placing braces after the name. For example, to define a tree @file{/vol}, the following map would be defined: @example automount /vol @{ @} @end example Within a tree, the only items that can appear are more maps. For example: @example automount /vol @{ andrew @{ @} X11 @{ @} @} @end example In this case, @i{FSinfo} will look for volumes named @file{/vol/andrew} and @file{/vol/X11} and a map entry will be generated for each. If the volumes are defined more than once, then @i{FSinfo} will generate a series of alternate entries for them in the maps.@refill Instead of a tree, either a link (@var{name} @code{->} @var{destination}) or a reference can be specified (@var{name} @code{=} @var{destination}). A link creates a symbolic link to the string specified, without further processing the entry. A reference will examine the destination filesystem and optimize the reference. For example, to create an entry for @code{njw} in the @file{/homes} map, either of the two forms can be used:@refill @example automount /homes @{ njw -> /home/dylan/njw @} @end example or @example automount /homes @{ njw = /home/dylan/njw @} @end example In the first example, when @file{/homes/njw} is referenced from @i{Amd}, a link will be created leading to @file{/home/dylan/njw} and the automounter will be referenced a second time to resolve this filename. The map entry would be: @example njw type:=link;fs:=/home/dylan/njw @end example In the second example, the destination directory is analyzed and found to be in the filesystem @file{/home/dylan} which has previously been defined in the maps. Hence the map entry will look like: @example njw rhost:=dylan;rfs:=/home/dylan;sublink:=njw @end example Creating only one symbolic link, and one access to @i{Amd}. @node FSinfo Command Line Options, FSinfo errors, FSinfo automount definitions, FSinfo @comment node-name, next, previous, up @section @i{FSinfo} Command Line Options @cindex FSinfo command line options @cindex Command line options, FSinfo @i{FSinfo} is started from the command line by using the command: @example fsinfo [@i{options}] @i{files} ... @end example The input to @i{FSinfo} is a single set of definitions of machines and automount maps. If multiple files are given on the command-line, then the files are concatenated together to form the input source. The files are passed individually through the C pre-processor before being parsed. Several options define a prefix for the name of an output file. If the prefix is not specified no output of that type is produced. The suffix used will correspond either to the hostname to which a file belongs, or to the type of output if only one file is produced. Dumpsets and the @file{bootparams} file are in the latter class. To put the output into a subdirectory simply put a @file{/} at the end of the prefix, making sure that the directory has already been made before running @i{Fsinfo}. @menu * -a FSinfo Option:: Amd automount directory: * -b FSinfo Option:: Prefix for bootparams files. * -d FSinfo Option:: Prefix for dumpset data files. * -e FSinfo Option:: Prefix for exports files. * -f FSinfo Option:: Prefix for fstab files. * -h FSinfo Option:: Local hostname. * -m FSinfo Option:: Prefix for automount maps. * -q FSinfo Option:: Ultra quiet mode. * -v FSinfo Option:: Verbose mode. * -I FSinfo Option:: Define new #include directory. * -D-FSinfo Option:: Define macro. * -U FSinfo Option:: Undefine macro. @end menu @node -a FSinfo Option, -b FSinfo Option, FSinfo Command Line Options, FSinfo Command Line Options @comment node-name, next, previous, up @subsection @code{-a} @var{autodir} Specifies the directory name in which to place the automounter's mountpoints. This defaults to @file{/a}. Some sites have the autodir set to be @file{/amd}, and this would be achieved by: @example fsinfo -a /amd ... @end example @node -b FSinfo Option, -d FSinfo Option, -a FSinfo Option, FSinfo Command Line Options @comment node-name, next, previous, up @subsection @code{-b} @var{bootparams} @cindex bootparams, FSinfo prefix This specifies the prefix for the @file{bootparams} filename. If it is not given, then the file will not be generated. The @file{bootparams} file will be constructed for the destination machine and will be placed into a file named @file{bootparams} and prefixed by this string. The file generated contains a list of entries describing each diskless client that can boot from the destination machine. As an example, to create a @file{bootparams} file in the directory @file{generic}, the following would be used: @example fsinfo -b generic/ ... @end example @node -d FSinfo Option, -e FSinfo Option, -b FSinfo Option, FSinfo Command Line Options @comment node-name, next, previous, up @subsection @code{-d} @var{dumpsets} @cindex dumpset, FSinfo prefix This specifies the prefix for the @file{dumpsets} file. If it is not specified, then the file will not be generated. The file will be for the destination machine and will be placed into a filename @file{dumpsets}, prefixed by this string. The @file{dumpsets} file is for use by Imperial College's local backup system. For example, to create a @file{dumpsets} file in the directory @file{generic}, then you would use the following: @example fsinfo -d generic/ ... @end example @node -e FSinfo Option, -f FSinfo Option, -d FSinfo Option, FSinfo Command Line Options @comment node-name, next, previous, up @subsection @code{-e} @var{exportfs} @cindex exports, FSinfo prefix Defines the prefix for the @file{exports} files. If it is not given, then the file will not be generated. For each machine defined in the configuration files as having disks, an @file{exports} file is constructed and given a filename determined by the name of the machine, prefixed with this string. If a machine is defined as diskless, then no @file{exports} file will be created for it. The files contain entries for directories on the machine that may be exported to clients. Example: To create the @file{exports} files for each diskfull machine and place them into the directory @file{exports}: @example fsinfo -e exports/ ... @end example @node -f FSinfo Option, -h FSinfo Option, -e FSinfo Option, FSinfo Command Line Options @comment node-name, next, previous, up @subsection @code{-f} @var{fstab} @cindex fstab, FSinfo prefix This defines the prefix for the @file{fstab} files. The files will only be created if this prefix is defined. For each machine defined in the configuration files, a @file{fstab} file is created with the filename determined by prefixing this string with the name of the machine. These files contain entries for filesystems and partitions to mount at boot time. Example, to create the files in the directory @file{fstabs}: @example fsinfo -f fstabs/ ... @end example @node -h FSinfo Option, -m FSinfo Option, -f FSinfo Option, FSinfo Command Line Options @comment node-name, next, previous, up @subsection @code{-h} @var{hostname} @cindex hostname, FSinfo command line option Defines the hostname of the destination machine to process for. If this is not specified, it defaults to the local machine name, as returned by @b{gethostname}(2). Example: @example fsinfo -h dylan.doc.ic.ac.uk ... @end example @node -m FSinfo Option, -q FSinfo Option, -h FSinfo Option, FSinfo Command Line Options @comment node-name, next, previous, up @subsection @code{-m} @var{mount-maps} @cindex maps, FSinfo command line option Defines the prefix for the automounter files. The maps will only be produced if this prefix is defined. The mount maps suitable for the network defined by the configuration files will be placed into files with names calculated by prefixing this string to the name of each map. For example, to create the automounter maps and place them in the directory @file{automaps}: @example fsinfo -m automaps/ ... @end example @node -q FSinfo Option, -v FSinfo Option, -m FSinfo Option, FSinfo Command Line Options @comment node-name, next, previous, up @subsection @code{-q} @cindex quiet, FSinfo command line option Selects quiet mode. @i{FSinfo} suppress the ``running commentary'' and only outputs any error messages which are generated. @node -v FSinfo Option, -D-FSinfo Option, -q FSinfo Option, FSinfo Command Line Options @comment node-name, next, previous, up @subsection @code{-v} @cindex verbose, FSinfo command line option Selects verbose mode. When this is activated, the program will display more messages, and display all the information discovered when performing the semantic analysis phase. Each verbose message is output to @file{stdout} on a line starting with a @samp{#} character. @node -D-FSinfo Option, -I FSinfo Option, -v FSinfo Option, FSinfo Command Line Options @comment node-name, next, previous, up @subsection @code{-D} @var{name}@i{[=defn]} Defines a symbol @dfn{name} for the preprocessor when reading the configuration files. Equivalent to @code{#define} directive. @node -I FSinfo Option, -U FSinfo Option, -D-FSinfo Option, FSinfo Command Line Options @comment node-name, next, previous, up @subsection @code{-I} @var{directory} This option is passed into the preprocessor for the configuration files. It specifies directories in which to find include files @node -U FSinfo Option, , -I FSinfo Option, FSinfo Command Line Options @comment node-name, next, previous, up @subsection @code{-U} @var{name} Removes any initial definition of the symbol @dfn{name}. Inverse of the @code{-D} option. @node FSinfo errors, , FSinfo Command Line Options, FSinfo @comment node-name, next, previous, up @section Errors produced by @i{FSinfo} @cindex FSinfo error messages The following table documents the errors and warnings which @i{FSinfo} may produce. @table @t @item " expected Occurs if an unescaped newline is found in a quoted string. @item ambiguous mount: @var{volume} is a replicated filesystem If several filesystems are declared as having the same volume name, they will be considered replicated filesystems. To mount a replicated filesystem statically, a specific host will need to be named, to say which particular copy to try and mount, else this error will result. @item can't open @var{filename} for writing Occurs if any errors are encountered when opening an output file. @item cannot determine localname since volname @var{volume} is not uniquely defined If a volume is replicated and an attempt is made to mount the filesystem statically without specifying a local mountpoint, @i{FSinfo} cannot calculate a mountpoint, as the desired pathname would be ambiguous. @item @var{device} has duplicate exportfs data Produced if the @samp{exportfs} option is used multiple times within the same branch of a filesystem definition. For example, if you attempt to set the @samp{exportfs} data at different levels of the mountpoint directory tree. @item dump frequency for @var{host}:@var{device} is non-zero Occurs if @var{device} has its @samp{fstype} declared to be @samp{swap} or @samp{export} and the @samp{dump} option is set to a value greater than zero. Swap devices should not be dumped. @item duplicate host @var{hostname}! If a host has more than one definition. @item end of file within comment A comment was unterminated before the end of one of the configuration files. @item @var{filename}: cannot open for reading If a file specified on the command line as containing configuration data could not be opened. @item @var{filesystem} has a volname but no exportfs data Occurs when a volume name is declared for a file system, but the string specifying what machines the filesystem can be exported to is missing. @item fs field "@var{field-name}" already set Occurs when multiple definitions are given for one of the attributes of a host's filesystem. @item host field "@var{field-name}" already set If duplicate definitions are given for any of the fields with a host definition. @item @var{host}:@var{device} has more than one mount point Occurs if the mount option for a host's filesystem specifies multiple trees at which to place the mountpoint. @item @var{host}:@var{device} has no mount point Occurs if the @samp{mount} option is not specified for a host's filesystem. @item @var{host}:@var{device} needs field "@var{field-name}" Occurs when a filesystem is missing a required field. @var{field-name} could be one of @samp{fstype}, @samp{opts}, @samp{passno} or @samp{mount}. @item @var{host}:mount field specified for swap partition Occurs if a mountpoint is given for a filesystem whose type is declared to be @samp{swap}. @item malformed IP dotted quad: @var{address} If the Internet address of an interface is incorrectly specified. An Internet address definition is handled to @b{inet_addr}(3N) to see if it can cope. If not, then this message will be displayed. @item malformed netmask: @var{netmask} If the netmask cannot be decoded as though it were a hexadecimal number, then this message will be displayed. It will typically be caused by incorrect characters in the @var{netmask} value. @item mount field "@var{field-name}" already set Occurs when a static mount has multiple definitions of the same field. @item mount tree field "@var{field-name}" already set Occurs when the @var{field-name} is defined more than once during the definition of a filesystems mountpoint. @item netif field @var{field-name} already set Occurs if you attempt to define an attribute of an interface more than once. @item network booting requires both root and swap areas Occurs if a machine has mount declarations for either the root partition or the swap area, but not both. You cannot define a machine to only partially boot via the network. @item no disk mounts on @var{hostname} If there are no static mounts, nor local disk mounts specified for a machine, this message will be displayed. @item no volname given for @var{host}:@var{device} Occurs when a filesystem is defined to be mounted on @file{default}, but no volume name is given for the file system, then the mountpoint cannot be determined. @item not allowed '/' in a directory name Occurs when a pathname with multiple directory elements is specified as the name for an automounter tree. A tree should only have one name at each level. @item pass number for @var{host}:@var{device} is non-zero Occurs if @var{device} has its @samp{fstype} declared to be @samp{swap} or @samp{export} and the @b{fsck}(8) pass number is set. Swap devices should not be fsck'd. @xref{FSinfo fstype Option}. @item sub-directory @var{directory} of @var{directory-tree} starts with '/' Within the filesystem specification for a host, if an element @var{directory} of the mountpoint begins with a @samp{/} and it is not the start of the tree. @item sub-directory of @var{directory-tree} is named "default" @samp{default} is a keyword used to specify if a mountpoint should be automatically calculated by @i{FSinfo}. If you attempt to specify a directory name as this, it will use the filename of @file{default} but will produce this warning. @item unknown \ sequence Occurs if an unknown escape sequence is found inside a string. Within a string, you can give the standard C escape sequences for strings, such as newlines and tab characters. @item unknown directory attribute If an unknown keyword is found while reading the definition of a host's filesystem mount option. @item unknown filesystem attribute Occurs if an unrecognized keyword is used when defining a host's filesystems. @item unknown host attribute Occurs if an unrecognized keyword is used when defining a host. @item unknown mount attribute Occurs if an unrecognized keyword is found while parsing the list of static mounts. @item unknown volname @var{volume} automounted @i{[} on @i{name} @i{]} Occurs if @var{volume} is used in a definition of an automount map but the volume name has not been declared during the host filesystem definitions. @item volname @var{volume} is unknown Occurs if an attempt is made to mount or reference a volume name which has not been declared during the host filesystem definitions. @item volname @var{volume} not exported from @var{machine} Occurs if you attempt to mount the volume @var{volume} from a machine which has not declared itself to have such a filesystem available. @end table @c ################################################################ @node Hlfsd, Assorted Tools, FSinfo, Top @comment node-name, next, previous, up @chapter Hlfsd @pindex Hlfsd @cindex Home-Link Filesystem @i{Hlfsd} is a daemon which implements a filesystem containing a symbolic link to subdirectory within a user's home directory, depending on the user which accessed that link. It was primarily designed to redirect incoming mail to users' home directories, so that it can be read from anywhere. It was designed and implemented by @uref{http://www.cs.sunysb.edu/~ezk,Erez Zadok} and @email{dupuy AT cs.columbia.edu,Alexander Dupuy}, at the @uref{http://www.cs.columbia.edu/,Computer Science Department} of @uref{http://www.columbia.edu/,Columbia University}. A @uref{http://www.fsl.cs.sunysb.edu/docs/hlfsd/hlfsd.html,paper} on @i{Hlfsd} was presented at the Usenix LISA VII conference in 1993. @i{Hlfsd} operates by mounting itself as an NFS server for the directory containing @i{linkname}, which defaults to @file{/hlfs/home}. Lookups within that directory are handled by @i{Hlfsd}, which uses the password map to determine how to resolve the lookup. The directory will be created if it doesn't already exist. The symbolic link will be to the accessing user's home directory, with @i{subdir} appended to it. If not specified, @i{subdir} defaults to @file{.hlfsdir}. This directory will also be created if it does not already exist. A @samp{SIGTERM} sent to @i{Hlfsd} will cause it to shutdown. A @samp{SIGHUP} will flush the internal caches, and reload the password map. It will also close and reopen the log file, to enable the original log file to be removed or rotated. A @samp{SIGUSR1} will cause it to dump its internal table of user IDs and home directories to the file @file{/tmp/hlfsddump}. @menu * Introduction to Hlfsd:: * Background to Mail Delivery:: * Using Hlfsd:: @end menu @c ================================================================ @node Introduction to Hlfsd, Background to Mail Delivery, Hlfsd, Hlfsd @comment node-name, next, previous, up @section Introduction to Hlfsd @cindex Introduction to Hlfsd @cindex Hlfsd; introduction Electronic mail has become one of the major applications for many computer networks, and use of this service is expected to increase over time, as networks proliferate and become faster. Providing a convenient environment for users to read, compose, and send electronic mail has become a requirement for systems administrators (SAs). Widely used methods for handling mail usually require users to be logged into a designated ``home'' machine, where their mailbox files reside. Only on that one machine can they read newly arrived mail. Since users have to be logged into that system to read their mail, they often find it convenient to run all of their other processes on that system as well, including memory and CPU-intensive jobs. For example, in our department, we have allocated and configured several multi-processor servers to handle such demanding CPU/memory applications, but these were underutilized, in large part due to the inconvenience of not being able to read mail on those machines. (No home directories were located on these designated CPU-servers, since we did not want NFS service for users' home directories to have to compete with CPU-intensive jobs. At the same time, we discouraged users from running demanding applications on their home machines.) Many different solutions have been proposed to allow users to read their mail on any host. However, all of these solutions fail in one or more of several ways: @itemize @bullet @item they introduce new single points of failure @item they require using different mail transfer agents (MTAs) or user agents (UAs) @item they do not solve the problem for all cases, i.e. the solution is only partially successful for a particular environment. @end itemize We have designed a simple filesystem, called the @dfn{Home-Link File System}, to provide the ability to deliver mail to users' home directories, without modification to mail-related applications. We have endeavored to make it as stable as possible. Of great importance to us was to make sure the HLFS daemon, @file{hlfsd} , would not hang under any circumstances, and would take the next-best action when faced with problems. Compared to alternative methods, @i{Hlfsd} is a stable, more general solution, and easier to install/use. In fact, in some ways, we have even managed to improve the reliability and security of mail service. Our server implements a small filesystem containing a symbolic link to a subdirectory of the invoking user's home directory, and named symbolic links to users' mailbox files. The @i{Hlfsd} server finds out the @var{uid} of the process that is accessing its mount point, and resolves the pathname component @samp{home} as a symbolic link to a subdirectory within the home directory given by the @var{uid}'s entry in the password file. If the @var{gid} of the process that attempts to access a mailbox file is a special one (called HLFS_GID), then the server maps the name of the @emph{next} pathname component directly to the user's mailbox. This is necessary so that access to a mailbox file by users other than the owner can succeed. The server has safety features in case of failures such as hung filesystems or home directory filesystems that are inaccessible or full. On most of our machines, mail gets delivered to the directory @file{/var/spool/mail}. Many programs, including UAs, depend on that path. @i{Hlfsd} creates a directory @file{/mail}, and mounts itself on top of that directory. @i{Hlfsd} implements the path name component called @samp{home}, pointing to a subdirectory of the user's home directory. We have made @file{/var/spool/mail} a symbolic link to @file{/mail/home}, so that accessing @file{/var/spool/mail} actually causes access to a subdirectory within a user's home directory. The following table shows an example of how resolving the pathname @file{/var/mail/@i{NAME}} to @file{/users/ezk/.mailspool/@i{NAME}} proceeds. @multitable {Resolving Component} {Pathname left to resolve} {Value if symbolic link} @item @b{Resolving Component} @tab @b{Pathname left to resolve} @tab @b{Value if symbolic link} @item @t{/} @tab @t{var/mail/}@i{NAME} @item @t{var/} @tab @t{mail/}@i{NAME} @item @t{mail}@@ @tab @t{/mail/home/}@i{NAME} @tab @t{mail}@@ -> @t{/mail/home} @item @t{/} @tab @t{mail/home/}@i{NAME} @item @t{mail/} @tab @t{home/}@i{NAME} @item @t{home}@@ @tab @i{NAME} @tab @t{home}@@ -> @t{/users/ezk/.mailspool} @item @t{/} @tab @t{users/ezk/.mailspool/}@i{NAME} @item @t{users/} @tab @t{ezk/.mailspool/}@i{NAME} @item @t{ezk/} @tab @t{.mailspool/}@i{NAME} @item @t{.mailspool/} @tab @i{NAME} @item @i{NAME} @end multitable @c ================================================================ @node Background to Mail Delivery, Using Hlfsd, Introduction to Hlfsd, Hlfsd @comment node-name, next, previous, up @section Background to Mail Delivery @cindex Background to Mail Delivery @cindex Hlfsd; background This section provides an in-depth discussion of why available methods for delivering mail to home directories are not as good as the one used by @i{Hlfsd}. @menu * Single-Host Mail Spool Directory:: * Centralized Mail Spool Directory:: * Distributed Mail Spool Service:: * Why Deliver Into the Home Directory?:: @end menu @c ---------------------------------------------------------------- @node Single-Host Mail Spool Directory, Centralized Mail Spool Directory, Background to Mail Delivery, Background to Mail Delivery @comment node-name, next, previous, up @subsection Single-Host Mail Spool Directory @cindex Single-Host Mail Spool Directory The most common method for mail delivery is for mail to be appended to a mailbox file in a standard spool directory on the designated ``mail home'' machine of the user. The greatest advantage of this method is that it is the default method most vendors provide with their systems, thus very little (if any) configuration is required on the SA's part. All they need to set up are mail aliases directing mail to the host on which the user's mailbox file is assigned. (Otherwise, mail is delivered locally, and users find mailboxes on many machines.) As users become more sophisticated, and aided by windowing systems, they find themselves logging in on multiple hosts at once, performing several tasks concurrently. They ask to be able to read their mail on any host on the network, not just the one designated as their ``mail home''. @c ---------------------------------------------------------------- @node Centralized Mail Spool Directory, Distributed Mail Spool Service, Single-Host Mail Spool Directory, Background to Mail Delivery @comment node-name, next, previous, up @subsection Centralized Mail Spool Directory @cindex Centralized Mail Spool Directory A popular method for providing mail readability from any host is to have all mail delivered to a mail spool directory on a designated ``mail-server'' which is exported via NFS to all of the hosts on the network. Configuring such a system is relatively easy. On most systems, the bulk of the work is a one-time addition to one or two configuration files in @file{/etc}. The file-server's spool directory is then hard-mounted across every machine on the local network. In small environments with only a handful of hosts this can be an acceptable solution. In our department, with a couple of hundred active hosts and thousands of mail messages processed daily, this was deemed completely unacceptable, as it introduced several types of problems: @table @b @item Scalability and Performance As more and more machines get added to the network, more mail traffic has to go over NFS to and from the mail-server. Users like to run mail-watchers, and read their mail often. The stress on the shared infrastructure increases with every user and host added; loads on the mail server would most certainly be high since all mail delivery goes through that one machine.@footnote{ Delivery via NFS-mounted filesystems may require usage of @samp{rpc.lockd} and @samp{rpc.statd} to provide distributed file-locking, both of which are widely regarded as unstable and unreliable. Furthermore, this will degrade performance, as local processes as well as remote @samp{nfsd} processes are kept busy.} This leads to lower reliability and performance. To reduce the number of concurrent connections between clients and the server host, some SAs have resorted to automounting the mail-spool directory. But this solution only makes things worse: since users often run mail watchers, and many popular applications such as @samp{trn}, @samp{emacs}, @samp{csh} or @samp{ksh} check periodically for new mail, the automounted directory would be effectively permanently mounted. If it gets unmounted automatically by the automounter program, it is most likely to get mounted shortly afterwards, consuming more I/O resources by the constant cycle of mount and umount calls. @item Reliability The mail-server host and its network connectivity must be very reliable. Worse, since the spool directory has to be hard-mounted,@footnote{No SA in their right minds would soft-mount read/write partitions --- the chances for data loss are too great.} many processes which access the spool directory (various shells, @samp{login}, @samp{emacs}, etc.) would be hung as long as connectivity to the mail-server is severed. To improve reliability, SAs may choose to backup the mail-server's spool partition several times a day. This may make things worse since reading or delivering mail while backups are in progress may cause backups to be inconsistent; more backups consume more backup-media resources, and increase the load on the mail-server host. @end table @c ---------------------------------------------------------------- @node Distributed Mail Spool Service, Why Deliver Into the Home Directory?, Centralized Mail Spool Directory, Background to Mail Delivery @comment node-name, next, previous, up @subsection Distributed Mail Spool Service @cindex Distributed Mail Spool Service Despite the existence of a few systems that support delivery to users' home directories, mail delivery to home directories hasn't caught on. We believe the main reason is that there are too many programs that ``know'' where mailbox files reside. Besides the obvious (the delivery program @file{/bin/mail} and mail readers like @file{/usr/ucb/Mail}, @samp{mush}, @samp{mm}, etc.), other programs that know mailbox location are login, from, almost every shell, @samp{xbiff}, @samp{xmailbox}, and even some programs not directly related to mail, such as @samp{emacs} and @samp{trn}. Although some of these programs can be configured to look in different directories with the use of environment variables and other resources, many of them cannot. The overall porting work is significant. Other methods that have yet to catch on require the use of a special mail-reading server, such as IMAP or POP. The main disadvantage of these systems is that UAs need to be modified to use these services --- a long and involved task. That is why they are not popular at this time. Several other ideas have been proposed and even used in various environments. None of them is robust. They are mostly very specialized, inflexible, and do not extend to the general case. Some of the ideas are plain bad, potentially leading to lost or corrupt mail: @table @b @item automounters Using an automounter such as @i{Amd} to provide a set of symbolic links from the normal spool directory to user home directories is not sufficient. UAs rename, unlink, and recreate the mailbox as a regular file, therefore it must be a real file, not a symbolic link. Furthermore, it must reside in a real directory which is writable by the UAs and MTAs. This method may also require populating @file{/var/spool/mail} with symbolic links and making sure they are updated. Making @i{Amd} manage that directory directly fails, since many various lock files need to be managed as well. Also, @i{Amd} does not provide all of the NFS operations which are required to write mail such as write, create, remove, and unlink. @item @code{$MAIL} Setting this variable to an automounted directory pointing to the user's mail spool host only solves the problem for those programs which know and use @code{$MAIL}. Many programs don't, therefore this solution is partial and of limited flexibility. Also, it requires the SAs or the users to set it themselves --- an added level of inconvenience and possible failures. @item @t{/bin/mail} Using a different mail delivery agent could be the solution. One such example is @samp{hdmail}. However, @samp{hdmail} still requires modifying all UAs, the MTA's configuration, installing new daemons, and changing login scripts. This makes the system less upgradable or compatible with others, and adds one more complicated system for SAs to deal with. It is not a complete solution because it still requires each user have their @code{$MAIL} variable setup correctly, and that every program use this variable. @end table @c ---------------------------------------------------------------- @node Why Deliver Into the Home Directory?, , Distributed Mail Spool Service, Background to Mail Delivery @comment node-name, next, previous, up @subsection Why Deliver Into the Home Directory? @cindex Why Deliver Into the Home Directory? @cindex Hlfsd; Why Deliver Into the Home Directory? There are several major reasons why SAs might want to deliver mail directly into the users' home directories: @table @b @item Location Many mail readers need to move mail from the spool directory to the user's home directory. It speeds up this operation if the two are on the same filesystem. If for some reason the user's home directory is inaccessible, it isn't that useful to be able to read mail, since there is no place to move it to. In some cases, trying to move mail to a non-existent or hung filesystem may result in mail loss. @item Distribution Having all mail spool directories spread among the many more filesystems minimizes the chances that complete environments will grind to a halt when a single server is down. It does increase the chance that there will be someone who is not able to read their mail when a machine is down, but that is usually preferred to having no one be able to read their mail because a centralized mail server is down. The problem of losing some mail due to the (presumably) higher chances that a user's machine is down is minimized in HLFS. @item Security Delivering mail to users' home directories has another advantage --- enhanced security and privacy. Since a shared system mail spool directory has to be world-readable and searchable, any user can see whether other users have mail, when they last received new mail, or when they last read their mail. Programs such as @samp{finger} display this information, which some consider an infringement of privacy. While it is possible to disable this feature of @samp{finger} so that remote users cannot see a mailbox file's status, this doesn't prevent local users from getting the information. Furthermore, there are more programs which make use of this information. In shared environments, disabling such programs has to be done on a system-wide basis, but with mail delivered to users' home directories, users less concerned with privacy who do want to let others know when they last received or read mail can easily do so using file protection bits. @c Lastly, on systems that do not export their NFS filesystem with @c @t{anon=0}, superusers are less likely to snoop around others' mail, as @c they become ``nobodies'' across NFS. @end table In summary, delivering mail to home directories provides users the functionality sought, and also avoids most of the problems just discussed. @c ================================================================ @node Using Hlfsd, , Background to Mail Delivery, Hlfsd @comment node-name, next, previous, up @section Using Hlfsd @cindex Using Hlfsd @cindex Hlfsd; using @menu * Controlling Hlfsd:: * Hlfsd Options:: * Hlfsd Files:: @end menu @c ---------------------------------------------------------------- @node Controlling Hlfsd, Hlfsd Options, Using Hlfsd, Using Hlfsd @comment node-name, next, previous, up @subsection Controlling Hlfsd @cindex Controlling Hlfsd @cindex Hlfsd; controlling @pindex ctl-hlfsd Much the same way @i{Amd} is controlled by @file{ctl-amd}, so does @i{Hlfsd} get controlled by the @file{ctl-hlfsd} script: @table @t @item ctl-hlfsd start Start a new @i{Hlfsd}. @item ctl-hlfsd stop Stop a running @i{Hlfsd}. @item ctl-hlfsd restart Stop a running @i{Hlfsd}, wait for 10 seconds, and then start a new one. It is hoped that within 10 seconds, the previously running @i{Hlfsd} terminate properly; otherwise, starting a second one could cause system lockup. @end table For example, on our systems, we start @i{Hlfsd} within @file{ctl-hlfsd} as follows on Solaris 2 systems: @example hlfsd -a /var/alt_mail -x all -l /var/log/hlfsd /mail/home .mailspool @end example The directory @file{/var/alt_mail} is a directory in the root partition where alternate mail will be delivered into, when it cannot be delivered into the user's home directory. Normal mail gets delivered into @file{/var/mail}, but on our systems, that is a symbolic link to @file{/mail/home}. @file{/mail} is managed by @i{Hlfsd}, which creates a dynamic symlink named @samp{home}, pointing to the subdirectory @file{.mailspool} @emph{within} the accessing user's home directory. This results in mail which normally should go to @file{/var/mail/@code{$USER}}, to go to @file{@code{$HOME}/.mailspool/@code{$USER}}. @i{Hlfsd} does not create the @file{/var/mail} symlink. This needs to be created (manually) once on each host, by the system administrators, as follows: @example mv /var/mail /var/alt_mail ln -s /mail/home /var/mail @end example @i{Hlfsd} also responds to the following signals: A @samp{SIGHUP} signal sent to @i{Hlfsd} will force it to reload the password map immediately. A @samp{SIGUSR1} signal sent to @i{Hlfsd} will cause it to dump its internal password map to the file @file{/usr/tmp/hlfsd.dump.XXXXXX}, where @samp{XXXXXX} will be replaced by a random string generated by @b{mktemp}(3) or (the more secure) @b{mkstemp}(3). @c ---------------------------------------------------------------- @node Hlfsd Options, Hlfsd Files, Controlling Hlfsd, Using Hlfsd @comment node-name, next, previous, up @subsection Hlfsd Options @cindex Hlfsd Options @cindex Hlfsd; Options @table @t @item -a @var{alt_dir} Alternate directory. The name of the directory to which the symbolic link returned by @i{Hlfsd} will point, if it cannot access the home directory of the user. This defaults to @file{/var/hlfs}. This directory will be created if it doesn't exist. It is expected that either users will read these files, or the system administrators will run a script to resend this ``lost mail'' to its owner. @item -c @var{cache-interval} Caching interval. @i{Hlfsd} will cache the validity of home directories for this interval, in seconds. Entries which have been verified within the last @var{cache-interval} seconds will not be verified again, since the operation could be expensive, and the entries are most likely still valid. After the interval has expired, @i{Hlfsd} will re-verify the validity of the user's home directory, and reset the cache time-counter. The default value for @var{cache-interval} is 300 seconds (5 minutes). @item -f Force fast startup. This option tells @i{Hlfsd} to skip startup-time consistency checks such as existence of mount directory, alternate spool directory, symlink to be hidden under the mount directory, their permissions and validity. @item -g @var{group} Set the special group HLFS_GID to @var{group}. Programs such as @file{/usr/ucb/from} or @file{/usr/sbin/in.comsat}, which access the mailboxes of other users, must be setgid @samp{HLFS_GID} to work properly. The default group is @samp{hlfs}. If no group is provided, and there is no group @samp{hlfs}, this feature is disabled. @item -h Help. Print a brief help message, and exit. @item -i @var{reload-interval} Map-reloading interval. Each @var{reload-interval} seconds, @i{Hlfsd} will reload the password map. @i{Hlfsd} needs the password map for the UIDs and home directory pathnames. @i{Hlfsd} schedules a @samp{SIGALRM} to reload the password maps. A @samp{SIGHUP} sent to @i{Hlfsd} will force it to reload the maps immediately. The default value for @var{reload-interval} is 900 seconds (15 minutes.) @item -l @var{logfile} Specify a log file to which @i{Hlfsd} will record events. If @var{logfile} is the string @samp{syslog} then the log messages will be sent to the system log daemon by @b{syslog}(3), using the @samp{LOG_DAEMON} facility. This is also the default. @item -n No verify. @i{Hlfsd} will not verify the validity of the symbolic link it will be returning, or that the user's home directory contains sufficient disk-space for spooling. This can speed up @i{Hlfsd} at the cost of possibly returning symbolic links to home directories which are not currently accessible or are full. By default, @i{Hlfsd} validates the symbolic-link in the background. The @code{-n} option overrides the meaning of the @code{-c} option, since no caching is necessary. @item -o @var{mount-options} Mount options which @i{Hlfsd} will use to mount itself on top of @var{dirname}. By default, @var{mount-options} is set to @samp{ro}. If the system supports symbolic-link caching, default options are set to @samp{ro,nocache}. @item -p Print PID. Outputs the process-id of @i{Hlfsd} to standard output where it can be saved into a file. @item -v Version. Displays version information to standard error. @item -x @var{log-options} Specify run-time logging options. The options are a comma separated list chosen from: @samp{fatal}, @samp{error}, @samp{user}, @samp{warn}, @samp{info}, @samp{map}, @samp{stats}, @samp{all}. @item -C Force @i{Hlfsd} to run on systems that cannot turn off the NFS attribute-cache. Use of this option on those systems is discouraged, as it may result in loss or misdelivery of mail. The option is ignored on systems that can turn off the attribute-cache. @item -D @var{log-options} Select from a variety of debugging options. Prefixing an option with the string @samp{no} reverses the effect of that option. Options are cumulative. The most useful option is @samp{all}. Since this option is only used for debugging other options are not documented here. A fuller description is available in the program source. @item -P @var{password-file} Read the user-name, user-id, and home directory information from the file @var{password-file}. Normally, @i{Hlfsd} will use @b{getpwent}(3) to read the password database. This option allows you to override the default database, and is useful if you want to map users' mail files to a directory other than their home directory. Only the username, uid, and home-directory fields of the file @var{password-file} are read and checked. All other fields are ignored. The file @var{password-file} must otherwise be compliant with Unix Version 7 colon-delimited format @b{passwd}(4). @end table @c ---------------------------------------------------------------- @node Hlfsd Files, , Hlfsd Options, Using Hlfsd @comment node-name, next, previous, up @subsection Hlfsd Files @cindex Hlfsd Files @cindex Hlfsd; Files The following files are used by @i{Hlfsd}: @table @file @item /hlfs directory under which @i{Hlfsd} mounts itself and manages the symbolic link @file{home}. @item .hlfsdir default sub-directory in the user's home directory, to which the @file{home} symbolic link returned by @i{Hlfsd} points. @item /var/hlfs directory to which @file{home} symbolic link returned by @i{Hlfsd} points if it is unable to verify the that user's home directory is accessible. @item /usr/tmp/hlfsd.dump.XXXXXX file to which @i{Hlfsd} will dump its internal password map when it receives the @samp{SIGUSR1} signal. @samp{XXXXXX} will be replaced by a random string generated by @b{mktemp}(3) or (the more secure) @b{mkstemp}(3). @end table For discussion on other files used by @i{Hlfsd}, see @xref{lostaltmail}, and @ref{lostaltmail.conf-sample}. @c ################################################################ @node Assorted Tools, Examples, Hlfsd, Top @comment node-name, next, previous, up @chapter Assorted Tools @cindex Assorted Tools The following are additional utilities and scripts included with am-utils, and get installed. @menu * am-eject:: * amd.conf-sample:: * amd2ldif:: * amd2sun:: * automount2amd:: * ctl-amd:: * ctl-hlfsd:: * expn:: * fix-amd-map:: * fixmount:: * fixrmtab:: * lostaltmail:: * lostaltmail.conf-sample:: * mk-amd-map:: * pawd:: * redhat-ctl-amd:: * wait4amd:: * wait4amd2die:: * wire-test:: @end menu @c ---------------------------------------------------------------- @node am-eject, amd.conf-sample, Assorted Tools, Assorted Tools @comment node-name, next, previous, up @section am-eject @pindex am-eject A shell script unmounts a floppy or CD-ROM that is automounted, and then attempts to eject the removable device. @c ---------------------------------------------------------------- @node amd.conf-sample, amd2ldif, am-eject, Assorted Tools @comment node-name, next, previous, up @section amd.conf-sample @pindex amd.conf-sample A sample @i{Amd} configuration file. @xref{Amd Configuration File}. @c ---------------------------------------------------------------- @node amd2ldif, amd2sun, amd.conf-sample, Assorted Tools @comment node-name, next, previous, up @section amd2ldif @pindex amd2ldif A script to convert @i{Amd} maps to LDAP input files. Use it as follows: @example amd2ldif @i{mapname} @i{base} < @i{amd.mapfile} > @i{mapfile.ldif} @end example @c ---------------------------------------------------------------- @node amd2sun, automount2amd, amd2ldif, Assorted Tools @comment node-name, next, previous, up @section amd2sun @pindex amd2sun A script to convert @i{Amd} maps to Sun Automounter maps. Use it as follows @example amd2sun < @i{amd.mapfile} > @i{auto_mapfile} @end example @c ---------------------------------------------------------------- @node automount2amd, ctl-amd, amd2sun, Assorted Tools @comment node-name, next, previous, up @section automount2amd @pindex automount2amd A script to convert old Sun Automounter maps to @i{Amd} maps. Say you have the Sun automount file @i{auto.foo}, with these two lines: @example home earth:/home moon -ro,intr server:/proj/images @end example Running @example automount2amd auto.foo > amd.foo @end example will produce the @i{Amd} map @i{amd.foo} with this content: @example # generated by automount2amd on Sat Aug 14 17:59:32 US/Eastern 1999 /defaults \\ type:=nfs;opts:=rw,grpid,nosuid,utimeout=600 home \ host==earth;type:=link;fs:=/home \\ rhost:=earth;rfs:=/home moon \ -addopts:=ro,intr \\ host==server;type:=link;fs:=/proj/images \\ rhost:=server;rfs:=/proj/images @end example This perl script will use the following @i{/default} entry @example type:=nfs;opts:=rw,grpid,nosuid,utimeout=600 @end example If you wish to override that, define the @b{$DEFAULTS} environment variable, or modify the script. If you wish to generate Amd maps using the @i{hostd} (@pxref{hostd Selector Variable}) @i{Amd} map syntax, then define the environment variable @b{$DOMAIN} or modify the script. Note that automount2amd does not understand the syntax in newer Sun Automount maps, those used with autofs. @c ---------------------------------------------------------------- @node ctl-amd, ctl-hlfsd, automount2amd, Assorted Tools @comment node-name, next, previous, up @section ctl-amd @pindex ctl-amd A script to start, stop, or restart @i{Amd}. Use it as follows: @table @t @item ctl-amd start Start a new @i{Amd} process. @item ctl-amd stop Stop the running @i{Amd}. @item ctl-amd restart Stop the running @i{Amd} (if any), safely wait for it to terminate, and then start a new process --- only if the previous one died cleanly. @end table @xref{Run-time Administration}, for more details. @c ---------------------------------------------------------------- @node ctl-hlfsd, expn, ctl-amd, Assorted Tools @comment node-name, next, previous, up @section ctl-hlfsd @pindex ctl-hlfsd A script for controlling @i{Hlfsd}, much the same way @file{ctl-amd} controls @i{Amd}. Use it as follows: @table @t @item ctl-hlfsd start Start a new @i{Hlfsd} process. @item ctl-hlfsd stop Stop the running @i{Hlfsd}. @item ctl-hlfsd restart Stop the running @i{Hlfsd} (if any), wait for 10 seconds for it to terminate, and then start a new process --- only if the previous one died cleanly. @end table @xref{Hlfsd}, for more details. @c ---------------------------------------------------------------- @node expn, fix-amd-map, ctl-hlfsd, Assorted Tools @comment node-name, next, previous, up @section expn @pindex expn A script to expand email addresses into their full name. It is generally useful when using with the @file{lostaltmail} script, but is a useful tools otherwise. @example $ expn -v ezk@@example.com ezk@@example.com -> ezk@@shekel.example.com ezk@@shekel.example.com -> Erez Zadok <"| /usr/local/mh/lib/slocal -user ezk || exit 75> Erez Zadok <\ezk> Erez Zadok @end example @c ---------------------------------------------------------------- @node fix-amd-map, fixmount, expn, Assorted Tools @comment node-name, next, previous, up @section fix-amd-map @pindex fix-amd-map Am-utils changed some of the syntax and default values of some variables. For example, the default value for @samp{$@{os@}} for Solaris 2.x (aka SunOS 5.x) systems used to be @samp{sos5}, it is now more automatically generated from @file{config.guess} and its value is @samp{sunos5}. This script converts older @i{Amd} maps to new ones. Use it as follows: @example fix-amd-map < @i{old.map} > @i{new.map} @end example @c ---------------------------------------------------------------- @node fixmount, fixrmtab, fix-amd-map, Assorted Tools @comment node-name, next, previous, up @section fixmount @pindex fixmount @samp{fixmount} is a variant of @b{showmount}(8) that can delete bogus mount entries in remote @b{mountd}(8) daemons. This is useful to cleanup otherwise ever-accumulating ``junk''. Use it for example: @example fixmount -r @i{host} @end example See the online manual page for @samp{fixmount} for more details of its usage. @c ---------------------------------------------------------------- @node fixrmtab, lostaltmail, fixmount, Assorted Tools @comment node-name, next, previous, up @section fixrmtab @pindex fixrmtab A script to invalidate @file{/etc/rmtab} entries for hosts named. Also restart mountd for changes to take effect. Use it for example: @example fixrmtab @i{host1} @i{host2} @i{...} @end example @c ---------------------------------------------------------------- @node lostaltmail, lostaltmail.conf-sample, fixrmtab, Assorted Tools @comment node-name, next, previous, up @section lostaltmail @pindex lostaltmail A script used with @i{Hlfsd} to resend any ``lost'' mail. @i{Hlfsd} redirects mail which cannot be written into the user's home directory to an alternate directory. This is useful to continue delivering mail, even if the user's file system was unavailable, full, or over quota. But, the mail which gets delivered to the alternate directory needs to be resent to its respective users. This is what the @samp{lostaltmail} script does. Use it as follows: @example lostaltmail @end example This script needs a configuration file @samp{lostaltmail.conf} set up with the right parameters to properly work. @xref{Hlfsd}, for more details. @c ---------------------------------------------------------------- @node lostaltmail.conf-sample, mk-amd-map, lostaltmail, Assorted Tools @comment node-name, next, previous, up @section lostaltmail.conf-sample @pindex lostaltmail.conf-sample @cindex lostaltmail; configuration file This is a text file with configuration parameters needed for the @samp{lostaltmail} script. The script includes comments explaining each of the configuration variables. See it for more information. Also @pxref{Hlfsd} for general information. @c ---------------------------------------------------------------- @node mk-amd-map, pawd, lostaltmail.conf-sample, Assorted Tools @comment node-name, next, previous, up @section mk-amd-map @pindex mk-amd-map This program converts a normal @i{Amd} map file into an ndbm database with the same prefix as the named file. Use it as follows: @example mk-amd-map @i{mapname} @end example @c ---------------------------------------------------------------- @node pawd, redhat-ctl-amd, mk-amd-map, Assorted Tools @comment node-name, next, previous, up @section pawd @pindex pawd @i{Pawd} is used to print the current working directory, adjusted to reflect proper paths that can be reused to go through the automounter for the shortest possible path. In particular, the path printed back does not include any of @i{Amd}'s local mount points. Using them is unsafe, because @i{Amd} may unmount managed file systems from the mount points, and thus including them in paths may not always find the files within. Without any arguments, @i{Pawd} will print the automounter adjusted current working directory. With any number of arguments, it will print the adjusted path of each one of the arguments. @c ---------------------------------------------------------------- @node redhat-ctl-amd, wait4amd, pawd, Assorted Tools @comment node-name, next, previous, up @section redhat-ctl-amd @pindex redhat-ctl-amd This script is similar to @i{ctl-amd} (@pxref{ctl-amd}) but is intended for Red Hat Linux systems. You can safely copy @i{redhat-ctl-amd} onto @file{/etc/rc.d/init.d/amd}. The script supplied by @i{Am-utils} is usually better than the one provided by Red Hat, because the Red Hat script does not correctly kill @i{Amd} processes: it is too quick to kill the wrong processes, leaving stale or hung mount points behind. @c ---------------------------------------------------------------- @node wait4amd, wait4amd2die, redhat-ctl-amd, Assorted Tools @comment node-name, next, previous, up @section wait4amd @pindex wait4amd A script to wait for @i{Amd} to start on a particular host before performing an arbitrary command. The command is executed repeatedly, with 1 second intervals in between. You may interrupt the script using @samp{^C} (or whatever keyboard sequence your terminal's @samp{intr} function is bound to). Examples: @table @t @item wait4amd saturn amq -p -h saturn When @i{Amd} is up on host @samp{saturn}, get the process ID of that running @i{Amd}. @item wait4amd pluto rlogin pluto Remote login to host @samp{pluto} when @i{Amd} is up on that host. It is generally necessary to wait for @i{Amd} to properly start and initialize on a remote host before logging in to it, because otherwise user home directories may not be accessible across the network. @item wait4amd pluto A short-hand version of the previous command, since the most useful reason for this script is to login to a remote host. I use it very often when testing out new versions of @i{Amd}, and need to reboot hung hosts. @end table @c ---------------------------------------------------------------- @node wait4amd2die, wire-test, wait4amd, Assorted Tools @comment node-name, next, previous, up @section wait4amd2die @pindex wait4amd2die This script is used internally by @samp{ctl-amd} when used to restart @i{Amd}. It waits for @i{Amd} to terminate. If it detected that @i{Amd} terminated cleanly, this script will return an exist status of zero. Otherwise, it will return a non-zero exit status. The script tests for @i{Amd}'s existence once every 5 seconds, six times, for a total of 30 seconds. It will return a zero exist status as soon as it detects that @i{Amd} dies. @c ---------------------------------------------------------------- @node wire-test, , wait4amd2die, Assorted Tools @comment node-name, next, previous, up @section wire-test @pindex wire-test A simple program to test if some of the most basic networking functions in am-util's library @file{libamu} work. It also tests the combination of NFS protocol and version number that are supported from the current host, to a remote one. For example, in this test a machine which only supports NFS Version 2 is contacting a remote host that can support the same version, but using both UDP and TCP. If no host name is specified, @samp{wire-test} will try @file{localhost}. @example $ wire-test moisil Network name is "mcl-lab-net.cs.columbia.edu" Network number is "128.59.13" Network name is "old-net.cs.columbia.edu" Network number is "128.59.16" My IP address is 0x7f000001. NFS Version and protocol tests to host "moisil"... testing vers=2, proto="udp" -> found version 2. testing vers=3, proto="udp" -> failed! testing vers=2, proto="tcp" -> found version 2. testing vers=3, proto="tcp" -> failed! @end example @c ################################################################ @node Examples, Internals, Assorted Tools, Top @comment node-name, next, previous, up @chapter Examples @menu * User Filesystems:: * Home Directories:: * Architecture Sharing:: * Wildcard Names:: * rwho servers:: * /vol:: * /defaults with selectors:: * /tftpboot in a chroot-ed environment:: @end menu @node User Filesystems, Home Directories, Examples, Examples @comment node-name, next, previous, up @section User Filesystems @cindex User filesystems @cindex Mounting user filesystems With more than one fileserver, the directories most frequently cross-mounted are those containing user home directories. A common convention used at Imperial College is to mount the user disks under @t{/home/}@i{machine}. Typically, the @samp{/etc/fstab} file contained a long list of entries such as: @example @i{machine}:/home/@i{machine} /home/@i{machine} nfs ... @end example for each fileserver on the network. There are numerous problems with this system. The mount list can become quite large and some of the machines may be down when a system is booted. When a new fileserver is installed, @samp{/etc/fstab} must be updated on every machine, the mount directory created and the filesystem mounted. In many environments most people use the same few workstations, but it is convenient to go to a colleague's machine and access your own files. When a server goes down, it can cause a process on a client machine to hang. By minimizing the mounted filesystems to only include those actively being used, there is less chance that a filesystem will be mounted when a server goes down. The following is a short extract from a map taken from a research fileserver at Imperial College. Note the entry for @samp{localhost} which is used for users such as the operator (@samp{opr}) who have a home directory on most machine as @samp{/home/localhost/opr}. @example /defaults opts:=rw,intr,grpid,nosuid charm host!=$@{key@};type:=nfs;rhost:=$@{key@};rfs:=/home/$@{key@} \ host==$@{key@};type:=ufs;dev:=/dev/xd0g # ... # localhost type:=link;fs:=$@{host@} ... # # dylan has two user disks so have a # top directory in which to mount them. # dylan type:=auto;fs:=$@{map@};pref:=$@{key@}/ # dylan/dk2 host!=dylan;type:=nfs;rhost:=dylan;rfs:=/home/$@{key@} \ host==dylan;type:=ufs;dev:=/dev/dsk/2s0 # dylan/dk5 host!=dylan;type:=nfs;rhost:=dylan;rfs:=/home/$@{key@} \ host==dylan;type:=ufs;dev:=/dev/dsk/5s0 ... # toytown host!=$@{key@};type:=nfs;rhost:=$@{key@};rfs:=/home/$@{key@} \ host==$@{key@};type:=ufs;dev:=/dev/xy1g ... # zebedee host!=$@{key@};type:=nfs;rhost:=$@{key@};rfs:=/home/$@{key@} \ host==$@{key@};type:=ufs;dev:=/dev/dsk/1s0 # # Just for access... # gould type:=auto;fs:=$@{map@};pref:=$@{key@}/ gould/staff host!=gould;type:=nfs;rhost:=gould;rfs:=/home/$@{key@} # gummo host!=$@{key@};type:=nfs;rhost:=$@{key@};rfs:=/home/$@{key@} ... @end example This map is shared by most of the machines listed so on those systems any of the user disks is accessible via a consistent name. @i{Amd} is started with the following command @example amd /home amd.home @end example Note that when mounting a remote filesystem, the @dfn{automounted} mount point is referenced, so that the filesystem will be mounted if it is not yet (at the time the remote @samp{mountd} obtains the file handle). @node Home Directories, Architecture Sharing, User Filesystems, Examples @comment node-name, next, previous, up @section Home Directories @cindex Home directories @cindex Example of mounting home directories @cindex Mount home directories One convention for home directories is to locate them in @samp{/homes} so user @samp{jsp}'s home directory is @samp{/homes/jsp}. With more than a single fileserver it is convenient to spread user files across several machines. All that is required is a mount-map which converts login names to an automounted directory. Such a map might be started by the command: @example amd /homes amd.homes @end example where the map @samp{amd.homes} contained the entries: @example /defaults type:=link # All the entries are of type:=link jsp fs:=/home/charm/jsp njw fs:=/home/dylan/dk5/njw ... phjk fs:=/home/toytown/ai/phjk sjv fs:=/home/ganymede/sjv @end example Whenever a login name is accessed in @samp{/homes} a symbolic link appears pointing to the real location of that user's home directory. In this example, @samp{/homes/jsp} would appear to be a symbolic link pointing to @samp{/home/charm/jsp}. Of course, @samp{/home} would also be an automount point. This system causes an extra level of symbolic links to be used. Although that turns out to be relatively inexpensive, an alternative is to directly mount the required filesystems in the @samp{/homes} map. The required map is simple, but long, and its creation is best automated. The entry for @samp{jsp} could be: @example jsp -sublink:=$@{key@};rfs:=/home/charm \ host==charm;type:=ufs;dev:=/dev/xd0g \ host!=charm;type:=nfs;rhost:=charm @end example This map can become quite big if it contains a large number of entries. By combining two other features of @i{Amd} it can be greatly simplified. First the UFS partitions should be mounted under the control of @samp{/etc/fstab}, taking care that they are mounted in the same place that @i{Amd} would have automounted them. In most cases this would be something like @samp{/a/@dfn{host}/home/@dfn{host}} and @samp{/etc/fstab} on host @samp{charm} would have a line:@refill @example /dev/xy0g /a/charm/home/charm 4.2 rw,nosuid,grpid 1 5 @end example The map can then be changed to: @example /defaults type:=nfs;sublink:=$@{key@};opts:=rw,intr,nosuid,grpid jsp rhost:=charm;rfs:=/home/charm njw rhost:=dylan;rfs:=/home/dylan/dk5 ... phjk rhost:=toytown;rfs:=/home/toytown;sublink:=ai/$@{key@} sjv rhost:=ganymede;rfs:=/home/ganymede @end example This map operates as usual on a remote machine (@i{ie} @code{$@{host@}} not equal to @code{$@{rhost@}}). On the machine where the filesystem is stored (@i{ie} @code{$@{host@}} equal to @code{$@{rhost@}}), @i{Amd} will construct a local filesystem mount point which corresponds to the name of the locally mounted UFS partition. If @i{Amd} is started with the @code{-r} option then instead of attempting an NFS mount, @i{Amd} will simply inherit the UFS mount (@pxref{Inheritance Filesystem}). If @code{-r} is not used then a loopback NFS mount will be made. This type of mount is known to cause a deadlock on many systems. @node Architecture Sharing, Wildcard Names, Home Directories, Examples @comment node-name, next, previous, up @section Architecture Sharing @cindex Architecture sharing @cindex Sharing a fileserver between architectures @cindex Architecture dependent volumes @c %At the moment some of the research machines have sets of software @c %mounted in @samp{/vol}. This contains subdirectories for \TeX, @c %system sources, local sources, prolog libraries and so on. Often a filesystem will be shared by machines of different architectures. Separate trees can be maintained for the executable images for each architecture, but it may be more convenient to have a shared tree, with distinct subdirectories. A shared tree might have the following structure on the fileserver (called @samp{fserver} in the example): @example local/tex local/tex/fonts local/tex/lib local/tex/bin local/tex/bin/sun3 local/tex/bin/sun4 local/tex/bin/hp9000 ... @end example In this example, the subdirectories of @samp{local/tex/bin} should be hidden when accessed via the automount point (conventionally @samp{/vol}). A mount-map for @samp{/vol} to achieve this would look like: @example /defaults sublink:=$@{/key@};rhost:=fserver;type:=link tex type:=auto;fs:=$@{map@};pref:=$@{key@}/ tex/fonts host!=fserver;type:=nfs;rfs:=/vol/tex \ host==fserver;fs:=/usr/local/tex tex/lib host!=fserver;type:=nfs;rfs:=/vol/tex \ host==fserver;fs:=/usr/local/tex tex/bin -sublink:=$@{/key@}/$@{arch@} \ host!=fserver;type:=nfs;rfs:=/vol/tex \ host:=fserver;fs:=/usr/local/tex @end example When @samp{/vol/tex/bin} is referenced, the current machine architecture is automatically appended to the path by the @code{$@{sublink@}} variable. This means that users can have @samp{/vol/tex/bin} in their @samp{PATH} without concern for architecture dependencies. @node Wildcard Names, rwho servers, Architecture Sharing, Examples @comment node-name, next, previous, up @section Wildcard Names & Replicated Servers By using the wildcard facility, @i{Amd} can @dfn{overlay} an existing directory with additional entries. The system files are usually mounted under @samp{/usr}. If instead, @i{Amd} is mounted on @samp{/usr}, additional names can be overlayed to augment or replace names in the ``master'' @samp{/usr}. A map to do this would have the form: @example local type:=auto;fs:=local-map share type:=auto;fs:=share-map * -type:=nfs;rfs:=/export/exec/$@{arch@};sublink:="$@{key@}" \ rhost:=fserv1 rhost:=fserv2 rhost:=fserv3 @end example Note that the assignment to @code{$@{sublink@}} is surrounded by double quotes to prevent the incoming key from causing the map to be misinterpreted. This map has the effect of directing any access to @samp{/usr/local} or @samp{/usr/share} to another automount point. In this example, it is assumed that the @samp{/usr} files are replicated on three fileservers: @samp{fserv1}, @samp{fserv2} and @samp{fserv3}. For any references other than to @samp{local} and @samp{share} one of the servers is used and a symbolic link to @t{$@{autodir@}/$@{rhost@}/export/exec/$@{arch@}/@i{whatever}} is returned once an appropriate filesystem has been mounted.@refill @node rwho servers, /vol, Wildcard Names, Examples @comment node-name, next, previous, up @section @samp{rwho} servers @cindex rwho servers @cindex Architecture specific mounts @cindex Example of architecture specific mounts The @samp{/usr/spool/rwho} directory is a good candidate for automounting. For efficiency reasons it is best to capture the rwho data on a small number of machines and then mount that information onto a large number of clients. The data written into the rwho files is byte order dependent so only servers with the correct byte ordering can be used by a client: @example /defaults type:=nfs usr/spool/rwho -byte==little;rfs:=/usr/spool/rwho \ rhost:=vaxA rhost:=vaxB \ || -rfs:=/usr/spool/rwho \ rhost:=sun4 rhost:=hp300 @end example @node /vol, /defaults with selectors, rwho servers, Examples @comment node-name, next, previous, up @section @samp{/vol} @cindex /vol @cindex Catch-all mount point @cindex Generic volume name @samp{/vol} is used as a catch-all for volumes which do not have other conventional names. Below is part of the @samp{/vol} map for the domain @samp{doc.ic.ac.uk}. The @samp{r+d} tree is used for new or experimental software that needs to be available everywhere without installing it on all the fileservers. Users wishing to try out the new software then simply include @samp{/vol/r+d/@{bin,ucb@}} in their path.@refill The main tree resides on one host @samp{gould.doc.ic.ac.uk}, which has different @samp{bin}, @samp{etc}, @samp{lib} and @samp{ucb} sub-directories for each machine architecture. For example, @samp{/vol/r+d/bin} for a Sun-4 would be stored in the sub-directory @samp{bin/sun4} of the filesystem @samp{/usr/r+d}. When it was accessed a symbolic link pointing to @samp{/a/gould/usr/r+d/bin/sun4} would be returned.@refill @example /defaults type:=nfs;opts:=rw,grpid,nosuid,intr,soft wp -opts:=rw,grpid,nosuid;rhost:=charm \ host==charm;type:=link;fs:=/usr/local/wp \ host!=charm;type:=nfs;rfs:=/vol/wp ... # src -opts:=rw,grpid,nosuid;rhost:=charm \ host==charm;type:=link;fs:=/usr/src \ host!=charm;type:=nfs;rfs:=/vol/src # r+d type:=auto;fs:=$@{map@};pref:=r+d/ # per architecture bin,etc,lib&ucb... r+d/bin rhost:=gould.doc.ic.ac.uk;rfs:=/usr/r+d;sublink:=$@{/key@}/$@{arch@} r+d/etc rhost:=gould.doc.ic.ac.uk;rfs:=/usr/r+d;sublink:=$@{/key@}/$@{arch@} r+d/include rhost:=gould.doc.ic.ac.uk;rfs:=/usr/r+d;sublink:=$@{/key@} r+d/lib rhost:=gould.doc.ic.ac.uk;rfs:=/usr/r+d;sublink:=$@{/key@}/$@{arch@} r+d/man rhost:=gould.doc.ic.ac.uk;rfs:=/usr/r+d;sublink:=$@{/key@} r+d/src rhost:=gould.doc.ic.ac.uk;rfs:=/usr/r+d;sublink:=$@{/key@} r+d/ucb rhost:=gould.doc.ic.ac.uk;rfs:=/usr/r+d;sublink:=$@{/key@}/$@{arch@} # hades pictures pictures -opts:=rw,grpid,nosuid;rhost:=thpfs \ host==thpfs;type:=link;fs:=/nbsd/pictures \ host!=thpfs;type:=nfs;rfs:=/nbsd;sublink:=pictures # hades tools hades -opts:=rw,grpid,nosuid;rhost:=thpfs \ host==thpfs;type:=link;fs:=/nbsd/hades \ host!=thpfs;type:=nfs;rfs:=/nbsd;sublink:=hades # bsd tools for hp. bsd -opts:=rw,grpid,nosuid;arch==hp9000;rhost:=thpfs \ host==thpfs;type:=link;fs:=/nbsd/bsd \ host!=thpfs;type:=nfs;rfs:=/nbsd;sublink:=bsd @end example @node /defaults with selectors, /tftpboot in a chroot-ed environment, /vol, Examples @comment node-name, next, previous, up @section @samp{/defaults} with selectors @cindex /defaults with selectors @cindex selectors on default It is sometimes useful to have different defaults for a given map. To achieve this, the @samp{/defaults} entry must be able to process normal selectors. This feature is turned on by setting @samp{selectors_in_defaults = yes} in the @file{amd.conf} file. @xref{selectors_in_defaults Parameter}. In this example, I set different default NFS mount options for hosts which are running over a slower network link. By setting a smaller size for the NFS read and write buffer sizes, you can greatly improve remote file service performance. @example /defaults \ wire==slip-net;opts:=rw,intr,rsize=1024,wsize=1024,timeo=20,retrans=10 \ wire!=slip-net;opts:=rw,intr @end example @node /tftpboot in a chroot-ed environment, , /defaults with selectors, Examples @comment node-name, next, previous, up @section @samp{/tftpboot} in a chroot-ed environment @cindex /tftpboot in a chroot-ed environment @cindex chroot; /tftpboot example In this complex example, we attempt to run an @i{Amd} process @emph{inside} a chroot-ed environment. @samp{tftpd} (Trivial FTP) is used to trivially retrieve files used to boot X-Terminals, Network Printers, Network routers, diskless workstations, and other such devices. For security reasons, @samp{tftpd} (and also @samp{ftpd}) processes are run using the @b{chroot}(2) system call. This provides an environment for these processes, where access to any files outside the directory where the chroot-ed process runs is denied. For example, if you start @samp{tftpd} on your system with @example chroot /tftpboot /usr/sbin/tftpd @end example @noindent then the @samp{tftpd} process will not be able to access any files outside @file{/tftpboot}. This ensures that no one can retrieve files such as @file{/etc/passwd} and run password crackers on it. Since the TFTP service works by broadcast, it is necessary to have at least one TFTP server running on each subnet. If you have lots of files that you need to make available for @samp{tftp}, and many subnets, it could take significant amounts of disk space on each host serving them. A solution we implemented at Columbia University was to have every host run @samp{tftpd}, but have those servers retrieve the boot files from two replicated servers. Those replicated servers have special partitions dedicated to the many network boot files. We start @i{Amd} as follows: @example amd /tftpboot/.amd amd.tftpboot @end example That is, @i{Amd} is serving the directory @file{/tftpboot/.amd}. The @samp{tftp} server runs inside @file{/tftpboot} and is chroot-ed in that directory too. The @file{amd.tftpboot} map looks like: @example # # Amd /tftpboot directory -> host map # /defaults opts:=nosuid,ro,intr,soft;fs:=/tftpboot/import;type:=nfs tp host==lol;rfs:=/n/lol/import/tftpboot;type:=lofs \ host==ober;rfs:=/n/ober/misc/win/tftpboot;type:=lofs \ rhost:=ober;rfs:=/n/ober/misc/win/tftpboot \ rhost:=lol;rfs:=/n/lol/import/tftpboot @end example To help understand this example, I list a few of the file entries that are created inside @file{/tftpboot}: @example $ ls -la /tftpboot dr-xr-xr-x 2 root 512 Aug 30 23:11 .amd drwxrwsr-x 12 root 512 Aug 30 08:00 import lrwxrwxrwx 1 root 33 Feb 27 1997 adminpr.cfg -> ./.amd/tp/hplj/adminpr.cfg lrwxrwxrwx 1 root 22 Dec 5 1996 tekxp -> ./.amd/tp/xterms/tekxp lrwxrwxrwx 1 root 1 Dec 5 1996 tftpboot -> . @end example Here is an explanation of each of the entries listed above: @table @code @item .amd This is the @i{Amd} mount point. Note that you do not need to run a separate @i{Amd} process for the TFTP service. The @b{chroot}(2) system call only protects against file access, but the same process can still serve files and directories inside and outside the chroot-ed environment, because @i{Amd} itself was not run in chroot-ed mode. @item import This is the mount point where @i{Amd} will mount the directories containing the boot files. The map is designed so that remote directories will be NFS mounted (even if they are already mounted elsewhere), and local directories are loopback mounted (since they are not accessible outside the chroot-ed @file{/tftpboot} directory). @item adminpr.cfg @itemx tekxp Two manually created symbolic links to directories @emph{inside} the @i{Amd}-managed directory. The crossing of the component @file{tp} will cause @i{Amd} to automount one of the remote replicas. Once crossed, access to files inside proceeds as usual. The @samp{adminpr.cfg} is a configuration file for an HP Laser-Jet 4si printer, and the @samp{tekxp} is a directory for Tektronix X-Terminal boot files. @item tftpboot This innocent looking symlink is important. Usually, when devices boot via the TFTP service, they perform the @samp{get file} command to retrieve @var{file}. However, some devices assume that @samp{tftpd} does not run in a chroot-ed environment, but rather ``unprotected'', and thus use a full pathname for files to retrieve, as in @samp{get /tftpboot/file}. This symlink effectively strips out the leading @file{/tftpboot/}. @end table @c ################################################################ @node Internals, Acknowledgments & Trademarks, Examples, Top @comment node-name, next, previous, up @chapter Internals Note that there are more error and logging messages possible than are listed here. Most of them are self-explanatory. Refer to the program sources for more details on the rest. @menu * Log Messages:: @end menu @node Log Messages, , Internals, Internals @comment node-name, next, previous, up @section Log Messages In the following sections a brief explanation is given of some of the log messages made by @i{Amd}. Where the message is in @samp{typewriter} font, it corresponds exactly to the message produced by @i{Amd}. Words in @dfn{italic} are replaced by an appropriate string. Variables, @code{$@{@i{var}@}}, indicate that the value of the appropriate variable is output. Log messages are either sent directly to a file, or logged via the @b{syslog}(3) mechanism. @xref{log_file Parameter}. In either case, entries in the file are of the form: @example @i{date-string} @i{hostname} @t{amd[}@i{pid}@t{]} @i{message} @end example @menu * Fatal errors:: * Info messages:: @end menu @node Fatal errors, Info messages, Log Messages, Log Messages @comment node-name, next, previous, up @subsection Fatal errors @i{Amd} attempts to deal with unusual events. Whenever it is not possible to deal with such an error, @i{Amd} will log an appropriate message and, if it cannot possibly continue, will either exit or abort. These messages are selected by @samp{-x fatal} on the command line. When @b{syslog}(3) is being used, they are logged with level @samp{LOG_FATAL}. Even if @i{Amd} continues to operate it is likely to remain in a precarious state and should be restarted at the earliest opportunity. @table @t @item Attempting to inherit not-a-filesystem The prototype mount point created during a filesystem restart did not contain a reference to the restarted filesystem. This error ``should never happen''. @item Can't bind to domain "@i{NIS-domain}" A specific NIS domain was requested on the command line, but no server for that domain is available on the local net. @item Can't determine IP address of this host (@i{hostname}) When @i{Amd} starts it determines its own IP address. If this lookup fails then @i{Amd} cannot continue. The hostname it looks up is that obtained returned by @b{gethostname}(2) system call. @item Can't find root file handle for @i{automount point} @i{Amd} creates its own file handles for the automount points. When it mounts itself as a server, it must pass these file handles to the local kernel. If the filehandle is not obtainable the mount point is ignored. This error ``should never happen''. @item Must be root to mount filesystems (euid = @i{euid}) To prevent embarrassment, @i{Amd} makes sure it has appropriate system privileges. This amounts to having an euid of 0. The check is made after argument processing complete to give non-root users a chance to access the @code{-v} option. @item No work to do - quitting No automount points were given on the command line and so there is no work to do. @item Out of memory While attempting to malloc some memory, the memory space available to @i{Amd} was exhausted. This is an unrecoverable error. @item Out of memory in realloc While attempting to realloc some memory, the memory space available to @i{Amd} was exhausted. This is an unrecoverable error. @item cannot create rpc/udp service Either the NFS or AMQ endpoint could not be created. @item gethostname: @i{description} The @b{gethostname}(2) system call failed during startup. @item host name is not set The @b{gethostname}(2) system call returned a zero length host name. This can happen if @i{Amd} is started in single user mode just after booting the system. @item ifs_match called! An internal error occurred while restarting a pre-mounted filesystem. This error ``should never happen''. @item mount_afs: @i{description} An error occurred while @i{Amd} was mounting itself. @item run_rpc failed Somehow the main NFS server loop failed. This error ``should never happen''. @item unable to free rpc arguments in amqprog_1 The incoming arguments to the AMQ server could not be free'ed. @item unable to free rpc arguments in nfs_program_1 The incoming arguments to the NFS server could not be free'ed. @item unable to register (AMQ_PROGRAM, AMQ_VERSION, udp) The AMQ server could not be registered with the local portmapper or the internal RPC dispatcher. @item unable to register (NFS_PROGRAM, NFS_VERSION, 0) The NFS server could not be registered with the internal RPC dispatcher. @end table XXX: This section needs to be updated @node Info messages, , Fatal errors, Log Messages @comment node-name, next, previous, up @subsection Info messages @i{Amd} generates information messages to record state changes. These messages are selected by @samp{-x info} on the command line. When @b{syslog}(3) is being used, they are logged with level @samp{LOG_INFO}. The messages listed below can be generated and are in a format suitable for simple statistical analysis. @dfn{mount-info} is the string that is displayed by @dfn{Amq} in its mount information column and placed in the system mount table. @table @t @item "@t{$@{@i{path}@}}" forcibly timed out An automount point has been timed out by the @i{Amq} command. @item "@t{$@{@i{path}@}}" has timed out No access to the automount point has been made within the timeout period. @item Filehandle denied for "$@{@i{rhost}@}:$@{@i{rfs}@}" The mount daemon refused to return a file handle for the requested filesystem. @item Filehandle error for "$@{@i{rhost}@}:$@{@i{rfs}@}": @i{description} The mount daemon gave some other error for the requested filesystem. @item Finishing with status @i{exit-status} @i{Amd} is about to exit with the given exit status. @item Re-synchronizing cache for map @t{$@{@i{map}@}} The named map has been modified and the internal cache is being re-synchronized. @item file server @t{$@{@i{rhost}@}} is down - timeout of "@t{$@{@i{path}@}}" ignored An automount point has timed out, but the corresponding file server is known to be down. This message is only produced once for each mount point for which the server is down. @item file server @t{$@{@i{rhost}@}} type nfs is down An NFS file server that was previously up is now down. @item file server @t{$@{@i{rhost}@}} type nfs is up An NFS file server that was previously down is now up. @item file server @t{$@{@i{rhost}@}} type nfs starts down A new NFS file server has been referenced and is known to be down. @item file server @t{$@{@i{rhost}@}} type nfs starts up A new NFS file server has been referenced and is known to be up. @item mount of "@t{$@{@i{path}@}}" on @t{$@{@i{fs}@}} timed out Attempts to mount a filesystem for the given automount point have failed to complete within 30 seconds. @item @i{mount-info} mounted fstype @t{$@{@i{type}@}} on @t{$@{@i{fs}@}} A new file system has been mounted. @item @i{mount-info} restarted fstype @t{$@{@i{type}@}} on @t{$@{@i{fs}@}} @i{Amd} is using a pre-mounted filesystem to satisfy a mount request. @item @i{mount-info} unmounted fstype @t{$@{@i{type}@}} from @t{$@{@i{fs}@}} A file system has been unmounted. @item @i{mount-info} unmounted fstype @t{$@{@i{type}@}} from @t{$@{@i{fs}@}} link @t{$@{@i{fs}@}}/@t{$@{@i{sublink}@}} A file system of which only a sub-directory was in use has been unmounted. @item restarting @i{mount-info} on @t{$@{@i{fs}@}} A pre-mounted file system has been noted. @end table XXX: This section needs to be updated @c ################################################################ @node Acknowledgments & Trademarks, Index, Internals, Top @comment node-name, next, previous, up @unnumbered Acknowledgments & Trademarks Many thanks to the Am-Utils Users mailing list through the months developing am-utils. These members have contributed to the discussions, ideas, code and documentation, and subjected their systems to alpha quality code. Special thanks go to those @uref{http://www.am-utils.org/docs/am-utils/AUTHORS.txt,authors} who have submitted patches, and especially to the maintainers: @itemize @bullet @item @uref{http://www.cs.sunysb.edu/~ezk,Erez Zadok} @item @email{ionut AT badula.org,Ion Badulescu} @item @email{ro AT techfak.uni-bielefeld.de,Rainer Orth} @item @email{nick.williams AT morganstanley.com,Nick Williams} @end itemize Thanks to the Formal Methods Group at Imperial College for suffering patiently while @i{Amd} was being developed on their machines. Thanks to the many people who have helped with the development of @i{Amd}, especially Piete Brooks at the Cambridge University Computing Lab for many hours of testing, experimentation and discussion. Thanks to the older @email{amd-workers AT majordomo.glue.umd.edu,Amd Workers} mailing list (now defunct) members for many suggestions and bug reports to @i{Amd}. @itemize @bullet @item @b{DEC}, @b{VAX} and @b{Ultrix} are registered trademarks of Digital Equipment Corporation. @item @b{AIX} and @b{IBM} are registered trademarks of International Business Machines Corporation. @item @b{Sun}, @b{NFS} and @b{SunOS} are registered trademarks of Sun Microsystems, Inc. @item @b{UNIX} is a registered trademark in the USA and other countries, exclusively licensed through X/Open Company, Ltd. @item All other registered trademarks are owned by their respective owners. @end itemize @c ################################################################ @node Index, , Acknowledgments & Trademarks, Top @comment node-name, next, previous, up @unnumbered Index @printindex cp @contents @bye @c ==================================================================== @c ISPELL LOCAL WORDS: @c LocalWords: setfilename amdref overfullrule settitle titlepage titlefont nz @c LocalWords: authorfont vskip ifinfo iftex cindex unnumberedsec dfn xref vol @c LocalWords: locationN pxref jpo nott concentrix Sjoerd sjoerd cwi Eitan vuw @c LocalWords: Mizrotsky eitan shumuji dgux fpx scp hcx metcalf masala hlh OTS @c LocalWords: Presnell srp cgl Trost trost ogi pyrOSx OSx tubsibr riscix iX @c LocalWords: Piete pb Lindblad cjl ai umax utek xinu Mitchum D'Souza dsouza @c LocalWords: mrc apu alliant aviion AViiON fps macII multimax tahoe vax emph @c LocalWords: mapdefault valA valB valC YPTSDIR ETCDIR substr MAKEDBM YPDBDIR @c LocalWords: NOPUSH njw dylan dk dylan njw anydir domN achilles mjh pref sel @c LocalWords: gdef loc loc loc ldots autodir remopts rwho rwho styx styx yoyo @c LocalWords: noindent gould rvdmount rvdunmount fserver mtmp unioned logfile @c LocalWords: dmn esac phjk toytown toytown toytown toytown phjk RdDir RdLnk @c LocalWords: volname attrs netif dougal inaddr hwaddr ec mountmaps passno xy @c LocalWords: freq dumpset hfs brian florence localinfo fstabs automaps defn @c LocalWords: localname fsck'd opr gummo sjv ganymede sjv fserv fserv fserv @c LocalWords: vaxA vaxB wp thpfs nbsd asis ifs amqprog free'ed printindex gov @c LocalWords: LocalWords syncodeindex Distrib bsdnet lanl AutoMounter acis ic @c LocalWords: ac uk aix bsd Mullender nl il DG lcs hpux irix ucsf NeXT cse cl @c LocalWords: mt FX hp ibm mips utils def def Domainname eg hostd getwd tmp @c LocalWords: subsubsection rw grpid intr noconn nocto nodevs nosuid retrans @c LocalWords: rsize tcp timeo nounmount utimeout DDEBUG nodaemon fd hostnames @c LocalWords: pid Amd's pendry vangogh nfsx backoff stats nomap nostats CRIT @c LocalWords: noinfo clustername RVD dsk dsk amq hostports osver statfs str @c LocalWords: ou counter's amdmaps proj src tftpboot sh mv cd sbin ypcat inet @c LocalWords: Getattr getattr localhost fhandles netmask fstype noquota addr @c LocalWords: exportfs Dumpsets dumpsets pindex ldif fixmount fixrmtab euid @c LocalWords: lostaltmail realloc netnumber itemx primnetnum primnetname ARG @c LocalWords: subsnetname subsnetnum netgrp netgroup multitable Shlib dec osf @c LocalWords: hppa pc bsdi freebsd netbsd openbsd ncr sysv rs acdirmax fsid @c LocalWords: acdirmin acregmax acregmin actimeo dumbtimr nfsv noac noauto sd @c LocalWords: nocache nodev noint nosub pgthresh posix rdonly suid symttl mfs @c LocalWords: AMFS umapfs myftpdir unionfs es mapname mapfile mapfile slocal @c LocalWords: mailspool saturn saturn notknown lol ober dr xr xr drwxrwsr cfg @c LocalWords: lrwxrwxrwx adminpr hplj adminpr cfg tekxp xterms tekxp Dupuy tp @c LocalWords: linkname hlfsddump dirname rmtab pluto rlogin direntry pg vr dn @c LocalWords: maxmem hlfsdir xmailbox showmount cn amdmap amdmapName resvport @c LocalWords: objectClass amdmapKey amdmapValue ln powerpc amdmapTimestamp ez @c LocalWords: moisil FSinfo Libtool Unmounting sublink fileservers NullProc @c LocalWords: gethostname mount's unmounts linkx remounts unmounting UAs SA's @c LocalWords: mountpoint mountpoints unescaped UIDs util's overlayed uref EFS @c LocalWords: serv maxgroups nfsl cachedir copt cfsadmin efs addopts fg ROMs @c LocalWords: nointr extatt setchapternewpage columnfractions alphaev gnulibc @c LocalWords: freebsdelf gnuoldld ifhtml defperm nodefperm norrip RRIP rrip @c LocalWords: noversion attr XXXXXX netgrpd rh mkstemp uid gid noexec mntfs @c LocalWords: nomnttab optionstr hrtime xdrtrace getpwd proplist redhat ctl @c LocalWords: texinfo texi ib sp cartouche ified xlatecookie dircategory sc @c LocalWords: AddInfo suse Novell softlookup ENOENT USB fullybrowsable LDAPv @c LocalWords: amy ie xfffffe zebedee andrew diskfull hdmail searchable si @c LocalWords: Orth ESTALE am-utils-6.2+rc20110530/doc/hlfsd.ps000066400000000000000000005616061157065440000165610ustar00rootroot00000000000000%!PS-Adobe-2.0 %%Creator: dvips 5.47 Copyright 1986-91 Radical Eye Software %%Title: hlfsd.dvi %%Pages: 15 1 %%BoundingBox: 0 0 612 792 %%EndComments %%BeginProcSet: /usr/local/lib/tex/ps/psfig.pro /TeXscale { 65536 div } def /DocumentInitState [ matrix currentmatrix currentlinewidth currentlinecap currentlinejoin currentdash currentgray currentmiterlimit ] cvx def /startTexFig { /SavedState save def userdict maxlength dict begin currentpoint transform DocumentInitState setmiterlimit setgray setdash setlinejoin setlinecap setlinewidth setmatrix itransform moveto /ury exch TeXscale def /urx exch TeXscale def /lly exch TeXscale def /llx exch TeXscale def /y exch TeXscale def /x exch TeXscale def currentpoint /cy exch def /cx exch def /sx x urx llx sub div def % scaling for x /sy y ury lly sub div def % scaling for y sx sy scale % scale by (sx,sy) cx sx div llx sub cy sy div ury sub translate /DefFigCTM matrix currentmatrix def /initmatrix { DefFigCTM setmatrix } def /defaultmatrix { DefFigCTM exch copy } def /initgraphics { DocumentInitState setmiterlimit setgray setdash setlinejoin setlinecap setlinewidth setmatrix DefFigCTM setmatrix } def /showpage { initgraphics } def /erasepage { initgraphics } def /copypage {} def } def /clipFig { currentpoint 6 2 roll newpath 4 copy 4 2 roll moveto 6 -1 roll exch lineto exch lineto exch lineto closepath clip newpath moveto } def /doclip { llx lly urx ury clipFig } def /endTexFig { end SavedState restore } def %%EndProcSet %%BeginProcSet: tex.pro /TeXDict 200 dict def TeXDict begin /N /def load def /B{bind def}N /S /exch load def /X{S N}B /TR /translate load N /isls false N /vsize 10 N /@rigin{ isls{[0 1 -1 0 0 0]concat}if 72 Resolution div 72 VResolution div neg scale Resolution VResolution vsize neg mul TR matrix currentmatrix dup dup 4 get round 4 exch put dup dup 5 get round 5 exch put setmatrix}N /@letter{/vsize 10 N}B /@landscape{/isls true N /vsize -1 N}B /@a4{/vsize 10.6929133858 N}B /@a3{ /vsize 15.5531 N}B /@ledger{/vsize 16 N}B /@legal{/vsize 13 N}B /@manualfeed{ statusdict /manualfeed true put}B /@copies{/#copies X}B /FMat[1 0 0 -1 0 0]N /FBB[0 0 0 0]N /nn 0 N /IE 0 N /ctr 0 N /df-tail{/nn 8 dict N nn begin /FontType 3 N /FontMatrix fntrx N /FontBBox FBB N string /base X array /BitMaps X /BuildChar{CharBuilder}N /Encoding IE N end dup{/foo setfont}2 array copy cvx N load 0 nn put /ctr 0 N[}B /df{/sf 1 N /fntrx FMat N df-tail} B /dfs{div /sf X /fntrx[sf 0 0 sf neg 0 0]N df-tail}B /E{pop nn dup definefont setfont}B /ch-width{ch-data dup length 5 sub get}B /ch-height{ch-data dup length 4 sub get}B /ch-xoff{128 ch-data dup length 3 sub get sub}B /ch-yoff{ ch-data dup length 2 sub get 127 sub}B /ch-dx{ch-data dup length 1 sub get}B /ch-image{ch-data dup type /stringtype ne{ctr get /ctr ctr 1 add N}if}B /id 0 N /rw 0 N /rc 0 N /gp 0 N /cp 0 N /G 0 N /sf 0 N /CharBuilder{save 3 1 roll S dup /base get 2 index get S /BitMaps get S get /ch-data X pop /ctr 0 N ch-dx 0 ch-xoff ch-yoff ch-height sub ch-xoff ch-width add ch-yoff setcachedevice ch-width ch-height true[1 0 0 -1 -.1 ch-xoff sub ch-yoff .1 add]{ch-image} imagemask restore}B /D{/cc X dup type /stringtype ne{]}if nn /base get cc ctr put nn /BitMaps get S ctr S sf 1 ne{dup dup length 1 sub dup 2 index S get sf div put}if put /ctr ctr 1 add N}B /I{cc 1 add D}B /bop{userdict /bop-hook known{bop-hook}if /SI save N @rigin 0 0 moveto}N /eop{clear SI restore showpage userdict /eop-hook known{eop-hook}if}N /@start{userdict /start-hook known{start-hook}if /VResolution X /Resolution X 1000 div /DVImag X /IE 256 array N 0 1 255{IE S 1 string dup 0 3 index put cvn put}for}N /p /show load N /RMat[1 0 0 -1 0 0]N /BDot 260 string N /rulex 0 N /ruley 0 N /v{/ruley X /rulex X V}B /V statusdict begin /product where{pop product dup length 7 ge{0 7 getinterval(Display)eq}{pop false}ifelse}{false}ifelse end{{gsave TR -.1 -.1 TR 1 1 scale rulex ruley false RMat{BDot}imagemask grestore}}{{gsave TR -.1 -.1 TR rulex ruley scale 1 1 false RMat{BDot}imagemask grestore}}ifelse B /a{ moveto}B /delta 0 N /tail{dup /delta X 0 rmoveto}B /M{S p delta add tail}B /b{ S p tail}B /c{-4 M}B /d{-3 M}B /e{-2 M}B /f{-1 M}B /g{0 M}B /h{1 M}B /i{2 M}B /j{3 M}B /k{4 M}B /w{0 rmoveto}B /l{p -4 w}B /m{p -3 w}B /n{p -2 w}B /o{p -1 w }B /q{p 1 w}B /r{p 2 w}B /s{p 3 w}B /t{p 4 w}B /x{0 S rmoveto}B /y{3 2 roll p a}B /bos{/SS save N}B /eos{clear SS restore}B end %%EndProcSet %%BeginProcSet: special.pro TeXDict begin /SDict 200 dict N SDict begin /@SpecialDefaults{/hs 612 N /vs 792 N /ho 0 N /vo 0 N /hsc 1 N /vsc 1 N /ang 0 N /CLIP false N /BBcalc false N /p 3 def}B /@scaleunit 100 N /@hscale{@scaleunit div /hsc X}B /@vscale{ @scaleunit div /vsc X}B /@hsize{/hs X /CLIP true N}B /@vsize{/vs X /CLIP true N}B /@hoffset{/ho X}B /@voffset{/vo X}B /@angle{/ang X}B /@rwi{10 div /rwi X} B /@llx{/llx X}B /@lly{/lly X}B /@urx{/urx X}B /@ury{/ury X /BBcalc true N}B /magscale true def end /@MacSetUp{userdict /md known{userdict /md get type /dicttype eq{md begin /letter{}N /note{}N /legal{}N /od{txpose 1 0 mtx defaultmatrix dtransform S atan/pa X newpath clippath mark{transform{ itransform moveto}}{transform{itransform lineto}}{6 -2 roll transform 6 -2 roll transform 6 -2 roll transform{itransform 6 2 roll itransform 6 2 roll itransform 6 2 roll curveto}}{{closepath}}pathforall newpath counttomark array astore /gc xdf pop ct 39 0 put 10 fz 0 fs 2 F/|______Courier fnt invertflag{ PaintBlack}if}N /txpose{pxs pys scale ppr aload pop por{noflips{pop S neg S TR pop 1 -1 scale}if xflip yflip and{pop S neg S TR 180 rotate 1 -1 scale ppr 3 get ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg TR}if xflip yflip not and{pop S neg S TR pop 180 rotate ppr 3 get ppr 1 get neg sub neg 0 TR}if yflip xflip not and{ppr 1 get neg ppr 0 get neg TR}if}{noflips{TR pop pop 270 rotate 1 -1 scale}if xflip yflip and{TR pop pop 90 rotate 1 -1 scale ppr 3 get ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg TR}if xflip yflip not and{TR pop pop 90 rotate ppr 3 get ppr 1 get neg sub neg 0 TR}if yflip xflip not and{TR pop pop 270 rotate ppr 2 get ppr 0 get neg sub neg 0 S TR}if} ifelse scaleby96{ppr aload pop 4 -1 roll add 2 div 3 1 roll add 2 div 2 copy TR .96 dup scale neg S neg S TR}if}N /cp{pop pop showpage pm restore}N end}if} if}N /normalscale{Resolution 72 div VResolution 72 div neg scale magscale{ DVImag dup scale}if}N /psfts{S 65536 div N}N /startTexFig{/psf$SavedState save N userdict maxlength dict begin /magscale false def normalscale currentpoint TR /psf$ury psfts /psf$urx psfts /psf$lly psfts /psf$llx psfts /psf$y psfts /psf$x psfts currentpoint /psf$cy X /psf$cx X /psf$sx psf$x psf$urx psf$llx sub div N /psf$sy psf$y psf$ury psf$lly sub div N psf$sx psf$sy scale psf$cx psf$sx div psf$llx sub psf$cy psf$sy div psf$ury sub TR /showpage{}N /erasepage{}N /copypage{}N /p 3 def @MacSetUp}N /doclip{psf$llx psf$lly psf$urx psf$ury currentpoint 6 2 roll newpath 4 copy 4 2 roll moveto 6 -1 roll S lineto S lineto S lineto closepath clip newpath moveto}N /endTexFig{end psf$SavedState restore}N /@beginspecial{SDict begin /SpecialSave save N gsave normalscale currentpoint TR @SpecialDefaults}N /@setspecial{CLIP{newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs neg 0 rlineto closepath clip}if ho vo TR hsc vsc scale ang rotate BBcalc{rwi urx llx sub div dup scale llx neg lly neg TR}if /showpage{}N /erasepage{}N /copypage{}N newpath}N /@endspecial{grestore clear SpecialSave restore end}N /@defspecial{SDict begin}N /@fedspecial{end}B /li{lineto}B /rl{rlineto}B /rc{rcurveto}B /np{/SaveX currentpoint /SaveY X N 1 setlinecap newpath}N /st{stroke SaveX SaveY moveto}N /fil{fill SaveX SaveY moveto}N /ellipse{/endangle X /startangle X /yrad X /xrad X /savematrix matrix currentmatrix N TR xrad yrad scale 0 0 1 startangle endangle arc savematrix setmatrix}N end %%EndProcSet TeXDict begin 1000 300 300 @start /Fa 2 117 df<3E0006000C000C000C000C00180019 E01E30183038303030303030306060606460C460C4C0C8C0700E147E9313>104 D<02000600060006000C00FF800C000C001800180018001800300031003100320032001C000912 7F910D>116 D E /Fb 5 116 df<001FC0001FC0001FC00001C00001C00001C00001C00001C000 01C001F1C007FDC00FFFC01E0FC03C07C07803C07001C0E001C0E001C0E001C0E001C0E001C0E0 01C0E001C07003C07003C03807C03E0FC01FFFFC07FDFC01F1FC161E7E9D1A>100 D<0007E0001FF0003FF800787800F03000E00000E00000E00000E0007FFFF0FFFFF0FFFFF000E0 0000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E00000E0 0000E0003FFF807FFFC03FFF80151E7F9D1A>102 D104 D108 D<07FB801FFF807FFF80780780E003 80E00380E003807800007FC0003FFC0007FE00003F800007806001C0E001C0E001C0F003C0FC07 80FFFF00EFFE00E3F80012157C941A>115 D E /Fc 13 118 df<000180000180000380000380 000780000780000B800013800013800023C00021C00041C000C1C00081C00101C001FFC00201C0 0201C00401C00801C00801C01801C0FE0FF815177E961A>65 D<03FFFE00E00E00E00400E00400 E00401C00401C00401C10001C10003820003820003FE000386000704000704080704080700100E 00100E00300E00200E00601C01C0FFFFC017177E9618>69 D<03F0003F8000F000780000B80078 0000B800B80000B80138000138017000013802700001380270000138047000023808E000021C08 E000021C10E000021C10E000041C21C000041C41C000041C41C000041C81C000081D038000081D 038000080E038000080E038000180C070000FE083FE00021177E9620>77 D<03F00FE000F0030000F0020000B8020000B80200011C0400011C0400011C0400010E0400020E 0800020E080002070800020708000403900004039000040390000401D0000801E0000800E00008 00E0000800E00018004000FE0040001B177E961A>I<03FFE000E03800E01C00E01C00E01C01C0 1C01C01C01C01C01C0380380700381C003FF000381800700C00700E00700E00700E00E01C00E01 C00E01C20E01C21C00C4FF807817177E961A>82 D<007C400182800301800601800601800C0100 0C01000C00000E00000FC00007F80003FC00007C00000E00000E00000600200600400C00400C00 600800601000D8600087C00012177D9614>I<7FC1FC1C00601C00401C00401C00403800803800 80380080380080700100700100700100700100E00200E00200E00200E00200E00400E00800E008 006030003040001F8000161779961A>85 D<007C00180018001800180030003000300030076008 E018E0306030C060C060C060C0C180C188C1884388659038E00E177C9612>100 D<030706000000000000384C4C4C8C18181830326262243808177D960B>105 D<078018C0304060606060C060C060C06080C080C08180C10046003C000B0E7B8D12>111 D<38F04518463846308C000C000C000C001800180018001800300030000D0E7D8D0F>114 D<07800C4018E018E038001E001F8007C000C060C0E0C0C180C3003E000B0E7D8D0F>I<1C0826 184618461886300C300C300C30186018621862186208E407380F0E7D8D13>117 D E /Fd 25 127 df<60F0F0600404798312>46 D<0018003800380070007000E000E001C001C0 01C003800380070007000E000E001C001C001C003800380070007000E000E000C0000D1A7E9612 >I<07C00FE01C703838701C701CE00EE00EE00EE00EE00EE00EE00EE01E701C701C38381C700F E007C00F147F9312>I61 D<3F807FC070E0207000700FF03FF07870E070E070E07070F03FFE1F3E0F0E7E8D12>97 DI<07F01FF8383870106000E000E000E000E0006000703838381FF007E00D0E 7E8D12>I<00F800F8003800380038003807B81FF8387870386038E038E038E038E03860387078 38781FFE0FBE0F147F9312>I<07801FE0387070706038E038FFF8FFF8E0006000703838381FF0 07C00D0E7E8D12>I<007E00FF01C70382038003807FFEFFFE0380038003800380038003800380 0380038003803FF83FF81014809312>I104 D<06000F000F00060000000000 0000FF00FF000700070007000700070007000700070007000700FFF0FFF00C157D9412>I107 DIII<0F803FE038E07070E038E038E038E038E0 38F078707038E03FE00F800D0E7E8D12>II114 D<1FF03FF06070C070E0007F003F E00FF000786018E018F030FFE0DFC00D0E7E8D12>I<06000E000E000E007FF8FFF80E000E000E 000E000E000E000E000E380E380E3807F003C00D127F9112>III<3FFC7FFC7038707000E001C0038007000E001C1C38 1C701CFFFCFFFC0E0E7F8D12>122 D<18403CE0E78043000B047D9312>126 D E /Fe 64 125 df<00FCF807839C0E079C1C07081C07001C07001C07001C07001C0700FFFFE0 1C07001C07001C07001C07001C07001C07001C07001C07001C07001C07001C07001C0700FF1FE0 1617809615>11 D<00FC000782000E07001C07001C02001C00001C00001C00001C0000FFFF001C 07001C07001C07001C07001C07001C07001C07001C07001C07001C07001C07001C0700FF1FE013 17809614>I<00FC7E000703C1000E0783801C0703801C0701001C0700001C0700001C0700001C 070000FFFFFF801C0703801C0703801C0703801C0703801C0703801C0703801C0703801C070380 1C0703801C0703801C0703801C070380FF1FCFF01C1780961D>14 D<60F0F07010102020404004 0A7D960A>39 D<0102040C1818303070606060E0E0E0E0E0E0E0E0E0E060606070303018180C04 020108227D980E>I<8040203018180C0C0E060606070707070707070707070606060E0C0C1818 3020408008227E980E>I<60F0F070101020204040040A7D830A>44 DI< 60F0F06004047D830A>I<0008001800300030003000600060006000C000C000C0018001800180 030003000600060006000C000C000C00180018001800300030003000600060006000C000C0000D 217E9812>I<03000700FF00070007000700070007000700070007000700070007000700070007 000700070007007FF00C157E9412>49 D<0F8030E040708030C038E03840380038007000700060 00C00180030006000C08080810183FF07FF0FFF00D157E9412>I<0FE030306018701C701C001C 00180038006007E000300018000C000E000EE00EE00EC00C401830300FE00F157F9412>I<0030 0030007000F001F001700270047008701870107020704070C070FFFE0070007000700070007003 FE0F157F9412>I<01F00608080C181C301C70006000E000E3E0EC30F018F00CE00EE00EE00E60 0E600E300C3018183007C00F157F9412>54 D<40007FFE7FFC7FF8C00880108020004000800080 0100010003000200060006000E000E000E000E000E0004000F167E9512>I<07E018302018600C 600C700C78183E101F600FC00FF018F8607C601EC00EC006C006C004600C38300FE00F157F9412 >I<07C0183030186018E00CE00CE00EE00EE00E601E301E186E0F8E000E000C001C7018701860 3020C01F800F157F9412>I<60F0F06000000000000060F0F07010102020404004147D8D0A>59 D<001000003800003800003800005C00005C00005C00008E00008E00008E000107000107000307 8002038002038007FFC00401C00401C00800E00800E01800E03800F0FE03FE17177F961A>65 DI<00 FC100383300E00B01C0070380030300030700010600010E00010E00000E00000E00000E00000E0 0000E000106000107000103000203800201C00400E008003830000FC0014177E9619>II70 D72 DI76 DII<00FC00030300 0E01C01C00E0380070300030700038600018E0001CE0001CE0001CE0001CE0001CE0001CE0001C 7000387000383000303800701C00E00E01C003030000FC0016177E961B>II82 D<0FC4302C601C400CC004C0 04C004E00070007F003FE00FF801FC001C000E0006800680068006C004E008D81087E00F177E96 14>I<7FFFF8603818403808403808803804803804803804003800003800003800003800003800 00380000380000380000380000380000380000380000380000380000380007FFC016177F9619> III88 D91 D93 D<1FC0386038301038003803F81E3830387038E039E039E07970FF1F1E100E7F8D12> 97 D I<07F01838303870106000E000E000E000E000600070083008183007C00D0E7F8D10>I<007E00 000E00000E00000E00000E00000E00000E00000E00000E0007CE001C3E00300E00700E00600E00 E00E00E00E00E00E00E00E00600E00700E00301E00182E0007CFC012177F9614>I<0FC0186030 307038E018FFF8E000E000E000600070083010183007C00D0E7F8D10>I<03E006700E701C201C 001C001C001C001C00FF801C001C001C001C001C001C001C001C001C001C001C001C00FF800C17 80960B>I<0F9E18E33060707070707070306018C02F80200060003FE03FF83FFC600EC006C006 C006600C38380FE010157F8D12>II<183C3C1800000000007C1C1C1C1C1C1C1C1C1C1C1C1CFF081780 960A>I107 DIII<07C018303018600C600CE00EE00EE00EE00EE00E701C30181830 07C00F0E7F8D12>II<07C2 001C2600381E00700E00600E00E00E00E00E00E00E00E00E00600E00700E00301E001C2E0007CE 00000E00000E00000E00000E00000E00007FC012147F8D13>II<1F4060C0C040C040E000FF007F801FC001 E080608060C060E0C09F000B0E7F8D0E>I<080008000800180018003800FF8038003800380038 0038003800380038403840384038401C800F000A147F930E>IIIIII124 D E /Ff 10 58 df<1F00318060C04040C060C060 C060C060C060C060C060C060404060C031801F000B107F8F0F>48 D<0C003C00CC000C000C000C 000C000C000C000C000C000C000C000C000C00FF8009107E8F0F>I<1F00618040C08060C06000 60006000C00180030006000C00102020207FC0FFC00B107F8F0F>I<1F00218060C060C000C000 8001800F00008000400060C060C060804060801F000B107F8F0F>I<0300030007000F000B0013 00330023004300C300FFE003000300030003001FE00B107F8F0F>I<20803F002C002000200020 002F0030802040006000600060C06080C061801F000B107F8F0F>I<0780184030C060C06000C0 00CF00F080E040C060C060C060406060C030801F000B107F8F0F>I<40007FE07FC08080808001 000200040004000C0008000800180018001800180018000B117E900F>I<1F00318060C060C060 C071803F000F00338061C0C060C060C060404060801F000B107F8F0F>I<1F00318060C0C040C0 60C060C06040E021E01E600060004060C0608043003E000B107F8F0F>I E /Fg 10 58 df<0F0030C0606060604020C030C030C030C030C030C030C030C030C030402060 60606030C00F000C137E9211>48 D<0C001C00EC000C000C000C000C000C000C000C000C000C00 0C000C000C000C000C000C00FFC00A137D9211>I<1F0060C06060F070F0306030007000700060 00C001C00180020004000810101020207FE0FFE00C137E9211>I<0FC030707038703870380038 003000E00FC0007000380018001C601CF01CF018E03860701FC00E137F9211>I<006000E000E0 0160026006600C600860106020606060C060FFFC0060006000600060006003FC0E137F9211>I< 60607FC07F8044004000400040004F0070C040E0006000700070E070E070E06040E021C01F000C 137E9211>I<07C00C201070207060006000C000CF00D0C0E060C020C030C030C0304030602020 6010C00F000C137E9211>I<40007FFC7FF8401080108020004000800100010003000200060006 000E000E000E000E000E0004000E147E9311>I<0FC0107020186018601870183C303F600F800F E031F06078C01CC00CC00CC00C601830300FC00E137F9211>I<0F00308060404060C020C030C0 30C0304030607030B00F30003000200060E040E08041003E000C137E9211>I E /Fh 59 122 df<183C3C3C0404080810204080060C779C0D>39 D<1838783808081010204040 80050C7D830D>44 DI<3078F06005047C830D>I<003C0000C60001 83000303000603000603800E03800C03801C03801C0300380700380700380700380700700E0070 0E00700E00700E00E01C00E01C00E01C00E03800E03800E03000C06000E0600060C0007180001E 0000111D7B9B15>48 D<00020006000C001C007C039C0038003800380038007000700070007000 E000E000E000E001C001C001C001C003800380038003800780FFF00F1C7C9B15>I<003C0000C3 000101800201800201C00441C00441C00841C00841C00841C01083801083801107000E0600000C 0000180000300000C0000100000600000800001001001002002002004006007E0C00C7F80083F8 0080E000121D7C9B15>I<0001800001C000038000038000038000030000070000070000060000 0E00000C00001C0000180000180000300000300000600000400000C600018E00010E00020E0006 1C000C1C00181C003F1C0040F800803F0000380000380000700000700000700000700000E00000 600012247E9B15>52 D<00C06000FFC001FF8001FE000100000100000200000200000200000200 00047800058C00060600040600080600000700000700000600000E00000E00700E00700C00E01C 0080180080380040300040600021C0001F0000131D7C9B15>I<09C04017E0801FE0803C610030 2700601A00400600400400800C0080080000180000100000300000600000600000600000C00000 C00001C0000180000380000380000300000700000700000700000E00000E00000C0000121D799B 15>55 D<001E000061000081800180800300C00300C006018006018006018007030007860003CC 0003F00001F000037800063C00081E00180E00300E00600600600600600600C00C00C00C00C018 0060100060200030C0000F0000121D7C9B15>I<003C0000C6000183000303000603000E03000C 03801C03801C03001C0300380700380700380700380F00380E00181E00181E000C6C00079C0000 1C00001800003800003000006000E0C000E0C0008180008600007C0000111D7B9B15>I<060F0F 06000000000000000000003078F06008127C910D>I<0000180000001800000038000000380000 007800000078000000B8000001B800000138000002380000023C0000041C0000041C0000081C00 00181C0000101C0000201C0000201C00007FFC0000401C0000801C0001801C0001001C0002001C 0002001C0004000E000C000E001C001E00FF00FFC01A1D7E9C1F>65 D<01FFFE00003C07800038 03C0003801C0003801C0003801C0007001C0007003C0007003C00070078000E0070000E00E0000 E03C0000FFF80001C01C0001C00E0001C00F0001C00F0003800F0003800F0003800F0003800F00 07001E0007001C0007003C00070078000E01E000FFFF80001A1C7D9B1D>I<0003F020001E0C60 003002E000E003C001C001C0038001C0070000C00E0000801E0000801C0000803C0000803C0000 00780000007800000078000000F0000000F0000000F0000000F0000000F0000400F0000400F000 0400F0000800700008007000100038002000180040000C0180000706000001F800001B1E7A9C1E >I<01FFFE00003C0780003801C0003801C0003800E0003800E0007000F0007000700070007000 7000F000E000F000E000F000E000F000E000F001C001E001C001E001C001E001C001C0038003C0 03800380038007800380070007000E0007001C0007003800070070000E01C000FFFF00001C1C7D 9B1F>I<01FFFFE0003C00E0003800600038004000380040003800400070004000700040007020 400070200000E0400000E0400000E0C00000FFC00001C0800001C0800001C0800001C080000381 0100038001000380020003800200070004000700040007000C00070018000E007800FFFFF0001B 1C7D9B1C>I<01FFFFC0003C01C0003800C0003800800038008000380080007000800070008000 7020800070200000E0400000E0400000E0C00000FFC00001C0800001C0800001C0800001C08000 03810000038000000380000003800000070000000700000007000000070000000F000000FFF000 001A1C7D9B1B>I<0003F020001E0C60003002E000E003C001C001C0038001C0070000C00E0000 801E0000801C0000803C0000803C000000780000007800000078000000F0000000F0000000F001 FFC0F0001E00F0001C00F0001C00F0001C00F0001C00700038007000380038003800180078000C 0090000707100001F800001B1E7A9C20>I<01FFCFFE003C01E0003801C0003801C0003801C000 3801C00070038000700380007003800070038000E0070000E0070000E0070000FFFF0001C00E00 01C00E0001C00E0001C00E0003801C0003801C0003801C0003801C000700380007003800070038 00070038000F007800FFE7FF001F1C7D9B1F>I<01FFC0003C0000380000380000380000380000 700000700000700000700000E00000E00000E00000E00001C00001C00001C00001C00003800003 80000380000380000700000700000700000700000F0000FFE000121C7E9B10>I<007FF0000780 000700000700000700000700000E00000E00000E00000E00001C00001C00001C00001C00003800 00380000380000380000700000700000700000700060E000E0E000C0C00081C000838000470000 3C0000141D7B9B16>I<01FFC0FF003C003C003800300038004000380080003801000070020000 700400007010000070200000E0400000E0C00000E1C00000E5C00001C8E00001D0E00001E0E000 01C07000038070000380700003803800038038000700380007001C0007001C0007001C000F001E 00FFE0FF80201C7D9B20>I<01FFE0003C00003800003800003800003800007000007000007000 00700000E00000E00000E00000E00001C00001C00001C00001C000038008038008038008038010 0700100700300700600700E00E03C0FFFFC0151C7D9B1A>I<01FE0007F8003E000780002E000F 00002E001700002E001700002E002700004E002E00004E004E00004E004E00004E008E00008E01 1C00008E011C00008E021C00008E021C0001070438000107043800010708380001071038000207 107000020720700002072070000207407000040740E000040780E000040700E0000C0700E0001C 0601E000FF861FFC00251C7D9B25>I<01FC03FE001C0070003C0060002E0040002E0040002E00 40004700800047008000470080004380800083810000838100008181000081C1000101C2000101 C2000100E2000100E2000200E4000200740002007400020074000400380004003800040038000C 0018001C001000FF8010001F1C7D9B1F>I<0007F000001C1C0000700E0000E0070001C0038003 800380070003800E0003C01E0003C01C0003C03C0003C03C0003C0780003C0780003C0780003C0 F0000780F0000780F0000780F0000F00F0000F00F0000E00F0001E00F0003C0070003800700070 007800E0003801C0001C0380000E0E000003F800001A1E7A9C20>I<01FFFC00003C0700003803 80003801C0003801C0003801C0007003C0007003C0007003C00070038000E0078000E0070000E0 0E0000E0380001FFE00001C0000001C0000001C000000380000003800000038000000380000007 0000000700000007000000070000000F000000FFE000001A1C7D9B1C>I<01FFF800003C0E0000 38070000380380003803800038038000700780007007800070078000700F0000E00E0000E01C00 00E0700000FFC00001C0C00001C0600001C0700001C07000038070000380700003807000038070 000700F0000700F0400700F0400700F0800F007880FFE0790000001E001A1D7D9B1E>82 D<000F8400304C00403C00801801001803001803001806001006001006000007000007000003E0 0003FC0001FF00007F800007C00001C00001C00000C00000C02000C02000C06001806001806003 00600200F00400CC180083E000161E7D9C17>I<1FFFFFC01C0701C0300E00C0200E0080600E00 80400E0080401C0080801C0080801C0080001C0000003800000038000000380000003800000070 000000700000007000000070000000E0000000E0000000E0000000E0000001C0000001C0000001 C0000001C0000003C000007FFE00001A1C799B1E>I<7FF0FF800F001C000E0018000E0010000E 0010000E0010001C0020001C0020001C0020001C00200038004000380040003800400038004000 70008000700080007000800070008000E0010000E0010000E0010000E0020000E0020000E00400 00E00400006008000030300000104000000F800000191D779B1F>I87 D<01FF81FE001E00F0001C0060001E 0080000E0180000E0100000F02000007040000070800000790000003A0000003C0000001C00000 01C0000001E0000002E0000004E0000008F0000010700000207000006038000040380000803C00 01001C0002001C0006001E001E001E00FF80FFC01F1C7E9B1F>I<00FFFF8000F0070001C00E00 01801E0001001C0001003800020070000200E0000201C0000001C0000003800000070000000E00 00001C0000001C0000003800000070000000E0080001C0100001C0100003801000070020000E00 20001C0060003C00C0003801C00070078000FFFF8000191C7D9B19>90 D<03CC063C0C3C181C38 38303870387038E070E070E070E070E0E2C0E2C0E261E462643C380F127B9115>97 D<3F00070007000E000E000E000E001C001C001C001C0039C03E60383038307038703870387038 E070E070E070E060E0E0C0C0C1C0618063003C000D1D7B9C13>I<01F007080C08181C38383000 70007000E000E000E000E000E000E008E010602030C01F000E127B9113>I<001F800003800003 80000700000700000700000700000E00000E00000E00000E0003DC00063C000C3C00181C003838 00303800703800703800E07000E07000E07000E07000E0E200C0E200C0E20061E4006264003C38 00111D7B9C15>I<01E007100C1018083810701070607F80E000E000E000E000E000E008601060 2030C01F000D127B9113>I<0003C0000670000C70001C60001C00001C00003800003800003800 00380000380003FF8000700000700000700000700000700000E00000E00000E00000E00000E000 01C00001C00001C00001C00001C000038000038000038000030000030000070000C60000E60000 CC00007800001425819C0D>I<00F3018F030F06070E0E0C0E1C0E1C0E381C381C381C381C3838 30383038187818F00F700070007000E000E0C0C0E1C0C3007E00101A7D9113>I<0FC00001C000 01C0000380000380000380000380000700000700000700000700000E78000E8C000F0E000E0E00 1C0E001C0E001C0E001C0E00381C00381C00381C00383800703880703880707080707100E03200 601C00111D7D9C15>I<01800380010000000000000000000000000000001C002600470047008E 008E000E001C001C001C0038003800710071007100720072003C00091C7C9B0D>I<0FC00001C0 0001C0000380000380000380000380000700000700000700000700000E0F000E11000E23800E43 801C83001C80001D00001E00003F800039C00038E00038E00070E20070E20070E20070E400E064 00603800111D7D9C13>107 D<1F800380038007000700070007000E000E000E000E001C001C00 1C001C0038003800380038007000700070007000E400E400E400E40068003800091D7C9C0B>I< 3C1E0780266318C04683A0E04703C0E08E0380E08E0380E00E0380E00E0380E01C0701C01C0701 C01C0701C01C070380380E0388380E0388380E0708380E0710701C0320300C01C01D127C9122> I<3C3C002646004687004707008E07008E07000E07000E07001C0E001C0E001C0E001C1C00381C 40381C40383840383880701900300E0012127C9117>I<01E007180C0C180C380C300E700E700E E01CE01CE01CE018E038E030E06060C031801E000F127B9115>I<07870004D98008E0C008E0C0 11C0E011C0E001C0E001C0E00381C00381C00381C00381800703800703000707000706000E8C00 0E70000E00000E00001C00001C00001C00001C00003C0000FF8000131A7F9115>I<3C3C26C246 8747078E068E000E000E001C001C001C001C0038003800380038007000300010127C9112>114 D<01F006080C080C1C18181C001F001FC00FF007F0007800386030E030C030806060C01F000E12 7D9111>I<00C001C001C001C00380038003800380FFE00700070007000E000E000E000E001C00 1C001C001C00384038403840388019000E000B1A7D990E>I<1E0300270700470700470700870E 00870E000E0E000E0E001C1C001C1C001C1C001C1C003838803838801838801839001C5900078E 0011127C9116>I<1E06270E470E4706870287020E020E021C041C041C041C0818083808181018 200C4007800F127C9113>I<1E01832703874703874703838707018707010E07010E07011C0E02 1C0E021C0E021C0E04180C04181C04181C081C1C100C263007C3C018127C911C>I<070E001991 0010E38020E38041C30041C00001C00001C000038000038000038000038000070200670200E704 00CB04008B080070F00011127D9113>I<1E03270747074707870E870E0E0E0E0E1C1C1C1C1C1C 1C1C38383838183818381C7007F00070007000E0E0C0E1C0818047003C00101A7C9114>I E /Fi 5 104 df<03C00FF01FF83FFC7FFE7FFEFFFFFFFFFFFFFFFF7FFE7FFE3FFC1FF80FF003 C010107E9115>15 D<0000030000000003000000000180000000018000000000C0000000006000 7FFFFFF000FFFFFFF8000000000E00000000070000000001E0000000007800000001E000000003 8000000006000000001C00FFFFFFF8007FFFFFF0000000006000000000C0000000018000000001 80000000030000000003000025187E952A>41 D<0000600000600000C00000C000018000018000 0180000300000300000600000600000C00000C0000180000180000180000300000300000600000 600000C00000C0000180000180000300000300000300000600000600000C00000C000018000018 0000300000300000300000600000600000C0000040000013287A9D00>54 D<003C00E001C00180038003800380038003800380038003800380038003800380038003000700 1C00F0001C00070003000380038003800380038003800380038003800380038003800380018001 C000E0003C0E297D9E15>102 DI E /Fj 57 123 df<3803807C07C0FE0FE0FF0FF0FF0FF07F07F03B03B00300300300300700700600600600600C 00C01C01C018018070070020020014117EA21D>34 D<387CFEFFFF7F3B03030706060C1C187020 08117C8610>44 DI<387CFEFEFE7C3807077C8610>I<00FE00 07FFC00F83E01F01F03E00F83E00F87C007C7C007C7C007CFC007CFC007EFC007EFC007EFC007E FC007EFC007EFC007EFC007EFC007EFC007EFC007EFC007EFC007E7C007C7C007C7C007C3E00F8 3E00F81F01F00F83E007FFC000FE0017207E9F1C>48 D<00180000780001F800FFF800FFF80001 F80001F80001F80001F80001F80001F80001F80001F80001F80001F80001F80001F80001F80001 F80001F80001F80001F80001F80001F80001F80001F80001F80001F80001F80001F8007FFFE07F FFE013207C9F1C>I<03FC000FFF003C1FC07007E07C07F0FE03F0FE03F8FE03F8FE01F87C01F8 3803F80003F80003F00003F00007E00007C0000F80001F00003E0000380000700000E01801C018 0380180700180E00380FFFF01FFFF03FFFF07FFFF0FFFFF0FFFFF015207D9F1C>I<00FE0007FF C00F07E01E03F03F03F03F81F83F81F83F81F81F03F81F03F00003F00003E00007C0001F8001FE 0001FF000007C00001F00001F80000FC0000FC3C00FE7E00FEFF00FEFF00FEFF00FEFF00FC7E01 FC7801F81E07F00FFFC001FE0017207E9F1C>I<0000E00001E00003E00003E00007E0000FE000 1FE0001FE00037E00077E000E7E001C7E00187E00307E00707E00E07E00C07E01807E03807E070 07E0E007E0FFFFFEFFFFFE0007E00007E00007E00007E00007E00007E00007E000FFFE00FFFE17 207E9F1C>I<1000201E01E01FFFC01FFF801FFF001FFE001FF8001BC000180000180000180000 18000019FC001FFF001E0FC01807E01803E00003F00003F00003F80003F83803F87C03F8FE03F8 FE03F8FC03F0FC03F07007E03007C01C1F800FFF0003F80015207D9F1C>I<001F8000FFE003F0 7007C0F00F01F81F01F83E01F83E01F87E00F07C00007C0000FC0800FC7FC0FCFFE0FD80F0FF00 F8FE007CFE007CFC007EFC007EFC007EFC007E7C007E7C007E7C007E3C007C3E007C1E00F80F00 F00783E003FFC000FF0017207E9F1C>I<6000007800007FFFFE7FFFFE7FFFFC7FFFF87FFFF87F FFF0E00060E000C0C00180C00300C00300000600000C00001C0000180000380000780000780000 F00000F00000F00001F00001F00001F00003F00003F00003F00003F00003F00003F00003F00001 E00017227DA11C>I<00FE0003FFC00703E00E00F01C00F01C00783C00783E00783F00783F8078 3FE0F01FF9E01FFFC00FFF8007FFC003FFE007FFF01E7FF83C1FFC7807FC7801FEF000FEF0003E F0001EF0001EF0001CF8001C7800383C00381F01F00FFFC001FF0017207E9F1C>I<01FE0007FF 800F83E01E01F03E00F07C00F87C0078FC007CFC007CFC007CFC007EFC007EFC007EFC007E7C00 FE7C00FE3E01FE1E037E0FFE7E07FC7E00207E00007C00007C1E007C3F00F83F00F83F00F03F01 E01E03C01C0F800FFE0003F80017207E9F1C>I<07FC001FFF00380F807007C0F807E0FC07E0FC 07E0FC07E07807E0000FC0001F80001F00003C0000780000700000E00000E00000C00000C00000 C00000C00000C00000C00000000000000000000000000000000001C00003E00007F00007F00007 F00003E00001C00013237DA21A>63 D<000070000000007000000000F800000000F800000000F8 00000001FC00000001FC00000003FE00000003FE00000003FE00000006FF000000067F0000000E 7F8000000C3F8000000C3F800000183FC00000181FC00000381FE00000300FE00000300FE00000 600FF000006007F00000E007F80000FFFFF80000FFFFF800018001FC00018001FC00038001FE00 030000FE00030000FE000600007F000600007F00FFE00FFFF8FFE00FFFF825227EA12A>65 DI<0003FE0080001FFF818000FF01E38001F8 003F8003E0001F8007C0000F800F800007801F800007803F000003803F000003807F000001807E 000001807E00000180FE00000000FE00000000FE00000000FE00000000FE00000000FE00000000 FE00000000FE000000007E000000007E000001807F000001803F000001803F000003801F800003 000F8000030007C000060003F0000C0001F800380000FF00F000001FFFC0000003FE000021227D A128>IIII72 DI76 DI<0007FC0000003FFF800000FC07E00003F001F80007E0 00FC000FC0007E001F80003F001F80003F003F00001F803F00001F807F00001FC07E00000FC07E 00000FC0FE00000FE0FE00000FE0FE00000FE0FE00000FE0FE00000FE0FE00000FE0FE00000FE0 FE00000FE0FE00000FE07E00000FC07F00001FC07F00001FC03F00001F803F80003F801F80003F 000FC0007E0007E000FC0003F001F80000FC07E000003FFF80000007FC000023227DA12A>79 DI82 D<01FC0407FF8C1F03FC3C007C7C003C78001C78001CF8000CF8000CFC00 0CFC0000FF0000FFE0007FFF007FFFC03FFFF01FFFF80FFFFC03FFFE003FFE0003FF00007F0000 3F00003FC0001FC0001FC0001FE0001EE0001EF0003CFC003CFF00F8C7FFE080FF8018227DA11F >I<7FFFFFFF807FFFFFFF807E03F80F807803F807807003F803806003F80180E003F801C0E003 F801C0C003F800C0C003F800C0C003F800C0C003F800C00003F800000003F800000003F8000000 03F800000003F800000003F800000003F800000003F800000003F800000003F800000003F80000 0003F800000003F800000003F800000003F800000003F800000003F800000003F800000003F800 000003F8000003FFFFF80003FFFFF80022227EA127>II87 D<0400400E00E0180180380380300300600600600600E0 0E00C00C00C00C00DC0DC0FE0FE0FF0FF0FF0FF07F07F03E03E01C01C014117AA21D>92 D<07FC001FFF803F07C03F03E03F01E03F01F01E01F00001F00001F0003FF003FDF01FC1F03F01 F07E01F0FC01F0FC01F0FC01F0FC01F07E02F07E0CF81FF87F07E03F18167E951B>97 DI<00FF8007FFE00F83 F01F03F03E03F07E03F07C01E07C0000FC0000FC0000FC0000FC0000FC0000FC00007C00007E00 007E00003E00301F00600FC0E007FF8000FE0014167E9519>I<0001FE000001FE0000003E0000 003E0000003E0000003E0000003E0000003E0000003E0000003E0000003E0000003E0000003E00 01FC3E0007FFBE000F81FE001F007E003E003E007E003E007C003E00FC003E00FC003E00FC003E 00FC003E00FC003E00FC003E00FC003E00FC003E007C003E007C003E003E007E001E00FE000F83 BE0007FF3FC001FC3FC01A237EA21F>I<00FE0007FF800F87C01E01E03E01F07C00F07C00F8FC 00F8FC00F8FFFFF8FFFFF8FC0000FC0000FC00007C00007C00007E00003E00181F00300FC07003 FFC000FF0015167E951A>I<003F8000FFC001E3E003C7E007C7E00F87E00F83C00F80000F8000 0F80000F80000F80000F8000FFFC00FFFC000F80000F80000F80000F80000F80000F80000F8000 0F80000F80000F80000F80000F80000F80000F80000F80000F80000F80000F80007FF8007FF800 13237FA211>I<03FC1E0FFF7F1F0F8F3E07CF3C03C07C03E07C03E07C03E07C03E07C03E03C03 C03E07C01F0F801FFF0013FC003000003000003800003FFF801FFFF00FFFF81FFFFC3800FC7000 3EF0001EF0001EF0001EF0001E78003C7C007C3F01F80FFFE001FF0018217E951C>II<1C003E007F007F007F003E001C 000000000000000000000000000000FF00FF001F001F001F001F001F001F001F001F001F001F00 1F001F001F001F001F001F001F001F00FFE0FFE00B247EA310>I107 DIII<00FE0007FFC00F83E01E00F03E00F87C007C7C00 7C7C007CFC007EFC007EFC007EFC007EFC007EFC007EFC007E7C007C7C007C3E00F81F01F00F83 E007FFC000FE0017167E951C>II114 D<0FF3003FFF00781F0060 0700E00300E00300F00300FC00007FE0007FF8003FFE000FFF0001FF00000F80C00780C00380E0 0380E00380F00700FC0E00EFFC00C7F00011167E9516>I<018000018000018000018000038000 0380000780000780000F80003F8000FFFF00FFFF000F80000F80000F80000F80000F80000F8000 0F80000F80000F80000F80000F80000F81800F81800F81800F81800F81800F830007C30003FE00 00F80011207F9F16>IIIII I<7FFFF07FFFF07C03E07007C0600FC0E01F80C01F00C03E00C07E0000FC0000F80001F00003F0 3007E03007C0300F80701F80703F00603E00E07C03E0FFFFE0FFFFE014167E9519>I E /Fk 44 127 df34 D<00C00001C00001C00001C00007F0001FFC003FFE007DCF0071C780E1C380E1C780E1C780F1C3 0079C0003FC0001FF00007FC0001FE0001CF0001C70061C380F1C380F1C380E1C38071C70079DF 003FFE001FF80007E00001C00001C00000C00011207E9C16>36 D<00E001E0038007000E001C00 1C0038003800700070007000E000E000E000E000E000E000E000E000E000700070007000380038 001C001C000E000700038001E000E00B217A9C16>40 DI45 D<70F8F8F8700505788416>I<000180000380000380000700000700000E00000E00001C00001C 0000380000380000700000700000E00000E00001C00001C0000380000380000700000700000E00 000E00001C00001C0000380000380000700000700000E00000E00000C0000011207E9C16>I<03 E0000FF8001FFC001E3C00380E00780F00700700700700E00380E00380E00380E00380E00380E0 0380E00380E00380F00780700700700700780F003C1E001E3C001FFC000FF80003E00011197E98 16>I<70F8F8F870000000000000000070F8F8F8700512789116>58 D<7FFF00FFFF80FFFF8000 0000000000000000000000000000FFFF80FFFF807FFF00110B7E9116>61 D<00F80003FC0007FE000F07001C3F80387F8078FF8071C3C071C3C0E381C0E381C0E381C0E381 C0E381C0E381C0E381C071C38071C38078FF00387E001C3C000F03C007FFC003FF0000FC001219 7E9816>64 D<00E00001F00001F00001B00001B00003B80003B80003B800031800071C00071C00 071C00071C00071C000E0E000E0E000FFE000FFE001FFF001C07001C07001C07007F1FC0FF1FE0 7F1FC013197F9816>I<7FFFC0FFFFC07FFFC01C01C01C01C01C01C01C01C01C00001C00001C1C 001C1C001FFC001FFC001FFC001C1C001C1C001C00001C00E01C00E01C00E01C00E01C00E07FFF E0FFFFE07FFFE013197F9816>69 D<7F1FC0FFBFE07F1FC01C07001C07001C07001C07001C0700 1C07001C07001FFF001FFF001FFF001C07001C07001C07001C07001C07001C07001C07001C0700 1C07007F1FC0FFBFE07F1FC013197F9816>72 D77 D<7FE000FFF8007FFC001C1E001C0F 001C07001C07001C07001C07001C0F001C1E001FFC001FF8001FFC001C1C001C0E001C0E001C0E 001C0E001C0E201C0E701C0E707F07E0FF87E07F03C014197F9816>82 D<07E3001FFF003FFF00 781F00F00700E00700E00700E00000F000007800003F80001FF00007FC0000FE00000F00000700 000380000380600380E00380E00700F80F00FFFE00FFFC00C7F00011197E9816>I<7F07F0FF8F F87F07F01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01C01 C01C01C01C01C01C01C01C01C00E03800E038007070007FF0003FE0000F8001519809816>85 D89 D<1FE0003FF0007FF800783C00300E00000E00000E0003FE001FFE003E0E00700E00 E00E00E00E00E00E00783E007FFFE03FE7E00F83E013127E9116>97 D<7E0000FE00007E00000E 00000E00000E00000E00000E3E000EFF000FFF800F83C00F00E00E00E00E00700E00700E00700E 00700E00700E00700E00E00F01E00F83C00FFF800EFF00063C001419809816>I<03F80FFC1FFE 3C1E780C7000E000E000E000E000E000F000700778073E0E1FFC0FF803F010127D9116>I<003F 00007F00003F0000070000070000070000070003C7000FF7001FFF003C1F00780F00700700E007 00E00700E00700E00700E00700E00700700F00700F003C1F001FFFE00FE7F007C7E014197F9816 >I<03E00FF81FFC3C1E780E7007E007FFFFFFFFFFFFE000E000700778073C0F1FFE0FFC03F010 127D9116>I<001F00007F8000FF8001E78001C30001C00001C0007FFF00FFFF00FFFF0001C000 01C00001C00001C00001C00001C00001C00001C00001C00001C00001C00001C0003FFE007FFF00 3FFE0011197F9816>I<03E3C007F7E00FFFE01C1CC0380E00380E00380E00380E00380E001C1C 000FF8001FF0001BE0003800001800001FFC001FFF003FFF807803C0E000E0E000E0E000E0E000 E07001C07C07C03FFF800FFE0003F800131C7F9116>I<7E0000FE00007E00000E00000E00000E 00000E00000E3C000EFE000FFF000F87800F03800E03800E03800E03800E03800E03800E03800E 03800E03800E03800E03807FC7F0FFE7F87FC7F01519809816>I<018003C003C0018000000000 000000007FC07FC07FC001C001C001C001C001C001C001C001C001C001C001C001C07FFFFFFF7F FF101A7D9916>I<7E0000FE00007E00000E00000E00000E00000E00000E7FE00E7FE00E7FE00E 0F000E1E000E3C000E78000EF0000FF0000FF8000FBC000F1E000E0E000E07000E07807F87F0FF CFF07F87F01419809816>107 DI I<7E3C00FEFE007FFF000F87800F03800E03800E03800E03800E03800E03800E03800E03800E03 800E03800E03807FC7F0FFE7F87FC7F01512809116>I<03E0000FF8001FFC003C1E00780F0070 0700E00380E00380E00380E00380E00380F00780700700780F003C1E001FFC000FF80003E00011 127E9116>I<7E3E00FEFF007FFF800F83C00F00E00E00E00E00700E00700E00700E00700E0070 0E00700E00E00F01E00F83C00FFF800EFF000E3C000E00000E00000E00000E00000E00000E0000 7FC000FFE0007FC000141B809116>I114 D<0FEC3FFC7FFCF03CE01CE01C70007F801FF007F8003C600EE00EF00EF81EFFFCFFF8C7E00F12 7D9116>I<0300000700000700000700000700007FFF00FFFF00FFFF0007000007000007000007 000007000007000007000007010007038007038007038007870003FE0001FC0000F80011177F96 16>I<7E1F80FE3F807E1F800E03800E03800E03800E03800E03800E03800E03800E03800E0380 0E03800E03800E0F800FFFF007FBF803E3F01512809116>I<7F1FC0FF1FE07F1FC01C07001E0F 000E0E000E0E000E0E00071C00071C00071C00071C0003B80003B80003B80001F00001F00000E0 0013127F9116>II<7F1FC07F3FC07F1FC0 0F1C00073C0003B80003F00001F00000E00001E00001F00003B800073C00071C000E0E007F1FC0 FF3FE07F1FC013127F9116>I<7F1FC0FF9FE07F1FC01C07000E07000E0E000E0E00070E00071C 00071C00039C00039C0003980001B80001B80000F00000F00000F00000E00000E00000E00001C0 0079C0007BC0007F80003F00003C0000131B7F9116>I<3FFFC07FFFC07FFFC0700780700F0070 1E00003C0000780001F00003E0000780000F00001E01C03C01C07801C0FFFFC0FFFFC0FFFFC012 127F9116>I<1C303F78FFF8F7E061C00D057C9816>126 D E /Fl 86 125 df<007E1F0001C1B1800303E3C00703C3C00E03C1800E01C0000E01C0000E01C0000E01C0000E 01C0000E01C000FFFFFC000E01C0000E01C0000E01C0000E01C0000E01C0000E01C0000E01C000 0E01C0000E01C0000E01C0000E01C0000E01C0000E01C0000E01C0000E01C0000E01C0007F87FC 001A1D809C18>11 D<007E0001C1800301800703C00E03C00E01800E00000E00000E00000E0000 0E0000FFFFC00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C0 0E01C00E01C00E01C00E01C00E01C07F87F8151D809C17>I<007FC001C1C00303C00703C00E01 C00E01C00E01C00E01C00E01C00E01C00E01C0FFFFC00E01C00E01C00E01C00E01C00E01C00E01 C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C00E01C07FCFF8151D809C17 >I<003F07E00001C09C18000380F018000701F03C000E01E03C000E00E018000E00E000000E00 E000000E00E000000E00E000000E00E00000FFFFFFFC000E00E01C000E00E01C000E00E01C000E 00E01C000E00E01C000E00E01C000E00E01C000E00E01C000E00E01C000E00E01C000E00E01C00 0E00E01C000E00E01C000E00E01C000E00E01C000E00E01C007FC7FCFF80211D809C23>I20 D<60F0F0F0F0F0F0F06060606060606060606060606000000000 0060F0F060041E7C9D0C>33 D<6060F0F0F8F86868080808080808101010102020404080800D0C 7F9C15>I<0080008007E01898308460824081C087C08FC08FC086E080F0807E803FC01FF00FF8 03FC00BE008E00876087F083F083E0838082408240842088189007E00080008010217E9E15>36 D<00E0000001900000030800000308000007080000070800000708000007080000071000000710 0000072000000740000003C03FE003800F00038006000380040005C0040009C0080010E0100030 E010006070200060702000E0384000E03C4000E01C8000E00F0020E0070020700780403009C040 1830E18007C03E001B1F7E9D20>38 D<60F0F8680808081010204080050C7C9C0C>I<00400080 0100020006000C000C0018001800300030007000600060006000E000E000E000E000E000E000E0 00E000E000E000E000E000600060006000700030003000180018000C000C000600020001000080 00400A2A7D9E10>I<800040002000100018000C000C0006000600030003000380018001800180 01C001C001C001C001C001C001C001C001C001C001C001C0018001800180038003000300060006 000C000C00180010002000400080000A2A7E9E10>I<60F0F0701010101020204080040C7C830C> 44 DI<60F0F06004047C830C>I<00010003000600060006000C000C00 0C0018001800180030003000300060006000C000C000C001800180018003000300030006000600 0C000C000C00180018001800300030003000600060006000C000C00010297E9E15>I<03C00C30 1818300C300C700E60066006E007E007E007E007E007E007E007E007E007E007E007E007E00760 066006700E300C300C18180C3007E0101D7E9B15>I<030007003F00C700070007000700070007 00070007000700070007000700070007000700070007000700070007000700070007000F80FFF8 0D1C7C9B15>I<07C01830201C400C400EF00FF80FF807F8077007000F000E000E001C001C0038 0070006000C00180030006010C01180110023FFE7FFEFFFE101C7E9B15>I<07E01830201C201C 781E780E781E381E001C001C00180030006007E00030001C001C000E000F000F700FF80FF80FF8 0FF00E401C201C183007E0101D7E9B15>I<000C00000C00001C00003C00003C00005C0000DC00 009C00011C00031C00021C00041C000C1C00081C00101C00301C00201C00401C00C01C00FFFFC0 001C00001C00001C00001C00001C00001C00001C0001FFC0121C7F9B15>I<300C3FF83FF03FC0 20002000200020002000200023E024302818301C200E000E000F000F000F600FF00FF00FF00F80 0E401E401C2038187007C0101D7E9B15>I<00F0030C06040C0E181E301E300C700070006000E3 E0E430E818F00CF00EE006E007E007E007E007E007600760077006300E300C18180C3003E0101D 7E9B15>I<4000007FFF807FFF007FFF0040020080040080040080080000100000100000200000 600000400000C00000C00001C00001800001800003800003800003800003800007800007800007 8000078000078000078000030000111D7E9B15>I<03E00C301008200C20066006600660067006 780C3E083FB01FE007F007F818FC307E601E600FC007C003C003C003C00360026004300C1C1007 E0101D7E9B15>I<03C00C301818300C700C600EE006E006E007E007E007E007E0076007700F30 0F18170C2707C700060006000E300C780C78187010203030C00F80101D7E9B15>I<60F0F06000 00000000000000000060F0F06004127C910C>I<60F0F0600000000000000000000060F0F07010 10101020204080041A7C910C>I<7FFFFFC0FFFFFFE00000000000000000000000000000000000 000000000000000000000000000000FFFFFFE07FFFFFC01B0C7E8F20>61 D<003F800000C0600003001800040004000800020010000100201F00802070808040E0404040C0 384041C038408180382083803820838038208380382083803820838038208180382041C0382040 C0384040E0784020709880201F0F00100000000800000004000000030001E000C01F80003FF000 1B1D7E9C20>64 D<000600000006000000060000000F0000000F0000000F000000178000001780 00001780000023C0000023C0000023C0000041E0000041E0000041E0000080F0000080F0000180 F8000100780001FFF80003007C0002003C0002003C0006003E0004001E0004001E000C001F001E 001F00FF80FFF01C1D7F9C1F>II<001F808000E0618001801980 070007800E0003801C0003801C00018038000180780000807800008070000080F0000000F00000 00F0000000F0000000F0000000F0000000F0000000F00000007000008078000080780000803800 00801C0001001C0001000E000200070004000180080000E03000001FC000191E7E9C1E>II< FFFFFC0F003C0F000C0F00040F00040F00060F00020F00020F02020F02000F02000F02000F0600 0FFE000F06000F02000F02000F02000F02010F00010F00020F00020F00020F00060F00060F000C 0F003CFFFFFC181C7E9B1C>II<001F808000E061800180198007 0007800E0003801C0003801C00018038000180780000807800008070000080F0000000F0000000 F0000000F0000000F0000000F0000000F000FFF0F0000F80700007807800078078000780380007 801C0007801C0007800E00078007000B800180118000E06080001F80001C1E7E9C21>III<1FFF00F8007800780078007800780078 00780078007800780078007800780078007800780078007800787078F878F878F878F0F040E021 C01F00101D7F9B15>IIIII<003F800000E0E0000380380007001C000E000E001C 0007003C00078038000380780003C0780003C0700001C0F00001E0F00001E0F00001E0F00001E0 F00001E0F00001E0F00001E0F00001E0700001C0780003C0780003C0380003803C0007801C0007 000E000E0007001C000380380000E0E000003F80001B1E7E9C20>II82 D<07E0801C1980300580700380600180E00180E00080E00080E00080F00000 F800007C00007FC0003FF8001FFE0007FF0000FF80000F800007C00003C00001C08001C08001C0 8001C0C00180C00180E00300D00200CC0C0083F800121E7E9C17>I<7FFFFFC0700F01C0600F00 C0400F0040400F0040C00F0020800F0020800F0020800F0020000F0000000F0000000F0000000F 0000000F0000000F0000000F0000000F0000000F0000000F0000000F0000000F0000000F000000 0F0000000F0000000F0000000F0000001F800003FFFC001B1C7F9B1E>IIII<7F F0FFC00FC03E000780180003C0180003E0100001E0200001F0600000F0400000788000007D8000 003D0000001E0000001F0000000F0000000F8000000F80000013C0000023E0000021E0000041F0 0000C0F8000080780001007C0003003C0002001E0006001F001F003F80FFC0FFF01C1C7F9B1F> II<7FFFF07C01F07001E06003C06003C0400780400F80400F00401E00001E00003C00007C00 00780000F00000F00001E00003E00003C0100780100780100F00101F00301E00203C00203C0060 7800E0F803E0FFFFE0141C7E9B19>II<0808101020204040404080808080 8080B0B0F8F8787830300D0C7A9C15>II<1FC000307000783800781C0030 1C00001C00001C0001FC000F1C00381C00701C00601C00E01C40E01C40E01C40603C40304E801F 870012127E9115>97 DI<07E00C301878307870306000E0 00E000E000E000E000E00060007004300418080C3007C00E127E9112>I<003F00000700000700 00070000070000070000070000070000070000070000070003E7000C1700180F00300700700700 600700E00700E00700E00700E00700E00700E00700600700700700300700180F000C370007C7E0 131D7E9C17>I<03E00C301818300C700E6006E006FFFEE000E000E000E0006000700230021804 0C1803E00F127F9112>I<00F8018C071E061E0E0C0E000E000E000E000E000E00FFE00E000E00 0E000E000E000E000E000E000E000E000E000E000E000E000E000E007FE00F1D809C0D>I<0003 8003C4C00C38C01C3880181800381C00381C00381C00381C001818001C38000C300013C0001000 003000001800001FF8001FFF001FFF803003806001C0C000C0C000C0C000C06001803003001C0E 0007F800121C7F9215>II<18003C003C00180000000000 00000000000000000000FC001C001C001C001C001C001C001C001C001C001C001C001C001C001C 001C001C00FF80091D7F9C0C>I<00C001E001E000C000000000000000000000000000000FE000 E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E000E0 60E0F0C0F1C061803E000B25839C0D>IIII< FC7C001C87001D03001E03801C03801C03801C03801C03801C03801C03801C03801C03801C0380 1C03801C03801C03801C0380FF9FF014127F9117>I<03F0000E1C001806003003007003806001 80E001C0E001C0E001C0E001C0E001C0E001C06001807003803003001806000E1C0003F0001212 7F9115>II<03C1000C3300180B00300F00700700700700E00700E00700E00700 E00700E00700E00700600700700700300F00180F000C370007C700000700000700000700000700 000700000700000700003FE0131A7E9116>II<1F9030704030C010C010E010F8007F80 3FE00FF000F880388018C018C018E010D0608FC00D127F9110>I<04000400040004000C000C00 1C003C00FFE01C001C001C001C001C001C001C001C001C001C101C101C101C101C100C100E2003 C00C1A7F9910>IIII<7F8FF00F03800F030007020003840001C80001D80000F00000 700000780000F800009C00010E00020E000607000403801E07C0FF0FF81512809116>II<7FFC70386038407040F040E041C003C0038007000F040E041C043C0C380870087038FF F80E127F9112>III E /Fm 42 127 df<00C00000C00007F0001FFC003CCE0070C30060C300E0C780E0CF80E0CF80F0 CF80F8C700FEC0007FE0007FF8003FFC001FFE000FFF0003FF0000DF8020CF8070C780F8C380F8 C380F0C380C0C30060C70070C60038DE001FF80007E00000C00000C00011217D9E18>36 D45 D<000180000380000380000700000700000700000E0000 0E00001C00001C00001C0000380000380000380000700000700000E00000E00000E00001C00001 C00001C0000380000380000380000700000700000E00000E00000E00001C00001C00001C000038 0000380000700000700000700000E00000E00000C0000011297D9E18>47 D<00600001E0000FE000FFE000F3E00003E00003E00003E00003E00003E00003E00003E00003E0 0003E00003E00003E00003E00003E00003E00003E00003E00003E00003E00003E00003E0007FFF 807FFF80111B7D9A18>49 D<00038000000380000007C0000007C0000007C000000FE000000FE0 00001FF000001BF000001BF0000031F8000031F8000061FC000060FC0000E0FE0000C07E0000C0 7E0001803F0001FFFF0003FFFF8003001F8003001F8006000FC006000FC00E000FE00C0007E0FF C07FFEFFC07FFE1F1C7E9B24>65 DI<001FE02000FFF8E003F80FE007C003E00F8001E01F00 00E03E0000E03E0000607E0000607C000060FC000000FC000000FC000000FC000000FC000000FC 000000FC000000FC0000007C0000607E0000603E0000603E0000C01F0000C00F80018007C00300 03F80E0000FFFC00001FE0001B1C7D9B22>III73 D76 DI80 D82 D<07F8201FFEE03C07E07801E07000E0F000E0F00060F00060F80000FE0000 FFE0007FFE003FFF003FFF800FFFC007FFE0007FE00003F00001F00000F0C000F0C000F0C000E0 E000E0F001C0FC03C0EFFF0083FC00141C7D9B1B>I<7FFFFFE07FFFFFE0781F81E0701F80E060 1F8060E01F8070C01F8030C01F8030C01F8030C01F8030001F8000001F8000001F8000001F8000 001F8000001F8000001F8000001F8000001F8000001F8000001F8000001F8000001F8000001F80 00001F8000001F800007FFFE0007FFFE001C1C7E9B21>I86 D<7FFFFC7FFFFC7E01F87803F87003F0E007E0E007E0C00F C0C01FC0C01F80003F00007F00007E0000FC0000FC0001F80003F80603F00607E0060FE0060FC0 0E1F800E1F801C3F001C7F003C7E00FCFFFFFCFFFFFC171C7D9B1D>90 D<0FF8001C1E003E0F80 3E07803E07C01C07C00007C0007FC007E7C01F07C03C07C07C07C0F807C0F807C0F807C0780BC0 3E13F80FE1F815127F9117>97 DI<03FC000E0E001C1F00 3C1F00781F00780E00F80000F80000F80000F80000F80000F800007800007801803C01801C0300 0E0E0003F80011127E9115>I<000FF0000FF00001F00001F00001F00001F00001F00001F00001 F00001F00001F001F9F00F07F01C03F03C01F07801F07801F0F801F0F801F0F801F0F801F0F801 F0F801F07801F07801F03C01F01C03F00F0FFE03F9FE171D7E9C1B>I<01FC000F07001C03803C 01C07801C07801E0F801E0F801E0FFFFE0F80000F80000F800007800007C00603C00601E00C00F 038001FC0013127F9116>I<007F0001E38003C7C00787C00F87C00F83800F80000F80000F8000 0F80000F8000FFF800FFF8000F80000F80000F80000F80000F80000F80000F80000F80000F8000 0F80000F80000F80000F80000F80007FF8007FF800121D809C0F>I<03F8F00E0F381E0F381C07 303C07803C07803C07803C07801C07001E0F000E0E001BF8001000001800001800001FFF001FFF C00FFFE01FFFF07801F8F00078F00078F000787000707800F01E03C007FF00151B7F9118>II<1E003F003F003F003F001E00000000000000000000000000 FF00FF001F001F001F001F001F001F001F001F001F001F001F001F001F001F00FFE0FFE00B1E7F 9D0E>I107 DIII<01FC000F07801C01C03C01E07800F07800F0F800F8F800F8F800F8F8 00F8F800F8F800F87800F07800F03C01E01E03C00F078001FC0015127F9118>I I114 D<1FD830786018E018E018F000FF80 7FE07FF01FF807FC007CC01CC01CE01CE018F830CFC00E127E9113>I<03000300030003000700 07000F000F003FFCFFFC1F001F001F001F001F001F001F001F001F001F0C1F0C1F0C1F0C0F0807 9803F00E1A7F9913>III120 DI<3FFF803C1F00303F00303E00607C0060FC0060F80001F00003F00007E00007 C1800F81801F81801F03803E03007E07007C0F00FFFF0011127F9115>I<1E023FFC7FF880F00F 047C9C18>126 D E /Fn 32 123 df<0E1E1E1E1E02020404080810204080070F7D840F>44 D<0000030000000300000007000000070000000F0000000F0000001F0000002F0000002F000000 4F0000004F80000087800000878000010780000207800002078000040780000407800008078000 080780001007800030078000200780007FFF80004007C0008007C0008003C0010003C0030003C0 020003C0040003C0040003C00C0003C03C0007C0FF003FFC1E237DA224>65 D<00007F00800003808100000E00630000380027000070001F0000E0000E0001C0000E00038000 0E000700000E000F000004000E000004001E000004003C000004003C0000080078000000007800 0000007800000000F000000000F000000000F000000000F000000000F000000000E000000000E0 00002000E000002000E000004000E000004000F000008000700000800070000100003800020000 18000400001C0008000006003000000381C0000000FE000000212479A223>67 D<00FFFFF000000F003C00000F000E00000F000700001E000380001E000380001E0001C0001E00 01C0003C0001C0003C0001E0003C0001E0003C0001E000780001E000780001E000780001E00078 0001E000F00003C000F00003C000F00003C000F00003C001E000078001E000078001E000070001 E0000F0003C0000E0003C0001C0003C0003C0003C00038000780007000078000E000078001C000 07800700000F801C0000FFFFF0000023227DA125>I<00FFFFFF80000F000780000F000180000F 000180001E000180001E000180001E000100001E000100003C000100003C000100003C01010000 3C01000000780200000078020000007806000000780E000000FFFC000000F00C000000F00C0000 00F00C000001E008000001E008000001E008040001E000080003C000080003C000080003C00010 0003C000100007800020000780006000078000C000078001C0000F8007C000FFFFFF800021227D A121>I<00FF800007FC000F80000F80000F80001780000F80001780001780002F000013C0002F 000013C0004F000013C0008F000023C0009E000023C0011E000023C0011E000023C0021E000043 C0043C000043C0043C000043C0083C000041E0083C000081E01078000081E02078000081E02078 000081E04078000101E040F0000101E080F0000101E100F0000101E100F0000200F201E0000200 F201E0000200F401E0000200F801E0000400F803C0000400F003C0000400F003C0000C00E003C0 001E00C007C000FFC0C07FFC002E227DA12C>77 D<00FFFFC0000F0070000F003C000F001C001E 000E001E000E001E000F001E000F003C001E003C001E003C001E003C003C007800380078007000 7801E00078078000FFFC0000F00E0000F0070000F0038001E003C001E003C001E003C001E003C0 03C0078003C0078003C0078003C0078007800F0007800F0107800F01078007020F800702FFF803 8C000000F020237DA124>82 D<0001F020000E0C40001802C0003001C0006001C000E0018000C0 018001C0018001C0018003C0010003C0010003C0000003C0000003E0000001F8000001FF000000 FFE000007FF000001FF8000003FC0000007C0000003C0000001E0000001E0000001E0020001C00 20001C0020001C00200018006000380060003000700060007000C000C8018000C607000081FC00 001B247DA21B>I<1FFFFFF81E03C0381803C0183003C018200780182007801840078010400780 10400F0010800F0010800F0010000F0000001E0000001E0000001E0000001E0000003C0000003C 0000003C0000003C00000078000000780000007800000078000000F0000000F0000000F0000000 F0000001E0000001E0000001E0000001E0000003E00000FFFF00001D2277A123>I<3FFE03FF03 C0007803C0006003C00020078000400780004007800040078000400F0000800F0000800F000080 0F0000801E0001001E0001001E0001001E0001003C0002003C0002003C0002003C000200780004 0078000400780004007800040070000800F0000800F00010007000100070002000700040003000 400038018000180200000E0C000003F00000202377A124>I<007FFFFE007E001E0078003C0060 007800C000F000C001E0008003E0008003C00100078001000F0001001E0000003C0000007C0000 0078000000F0000001E0000003C00000078000000F8000000F0000001E0000003C004000780040 00F0008001F0008001E0008003C00100078001000F0003001E0006001E0006003C001E0078007C 00FFFFFC001F227DA11E>90 D<00F8C00185C00705C00E03800E03801C03803C03803807007807 00780700780700F00E00F00E00F00E00F00E10F01C20701C20703C20305C40308C400F07801415 7B9419>97 D<03C03F8003800380038007000700070007000E000E000E000E001C001CF81D0C1E 0E3C0638073807380F700F700F700F700FE01EE01EE01EE03CE038E038607060E031C01F001023 7BA216>I<007E0001C1000301800703800E07801C07803C0000380000780000780000780000F0 0000F00000F00000F00000F00100700100700200300C001830000FC00011157B9416>I<00003C 0003F80000380000380000380000700000700000700000700000E00000E00000E00000E00001C0 00F9C00185C00705C00E03800E03801C03803C0380380700780700780700780700F00E00F00E00 F00E00F00E10F01C20701C20703C20305C40308C400F078016237BA219>I<00F803840E021C02 3C0238027804F018FFE0F000F000E000E000E000E000E002E0026004701830600F800F157A9416 >I<001F180030B800E0B801C07001C0700380700780700700E00F00E00F00E00F00E01E01C01E 01C01E01C01E01C01E03800E03800E0780060B8006170001E700000700000700000E00000E0000 0E00701C00F01800F0300060E0003F8000151F7E9416>103 D<00C001E001C001C00000000000 00000000000000000000001C002300430043008700870087000E000E001C001C001C0038003800 3840708070807080710032001C000B217BA00F>105 D<00F0000FE00000E00000E00000E00001 C00001C00001C00001C0000380000380000380000380000700000701E0070210070C700E10F00E 10F00E20600E40001D80001E00001FC0001C7000383800383800381C00381C2070384070384070 3840701880E01880600F0014237DA216>107 D<01E01FC001C001C001C0038003800380038007 000700070007000E000E000E000E001C001C001C001C0038003800380038007000700070007100 E200E200E200E200640038000B237CA20C>I<1C0F80F8002610C10C0047606606008780780700 8780780700870070070087007007000E00E00E000E00E00E000E00E00E000E00E00E001C01C01C 001C01C01C001C01C01C001C01C038203803803840380380704038038070803803803080700700 31003003001E0023157B9428>I<1C0F002631C04740C08780E08780E08700E08700E00E01C00E 01C00E01C00E01C01C03801C03801C03801C0704380708380E08380E103806107006203003C016 157B941B>I<007E0001C3000381800701C00E01C01C01E03C01E03801E07801E07801E07801E0 F003C0F003C0F00380F00780700700700E00700C0030180018700007C00013157B9419>I<01C1 F002621804741C08780C08700E08700E08701E00E01E00E01E00E01E00E01E01C03C01C03C01C0 3C01C07803807003807003C0E003C1C0072380071E000700000700000E00000E00000E00000E00 001C00001C00001C0000FFC000171F7F9419>I<1C1F002620804741C08783C08703C087018087 00000E00000E00000E00000E00001C00001C00001C00001C000038000038000038000038000070 000030000012157B9415>114 D<00FC000183000200800401800C03800C03000C00000F00000F F00007FC0003FE00003E00000F00000700700700F00600F00600E004004008002030001FC00011 157D9414>I<00C001C001C001C001C003800380038003800700FFF8070007000E000E000E000E 001C001C001C001C003800380038003810702070207040708031001E000D1F7C9E10>I<1E0060 2300E04380E04381C08381C08701C08701C00703800E03800E03800E03801C07001C07001C0700 1C07081C0E10180E101C0E101C1E200C262007C3C015157B941A>I<1E03802307C04387C04383 C08381C08700C08700C00700800E00800E00800E00801C01001C01001C01001C02001C02001C04 001C08001C08000C300003C00012157B9416>I<03C1E0046210083470103CF02038F020386020 380000700000700000700000700000E00000E00000E00000E02061C040F1C040F1C080E2C10044 6200383C0014157D9416>120 D<1E00302300704380704380E08380E08700E08700E00701C00E 01C00E01C00E01C01C03801C03801C03801C03801C07001C07001C07001C0F000C3E0003CE0000 0E00000E00001C00601C00F03800F03000E0600080C0004380003E0000141F7B9418>I<01E020 03F06007F8C0041F80080100080200000400000800001000002000004000008000010000020000 0400800801001003003F060061FC0040F80080700013157D9414>I E /Fo 23 119 df<00038000000380000003800000038000001FF00000FFFE0003FFFF0007E38FC00F03 83E01E0380F03C0380703C038038780380F8780381FCF80383FCF80387FCF80387FCFC0387FCFC 0387FCFE0383F8FF0381F0FFC380007FFB80007FFFC0003FFFF8003FFFFE001FFFFF000FFFFF80 07FFFFC003FFFFE001FFFFF0007FFFF0000FFFF80003FFF800038FF8000383FC3E0381FC7F0380 FCFF8380FCFF83807CFF83807CFF83807CFF03807CFE0380787C038078700380F8780380F03803 80E01C0381E00F0387C007E39F8003FFFF0000FFFC00001FE00000038000000380000003800000 0380001E3A7BB529>36 D<1F003F807FC0FFE0FFE0FFE0FFE0FFE07FC03F801F00000000000000 00000000000000000000000000001F003F807FC0FFE0FFE0FFE0FFE0FFE07FC03F801F000B207A 9F17>58 D68 DII72 D76 DI<00000FFE0000000000 FFFFE000000007FFFFFC0000001FFC07FF0000003FE000FF800000FF80003FE00001FF00001FF0 0003FE00000FF80007FC000007FC0007FC000007FC000FF8000003FE001FF8000003FF001FF000 0001FF003FF0000001FF803FF0000001FF803FF0000001FF807FE0000000FFC07FE0000000FFC0 7FE0000000FFC0FFE0000000FFE0FFE0000000FFE0FFE0000000FFE0FFE0000000FFE0FFE00000 00FFE0FFE0000000FFE0FFE0000000FFE0FFE0000000FFE0FFE0000000FFE0FFE0000000FFE0FF E0000000FFE07FE0000000FFC07FE0000000FFC07FF0000001FFC07FF0000001FFC03FF0000001 FF803FF0000001FF801FF8000003FF001FF8000003FF000FFC000007FE000FFC000007FE0007FE 00000FFC0003FF00001FF80001FF80003FF00000FFC0007FE000003FE000FF8000001FFC07FF00 000007FFFFFC00000000FFFFE0000000000FFE00000033317BB03E>79 D<001FF0018000FFFF03 8003FFFFC78007F00FFF800F8001FF801F00007F803F00001F803E00000F807E00000F807E0000 0780FE00000780FE00000780FE00000380FF00000380FF00000380FF80000000FFE00000007FFC 0000007FFFE000007FFFFE00003FFFFFC0001FFFFFF0001FFFFFF8000FFFFFFC0003FFFFFE0001 FFFFFF00007FFFFF80001FFFFF800000FFFFC0000007FFC0000000FFE00000003FE00000003FE0 0000001FE06000001FE0E000000FE0E000000FE0E000000FE0E000000FC0F000000FC0F000000F C0F800001F80FC00001F80FF00003F00FFC0007E00FFFC01FC00F1FFFFF800E03FFFE000C007FF 000023317BB02E>83 D89 D<007FF8000003FFFF000007FFFFC0000FE01FE0 001FF007F0001FF003F8001FF003FC001FF001FE000FE001FE0007C001FE00010001FE00000001 FE00000001FE000001FFFE00003FFFFE0001FFF1FE0007FE01FE000FF001FE001FC001FE003F80 01FE007F8001FE00FF0001FE00FF0001FE00FF0001FE00FF0001FE00FF0003FE007F8003FE007F C00EFE003FF03CFF000FFFF87FF807FFF03FF800FF800FF825207E9F28>97 D<0007FC0000003FFF800000FFFFE00003FC07F00007F801F8000FE000FC001FE0007E003FC000 7E003FC0003F007FC0003F007F80003F007F80003F80FF80003F80FF80003F80FFFFFFFF80FFFF FFFF80FFFFFFFF80FF80000000FF80000000FF800000007F800000007F800000003FC00000003F C00003801FC00003801FE00007800FF0000F0007F8001E0003FE00FC0000FFFFF800003FFFE000 0003FF000021207E9F26>101 D<001FF007E000FFFE3FF001FFFF7FF807F83FF1F80FE00FE1F8 0FE00FE0F01FC007F0601FC007F0003FC007F8003FC007F8003FC007F8003FC007F8003FC007F8 001FC007F0001FC007F0000FE00FE0000FE00FE00007F83FC00007FFFF000006FFFE00000E1FF0 00000E000000001E000000001E000000001F000000001F800000001FFFFFC0000FFFFFF8000FFF FFFE0007FFFFFF0003FFFFFF8007FFFFFFC01FFFFFFFE03F00007FE07E00000FF0FC000007F0FC 000003F0FC000003F0FC000003F0FC000003F07E000007E03F00000FC01FC0003F800FF801FF00 07FFFFFE0000FFFFF000001FFF8000252F7E9F29>103 D<01C00007F0000FF8000FF8001FFC00 1FFC001FFC000FF8000FF80007F00001C000000000000000000000000000000000000000000000 00000001F800FFF800FFF800FFF8000FF80007F80007F80007F80007F80007F80007F80007F800 07F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F800 07F80007F80007F80007F800FFFF80FFFF80FFFF8011337DB217>105 D<01F800FFF800FFF800 FFF8000FF80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F800 07F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F800 07F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F800 07F80007F80007F80007F80007F800FFFFC0FFFFC0FFFFC012327DB117>108 D<03F007F8000FF000FFF03FFF007FFE00FFF07FFF80FFFF00FFF0F03FC1E07F800FF1C01FE380 3FC007F3000FE6001FC007F6000FFC001FE007FE000FFC001FE007FC000FF8001FE007FC000FF8 001FE007F8000FF0001FE007F8000FF0001FE007F8000FF0001FE007F8000FF0001FE007F8000F F0001FE007F8000FF0001FE007F8000FF0001FE007F8000FF0001FE007F8000FF0001FE007F800 0FF0001FE007F8000FF0001FE007F8000FF0001FE007F8000FF0001FE007F8000FF0001FE007F8 000FF0001FE007F8000FF0001FE007F8000FF0001FE007F8000FF0001FE007F8000FF0001FE0FF FFC1FFFF83FFFFFFFFC1FFFF83FFFFFFFFC1FFFF83FFFF40207D9F45>I<03F007F80000FFF03F FF0000FFF07FFF8000FFF0F03FC0000FF1C01FE00007F3000FE00007F6000FF00007FE000FF000 07FC000FF00007FC000FF00007F8000FF00007F8000FF00007F8000FF00007F8000FF00007F800 0FF00007F8000FF00007F8000FF00007F8000FF00007F8000FF00007F8000FF00007F8000FF000 07F8000FF00007F8000FF00007F8000FF00007F8000FF00007F8000FF00007F8000FF00007F800 0FF00007F8000FF000FFFFC1FFFF80FFFFC1FFFF80FFFFC1FFFF8029207D9F2E>I<0007FE0000 003FFFC00000FFFFF00003FC03FC0007F000FE000FE0007F001FC0003F803FC0003FC03FC0003F C07F80001FE07F80001FE07F80001FE0FF80001FF0FF80001FF0FF80001FF0FF80001FF0FF8000 1FF0FF80001FF0FF80001FF0FF80001FF07F80001FE07F80001FE07F80001FE03FC0003FC03FC0 003FC01FE0007F800FE0007F0007F801FE0003FE07FC0001FFFFF800003FFFC0000007FE000024 207E9F29>I<03F03F00FFF07FC0FFF1FFE0FFF3C7F00FF38FF807F70FF807F60FF807FE0FF807 FC07F007FC03E007FC008007F8000007F8000007F8000007F8000007F8000007F8000007F80000 07F8000007F8000007F8000007F8000007F8000007F8000007F8000007F8000007F8000007F800 0007F80000FFFFE000FFFFE000FFFFE0001D207E9F22>114 D<00380000380000380000380000 380000780000780000780000F80000F80001F80003F80007F8001FF800FFFFFEFFFFFEFFFFFE07 F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007F80007 F80007F80007F80007F80707F80707F80707F80707F80707F80707F80703F80E03FC0E01FE1C00 FFF8007FF0000FE0182E7EAD20>116 D<01F80003F000FFF801FFF000FFF801FFF000FFF801FF F0000FF8001FF00007F8000FF00007F8000FF00007F8000FF00007F8000FF00007F8000FF00007 F8000FF00007F8000FF00007F8000FF00007F8000FF00007F8000FF00007F8000FF00007F8000F F00007F8000FF00007F8000FF00007F8000FF00007F8000FF00007F8000FF00007F8000FF00007 F8000FF00007F8001FF00007F8001FF00003F8003FF00003F8006FF00001FE03CFF80000FFFF8F FF80007FFF0FFF80000FFC0FFF8029207D9F2E>II E end %%EndProlog %%BeginSetup %%Feature: *Resolution 300 TeXDict begin %%EndSetup %%Page: 1 1 bop 193 216 a Fo(HLFSD:)26 b(Deliv)n(ering)h(Email)g(to)h(Y)-7 b(our)28 b($HOME)280 336 y Fn(Er)n(ez)17 b(Zadok,)g(Computer)h(Scienc)n(e)h (Dep)n(artment,)e(Columbia)h(University)482 394 y(A)o(lexander)h(Dupuy,)e (System)h(Management)h(AR)l(TS)841 541 y Fm(ABSTRA)o(CT)241 628 y Fl(W)m(e)12 b(consider)h(the)g(problem)e(of)h(enabling)g(users)i(to)e (access)i(their)f(mailb)q(o)o(x)d(\014les)i(from)f(an)o(y)h(host)179 678 y(on)k(our)h(lo)q(cal)f(net)o(w)o(ork,)h(and)f(not)h(only)f(on)g(one)h (designated)g(\\home)f(mac)o(hine".)25 b(W)m(e)16 b(require)h(a)179 728 y(solution)11 b(whic)o(h)g(will)f(not)i(in)o(tro)q(duce)g(an)o(y)f(new)h (single)g(p)q(oin)o(ts)f(of)g(failure,)g(force)h(us)g(to)g(mo)q(dify)d(mail) 179 778 y(transfer)16 b(agen)o(ts)f(and)g(user)i(agen)o(ts,)e(or)g(require)h (c)o(hanges)g(to)f(the)h(op)q(erating)f(system)g(k)o(ernels.)22 b(In)179 828 y(other)15 b(w)o(ords,)g(minim)o(ize)e(the)i(amoun)o(t)e(of)h(w) o(ork)h(needed)h(b)o(y)e(system-administrators)g(and)g(users.)179 877 y(Our)i(solution)e(is)h(to)h(deliv)o(er)f(mail)e(in)o(to)h(the)i(users')h (home)d(directories,)i(whic)o(h)g(are)f(exp)q(orted)i(via)179 927 y(NFS[20)o(,)g(25])f(to)i(all)e(of)h(the)h(mac)o(hines)e(on)h(our)h(net)o (w)o(ork.)29 b(W)m(e)17 b(wrote)h(a)f(small)e(user-lev)o(el)j(NFS)179 977 y(serv)o(er)d(implemen)o(ting)c(a)j(single)f(sym)o(b)q(olic)f(link)h (that)h(references)j(the)e(home)e(directory)h(of)g(a)g(user,)179 1027 y(either)h(the)g(one)g(who)f(accessed)j(it,)c(or)i(b)o(y)f(name,)f(with) h(a)g(fallbac)o(k)f(reference)k(in)d(case)h(of)f(failures.)179 1077 y(This)d(enables)h(electronic)g(mail)d(to)i(b)q(e)h(deliv)o(ered)g (directly)g(in)o(to)e(the)i(user's)g(home)f(directory)m(,)g(whic)o(h)179 1126 y(is)f(already)h(accessible)h(from)d(an)o(y)h(mac)o(hine)g(on)h(the)g (net)o(w)o(ork.)17 b(Although)10 b(w)o(e)i(ha)o(v)o(e)e(used)i(our)f(serv)o (er)179 1176 y(primarily)f(for)i(mail)e(deliv)o(ery)j(redirection,)g(it)f (can)h(b)q(e)g(used)h(to)e(redirect)i(sp)q(o)q(oled)f(faxes,)g(access)h(to) 179 1226 y Fk(/tmp)p Fl(,)e(etc.)75 1345 y Fj(1)56 b(In)n(tro)r(duction)175 1420 y Fl(Electronic)16 b(mail)e(has)i(b)q(ecome)g(one)g(of)f(the)i(ma)r(jor) d(applications)h(for)h(man)o(y)e(computer)i(net)o(w)o(orks,)g(and)75 1470 y(use)k(of)f(this)g(service)h(is)f(exp)q(ected)j(to)d(increase)h(o)o(v)o (er)f(time,)g(as)g(net)o(w)o(orks)h(proliferate)f(and)g(b)q(ecome)g(faster.) 75 1520 y(Pro)o(viding)10 b(a)h(con)o(v)o(enien)o(t)h(en)o(vironmen)o(t)f (for)g(users)i(to)e(read,)h(comp)q(ose,)f(and)g(send)h(electronic)h(mail)c (has)i(b)q(ecome)75 1570 y(a)j(requiremen)o(t)f(for)h(systems)g (administrators)e(\(SAs\).)175 1644 y(Widely)j(used)j(metho)q(ds)d(for)i (handling)e(mail)f(usually)h(require)j(users)f(to)g(b)q(e)g(logged)e(in)o(to) h(a)g(designated)75 1694 y(\\home")e(mac)o(hine,)f(where)k(their)e(mailb)q(o) o(x)e(\014les)i(reside.)23 b(Only)15 b(on)g(that)h(one)f(mac)o(hine)f(can)i (they)f(read)h(newly)75 1744 y(arriv)o(ed)i(mail.)28 b(Since)19 b(users)g(ha)o(v)o(e)f(to)g(b)q(e)h(logged)e(in)o(to)g(that)h(system)g(to)g (read)h(their)f(mail,)e(they)j(often)f(\014nd)75 1794 y(it)h(con)o(v)o(enien) o(t)h(to)g(run)g(all)f(of)g(their)h(other)g(pro)q(cesses)j(on)c(that)h (system)f(as)h(w)o(ell,)g(including)f(memory)e(and)75 1844 y(CPU-in)o(tensiv)o(e)j(jobs.)34 b(F)m(or)19 b(example,)g(in)g(our)g (departmen)o(t,)h(w)o(e)g(ha)o(v)o(e)f(allo)q(cated)g(and)g(con\014gured)h (sev)o(eral)75 1893 y(m)o(ulti-pro)q(cessor)11 b(serv)o(ers)i(to)e(handle)g (suc)o(h)i(demanding)c(CPU)q(/memory)f(applications,)j(but)g(these)i(w)o(ere) f(under-)75 1943 y(utilized,)k(in)g(large)g(part)g(due)h(to)f(the)g(incon)o (v)o(enience)i(of)d(not)h(b)q(eing)g(able)g(to)g(read)h(mail)c(on)j(those)h (mac)o(hines.)75 1993 y(\(No)h(home)e(directories)j(w)o(ere)g(lo)q(cated)f (on)f(these)i(designated)g(CPU-serv)o(ers,)h(since)f(w)o(e)e(did)h(not)f(w)o (an)o(t)h(NFS)75 2043 y(service)g(for)f(users')g(home)f(directories)i(to)f (ha)o(v)o(e)f(to)h(comp)q(ete)g(with)f(in)o(tensiv)o(e)h(jobs.)27 b(A)o(t)17 b(the)g(same)f(time,)g(w)o(e)75 2093 y(discouraged)e(users)i(from) c(running)h(demanding)g(applications)f(on)i(their)g(home)f(mac)o(hines.\))175 2167 y(Man)o(y)k(di\013eren)o(t)h(solutions)f(ha)o(v)o(e)h(b)q(een)h(prop)q (osed)f(to)f(allo)o(w)f(users)j(to)f(read)g(their)g(mail)d(on)i(an)o(y)g (host.)75 2217 y(Ho)o(w)o(ev)o(er,)d(all)e(of)i(these)h(solutions)f(fail)e (in)h(one)h(or)g(more)f(of)g(sev)o(eral)i(w)o(a)o(ys:)137 2328 y Fi(\017)21 b Fl(they)14 b(in)o(tro)q(duce)h(new)f(single)g(p)q(oin)o(ts)f (of)h(failure)137 2409 y Fi(\017)21 b Fl(they)14 b(require)h(using)f (di\013eren)o(t)g(mail)e(transfer)i(agen)o(ts)h(\(MT)m(As\)[15)o(])e(or)h (user)h(agen)o(ts)g(\(UAs\))137 2490 y Fi(\017)21 b Fl(they)16 b(do)f(not)g(solv)o(e)g(the)h(problem)e(for)h(all)f(cases,)i(i.e.)22 b(the)16 b(solution)e(is)h(only)g(partially)e(successful)k(for)e(a)179 2539 y(particular)e(en)o(vironmen)o(t.)175 2650 y(W)m(e)e(ha)o(v)o(e)h (designed)g(a)f(simple)g(\014lesystem,)g(called)h(the)g Fh(Home-Link)h(File)f (System)p Fl(,)g(to)g(pro)o(vide)f(the)i(abilit)o(y)75 2700 y(to)d(deliv)o(er)h(mail)d(to)i(users')h(home)e(directories,)j(without)e(mo)q (di\014cation)f(to)h(mail-related)e(applications.)16 b(W)m(e)10 b(ha)o(v)o(e)p eop %%Page: 2 2 bop 75 42 a Fl(endea)o(v)o(ored)15 b(to)e(mak)o(e)f(it)i(as)f(stable)h(as)g (p)q(ossible.)k(Of)c(great)g(imp)q(ortance)f(to)g(us)h(w)o(as)g(to)f(mak)o(e) g(sure)h(the)h(HLFS)75 91 y(daemon,)10 b Fk(hlfsd)o Fl(,)h(w)o(ould)g(not)g (hang)g(under)h(an)o(y)f(circumstances,)h(and)f(w)o(ould)f(tak)o(e)i(the)g (next-b)q(est)h(action)d(when)75 141 y(faced)16 b(with)g(problems.)24 b(Compared)15 b(to)g(alternativ)o(e)h(metho)q(ds,)g Fk(hlfsd)f Fl(is)h(a)g(stable,)g(more)f(general)h(solution,)75 191 y(and)g(easier)h(to)f (install/use.)25 b(In)16 b(fact,)g(in)g(some)f(w)o(a)o(ys,)i(w)o(e)f(ha)o(v)o (e)g(ev)o(en)h(managed)e(to)h(impro)o(v)o(e)e(the)j(reliabilit)o(y)75 241 y(and)d(securit)o(y)h(of)e(mail)e(service.)175 315 y(Our)k(serv)o(er)i (implemen)o(ts)c(a)i(small)e(\014lesystem)i(con)o(taining)f(a)h(sym)o(b)q (olic)f(link)g(to)h(a)g(sub)q(directory)i(of)d(the)75 365 y(in)o(v)o(oking)c (user's)j(home)e(directory)m(,)i(and)f(named)e(sym)o(b)q(olic)h(links)g(to)h (users')h(mailb)q(o)o(x)c(\014les.)18 b(An)13 b(example,)d(using)75 415 y(pathnames)j(from)f(our)i(en)o(vironmen)o(t,)e(is)i(depicted)h(in)f (Figure)g(1.)1128 400 y Fg(1)p 75 477 1800 5 v 75 1424 a @beginspecial 0 @llx 0 @lly 599 @urx 311 @ury 4320 @rwi @setspecial %%BeginDocument: hlfs-flowchart.eps /$F2psDict 200 dict def $F2psDict begin $F2psDict /mtrx matrix put /l {lineto} bind def /m {moveto} bind def /s {stroke} bind def /n {newpath} bind def /gs {gsave} bind def /gr {grestore} bind def /clp {closepath} bind def /graycol {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul 4 -2 roll mul setrgbcolor} bind def /col-1 {} def /col0 {0 0 0 setrgbcolor} bind def /col1 {0 0 1 setrgbcolor} bind def /col2 {0 1 0 setrgbcolor} bind def /col3 {0 1 1 setrgbcolor} bind def /col4 {1 0 0 setrgbcolor} bind def /col5 {1 0 1 setrgbcolor} bind def /col6 {1 1 0 setrgbcolor} bind def /col7 {1 1 1 setrgbcolor} bind def end /$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def /$F2psEnd {$F2psEnteredState restore end} def $F2psBegin 0 setlinecap 0 setlinejoin -4.0 329.0 translate 0.900 -0.900 scale 0.500 setlinewidth n 319 19 m 312 19 312 32 7 arcto 4 {pop} repeat 312 39 350 39 7 arcto 4 {pop} repeat 357 39 357 26 7 arcto 4 {pop} repeat 357 19 319 19 7 arcto 4 {pop} repeat clp gs col-1 s gr /Times-Roman findfont 12.00 scalefont setfont 317 34 m gs 1 -1 scale (START) col-1 show gr /Times-Roman findfont 18.00 scalefont setfont 269 360 m gs 1 -1 scale (".") col-1 show gr /Times-Roman findfont 18.00 scalefont setfont 254 335 m gs 1 -1 scale (Return) col-1 show gr n 256 320 m 249 320 249 358 7 arcto 4 {pop} repeat 249 365 302 365 7 arcto 4 {pop} repeat 309 365 309 327 7 arcto 4 {pop} repeat 309 320 256 320 7 arcto 4 {pop} repeat clp gs col-1 s gr n 274 100 m 199 100 l 199 170 l gs col-1 s gr n 201.000 162.000 m 199.000 170.000 l 197.000 162.000 l gs 2 setlinejoin col-1 s gr n 394 100 m 479 100 l 479 120 l gs col-1 s gr n 481.000 112.000 m 479.000 120.000 l 477.000 112.000 l gs 2 setlinejoin col-1 s gr n 139 210 m 124 210 l 124 320 l gs col-1 s gr n 126.000 312.000 m 124.000 320.000 l 122.000 312.000 l gs 2 setlinejoin col-1 s gr n 479 200 m 479 220 l gs col-1 s gr n 481.000 212.000 m 479.000 220.000 l 477.000 212.000 l gs 2 setlinejoin col-1 s gr n 539 260 m 569 260 l 569 320 l gs col-1 s gr n 571.000 312.000 m 569.000 320.000 l 567.000 312.000 l gs 2 setlinejoin col-1 s gr n 334 40 m 334 60 l gs col-1 s gr n 336.000 52.000 m 334.000 60.000 l 332.000 52.000 l gs 2 setlinejoin col-1 s gr n 334 60 m 274 100 l 334 140 l 394 100 l 334 60 l gs col-1 s gr n 199 170 m 139 210 l 199 250 l 259 210 l 199 170 l gs col-1 s gr n 479 120 m 419 160 l 479 200 l 539 160 l 479 120 l gs col-1 s gr n 479 220 m 419 260 l 479 300 l 539 260 l 479 220 l gs col-1 s gr n 326 319 m 319 319 319 357 7 arcto 4 {pop} repeat 319 364 467 364 7 arcto 4 {pop} repeat 474 364 474 326 7 arcto 4 {pop} repeat 474 319 326 319 7 arcto 4 {pop} repeat clp gs col-1 s gr n 419 159 m 364 159 l 364 179 l gs col-1 s gr n 366.000 171.000 m 364.000 179.000 l 362.000 171.000 l gs 2 setlinejoin col-1 s gr n 306 179 m 299 179 299 212 7 arcto 4 {pop} repeat 299 219 427 219 7 arcto 4 {pop} repeat 434 219 434 186 7 arcto 4 {pop} repeat 434 179 306 179 7 arcto 4 {pop} repeat clp gs col-1 s gr n 491 319 m 484 319 484 357 7 arcto 4 {pop} repeat 484 364 662 364 7 arcto 4 {pop} repeat 669 364 669 326 7 arcto 4 {pop} repeat 669 319 491 319 7 arcto 4 {pop} repeat clp gs col-1 s gr n 11 319 m 4 319 4 357 7 arcto 4 {pop} repeat 4 364 237 364 7 arcto 4 {pop} repeat 244 364 244 326 7 arcto 4 {pop} repeat 244 319 11 319 7 arcto 4 {pop} repeat clp gs col-1 s gr n 259 210 m 279 210 l 279 320 l gs col-1 s gr n 281.000 312.000 m 279.000 320.000 l 277.000 312.000 l gs 2 setlinejoin col-1 s gr n 419 259 m 389 259 l 389 319 l gs col-1 s gr n 391.000 311.000 m 389.000 319.000 l 387.000 311.000 l gs 2 setlinejoin col-1 s gr /Times-BoldItalic findfont 12.00 scalefont setfont 399 90 m gs 1 -1 scale (No) col-1 show gr /Times-BoldItalic findfont 12.00 scalefont setfont 254 90 m gs 1 -1 scale (Yes) col-1 show gr /Times-BoldItalic findfont 12.00 scalefont setfont 259 200 m gs 1 -1 scale (Yes) col-1 show gr /Times-BoldItalic findfont 12.00 scalefont setfont 124 200 m gs 1 -1 scale (No) col-1 show gr /Times-BoldItalic findfont 12.00 scalefont setfont 399 150 m gs 1 -1 scale (Yes) col-1 show gr /Times-BoldItalic findfont 12.00 scalefont setfont 489 215 m gs 1 -1 scale (No) col-1 show gr /Times-BoldItalic findfont 12.00 scalefont setfont 544 250 m gs 1 -1 scale (Yes) col-1 show gr /Times-BoldItalic findfont 12.00 scalefont setfont 404 250 m gs 1 -1 scale (No) col-1 show gr /Times-Roman findfont 12.00 scalefont setfont 459 280 m gs 1 -1 scale (Writable?) col-1 show gr /Times-Roman findfont 18.00 scalefont setfont 102 335 m gs 1 -1 scale (Return) col-1 show gr /Times-Roman findfont 18.00 scalefont setfont 547 335 m gs 1 -1 scale (Return) col-1 show gr /Times-Italic findfont 12.00 scalefont setfont 454 164 m gs 1 -1 scale (uid) col-1 show gr /Times-Roman findfont 12.00 scalefont setfont 474 164 m gs 1 -1 scale (== 0?) col-1 show gr /Times-Roman findfont 12.00 scalefont setfont 192 215 m gs 1 -1 scale (==) col-1 show gr /Times-Roman findfont 18.00 scalefont setfont 369 335 m gs 1 -1 scale (Return) col-1 show gr /Times-BoldItalic findfont 18.00 scalefont setfont 487 355 m gs 1 -1 scale (~USER) col-1 show gr /Courier-Bold findfont 18.00 scalefont setfont 549 354 m gs 1 -1 scale (.mailspool/) col-1 show gr /Courier-Bold findfont 18.00 scalefont setfont 542 354 m gs 1 -1 scale (/) col-1 show gr /Courier findfont 11.00 scalefont setfont 461 264 m gs 1 -1 scale (.mailspool/) col-1 show gr /Courier findfont 12.00 scalefont setfont 459 263 m gs 1 -1 scale (/) col-1 show gr /Times-Italic findfont 12.00 scalefont setfont 424 264 m gs 1 -1 scale (~USER) col-1 show gr /Courier findfont 12.00 scalefont setfont 207 215 m gs 1 -1 scale (home) col-1 show gr /Times-Roman findfont 12.00 scalefont setfont 239 215 m gs 1 -1 scale (?) col-1 show gr /Times-Italic findfont 12.00 scalefont setfont 155 215 m gs 1 -1 scale (NAME) col-1 show gr /Times-Roman findfont 18.00 scalefont setfont 341 194 m gs 1 -1 scale (Return) col-1 show gr /Times-Italic findfont 12.00 scalefont setfont 284 102 m gs 1 -1 scale (gid) col-1 show gr /Times-Roman findfont 12.00 scalefont setfont 302 103 m gs 1 -1 scale (== HLFS_GID?) col-1 show gr /Times-Roman findfont 12.00 scalefont setfont 474 249 m gs 1 -1 scale (Is) col-1 show gr /Courier-Bold findfont 18.00 scalefont setfont 322 354 m gs 1 -1 scale (/var/alt_mail/) col-1 show gr /Times-BoldItalic findfont 18.00 scalefont setfont 189 354 m gs 1 -1 scale (NAME) col-1 show gr /Times-BoldItalic findfont 18.00 scalefont setfont 6 353 m gs 1 -1 scale (~NAME) col-1 show gr /Courier-Bold findfont 18.00 scalefont setfont 69 353 m gs 1 -1 scale (/) col-1 show gr /Courier-Bold findfont 18.00 scalefont setfont 73 353 m gs 1 -1 scale (.mailspool/) col-1 show gr /Courier-Bold findfont 18.00 scalefont setfont 300 214 m gs 1 -1 scale (/.mailspool/) col-1 show gr $F2psEnd %%EndDocument @endspecial 371 1515 a Fl(Figure)g(1:)j Fk(Hlfsd)c Fl(resolving)h(the)g Fh(NAME)g Fl(comp)q(onen)o(t)f(of)h Fk(/mail/)p Fh(NAME)p 75 1565 V 175 1707 a Fl(The)c Fk(hlfsd)f Fl(serv)o(er)j(\014nds)f(out)f(the)h Fh(uid)782 1692 y Fg(2)810 1707 y Fl(of)f(the)h(pro)q(cess)h(that)e(is)g (accessing)h(its)g(moun)o(t)d(p)q(oin)o(t,)i(and)g(resolv)o(es)75 1756 y(the)j(pathname)e(comp)q(onen)o(t)g Fk(home)g Fl(as)i(a)f(sym)o(b)q (olic)e(link)h(to)h(a)g(sub)q(directory)h(within)f(the)h(home)e(directory)h (giv)o(en)75 1806 y(b)o(y)18 b(the)h Fh(uid)p Fl('s)f(en)o(try)h(in)e(the)i (passw)o(ord)g(\014le.)30 b(See)19 b(T)m(able)f(1.)30 b(If)18 b(the)h Fh(gid)f Fl(of)f(the)i(pro)q(cess)h(that)e(attempts)g(to)75 1856 y(access)c(a)f(mailb)q(o)o(x)d(\014le)i(is)h(a)f(sp)q(ecial)h(one)g (\(called)f(HLFS)p 976 1856 13 2 v 16 w(GID\),)f(then)j(the)f(serv)o(er)h (maps)d(the)j(name)d(of)h(the)h(next)p 1795 1863 80 2 v 75 1906 a(pathname)h(comp)q(onen)o(t)h(directly)h(to)g(the)g(user's)g(mailb)q(o) o(x)d(\(T)m(able)i(2\).)23 b(This)15 b(is)h(necessary)h(so)f(that)g(access)h (to)75 1956 y(a)d(mailb)q(o)o(x)e(\014le)i(b)o(y)h(users)h(other)f(than)g (the)g(o)o(wner)g(can)f(succeed.)23 b(The)15 b(serv)o(er)h(has)f(safet)o(y)f (features)i(in)e(case)i(of)75 2006 y(failures)d(suc)o(h)i(as)f(h)o(ung)g (\014lesystems)g(or)g(home)e(directory)j(\014lesystems)f(that)g(are)g (inaccessible)h(or)f(full.)175 2080 y(On)20 b(most)f(of)g(our)h(mac)o(hines,) g(mail)e(gets)j(deliv)o(ered)f(to)g(the)h(directory)f Fk(/var/spool/mail)p Fl(.)1720 2065 y Fg(3)1772 2080 y Fl(Man)o(y)75 2130 y(programs,)12 b(including)g(UAs,)i(dep)q(end)h(on)e(that)h(path.)k Fk(Hlfsd)12 b Fl(creates)k(a)d(directory)h Fk(/mail)p Fl(,)f(and)g(moun)o(ts)f(itself)75 2180 y(on)18 b(top)h(of)f(that)h(directory)m(.)32 b Fk(Hlfsd)18 b Fl(implem)o(en)o(ts)f(the)i(path)g(name)e(comp)q(onen)o(t)h(called)g Fk(home)p Fl(,)h(p)q(oin)o(ting)e(to)75 2230 y(a)f(sub)q(directory)j(of)d (the)h(user's)h(home)e(directory)m(.)27 b(W)m(e)16 b(ha)o(v)o(e)h(made)e Fk(/var/spool/mail)f Fl(a)i(sym)o(b)q(olic)f(link)h(to)75 2280 y Fk(/mail/home)p Fl(,)d(so)i(that)g(accessing)h Fk(/var/spool/mail)c Fl(actually)i(causes)i(access)h(to)e(a)g(sub)q(directory)h(within)e(a)75 2329 y(user's)h(home)e(directory)m(.)175 2404 y(The)20 b(rest)h(of)f(this)g (pap)q(er)g(is)g(organized)g(as)g(follo)o(ws.)35 b(Section)21 b(2)e(discusses)j(in)e(detail)f(the)i(problems)75 2454 y(and)e(limitations)d (of)j(other)h(home-mai)o(l-deli)o(v)o(ery)d(metho)q(ds.)34 b(Section)19 b(3)g(detail)g(the)h(design)f(of)g(the)h Fh(Home-)p 75 2488 720 2 v 121 2515 a Ff(1)139 2527 y Fe(In)10 b(Figure)g(1,)h Fd(~)p Fc(NAME)h Fe(is)f(the)g(home)f(directory)e(of)j(the)g(user)f(whose)h (user-name)d(is)j Fc(NAME)p Fe(;)i Fd(~)p Fc(USER)e Fe(is)h(the)e(home)g (directory)75 2566 y(of)h(the)g(user)g(with)g(user-id)f Fc(uid)p Fe(.)121 2594 y Ff(2)139 2606 y Fe(NFS)h(uses)g(e\013ectiv)o(e)e Fc(uids)p Fe(.)121 2634 y Ff(3)139 2646 y Fe(Other)i(directories)f(used)h (for)g(this)h(purp)q(ose)e(are)h Fd(/var/mail)f Fe(on)h(SVR4,)h Fd(/usr/mail)d Fe(on)j(other)f(System)f(V-based)h(op)q(erating-)75 2685 y(systems,)f(and)g Fd(/usr/spool/)o(mai)o(l)f Fe(on)i(BSD-based)e (systems.)965 2825 y Fl(2)p eop %%Page: 3 3 bop 75 4 1800 5 v 229 58 a Fl(Conditions:)17 b Fh(uid)p Fl(=)p Fk(ezk)p Fl(,)c Fh(gid)p Fi(6)p Fl(=HLFS)p 828 58 13 2 v 16 w(GID,)f(and)i Fk(/users/ezk/.mailsp)o(ool/)c Fl(is)k(writable.)p 157 77 1636 2 v 156 127 2 50 v 165 127 V 190 112 a Fm(Resolving)p 453 127 V 1088 127 V 1784 127 V 1793 127 V 156 177 V 165 177 V 190 162 a(comp)q(onen)o(t)p 453 177 V 58 w(P)o(athname)g(left)p 1088 177 V 337 w(V)l(alue)h(if)g(sym)o(b)q(olic)f(link)p 1784 177 V 1793 177 V 157 179 1636 2 v 157 189 V 156 238 2 50 v 165 238 V 190 223 a Fk(/)p 453 238 V 267 w(var/mail/)p Fh(NAME)p 1088 238 V 1784 238 V 1793 238 V 157 240 1636 2 v 156 290 2 50 v 165 290 V 190 275 a Fk(var)p Fl(/)p 453 290 V 202 w Fk(mail/)p Fh(NAME)p 1088 290 V 1784 290 V 1793 290 V 157 291 1636 2 v 156 341 2 50 v 165 341 V 190 326 a Fk(mail)p Fl(@)p 453 341 V 169 w Fk(/mail/home/)p Fh(NAME)p 1088 341 V 265 w Fk(mail)p Fl(@)g Fi(\))f Fk(/mail/home)p 1784 341 V 1793 341 V 157 343 1636 2 v 156 393 2 50 v 165 393 V 190 378 a(/)p 453 393 V 267 w(mail/home/)p Fh(NAME)p 1088 393 V 1784 393 V 1793 393 V 157 394 1636 2 v 156 444 2 50 v 165 444 V 190 429 a Fk(mail)p Fl(/)p 453 444 V 180 w Fk(home/)p Fh(NAME)p 1088 444 V 1784 444 V 1793 444 V 157 446 1636 2 v 156 496 2 50 v 165 496 V 190 481 a Fk(home)p Fl(@)p 453 496 V 169 w Fh(NAME)p 1088 496 V 507 w Fk(home)p Fl(@)h Fi(\))f Fk(/users/ezk/.mailsp)o(ool)p 1784 496 V 1793 496 V 157 497 1636 2 v 156 547 2 50 v 165 547 V 190 532 a(/)p 453 547 V 267 w(users/ezk/.mailsp)o(ool/)o Fh(NAME)p 1088 547 V 1784 547 V 1793 547 V 157 549 1636 2 v 156 599 2 50 v 165 599 V 190 584 a Fk(users)p Fl(/)p 453 599 V 158 w Fk(ezk/.mailspool/)p Fh(NA)o(ME)p 1088 599 V 1784 599 V 1793 599 V 157 600 1636 2 v 156 650 2 50 v 165 650 V 190 635 a Fk(ezk)p Fl(/)p 453 650 V 202 w Fk(.mailspool/)p Fh(NAME)p 1088 650 V 1784 650 V 1793 650 V 157 652 1636 2 v 156 702 2 50 v 165 702 V 190 687 a Fk(.mailspool)p Fl(/)p 453 702 V 48 w Fh(NAME)p 1088 702 V 1784 702 V 1793 702 V 157 703 1636 2 v 156 753 2 50 v 165 753 V 190 738 a(NAME)p 453 753 V 1088 753 V 1784 753 V 1793 753 V 157 755 1636 2 v 290 829 a Fl(T)m(able)g(1:)18 b(Resolving)13 b Fk(/var/mail/)p Fh(NAME)f Fl(to)h Fk(/users/ezk/.mailspo)o (ol/)p Fh(NAME)p 75 879 1800 5 v 75 1000 a(Link)19 b(File)f(System)h Fl(and)f(Section)g(4)g(describ)q(es)i(the)f(implemen)o(tation)c(of)i Fk(hlfsd)o Fl(.)31 b(Section)19 b(5)f(ev)n(aluates)g(our)75 1050 y(implemen)o(tatio)o(n.)e(Related)d(systems,)h(conclusions,)g(future)g (directions,)g(and)g(alternativ)o(e)g(uses)h(are)f(describ)q(ed)75 1100 y(in)f(Sections)i(6)f(and)f(7.)75 1208 y Fj(2)56 b(Bac)n(kground)175 1283 y Fl(This)16 b(section)h(pro)o(vides)f(an)g(in-depth)g(discussion)h(of)f (wh)o(y)g(a)o(v)n(ailable)d(metho)q(ds)j(for)g(deliv)o(ering)g(mail)d(to)75 1333 y(home)g(directories)i(are)f(not)g(as)g(go)q(o)q(d)f(as)h(the)h(one)f (used)h(b)o(y)e Fk(hlfsd)o Fl(.)75 1441 y Fj(2.1)56 b(Single-Host)17 b(Mail)h(Sp)r(o)r(ol)g(Directory)175 1516 y Fl(The)d(most)e(common)f(metho)q (d)i(for)g(mail)e(deliv)o(ery)i(is)h(for)f(mail)e(to)i(b)q(e)h(app)q(ended)h (to)f(a)f(mailb)q(o)o(x)e(\014le)i(in)g(a)75 1566 y(standard)d(sp)q(o)q(ol)f (directory)h(on)f(the)h(designated)g(\\mail)c(home")i(mac)o(hine)g(of)h(the)h (user.)17 b(The)11 b(greatest)h(adv)n(an)o(tage)75 1616 y(of)i(this)h(metho)q (d)f(is)g(that)h(it)f(is)h(the)g(default)f(metho)q(d)g(most)g(v)o(endors)h (pro)o(vide)g(with)f(their)h(systems,)g(th)o(us)g(v)o(ery)75 1665 y(little)h(\(if)g(an)o(y\))g(con\014guration)g(is)h(required)g(on)f(the) i(SA's)e(part.)26 b(All)16 b(they)h(need)h(to)e(set)i(up)e(are)h(mail)d (aliases)75 1715 y(directing)g(mail)c(to)j(the)h(host)g(on)f(whic)o(h)g(the)h (user's)h(mailb)q(o)o(x)10 b(\014le)k(is)f(assigned.)18 b(\(Otherwise,)d (mail)10 b(is)j(deliv)o(ered)75 1765 y(lo)q(cally)m(,)f(and)h(users)j(\014nd) e(mailb)q(o)o(xes)d(on)j(man)o(y)e(mac)o(hines.\))175 1840 y(As)k(users)i(b)q(ecome)e(more)f(sophisticated,)i(and)f(aided)g(b)o(y)g (windo)o(wing)f(systems,)i(they)f(\014nd)h(themselv)o(es)75 1890 y(logging)12 b(in)i(on)g(m)o(ultiple)e(hosts)j(at)f(once,)g(p)q (erforming)f(sev)o(eral)i(tasks)g(concurren)o(tly)m(.)k(They)c(ask)f(to)g(b)q (e)h(able)f(to)75 1939 y(read)g(their)h(mail)c(on)j(an)o(y)f(host)h(on)g(the) g(net)o(w)o(ork,)g(not)g(just)g(the)g(one)g(designated)h(as)f(their)g(\\mail) d(home.")75 2047 y Fj(2.2)56 b(Cen)n(tralized)18 b(Mail)g(Sp)r(o)r(ol)f (Directory)175 2122 y Fl(A)f(p)q(opular)g(metho)q(d)f(for)h(pro)o(viding)f (mail)f(readabilit)o(y)h(from)g(an)o(y)h(host)g(is)g(to)h(ha)o(v)o(e)f(all)f (mail)e(deliv)o(ered)75 2172 y(to)18 b(a)g(mail)e(sp)q(o)q(ol)i(directory)h (on)f(a)g(designated)h(\\mail-serv)o(er")e(whic)o(h)h(is)g(exp)q(orted)h(via) f(NFS)g(to)h(all)e(of)g(the)75 2222 y(hosts)f(on)g(the)g(net)o(w)o(ork.)24 b(Con\014guring)15 b(suc)o(h)h(a)f(system)h(is)f(relativ)o(ely)g(easy)m(.)24 b(On)16 b(most)e(systems,)i(the)g(bulk)g(of)75 2272 y(the)i(w)o(ork)f(is)h(a) f(one-time)f(addition)g(to)i(one)f(or)h(t)o(w)o(o)f(con\014guration)g (\014les)h(in)f Fk(/etc)p Fl(.)28 b(The)17 b(\014le-serv)o(er's)i(sp)q(o)q (ol)75 2322 y(directory)d(is)f(then)h(hard-moun)o(ted)e(across)i(ev)o(ery)g (mac)o(hine)e(on)h(the)h(lo)q(cal)e(net)o(w)o(ork.)22 b(In)16 b(small)d(en)o(vironmen)o(ts)75 2371 y(with)f(only)g(a)g(handful)g(of)g (hosts)h(this)f(can)h(b)q(e)g(an)f(acceptable)i(solution.)i(In)d(our)f (departmen)o(t,)h(with)f(a)g(couple)h(of)75 2421 y(h)o(undred)j(activ)o(e)f (hosts)h(and)f(thousands)g(of)g(mail)d(messages)j(pro)q(cessed)j(daily)m(,)13 b(this)i(w)o(as)g(deemed)g(completely)75 2471 y(unacceptable,)g(as)f(it)f(in) o(tro)q(duced)i(sev)o(eral)f(t)o(yp)q(es)h(of)e(problems:)137 2587 y Fi(\017)21 b Fm(Scalabili)o(t)o(y)12 b(and)i(P)o(erformance)p Fl(:)h(as)d(more)g(and)h(more)f(mac)o(hines)g(get)h(added)g(to)g(the)g(net)o (w)o(ork,)g(more)179 2637 y(mail)7 b(tra\016c)j(has)g(to)g(go)f(o)o(v)o(er)h (NFS)g(to)g(and)g(from)e(the)j(mail-serv)o(er.)k(Users)c(lik)o(e)f(to)f(run)i (mail-w)o(a)o(tc)o(hers[2)n(,)f(7)o(])179 2687 y(and)g(read)i(their)f(mail)d (often.)17 b(The)11 b(stress)i(on)d(the)i(shared)g(infrastructure)g (increases)g(with)f(ev)o(ery)g(user)h(and)965 2825 y(3)p eop %%Page: 4 4 bop 179 42 a Fl(host)14 b(added;)f(loads)g(on)h(the)g(mail)d(serv)o(er)k(w)o (ould)e(most)f(certainly)i(b)q(e)g(high)f(since)i(all)d(mail)f(deliv)o(ery)j (go)q(es)179 91 y(through)i(that)h(one)g(mac)o(hine.)672 76 y Fg(4)715 91 y Fl(This)g(leads)g(to)f(lo)o(w)o(er)g(reliabilit)o(y)f(and)h (p)q(erformance.)26 b(T)m(o)16 b(reduce)i(the)179 141 y(n)o(um)o(b)q(er)11 b(of)g(concurren)o(t)j(connections)f(b)q(et)o(w)o(een)g(clien)o(ts)f(and)g (the)h(serv)o(er)g(host,)f(some)f(SAs)i(ha)o(v)o(e)e(resorted)179 191 y(to)16 b(automoun)o(ting)e(the)j(mail-sp)q(o)q(ol)c(directory)m(.)26 b(But)17 b(this)g(solution)e(only)h(mak)o(es)f(things)h(w)o(orse:)24 b(since)179 241 y(users)15 b(often)e(run)h(mail)d(w)o(atc)o(hers,)j(and)f (man)o(y)e(p)q(opular)i(applications)g(suc)o(h)h(as)f Fk(trn)p Fl(,)g Fk(emacs)p Fl(,)f Fk(csh)g Fl(or)i Fk(ksh)179 291 y Fl(c)o(hec)o(k)h(p)q(erio)q(dically)f(for)g(new)h(mail,)d(the)j(automoun)o (ted)e(directory)i(w)o(ould)f(b)q(e)h(e\013ectiv)o(ely)h(p)q(ermanen)o(tly) 179 340 y(moun)o(ted.)g(If)c(it)g(gets)i(unmoun)o(ted)d(automatically)e(b)o (y)k(the)g(automoun)o(ter)e(program[3)n(],)h(it)g(is)g(most)f(lik)o(ely)179 390 y(to)17 b(get)h(moun)o(ted)e(shortly)i(afterw)o(ards,)g(consuming)e(more) h(I/O)g(resources)j(b)o(y)d(the)h(constan)o(t)g(cycle)h(of)179 440 y Fk(mount)13 b Fl(and)g Fk(umount)g Fl(calls.)137 523 y Fi(\017)21 b Fm(Reliabil)o(i)o(t)o(y)p Fl(:)16 b(the)f(mail-serv)o(er)f (host)h(and)f(its)h(net)o(w)o(ork)f(connectivit)o(y)h(m)o(ust)f(b)q(e)h(v)o (ery)g(reliable.)k(W)m(orse,)179 573 y(since)g(the)g(sp)q(o)q(ol)f(directory) h(has)f(to)g(b)q(e)h(hard-moun)o(ted,)1117 558 y Fg(5)1153 573 y Fl(man)o(y)d(pro)q(cesses)21 b(whic)o(h)d(access)i(the)f(sp)q(o)q(ol) 179 623 y(directory)f(\(v)n(arious)e(shells,)i Fk(login)p Fl(,)f Fk(emacs)p Fl(,)f(etc.\))30 b(w)o(ould)16 b(b)q(e)i(h)o(ung)f(as)g(long)g(as) g(connectivit)o(y)g(to)g(the)179 672 y(mail-serv)o(er)9 b(is)h(sev)o(ered.)19 b(T)m(o)10 b(impro)o(v)o(e)f(reliabilit)o(y)m(,)f(SAs)j(ma)o(y)e(c)o(ho)q (ose)i(to)f(bac)o(kup)h(the)g(mail-serv)o(er's)e(sp)q(o)q(ol)179 722 y(partition)16 b(sev)o(eral)h(times)g(a)f(da)o(y)m(.)27 b(This)17 b(ma)o(y)e(mak)o(e)g(things)i(w)o(orse)h(since)f(reading)g(or)g (deliv)o(ering)g(mail)179 772 y(while)e(bac)o(kups)h(are)g(in)f(progress)i (ma)o(y)d(cause)j(bac)o(kups)f(to)f(b)q(e)i(inconsisten)o(t;)f(more)f(bac)o (kups)h(consume)179 822 y(more)d(bac)o(kup-media)f(resources,)k(and)d (increase)j(the)e(load)f(on)h(the)g(mail-serv)o(er)f(host.)75 946 y Fj(2.3)56 b(Distributed)17 b(Mail)h(Sp)r(o)r(ol)g(Service)175 1022 y Fl(Despite)d(the)f(existence)i(of)e(a)g(few)g(systems)h(that)f(supp)q (ort)h(deliv)o(ery)f(to)h(users')g(home)e(directories,)1763 1007 y Fg(6)1797 1022 y Fl(mail)75 1071 y(deliv)o(ery)18 b(to)f(home)g (directories)i(hasn't)e(caugh)o(t)h(on.)29 b(W)m(e)17 b(b)q(eliev)o(e)i(the)f (main)d(reason)k(is)e(that)h(there)h(are)f(to)q(o)75 1121 y(man)o(y)12 b(programs)h(that)h(\\kno)o(w")g(where)h(mailb)q(o)o(x)c(\014les)k(reside.)20 b(Besides)15 b(the)g(ob)o(vious)f(\(the)h(deliv)o(ery)f(program)75 1171 y Fk(/bin/mail)9 b Fl(and)i(mail)e(readers)k(lik)o(e)d Fk(/usr/ucb/Mail)p Fl(,)f Fk(mush)p Fl(,)h Fk(mm)p Fl(,)h(etc.\),)h(other)g (programs)e(that)h(kno)o(w)g(mailb)q(o)o(x)75 1221 y(lo)q(cation)g(are)g Fk(login)p Fl(,)g Fk(from)p Fl(,)g(almost)e(ev)o(ery)j(shell,)g Fk(xbiff)p Fl(,)e Fk(xmailbox)p Fl(,)g(and)h(ev)o(en)h(some)f(programs)f(not) i(directly)75 1271 y(related)h(to)g(mail,)c(suc)o(h)14 b(as)f Fk(emacs)e Fl(and)i Fk(trn)p Fl(.)k(Although)12 b(some)f(of)h(these)i (programs)e(can)h(b)q(e)g(con\014gured)g(to)g(lo)q(ok)75 1320 y(in)18 b(di\013eren)o(t)h(directories)g(with)f(the)g(use)h(of)e(en)o (vironmen)o(t)g(v)n(ariables)h(and)g(other)g(resources,)j(man)o(y)16 b(of)i(them)75 1370 y(cannot.)g(The)d(o)o(v)o(erall)d(p)q(orting)i(w)o(ork)f (is)h(signi\014can)o(t.)175 1445 y(Other)g(metho)q(ds)f(that)g(ha)o(v)o(e)g (y)o(et)g(to)g(catc)o(h)h(on)f(require)h(the)g(use)g(of)e(a)h(sp)q(ecial)h (mail-reading)c(serv)o(er,)k(suc)o(h)75 1495 y(as)g(IMAP[16)o(])f(or)h(POP)q ([17)o(].)j(The)d(main)e(disadv)n(an)o(tage)h(of)g(these)i(systems)f(is)f (that)h(UAs)g(need)h(to)e(b)q(e)h(mo)q(di\014ed)75 1545 y(to)i(use)h(these)g (services)h(|)d(a)h(long)f(and)h(in)o(v)o(olv)o(ed)f(task.)24 b(That)16 b(is)g(wh)o(y)f(they)i(are)f(not)g(p)q(opular)g(at)g(this)g(time.) 75 1594 y(See)f(Section)f(6.1)f(for)h(more)e(details.)175 1669 y(Sev)o(eral)h(other)i(ideas)e(ha)o(v)o(e)h(b)q(een)g(prop)q(osed)h(and)e(ev) o(en)h(used)h(in)e(v)n(arious)g(en)o(vironmen)o(ts.)k(None)d(of)f(them)75 1719 y(is)g(robust.)18 b(They)c(are)g(mostly)d(v)o(ery)j(sp)q(ecialized,)f (in\015exible,)g(and)g(do)g(not)g(extend)h(to)f(the)h(general)f(case.)19 b(Some)75 1769 y(of)13 b(the)i(ideas)f(are)g(plain)f(bad,)g(p)q(oten)o (tially)g(leading)g(to)h(lost)f(or)h(corrupt)h(mail:)137 1885 y Fi(\017)21 b Fm(automoun)o(ter)o(s)p Fl(:)14 b(using)f(an)f(automoun)o(ter) f(suc)o(h)i(as)g Fk(amd)p Fl([13)n(])f(to)g(pro)o(vide)g(a)g(set)i(of)d(sym)o (b)q(olic)g(links)h(from)179 1935 y(the)h(normal)e(sp)q(o)q(ol)i(directory)g (to)g(user)h(home)d(directories)j(is)f(not)g(su\016cien)o(t.)18 b(UAs)13 b(rename,)f(unlink,)g(and)179 1985 y(recreate)20 b(the)f(mailb)q(o)o (x)c(as)k(a)f(regular)g(\014le,)h(therefore)g(it)f(m)o(ust)f(b)q(e)i(a)f (real)g(\014le,)h(not)f(a)g(sym)o(b)q(olic)e(link.)179 2034 y(F)m(urthermore,)d(it)g(m)o(ust)f(reside)j(in)e(a)g(real)g(directory)i(whic) o(h)e(is)g(writable)g(b)o(y)h(the)g(UAs)g(and)f(MT)m(As.)18 b(This)179 2084 y(metho)q(d)c(ma)o(y)g(also)h(require)h(p)q(opulating)e Fk(/var/spool/mail)e Fl(with)j(sym)o(b)q(olic)f(links)h(and)g(making)e(sure) 179 2134 y(they)j(are)g(up)q(dated.)24 b(Making)15 b Fk(amd)g Fl(manage)f(that)i(directory)g(directly)g(fails,)f(since)i(man)o(y)c(v)n (arious)i(lo)q(c)o(k)179 2184 y(\014les)g(need)g(to)g(b)q(e)g(managed)e(as)h (w)o(ell)g(\(see)i(Section)f(4.6\).)k(Also,)14 b Fk(amd)g Fl(do)q(es)h(not)g (pro)o(vide)f(all)g(of)g(the)h(NFS)179 2234 y(op)q(erations)f(whic)o(h)g(are) g(required)h(to)f(write)g(mail)d(suc)o(h)k(as)f Fh(write)p Fl(,)e Fh(cr)n(e)n(ate)p Fl(,)h Fh(r)n(emove)p Fl(,)g(and)g Fh(unlink)p Fl(.)137 2317 y Fi(\017)21 b Fm($MAIL)p Fl(:)15 b(setting)g(this)h(v)n(ariable)e(to)h(an)h(automoun)o(ted)e(directory)i(p)q (oin)o(ting)e(to)h(the)h(user's)g(mail)d(sp)q(o)q(ol)179 2367 y(host)g(only)f(solv)o(es)i(the)f(problem)f(for)h(those)g(programs)f(whic)o (h)h(kno)o(w)f(and)h(use)h($MAIL.)f(Man)o(y)f(programs)179 2416 y(don't,)j(therefore)i(this)e(solution)g(is)g(partial)g(and)g(of)g (limited)e(\015exibilit)o(y)m(.)21 b(Also,)15 b(it)g(requires)i(the)f(SAs)g (or)179 2466 y(the)e(users)i(to)d(set)i(it)f(themselv)o(es)g(|)f(an)h(added)g (lev)o(el)f(of)h(incon)o(v)o(enience)g(and)g(p)q(ossible)g(failures.)p 75 2501 720 2 v 121 2528 a Ff(4)139 2539 y Fe(Deliv)o(ery)8 b(via)i(NFS-moun)o(ted)e(\014lesystems)h(ma)o(y)g(require)g(usage)h(of)g Fd(rpc.lockd)e Fe(and)i Fd(rpc.statd)d Fe(to)k(pro)o(vide)d(distributed)g (\014le-)75 2579 y(lo)q(c)o(king,)j(b)q(oth)g(of)i(whic)o(h)f(are)g(widely)f (regarded)g(as)h(unstable)f(and)g(unreliable.)16 b(F)m(urthermore,)10 b(this)i(will)h(degrade)d(p)q(erformance)o(,)75 2618 y(as)h(lo)q(cal)g(pro)q (cesses)e(as)i(w)o(ell)h(as)f(remote)f Fd(nfsd)g Fe(pro)q(cesses)g(are)h(k)o (ept)f(busy)m(.)121 2646 y Ff(5)139 2658 y Fe(No)h(SA)h(in)f(their)g(righ)o (t)f(minds)g(w)o(ould)h(soft-moun)o(t)e(read/write)g(partitions)g(|)j(the)f (c)o(hances)e(for)i(data)g(loss)g(are)g(to)q(o)f(great.)121 2686 y Ff(6)139 2697 y Fe(AIX)i(1.2's)e Fd(bellmail)f Fe(for)i(the)g(IBM)h (PS/2)p Fc(s)p Fe([9)n(],)f Fd(/bin/mail)e Fe(on)i(SunOS)f(for)h(the)g(Sun)f (386i)h(mac)o(hines,)e(and)h Fd(zmailer)p Fe([27)m(].)965 2825 y Fl(4)p eop %%Page: 5 5 bop 137 42 a Fi(\017)21 b Fm(/bin/mail)o Fl(:)h(using)17 b(a)g(di\013eren)o (t)h(mail)d(deliv)o(ery)i(agen)o(t)g(could)g(b)q(e)h(the)g(solution.)27 b(One)18 b(suc)o(h)g(example)179 91 y(is)h Fk(hdmail)p Fl([6)n(].)34 b(Ho)o(w)o(ev)o(er,)21 b Fk(hdmail)d Fl(still)h(requires)h(mo)q(difying)d (all)h(UAs,)j(the)f(MT)m(A's)f(con\014guration,)179 141 y(installing)c(new)i (daemons,)e(and)i(c)o(hanging)e(login)h(scripts.)27 b(This)16 b(mak)o(es)g(the)h(system)f(less)h(upgradable)179 191 y(or)f(compatible)f (with)i(others,)h(and)e(adds)h(one)g(more)f(complicated)f(system)h(for)h(SAs) g(to)f(deal)h(with.)26 b(It)179 241 y(is)14 b(not)g(a)g(complete)g(solution)g (b)q(ecause)i(it)e(still)f(requires)j(eac)o(h)f(user)g(ha)o(v)o(e)g(their)f ($MAIL)h(v)n(ariable)e(setup)179 291 y(correctly)m(,)h(and)g(that)g(ev)o(ery) g(program)e(use)j(this)f(v)n(ariable.)75 415 y Fj(2.3.1)55 b(Wh)n(y)19 b(Deliv)n(er)e(In)n(to)i(the)f(Home)f(Directory?)175 490 y Fl(There)g(are)f(sev)o(eral)g(ma)r(jor)e(reasons)j(wh)o(y)f(SAs)g(migh) o(t)e(w)o(an)o(t)h(to)h(deliv)o(er)g(mail)d(directly)j(in)o(to)f(the)i (users')75 540 y(home)c(directories:)137 656 y Fi(\017)21 b Fm(Lo)q(cation)p Fl(:)16 b(man)o(y)c(mail)g(readers)j(need)g(to)f(mo)o(v)o(e) e(mail)f(from)h(the)j(sp)q(o)q(ol)e(directory)i(to)f(the)g(user's)h(home)179 706 y(directory)m(.)j(It)13 b(sp)q(eeds)h(up)f(this)g(op)q(eration)g(if)e (the)j(t)o(w)o(o)e(are)h(on)g(the)g(same)f(\014lesystem.)18 b(If)12 b(for)g(some)g(reason)179 756 y(the)19 b(user's)g(home)e(directory)i (is)g(inaccessible,)h(it)e(isn't)g(that)g(useful)g(to)h(b)q(e)g(able)f(to)g (read)h(mail,)d(since)179 806 y(there)f(is)e(no)g(place)h(to)f(mo)o(v)o(e)f (it)i(to.)737 791 y Fg(7)773 806 y Fl(In)f(some)g(cases,)i(trying)e(to)g(mo)o (v)o(e)f(mail)f(to)i(a)h(non-existen)o(t)g(or)f(h)o(ung)179 856 y(\014lesystem)g(ma)o(y)f(result)j(in)f(mail)d(loss.)137 939 y Fi(\017)21 b Fm(Distrib)o(uti)o(on)o Fl(:)27 b(ha)o(ving)19 b(all)f(mail)f(sp)q(o)q(ol)j(directories)h(spread)f(among)e(the)i(man)o(y)e (more)h(\014lesystems)179 988 y(minim)o(izes)14 b(the)j(c)o(hances)h(that)f (complete)f(en)o(vironmen)o(ts)g(will)f(grind)h(to)g(a)g(halt)g(when)h(a)f (single)g(serv)o(er)179 1038 y(is)e(do)o(wn.)19 b(It)c(do)q(es)g(increase)g (the)g(c)o(hance)h(that)e(there)i(will)d(b)q(e)i(someone)f(who)g(is)g(not)g (able)g(to)h(read)g(their)179 1088 y(mail)d(when)j(a)g(mac)o(hine)e(is)i(do)o (wn,)f(but)h(that)g(is)g(usually)f(preferred)j(to)d(ha)o(ving)g(no)h(one)g(b) q(e)g(able)g(to)f(read)179 1138 y(their)j(mail)e(b)q(ecause)k(a)d(cen)o (tralized)i(mail)d(serv)o(er)k(is)d(do)o(wn.)28 b(The)17 b(problem)f(of)h (losing)f(some)g(mail)e(due)179 1188 y(to)i(the)h(\(presumably\))f(higher)g (c)o(hances)i(that)e(a)g(user's)i(mac)o(hine)d(is)h(do)o(wn)g(is)g(minimi)o (zed)e(in)i(HLFS)h(as)179 1237 y(describ)q(ed)e(in)f(Sections)h(4.3)d(and)i (4.4.)137 1320 y Fi(\017)21 b Fm(Securit)o(y)p Fl(:)e(deliv)o(ering)d(mail)d (to)j(users')g(home)f(directories)i(has)f(another)h(adv)n(an)o(tage)e(|)g (enhanced)i(se-)179 1370 y(curit)o(y)e(and)g(priv)n(acy)m(.)21 b(Since)15 b(a)g(shared)h(system)f(mail)d(sp)q(o)q(ol)j(directory)h(has)f(to) g(b)q(e)h(w)o(orld-readable)e(and)179 1420 y(searc)o(hable,)376 1405 y Fg(8)407 1420 y Fl(an)o(y)d(user)i(can)f(see)i(whether)f(other)f (users)h(ha)o(v)o(e)f(mail,)d(when)k(they)f(last)g(receiv)o(ed)h(new)f(mail,) 179 1470 y(or)j(when)h(they)g(last)f(read)h(their)g(mail.)k(Programs)14 b(suc)o(h)i(as)g Fk(finger)e Fl(displa)o(y)g(this)i(information,)c(whic)o(h) 179 1520 y(some)f(consider)i(an)f(infringemen)o(t)f(of)h(priv)n(acy)m(.)k (While)c(it)g(is)g(p)q(ossible)g(to)g(disable)g(this)h(feature)g(of)e Fk(finger)179 1570 y Fl(so)16 b(that)f(remote)g(users)j(cannot)d(see)i(a)f (mailb)q(o)o(x)c(\014le's)k(status,)g(this)g(do)q(esn't)g(prev)o(en)o(t)h(lo) q(cal)e(users)i(from)179 1619 y(getting)d(the)g(information.)i(F)m (urthermore,)e(there)h(are)g(more)e(programs)g(whic)o(h)h(mak)o(e)e(use)j(of) f(this)g(infor-)179 1669 y(mation.)24 b(In)17 b(shared)h(en)o(vironmen)o(ts,) e(disabling)f(suc)o(h)j(programs)d(has)i(to)g(b)q(e)g(done)g(on)g(a)f (system-wide)179 1719 y(basis,)i(but)g(with)g(mail)d(deliv)o(ered)j(to)g (users')h(home)e(directories,)i(users)h(less)e(concerned)i(with)d(priv)n(acy) 179 1769 y(who)f Fh(do)g Fl(w)o(an)o(t)f(to)h(let)g(others)h(kno)o(w)f(when)g (they)h(last)f(receiv)o(ed)h(or)f(read)g(mail)e(can)i(easily)f(do)h(so)g (using)179 1819 y(\014le)e(protection)i(bits.)k(Lastly)m(,)14 b(on)g(systems)h(that)g(do)f(not)h(exp)q(ort)g(their)g(NFS)g(\014lesystem)f (with)h Fk(anon=0)p Fl(,)179 1868 y(sup)q(erusers)f(are)e(less)g(lik)o(ely)d (to)j(sno)q(op)f(around)g(others')h(mail,)d(as)i(they)h(b)q(ecome)f(\\nob)q (o)q(dies")g(across)h(NFS.)175 1985 y(In)j(summary)m(,)e(deliv)o(ering)i (mail)d(to)k(home)e(directories)j(pro)o(vides)f(users)h(the)f(functionalit)o (y)e(sough)o(t,)h(and)75 2034 y(also)e(a)o(v)o(oids)g(most)g(of)g(the)i (problems)e(discussed)i(in)f(Section)g(2.2.)75 2142 y Fj(3)56 b(Design)175 2218 y Fl(W)m(e)16 b(named)f(our)h(\014le)h(system)f(the)h Fh(Home-Link)h(File)e(System)p Fl(,)h(b)q(ecause)h(that's)f(all)e(it)h(do)q (es)h(|)f(pro)o(vide)75 2267 y(sym)o(b)q(olic)11 b(links)g(to)i(\014les)f (and)h(directories)g(in)f(a)g(user's)i(home)d(directory)m(.)18 b(The)13 b(soft)f(link)f(has)i(a)f(\014xed)h(name,)e(but)75 2317 y(unlik)o(e)16 b(regular)h(soft)g(links,)f(what)h(it)f(p)q(oin)o(ts)h (to)f(is)h(\\dynamic")e(dep)q(ending)i(on)f(who)h(accesses)i(the)f(sym)o(b)q (olic)75 2367 y(link.)25 b(The)18 b(ideas)e(that)h(this)g(\014lesystem)f (represen)o(ts)k(are)d(not)f(limited)f(just)i(to)f(handling)g(electronic)h (mail)d(|)75 2417 y(that)g(is)g(only)f(one)h(application)e(of)i(this)g (\014lesystem.)j(See)e(Sections)g(7.1)e(and)g(7.2)g(for)h(other)g(ideas.)175 2491 y(Our)g(k)o(ey)g(goals)f(in)g(designing)h(HLFS)g(w)o(ere:)p 75 2526 720 2 v 121 2553 a Ff(7)139 2565 y Fe(This)e(assumes)f(that)h(they)g (can)g(login)f(to)i(a)f(di\013eren)o(t)f(host.)18 b(Some)11 b(systems,)g(suc)o(h)h(as)h(HP-UX,)h(do)e(not)g(allo)o(w)g(login)g(if)g(they) 75 2604 y(cannot)e Fd(chdir)g Fe(to)h(the)g(user's)f(home)g(directory)m(.)121 2632 y Ff(8)139 2644 y Fe(System)g(V)i(has)g(the)f(mail)g(sp)q(o)q(ol)f (directory)g(only)h(group)f(writable)h(but)g(that)g(mak)o(es)f(it)i(more)f (di\016cult)g(to)g(install)g(other)f(UAs)75 2683 y(or)h(MT)m(As.)965 2825 y Fl(5)p eop %%Page: 6 6 bop 126 42 a Fl(1.)20 b(T)m(o)13 b(pro)o(vide)h(ev)o(ery)g(user)h(with)f(the) g(abilit)o(y)e(to)i(read)h(mail)c(from)h(an)o(y)h(host.)126 125 y(2.)20 b(T)m(o)14 b(ensure)j(that)f(all)e(MT)m(As)h(and)g(UAs)h(in)f (use,)h(as)f(w)o(ell)g(as)g(an)o(y)g(other)h(utilities)f(whic)o(h)g(dep)q (end)h(on)f(the)179 174 y(standard)f(mail)d(sp)q(o)q(ol)i(directory)m(,)g (face)h(no)g(problems)e(from)g(the)i(c)o(hange)g(in)f(the)h(underlying)g (\014lesystem.)126 257 y(3.)20 b(T)m(o)13 b(minim)o(ize)e(the)k(p)q (ossibilit)o(y)e(of)g(mail)e(b)q(eing)j(lost)g(or)f(b)q(ouncing)h(bac)o(k)g (to)g(the)g(sender.)126 340 y(4.)20 b(T)m(o)13 b(pro)o(vide)h(more)e(priv)n (acy)i(for)f(users')i(mail)d(\014les.)175 457 y(Since)g(most)f(sites)i(pro)o (vide)f(access)i(to)e(users')i(home)c(directories)k(from)c(an)o(y)i(host,)g (it)g(made)f(sense)j(to)e(store)75 506 y(incoming)f(mail)g(there)k(as)f(w)o (ell.)j(That)c(w)o(a)o(y)m(,)f(as)i(long)f(as)g(users)i(could)f(log)e(in)o (to)h(a)h(host)f(and)h(access)h(their)f(home)75 556 y(directories)f(via)e (NFS,)h(their)g(mail)d(w)o(ould)i(b)q(e)h(accessible)h(as)f(w)o(ell.)17 b(This)11 b(solv)o(ed)h(the)g(\014rst)h(problem.)j(Also,)11 b(since)75 606 y(users)16 b(m)o(ust)e(login)f(in)i(order)g(to)g(read)g(their) g(mail,)d(causing)i(their)i(home)d(directories)j(to)f(b)q(e)g(automoun)o (ted,)e(no)75 656 y(extra)h(moun)o(ts)f(are)h(required)h(in)f(order)g(to)g(b) q(egin)g(reading)f(mail.)175 731 y(The)f(second)g(problem)f(w)o(as)g(solv)o (ed)h(b)o(y)f(making)e(sure)k(that)f(the)g(\014nal)f(access)j(of)d(the)h (mail)d(sp)q(o)q(ol)i(directory)75 780 y(remains)17 b(a)g(\\real")h (directory)g(\(not)g(a)g(read-only)f(pseudo-\014lesystem)i(pro)o(vided)f(b)o (y)f(an)h(automoun)o(ter\).)29 b(All)75 830 y(UAs)20 b(access)h(the)f(sp)q(o) q(ol)f(directory)h(for)f(reading)g(and)h(writing)e(the)i(user's)h(mail)16 b(\014le)k(and)f(create)i(lo)q(c)o(k)e(\014les)75 880 y(there.)178 865 y Fg(9)217 880 y Fl(That)14 b(means)f(that)h Fk(/var/spool/mail)d Fl(needs)16 b(to)e(b)q(e)g(readable,)g(writable,)g(and)g(searc)o(hable)h(for) e(UAs)75 930 y(and)i(MT)m(As)g(so)g(that)g(lo)q(c)o(k)f(\014les)h(can)g(b)q (e)h(written)f(and)g(remo)o(v)o(ed.)20 b(See)c(also)e(Section)i(4.6.)k(F)m (or)14 b(the)i(purp)q(ose)g(of)75 980 y(writing)g(the)i(mail)c(and)j(lo)q(c)o (k)g(\014les,)g(a)g(sub)q(directory)h(inside)f(the)h(user's)g(home)e (directory)i(is)e(su\016cien)o(t,)i(since)75 1029 y(it)d(is)f(already)h(o)o (wned)g(b)o(y)g(that)g(user.)22 b(Ensuring)15 b(that)g(users)i(cannot)e (access)i(other)e(users')h(\014les)g(can)f(easily)f(b)q(e)75 1079 y(ac)o(hiev)o(ed)g(b)o(y)g(protecting)g(this)g(sub)q(directory)m(.)175 1154 y(In)h(order)i(not)f(to)g(c)o(hange)g(the)g(b)q(eha)o(vior)g(of)f (programs)g(lik)o(e)g Fk(comsat)p Fl([21)m(,)h(23)o(],)g Fk(from)f Fl(or)g Fk(finger)p Fl(,)g(whic)o(h)75 1204 y(are)j(designed)g(to)g(read)g (an)o(y)f(user's)h(mail,)e(w)o(e)i(implem)o(en)o(ted)e(a)h(sp)q(ecial)h(c)o (hec)o(k)h(for)e(a)g(designated)h(group.)29 b(If)75 1254 y(the)17 b(e\013ectiv)o(e)g Fh(gid)f Fl(of)g(the)g(pro)q(cess)i(is)e(the)h(designated) g(group,)f(w)o(e)g(assume)g(that)g(suc)o(h)h(a)e(sp)q(ecial)i(program)d(is)75 1303 y(executing,)20 b(and)e Fk(hlfsd)f Fl(arranges)i(to)f(do)g(the)h(lo)q (okup)f(not)g(only)g(of)f(the)i(real)g(sp)q(o)q(ol)f(directory)m(,)h(but)g (of)e(the)75 1353 y(mailb)q(o)o(x)f(itself.)34 b(See)20 b(T)m(able)e(2.)33 b(Note)20 b(that)f(this)g(metho)q(d)g(only)f(supp)q(orts)i(read)g(access)h (without)d(lo)q(c)o(king;)p 75 1415 1800 5 v 607 1469 a(Conditions:)f Fh(gid)p Fl(=HLFS)p 1027 1469 13 2 v 15 w(GID)d(for)f(an)o(y)h Fh(uid)p Fl(.)p 206 1487 1538 2 v 205 1537 2 50 v 214 1537 V 239 1522 a Fm(Resolving)p 502 1537 V 919 1537 V 1735 1537 V 1744 1537 V 205 1587 V 214 1587 V 239 1572 a(comp)q(onen)o(t)p 502 1587 V 58 w(P)o(athname)g(left)p 919 1587 V 120 w(V)l(alue)g(if)h(sym)o (b)q(olic)f(link)p 1735 1587 V 1744 1587 V 206 1589 1538 2 v 206 1599 V 205 1648 2 50 v 214 1648 V 239 1633 a Fk(/)p 502 1648 V 267 w(var/mail/)p Fh(NAME)p 919 1648 V 1735 1648 V 1744 1648 V 206 1650 1538 2 v 205 1700 2 50 v 214 1700 V 239 1685 a Fk(var)p Fl(/)p 502 1700 V 202 w Fk(mail/)p Fh(NAME)p 919 1700 V 1735 1700 V 1744 1700 V 206 1701 1538 2 v 205 1751 2 50 v 214 1751 V 239 1736 a Fk(mail)p Fl(@)p 502 1751 V 169 w Fk(/mail/home/)p Fh(NAME)p 919 1751 V 48 w Fk(mail)p Fl(@)f Fi(\))g Fk(/mail/home)p 1735 1751 V 1744 1751 V 206 1753 1538 2 v 205 1803 2 50 v 214 1803 V 239 1788 a(/)p 502 1803 V 267 w(mail/home/)p Fh(NAME)p 919 1803 V 1735 1803 V 1744 1803 V 206 1804 1538 2 v 205 1854 2 50 v 214 1854 V 239 1839 a Fk(mail)p Fl(/)p 502 1854 V 180 w Fk(home/)p Fh(NAME)p 919 1854 V 1735 1854 V 1744 1854 V 206 1856 1538 2 v 205 1906 2 50 v 214 1906 V 239 1891 a Fk(home)p Fl(@)p 502 1906 V 169 w Fh(NAME)p 919 1906 V 290 w Fk(home)p Fl(@)g Fi(\))g Fk(.)p 1735 1906 V 1744 1906 V 206 1907 1538 2 v 205 1957 2 50 v 214 1957 V 239 1942 a(.)p Fl(/)p 502 1957 V 246 w Fh(NAME)p 919 1957 V 1735 1957 V 1744 1957 V 206 1959 1538 2 v 206 1969 V 205 2019 2 50 v 214 2019 V 239 2004 a(NAME)p Fl(@)p 502 2019 V 919 2019 V 547 w Fh(NAME)p Fl(@)h Fi(\))f Fk(~)p Fh(NAME)p Fk(/.mailspool/)p Fh(NAME)p 1735 2019 V 1744 2019 V 206 2020 1538 2 v 205 2070 2 50 v 214 2070 V 239 2055 a Fk(~)p Fh(NAME)p Fl(/)p 502 2070 V 119 w Fk(.mailspool/)p Fh(NAME)p 919 2070 V 1735 2070 V 1744 2070 V 206 2072 1538 2 v 205 2122 2 50 v 214 2122 V 239 2107 a Fk(.mailspool)p Fl(/)p 502 2122 V 48 w Fh(NAME)p 919 2122 V 1735 2122 V 1744 2122 V 206 2123 1538 2 v 205 2173 2 50 v 214 2173 V 239 2158 a(NAME)p 502 2173 V 919 2173 V 1735 2173 V 1744 2173 V 206 2175 1538 2 v 243 2249 a Fl(T)m(able)g(2:)18 b(Sp)q(ecially)13 b(resolving)h Fk(/var/mail/)p Fh(NAME)e Fl(to)h Fm(~)p Fh(NAME)p Fk(/.mailspool/)p Fh(NAME)p 75 2299 1800 5 v 75 2440 a Fl(ho)o(w)o(ev)o(er,)k(this)g(is)f(su\016cien)o(t)h(for)f(all)g (programs)f(that)i(need)g(to)g(access)h(other)f(users')h(mailb)q(o)o(xes.)24 b(All)15 b(that)i(is)75 2490 y(required)e(is)f(to)f(set)i(these)g(programs)e (to)h(b)q(e)g Fh(setgid)g Fl(to)g(the)g(designated)h(group.)p 75 2525 720 2 v 121 2552 a Ff(9)139 2563 y Fe(Note)e(that,)g(in)g(order)g(to) g(allo)o(w)g(mail)g(deliv)o(ery)e(to)i(NFS)q(-moun)o(ted)d(mail)j(sp)q(o)q (ol)g(directories,)e(most)h(v)o(endors)g(ha)o(v)o(e)h(mo)q(di\014ed)75 2603 y(the)d Fd(/bin/mail)e Fe(program)g(to)j(set)f(its)g Fc(uid)h Fe(to)g(that)f(of)g(the)g(recipien)o(t)e(when)j(deliv)o(ering)d(mail.)13 b(If)e(a)g(lo)q(cal)e(deliv)o(ery)g(agen)o(t)g(\(LD)o(A\))i(on)75 2642 y(a)g(system)f(do)q(es)g(not)g(pro)o(vide)f(this)i(b)q(eha)o(vior,)d (the)j(MT)m(A)i(m)o(ust)d(arrange)f(to)i(in)o(v)o(ok)o(e)e(it)i(with)g(the)f Fc(uid)i Fe(of)f(the)f(recipien)o(t)f(|)j(this)e(can)75 2682 y(b)q(e)h(done)f(b)o(y)h(a)h(wrapp)q(er)e(C)i(program.)965 2825 y Fl(6)p eop %%Page: 7 7 bop 175 42 a Fl(The)14 b(third)h(problem)d(is)j(solv)o(ed)f(b)o(y)g(ensuring) g(that)h(all)e(op)q(erations)h(whic)o(h)g(migh)o(t)f(hang)g Fk(hlfsd)h Fl(are)g(p)q(er-)75 91 y(formed)e(in)h(the)h(bac)o(kground,)f (while)g(still)g(pro)o(viding)f(service)j(in)e(the)h(paren)o(t)g(or)g(c)o (hild)f(pro)q(cess.)20 b(F)m(urthermore,)75 141 y(if)12 b Fk(hlfsd)f Fl(is)i(not)g(running)f(an)o(ymore,)f(or)i(if)f(the)h(user's)h(home)d (\014lesystem)i(is)f(full,)f(mail)f(gets)k(deliv)o(ered)f(to)f(an)h(al-)75 191 y(ternate)f(directory)g(\(See)g(also)f(Section)g(4.3\).)16 b(A)11 b Fk(cron)f Fl(job)h(\(running)g(sev)o(eral)g(times)g(a)f(da)o(y)h(in) f(our)i(departmen)o(t\),)75 241 y(lo)q(oks)h(at)h(the)h(alternate)g (directory)m(,)f(and)g(attempts)f(to)h(resend)i(messages)e(in)g(it)f(to)h (their)h(righ)o(tful)e(o)o(wners.)19 b(All)75 291 y(that)12 b(is)h(incurred)g(is)g(a)f(dela)o(y)g(in)g(mail)d(deliv)o(ery)m(,)j(whic)o (h,)g(in)g(most)f(cases,)j(is)e(no)g(longer)h(than)f(the)h(length)f(of)g (time)75 340 y(b)q(et)o(w)o(een)j(consecutiv)o(e)h(in)o(v)o(o)q(cations)d(of) g(the)h(lost-mail)d(remailing)h(script.)175 415 y(Ha)o(ving)h(a)h(sp)q(ecial) g(mail-sp)q(o)q(ol)e(sub)q(directory)j(o)o(wned)g(and)f(con)o(trolled)g(b)o (y)g(the)h(user)g(also)f(addresses)i(the)75 465 y(last)c(problem,)f(that)i (of)f(priv)n(acy)m(.)k(Users)e(can)f(c)o(hange)g(the)g(protection)g(bits)g (on)f(their)h(mailb)q(o)o(x)d(directory)j(inside)75 515 y(their)g(home)f (directory)i(so)f(that)g(it)f(is)h(readable)g(and)g(searc)o(hable)h(only)e(b) o(y)h(the)g(o)o(wner.)18 b(An)o(y)13 b(other)h(program)d(or)75 565 y(user,)16 b(unless)f(running)g(as)g(the)g(sup)q(eruser)j(on)c(the)i (same)e(host,)1091 549 y Fg(10)1141 565 y Fl(w)o(ould)g(not)h(b)q(e)g(able)g (to)f(\014nd)h(out)g(whether)h(a)75 614 y(user)f(has)f(new)g(mail,)d(ho)o(w)j (m)o(uc)o(h)e(of)i(it)f(there)i(is,)f(or)f(when)i(it)e(w)o(as)h(last)g(read.) 75 722 y Fj(4)56 b(Impleme)o(n)n(tation)16 b(of)j Fb(hlfsd)175 797 y Fl(W)m(e)f(used)i(a)f(protot)o(yp)q(e)h(NFS)f(serv)o(er,)j(and)d (implem)o(en)o(ted)e(only)i(the)g(op)q(erations)h(that)f(w)o(ere)h(needed.)75 847 y(W)m(e)14 b(generated)i(NFS)e(stubs)i(using)e Fk(rpcgen)p Fl(.)k(The)d(serv)o(er)h(w)o(as)e(dev)o(elop)q(ed)h(\014rst)g(under)h(SunOS)f (v)o(ersion)f(4.1.2.)75 897 y(This)g(serv)o(er)i(w)o(as)e(incorp)q(orated)h (in)o(to)e(the)i Fk(amd)e Fl(source)j(tree,)f(and)f(w)o(e)g(used)h(some)e(of) h Fk(amd)p Fl('s)f(sources)j(as)e(utilit)o(y)75 947 y(functions,)k(since)g (they)g(are)g(w)o(ell-written)f(to)h(handle)f(a)g(v)n(ariet)o(y)g(of)g(arc)o (hitectures)j(and)d(op)q(erating)g(systems.)75 997 y(\(See)e(Section)f(4.7)f (for)h(source)h(co)q(de)g(a)o(v)n(ailabil)o(it)o(y)l(.\))75 1105 y Fj(4.1)56 b(The)18 b(\\Home-Link")d(File)j(Service)175 1180 y Fl(This)10 b(subsection)i(includes)g(tec)o(hnical)f(details)f(of)h (the)g(NFS)g(op)q(erations)g(and)g(ma)o(y)e(b)q(e)i(skipp)q(ed.)18 b(Ho)o(w)o(ev)o(er,)75 1230 y(it)13 b(pro)o(vides)g(an)g(example)e(of)i(the)g (design)h(and)f(implem)o(en)o(tation)d(of)i(a)h(small)e(sp)q(ecial-purp)q (ose)j(NFS)g(serv)o(er)g(and)75 1279 y(ma)o(y)e(b)q(e)i(of)g(use)g(to)g (others.)175 1354 y(HLFS)j(is)g(a)g(read-only)g(\014lesystem,)g(and)g(as)h (suc)o(h,)g(all)e(op)q(erations)i(that)f(require)h(write)g(access)h(return)75 1404 y(the)d(error)h(co)q(de)f(NFSERR)p 522 1404 13 2 v 14 w(R)o(OFS)g(\(\\Read-Only)f(Filesystem"\):)20 b Fh(setattr,)c(write,)f(cr)n (e)n(ate,)h(r)n(emove,)g(r)n(ename,)75 1454 y(link,)g(unlink,)g(symlink,)g (mkdir,)f Fl(and)g Fh(rmdir)p Fl(.)21 b(T)m(rivially)13 b(implemen)o(ted)g(w) o(ere)j(the)g Fh(nul)r(l)p Fl(,)f Fh(r)n(o)n(ot)p Fl(,)g(and)g Fh(write)n(c)n(ache)75 1504 y Fl(op)q(erations.)i(W)m(e)11 b(decided)h(to)e(ha)o(v)o(e)h Fh(statfs)f Fl(return)i(some)e(v)n(alue)h (\(all)e(zeros)k(in)d(most)g(cases\).)18 b(The)11 b Fh(r)n(e)n(ad)g Fl(op)q(eration)75 1553 y(simply)h(returns)j(NFSERR)p 524 1553 V 15 w(A)o(CCES)f(\(\\P)o(ermission)f(Denied"\).)175 1628 y(The)e(remaining)e (op)q(erations)i(are)h(the)f(heart)h(of)e(this)h(\014lesystem:)17 b Fh(r)n(e)n(addir)p Fl(,)10 b Fh(getattr)p Fl(,)g Fh(lo)n(okup)p Fl(,)i(and)f Fh(r)n(e)n(ad)r(link)p Fl(.)175 1703 y(Our)j(serv)o(er)h(m)o (ust)d(distinguish)h(b)q(et)o(w)o(een)i(the)f(directory)g(and)g(the)g(link,)e (so)i(w)o(e)f(assigned)h(them)f(di\013eren)o(t)75 1753 y(in)o(tegers)f(to)f (serv)o(e)i(as)f(\014lehandles.)17 b(Note)12 b(that)f(these)i(need)g(not)e(b) q(e)h(as)f(complicated)g(as)g(the)h(\014lehandles)g(usually)75 1802 y(generated)j(b)o(y)f(NFS.)k(They)c(need)h(only)e(to)h(b)q(e)h(unique,)e (and)h(their)g(v)n(alue)f(is)h(meaningful)d(only)i(to)h(the)h(serv)o(er.)75 1910 y Fj(4.1.1)55 b(The)19 b(readdir)f(Op)r(eration)175 1985 y Fl(Op)q(ening)h(this)g(directory)h(returns)h(the)f(\\.")33 b(and)19 b(\\..")33 b(directories,)21 b(and)e(one)g(sym)o(b)q(olic)e(link,)i Fk(home)p Fl(.)75 2035 y(A)o(ttempting)e(to)g(readdir)h(on)g(the)g(sym)o(b)q (olic)e(link)h(results)i(in)f(an)f(NFSERR)p 1326 2035 V 15 w(NOTDIR.)g(An)o(ything)g(else)i(is)e(a)75 2085 y(stale)d(\014lehandle.)75 2193 y Fj(4.1.2)55 b(The)19 b(getattr)e(Op)r(eration)175 2268 y Fh(Getattr)h Fl(returns)i(r-xr-xr-x)e(for)h(the)g(\\.")32 b(and)18 b(\\..")32 b(directories.)h(The)19 b(link)f(itself,)h(named)e Fk(home)h Fl(b)o(y)75 2318 y(default,)d(is)h(protected)h(as)f(rwxrwxrwx.)23 b(It)16 b(do)q(es)g(not)g(matter)f(for)g(the)h(link)f(that)h(it)f(is)g(w)o (orld-writable.)23 b(The)75 2368 y(mo)q(di\014cation)10 b(and)j(creation)f (times)g(for)g(the)h(link)e(and)i(directories)g(are)g(the)g(startup)g(time)e (of)h(the)h(serv)o(er.)19 b(If)12 b(the)75 2418 y(e\013ectiv)o(e)k Fh(gid)f Fl(of)f(the)h(pro)q(cess)h(is)f(HLFS)p 721 2418 V 15 w(GID,)e(then)j(some)d(\014xed)i(v)n(alid)e(attributes)j(are)f(returned.) 22 b(An)o(y)14 b(other)75 2467 y(\014lehandle)i(giv)o(en)f(to)g Fk(hlfsd)g Fl(is)g(considered)i(stale)f(and)f(the)i(NFSERR)p 1227 2467 V 14 w(ST)m(ALE)f(\(\\Stale)f(Filehandle"\))g(result)75 2517 y(co)q(de)g(is)e(returned.)p 75 2544 720 2 v 106 2571 a Ff(10)139 2582 y Fe(Or)e(as)h(the)f(sup)q(eruser)e(elsewhere,)h(if)h(the)g (\014lesystem)e(is)i(NFS-exp)q(orted)e(with)j Fd(anon=0)p Fe(.)965 2825 y Fl(7)p eop %%Page: 8 8 bop 75 42 a Fj(4.1.3)55 b(The)19 b(lo)r(okup)e(Op)r(eration)175 117 y Fl(Ob)o(viously)m(,)c(w)o(e)i(only)f(allo)o(w)f(lo)q(oking)g(up)h(in)h (the)g(\\.")20 b(and)14 b(\\..")20 b(directories,)15 b(b)q(oth)g(of)f(whic)o (h)g(return)i(the)75 166 y(same)e(v)n(alues.)22 b(T)m(rying)15 b(to)g(lo)q(okup)f(\\in")h(the)g(link)g(results)h(in)f(an)g(NFSERR)p 1312 166 13 2 v 15 w(NOTDIR)f(\(\\Not)i(a)f(Directory"\))75 216 y(error)k(co)q(de.)32 b(An)o(y)18 b(link)g(not)g(kno)o(wn)g(to)g(the)h (serv)o(er)g(returns)h(an)e(NFSERR)p 1338 216 V 15 w(NOENT)h(\(\\No)f(Suc)o (h)h(En)o(try"\))75 266 y(error,)f(unless)f(the)g Fh(gid)g Fl(of)e(the)j(requesting)f(pro)q(cess)h(is)f(HLFS)p 1088 266 V 15 w(GID)f(and)g(the)h(name)e(corresp)q(onds)k(to)d(a)h(v)n(alid)75 316 y(user.)i(In)12 b(this)g(case)h(the)g Fh(username)f Fl(for)g(that)g(user) h(is)f(used)h(in)f(the)g(returned)i(\014lehandle,)e(allo)o(wing)e(the)i (readlink)75 366 y(op)q(eration)i(to)f(return)j(the)e(correct)i(link.)h(An)o (ything)c(else)i(is)e(a)h(stale)g(\014lehandle.)75 474 y Fj(4.1.4)55 b(The)19 b(readlink)e(Op)r(eration)175 549 y Fl(This)d(is)h(the)g(most)f(imp) q(ortan)o(t)e(op)q(eration,)j(the)g(cen)o(tral)g(p)q(oin)o(t)f(of)g(this)h(w) o(ork.)20 b(W)m(e)15 b(get)g(the)g Fh(uid)g Fl(n)o(um)o(b)q(er)75 599 y(from)c(the)j(creden)o(tials)g(sen)o(t)g(with)e(the)i(RPC)f(op)q (eration.)k(W)m(e)c(mak)o(e)e(sure)j(that)f(Unix)g(Authen)o(tication)g(or)g (DES)75 648 y(is)h(used)h(or)e(else)i(w)o(e)f(return)h(the)g(NFSERR)p 774 648 V 14 w(PERM)f(\(\\Not)g(Owner"\))h(co)q(de.)175 723 y(If)j(the)h Fh(gid)g Fl(of)f(the)h(accessing)h(pro)q(cess)g(is)f(not)g(HLFS) p 1064 723 V 15 w(GID,)e(the)i(v)n(alue)f(w)o(e)h(return)h(for)f(the)g(sym)o (b)q(olic)75 773 y(link)13 b(named)g Fk(home)379 758 y Fg(11)427 773 y Fl(is)h(a)g(string)g(represen)o(ting)i(the)f(home)e(directory)i(of)e (the)i(user)g(whose)g Fh(uid)f Fl(w)o(e)h(just)f(found,)75 823 y(concatenated)g(with)e(a)h(\014xed)g(comp)q(onen)o(t)e(name)h(represen)o (ting)i(a)e(sub)q(directory)i(within)e(it.)17 b(W)m(e)c(used)g(a)f(binary)75 873 y(searc)o(h)h(on)e(the)h(lo)q(okup)e(table)h(to)h(quic)o(kly)e(get)i(the) g(righ)o(t)f(pathname.)16 b(Di\013eren)o(t)c(home)e(directories)i(for)f(m)o (ultiple)75 922 y(passw)o(ord)i(database)f(en)o(tries)h(with)f(the)h(same)e Fh(uid)i Fl(n)o(um)o(b)q(ers)f(ma)o(y)e(return)j(an)o(y)f(of)g(the)h(home)e (directories.)18 b(Only)75 972 y Fh(uid)c Fl(0)g(is)f(guaran)o(teed)i(to)f (return)h(\\)p Fk(/)p Fl(".)i(See)e(also)e(Section)h(5.3.)175 1047 y(If)h(the)h(sym)o(b)q(olic)e(link)g(is)i(named)e Fk(home)h Fl(and)g(the)h Fh(gid)g Fl(is)f(HLFS)p 1206 1047 V 15 w(GID,)g(w)o(e)h (return)g(a)g(link)e(to)i(\\.",)e(whic)o(h)75 1097 y(causes)19 b Fk(hlfsd)d Fl(to)h(b)q(e)h(used)g(to)f(resolv)o(e)h(the)g(next)g(pathname)e (comp)q(onen)o(t.)27 b(This)17 b(is)h(designed)g(to)f(main)o(tain)75 1147 y(functionalit)o(y)c(of)i(programs)f(suc)o(h)i(as)f Fk(from)p Fl(.)20 b(If)15 b(the)h(sym)o(b)q(olic)d(link)h(is)h(not)g(named)f Fk(home)g Fl(and)h(the)h Fh(gid)f Fl(of)f(the)75 1196 y(accessing)j(pro)q (cess)g(is)e(HLFS)p 553 1196 V 16 w(GID,)f(w)o(e)i(return)g(a)f(v)n(alue)g(p) q(oin)o(ting)g(to)g(the)h(user's)h(mailb)q(o)o(x)12 b(\014le)k(in)f(their)h (mail)75 1246 y(sp)q(o)q(ol)c(directory)m(.)18 b(T)m(o)12 b(do)g(this,)g(w)o (e)h(extract)g(the)h Fh(username)e Fl(from)f(the)i(\014lehandle,)f(whic)o(h)h (w)o(as)f(returned)i(b)o(y)e(the)75 1296 y(lo)q(okup)h(op)q(eration.)18 b(See)d(T)m(able)e(2.)175 1371 y(T)m(rying)c(to)i(readlink)f(on)h(one)g(of)f (the)i(t)o(w)o(o)e(directories)i(results)g(in)e(an)h(NFSERR)p 1426 1371 V 15 w(ISDIR)f(\(\\Is)h(a)f(directory"\))75 1421 y(error.)19 b(An)o(ything)13 b(else)i(is)f(a)f(stale)h(\014lehandle.)75 1528 y Fj(4.2)56 b(Execution)17 b(Flo)n(w)175 1604 y Fl(A)o(t)12 b(initialization)d(time,)i Fk(hlfsd)g Fl(creates)j(a)e(UDP)g(service,)i(and)e (forks)g(a)g(c)o(hild.)17 b(The)c(c)o(hild)e(builds)h(the)h Fh(uid)75 1653 y Fl(lo)q(okup)h(table,)g(sets)i(up)e(signal)g(handlers,)h (and)f(in)o(terv)n(al)g(timers.)19 b(The)c(signal)e(handlers)i(are)g(mean)o (t)f(to)g(reload)75 1703 y(the)i(lo)q(okup)f(table)g(at)g(expiration)g(time)f (of)h(the)h(in)o(terv)n(al)f(timer,)f(or)i(when)g(a)f(SIGHUP)g(is)h(sen)o(t)g (to)f(the)h(serv)o(er)75 1753 y(\(presumably)11 b(b)o(y)h(a)f(sup)q (eruser\).)20 b(A)12 b(sp)q(ecial)g(clean)o(up)h(handler)f(is)f(setup)i(for)f (SIGTERM,)f(to)g(ensure)j(the)e(serv)o(er)75 1803 y(terminates)i(cleanly)m(.) j(Then)d(the)h Fk(svc)p 682 1803 14 2 v 15 w(run\(\))e Fl(routine)h(is)f(in)o (v)o(ok)o(ed.)175 1878 y(Mean)o(while)i(the)i(paren)o(t)g(w)o(aits)f(for)f (the)i(c)o(hild)f(to)g(initialize.)23 b(When)16 b(it)g(do)q(es,)h(the)g (paren)o(t)f(moun)o(ts)f(the)75 1927 y(serv)o(er)g(on)f(the)g(moun)o(t)e(p)q (oin)o(t.)18 b(Of)c(utmost)e(imp)q(ortance)h(is)h(to)g(mak)o(e)e(sure)j(the)f (attribute)g(cac)o(he)h(is)f(turned)g(o\013.)75 1977 y(If)h(the)g(attribute)h (cac)o(he)f(is)g(not)g(turned)h(o\013,)f(successiv)o(e)i(accesses)g(to)e Fk(/mail/home)e Fl(w)o(ould)h(return)i(previously)75 2027 y(computed)f (pathnames)g(p)q(oin)o(ting)f(to)i(another)g(user's)g(mail,)d(resulting)j(in) f(mail)e(loss)i(or)h(misdeliv)o(ery)m(.)21 b(If)15 b(it)g(is)75 2077 y(not)d(p)q(ossible)g(to)g(turn)h(o\013)e(the)i(attribute)g(cac)o(he,)f Fk(hlfsd)f Fl(will)g(exit.)17 b(Ho)o(w)o(ev)o(er,)c(the)f(SA)g(has)h(the)f (option)g(to)f(force)75 2127 y Fk(hlfsd)j Fl(to)h(con)o(tin)o(ue)g(running)g (and)g(set)h(the)f(attribute)h(cac)o(he)g(to)f(as)g(short)g(an)g(in)o(terv)n (al)f(as)h(p)q(ossible)h(\(See)g(also)75 2176 y(Section)e(5.3\).)j(A)o(t)d (this)g(p)q(oin)o(t)g(the)g(paren)o(t)h(terminates,)e(lea)o(ving)f(the)j(c)o (hild)e(to)h(run.)175 2251 y(When)j(an)f(in)o(terv)n(al)g(timer)g(go)q(es)h (o\013)g(\(SIGALRM\))f(or)h(a)f(SIGHUP)h(is)g(sen)o(t)g(to)g(the)h(serv)o (er,)g(the)f(serv)o(er)75 2301 y(forks)d(a)g(c)o(hild)g(that)g(con)o(tin)o (ues)h(serving,)f(while)g(the)h(paren)o(t)g(reloads)f(the)h(lo)q(okup)f (table.)19 b(When)14 b(the)h(paren)o(t)g(is)75 2351 y(\014nished)f(loading,)d (it)i(sends)i(a)e(SIGKILL)g(to)g(the)h(c)o(hild)e(pro)q(cess,)j(and)e (resumes)h(serving.)k(When)c(a)f(SIGTERM)75 2401 y(is)h(receiv)o(ed,)h(the)g (serv)o(er)g(forks)f(a)g(c)o(hild)g(that)g(con)o(tin)o(ues)g(serving,)g (while)g(it)g(tries)g(to)g(unmoun)o(t)f(the)i(\014lesystem.)75 2450 y(If)f(and)f(when)i(that)f(succeeds,)i(b)q(oth)e(paren)o(t)g(and)g(c)o (hild)f(exit.)175 2525 y(As)i(mail)d(service)k(is)e(v)o(ery)h(imp)q(ortan)o (t,)d(w)o(e)j(w)o(an)o(ted)g(to)f(mak)o(e)g Fk(hlfsd)f Fl(as)i(robust)g(as)g (p)q(ossible.)20 b(W)m(e)14 b(could)75 2575 y(ha)o(v)o(e)k(designed)g(it)f (as)h(another)g Fk(amd)g Fl(\\\014lesystem)f(t)o(yp)q(e",)h(but)g(decided)h (that)f(a)f(separate)i(daemon)e(pro)o(vides)75 2625 y(b)q(etter)i(reliabilit) o(y)c(and)j(faster)g(service.)29 b(In)18 b(general,)g(w)o(e)f(try)h(to)f(do)g (as)h(m)o(uc)o(h)e(as)h(p)q(ossible:)25 b(w)o(e)18 b(mak)o(e)e(sure)p 75 2659 720 2 v 106 2686 a Ff(11)139 2698 y Fe(The)11 b(name)f(of)h(the)g (sym)o(b)q(olic)e(link)i(is)g(con\014gurable.)965 2825 y Fl(8)p eop %%Page: 9 9 bop 75 42 a Fl(\014lesystems)10 b(are)h(accessible)h(and)e(con)o(tain)f(some) h(disk)g(space)h(to)f(ha)o(v)o(e)g(mail)e(deliv)o(ered)j(there.)18 b(Where)11 b(directories)75 91 y(are)j(exp)q(ected)h(w)o(e)f(mak)o(e)d(sure)k (there)f(are)g(no)f(\014les)h(b)o(y)f(these)h(names;)f(where)h(sym)o(b)q (olic)d(links)i(are)h(exp)q(ected,)h(w)o(e)75 141 y(mak)o(e)f(sure)i(there)h (are)e(no)g(real)h(\014les)f(or)h(directories)g(with)f(the)h(same)e(name.)21 b(Whenev)o(er)c(p)q(ossible,)e(w)o(e)g(create)75 191 y(directories,)f(with)f (prop)q(er)i(o)o(wnership)f(and)f(p)q(ermissions.)k(W)m(e)c(ev)o(en)h(c)o (hec)o(k)h(that)e(the)h(moun)o(t)e(p)q(oin)o(t)h(for)g Fk(hlfsd)75 241 y Fl(is)h(w)o(orld)f(readable)h(and)g(executable,)h(since)f(if)f(it)h (isn't,)f Fk(getwd\(".."\))e Fl(migh)o(t)h(fail.)75 349 y Fj(4.3)56 b(Alternate)17 b(Mail)h(Sp)r(o)r(ol)g(Directories)175 424 y Fk(Hlfsd)e Fl(tries)i(to)g(ensure)h(that)f(the)g(user's)g(home)f(directory)h (is)f(accessible.)31 b(P)o(erio)q(dically)16 b(it)i(also)f(tests)75 474 y(that)i(it)f(can)h(b)q(e)g(written)g(in)o(to)f(\(Section)h(4.5\).)31 b(If)18 b(for)h(an)o(y)f(reason)h(a)f(failure)g(o)q(ccurs,)j Fk(hlfsd)c Fl(rep)q(oin)o(ts)i(the)75 523 y(sym)o(b)q(olic)11 b(link)h(for)g(that)h(user)h(to)f(an)f(alternate)h(lo)q(cal)f(directory)m(,)h (whic)o(h)g(is)g(presumably)e(highly)h(a)o(v)n(ailable.)j(W)m(e)75 573 y(use)g Fk(/var/spool/alt)p 457 573 14 2 v 13 w(mail)e Fl(in)g(our)h(en)o(vironmen)o(t.)j(See)e(T)m(able)e(3.)1167 558 y Fg(12)p 75 636 1800 5 v 238 690 a Fl(Conditions:)k(An)o(y)d Fh(uid)p Fl(,)g Fh(gid)p Fi(6)p Fl(=HLFS)p 829 690 13 2 v 15 w(GID,)f(and)g Fk(~)p Fh(USER)p Fk(/.mailspool/)f Fl(is)i(not)p 1479 697 60 2 v 14 w(writable.)p 343 710 1265 2 v 342 759 2 50 v 351 759 V 376 744 a Fm(Resolving)p 629 759 V 1083 759 V 1598 759 V 1607 759 V 342 809 V 351 809 V 376 794 a(comp)q(onen)o(t)p 629 809 V 47 w(P)o(athname)g(left)p 1083 809 V 157 w(V)l(alue)h(if)g(sym)o(b) q(olic)f(link)p 1598 809 V 1607 809 V 343 811 1265 2 v 343 821 V 342 871 2 50 v 351 871 V 376 856 a Fk(/)p 629 871 V 256 w(var/mail/)p Fh(NAME)p 1083 871 V 1598 871 V 1607 871 V 343 872 1265 2 v 342 922 2 50 v 351 922 V 376 907 a Fk(var)p Fl(/)p 629 922 V 191 w Fk(mail/)p Fh(NAME)p 1083 922 V 1598 922 V 1607 922 V 343 924 1265 2 v 342 974 2 50 v 351 974 V 376 959 a Fk(mail)p Fl(@)p 629 974 V 158 w Fk(/mail/home/)p Fh(NAME)p 1083 974 V 85 w Fk(mail)p Fl(@)g Fi(\))f Fk(/mail/home)p 1598 974 V 1607 974 V 343 975 1265 2 v 342 1025 2 50 v 351 1025 V 376 1010 a(/)p 629 1025 V 256 w(mail/home/)p Fh(NAME)p 1083 1025 V 1598 1025 V 1607 1025 V 343 1027 1265 2 v 342 1077 2 50 v 351 1077 V 376 1062 a Fk(mail)p Fl(/)p 629 1077 V 169 w Fk(home/)p Fh(NAME)p 1083 1077 V 1598 1077 V 1607 1077 V 343 1078 1265 2 v 342 1128 2 50 v 351 1128 V 376 1113 a Fk(home)p Fl(@)p 629 1128 V 158 w Fh(NAME)p 1083 1128 V 327 w Fk(home)p Fl(@)h Fi(\))f Fk(/var/alt)p 1476 1113 14 2 v 14 w(mail)p 1598 1128 2 50 v 1607 1128 V 343 1130 1265 2 v 342 1180 2 50 v 351 1180 V 376 1165 a(/)p 629 1180 V 256 w(var/alt)p 811 1165 14 2 v 15 w(mail/)p Fh(NAME)p 1083 1180 2 50 v 1598 1180 V 1607 1180 V 343 1181 1265 2 v 342 1231 2 50 v 351 1231 V 376 1216 a Fk(var)p Fl(/)p 629 1231 V 191 w Fk(alt)p 723 1216 14 2 v 15 w(mail/)p Fh(NAME)p 1083 1231 2 50 v 1598 1231 V 1607 1231 V 343 1233 1265 2 v 342 1282 2 50 v 351 1282 V 376 1268 a Fk(alt)p 445 1268 14 2 v 15 w(mail)p Fl(/)p 629 1282 2 50 v 88 w Fh(NAME)p 1083 1282 V 1598 1282 V 1607 1282 V 343 1284 1265 2 v 342 1334 2 50 v 351 1334 V 376 1319 a(NAME)p 629 1334 V 1083 1334 V 1598 1334 V 1607 1334 V 343 1336 1265 2 v 380 1410 a Fl(T)m(able)g(3:)18 b(Resolving)13 b Fk(/var/mail/)p Fh(NAME)f Fl(to)i Fk(/var/alt)p 1323 1410 14 2 v 14 w(mail/)p Fh(NAME)p 75 1460 1800 5 v 175 1600 a Fl(When)f Fk(hlfsd)f Fl(starts)i(up,)f(and)g(b)q(efore)h(it)f(moun)o (ts)f(itself)h(on)f(top)i(of)e(the)i(moun)o(t)d(p)q(oin)o(t,)i(hiding)f(an)o (ything)75 1650 y(that)k(is)f(underneath,)i Fk(hlfsd)e Fl(creates)i(a)f (\014xed)g(sym)o(b)q(olic)e(link)g(to)i(the)g(alternate)g(sp)q(o)q(ol)g (directory)g(\(if)f(it)g(do)q(es)75 1700 y(not)e(exist)g(already\).)k(This)c (is)g(done)g(so)g(that)f Fk(/var/spool/mail)e Fl(w)o(ould)i(not)h(b)q(e)g(a)g (\\dangling")d(sym)o(b)q(olic)h(link,)75 1750 y(and)j(p)q(oin)o(ts)g(to)f(a)h (real)g(directory)h(at)f(all)e(times,)h(ev)o(en)i(after)f Fk(hlfsd)f Fl(terminates.)18 b(When)c Fk(hlfsd)f Fl(runs,)h(it)g(hides)75 1799 y(this)h(sym)o(b)q(olic)e(link,)h(and)h(pro)o(vides)g(our)g(\\dynamic")e (sym)o(b)q(olic)g(link.)20 b(This)15 b(tric)o(k)g(at)g(least)g(pro)o(vides)g (us)g(with)75 1849 y(an)f(alternate)g(place)g(to)g(deliv)o(er)g(mail)d(when)j (things)g(go)f(wrong,)h(rather)g(than)g(b)q(ounce)h(or)f(drop)g(the)g(mail.) 175 1924 y(A)g(cron)h(job)e(on)h(our)h(systems)f(c)o(hec)o(ks)i(the)f (alternate)f(mail)e(sp)q(o)q(ol)i(directory)h(sev)o(eral)g(times)e(a)h(da)o (y)m(.)k(An)o(y)75 1974 y(messages)12 b(found)g(there)i(are)f(resen)o(t)g(to) g(their)f(righ)o(tful)f(o)o(wners.)19 b(The)12 b(remailing)e(script)j(can)g (b)q(e)g(run)f(as)h(often)f(as)75 2024 y(needed.)19 b(Eac)o(h)14 b(in)o(v)o(o)q(cation)e(of)h(the)g(script)h(deals)g(only)e(with)h(newly)g (lost)g(mail)e(since)j(the)g(previous)g(in)o(v)o(o)q(cation;)75 2073 y(the)f(script)g(lo)q(c)o(ks)g(and)f(renames)h(the)g(lost)f(mailb)q(o)o (x)e(\014le)i(to)h(a)f(unique)h(name,)e(b)q(efore)i(parsing)f(and)h (remailing)d(it.)175 2148 y(Similar)j(to)k Fk(amd)p Fl(,)f Fk(hlfsd)f Fl(can)i(log)e(debugging)h(and)h(v)n(arious)e(status)j (information)13 b(to)k(a)f(designated)h(log)75 2198 y(\014le)e(or)h(using)f (the)h Fk(syslog)p Fl([22)n(])f(facilit)o(y)m(.)21 b(The)16 b(SA)f(ma)o(y)f(c)o(ho)q(ose)i(to)g(w)o(atc)o(h)f(these)i(log)e(\014les)g (and)h(facilities)e(and)75 2248 y(b)q(e)h(noti\014ed)e(when)i(serious)f (problems)f(o)q(ccur)i(suc)o(h)g(as)f(a)g(full)e(\014lesystem.)75 2356 y Fj(4.4)56 b(Av)n(oiding)18 b(Hangs)175 2431 y Fl(As)10 b(describ)q(ed)i(in)e(Section)h(4.2,)e Fk(hlfsd)g Fl(forks)i(a)e(c)o(hild)h (at)g(an)o(y)g(p)q(oin)o(t)g(where)h(w)o(e)g(susp)q(ect)h(that)e(an)g(op)q (eration)75 2481 y(migh)o(t)h(hang.)17 b(If,)12 b(for)h(example,)e(the)j (home)e(mac)o(hine)f(of)i(the)g(user)h(is)f(do)o(wn,)g(and)f(the)i (\014lesystem)f(on)f(a)h(clien)o(t)g(is)75 2530 y(hard-moun)o(ted,)h Fk(hlfsd)f Fl(will)h(hang)g(un)o(til)g(the)i(remote)e(serv)o(er)i(is)f(bac)o (k)g(up.)21 b(P)o(erforming)13 b(these)j(op)q(erations)f(in)75 2580 y(the)f(bac)o(kground)g(pro)o(vides)g(added)h(reliabilit)o(y)m(,)c(an)i (idea)h(tak)o(en)g(from)e Fk(amd)p Fl(.)p 75 2615 720 2 v 106 2642 a Ff(12)139 2653 y Fe(In)f(the)f(conditions)f(for)i(T)m(able)g(3,)g Fd(~)p Fc(USER)h Fe(is)g(the)f(home)f(directory)f(of)i(the)g(user)f(with)i (user-id)e Fc(uid)p Fe(.)965 2825 y Fl(9)p eop %%Page: 10 10 bop 75 42 a Fj(4.5)56 b(Disk)18 b(Space)g(Problems)175 117 y Fk(Hlfsd)13 b Fl(c)o(hec)o(ks)j(if)e(the)h(user's)h(home)e(directory)h(is)g (full)e(or)i(they)g(exceeded)i(their)e(quota.)20 b(It)15 b(attempts)f(to)75 166 y(create)i(and)e(then)h(remo)o(v)o(e)e(a)h(simple)f(nonzero-length)i (\014le)f(in)g(the)h(user's)g(sp)q(o)q(ol)f(directory)m(,)h(with)f(the)h (e\013ectiv)o(e)75 216 y Fh(uid)j Fl(set)g(to)f(that)h(of)f(the)h(user.)30 b(If)17 b(that)g(fails,)g(it)g(instead)h(returns)h(bac)o(k)e(the)h(name)e(of) h(the)h(alternate)g(sp)q(o)q(ol)75 266 y(directory)d(as)f(the)g(v)n(alue)f (of)h(the)g Fk(home)f Fl(sym)o(b)q(olic)f(link.)17 b(Otherwise)f(mail)11 b(migh)o(t)h(b)q(e)i(dropp)q(ed)h(or)f(b)q(ounce.)175 341 y(An)o(y)j(success) k(or)d(failure)f(state)h(is)g(recorded)i(in)d Fk(hlfsd)o Fl(.)30 b(It)18 b(is)g(left)g(there)h(for)e(a)h(sp)q(eci\014ed)h(n)o(um)o(b)q(er)f (of)75 391 y(seconds,)k(after)f(whic)o(h)e(the)i(en)o(try)g(\\times)d(out")i (and)g(a)f(new)i(actual)e(bac)o(kgrounded)i(lo)q(okup)e(is)g(required.)75 440 y(Otherwise,)14 b(the)g(cac)o(hed)g(result)g(is)f(used)g(and)g(no)g(exp)q (ensiv)o(e)h Fk(fork)e Fl(is)h(required.)19 b(This)13 b(simple)e(cac)o(hing)i (feature)75 490 y(of)g Fk(hlfsd)g Fl(has)h(greatly)g(impro)o(v)o(ed)e(its)i (p)q(erformance)g(and)f(reliabilit)o(y)m(.)j(See)f(also)e(Section)h(5.3.)75 598 y Fj(4.6)56 b(Lo)r(c)n(k)17 b(Files)175 673 y Fl(An)12 b(alternativ)o(e)h(design)g(for)f Fk(hlfsd)f Fl(is)i(to)f(ha)o(v)o(e)h(it)f (moun)o(t)f(on)h(top)h(of)f(the)h(mail)d(sp)q(o)q(ol)i(directory)i(directly)m (,)75 723 y(instead)d(of)f(ha)o(ving)f(the)j(mail)c(sp)q(o)q(ol)i(directory)h (b)q(e)g(a)g(sym)o(b)q(olic)e(link)g(to)i(another)g(link)e(\()p Fk(home)p Fl(\))h(within)g(the)h(HLFS,)75 773 y(whic)o(h)k(p)q(oin)o(ts)g(to) g(a)f(real)h(sub)q(directory)i(of)d(the)i(user's)g(home.)k(With)15 b(some)f(mo)q(di\014cations)f(to)i(the)g(serv)o(er,)i(w)o(e)75 823 y(could)d(ha)o(v)o(e)g(made)f(all)h(of)f(the)i(user's)h(mailb)q(o)o(x)11 b(\014les)k(p)q(oin)o(t)f(to)g(the)h(righ)o(t)f(place,)g(but)g(it)g (su\013ered)j(from)12 b(serious)75 873 y(dra)o(wbac)o(ks:)137 977 y Fi(\017)21 b Fl(The)15 b(sp)q(o)q(ol)f(directory)i(w)o(ould)d(no)i (longer)f(b)q(e)h(a)g(regular)f(directory)m(.)21 b(It)14 b(w)o(ould)g(ha)o(v) o(e)h(to)f(b)q(e)h(managed)e(b)o(y)179 1027 y Fk(hlfsd)o Fl(.)18 b(This)c(w)o(ould)f(require)h(the)h(implemen)o(tatio)o(n)c(of)i(more)g(NFS)h (op)q(erations.)137 1105 y Fi(\017)21 b Fl(The)e(user's)h(sp)q(o)q(ol)f (\014le)g(w)o(ould)g(not)g(b)q(e)g(a)g(regular)g(\014le,)h(but)f(a)g(sym)o(b) q(olic)e(link)h(to)h(suc)o(h.)35 b(Some)18 b(mail)179 1155 y(programs)e(remo)o(v)o(e)g(that)h(\014le,)g(not)g(c)o(hec)o(king)g(if)f (it's)h(a)f(sym)o(b)q(olic)g(link.)26 b(Therefore)18 b(the)g(sym)o(b)q(olic)d (link)179 1205 y(w)o(ould)10 b(b)q(e)i(remo)o(v)o(ed.)k(W)m(e)10 b(w)o(ould)h(ha)o(v)o(e)g(had)f(to)h(c)o(hange)h(the)f(serv)o(er)i(so)e(that) g(remo)o(ving)e(the)j(sym)o(b)q(olic)d(link)179 1255 y(w)o(ould)14 b(\014rst)i(follo)o(w)d(it)i(and)g(remo)o(v)o(e)f(the)i(\014le)f(it)g(w)o(as) g(p)q(oin)o(ting)f(to.)22 b(The)16 b(same)e(go)q(es)i(for)f(all)f(op)q (erations)179 1304 y(whic)o(h)g(require)g(access)i(to)e(the)g(user's)h(mail)c (sp)q(o)q(ol)j(\014le.)137 1383 y Fi(\017)21 b Fl(The)11 b(w)o(orst)f (problem)f(w)o(as)h(that)h(di\013eren)o(t)g(UAs)g(and)f(MT)m(As)g(use)h (di\013eren)o(t)h(metho)q(ds)d(for)h(lo)q(c)o(king)g(the)h(mail)179 1432 y(\014le.)17 b(Some)12 b(of)g(them)h(create)h(temp)q(orary)e(\014les)h (named)f Fk($)p Fi(f)p Fk(USER)p Fi(g)p Fk(.lock)p Fl(,)e(others)k(use)g(the) f Fk(mktemp)f Fl(library)179 1482 y(call)17 b(to)h(generate)i(unique)e (names.)31 b(Our)19 b(metho)q(d)e(a)o(v)o(oids)h(the)g(need)i(to)e(\014gure)h (out)f(all)f(the)i(di\013eren)o(t)179 1532 y(metho)q(ds)13 b(used)i(in)e(lo)q(c)o(king)g(mail)e(\014les,)j(and)g(usage)g(of)g(temp)q (orary)f(\014les.)175 1636 y(An)g(alternate)h(w)o(a)o(y)e(to)h(a)o(v)o(oid)f (the)i(need)g(for)f(lo)q(c)o(k)g(\014les)h(is)f(to)g(deliv)o(er)g(mail)e(one) i(message)g(p)q(er)h(\014le)f(using)g(a)75 1686 y(di\013eren)o(t)i(system)g (suc)o(h)g(as)f(with)h(INN[19)o(])f(and)g(NNTP[10];)f(ho)o(w)o(ev)o(er,)i (this)f(w)o(ould)g(require)h(mo)q(di\014cations)e(to)75 1736 y(all)g(UAs)h(and)g(MT)m(As.)75 1844 y Fj(4.7)56 b(Source)18 b(Co)r(de)g(Size,)g(Av)m(ailabilit)n(y)-5 b(,)16 b(and)k(P)n(ortabilit)n(y) 175 1919 y Fk(Hlfsd)c Fl(is)h(less)h(than)f(2500)f(lines)h(of)f(C)h(co)q(de,) i(including)d(commen)o(ts)f(and)i(white-spaces.)29 b(Ho)o(w)o(ev)o(er,)18 b(it)75 1969 y(mak)o(es)13 b(use)h(of)g(almost)e(4000)h(lines)g(of)h(co)q(de) g(from)f(the)h Fk(amd)f Fl(distribution)h(itself.)175 2044 y Fk(Hlfsd)g Fl(is)h(a)o(v)n(ailable)e(in)i(source)i(form)c(as)j(part)f(of)g (a)g(sp)q(ecial)h(distribution)e(of)h Fk(amd)p Fl(.)22 b(It)15 b(can)h(b)q(e)g(retriev)o(ed)75 2094 y(via)d(anon)o(ymous)f Fk(ftp)h Fl(from)f Fk(ftp.cs.columbia.edu)e Fl(in)k(the)g(directory)h Fk(/pub/amd)p Fl(.)175 2168 y Fk(Hlfsd)h Fl(is)i(built)f(as)g(part)h(of)f (the)h(sp)q(ecial)g(distribution)f(of)g Fk(amd)g Fl(a)o(v)n(ailable)f(from)g (our)h(ftp)h(serv)o(er.)30 b(It)18 b(is)75 2218 y(almost)12 b(as)j(p)q(ortable)f(as)g Fk(amd)g Fl(is.)k(It)c(is)h(only)e(the)i(lac)o(k)e (of)h(access)i(to)e(certain)h(mac)o(hines)e(that)h(stopp)q(ed)h(us)g(from)75 2268 y(p)q(orting)d Fk(hlfsd)f Fl(to)i(the)g(n)o(umerous)f(platforms)e Fk(amd)i Fl(runs)h(on.)k(A)o(t)c(the)g(writing)f(of)f(this)i(pap)q(er,)g Fk(hlfsd)e Fl(has)i(b)q(een)75 2318 y(successfully)h(p)q(orted)g(and)e (running)h(on)f(SunOS)i(4.1.3,)c(HP-UX)k(9.0.1,)d(and)h(Solaris)g(2.2.)17 b(Those)c(represen)o(t)i(the)75 2367 y(3)h(main)e(system)i(t)o(yp)q(es)h Fk(amd)e Fl(runs)i(on)f(and)f(span)i(most)e(Unix)g(\015a)o(v)o(ors:)22 b(a)16 b(BSD-st)o(yle)g(system,)g(an)g(SVR-BSD)75 2417 y(h)o(ybrid,)d(and)h (a)f(system)h(v)o(ery)g(close)h(to)e(SVR4,)g(resp)q(ectiv)o(ely)m(.)75 2525 y Fj(5)56 b(Ev)m(aluation)175 2600 y Fl(This)11 b(system)h(is)g(implem)o (en)o(ted)e(and)i(has)g(b)q(een)h(in)e(use)i(on)e(a)h(n)o(um)o(b)q(er)f(of)g (mac)o(hines)g(for)h(more)e(than)i(a)g(y)o(ear)75 2650 y(no)o(w.)20 b(F)m(or)14 b(the)h(\014rst)g(nine)g(mon)o(ths)e Fk(hlfsd)h Fl(w)o(as)g(in)g(exp)q(erimen)o(tal)g(use.)21 b(W)m(e)14 b(ha)o(v)o(e)h (since)g(deplo)o(y)o(ed)g(it)f(on)g(most)75 2700 y(pro)q(duction)g(mac)o (hines)f(in)h(our)f(departmen)o(t,)h(spanning)f(o)o(v)o(er)h(a)g(100)f(hosts) h(and)g(3)g(di\013eren)o(t)g(arc)o(hitectures.)954 2825 y(10)p eop %%Page: 11 11 bop 175 42 a Fl(The)11 b(goal)f(of)h(this)g(w)o(ork)g(is)f(to)h(expand)h(the) f(accessibilit)o(y)g(of)g(electronic)h(mail,)d(impro)o(v)o(e)g(o)o(v)o(erall) h(reliabilit)o(y)75 91 y(and)i(stabilit)o(y)f(of)g(this)h(vital)f(service,)j (while)d(at)h(the)h(same)e(time)g(main)o(tain)e(the)k(sanit)o(y)f(of)f(our)h (SAs)h(\(y)o(ours)f(truly)75 141 y(included\).)18 b(F)m(or)c(this)g(to)g (really)f(w)o(ork,)g(it)g(m)o(ust)g(ha)o(v)o(e:)126 257 y(1.)20 b(V)m(ery)14 b(high)f(a)o(v)n(ailabilit)o(y)l(.)126 340 y(2.)20 b(Little)13 b(o)o(v)o(erhead.)126 423 y(3.)20 b(Little)14 b(hassle)g(for)g (users)i(and)e(administrators)e(as)i(the)h(system)f(is)g(b)q(eing)g(used)h (or)f(installed)g(for)f(the)i(\014rst)179 473 y(time.)75 598 y Fj(5.1)56 b(P)n(erformance)175 673 y Fl(W)m(e)15 b(ha)o(v)o(e)g(carried)h (out)g(some)e(measuremen)o(ts)h(to)h(quan)o(tify)e(the)i(ab)q(o)o(v)o(e)f (requiremen)o(ts)h(and)g(more.)22 b(The)75 723 y(tests)15 b(w)o(ere)g(p)q (erformed)f(on)f(a)h(Sun)g(SP)m(AR)o(Cstation-2)f(running)g(SunOS)i(4.1.3.) 175 797 y(Accessing)20 b(a)f(lo)q(cal)g(sp)q(o)q(ol)g(\014le)g(via)f Fk(stat)h Fl(normally)d(tak)o(es)k(180)e(msec)h(without)g Fk(hlfsd)o Fl(.)34 b(If)19 b Fk(hlfsd)f Fl(is)75 847 y(running)g(and)g(has)g(the)h (user's)h(en)o(try)e(already)g(cac)o(hed,)i(it)e(tak)o(es)h(60)f(msec)g(more) f(to)h(access)i(the)f(\014le.)31 b(This)75 897 y(o)o(v)o(erhead)19 b(is)f(attributed)h(to)f(the)h(fact)g(that)f(the)h(k)o(ernel)g(has)g(to)f (access)i(a)e(user-lev)o(el)h(NFS)g(serv)o(er,)h(making)75 947 y(sev)o(eral)14 b(con)o(text)h(switc)o(hes.)175 1022 y(If)h(the)h(en)o (try)h(is)e(not)h(cac)o(hed,)h Fk(hlfsd)e Fl(forks)g(a)h(c)o(hild)f(to)h(p)q (erform)f(op)q(erations)h(whic)o(h)f(ma)o(y)f(cause)j(it)e(to)75 1071 y(hang.)21 b(The)16 b(o)o(v)o(erhead)f(of)f(that)i Fk(fork)e Fl(and)h(other)g(c)o(hec)o(ks)i(is)e(an)f(additional)g(70)g(msec)h(\(or)g (130)f(msec)h(o)o(v)o(er)g(the)75 1121 y(regular)d(lo)q(okup)f(not)g(using)h Fk(hlfsd)o Fl(\).)17 b(Ho)o(w)o(ev)o(er,)12 b(this)g(o)o(v)o(erhead)g(is)g (incurred)h(only)d(once)j(in)e(5)h(min)o(utes,)e(b)q(ecause)75 1171 y(the)k(result)h(of)e(eac)o(h)i(c)o(hec)o(k)g(is)e(cac)o(hed)i(for)f (that)g(long)f(b)o(y)g(default.)175 1246 y(The)f(ab)q(o)o(v)o(e)g(times)f (are)i(somewhat)e(signi\014can)o(t,)g(but)i(not)e(b)o(y)h(m)o(uc)o(h,)f (considering)h(the)h(use)g(of)f(a)f(user-lev)o(el)75 1296 y(\014le-serv)o (er.)19 b(\(By)12 b(comparison,)e(in)h(our)h(en)o(vironmen)o(t)f(it)g(tak)o (es)h(ab)q(out)g(0.5)e(seconds)k(to)d(access)j(a)d(new)h(\014lesystem)75 1345 y(using)h Fk(amd)p Fl(.\))18 b(Giv)o(en)13 b(the)h(b)q(ene\014ts)i(of)d Fk(hlfsd)o Fl(,)g(w)o(e)h(feel)g(that)g(a)f(minima)o(l)e(access)k(slo)o(wdo)o (wn)e(is)h(a)f(small)f(price)i(to)75 1395 y(pa)o(y)m(.)j(In)d(practice,)g(o)o (v)o(er)g(12)g(mon)o(ths)e(of)i(usage)g(w)o(e)g(ha)o(v)o(e)g(noticed)g(no)g (visible)f(degradation)g(of)h(service.)1734 1380 y Fg(13)175 1470 y Fl(The)h(in)o(ternal)g(data)h(structures)h(\(tables)f(and)f(cac)o (hes\))i(require)g(50)e(b)o(ytes)h(p)q(er)g(user)g(on)g(the)g(system.)22 b(In)75 1520 y(our)16 b(en)o(vironmen)o(t,)e(with)i(750)f(users,)i(that)f (translates)g(to)g(ab)q(out)f(37KB)h(|)f(rather)i(insigni\014can)o(t)e(giv)o (en)g(that)75 1570 y(w)o(orkstations)f(these)h(da)o(ys)f(come)f(installed)g (with)h(at)f(least)i(16-32MB)e(of)g(RAM.)75 1677 y Fj(5.1.1)55 b(Remailing)16 b(Lost)i(Mail)175 1753 y Fl(The)h Fk(hlfsd)f Fl(distribution)h(con)o(tains)g(a)f Fk(perl)p Fl([26)o(])g(script)i(called)f Fk(lostaltmail)p Fl(.)31 b(Remailing)16 b(a)i(single)75 1802 y(message)c(with)g(a)g(b)q(o)q(dy)g(size)h(of)f(1KB,)g(tak)o(es)h(an)f(a)o(v) o(erage)g(of)g(1.2)f(seconds)j(\(total)d(time\).)18 b(In)c(our)h(departmen)o (t,)75 1852 y(resending)g(an)e(a)o(v)o(erage)h(mailb)q(o)o(x)d(\014le)j(tak)o (es)h(ab)q(out)e(20)h(seconds.)175 1927 y(Initially)f(w)o(e)j(ran)g(the)h (script)f(once)h(a)e(da)o(y)m(,)g(but)h(found)g(ha)o(ving)f(to)g(w)o(ait)g (up)h(to)g(24)f(hours)i(for)e(lost)h(mail)75 1977 y(redeliv)o(ery)f(to)q(o)g (long.)k(W)m(e)14 b(then)i(exp)q(erimen)o(ted)f(with)f(running)g Fk(lostaltmail)f Fl(once)i(an)f(hour.)21 b(Ho)o(w)o(ev)o(er,)15 b(w)o(e)75 2027 y(found)c(that)g(frequency)h(to)q(o)f(fast.)17 b(The)12 b(most)e(lik)o(ely)f(situation)i(in)g(whic)o(h)g Fk(hlfsd)f Fl(will)f(rep)q(oin)o(t)j(its)f(sym)o(b)q(olic)e(link)75 2076 y(to)14 b(the)g(alternate)g(sp)q(o)q(ol)g(directory)g(is)g(when)g(the)g (user's)h(\014lesystem)f(is)f(full.)k(A)d(full)e(\014lesystem)i(is)g(a)f(p)q (ersisten)o(t)75 2126 y(situation)18 b(that)h(in)f(most)f(cases)j(tak)o(es)f (some)f(time)f(to)h(get)h(\014xed,)h(as)e(it)h(requires)g(h)o(uman)e(in)o (terv)o(en)o(tion.)32 b(If)75 2176 y(the)19 b(situation)f(that)h(causes)h Fk(hlfsd)e Fl(to)g(use)i(the)f(alternate)g(sp)q(o)q(ol)g(directory)g(is)g (lik)o(ely)e(to)i(p)q(ersist,)h(running)75 2226 y(the)15 b Fk(lostaltmail)e Fl(script)i(will)f(consume)g(unnecessary)j(resources,)g (only)d(to)h(redeliv)o(er)g(the)h(mail)c(bac)o(k)j(to)f(the)75 2276 y(alternate)f(sp)q(o)q(ol)f(directory)m(.)18 b(W)m(e)12 b(\014nally)g(settled)h(on)g(running)f Fk(lostaltmail)e Fl(b)q(et)o(w)o(een)k (6)e(and)h(12)f(times)f(a)h(da)o(y)m(.)75 2325 y(Dep)q(ending)i(on)g(the)g (amoun)o(t)e(of)i(lost)f(mail)e(exp)q(ected,)16 b(the)e(script)h(could)f(b)q (e)g(run)h(more)d(or)i(less)h(often.)75 2433 y Fj(5.1.2)55 b(Reliabilit)n(y)175 2509 y Fl(W)m(e)11 b(ha)o(v)o(e)h(sim)o(ulated)f(w)o (orst-case)i(scenarios)g(b)o(y)f(\014lling)e(up)i(a)g(user)h(\014lesystem)f (and)g(letting)g Fk(hlfsd)f Fl(decide)75 2558 y(to)k(redirect)i(mail)12 b(to)j(the)h(alternate)g(sp)q(o)q(ol)e(directory)m(.)22 b(A)o(t)16 b(this)f(p)q(oin)o(t)f(w)o(e)i(\014lled)f(up)g(that)g(\014lesystem)g(as)g(w)o (ell.)p 75 2593 720 2 v 106 2620 a Ff(13)139 2632 y Fe(The)g(SAs)h(group)e (felt)h(so)g(con)o(vinced)e(that)i Fd(hlfsd)f Fe(w)o(as)i(w)o(orking)e(w)o (ell,)j(that)d(w)o(e)i(w)o(ere)g(the)f(\014rst)g(to)g(use)g(it)g(on)g Fc(our)i Fe(home)75 2671 y(mac)o(hines.)954 2825 y Fl(11)p eop %%Page: 12 12 bop 75 42 a Fk(Hlfsd)16 b Fl(k)o(ept)i(on)e(p)q(oin)o(ting)g(to)h(the)h (alternate)g(sp)q(o)q(ol)f(directory)g(during)g(the)h(cac)o(hed)g(en)o(try)g (in)o(terv)n(al,)e(but)i(w)o(e)75 91 y(observ)o(ed)d(no)g(mail)c(lost.)19 b(Instead,)c(the)g(sending)g(side)f(detected)j(that)d(the)h(\014lesystem)f(w) o(as)h(full,)d(and)j(k)o(ept)f(the)75 141 y(message)g(in)f(the)i(remote)e (\(priv)n(ate\))h(sp)q(o)q(ol)g(directory)m(.)k(This)c(is)f(the)i(default)e (b)q(eha)o(vior)h Fk(sendmail)p Fl([1)n(])f(pro)o(vides.)175 216 y Fk(Hlfsd)d Fl(do)q(es)i(not)g(in)o(tro)q(duce)g(an)o(y)f(new)h (problems;)f(that)h(is,)f(if)g(a)h(\014lesystem)f(is)g(completely)g(full,)f (whatev)o(er)75 266 y(b)q(eha)o(vior)j(y)o(our)g(curren)o(t)h(LD)o(A)f(pro)o (vides)g(is)g(main)o(tained.)j(Since)e Fk(hlfsd)e Fl(uses)i(b)q(oth)f(the)h (user's)g(\014lesystem)f(and)75 315 y(an)18 b(alternate)h(sp)q(o)q(ol)f (directory)m(,)h(it)f(actually)g(increases)i(the)f(a)o(v)n(ailabili)o(t)o(y)c (of)j(mail)e(services,)21 b(b)o(y)d(\\virtually")75 365 y(increasing)c(the)h (disk)e(space)i(a)o(v)n(ailable)d(for)h(mail)f(sp)q(o)q(oling.)175 440 y(Once)g(space)g(has)f(b)q(een)h(freed)g(in)f(the)g(user's)h (\014lesystem,)f(and)g(the)h(cac)o(hed)g(en)o(try)f(expired,)h Fk(hlfsd)e Fl(p)q(oin)o(ted)75 490 y(its)h(sym)o(b)q(olic)f(link)h(bac)o(k)g (to)g(the)h(user's)h(home)d(directory)m(.)18 b(The)12 b(next)g(time)e(the)i (remailing)d(script)j(ran,)f(all)g(\\lost")75 540 y(mail)g(got)j(resen)o(t)h (to)f(its)g(o)o(wners.)175 614 y(Since)f(the)g(installation)d(of)i Fk(hlfsd)f Fl(in)h(our)h(pro)q(duction)f(en)o(vironmen)o(t,)f(w)o(e)i(ha)o(v) o(e)f(seen)i(a)e(few)h(cases)g(of)f(lost)75 664 y(mail)i(b)q(eing)i(resen)o (t,)i(mostly)c(due)j(to)f(full)f(\014lesystems.)25 b(W)m(e)16 b(kno)o(w)g(of)g(no)g(case)h(where)g(mail)d(w)o(as)i(completely)75 714 y(lost.)75 822 y Fj(5.2)56 b(Installation)175 897 y Fl(Since)13 b Fk(hlfsd)e Fl(w)o(as)i(written)g(b)o(y)f(SAs)h(for)f(other)h(SAs,)g(w)o(e)g (ha)o(v)o(e)f(pro)o(vided)h(it)f(with)g(sev)o(eral)h(command-li)o(ne)75 947 y(options)f(to)h(use)g(at)g(startup)g(time,)e(enabling)h Fk(hlfsd)g Fl(to)g(b)q(e)h(tailored)g(for)f(a)g(particular)h(en)o(vironmen)o (t.)j(Needless)75 997 y(to)g(sa)o(y)m(,)g(a)g(man)e(page)i(is)h(pro)o(vided,) f(as)g(w)o(ell)g(as)g(complete)g(source)h(co)q(de.)26 b(F)m(urthermore,)16 b(w)o(e)h(included)f(a)g(few)75 1046 y(scripts)f(written)f(in)f Fk(sh)g Fl(and)h Fk(perl)e Fl(whic)o(h)i(w)o(e)g(use)g(in)f(our)h(en)o (vironmen)o(t)e(to)i(re/start)h Fk(hlfsd)o Fl(,)e(test)h(for)g(p)q(ossible)75 1096 y(con\014guration)f(anomalies,)f(and)h(resend)j(\\lost")d(mail.)175 1171 y(The)e(most)f(signi\014can)o(t)h(w)o(ork)f(that)i(SAs)f(need)h(to)f(do) g(is)g(iden)o(tify)f(programs)g(that)h(need)h(to)f(access)i(mailb)q(o)o(x)75 1221 y(\014les)18 b(of)f(other)i(users,)h(and)d(\\)p Fh(setgid)p Fl(")h(them)f(to)g(HLFS)p 967 1221 13 2 v 15 w(GID.)g(In)h(our)g(en)o (vironmen)o(t)e(w)o(e)i(had)g(to)g(do)f(that)h(for)75 1271 y Fk(comsat)p Fl(,)f Fk(from)p Fl(,)g Fk(finger)g Fl(and)g(a)h(few)g(others.) 30 b(Our)19 b(en)o(vironmen)o(t)d(uses)j(the)g Fk(rdist)p Fl([5)n(])e (automatic)f(soft)o(w)o(are)75 1320 y(distribution)i(program,)g(and)g(th)o (us)h(these)h(c)o(hanges)f(w)o(ere)h(required)f(only)f(in)g(one)h(place)f(|)g (the)i(top)e(of)g(our)75 1370 y Fk(rdist)13 b Fl(tree.)75 1478 y Fj(5.3)56 b(Problems)175 1553 y Fl(There)15 b(are)f(a)g(few)g(problems,)e (some)h(of)g(whic)o(h)h(cannot)g(b)q(e)h(easily)e(resolv)o(ed:)137 1670 y Fi(\017)21 b Fl(Some)15 b(programs)g(need)i(to)f(b)q(e)h Fh(setgid)g Fl(to)f(the)h(sp)q(ecial)f(HLFS)p 1181 1670 V 15 w(GID)g(group.)25 b(There)17 b(is)g(no)f(easy)g(w)o(a)o(y)g(to)179 1719 y(lo)q(cate)f(them)g(other)h(than)g(kno)o(wing)e(ahead)i(of)f(time)f (what)h(they)h(do.)23 b(Note)16 b(that)f(if)g(the)h(programs)f(are)179 1769 y(not)c Fh(setgid)p Fl(,)g(the)h(only)f(consequence)i(is)e(that)h(these) g(programs)f(are)g(unable)g(to)g(\014nd)h(mailb)q(o)o(xes.)j(Ho)o(w)o(ev)o (er,)179 1819 y(with)e(other)i(metho)q(ds,)e(if)g($MAIL)h(is)f(not)h(used,)g (mail)e(is)h(not)h(deliv)o(ered.)137 1902 y Fi(\017)21 b Fl(It)12 b(is)f(p)q(ossible)h(that)g(the)h(status)f(of)g(a)f(home)g(directory)h (access)i(will)c(c)o(hange)j(during)e(the)i(time)d(that)i Fk(hlfsd)179 1952 y Fl(cac)o(hes)17 b(this)g(information.)23 b(Pic)o(king)15 b(a)h(smaller)f(cac)o(he)i(expiration)f(time)f(can)i(alleviate)e(this)i (problem,)179 2002 y(but)d(it)g(increases)h(the)g(resources)h(tak)o(en)e(b)o (y)g Fk(hlfsd)f Fl(and)h(slo)o(ws)f(do)o(wn)h(access)i(to)e(mail.)h(It)f(is)g (left)g(for)f(the)179 2051 y(individual)f(SAs)i(to)g(c)o(hange)g(this)g (default)f(v)n(alue.)137 2134 y Fi(\017)21 b Fl(An)o(y)14 b(logins)e(with)i (the)h(same)e Fh(uid)h Fl(and)f(a)h(di\013eren)o(t)h(home)e(directory)h(ma)o (y)e(ha)o(v)o(e)i(mail)d(deliv)o(ered)k(or)e(read)179 2184 y(from)c(an)o(y)i(of)f(their)h(home)f(directory)i(pathnames.)k Fk(Hlfsd)10 b Fl(stores)j(pathnames)d(in)g(an)h(in)o(ternal)g(hash)g(table) 179 2234 y(k)o(ey)o(ed)i(b)o(y)g(the)g Fh(uid)p Fl(;)g(therefore,)h(it)f(is)g (unde\014ned)h(whic)o(h)f(pathname)f(is)g(returned)j(in)d(the)i(case)g(of)e (m)o(ultiple)179 2284 y(users)k(with)e(the)h(same)f Fh(uid)h Fl(and)g(di\013eren)o(t)g(home)f(directories.)21 b(W)m(e)14 b(pro)o(vide)h(a)f(script)i(whic)o(h)e(c)o(hec)o(ks)i(for)179 2334 y(this)e(situation)f(and)h(w)o(arns)g(the)g(SAs.)137 2417 y Fi(\017)21 b Fl(On)16 b(systems)g(that)g(cannot)g(turn)g(o\013)g(the)g(NFS) g(attribute)g(cac)o(he,)h(the)g(k)o(ernel)f(migh)o(t)d(return)k(the)g(same) 179 2467 y(sym)o(b)q(olic)8 b(link)h(name)f(for)i(t)o(w)o(o)f(di\013eren)o(t) i(users)g(who)f(access)h(the)g(sp)q(o)q(ol)e(directory)i(consecutiv)o(ely)m (,)f(p)q(ossibly)179 2516 y(resulting)17 b(in)f(mail)e(getting)i(deliv)o (ered)h(to)g(the)g(wrong)g(mailb)q(o)o(x!)23 b(On)17 b(these)h(systems,)f Fk(hlfsd)f Fl(will)f(not)179 2566 y(run)h(unless)g(started)g(with)f(a)h(sp)q (ecial)f(option.)22 b(In)16 b(that)f(case)i(it)e(will)f(set)i(the)g (attribute)g(cac)o(he)g(v)n(alue)f(to)179 2616 y(the)f(shortest)i(p)q (ossible)e(in)o(terv)n(al,)e(but)i(it)g(ma)o(y)e(not)i(b)q(e)g(su\016cien)o (t.)954 2825 y(12)p eop %%Page: 13 13 bop 75 42 a Fj(6)56 b(Related)17 b(W)-5 b(ork)175 117 y Fl(The)18 b(idea)f(of)h(dynamic)e(or)h(v)n(ariable)g(pathname)g(comp)q(onen)o(ts)g(is)h (not)g(new.)30 b(HP-UX)18 b(do)q(es)g(this)g(with)75 166 y(con)o(text-dep)q (enden)o(t)g(\014les[8],)d(and)g(Mac)o(h)h(with)f(the)h(\\)p Fk(@SYS)p Fl(")f(v)n(ariables[4)n(].)23 b(Both)16 b(of)f(these)i(implemen)o (tations)75 216 y(supp)q(ort)11 b(replacemen)o(t)f(of)f(pathname)g(comp)q (onen)o(ts)h(b)o(y)g(k)o(ernel)g(v)n(ariables.)16 b(Ap)q(ollo's)9 b(DOMAIN/OS)i(supp)q(orted)75 266 y(a)20 b(more)g(sophisticated)h(system)f (where)i(arbitrary)e(user)i(en)o(vironmen)o(t)d(v)n(ariables)h(could)g(b)q(e) h(referenced)i(in)75 316 y(pathnames[11)n(,)12 b(12].)k(On)d(the)g(issue)g (of)e(ha)o(ving)g(a)h(user's)i(home)d(\014les)h(and)g(mailb)q(o)o(x)e(\014le) i(reside)h(in)f(one)g(lo)q(cation,)75 366 y(Plan)h(9's)h Fh(attach)g Fl(op)q(erator)h(can)f(b)q(e)g(used)h(to)f(unify)f(sev)o(eral)h(\014le)g (serv)o(ers)i(in)o(to)d(one)h(user)h(name)e(space[14].)175 440 y(What)f(is)h(new)g(ab)q(out)g(our)g(idea)g(is)g(that)g(w)o(e)g(do)f(not) h(require)h(an)o(y)f(c)o(hange)g(to)g(an)o(y)f(part)h(of)g(the)g (\014lesystem)75 490 y(implemen)o(tatio)o(n)c(in)i(the)i(k)o(ernel.)18 b(All)10 b(that)i(is)g(required)h(are)f(RPC)f(and)h(NFS,)f(making)f(the)i (system)f(m)o(uc)o(h)g(more)75 540 y(widely)i(applicable.)175 615 y(Though)i(at)h(\014rst)h(it)e(ma)o(y)f(app)q(ear)i(that)g Fk(amd)f Fl(can)i(do)e(what)h(hlfsd)f(do)q(es,)i(it)f(can't.)24 b Fk(Amd)15 b Fl(cannot)h(return)75 665 y(di\013eren)o(t)d(pathnames)f(as)g (a)g(v)n(alue)g(of)g(a)g(sym)o(b)q(olic)f(link)g(dep)q(ending)i(on)f(who)g (accessed)j(it.)i(See)c(also)f(Section)h(2.3)75 714 y(for)h(more)e(details)i (on)g(v)n(arious)f(w)o(a)o(ys)g(in)h(whic)o(h)g Fk(amd)f Fl(cannot)h(help)g (the)g(w)o(a)o(y)g Fk(hlfsd)e Fl(can.)75 822 y Fj(6.1)56 b(Mail-reading)17 b(Serv)n(ers)175 897 y Fl(The)11 b(future)g(of)g(mail)d(reading)i(and)h (sending)g(ma)o(y)e(b)q(e)i(similar)e(to)h(that)h(used)h(b)o(y)f(the)g(NNTP)g (proto)q(col)g(used)75 947 y(for)g(managing)d(NetNews[10)q(,)j(19)o(].)17 b(That)11 b(is,)g(a)g(sp)q(ecial-purp)q(ose)h(serv)o(er)h(whic)o(h)e(pro)o (vides)h(net)o(w)o(ork)f(connections)75 997 y(for)j(reading)f(and)h(writing)f (mail)e(remotely)m(.)175 1072 y(Sev)o(eral)19 b(suc)o(h)g(programs)f(exist,)i (most)e(notably)g(IMAP[16])g(and)h(POP[17].)32 b(Ho)o(w)o(ev)o(er,)20 b(use)g(of)f(these)75 1122 y(serv)o(ers)14 b(is)e(limited)e(at)i(this)g(time) e(b)q(ecause)k(most)d(MT)m(As)h(and)g(UAs)h(ha)o(v)o(e)f(not)g(b)q(een)h(con) o(v)o(erted)g(to)f(use)h(them,)e(or)75 1171 y(they)i(require)h(sp)q(ecial)f (en)o(vironmen)o(ts)f(\(the)i Fh(A)o(ndr)n(ew)f(Message)i(Delivery)e(System)p Fl([18)o(])g(requires)h(AFS\).)e(P)o(orting)75 1221 y(those)18 b(applications)f(for)h(most)e(p)q(opular)i(en)o(vironmen)o(ts)f(is)g(not)h (going)f(to)g(b)q(e)i(an)e(easy)h(task.)30 b(Nev)o(ertheless,)75 1271 y(the)15 b(b)q(ene\014ts)h(of)d(suc)o(h)i(services)h(o)o(v)o(er)e(that)g (of)g Fk(hlfsd)f Fl(w)o(ould)g(include)h(faster)h(and)f(more)f(reliable)h (service,)h(plus)75 1321 y(greatly)e(expanded)h(functionalit)o(y)e(\(p)q (ossibly)h(pro)o(viding)f(threads)i(information)c(for)j(threaded)i(mail)10 b(readers\).)75 1429 y Fj(7)56 b(Conclusion)175 1504 y Fl(W)m(e)16 b(ha)o(v)o(e)h(describ)q(ed)i(the)f(b)q(ene\014ts)h(of)d(deliv)o(ering)h (mail)d(to)j(users')h(home)e(directories,)j(the)e(traditional)75 1554 y(w)o(a)o(ys)10 b(to)f(do)h(that)g(and)g(wh)o(y)f(w)o(e)i(think)e(they)h (are)h(inadequate,)f(and)g(the)g(design,)h(implemen)o(tatio)o(n,)d(p)q (erformance,)75 1604 y(and)14 b(con)o(v)o(enience)h(of)e(our)h(alternativ)o (e.)175 1678 y(The)i(main)f(con)o(tribution)g(of)h(our)g(w)o(ork)g(is)h(the)g (idea)f(mail)d(can)k(b)q(e)g(reliably)e(deliv)o(ered)i(to)f(user's)h(home)75 1728 y(directories)12 b(for)e(easy)h(access)i(with)d(v)o(ery)h(little)f(o)o (v)o(erhead,)h(user)g(hassle,)h(or)e(the)i(need)f(for)f(extensiv)o(e)i(in)o (terv)o(en)o(tion)75 1778 y(on)i(the)g(part)g(of)f(SAs.)175 1853 y(A)h(w)o(orking)f(protot)o(yp)q(e)i(v)o(ersion)f(of)g Fk(hlfsd)f Fl(w)o(as)h(written)h(in)f(one)g(w)o(eek)o(end.)20 b(Ho)o(w)o(ev)o(er,)15 b(the)f(ideas)h(repre-)75 1902 y(sen)o(ted)e(in)e(the) i(w)o(ork)e(span)h(sev)o(eral)h(y)o(ears)f(of)f(exp)q(erience)j(in)d(net)o(w) o(ork)h(programming)c(\(esp)q(ecially)13 b(RPC)o(\),)f(NFS,)75 1952 y Fk(amd)p Fl(,)h(and)g(mail)f(systems.)75 2060 y Fj(7.1)56 b(F)-5 b(uture)18 b(W)-5 b(ork)175 2135 y Fl(It)15 b(w)o(ould)e(b)q(e)j(p)q (ossible)f(to)g(in)o(tegrate)g(some)f(of)g Fk(hlfsd)o Fl('s)g(functionalit)o (y)g(in)o(to)g Fk(amd)p Fl(,)g(b)o(y)g(pro)o(viding)g(sp)q(ecial)75 2185 y(k)o(eyw)o(ords)g(lik)o(e)f Fk($)p Fi(f)p Fk(home)p Fi(g)p Fl(,)f Fk($)p Fi(f)p Fk(user)p Fi(g)g Fl(and)i Fk($)p Fi(f)p Fk(group)p Fi(g)e Fl(for)i(use)h(in)e Fk(amd)p Fl('s)g(maps.)175 2260 y(W)m(e)e(plan)g(on)g(making)e(sure)k Fk(hlfsd)d Fl(is)h(as)h(p)q (ortable)g(as)f Fk(amd)g Fl(is,)g(and)h(impro)o(ving)d(its)i(p)q(erformance)h (as)f(m)o(uc)o(h)75 2310 y(as)j(p)q(ossible.)k(An)c(RPC)g(in)o(terface)g(for) g(querying)g Fk(hlfsd)o Fl('s)f(status)i(is)f(needed)h(as)f(w)o(ell.)75 2418 y Fj(7.2)56 b(Alternativ)n(e)17 b(Uses)175 2493 y Fk(Hlfsd)o Fl('s)g(primary)e(use)j(is)f(that)h(of)e(a)h(mail-sp)q(o)q(ol)e(redirector.) 29 b(Ho)o(w)o(ev)o(er,)18 b(it)f(can)h(b)q(e)g(used)g(to)f(p)q(erform)75 2543 y(other)e(tasks.)j(All)13 b(it)h(tak)o(es)g(are)g(the)h(righ)o(t)e (command-li)o(ne)f(options:)137 2650 y Fi(\017)21 b Fk(Hlfsd)10 b Fl(can)h(manage)e(the)j Fk(/var/tmp)d Fl(directory)m(.)17 b(Th)o(us)12 b(ev)o(ery)f(user)h(who)f(uses)h Fk(/var/tmp)e Fl(w)o(ould)g(actually)179 2700 y(b)q(e)j(using)e(a)h(sub)q(directory)i (within)d(their)i(o)o(wn)e(home)g(directory)m(,)i(rather)g(than)f(taking)f (from)f(system-wide)954 2825 y(13)p eop %%Page: 14 14 bop 179 42 a Fl(resources.)137 124 y Fi(\017)21 b Fl(Other)13 b(t)o(yp)q(es)g(of)e(user-sp)q(eci\014c)k(\014les)d(whic)o(h)g(get)h(sp)q(o)q (oled)f(to)g(a)g(particular)g(host,)g(suc)o(h)h(as)f Fh(Se)n(cr)n(et)h(Mail)p Fl([24)n(])179 173 y(or)h(electronic)h(faxes)f(can)g(also)f(b)q(e)h (redirected)i(for)e(sp)q(o)q(oling)f(in)o(to)g(home)g(directories.)75 296 y Fj(8)56 b(Ac)n(kno)n(wledgmen)n(ts)175 371 y Fl(Sp)q(ecial)10 b(thanks)h(go)e(to)i(Daniel)e(Duc)o(hamp)g(for)h(his)g(in)o(v)n(aluable)f (commen)o(ts)f(on)i(the)h(pap)q(er,)h(to)e(James)g(T)m(anis)75 421 y(who)g(wrote)h(the)f(remailing)e(script)j(and)f(pro)o(vided)g(useful)g (feedbac)o(k,)h(and)f(to)g(all)f(mem)o(b)q(ers)g(of)g(the)i(tec)o(hnical)g (sta\013)75 471 y(who)e(help)q(ed)h(in)f(stress-testing)i Fk(hlfsd)o Fl(.)17 b(W)m(e)9 b(also)f(thank)h(man)o(y)f(mem)o(b)q(ers)g(of)g(the)i Fk(amd-workers@acl.lan)o(l.gov)75 520 y Fl(mailing)h(list)i(for)h(pro)o (viding)e(v)n(aluable)h(discussion)h(on)g(the)g(sub)r(ject.)175 595 y(This)f(w)o(ork)h(w)o(as)f(supp)q(orted)i(in)e(part)h(b)o(y)f(a)h (National)e(Science)j(F)m(oundation)d(CISE)i(Institutional)f(Infras-)75 645 y(tructure)j(gran)o(t,)d(n)o(um)o(b)q(er)g(CD)o(A-90-24735.)175 720 y(As)i Fk(hlfsd)f Fl(uses)i(parts)f(of)f(the)i Fk(amd)e Fl(distribution,)g(it)h(is)f(distributed)i(under)g(the)f(same)f(restrictions) i(and)75 769 y(licenses)f(that)f Fk(amd)f Fl(is.)75 877 y Fj(9)56 b(References)75 952 y Fl([1])20 b(E.)14 b(Allman.)k(SENDMAIL)d({)f(An)h(In)o (ternet)o(w)o(ork)h(Mail)d(Router.)21 b(In)14 b Fh(UNIX)i(System)f(Manager's) h(Manual.)140 1002 y Fl(Univ)o(ersit)o(y)d(of)h(California,)d(Berk)o(eley)m (,)j(1986.)75 1084 y([2])20 b(F.)g(C.)g(Baran.)39 b(MW:)20 b(Mail-W)m(atc)o(h.)37 b(An)21 b(unpublished)g(man)o(ual)d(page,)k(Academic)e (Systems)h(Group,)140 1134 y(Colum)o(bia)11 b(Univ)o(ersit)o(y)i(Cen)o(ter)i (for)f(Computing)e(Activities,)h(1987.)75 1216 y([3])20 b(B.)12 b(Callaghan)f(and)h(T.)g(Ly)o(on.)j(The)e(Automoun)o(ter.)i(In)e Fh(Pr)n(o)n(c.)g(1989)h(Winter)g(USENIX)g(Conf.)p Fl(,)e(pp.)g(43{51,)140 1266 y(Jan)o(uary)h(1989.)75 1348 y([4])20 b(M.)13 b(N.)g(Condict.)18 b(Con\014guring)13 b(and)g(Building)g(Mac)o(h)h(3.0.)i(OSF)e(Researc)o(h)h (Institute,)f(Grenoble,)g(F)m(rance.)140 1398 y(Unpublished)g(notes)g(a)o(v)n (ailable)e(via)h(ftp)h(from)e Fk(mach.cs.cmu.edu:d)o(oc/no)o(tes/k)o(ernel)p 1595 1398 14 2 v 12 w(build.doc)p Fl(.)75 1480 y([5])20 b(M.)13 b(A.)g(Co)q(op)q(er.)18 b(Ov)o(erhauling)13 b(Rdist)g(for)h(the)g('90s.)j Fh(L)n(ar)n(ge)d(Instal)r(lation)h(System)g(A)n(dministr)n(ators)e(Work-)140 1530 y(shop)i(Pr)n(o)n(c)n(e)n(e)n(dings)p Fl(,)e(pp.)h(1-8,)f(USENIX,)h (Long)f(Beac)o(h,)h(CA,)g(Octob)q(er)h(19-June)f(23,)f(1992.)75 1612 y([6])20 b(A.)13 b(J.)h(Findla)o(y)m(.)i(The)e(Home-Directory)f(Mail)g (System.)18 b(In)13 b Fh(EUUG)i(News)p Fl(,)e(Autumn)g(1988.)75 1694 y([7])20 b(J.)13 b(F)m(ulton.)k(MIT)d(X)g(Consortium.)j(X11R5)12 b(Reference)k(Man)o(ual)d(P)o(ages,)h(Section)g(1:)k(\\xbi\013\(1\)",)12 b(1988.)75 1776 y([8])20 b(Hewlett-P)o(ac)o(k)n(ard)14 b(Compan)o(y)m(.)j (HP-UX)e(Release)g(9.0)e(Reference)j(Man)o(ual,)d(Section)i(4:)k (\\cdf\(4\)",)13 b(August)140 1826 y(1992.)75 1908 y([9])20 b(IBM)11 b(Corp.)j(AIX)e(Comma)o(nds)d(Reference,)k(V)m(olume)d(1,)h(\\b)q (ellmail\(1\)")o(,)e(pp.)i(1-84|1-87,)e(Decem)o(b)q(er)i(1989.)75 1990 y([10])19 b(B.)14 b(Kan)o(tor)g(and)g(P)m(.)f(Lapsley)m(.)k(Net)o(w)o (ork)e(News)f(T)m(ransfer)h(Proto)q(col.)j(RF)o(C)13 b(977,)f(F)m(ebruary)j (1986;)d(27)h(p.)75 2073 y([11])19 b(P)m(.)14 b(J.)h(Leac)o(h,)g(P)m(.)f(H.)g (Levine,)h(B.)f(P)m(.)g(Douros,)h(J.)f(A.)h(Hamilton,)c(D.L.)j(Nelson,)g(and) h(B.)g(L.)f(Stumpf.)19 b Fh(The)140 2122 y(A)o(r)n(chite)n(ctur)n(e)14 b(of)j(an)f(Inte)n(gr)n(ate)n(d)g(L)n(o)n(c)n(al)g(Network.)22 b Fl(In)15 b Fh(IEEE)i(Journal)f(on)h(Sele)n(cte)n(d)f(A)o(r)n(e)n(as)g(in)g (Communi-)140 2172 y(c)n(ations,)d Fm(SA)o(C-1)p Fl(\(5\),)g(pp.)h(842-856,)e (No)o(v)o(em)o(b)q(er)h(1983.)75 2254 y([12])19 b(P)m(.)12 b(H.)f(Levine.)16 b Fh(The)d(Ap)n(ol)r(lo)g(DOMAIN)g(Distribute)n(d)g(File)f (System.)k Fl(In)c Fh(NA)m(TO)g(ASI)i(Series:)j(The)n(ory)c(and)140 2304 y(Pr)n(actic)n(e)k(of)i(Distribute)n(d)f(Op)n(er)n(ating)g(Systems,)g Fl(Y.)g(P)o(ak)o(er,)g(J-P)m(.)g(Banatre,)h(M.)e(Bozyi\024)-21 b(git,)18 b(pp.)f(241-260,)140 2354 y(editors,)d(Springer-V)m(erlag,)f(1987.) 75 2436 y([13])19 b(J.)14 b(S.)g(P)o(endry)h(and)f(N.)g(William)o(s.)j Fh(A)o(md)e(-)g(The)g(4.4)g(BSD)h(A)o(utomounter)p Fl(.)k(Imp)q(erial)12 b(College)i(of)g(Science)140 2486 y(T)m(ec)o(hnology)f(and)g(Medicine,)h (London.)f(Marc)o(h)h(1991.)75 2568 y([14])19 b(R.)14 b(Pik)o(e,)g(D.)f (Presotto,)i(K.)f(Thompson,)f(and)h(H.)g(T)m(ric)o(k)o(ey)m(.)19 b Fh(Plan)d(9)f(fr)n(om)g(Bel)r(l)g(L)n(abs)p Fl(.)k(In)c Fh(Pr)n(o)n(c)n(e)n (e)n(dings)g(of)140 2618 y(the)g(Summer)f(1990)i(UKUUG)f(Conf.)p Fl(,)e(London,)g(July)m(,)f(1990,)h(pp.)g(1-9.)75 2700 y([15])19 b(J.)14 b(B.)g(P)o(ostel.)k(Simple)12 b(Mail)h(T)m(ransfer)h(Proto)q(col.)k (RF)o(C)13 b(821,)g(August)h(1982;)f(68)g(p.)954 2825 y(14)p eop %%Page: 15 15 bop 75 42 a Fl([16])19 b(J.)14 b(Rice.)k(In)o(teractiv)o(e)d(Mail)d(Access)k (Proto)q(col.)i(RF)o(C)c(1203,)e(F)m(ebruary)i(1991;)f(49)g(p.)75 125 y([17])19 b(M.)14 b(Rose.)k(P)o(ost)c(O\016ce)h(Proto)q(col.)j(RF)o(C)13 b(1225,)f(Ma)o(y)i(1991;)e(16)h(p.)75 208 y([18])19 b(J.)f(Roseneb)q(erg,)h (C.)f(F.)f(Ev)o(erhart,)i(and)f(N.)g(S.)f(Borenstein.)32 b Fh(A)o(n)19 b(Overview)f(of)g(the)h(A)o(ndr)n(ew)f(Message)140 257 y(System)p Fl(.)i(In)15 b Fh(Pr)n(o)n(c)n(e)n(e)n(dings)h(of)f(the)h(A)o (CM)f(SIGCOMM)h('87)g(Workshop)p Fl(,)g(Sto)o(w)o(e,)e(V)m(ermon)o(t,)f (August)j(11-13,)140 307 y(1987,)c(pp.)h(99-108.)75 390 y([19])19 b(R.)d(Salz.)24 b Fh(InterNetNews:)e(Usenet)17 b(tr)n(ansp)n(ort)g(for)f (Internet)h(sites)p Fl(.)24 b(In)17 b Fh(Pr)n(o)n(c.)f(1992)i(Summer)f (USENIX)140 440 y(Conf.)p Fl(,)c(pages)h(93{98,)e(June)j(1992.)75 523 y([20])k(R.)14 b(Sandb)q(erg)h(et)g(al.)k(Design)c(and)f(Implemen)o (tation)e(of)i(the)h(Sun)f(Net)o(w)o(ork)h(Filesystem.)20 b(In)14 b Fh(Pr)n(o)n(c.)h(1985)140 573 y(Summer)g(Usenix)g(Conf.)p Fl(,)e(pages)h(119-130,)e(June)i(1985.)75 656 y([21])19 b(Sun)13 b(Microsystems,)f(Inc.)k(SunOS)d(Reference)h(Man)o(ual,)e(V)m(olume)e(I,)i (Section)h(1:)k(\\bi\013\(1\)",)12 b(Septem)o(b)q(er)h(9,)140 706 y(1987.)75 789 y([22])19 b(Sun)11 b(Microsystems,)f(Inc.)j(SunOS)e (Reference)i(Man)o(ual,)d(V)m(olume)e(I)q(I,)i(Section)h(3:)16 b(\\syslog\(3\)",)10 b(Septem)o(b)q(er)140 839 y(9,)j(1987.)75 922 y([23])19 b(Sun)g(Microsystems,)f(Inc.)33 b(SunOS)19 b(Reference)h(Man)o (ual,)e(V)m(olume)f(I,)h(Section)h(1:)27 b(\\comsat\(8c\)",)18 b(and)140 971 y(\\in.comsat\(8c\)",)11 b(Septem)o(b)q(er)k(9,)e(1987.)75 1054 y([24])19 b(Sun)14 b(Microsystems,)f(Inc.)k(SunOS)d(Reference)h(Man)o (ual,)d(V)m(olume)f(I,)i(Section)h(1:)j(\\xsend\(1\)",)d(\\xget\(1\)",)140 1104 y(and)f(\\enroll\(1\)",)g(Septem)o(b)q(er)h(9,)f(1987.)75 1187 y([25])19 b(Sun)f(Microsystems,)g(Inc.)31 b(NFS:)18 b(Net)o(w)o(ork)g (File)g(System)f(Proto)q(col)h(sp)q(eci\014cation.)31 b(RF)o(C)17 b(1094,)h(1989)140 1237 y(Marc)o(h;)13 b(27)h(p.)75 1320 y([26])19 b(L.)c(W)m(all)f(and)h(R.)f(L.)h(Sc)o(h)o(w)o(artz.)23 b Fh(Pr)n(o)n(gr)n (amming)16 b(Perl)p Fl(.)22 b(O'Reilly)14 b(&)h(Asso)q(ciates,)i(Inc.,)e (Sebastop)q(ol,)h(CA)140 1370 y(\(1991\).)75 1453 y([27])j(R.)d(S.)g(Zac)o (hariassen.)26 b Fh(ZMOG:)18 b(The)f(ZMailer)g(Op)n(er)n(ations)f(Guide)p Fl(.)26 b(Av)n(ailable)15 b(via)g(ftp)i(as)f(part)h(of)e(the)140 1503 y(ZMailer)e(distribution)h(from)e Fk(ftp.uu.net:/netwo)o(rkin)o(g/mai)o (l/zma)o(iler)p Fl(.)75 1627 y Fj(10)56 b(Author)19 b(Information)175 1702 y Fm(Erez)f(Zadok)e Fl(is)g(an)f(MS)h(candidate)g(and)g(full-time)d (Sta\013)k(Asso)q(ciate)f(in)g(the)g(Computer)g(Science)h(De-)75 1752 y(partmen)o(t)11 b(at)h(Colum)o(bia)d(Univ)o(ersit)o(y)m(.)16 b(His)c(primary)e(in)o(terests)k(include)e(op)q(erating)f(systems,)h(\014le)g (systems,)g(and)75 1802 y(w)o(a)o(ys)j(to)g(ease)h(system)f(administration)e (tasks.)23 b(In)15 b(Ma)o(y)g(1991,)f(he)i(receiv)o(ed)g(his)f(B.S.)g(in)g (Computer)g(Science)75 1852 y(from)g(Colum)o(bia's)f(Sc)o(ho)q(ol)i(of)g (Engineering)h(and)f(Applied)h(Science.)28 b(Erez)18 b(came)e(to)g(the)i (United)f(States)g(six)75 1902 y(y)o(ears)d(ago)e(and)i(has)f(liv)o(ed)g(in)g (New)g(Y)m(ork)g(\\Sin")g(Cit)o(y)f(ev)o(er)j(since.)j(In)c(his)f(rare)h (free)g(time)e(Erez)j(is)e(an)g(amateur)75 1951 y(photographer,)h(science)h (\014ction)f(dev)o(otee,)h(and)e(ro)q(c)o(k-n-roll)g(fan.)175 2026 y(Mailing)h(address:)25 b(500)16 b(W)m(est)h(120)747 2011 y Fa(th)797 2026 y Fl(Street,)h(Colum)o(bia)c(Univ)o(ersit)o(y)m(,)i(New)h(Y) m(ork,)g(NY)f(10027.)25 b(Email)75 2076 y(address:)19 b Fk (ezk@cs.columbia.edu)o Fl(.)175 2151 y Fm(Alexander)10 b(Dupuy)g Fl(has)h(b)q(een)h(a)e(Senior)h(Researc)o(h)i(Sta\013)e(Asso)q(ciate)h(for)e (the)i(Distributed)f(Computing)75 2200 y(and)i(Comm)o(uni)o(cations)d(Lab)j (in)f(the)i(Computer)e(Science)i(Departmen)o(t)f(at)f(Colum)o(bia)e(Univ)o (ersit)o(y)j(for)g(the)g(last)75 2250 y(7)h(y)o(ears.)21 b(He)16 b(has)f(recen)o(tly)g(tak)o(en)g(a)f(p)q(osition)h(at)f(System)g(Managemen)o (t)g(AR)m(TS,)f(a)i(small)d(startup)k(compan)o(y)75 2300 y(dev)o(eloping)e (net)o(w)o(ork)h(and)g(systems)g(managemen)o(t)d(tec)o(hnology)m(.)20 b(A)15 b(nativ)o(e)g(b)q(orn)g(and)g(bred)g(New)h(Y)m(ork)o(er,)e(he)75 2350 y(insists)g(that)g(w)o(orking)f(in)h(the)g(suburbs)h(is)f(not)g(the)g (\014rst)h(step)g(to)o(w)o(ards)f(living)e(there.)175 2425 y(Mailing)h(address:)23 b(System)15 b(Managemen)o(t)f(AR)m(TS,)g(199)h(Main)g (Street,)h(Suite)g(900,)f(White)g(Plains,)g(NY)75 2474 y(10601.)i(Email)11 b(address:)20 b Fk(dupuy@smarts.co)o(m)p Fl(.)954 2825 y(15)p eop %%Trailer end userdict /end-hook known{end-hook}if %%EOF am-utils-6.2+rc20110530/doc/mdate-sh000077500000000000000000000127511157065440000165350ustar00rootroot00000000000000#!/bin/sh # Get modification time of a file or directory and pretty-print it. scriptversion=2009-04-28.21; # UTC # Copyright (C) 1995, 1996, 1997, 2003, 2004, 2005, 2007, 2009 Free # Software Foundation, Inc. # written by Ulrich Drepper , June 1995 # # 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, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . case $1 in '') echo "$0: No file. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: mdate-sh [--help] [--version] FILE Pretty-print the modification time of FILE. Report bugs to . EOF exit $? ;; -v | --v*) echo "mdate-sh $scriptversion" exit $? ;; esac # Prevent date giving response in another language. LANG=C export LANG LC_ALL=C export LC_ALL LC_TIME=C export LC_TIME # GNU ls changes its time format in response to the TIME_STYLE # variable. Since we cannot assume `unset' works, revert this # variable to its documented default. if test "${TIME_STYLE+set}" = set; then TIME_STYLE=posix-long-iso export TIME_STYLE fi save_arg1=$1 # Find out how to get the extended ls output of a file or directory. if ls -L /dev/null 1>/dev/null 2>&1; then ls_command='ls -L -l -d' else ls_command='ls -l -d' fi # Avoid user/group names that might have spaces, when possible. if ls -n /dev/null 1>/dev/null 2>&1; then ls_command="$ls_command -n" fi # A `ls -l' line looks as follows on OS/2. # drwxrwx--- 0 Aug 11 2001 foo # This differs from Unix, which adds ownership information. # drwxrwx--- 2 root root 4096 Aug 11 2001 foo # # To find the date, we split the line on spaces and iterate on words # until we find a month. This cannot work with files whose owner is a # user named `Jan', or `Feb', etc. However, it's unlikely that `/' # will be owned by a user whose name is a month. So we first look at # the extended ls output of the root directory to decide how many # words should be skipped to get the date. # On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below. set x`$ls_command /` # Find which argument is the month. month= command= until test $month do shift # Add another shift to the command. command="$command shift;" case $1 in Jan) month=January; nummonth=1;; Feb) month=February; nummonth=2;; Mar) month=March; nummonth=3;; Apr) month=April; nummonth=4;; May) month=May; nummonth=5;; Jun) month=June; nummonth=6;; Jul) month=July; nummonth=7;; Aug) month=August; nummonth=8;; Sep) month=September; nummonth=9;; Oct) month=October; nummonth=10;; Nov) month=November; nummonth=11;; Dec) month=December; nummonth=12;; esac done # Get the extended ls output of the file or directory. set dummy x`eval "$ls_command \"\$save_arg1\""` # Remove all preceding arguments eval $command # Because of the dummy argument above, month is in $2. # # On a POSIX system, we should have # # $# = 5 # $1 = file size # $2 = month # $3 = day # $4 = year or time # $5 = filename # # On Darwin 7.7.0 and 7.6.0, we have # # $# = 4 # $1 = day # $2 = month # $3 = year or time # $4 = filename # Get the month. case $2 in Jan) month=January; nummonth=1;; Feb) month=February; nummonth=2;; Mar) month=March; nummonth=3;; Apr) month=April; nummonth=4;; May) month=May; nummonth=5;; Jun) month=June; nummonth=6;; Jul) month=July; nummonth=7;; Aug) month=August; nummonth=8;; Sep) month=September; nummonth=9;; Oct) month=October; nummonth=10;; Nov) month=November; nummonth=11;; Dec) month=December; nummonth=12;; esac case $3 in ???*) day=$1;; *) day=$3; shift;; esac # Here we have to deal with the problem that the ls output gives either # the time of day or the year. case $3 in *:*) set `date`; eval year=\$$# case $2 in Jan) nummonthtod=1;; Feb) nummonthtod=2;; Mar) nummonthtod=3;; Apr) nummonthtod=4;; May) nummonthtod=5;; Jun) nummonthtod=6;; Jul) nummonthtod=7;; Aug) nummonthtod=8;; Sep) nummonthtod=9;; Oct) nummonthtod=10;; Nov) nummonthtod=11;; Dec) nummonthtod=12;; esac # For the first six month of the year the time notation can also # be used for files modified in the last year. if (expr $nummonth \> $nummonthtod) > /dev/null; then year=`expr $year - 1` fi;; *) year=$3;; esac # The result. echo $day $month $year # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: am-utils-6.2+rc20110530/doc/texinfo.tex000066400000000000000000011003511157065440000172760ustar00rootroot00000000000000% texinfo.tex -- TeX macros to handle Texinfo files. % % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % \def\texinfoversion{2009-08-14.15} % % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, % 2007, 2008, 2009 Free Software Foundation, Inc. % % This texinfo.tex file 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 3 of the % License, or (at your option) any later version. % % This texinfo.tex file 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, see . % % As a special exception, when this file is read by TeX when processing % a Texinfo source document, you may use the result without % restriction. (This has been our intent since Texinfo was invented.) % % Please try the latest version of texinfo.tex before submitting bug % reports; you can get the latest version from: % http://www.gnu.org/software/texinfo/ (the Texinfo home page), or % ftp://tug.org/tex/texinfo.tex % (and all CTAN mirrors, see http://www.ctan.org). % The texinfo.tex in any given distribution could well be out % of date, so if that's what you're using, please check. % % Send bug reports to bug-texinfo@gnu.org. Please include including a % complete document in each bug report with which we can reproduce the % problem. Patches are, of course, greatly appreciated. % % To process a Texinfo manual with TeX, it's most reliable to use the % texi2dvi shell script that comes with the distribution. For a simple % manual foo.texi, however, you can get away with this: % tex foo.texi % texindex foo.?? % tex foo.texi % tex foo.texi % dvips foo.dvi -o # or whatever; this makes foo.ps. % The extra TeX runs get the cross-reference information correct. % Sometimes one run after texindex suffices, and sometimes you need more % than two; texi2dvi does it as many times as necessary. % % It is possible to adapt texinfo.tex for other languages, to some % extent. You can get the existing language-specific files from the % full Texinfo distribution. % % The GNU Texinfo home page is http://www.gnu.org/software/texinfo. \message{Loading texinfo [version \texinfoversion]:} % If in a .fmt file, print the version number % and turn on active characters that we couldn't do earlier because % they might have appeared in the input file name. \everyjob{\message{[Texinfo version \texinfoversion]}% \catcode`+=\active \catcode`\_=\active} \chardef\other=12 % We never want plain's \outer definition of \+ in Texinfo. % For @tex, we can use \tabalign. \let\+ = \relax % Save some plain tex macros whose names we will redefine. \let\ptexb=\b \let\ptexbullet=\bullet \let\ptexc=\c \let\ptexcomma=\, \let\ptexdot=\. \let\ptexdots=\dots \let\ptexend=\end \let\ptexequiv=\equiv \let\ptexexclam=\! \let\ptexfootnote=\footnote \let\ptexgtr=> \let\ptexhat=^ \let\ptexi=\i \let\ptexindent=\indent \let\ptexinsert=\insert \let\ptexlbrace=\{ \let\ptexless=< \let\ptexnewwrite\newwrite \let\ptexnoindent=\noindent \let\ptexplus=+ \let\ptexrbrace=\} \let\ptexslash=\/ \let\ptexstar=\* \let\ptext=\t \let\ptextop=\top {\catcode`\'=\active \global\let\ptexquoteright'}% Math-mode def from plain.tex. \let\ptexraggedright=\raggedright % If this character appears in an error message or help string, it % starts a new line in the output. \newlinechar = `^^J % Use TeX 3.0's \inputlineno to get the line number, for better error % messages, but if we're using an old version of TeX, don't do anything. % \ifx\inputlineno\thisisundefined \let\linenumber = \empty % Pre-3.0. \else \def\linenumber{l.\the\inputlineno:\space} \fi % Set up fixed words for English if not already set. \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi \ifx\putwordin\undefined \gdef\putwordin{in}\fi \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi \ifx\putwordof\undefined \gdef\putwordof{of}\fi \ifx\putwordon\undefined \gdef\putwordon{on}\fi \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi % \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi % \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi % Since the category of space is not known, we have to be careful. \chardef\spacecat = 10 \def\spaceisspace{\catcode`\ =\spacecat} % sometimes characters are active, so we need control sequences. \chardef\colonChar = `\: \chardef\commaChar = `\, \chardef\dashChar = `\- \chardef\dotChar = `\. \chardef\exclamChar= `\! \chardef\lquoteChar= `\` \chardef\questChar = `\? \chardef\rquoteChar= `\' \chardef\semiChar = `\; \chardef\underChar = `\_ % Ignore a token. % \def\gobble#1{} % The following is used inside several \edef's. \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname} % Hyphenation fixes. \hyphenation{ Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script ap-pen-dix bit-map bit-maps data-base data-bases eshell fall-ing half-way long-est man-u-script man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces spell-ing spell-ings stand-alone strong-est time-stamp time-stamps which-ever white-space wide-spread wrap-around } % Margin to add to right of even pages, to left of odd pages. \newdimen\bindingoffset \newdimen\normaloffset \newdimen\pagewidth \newdimen\pageheight % For a final copy, take out the rectangles % that mark overfull boxes (in case you have decided % that the text looks ok even though it passes the margin). % \def\finalout{\overfullrule=0pt} % @| inserts a changebar to the left of the current line. It should % surround any changed text. This approach does *not* work if the % change spans more than two lines of output. To handle that, we would % have adopt a much more difficult approach (putting marks into the main % vertical list for the beginning and end of each change). % \def\|{% % \vadjust can only be used in horizontal mode. \leavevmode % % Append this vertical mode material after the current line in the output. \vadjust{% % We want to insert a rule with the height and depth of the current % leading; that is exactly what \strutbox is supposed to record. \vskip-\baselineskip % % \vadjust-items are inserted at the left edge of the type. So % the \llap here moves out into the left-hand margin. \llap{% % % For a thicker or thinner bar, change the `1pt'. \vrule height\baselineskip width1pt % % This is the space between the bar and the text. \hskip 12pt }% }% } % Sometimes it is convenient to have everything in the transcript file % and nothing on the terminal. We don't just call \tracingall here, % since that produces some useless output on the terminal. We also make % some effort to order the tracing commands to reduce output in the log % file; cf. trace.sty in LaTeX. % \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% \def\loggingall{% \tracingstats2 \tracingpages1 \tracinglostchars2 % 2 gives us more in etex \tracingparagraphs1 \tracingoutput1 \tracingmacros2 \tracingrestores1 \showboxbreadth\maxdimen \showboxdepth\maxdimen \ifx\eTeXversion\undefined\else % etex gives us more logging \tracingscantokens1 \tracingifs1 \tracinggroups1 \tracingnesting2 \tracingassigns1 \fi \tracingcommands3 % 3 gives us more in etex \errorcontextlines16 }% % add check for \lastpenalty to plain's definitions. If the last thing % we did was a \nobreak, we don't want to insert more space. % \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount \removelastskip\penalty-50\smallskip\fi\fi} \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount \removelastskip\penalty-100\medskip\fi\fi} \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount \removelastskip\penalty-200\bigskip\fi\fi} % For @cropmarks command. % Do @cropmarks to get crop marks. % \newif\ifcropmarks \let\cropmarks = \cropmarkstrue % % Dimensions to add cropmarks at corners. % Added by P. A. MacKay, 12 Nov. 1986 % \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines \newdimen\cornerlong \cornerlong=1pc \newdimen\cornerthick \cornerthick=.3pt \newdimen\topandbottommargin \topandbottommargin=.75in % Output a mark which sets \thischapter, \thissection and \thiscolor. % We dump everything together because we only have one kind of mark. % This works because we only use \botmark / \topmark, not \firstmark. % % A mark contains a subexpression of the \ifcase ... \fi construct. % \get*marks macros below extract the needed part using \ifcase. % % Another complication is to let the user choose whether \thischapter % (\thissection) refers to the chapter (section) in effect at the top % of a page, or that at the bottom of a page. The solution is % described on page 260 of The TeXbook. It involves outputting two % marks for the sectioning macros, one before the section break, and % one after. I won't pretend I can describe this better than DEK... \def\domark{% \toks0=\expandafter{\lastchapterdefs}% \toks2=\expandafter{\lastsectiondefs}% \toks4=\expandafter{\prevchapterdefs}% \toks6=\expandafter{\prevsectiondefs}% \toks8=\expandafter{\lastcolordefs}% \mark{% \the\toks0 \the\toks2 \noexpand\or \the\toks4 \the\toks6 \noexpand\else \the\toks8 }% } % \topmark doesn't work for the very first chapter (after the title % page or the contents), so we use \firstmark there -- this gets us % the mark with the chapter defs, unless the user sneaks in, e.g., % @setcolor (or @url, or @link, etc.) between @contents and the very % first @chapter. \def\gettopheadingmarks{% \ifcase0\topmark\fi \ifx\thischapter\empty \ifcase0\firstmark\fi \fi } \def\getbottomheadingmarks{\ifcase1\botmark\fi} \def\getcolormarks{\ifcase2\topmark\fi} % Avoid "undefined control sequence" errors. \def\lastchapterdefs{} \def\lastsectiondefs{} \def\prevchapterdefs{} \def\prevsectiondefs{} \def\lastcolordefs{} % Main output routine. \chardef\PAGE = 255 \output = {\onepageout{\pagecontents\PAGE}} \newbox\headlinebox \newbox\footlinebox % \onepageout takes a vbox as an argument. Note that \pagecontents % does insertions, but you have to call it yourself. \def\onepageout#1{% \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi % \ifodd\pageno \advance\hoffset by \bindingoffset \else \advance\hoffset by -\bindingoffset\fi % % Do this outside of the \shipout so @code etc. will be expanded in % the headline as they should be, not taken literally (outputting ''code). \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% % {% % Have to do this stuff outside the \shipout because we want it to % take effect in \write's, yet the group defined by the \vbox ends % before the \shipout runs. % \indexdummies % don't expand commands in the output. \normalturnoffactive % \ in index entries must not stay \, e.g., if % the page break happens to be in the middle of an example. % We don't want .vr (or whatever) entries like this: % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}} % "\acronym" won't work when it's read back in; % it needs to be % {\code {{\tt \backslashcurfont }acronym} \shipout\vbox{% % Do this early so pdf references go to the beginning of the page. \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi % \ifcropmarks \vbox to \outervsize\bgroup \hsize = \outerhsize \vskip-\topandbottommargin \vtop to0pt{% \line{\ewtop\hfil\ewtop}% \nointerlineskip \line{% \vbox{\moveleft\cornerthick\nstop}% \hfill \vbox{\moveright\cornerthick\nstop}% }% \vss}% \vskip\topandbottommargin \line\bgroup \hfil % center the page within the outer (page) hsize. \ifodd\pageno\hskip\bindingoffset\fi \vbox\bgroup \fi % \unvbox\headlinebox \pagebody{#1}% \ifdim\ht\footlinebox > 0pt % Only leave this space if the footline is nonempty. % (We lessened \vsize for it in \oddfootingyyy.) % The \baselineskip=24pt in plain's \makefootline has no effect. \vskip 24pt \unvbox\footlinebox \fi % \ifcropmarks \egroup % end of \vbox\bgroup \hfil\egroup % end of (centering) \line\bgroup \vskip\topandbottommargin plus1fill minus1fill \boxmaxdepth = \cornerthick \vbox to0pt{\vss \line{% \vbox{\moveleft\cornerthick\nsbot}% \hfill \vbox{\moveright\cornerthick\nsbot}% }% \nointerlineskip \line{\ewbot\hfil\ewbot}% }% \egroup % \vbox from first cropmarks clause \fi }% end of \shipout\vbox }% end of group with \indexdummies \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi } \newinsert\margin \dimen\margin=\maxdimen \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} {\catcode`\@ =11 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi % marginal hacks, juha@viisa.uucp (Juha Takala) \ifvoid\margin\else % marginal info is present \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi \dimen@=\dp#1\relax \unvbox#1\relax \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi \ifr@ggedbottom \kern-\dimen@ \vfil \fi} } % Here are the rules for the cropmarks. Note that they are % offset so that the space between them is truly \outerhsize or \outervsize % (P. A. MacKay, 12 November, 1986) % \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} \def\nstop{\vbox {\hrule height\cornerthick depth\cornerlong width\cornerthick}} \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} \def\nsbot{\vbox {\hrule height\cornerlong depth\cornerthick width\cornerthick}} % Parse an argument, then pass it to #1. The argument is the rest of % the input line (except we remove a trailing comment). #1 should be a % macro which expects an ordinary undelimited TeX argument. % \def\parsearg{\parseargusing{}} \def\parseargusing#1#2{% \def\argtorun{#2}% \begingroup \obeylines \spaceisspace #1% \parseargline\empty% Insert the \empty token, see \finishparsearg below. } {\obeylines % \gdef\parseargline#1^^M{% \endgroup % End of the group started in \parsearg. \argremovecomment #1\comment\ArgTerm% }% } % First remove any @comment, then any @c comment. \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} % Each occurrence of `\^^M' or `\^^M' is replaced by a single space. % % \argremovec might leave us with trailing space, e.g., % @end itemize @c foo % This space token undergoes the same procedure and is eventually removed % by \finishparsearg. % \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% \def\temp{#3}% \ifx\temp\empty % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp: \let\temp\finishparsearg \else \let\temp\argcheckspaces \fi % Put the space token in: \temp#1 #3\ArgTerm } % If a _delimited_ argument is enclosed in braces, they get stripped; so % to get _exactly_ the rest of the line, we had to prevent such situation. % We prepended an \empty token at the very beginning and we expand it now, % just before passing the control to \argtorun. % (Similarly, we have to think about #3 of \argcheckspacesY above: it is % either the null string, or it ends with \^^M---thus there is no danger % that a pair of braces would be stripped. % % But first, we have to remove the trailing space token. % \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}} % \parseargdef\foo{...} % is roughly equivalent to % \def\foo{\parsearg\Xfoo} % \def\Xfoo#1{...} % % Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my % favourite TeX trick. --kasal, 16nov03 \def\parseargdef#1{% \expandafter \doparseargdef \csname\string#1\endcsname #1% } \def\doparseargdef#1#2{% \def#2{\parsearg#1}% \def#1##1% } % Several utility definitions with active space: { \obeyspaces \gdef\obeyedspace{ } % Make each space character in the input produce a normal interword % space in the output. Don't allow a line break at this space, as this % is used only in environments like @example, where each line of input % should produce a line of output anyway. % \gdef\sepspaces{\obeyspaces\let =\tie} % If an index command is used in an @example environment, any spaces % therein should become regular spaces in the raw index file, not the % expansion of \tie (\leavevmode \penalty \@M \ ). \gdef\unsepspaces{\let =\space} } \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} % Define the framework for environments in texinfo.tex. It's used like this: % % \envdef\foo{...} % \def\Efoo{...} % % It's the responsibility of \envdef to insert \begingroup before the % actual body; @end closes the group after calling \Efoo. \envdef also % defines \thisenv, so the current environment is known; @end checks % whether the environment name matches. The \checkenv macro can also be % used to check whether the current environment is the one expected. % % Non-false conditionals (@iftex, @ifset) don't fit into this, so they % are not treated as environments; they don't open a group. (The % implementation of @end takes care not to call \endgroup in this % special case.) % At run-time, environments start with this: \def\startenvironment#1{\begingroup\def\thisenv{#1}} % initialize \let\thisenv\empty % ... but they get defined via ``\envdef\foo{...}'': \long\def\envdef#1#2{\def#1{\startenvironment#1#2}} \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}} % Check whether we're in the right environment: \def\checkenv#1{% \def\temp{#1}% \ifx\thisenv\temp \else \badenverr \fi } % Environment mismatch, #1 expected: \def\badenverr{% \errhelp = \EMsimple \errmessage{This command can appear only \inenvironment\temp, not \inenvironment\thisenv}% } \def\inenvironment#1{% \ifx#1\empty out of any environment% \else in environment \expandafter\string#1% \fi } % @end foo executes the definition of \Efoo. % But first, it executes a specialized version of \checkenv % \parseargdef\end{% \if 1\csname iscond.#1\endcsname \else % The general wording of \badenverr may not be ideal, but... --kasal, 06nov03 \expandafter\checkenv\csname#1\endcsname \csname E#1\endcsname \endgroup \fi } \newhelp\EMsimple{Press RETURN to continue.} %% Simple single-character @ commands % @@ prints an @ % Kludge this until the fonts are right (grr). \def\@{{\tt\char64}} % This is turned off because it was never documented % and you can use @w{...} around a quote to suppress ligatures. %% Define @` and @' to be the same as ` and ' %% but suppressing ligatures. %\def\`{{`}} %\def\'{{'}} % Used to generate quoted braces. \def\mylbrace {{\tt\char123}} \def\myrbrace {{\tt\char125}} \let\{=\mylbrace \let\}=\myrbrace \begingroup % Definitions to produce \{ and \} commands for indices, % and @{ and @} for the aux/toc files. \catcode`\{ = \other \catcode`\} = \other \catcode`\[ = 1 \catcode`\] = 2 \catcode`\! = 0 \catcode`\\ = \other !gdef!lbracecmd[\{]% !gdef!rbracecmd[\}]% !gdef!lbraceatcmd[@{]% !gdef!rbraceatcmd[@}]% !endgroup % @comma{} to avoid , parsing problems. \let\comma = , % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. \let\, = \c \let\dotaccent = \. \def\ringaccent#1{{\accent23 #1}} \let\tieaccent = \t \let\ubaraccent = \b \let\udotaccent = \d % Other special characters: @questiondown @exclamdown @ordf @ordm % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. \def\questiondown{?`} \def\exclamdown{!`} \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}} \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}} % Dotless i and dotless j, used for accents. \def\imacro{i} \def\jmacro{j} \def\dotless#1{% \def\temp{#1}% \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi \else \errmessage{@dotless can be used only with i or j}% \fi\fi } % The \TeX{} logo, as in plain, but resetting the spacing so that a % period following counts as ending a sentence. (Idea found in latex.) % \edef\TeX{\TeX \spacefactor=1000 } % @LaTeX{} logo. Not quite the same results as the definition in % latex.ltx, since we use a different font for the raised A; it's most % convenient for us to use an explicitly smaller font, rather than using % the \scriptstyle font (since we don't reset \scriptstyle and % \scriptscriptstyle). % \def\LaTeX{% L\kern-.36em {\setbox0=\hbox{T}% \vbox to \ht0{\hbox{\selectfonts\lllsize A}\vss}}% \kern-.15em \TeX } % Be sure we're in horizontal mode when doing a tie, since we make space % equivalent to this in @example-like environments. Otherwise, a space % at the beginning of a line will start with \penalty -- and % since \penalty is valid in vertical mode, we'd end up putting the % penalty on the vertical list instead of in the new paragraph. {\catcode`@ = 11 % Avoid using \@M directly, because that causes trouble % if the definition is written into an index file. \global\let\tiepenalty = \@M \gdef\tie{\leavevmode\penalty\tiepenalty\ } } % @: forces normal size whitespace following. \def\:{\spacefactor=1000 } % @* forces a line break. \def\*{\hfil\break\hbox{}\ignorespaces} % @/ allows a line break. \let\/=\allowbreak % @. is an end-of-sentence period. \def\.{.\spacefactor=\endofsentencespacefactor\space} % @! is an end-of-sentence bang. \def\!{!\spacefactor=\endofsentencespacefactor\space} % @? is an end-of-sentence query. \def\?{?\spacefactor=\endofsentencespacefactor\space} % @frenchspacing on|off says whether to put extra space after punctuation. % \def\onword{on} \def\offword{off} % \parseargdef\frenchspacing{% \def\temp{#1}% \ifx\temp\onword \plainfrenchspacing \else\ifx\temp\offword \plainnonfrenchspacing \else \errhelp = \EMsimple \errmessage{Unknown @frenchspacing option `\temp', must be on/off}% \fi\fi } % @w prevents a word break. Without the \leavevmode, @w at the % beginning of a paragraph, when TeX is still in vertical mode, would % produce a whole line of output instead of starting the paragraph. \def\w#1{\leavevmode\hbox{#1}} % @group ... @end group forces ... to be all on one page, by enclosing % it in a TeX vbox. We use \vtop instead of \vbox to construct the box % to keep its height that of a normal line. According to the rules for % \topskip (p.114 of the TeXbook), the glue inserted is % max (\topskip - \ht (first item), 0). If that height is large, % therefore, no glue is inserted, and the space between the headline and % the text is small, which looks bad. % % Another complication is that the group might be very large. This can % cause the glue on the previous page to be unduly stretched, because it % does not have much material. In this case, it's better to add an % explicit \vfill so that the extra space is at the bottom. The % threshold for doing this is if the group is more than \vfilllimit % percent of a page (\vfilllimit can be changed inside of @tex). % \newbox\groupbox \def\vfilllimit{0.7} % \envdef\group{% \ifnum\catcode`\^^M=\active \else \errhelp = \groupinvalidhelp \errmessage{@group invalid in context where filling is enabled}% \fi \startsavinginserts % \setbox\groupbox = \vtop\bgroup % Do @comment since we are called inside an environment such as % @example, where each end-of-line in the input causes an % end-of-line in the output. We don't want the end-of-line after % the `@group' to put extra space in the output. Since @group % should appear on a line by itself (according to the Texinfo % manual), we don't worry about eating any user text. \comment } % % The \vtop produces a box with normal height and large depth; thus, TeX puts % \baselineskip glue before it, and (when the next line of text is done) % \lineskip glue after it. Thus, space below is not quite equal to space % above. But it's pretty close. \def\Egroup{% % To get correct interline space between the last line of the group % and the first line afterwards, we have to propagate \prevdepth. \endgraf % Not \par, as it may have been set to \lisppar. \global\dimen1 = \prevdepth \egroup % End the \vtop. % \dimen0 is the vertical size of the group's box. \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox % \dimen2 is how much space is left on the page (more or less). \dimen2 = \pageheight \advance\dimen2 by -\pagetotal % if the group doesn't fit on the current page, and it's a big big % group, force a page break. \ifdim \dimen0 > \dimen2 \ifdim \pagetotal < \vfilllimit\pageheight \page \fi \fi \box\groupbox \prevdepth = \dimen1 \checkinserts } % % TeX puts in an \escapechar (i.e., `@') at the beginning of the help % message, so this ends up printing `@group can only ...'. % \newhelp\groupinvalidhelp{% group can only be used in environments such as @example,^^J% where each line of input produces a line of output.} % @need space-in-mils % forces a page break if there is not space-in-mils remaining. \newdimen\mil \mil=0.001in % Old definition--didn't work. %\parseargdef\need{\par % %% This method tries to make TeX break the page naturally %% if the depth of the box does not fit. %{\baselineskip=0pt% %\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak %\prevdepth=-1000pt %}} \parseargdef\need{% % Ensure vertical mode, so we don't make a big box in the middle of a % paragraph. \par % % If the @need value is less than one line space, it's useless. \dimen0 = #1\mil \dimen2 = \ht\strutbox \advance\dimen2 by \dp\strutbox \ifdim\dimen0 > \dimen2 % % Do a \strut just to make the height of this box be normal, so the % normal leading is inserted relative to the preceding line. % And a page break here is fine. \vtop to #1\mil{\strut\vfil}% % % TeX does not even consider page breaks if a penalty added to the % main vertical list is 10000 or more. But in order to see if the % empty box we just added fits on the page, we must make it consider % page breaks. On the other hand, we don't want to actually break the % page after the empty box. So we use a penalty of 9999. % % There is an extremely small chance that TeX will actually break the % page at this \penalty, if there are no other feasible breakpoints in % sight. (If the user is using lots of big @group commands, which % almost-but-not-quite fill up a page, TeX will have a hard time doing % good page breaking, for example.) However, I could not construct an % example where a page broke at this \penalty; if it happens in a real % document, then we can reconsider our strategy. \penalty9999 % % Back up by the size of the box, whether we did a page break or not. \kern -#1\mil % % Do not allow a page break right after this kern. \nobreak \fi } % @br forces paragraph break (and is undocumented). \let\br = \par % @page forces the start of a new page. % \def\page{\par\vfill\supereject} % @exdent text.... % outputs text on separate line in roman font, starting at standard page margin % This records the amount of indent in the innermost environment. % That's how much \exdent should take out. \newskip\exdentamount % This defn is used inside fill environments such as @defun. \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break} % This defn is used inside nofill environments such as @example. \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount \leftline{\hskip\leftskip{\rm#1}}}} % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current % paragraph. For more general purposes, use the \margin insertion % class. WHICH is `l' or `r'. % \newskip\inmarginspacing \inmarginspacing=1cm \def\strutdepth{\dp\strutbox} % \def\doinmargin#1#2{\strut\vadjust{% \nobreak \kern-\strutdepth \vtop to \strutdepth{% \baselineskip=\strutdepth \vss % if you have multiple lines of stuff to put here, you'll need to % make the vbox yourself of the appropriate size. \ifx#1l% \llap{\ignorespaces #2\hskip\inmarginspacing}% \else \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}% \fi \null }% }} \def\inleftmargin{\doinmargin l} \def\inrightmargin{\doinmargin r} % % @inmargin{TEXT [, RIGHT-TEXT]} % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; % else use TEXT for both). % \def\inmargin#1{\parseinmargin #1,,\finish} \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. \setbox0 = \hbox{\ignorespaces #2}% \ifdim\wd0 > 0pt \def\lefttext{#1}% have both texts \def\righttext{#2}% \else \def\lefttext{#1}% have only one text \def\righttext{#1}% \fi % \ifodd\pageno \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin \else \def\temp{\inleftmargin\lefttext}% \fi \temp } % @include FILE -- \input text of FILE. % \def\include{\parseargusing\filenamecatcodes\includezzz} \def\includezzz#1{% \pushthisfilestack \def\thisfile{#1}% {% \makevalueexpandable % we want to expand any @value in FILE. \turnoffactive % and allow special characters in the expansion \indexnofonts % Allow `@@' and other weird things in file names. \edef\temp{\noexpand\input #1 }% % % This trickery is to read FILE outside of a group, in case it makes % definitions, etc. \expandafter }\temp \popthisfilestack } \def\filenamecatcodes{% \catcode`\\=\other \catcode`~=\other \catcode`^=\other \catcode`_=\other \catcode`|=\other \catcode`<=\other \catcode`>=\other \catcode`+=\other \catcode`-=\other \catcode`\`=\other \catcode`\'=\other } \def\pushthisfilestack{% \expandafter\pushthisfilestackX\popthisfilestack\StackTerm } \def\pushthisfilestackX{% \expandafter\pushthisfilestackY\thisfile\StackTerm } \def\pushthisfilestackY #1\StackTerm #2\StackTerm {% \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}% } \def\popthisfilestack{\errthisfilestackempty} \def\errthisfilestackempty{\errmessage{Internal error: the stack of filenames is empty.}} \def\thisfile{} % @center line % outputs that line, centered. % \parseargdef\center{% \ifhmode \let\next\centerH \else \let\next\centerV \fi \next{\hfil \ignorespaces#1\unskip \hfil}% } \def\centerH#1{% {% \hfil\break \advance\hsize by -\leftskip \advance\hsize by -\rightskip \line{#1}% \break }% } \def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}} % @sp n outputs n lines of vertical space \parseargdef\sp{\vskip #1\baselineskip} % @comment ...line which is ignored... % @c is the same as @comment % @ignore ... @end ignore is another way to write a comment \def\comment{\begingroup \catcode`\^^M=\other% \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% \commentxxx} {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} \let\c=\comment % @paragraphindent NCHARS % We'll use ems for NCHARS, close enough. % NCHARS can also be the word `asis' or `none'. % We cannot feasibly implement @paragraphindent asis, though. % \def\asisword{asis} % no translation, these are keywords \def\noneword{none} % \parseargdef\paragraphindent{% \def\temp{#1}% \ifx\temp\asisword \else \ifx\temp\noneword \defaultparindent = 0pt \else \defaultparindent = #1em \fi \fi \parindent = \defaultparindent } % @exampleindent NCHARS % We'll use ems for NCHARS like @paragraphindent. % It seems @exampleindent asis isn't necessary, but % I preserve it to make it similar to @paragraphindent. \parseargdef\exampleindent{% \def\temp{#1}% \ifx\temp\asisword \else \ifx\temp\noneword \lispnarrowing = 0pt \else \lispnarrowing = #1em \fi \fi } % @firstparagraphindent WORD % If WORD is `none', then suppress indentation of the first paragraph % after a section heading. If WORD is `insert', then do indent at such % paragraphs. % % The paragraph indentation is suppressed or not by calling % \suppressfirstparagraphindent, which the sectioning commands do. % We switch the definition of this back and forth according to WORD. % By default, we suppress indentation. % \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent} \def\insertword{insert} % \parseargdef\firstparagraphindent{% \def\temp{#1}% \ifx\temp\noneword \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent \else\ifx\temp\insertword \let\suppressfirstparagraphindent = \relax \else \errhelp = \EMsimple \errmessage{Unknown @firstparagraphindent option `\temp'}% \fi\fi } % Here is how we actually suppress indentation. Redefine \everypar to % \kern backwards by \parindent, and then reset itself to empty. % % We also make \indent itself not actually do anything until the next % paragraph. % \gdef\dosuppressfirstparagraphindent{% \gdef\indent{% \restorefirstparagraphindent \indent }% \gdef\noindent{% \restorefirstparagraphindent \noindent }% \global\everypar = {% \kern -\parindent \restorefirstparagraphindent }% } \gdef\restorefirstparagraphindent{% \global \let \indent = \ptexindent \global \let \noindent = \ptexnoindent \global \everypar = {}% } % @asis just yields its argument. Used with @table, for example. % \def\asis#1{#1} % @math outputs its argument in math mode. % % One complication: _ usually means subscripts, but it could also mean % an actual _ character, as in @math{@var{some_variable} + 1}. So make % _ active, and distinguish by seeing if the current family is \slfam, % which is what @var uses. { \catcode`\_ = \active \gdef\mathunderscore{% \catcode`\_=\active \def_{\ifnum\fam=\slfam \_\else\sb\fi}% } } % Another complication: we want \\ (and @\) to output a \ character. % FYI, plain.tex uses \\ as a temporary control sequence (why?), but % this is not advertised and we don't care. Texinfo does not % otherwise define @\. % % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} % \def\math{% \tex \mathunderscore \let\\ = \mathbackslash \mathactive % make the texinfo accent commands work in math mode \let\"=\ddot \let\'=\acute \let\==\bar \let\^=\hat \let\`=\grave \let\u=\breve \let\v=\check \let\~=\tilde \let\dotaccent=\dot $\finishmath } \def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. % Some active characters (such as <) are spaced differently in math. % We have to reset their definitions in case the @math was an argument % to a command which sets the catcodes (such as @item or @section). % { \catcode`^ = \active \catcode`< = \active \catcode`> = \active \catcode`+ = \active \catcode`' = \active \gdef\mathactive{% \let^ = \ptexhat \let< = \ptexless \let> = \ptexgtr \let+ = \ptexplus \let' = \ptexquoteright } } % Some math mode symbols. \def\bullet{$\ptexbullet$} \def\geq{\ifmmode \ge\else $\ge$\fi} \def\leq{\ifmmode \le\else $\le$\fi} \def\minus{\ifmmode -\else $-$\fi} % @dots{} outputs an ellipsis using the current font. % We do .5em per period so that it has the same spacing in the cm % typewriter fonts as three actual period characters; on the other hand, % in other typewriter fonts three periods are wider than 1.5em. So do % whichever is larger. % \def\dots{% \leavevmode \setbox0=\hbox{...}% get width of three periods \ifdim\wd0 > 1.5em \dimen0 = \wd0 \else \dimen0 = 1.5em \fi \hbox to \dimen0{% \hskip 0pt plus.25fil .\hskip 0pt plus1fil .\hskip 0pt plus1fil .\hskip 0pt plus.5fil }% } % @enddots{} is an end-of-sentence ellipsis. % \def\enddots{% \dots \spacefactor=\endofsentencespacefactor } % @comma{} is so commas can be inserted into text without messing up % Texinfo's parsing. % \let\comma = , % @refill is a no-op. \let\refill=\relax % If working on a large document in chapters, it is convenient to % be able to disable indexing, cross-referencing, and contents, for test runs. % This is done with @novalidate (before @setfilename). % \newif\iflinks \linkstrue % by default we want the aux files. \let\novalidate = \linksfalse % @setfilename is done at the beginning of every texinfo file. % So open here the files we need to have open while reading the input. % This makes it possible to make a .fmt file for texinfo. \def\setfilename{% \fixbackslash % Turn off hack to swallow `\input texinfo'. \iflinks \tryauxfile % Open the new aux file. TeX will close it automatically at exit. \immediate\openout\auxfile=\jobname.aux \fi % \openindices needs to do some work in any case. \openindices \let\setfilename=\comment % Ignore extra @setfilename cmds. % % If texinfo.cnf is present on the system, read it. % Useful for site-wide @afourpaper, etc. \openin 1 texinfo.cnf \ifeof 1 \else \input texinfo.cnf \fi \closein 1 % \comment % Ignore the actual filename. } % Called from \setfilename. % \def\openindices{% \newindex{cp}% \newcodeindex{fn}% \newcodeindex{vr}% \newcodeindex{tp}% \newcodeindex{ky}% \newcodeindex{pg}% } % @bye. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} \message{pdf,} % adobe `portable' document format \newcount\tempnum \newcount\lnkcount \newtoks\filename \newcount\filenamelength \newcount\pgn \newtoks\toksA \newtoks\toksB \newtoks\toksC \newtoks\toksD \newbox\boxA \newcount\countA \newif\ifpdf \newif\ifpdfmakepagedest % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 % can be set). So we test for \relax and 0 as well as \undefined, % borrowed from ifpdf.sty. \ifx\pdfoutput\undefined \else \ifx\pdfoutput\relax \else \ifcase\pdfoutput \else \pdftrue \fi \fi \fi % PDF uses PostScript string constants for the names of xref targets, % for display in the outlines, and in other places. Thus, we have to % double any backslashes. Otherwise, a name like "\node" will be % interpreted as a newline (\n), followed by o, d, e. Not good. % http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html % (and related messages, the final outcome is that it is up to the TeX % user to double the backslashes and otherwise make the string valid, so % that's what we do). % double active backslashes. % {\catcode`\@=0 \catcode`\\=\active @gdef@activebackslashdouble{% @catcode`@\=@active @let\=@doublebackslash} } % To handle parens, we must adopt a different approach, since parens are % not active characters. hyperref.dtx (which has the same problem as % us) handles it with this amazing macro to replace tokens, with minor % changes for Texinfo. It is included here under the GPL by permission % from the author, Heiko Oberdiek. % % #1 is the tokens to replace. % #2 is the replacement. % #3 is the control sequence with the string. % \def\HyPsdSubst#1#2#3{% \def\HyPsdReplace##1#1##2\END{% ##1% \ifx\\##2\\% \else #2% \HyReturnAfterFi{% \HyPsdReplace##2\END }% \fi }% \xdef#3{\expandafter\HyPsdReplace#3#1\END}% } \long\def\HyReturnAfterFi#1\fi{\fi#1} % #1 is a control sequence in which to do the replacements. \def\backslashparens#1{% \xdef#1{#1}% redefine it as its expansion; the definition is simply % \lastnode when called from \setref -> \pdfmkdest. \HyPsdSubst{(}{\realbackslash(}{#1}% \HyPsdSubst{)}{\realbackslash)}{#1}% } \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images with PDF output, and none of those formats could be found. (.eps cannot be supported due to the design of the PDF format; use regular TeX (DVI output) for that.)} \ifpdf % % Color manipulation macros based on pdfcolor.tex, % except using rgb instead of cmyk; the latter is said to render as a % very dark gray on-screen and a very dark halftone in print, instead % of actual black. \def\rgbDarkRed{0.50 0.09 0.12} \def\rgbBlack{0 0 0} % % k sets the color for filling (usual text, etc.); % K sets the color for stroking (thin rules, e.g., normal _'s). \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}} % % Set color, and create a mark which defines \thiscolor accordingly, % so that \makeheadline knows which color to restore. \def\setcolor#1{% \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}% \domark \pdfsetcolor{#1}% } % \def\maincolor{\rgbBlack} \pdfsetcolor{\maincolor} \edef\thiscolor{\maincolor} \def\lastcolordefs{} % \def\makefootline{% \baselineskip24pt \line{\pdfsetcolor{\maincolor}\the\footline}% } % \def\makeheadline{% \vbox to 0pt{% \vskip-22.5pt \line{% \vbox to8.5pt{}% % Extract \thiscolor definition from the marks. \getcolormarks % Typeset the headline with \maincolor, then restore the color. \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% }% \vss }% \nointerlineskip } % % \pdfcatalog{/PageMode /UseOutlines} % % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). \def\dopdfimage#1#2#3{% \def\imagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% \def\imageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% % % pdftex (and the PDF format) support .png, .jpg, .pdf (among % others). Let's try in that order. \let\pdfimgext=\empty \begingroup \openin 1 #1.png \ifeof 1 \openin 1 #1.jpg \ifeof 1 \openin 1 #1.jpeg \ifeof 1 \openin 1 #1.JPG \ifeof 1 \openin 1 #1.pdf \ifeof 1 \openin 1 #1.PDF \ifeof 1 \errhelp = \nopdfimagehelp \errmessage{Could not find image file #1 for pdf}% \else \gdef\pdfimgext{PDF}% \fi \else \gdef\pdfimgext{pdf}% \fi \else \gdef\pdfimgext{JPG}% \fi \else \gdef\pdfimgext{jpeg}% \fi \else \gdef\pdfimgext{jpg}% \fi \else \gdef\pdfimgext{png}% \fi \closein 1 \endgroup % % without \immediate, ancient pdftex seg faults when the same image is % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) \ifnum\pdftexversion < 14 \immediate\pdfimage \else \immediate\pdfximage \fi \ifdim \wd0 >0pt width \imagewidth \fi \ifdim \wd2 >0pt height \imageheight \fi \ifnum\pdftexversion<13 #1.\pdfimgext \else {#1.\pdfimgext}% \fi \ifnum\pdftexversion < 14 \else \pdfrefximage \pdflastximage \fi} % \def\pdfmkdest#1{{% % We have to set dummies so commands such as @code, and characters % such as \, aren't expanded when present in a section title. \indexnofonts \turnoffactive \activebackslashdouble \makevalueexpandable \def\pdfdestname{#1}% \backslashparens\pdfdestname \safewhatsit{\pdfdest name{\pdfdestname} xyz}% }} % % used to mark target names; must be expandable. \def\pdfmkpgn#1{#1} % % by default, use a color that is dark enough to print on paper as % nearly black, but still distinguishable for online viewing. \def\urlcolor{\rgbDarkRed} \def\linkcolor{\rgbDarkRed} \def\endlink{\setcolor{\maincolor}\pdfendlink} % % Adding outlines to PDF; macros for calculating structure of outlines % come from Petr Olsak \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% \else \csname#1\endcsname \fi} \def\advancenumber#1{\tempnum=\expnumber{#1}\relax \advance\tempnum by 1 \expandafter\xdef\csname#1\endcsname{\the\tempnum}} % % #1 is the section text, which is what will be displayed in the % outline by the pdf viewer. #2 is the pdf expression for the number % of subentries (or empty, for subsubsections). #3 is the node text, % which might be empty if this toc entry had no corresponding node. % #4 is the page number % \def\dopdfoutline#1#2#3#4{% % Generate a link to the node text if that exists; else, use the % page number. We could generate a destination for the section % text in the case where a section has no node, but it doesn't % seem worth the trouble, since most documents are normally structured. \def\pdfoutlinedest{#3}% \ifx\pdfoutlinedest\empty \def\pdfoutlinedest{#4}% \else % Doubled backslashes in the name. {\activebackslashdouble \xdef\pdfoutlinedest{#3}% \backslashparens\pdfoutlinedest}% \fi % % Also double the backslashes in the display string. {\activebackslashdouble \xdef\pdfoutlinetext{#1}% \backslashparens\pdfoutlinetext}% % \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}% } % \def\pdfmakeoutlines{% \begingroup % Thanh's hack / proper braces in bookmarks \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace % % Read toc silently, to get counts of subentries for \pdfoutline. \def\numchapentry##1##2##3##4{% \def\thischapnum{##2}% \def\thissecnum{0}% \def\thissubsecnum{0}% }% \def\numsecentry##1##2##3##4{% \advancenumber{chap\thischapnum}% \def\thissecnum{##2}% \def\thissubsecnum{0}% }% \def\numsubsecentry##1##2##3##4{% \advancenumber{sec\thissecnum}% \def\thissubsecnum{##2}% }% \def\numsubsubsecentry##1##2##3##4{% \advancenumber{subsec\thissubsecnum}% }% \def\thischapnum{0}% \def\thissecnum{0}% \def\thissubsecnum{0}% % % use \def rather than \let here because we redefine \chapentry et % al. a second time, below. \def\appentry{\numchapentry}% \def\appsecentry{\numsecentry}% \def\appsubsecentry{\numsubsecentry}% \def\appsubsubsecentry{\numsubsubsecentry}% \def\unnchapentry{\numchapentry}% \def\unnsecentry{\numsecentry}% \def\unnsubsecentry{\numsubsecentry}% \def\unnsubsubsecentry{\numsubsubsecentry}% \readdatafile{toc}% % % Read toc second time, this time actually producing the outlines. % The `-' means take the \expnumber as the absolute number of % subentries, which we calculated on our first read of the .toc above. % % We use the node names as the destinations. \def\numchapentry##1##2##3##4{% \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}% \def\numsecentry##1##2##3##4{% \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}% \def\numsubsecentry##1##2##3##4{% \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}% \def\numsubsubsecentry##1##2##3##4{% count is always zero \dopdfoutline{##1}{}{##3}{##4}}% % % PDF outlines are displayed using system fonts, instead of % document fonts. Therefore we cannot use special characters, % since the encoding is unknown. For example, the eogonek from % Latin 2 (0xea) gets translated to a | character. Info from % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. % % xx to do this right, we have to translate 8-bit characters to % their "best" equivalent, based on the @documentencoding. Right % now, I guess we'll just let the pdf reader have its way. \indexnofonts \setupdatafile \catcode`\\=\active \otherbackslash \input \tocreadfilename \endgroup } % \def\skipspaces#1{\def\PP{#1}\def\D{|}% \ifx\PP\D\let\nextsp\relax \else\let\nextsp\skipspaces \ifx\p\space\else\addtokens{\filename}{\PP}% \advance\filenamelength by 1 \fi \fi \nextsp} \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax} \ifnum\pdftexversion < 14 \let \startlink \pdfannotlink \else \let \startlink \pdfstartlink \fi % make a live url in pdf output. \def\pdfurl#1{% \begingroup % it seems we really need yet another set of dummies; have not % tried to figure out what each command should do in the context % of @url. for now, just make @/ a no-op, that's the only one % people have actually reported a problem with. % \normalturnoffactive \def\@{@}% \let\/=\empty \makevalueexpandable % do we want to go so far as to use \indexnofonts instead of just % special-casing \var here? \def\var##1{##1}% % \leavevmode\setcolor{\urlcolor}% \startlink attr{/Border [0 0 0]}% user{/Subtype /Link /A << /S /URI /URI (#1) >>}% \endgroup} \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} \def\maketoks{% \expandafter\poptoks\the\toksA|ENDTOKS|\relax \ifx\first0\adn0 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 \else \ifnum0=\countA\else\makelink\fi \ifx\first.\let\next=\done\else \let\next=\maketoks \addtokens{\toksB}{\the\toksD} \ifx\first,\addtokens{\toksB}{\space}\fi \fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \next} \def\makelink{\addtokens{\toksB}% {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} \def\pdflink#1{% \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} \setcolor{\linkcolor}#1\endlink} \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} \else % non-pdf mode \let\pdfmkdest = \gobble \let\pdfurl = \gobble \let\endlink = \relax \let\setcolor = \gobble \let\pdfsetcolor = \gobble \let\pdfmakeoutlines = \relax \fi % \ifx\pdfoutput \message{fonts,} % Change the current font style to #1, remembering it in \curfontstyle. % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in % italics, not bold italics. % \def\setfontstyle#1{% \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. \csname ten#1\endcsname % change the current font } % Select #1 fonts with the current style. % \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname} \def\rm{\fam=0 \setfontstyle{rm}} \def\it{\fam=\itfam \setfontstyle{it}} \def\sl{\fam=\slfam \setfontstyle{sl}} \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} \def\tt{\fam=\ttfam \setfontstyle{tt}} % Unfortunately, we have to override this for titles and the like, since % in those cases "rm" is bold. Sigh. \def\rmisbold{\rm\def\curfontstyle{bf}} % Texinfo sort of supports the sans serif font style, which plain TeX does not. % So we set up a \sf. \newfam\sffam \def\sf{\fam=\sffam \setfontstyle{sf}} \let\li = \sf % Sometimes we call it \li, not \sf. % We don't need math for this font style. \def\ttsl{\setfontstyle{ttsl}} % Default leading. \newdimen\textleading \textleading = 13.2pt % Set the baselineskip to #1, and the lineskip and strut size % correspondingly. There is no deep meaning behind these magic numbers % used as factors; they just match (closely enough) what Knuth defined. % \def\lineskipfactor{.08333} \def\strutheightpercent{.70833} \def\strutdepthpercent {.29167} % % can get a sort of poor man's double spacing by redefining this. \def\baselinefactor{1} % \def\setleading#1{% \dimen0 = #1\relax \normalbaselineskip = \baselinefactor\dimen0 \normallineskip = \lineskipfactor\normalbaselineskip \normalbaselines \setbox\strutbox =\hbox{% \vrule width0pt height\strutheightpercent\baselineskip depth \strutdepthpercent \baselineskip }% } % PDF CMaps. See also LaTeX's t1.cmap. % % do nothing with this by default. \expandafter\let\csname cmapOT1\endcsname\gobble \expandafter\let\csname cmapOT1IT\endcsname\gobble \expandafter\let\csname cmapOT1TT\endcsname\gobble % if we are producing pdf, and we have \pdffontattr, then define cmaps. % (\pdffontattr was introduced many years ago, but people still run % older pdftex's; it's easy to conditionalize, so we do.) \ifpdf \ifx\pdffontattr\undefined \else \begingroup \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap %%DocumentNeededResources: ProcSet (CIDInit) %%IncludeResource: ProcSet (CIDInit) %%BeginResource: CMap (TeX-OT1-0) %%Title: (TeX-OT1-0 TeX OT1 0) %%Version: 1.000 %%EndComments /CIDInit /ProcSet findresource begin 12 dict begin begincmap /CIDSystemInfo << /Registry (TeX) /Ordering (OT1) /Supplement 0 >> def /CMapName /TeX-OT1-0 def /CMapType 2 def 1 begincodespacerange <00> <7F> endcodespacerange 8 beginbfrange <00> <01> <0393> <09> <0A> <03A8> <23> <26> <0023> <28> <3B> <0028> <3F> <5B> <003F> <5D> <5E> <005D> <61> <7A> <0061> <7B> <7C> <2013> endbfrange 40 beginbfchar <02> <0398> <03> <039B> <04> <039E> <05> <03A0> <06> <03A3> <07> <03D2> <08> <03A6> <0B> <00660066> <0C> <00660069> <0D> <0066006C> <0E> <006600660069> <0F> <00660066006C> <10> <0131> <11> <0237> <12> <0060> <13> <00B4> <14> <02C7> <15> <02D8> <16> <00AF> <17> <02DA> <18> <00B8> <19> <00DF> <1A> <00E6> <1B> <0153> <1C> <00F8> <1D> <00C6> <1E> <0152> <1F> <00D8> <21> <0021> <22> <201D> <27> <2019> <3C> <00A1> <3D> <003D> <3E> <00BF> <5C> <201C> <5F> <02D9> <60> <2018> <7D> <02DD> <7E> <007E> <7F> <00A8> endbfchar endcmap CMapName currentdict /CMap defineresource pop end end %%EndResource %%EOF }\endgroup \expandafter\edef\csname cmapOT1\endcsname#1{% \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% }% % % \cmapOT1IT \begingroup \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap %%DocumentNeededResources: ProcSet (CIDInit) %%IncludeResource: ProcSet (CIDInit) %%BeginResource: CMap (TeX-OT1IT-0) %%Title: (TeX-OT1IT-0 TeX OT1IT 0) %%Version: 1.000 %%EndComments /CIDInit /ProcSet findresource begin 12 dict begin begincmap /CIDSystemInfo << /Registry (TeX) /Ordering (OT1IT) /Supplement 0 >> def /CMapName /TeX-OT1IT-0 def /CMapType 2 def 1 begincodespacerange <00> <7F> endcodespacerange 8 beginbfrange <00> <01> <0393> <09> <0A> <03A8> <25> <26> <0025> <28> <3B> <0028> <3F> <5B> <003F> <5D> <5E> <005D> <61> <7A> <0061> <7B> <7C> <2013> endbfrange 42 beginbfchar <02> <0398> <03> <039B> <04> <039E> <05> <03A0> <06> <03A3> <07> <03D2> <08> <03A6> <0B> <00660066> <0C> <00660069> <0D> <0066006C> <0E> <006600660069> <0F> <00660066006C> <10> <0131> <11> <0237> <12> <0060> <13> <00B4> <14> <02C7> <15> <02D8> <16> <00AF> <17> <02DA> <18> <00B8> <19> <00DF> <1A> <00E6> <1B> <0153> <1C> <00F8> <1D> <00C6> <1E> <0152> <1F> <00D8> <21> <0021> <22> <201D> <23> <0023> <24> <00A3> <27> <2019> <3C> <00A1> <3D> <003D> <3E> <00BF> <5C> <201C> <5F> <02D9> <60> <2018> <7D> <02DD> <7E> <007E> <7F> <00A8> endbfchar endcmap CMapName currentdict /CMap defineresource pop end end %%EndResource %%EOF }\endgroup \expandafter\edef\csname cmapOT1IT\endcsname#1{% \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% }% % % \cmapOT1TT \begingroup \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap %%DocumentNeededResources: ProcSet (CIDInit) %%IncludeResource: ProcSet (CIDInit) %%BeginResource: CMap (TeX-OT1TT-0) %%Title: (TeX-OT1TT-0 TeX OT1TT 0) %%Version: 1.000 %%EndComments /CIDInit /ProcSet findresource begin 12 dict begin begincmap /CIDSystemInfo << /Registry (TeX) /Ordering (OT1TT) /Supplement 0 >> def /CMapName /TeX-OT1TT-0 def /CMapType 2 def 1 begincodespacerange <00> <7F> endcodespacerange 5 beginbfrange <00> <01> <0393> <09> <0A> <03A8> <21> <26> <0021> <28> <5F> <0028> <61> <7E> <0061> endbfrange 32 beginbfchar <02> <0398> <03> <039B> <04> <039E> <05> <03A0> <06> <03A3> <07> <03D2> <08> <03A6> <0B> <2191> <0C> <2193> <0D> <0027> <0E> <00A1> <0F> <00BF> <10> <0131> <11> <0237> <12> <0060> <13> <00B4> <14> <02C7> <15> <02D8> <16> <00AF> <17> <02DA> <18> <00B8> <19> <00DF> <1A> <00E6> <1B> <0153> <1C> <00F8> <1D> <00C6> <1E> <0152> <1F> <00D8> <20> <2423> <27> <2019> <60> <2018> <7F> <00A8> endbfchar endcmap CMapName currentdict /CMap defineresource pop end end %%EndResource %%EOF }\endgroup \expandafter\edef\csname cmapOT1TT\endcsname#1{% \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% }% \fi\fi % Set the font macro #1 to the font named #2, adding on the % specified font prefix (normally `cm'). % #3 is the font's design size, #4 is a scale factor, #5 is the CMap % encoding (currently only OT1, OT1IT and OT1TT are allowed, pass % empty to omit). \def\setfont#1#2#3#4#5{% \font#1=\fontprefix#2#3 scaled #4 \csname cmap#5\endcsname#1% } % This is what gets called when #5 of \setfont is empty. \let\cmap\gobble % emacs-page end of cmaps % Use cm as the default font prefix. % To specify the font prefix, you must define \fontprefix % before you read in texinfo.tex. \ifx\fontprefix\undefined \def\fontprefix{cm} \fi % Support font families that don't use the same naming scheme as CM. \def\rmshape{r} \def\rmbshape{bx} %where the normal face is bold \def\bfshape{b} \def\bxshape{bx} \def\ttshape{tt} \def\ttbshape{tt} \def\ttslshape{sltt} \def\itshape{ti} \def\itbshape{bxti} \def\slshape{sl} \def\slbshape{bxsl} \def\sfshape{ss} \def\sfbshape{ss} \def\scshape{csc} \def\scbshape{csc} % Definitions for a main text size of 11pt. This is the default in % Texinfo. % \def\definetextfontsizexi{% % Text fonts (11.2pt, magstep1). \def\textnominalsize{11pt} \edef\mainmagstep{\magstephalf} \setfont\textrm\rmshape{10}{\mainmagstep}{OT1} \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} \setfont\textbf\bfshape{10}{\mainmagstep}{OT1} \setfont\textit\itshape{10}{\mainmagstep}{OT1IT} \setfont\textsl\slshape{10}{\mainmagstep}{OT1} \setfont\textsf\sfshape{10}{\mainmagstep}{OT1} \setfont\textsc\scshape{10}{\mainmagstep}{OT1} \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} \font\texti=cmmi10 scaled \mainmagstep \font\textsy=cmsy10 scaled \mainmagstep \def\textecsize{1095} % A few fonts for @defun names and args. \setfont\defbf\bfshape{10}{\magstep1}{OT1} \setfont\deftt\ttshape{10}{\magstep1}{OT1TT} \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT} \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} % Fonts for indices, footnotes, small examples (9pt). \def\smallnominalsize{9pt} \setfont\smallrm\rmshape{9}{1000}{OT1} \setfont\smalltt\ttshape{9}{1000}{OT1TT} \setfont\smallbf\bfshape{10}{900}{OT1} \setfont\smallit\itshape{9}{1000}{OT1IT} \setfont\smallsl\slshape{9}{1000}{OT1} \setfont\smallsf\sfshape{9}{1000}{OT1} \setfont\smallsc\scshape{10}{900}{OT1} \setfont\smallttsl\ttslshape{10}{900}{OT1TT} \font\smalli=cmmi9 \font\smallsy=cmsy9 \def\smallecsize{0900} % Fonts for small examples (8pt). \def\smallernominalsize{8pt} \setfont\smallerrm\rmshape{8}{1000}{OT1} \setfont\smallertt\ttshape{8}{1000}{OT1TT} \setfont\smallerbf\bfshape{10}{800}{OT1} \setfont\smallerit\itshape{8}{1000}{OT1IT} \setfont\smallersl\slshape{8}{1000}{OT1} \setfont\smallersf\sfshape{8}{1000}{OT1} \setfont\smallersc\scshape{10}{800}{OT1} \setfont\smallerttsl\ttslshape{10}{800}{OT1TT} \font\smalleri=cmmi8 \font\smallersy=cmsy8 \def\smallerecsize{0800} % Fonts for title page (20.4pt): \def\titlenominalsize{20pt} \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} \setfont\titleit\itbshape{10}{\magstep4}{OT1IT} \setfont\titlesl\slbshape{10}{\magstep4}{OT1} \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} \setfont\titlesf\sfbshape{17}{\magstep1}{OT1} \let\titlebf=\titlerm \setfont\titlesc\scbshape{10}{\magstep4}{OT1} \font\titlei=cmmi12 scaled \magstep3 \font\titlesy=cmsy10 scaled \magstep4 \def\titleecsize{2074} % Chapter (and unnumbered) fonts (17.28pt). \def\chapnominalsize{17pt} \setfont\chaprm\rmbshape{12}{\magstep2}{OT1} \setfont\chapit\itbshape{10}{\magstep3}{OT1IT} \setfont\chapsl\slbshape{10}{\magstep3}{OT1} \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT} \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT} \setfont\chapsf\sfbshape{17}{1000}{OT1} \let\chapbf=\chaprm \setfont\chapsc\scbshape{10}{\magstep3}{OT1} \font\chapi=cmmi12 scaled \magstep2 \font\chapsy=cmsy10 scaled \magstep3 \def\chapecsize{1728} % Section fonts (14.4pt). \def\secnominalsize{14pt} \setfont\secrm\rmbshape{12}{\magstep1}{OT1} \setfont\secit\itbshape{10}{\magstep2}{OT1IT} \setfont\secsl\slbshape{10}{\magstep2}{OT1} \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT} \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT} \setfont\secsf\sfbshape{12}{\magstep1}{OT1} \let\secbf\secrm \setfont\secsc\scbshape{10}{\magstep2}{OT1} \font\seci=cmmi12 scaled \magstep1 \font\secsy=cmsy10 scaled \magstep2 \def\sececsize{1440} % Subsection fonts (13.15pt). \def\ssecnominalsize{13pt} \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1} \setfont\ssecit\itbshape{10}{1315}{OT1IT} \setfont\ssecsl\slbshape{10}{1315}{OT1} \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT} \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT} \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1} \let\ssecbf\ssecrm \setfont\ssecsc\scbshape{10}{1315}{OT1} \font\sseci=cmmi12 scaled \magstephalf \font\ssecsy=cmsy10 scaled 1315 \def\ssececsize{1200} % Reduced fonts for @acro in text (10pt). \def\reducednominalsize{10pt} \setfont\reducedrm\rmshape{10}{1000}{OT1} \setfont\reducedtt\ttshape{10}{1000}{OT1TT} \setfont\reducedbf\bfshape{10}{1000}{OT1} \setfont\reducedit\itshape{10}{1000}{OT1IT} \setfont\reducedsl\slshape{10}{1000}{OT1} \setfont\reducedsf\sfshape{10}{1000}{OT1} \setfont\reducedsc\scshape{10}{1000}{OT1} \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT} \font\reducedi=cmmi10 \font\reducedsy=cmsy10 \def\reducedecsize{1000} % reset the current fonts \textfonts \rm } % end of 11pt text font size definitions % Definitions to make the main text be 10pt Computer Modern, with % section, chapter, etc., sizes following suit. This is for the GNU % Press printing of the Emacs 22 manual. Maybe other manuals in the % future. Used with @smallbook, which sets the leading to 12pt. % \def\definetextfontsizex{% % Text fonts (10pt). \def\textnominalsize{10pt} \edef\mainmagstep{1000} \setfont\textrm\rmshape{10}{\mainmagstep}{OT1} \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} \setfont\textbf\bfshape{10}{\mainmagstep}{OT1} \setfont\textit\itshape{10}{\mainmagstep}{OT1IT} \setfont\textsl\slshape{10}{\mainmagstep}{OT1} \setfont\textsf\sfshape{10}{\mainmagstep}{OT1} \setfont\textsc\scshape{10}{\mainmagstep}{OT1} \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} \font\texti=cmmi10 scaled \mainmagstep \font\textsy=cmsy10 scaled \mainmagstep \def\textecsize{1000} % A few fonts for @defun names and args. \setfont\defbf\bfshape{10}{\magstephalf}{OT1} \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT} \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT} \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} % Fonts for indices, footnotes, small examples (9pt). \def\smallnominalsize{9pt} \setfont\smallrm\rmshape{9}{1000}{OT1} \setfont\smalltt\ttshape{9}{1000}{OT1TT} \setfont\smallbf\bfshape{10}{900}{OT1} \setfont\smallit\itshape{9}{1000}{OT1IT} \setfont\smallsl\slshape{9}{1000}{OT1} \setfont\smallsf\sfshape{9}{1000}{OT1} \setfont\smallsc\scshape{10}{900}{OT1} \setfont\smallttsl\ttslshape{10}{900}{OT1TT} \font\smalli=cmmi9 \font\smallsy=cmsy9 \def\smallecsize{0900} % Fonts for small examples (8pt). \def\smallernominalsize{8pt} \setfont\smallerrm\rmshape{8}{1000}{OT1} \setfont\smallertt\ttshape{8}{1000}{OT1TT} \setfont\smallerbf\bfshape{10}{800}{OT1} \setfont\smallerit\itshape{8}{1000}{OT1IT} \setfont\smallersl\slshape{8}{1000}{OT1} \setfont\smallersf\sfshape{8}{1000}{OT1} \setfont\smallersc\scshape{10}{800}{OT1} \setfont\smallerttsl\ttslshape{10}{800}{OT1TT} \font\smalleri=cmmi8 \font\smallersy=cmsy8 \def\smallerecsize{0800} % Fonts for title page (20.4pt): \def\titlenominalsize{20pt} \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} \setfont\titleit\itbshape{10}{\magstep4}{OT1IT} \setfont\titlesl\slbshape{10}{\magstep4}{OT1} \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} \setfont\titlesf\sfbshape{17}{\magstep1}{OT1} \let\titlebf=\titlerm \setfont\titlesc\scbshape{10}{\magstep4}{OT1} \font\titlei=cmmi12 scaled \magstep3 \font\titlesy=cmsy10 scaled \magstep4 \def\titleecsize{2074} % Chapter fonts (14.4pt). \def\chapnominalsize{14pt} \setfont\chaprm\rmbshape{12}{\magstep1}{OT1} \setfont\chapit\itbshape{10}{\magstep2}{OT1IT} \setfont\chapsl\slbshape{10}{\magstep2}{OT1} \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT} \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT} \setfont\chapsf\sfbshape{12}{\magstep1}{OT1} \let\chapbf\chaprm \setfont\chapsc\scbshape{10}{\magstep2}{OT1} \font\chapi=cmmi12 scaled \magstep1 \font\chapsy=cmsy10 scaled \magstep2 \def\chapecsize{1440} % Section fonts (12pt). \def\secnominalsize{12pt} \setfont\secrm\rmbshape{12}{1000}{OT1} \setfont\secit\itbshape{10}{\magstep1}{OT1IT} \setfont\secsl\slbshape{10}{\magstep1}{OT1} \setfont\sectt\ttbshape{12}{1000}{OT1TT} \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT} \setfont\secsf\sfbshape{12}{1000}{OT1} \let\secbf\secrm \setfont\secsc\scbshape{10}{\magstep1}{OT1} \font\seci=cmmi12 \font\secsy=cmsy10 scaled \magstep1 \def\sececsize{1200} % Subsection fonts (10pt). \def\ssecnominalsize{10pt} \setfont\ssecrm\rmbshape{10}{1000}{OT1} \setfont\ssecit\itbshape{10}{1000}{OT1IT} \setfont\ssecsl\slbshape{10}{1000}{OT1} \setfont\ssectt\ttbshape{10}{1000}{OT1TT} \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT} \setfont\ssecsf\sfbshape{10}{1000}{OT1} \let\ssecbf\ssecrm \setfont\ssecsc\scbshape{10}{1000}{OT1} \font\sseci=cmmi10 \font\ssecsy=cmsy10 \def\ssececsize{1000} % Reduced fonts for @acro in text (9pt). \def\reducednominalsize{9pt} \setfont\reducedrm\rmshape{9}{1000}{OT1} \setfont\reducedtt\ttshape{9}{1000}{OT1TT} \setfont\reducedbf\bfshape{10}{900}{OT1} \setfont\reducedit\itshape{9}{1000}{OT1IT} \setfont\reducedsl\slshape{9}{1000}{OT1} \setfont\reducedsf\sfshape{9}{1000}{OT1} \setfont\reducedsc\scshape{10}{900}{OT1} \setfont\reducedttsl\ttslshape{10}{900}{OT1TT} \font\reducedi=cmmi9 \font\reducedsy=cmsy9 \def\reducedecsize{0900} % reduce space between paragraphs \divide\parskip by 2 % reset the current fonts \textfonts \rm } % end of 10pt text font size definitions % We provide the user-level command % @fonttextsize 10 % (or 11) to redefine the text font size. pt is assumed. % \def\xword{10} \def\xiword{11} % \parseargdef\fonttextsize{% \def\textsizearg{#1}% \wlog{doing @fonttextsize \textsizearg}% % % Set \globaldefs so that documents can use this inside @tex, since % makeinfo 4.8 does not support it, but we need it nonetheless. % \begingroup \globaldefs=1 \ifx\textsizearg\xword \definetextfontsizex \else \ifx\textsizearg\xiword \definetextfontsizexi \else \errhelp=\EMsimple \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'} \fi\fi \endgroup } % In order for the font changes to affect most math symbols and letters, % we have to define the \textfont of the standard families. Since % texinfo doesn't allow for producing subscripts and superscripts except % in the main text, we don't bother to reset \scriptfont and % \scriptscriptfont (which would also require loading a lot more fonts). % \def\resetmathfonts{% \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf \textfont\ttfam=\tentt \textfont\sffam=\tensf } % The font-changing commands redefine the meanings of \tenSTYLE, instead % of just \STYLE. We do this because \STYLE needs to also set the % current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire % \tenSTYLE to set the current font. % % Each font-changing command also sets the names \lsize (one size lower) % and \lllsize (three sizes lower). These relative commands are used in % the LaTeX logo and acronyms. % % This all needs generalizing, badly. % \def\textfonts{% \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl \def\curfontsize{text}% \def\lsize{reduced}\def\lllsize{smaller}% \resetmathfonts \setleading{\textleading}} \def\titlefonts{% \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy \let\tenttsl=\titlettsl \def\curfontsize{title}% \def\lsize{chap}\def\lllsize{subsec}% \resetmathfonts \setleading{25pt}} \def\titlefont#1{{\titlefonts\rmisbold #1}} \def\chapfonts{% \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl \def\curfontsize{chap}% \def\lsize{sec}\def\lllsize{text}% \resetmathfonts \setleading{19pt}} \def\secfonts{% \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl \def\curfontsize{sec}% \def\lsize{subsec}\def\lllsize{reduced}% \resetmathfonts \setleading{16pt}} \def\subsecfonts{% \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl \def\curfontsize{ssec}% \def\lsize{text}\def\lllsize{small}% \resetmathfonts \setleading{15pt}} \let\subsubsecfonts = \subsecfonts \def\reducedfonts{% \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy \let\tenttsl=\reducedttsl \def\curfontsize{reduced}% \def\lsize{small}\def\lllsize{smaller}% \resetmathfonts \setleading{10.5pt}} \def\smallfonts{% \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy \let\tenttsl=\smallttsl \def\curfontsize{small}% \def\lsize{smaller}\def\lllsize{smaller}% \resetmathfonts \setleading{10.5pt}} \def\smallerfonts{% \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy \let\tenttsl=\smallerttsl \def\curfontsize{smaller}% \def\lsize{smaller}\def\lllsize{smaller}% \resetmathfonts \setleading{9.5pt}} % Fonts for short table of contents. \setfont\shortcontrm\rmshape{12}{1000}{OT1} \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12 \setfont\shortcontsl\slshape{12}{1000}{OT1} \setfont\shortconttt\ttshape{12}{1000}{OT1TT} % Define these just so they can be easily changed for other fonts. \def\angleleft{$\langle$} \def\angleright{$\rangle$} % Set the fonts to use with the @small... environments. \let\smallexamplefonts = \smallfonts % About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample % can fit this many characters: % 8.5x11=86 smallbook=72 a4=90 a5=69 % If we use \scriptfonts (8pt), then we can fit this many characters: % 8.5x11=90+ smallbook=80 a4=90+ a5=77 % For me, subjectively, the few extra characters that fit aren't worth % the additional smallness of 8pt. So I'm making the default 9pt. % % By the way, for comparison, here's what fits with @example (10pt): % 8.5x11=71 smallbook=60 a4=75 a5=58 % --karl, 24jan03. % Set up the default fonts, so we can use them for creating boxes. % \definetextfontsizexi \message{markup,} % Check if we are currently using a typewriter font. Since all the % Computer Modern typewriter fonts have zero interword stretch (and % shrink), and it is reasonable to expect all typewriter fonts to have % this property, we can check that font parameter. % \def\ifmonospace{\ifdim\fontdimen3\font=0pt } % Markup style infrastructure. \defmarkupstylesetup\INITMACRO will % define and register \INITMACRO to be called on markup style changes. % \INITMACRO can check \currentmarkupstyle for the innermost % style and the set of \ifmarkupSTYLE switches for all styles % currently in effect. \newif\ifmarkupvar \newif\ifmarkupsamp \newif\ifmarkupkey %\newif\ifmarkupfile % @file == @samp. %\newif\ifmarkupoption % @option == @samp. \newif\ifmarkupcode \newif\ifmarkupkbd %\newif\ifmarkupenv % @env == @code. %\newif\ifmarkupcommand % @command == @code. \newif\ifmarkuptex % @tex (and part of @math, for now). \newif\ifmarkupexample \newif\ifmarkupverb \newif\ifmarkupverbatim \let\currentmarkupstyle\empty \def\setupmarkupstyle#1{% \csname markup#1true\endcsname \def\currentmarkupstyle{#1}% \markupstylesetup } \let\markupstylesetup\empty \def\defmarkupstylesetup#1{% \expandafter\def\expandafter\markupstylesetup \expandafter{\markupstylesetup #1}% \def#1% } % Markup style setup for left and right quotes. \defmarkupstylesetup\markupsetuplq{% \expandafter\let\expandafter \temp \csname markupsetuplq\currentmarkupstyle\endcsname \ifx\temp\relax \markupsetuplqdefault \else \temp \fi } \defmarkupstylesetup\markupsetuprq{% \expandafter\let\expandafter \temp \csname markupsetuprq\currentmarkupstyle\endcsname \ifx\temp\relax \markupsetuprqdefault \else \temp \fi } { \catcode`\'=\active \catcode`\`=\active \gdef\markupsetuplqdefault{\let`\lq} \gdef\markupsetuprqdefault{\let'\rq} \gdef\markupsetcodequoteleft{\let`\codequoteleft} \gdef\markupsetcodequoteright{\let'\codequoteright} \gdef\markupsetnoligaturesquoteleft{\let`\noligaturesquoteleft} } \let\markupsetuplqcode \markupsetcodequoteleft \let\markupsetuprqcode \markupsetcodequoteright \let\markupsetuplqexample \markupsetcodequoteleft \let\markupsetuprqexample \markupsetcodequoteright \let\markupsetuplqverb \markupsetcodequoteleft \let\markupsetuprqverb \markupsetcodequoteright \let\markupsetuplqverbatim \markupsetcodequoteleft \let\markupsetuprqverbatim \markupsetcodequoteright \let\markupsetuplqsamp \markupsetnoligaturesquoteleft \let\markupsetuplqkbd \markupsetnoligaturesquoteleft % Allow an option to not replace quotes with a regular directed right % quote/apostrophe (char 0x27), but instead use the undirected quote % from cmtt (char 0x0d). The undirected quote is ugly, so don't make it % the default, but it works for pasting with more pdf viewers (at least % evince), the lilypond developers report. xpdf does work with the % regular 0x27. % \def\codequoteright{% \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax '% \else \char'15 \fi \else \char'15 \fi } % % and a similar option for the left quote char vs. a grave accent. % Modern fonts display ASCII 0x60 as a grave accent, so some people like % the code environments to do likewise. % \def\codequoteleft{% \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax % [Knuth] pp. 380,381,391 % \relax disables Spanish ligatures ?` and !` of \tt font. \relax`% \else \char'22 \fi \else \char'22 \fi } % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font. \def\noligaturesquoteleft{\relax\lq} % Count depth in font-changes, for error checks \newcount\fontdepth \fontdepth=0 %% Add scribe-like font environments, plus @l for inline lisp (usually sans %% serif) and @ii for TeX italic % \smartitalic{ARG} outputs arg in italics, followed by an italic correction % unless the following character is such as not to need one. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else \ptexslash\fi\fi\fi} \def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx} \def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx} % like \smartslanted except unconditionally uses \ttsl. % @var is set to this for defun arguments. \def\ttslanted#1{{\ttsl #1}\futurelet\next\smartitalicx} % @cite is like \smartslanted except unconditionally use \sl. We never want % ttsl for book titles, do we? \def\cite#1{{\sl #1}\futurelet\next\smartitalicx} \let\i=\smartitalic \let\slanted=\smartslanted \def\var#1{{\setupmarkupstyle{var}\smartslanted{#1}}} \let\dfn=\smartslanted \let\emph=\smartitalic % Explicit font changes: @r, @sc, undocumented @ii. \def\r#1{{\rm #1}} % roman font \def\sc#1{{\smallcaps#1}} % smallcaps font \def\ii#1{{\it #1}} % italic font % @b, explicit bold. Also @strong. \def\b#1{{\bf #1}} \let\strong=\b % @sansserif, explicit sans. \def\sansserif#1{{\sf #1}} % We can't just use \exhyphenpenalty, because that only has effect at % the end of a paragraph. Restore normal hyphenation at the end of the % group within which \nohyphenation is presumably called. % \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} \def\restorehyphenation{\hyphenchar\font = `- } % Set sfcode to normal for the chars that usually have another value. % Can't use plain's \frenchspacing because it uses the `\x notation, and % sometimes \x has an active definition that messes things up. % \catcode`@=11 \def\plainfrenchspacing{% \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m \def\endofsentencespacefactor{1000}% for @. and friends } \def\plainnonfrenchspacing{% \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000 \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250 \def\endofsentencespacefactor{3000}% for @. and friends } \catcode`@=\other \def\endofsentencespacefactor{3000}% default % @t, explicit typewriter. \def\t#1{% {\tt \rawbackslash \plainfrenchspacing #1}% \null } % @samp. \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}} % definition of @key that produces a lozenge. Doesn't adjust to text size. %\setfont\keyrm\rmshape{8}{1000}{OT1} %\font\keysy=cmsy9 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% % \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% % \vbox{\hrule\kern-0.4pt % \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% % \kern-0.4pt\hrule}% % \kern-.06em\raise0.4pt\hbox{\angleright}}}} % definition of @key with no lozenge. If the current font is already % monospace, don't change it; that way, we respect @kbdinputstyle. But % if it isn't monospace, then use \tt. % \def\key#1{{\setupmarkupstyle{key}% \nohyphenation \ifmonospace\else\tt\fi #1}\null} % ctrl is no longer a Texinfo command. \def\ctrl #1{{\tt \rawbackslash \hat}#1} % @file, @option are the same as @samp. \let\file=\samp \let\option=\samp % @code is a modification of @t, % which makes spaces the same size as normal in the surrounding text. \def\tclose#1{% {% % Change normal interword space to be same as for the current font. \spaceskip = \fontdimen2\font % % Switch to typewriter. \tt % % But `\ ' produces the large typewriter interword space. \def\ {{\spaceskip = 0pt{} }}% % % Turn off hyphenation. \nohyphenation % \rawbackslash \plainfrenchspacing #1% }% \null } % We *must* turn on hyphenation at `-' and `_' in @code. % Otherwise, it is too hard to avoid overfull hboxes % in the Emacs manual, the Library manual, etc. % Unfortunately, TeX uses one parameter (\hyphenchar) to control % both hyphenation at - and hyphenation within words. % We must therefore turn them both off (\tclose does that) % and arrange explicitly to hyphenate at a dash. % -- rms. { \catcode`\-=\active \catcode`\_=\active \catcode`\'=\active \catcode`\`=\active \global\let'=\rq \global\let`=\lq % default definitions % \global\def\code{\begingroup \setupmarkupstyle{code}% % The following should really be moved into \setupmarkupstyle handlers. \catcode\dashChar=\active \catcode\underChar=\active \ifallowcodebreaks \let-\codedash \let_\codeunder \else \let-\realdash \let_\realunder \fi \codex } } \def\realdash{-} \def\codedash{-\discretionary{}{}{}} \def\codeunder{% % this is all so @math{@code{var_name}+1} can work. In math mode, _ % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) % will therefore expand the active definition of _, which is us % (inside @code that is), therefore an endless loop. \ifusingtt{\ifmmode \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. \else\normalunderscore \fi \discretionary{}{}{}}% {\_}% } \def\codex #1{\tclose{#1}\endgroup} % An additional complication: the above will allow breaks after, e.g., % each of the four underscores in __typeof__. This is undesirable in % some manuals, especially if they don't have long identifiers in % general. @allowcodebreaks provides a way to control this. % \newif\ifallowcodebreaks \allowcodebreakstrue \def\keywordtrue{true} \def\keywordfalse{false} \parseargdef\allowcodebreaks{% \def\txiarg{#1}% \ifx\txiarg\keywordtrue \allowcodebreakstrue \else\ifx\txiarg\keywordfalse \allowcodebreaksfalse \else \errhelp = \EMsimple \errmessage{Unknown @allowcodebreaks option `\txiarg'}% \fi\fi } % @kbd is like @code, except that if the argument is just one @key command, % then @kbd has no effect. \def\kbd#1{{\setupmarkupstyle{kbd}\def\look{#1}\expandafter\kbdfoo\look??\par}} % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), % `example' (@kbd uses ttsl only inside of @example and friends), % or `code' (@kbd uses normal tty font always). \parseargdef\kbdinputstyle{% \def\txiarg{#1}% \ifx\txiarg\worddistinct \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% \else\ifx\txiarg\wordexample \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% \else\ifx\txiarg\wordcode \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% \else \errhelp = \EMsimple \errmessage{Unknown @kbdinputstyle option `\txiarg'}% \fi\fi\fi } \def\worddistinct{distinct} \def\wordexample{example} \def\wordcode{code} % Default is `distinct'. \kbdinputstyle distinct \def\xkey{\key} \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% \ifx\one\xkey\ifx\threex\three \key{#2}% \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi} % For @indicateurl, @env, @command quotes seem unnecessary, so use \code. \let\indicateurl=\code \let\env=\code \let\command=\code % @clicksequence{File @click{} Open ...} \def\clicksequence#1{\begingroup #1\endgroup} % @clickstyle @arrow (by default) \parseargdef\clickstyle{\def\click{#1}} \def\click{\arrow} % @uref (abbreviation for `urlref') takes an optional (comma-separated) % second argument specifying the text to display and an optional third % arg as text to display instead of (rather than in addition to) the url % itself. First (mandatory) arg is the url. Perhaps eventually put in % a hypertex \special here. % \def\uref#1{\douref #1,,,\finish} \def\douref#1,#2,#3,#4\finish{\begingroup \unsepspaces \pdfurl{#1}% \setbox0 = \hbox{\ignorespaces #3}% \ifdim\wd0 > 0pt \unhbox0 % third arg given, show only that \else \setbox0 = \hbox{\ignorespaces #2}% \ifdim\wd0 > 0pt \ifpdf \unhbox0 % PDF: 2nd arg given, show only it \else \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url \fi \else \code{#1}% only url given, so show it \fi \fi \endlink \endgroup} % @url synonym for @uref, since that's how everyone uses it. % \let\url=\uref % rms does not like angle brackets --karl, 17may97. % So now @email is just like @uref, unless we are pdf. % %\def\email#1{\angleleft{\tt #1}\angleright} \ifpdf \def\email#1{\doemail#1,,\finish} \def\doemail#1,#2,#3\finish{\begingroup \unsepspaces \pdfurl{mailto:#1}% \setbox0 = \hbox{\ignorespaces #2}% \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi \endlink \endgroup} \else \let\email=\uref \fi % Typeset a dimension, e.g., `in' or `pt'. The only reason for the % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. % \def\dmn#1{\thinspace #1} % @l was never documented to mean ``switch to the Lisp font'', % and it is not used as such in any manual I can find. We need it for % Polish suppressed-l. --karl, 22sep96. %\def\l#1{{\li #1}\null} % @acronym for "FBI", "NATO", and the like. % We print this one point size smaller, since it's intended for % all-uppercase. % \def\acronym#1{\doacronym #1,,\finish} \def\doacronym#1,#2,#3\finish{% {\selectfonts\lsize #1}% \def\temp{#2}% \ifx\temp\empty \else \space ({\unsepspaces \ignorespaces \temp \unskip})% \fi } % @abbr for "Comput. J." and the like. % No font change, but don't do end-of-sentence spacing. % \def\abbr#1{\doabbr #1,,\finish} \def\doabbr#1,#2,#3\finish{% {\plainfrenchspacing #1}% \def\temp{#2}% \ifx\temp\empty \else \space ({\unsepspaces \ignorespaces \temp \unskip})% \fi } \message{glyphs,} % @point{}, @result{}, @expansion{}, @print{}, @equiv{}. % % Since these characters are used in examples, they should be an even number of % \tt widths. Each \tt character is 1en, so two makes it 1em. % \def\point{$\star$} \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}} \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}} \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}} % The @error{} command. % Adapted from the TeXbook's \boxit. % \newbox\errorbox % {\tentt \global\dimen0 = 3em}% Width of the box. \dimen2 = .55pt % Thickness of rules % The text. (`r' is open on the right, `e' somewhat less so on the left.) \setbox0 = \hbox{\kern-.75pt \reducedsf error\kern-1.5pt} % \setbox\errorbox=\hbox to \dimen0{\hfil \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. \advance\hsize by -2\dimen2 % Rules. \vbox{% \hrule height\dimen2 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. \kern3pt\vrule width\dimen2}% Space to right. \hrule height\dimen2} \hfil} % \def\error{\leavevmode\lower.7ex\copy\errorbox} % @pounds{} is a sterling sign, which Knuth put in the CM italic font. % \def\pounds{{\it\$}} % @euro{} comes from a separate font, depending on the current style. % We use the free feym* fonts from the eurosym package by Henrik % Theiling, which support regular, slanted, bold and bold slanted (and % "outlined" (blackboard board, sort of) versions, which we don't need). % It is available from http://www.ctan.org/tex-archive/fonts/eurosym. % % Although only regular is the truly official Euro symbol, we ignore % that. The Euro is designed to be slightly taller than the regular % font height. % % feymr - regular % feymo - slanted % feybr - bold % feybo - bold slanted % % There is no good (free) typewriter version, to my knowledge. % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. % Hmm. % % Also doesn't work in math. Do we need to do math with euro symbols? % Hope not. % % \def\euro{{\eurofont e}} \def\eurofont{% % We set the font at each command, rather than predefining it in % \textfonts and the other font-switching commands, so that % installations which never need the symbol don't have to have the % font installed. % % There is only one designed size (nominal 10pt), so we always scale % that to the current nominal size. % % By the way, simply using "at 1em" works for cmr10 and the like, but % does not work for cmbx10 and other extended/shrunken fonts. % \def\eurosize{\csname\curfontsize nominalsize\endcsname}% % \ifx\curfontstyle\bfstylename % bold: \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize \else % regular: \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize \fi \thiseurofont } % Glyphs from the EC fonts. We don't use \let for the aliases, because % sometimes we redefine the original macro, and the alias should reflect % the redefinition. % % Use LaTeX names for the Icelandic letters. \def\DH{{\ecfont \char"D0}} % Eth \def\dh{{\ecfont \char"F0}} % eth \def\TH{{\ecfont \char"DE}} % Thorn \def\th{{\ecfont \char"FE}} % thorn % \def\guillemetleft{{\ecfont \char"13}} \def\guillemotleft{\guillemetleft} \def\guillemetright{{\ecfont \char"14}} \def\guillemotright{\guillemetright} \def\guilsinglleft{{\ecfont \char"0E}} \def\guilsinglright{{\ecfont \char"0F}} \def\quotedblbase{{\ecfont \char"12}} \def\quotesinglbase{{\ecfont \char"0D}} % % This positioning is not perfect (see the ogonek LaTeX package), but % we have the precomposed glyphs for the most common cases. We put the % tests to use those glyphs in the single \ogonek macro so we have fewer % dummy definitions to worry about for index entries, etc. % % ogonek is also used with other letters in Lithuanian (IOU), but using % the precomposed glyphs for those is not so easy since they aren't in % the same EC font. \def\ogonek#1{{% \def\temp{#1}% \ifx\temp\macrocharA\Aogonek \else\ifx\temp\macrochara\aogonek \else\ifx\temp\macrocharE\Eogonek \else\ifx\temp\macrochare\eogonek \else \ecfont \setbox0=\hbox{#1}% \ifdim\ht0=1ex\accent"0C #1% \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}% \fi \fi\fi\fi\fi }% } \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A} \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a} \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E} \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e} % % Use the ec* fonts (cm-super in outline format) for non-CM glyphs. \def\ecfont{% % We can't distinguish serif/sans and italic/slanted, but this % is used for crude hacks anyway (like adding French and German % quotes to documents typeset with CM, where we lose kerning), so % hopefully nobody will notice/care. \edef\ecsize{\csname\curfontsize ecsize\endcsname}% \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}% \ifx\curfontstyle\bfstylename % bold: \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize \else % regular: \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize \fi \thisecfont } % @registeredsymbol - R in a circle. The font for the R should really % be smaller yet, but lllsize is the best we can do for now. % Adapted from the plain.tex definition of \copyright. % \def\registeredsymbol{% $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}% \hfil\crcr\Orb}}% }$% } % @textdegree - the normal degrees sign. % \def\textdegree{$^\circ$} % Laurent Siebenmann reports \Orb undefined with: % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 % so we'll define it if necessary. % \ifx\Orb\undefined \def\Orb{\mathhexbox20D} \fi % Quotes. \chardef\quotedblleft="5C \chardef\quotedblright=`\" \chardef\quoteleft=`\` \chardef\quoteright=`\' \message{page headings,} \newskip\titlepagetopglue \titlepagetopglue = 1.5in \newskip\titlepagebottomglue \titlepagebottomglue = 2pc % First the title page. Must do @settitle before @titlepage. \newif\ifseenauthor \newif\iffinishedtitlepage % Do an implicit @contents or @shortcontents after @end titlepage if the % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. % \newif\ifsetcontentsaftertitlepage \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue \newif\ifsetshortcontentsaftertitlepage \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue \parseargdef\shorttitlepage{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% \endgroup\page\hbox{}\page} \envdef\titlepage{% % Open one extra group, as we want to close it in the middle of \Etitlepage. \begingroup \parindent=0pt \textfonts % Leave some space at the very top of the page. \vglue\titlepagetopglue % No rule at page bottom unless we print one at the top with @title. \finishedtitlepagetrue % % Most title ``pages'' are actually two pages long, with space % at the top of the second. We don't want the ragged left on the second. \let\oldpage = \page \def\page{% \iffinishedtitlepage\else \finishtitlepage \fi \let\page = \oldpage \page \null }% } \def\Etitlepage{% \iffinishedtitlepage\else \finishtitlepage \fi % It is important to do the page break before ending the group, % because the headline and footline are only empty inside the group. % If we use the new definition of \page, we always get a blank page % after the title page, which we certainly don't want. \oldpage \endgroup % % Need this before the \...aftertitlepage checks so that if they are % in effect the toc pages will come out with page numbers. \HEADINGSon % % If they want short, they certainly want long too. \ifsetshortcontentsaftertitlepage \shortcontents \contents \global\let\shortcontents = \relax \global\let\contents = \relax \fi % \ifsetcontentsaftertitlepage \contents \global\let\contents = \relax \global\let\shortcontents = \relax \fi } \def\finishtitlepage{% \vskip4pt \hrule height 2pt width \hsize \vskip\titlepagebottomglue \finishedtitlepagetrue } %%% Macros to be used within @titlepage: \let\subtitlerm=\tenrm \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} \parseargdef\title{% \checkenv\titlepage \leftline{\titlefonts\rmisbold #1} % print a rule at the page bottom also. \finishedtitlepagefalse \vskip4pt \hrule height 4pt width \hsize \vskip4pt } \parseargdef\subtitle{% \checkenv\titlepage {\subtitlefont \rightline{#1}}% } % @author should come last, but may come many times. % It can also be used inside @quotation. % \parseargdef\author{% \def\temp{\quotation}% \ifx\thisenv\temp \def\quotationauthor{#1}% printed in \Equotation. \else \checkenv\titlepage \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi {\secfonts\rmisbold \leftline{#1}}% \fi } %%% Set up page headings and footings. \let\thispage=\folio \newtoks\evenheadline % headline on even pages \newtoks\oddheadline % headline on odd pages \newtoks\evenfootline % footline on even pages \newtoks\oddfootline % footline on odd pages % Now make TeX use those variables \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}} \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline \else \the\evenfootline \fi}\HEADINGShook} \let\HEADINGShook=\relax % Commands to set those variables. % For example, this is what @headings on does % @evenheading @thistitle|@thispage|@thischapter % @oddheading @thischapter|@thispage|@thistitle % @evenfooting @thisfile|| % @oddfooting ||@thisfile \def\evenheading{\parsearg\evenheadingxxx} \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish} \def\evenheadingyyy #1\|#2\|#3\|#4\finish{% \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \def\oddheading{\parsearg\oddheadingxxx} \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish} \def\oddheadingyyy #1\|#2\|#3\|#4\finish{% \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}% \def\evenfooting{\parsearg\evenfootingxxx} \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish} \def\evenfootingyyy #1\|#2\|#3\|#4\finish{% \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \def\oddfooting{\parsearg\oddfootingxxx} \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish} \def\oddfootingyyy #1\|#2\|#3\|#4\finish{% \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% % % Leave some space for the footline. Hopefully ok to assume % @evenfooting will not be used by itself. \global\advance\pageheight by -12pt \global\advance\vsize by -12pt } \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}} % @evenheadingmarks top \thischapter <- chapter at the top of a page % @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page % % The same set of arguments for: % % @oddheadingmarks % @evenfootingmarks % @oddfootingmarks % @everyheadingmarks % @everyfootingmarks \def\evenheadingmarks{\headingmarks{even}{heading}} \def\oddheadingmarks{\headingmarks{odd}{heading}} \def\evenfootingmarks{\headingmarks{even}{footing}} \def\oddfootingmarks{\headingmarks{odd}{footing}} \def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1} \headingmarks{odd}{heading}{#1} } \def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1} \headingmarks{odd}{footing}{#1} } % #1 = even/odd, #2 = heading/footing, #3 = top/bottom. \def\headingmarks#1#2#3 {% \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname \global\expandafter\let\csname get#1#2marks\endcsname \temp } \everyheadingmarks bottom \everyfootingmarks bottom % @headings double turns headings on for double-sided printing. % @headings single turns headings on for single-sided printing. % @headings off turns them off. % @headings on same as @headings double, retained for compatibility. % @headings after turns on double-sided headings after this page. % @headings doubleafter turns on double-sided headings after this page. % @headings singleafter turns on single-sided headings after this page. % By default, they are off at the start of a document, % and turned `on' after @end titlepage. \def\headings #1 {\csname HEADINGS#1\endcsname} \def\HEADINGSoff{% \global\evenheadline={\hfil} \global\evenfootline={\hfil} \global\oddheadline={\hfil} \global\oddfootline={\hfil}} \HEADINGSoff % When we turn headings on, set the page number to 1. % For double-sided printing, put current file name in lower left corner, % chapter name on inside top of right hand pages, document % title on inside top of left hand pages, and page numbers on outside top % edge of all pages. \def\HEADINGSdouble{% \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\folio\hfil\thistitle}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chapoddpage } \let\contentsalignmacro = \chappager % For single-sided printing, chapter title goes across top left of page, % page number on top right. \def\HEADINGSsingle{% \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\thischapter\hfil\folio}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chappager } \def\HEADINGSon{\HEADINGSdouble} \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} \let\HEADINGSdoubleafter=\HEADINGSafter \def\HEADINGSdoublex{% \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\folio\hfil\thistitle}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chapoddpage } \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} \def\HEADINGSsinglex{% \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\thischapter\hfil\folio}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chappager } % Subroutines used in generating headings % This produces Day Month Year style of output. % Only define if not already defined, in case a txi-??.tex file has set % up a different format (e.g., txi-cs.tex does this). \ifx\today\undefined \def\today{% \number\day\space \ifcase\month \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec \fi \space\number\year} \fi % @settitle line... specifies the title of the document, for headings. % It generates no output of its own. \def\thistitle{\putwordNoTitle} \def\settitle{\parsearg{\gdef\thistitle}} \message{tables,} % Tables -- @table, @ftable, @vtable, @item(x). % default indentation of table text \newdimen\tableindent \tableindent=.8in % default indentation of @itemize and @enumerate text \newdimen\itemindent \itemindent=.3in % margin between end of table item and start of table text. \newdimen\itemmargin \itemmargin=.1in % used internally for \itemindent minus \itemmargin \newdimen\itemmax % Note @table, @ftable, and @vtable define @item, @itemx, etc., with % these defs. % They also define \itemindex % to index the item name in whatever manner is desired (perhaps none). \newif\ifitemxneedsnegativevskip \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} \def\internalBitem{\smallbreak \parsearg\itemzzz} \def\internalBitemx{\itemxpar \parsearg\itemzzz} \def\itemzzz #1{\begingroup % \advance\hsize by -\rightskip \advance\hsize by -\tableindent \setbox0=\hbox{\itemindicate{#1}}% \itemindex{#1}% \nobreak % This prevents a break before @itemx. % % If the item text does not fit in the space we have, put it on a line % by itself, and do not allow a page break either before or after that % line. We do not start a paragraph here because then if the next % command is, e.g., @kindex, the whatsit would get put into the % horizontal list on a line by itself, resulting in extra blank space. \ifdim \wd0>\itemmax % % Make this a paragraph so we get the \parskip glue and wrapping, % but leave it ragged-right. \begingroup \advance\leftskip by-\tableindent \advance\hsize by\tableindent \advance\rightskip by0pt plus1fil \leavevmode\unhbox0\par \endgroup % % We're going to be starting a paragraph, but we don't want the % \parskip glue -- logically it's part of the @item we just started. \nobreak \vskip-\parskip % % Stop a page break at the \parskip glue coming up. However, if % what follows is an environment such as @example, there will be no % \parskip glue; then the negative vskip we just inserted would % cause the example and the item to crash together. So we use this % bizarre value of 10001 as a signal to \aboveenvbreak to insert % \parskip glue after all. Section titles are handled this way also. % \penalty 10001 \endgroup \itemxneedsnegativevskipfalse \else % The item text fits into the space. Start a paragraph, so that the % following text (if any) will end up on the same line. \noindent % Do this with kerns and \unhbox so that if there is a footnote in % the item text, it can migrate to the main vertical list and % eventually be printed. \nobreak\kern-\tableindent \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 \unhbox0 \nobreak\kern\dimen0 \endgroup \itemxneedsnegativevskiptrue \fi } \def\item{\errmessage{@item while not in a list environment}} \def\itemx{\errmessage{@itemx while not in a list environment}} % @table, @ftable, @vtable. \envdef\table{% \let\itemindex\gobble \tablecheck{table}% } \envdef\ftable{% \def\itemindex ##1{\doind {fn}{\code{##1}}}% \tablecheck{ftable}% } \envdef\vtable{% \def\itemindex ##1{\doind {vr}{\code{##1}}}% \tablecheck{vtable}% } \def\tablecheck#1{% \ifnum \the\catcode`\^^M=\active \endgroup \errmessage{This command won't work in this context; perhaps the problem is that we are \inenvironment\thisenv}% \def\next{\doignore{#1}}% \else \let\next\tablex \fi \next } \def\tablex#1{% \def\itemindicate{#1}% \parsearg\tabley } \def\tabley#1{% {% \makevalueexpandable \edef\temp{\noexpand\tablez #1\space\space\space}% \expandafter }\temp \endtablez } \def\tablez #1 #2 #3 #4\endtablez{% \aboveenvbreak \ifnum 0#1>0 \advance \leftskip by #1\mil \fi \ifnum 0#2>0 \tableindent=#2\mil \fi \ifnum 0#3>0 \advance \rightskip by #3\mil \fi \itemmax=\tableindent \advance \itemmax by -\itemmargin \advance \leftskip by \tableindent \exdentamount=\tableindent \parindent = 0pt \parskip = \smallskipamount \ifdim \parskip=0pt \parskip=2pt \fi \let\item = \internalBitem \let\itemx = \internalBitemx } \def\Etable{\endgraf\afterenvbreak} \let\Eftable\Etable \let\Evtable\Etable \let\Eitemize\Etable \let\Eenumerate\Etable % This is the counter used by @enumerate, which is really @itemize \newcount \itemno \envdef\itemize{\parsearg\doitemize} \def\doitemize#1{% \aboveenvbreak \itemmax=\itemindent \advance\itemmax by -\itemmargin \advance\leftskip by \itemindent \exdentamount=\itemindent \parindent=0pt \parskip=\smallskipamount \ifdim\parskip=0pt \parskip=2pt \fi % % Try typesetting the item mark that if the document erroneously says % something like @itemize @samp (intending @table), there's an error % right away at the @itemize. It's not the best error message in the % world, but it's better than leaving it to the @item. This means if % the user wants an empty mark, they have to say @w{} not just @w. \def\itemcontents{#1}% \setbox0 = \hbox{\itemcontents}% % % @itemize with no arg is equivalent to @itemize @bullet. \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi % \let\item=\itemizeitem } % Definition of @item while inside @itemize and @enumerate. % \def\itemizeitem{% \advance\itemno by 1 % for enumerations {\let\par=\endgraf \smallbreak}% reasonable place to break {% % If the document has an @itemize directly after a section title, a % \nobreak will be last on the list, and \sectionheading will have % done a \vskip-\parskip. In that case, we don't want to zero % parskip, or the item text will crash with the heading. On the % other hand, when there is normal text preceding the item (as there % usually is), we do want to zero parskip, or there would be too much % space. In that case, we won't have a \nobreak before. At least % that's the theory. \ifnum\lastpenalty<10000 \parskip=0in \fi \noindent \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% % \vadjust{\penalty 1200}}% not good to break after first line of item. \flushcr } % \splitoff TOKENS\endmark defines \first to be the first token in % TOKENS, and \rest to be the remainder. % \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% % Allow an optional argument of an uppercase letter, lowercase letter, % or number, to specify the first label in the enumerated list. No % argument is the same as `1'. % \envparseargdef\enumerate{\enumeratey #1 \endenumeratey} \def\enumeratey #1 #2\endenumeratey{% % If we were given no argument, pretend we were given `1'. \def\thearg{#1}% \ifx\thearg\empty \def\thearg{1}\fi % % Detect if the argument is a single token. If so, it might be a % letter. Otherwise, the only valid thing it can be is a number. % (We will always have one token, because of the test we just made. % This is a good thing, since \splitoff doesn't work given nothing at % all -- the first parameter is undelimited.) \expandafter\splitoff\thearg\endmark \ifx\rest\empty % Only one token in the argument. It could still be anything. % A ``lowercase letter'' is one whose \lccode is nonzero. % An ``uppercase letter'' is one whose \lccode is both nonzero, and % not equal to itself. % Otherwise, we assume it's a number. % % We need the \relax at the end of the \ifnum lines to stop TeX from % continuing to look for a . % \ifnum\lccode\expandafter`\thearg=0\relax \numericenumerate % a number (we hope) \else % It's a letter. \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax \lowercaseenumerate % lowercase letter \else \uppercaseenumerate % uppercase letter \fi \fi \else % Multiple tokens in the argument. We hope it's a number. \numericenumerate \fi } % An @enumerate whose labels are integers. The starting integer is % given in \thearg. % \def\numericenumerate{% \itemno = \thearg \startenumeration{\the\itemno}% } % The starting (lowercase) letter is in \thearg. \def\lowercaseenumerate{% \itemno = \expandafter`\thearg \startenumeration{% % Be sure we're not beyond the end of the alphabet. \ifnum\itemno=0 \errmessage{No more lowercase letters in @enumerate; get a bigger alphabet}% \fi \char\lccode\itemno }% } % The starting (uppercase) letter is in \thearg. \def\uppercaseenumerate{% \itemno = \expandafter`\thearg \startenumeration{% % Be sure we're not beyond the end of the alphabet. \ifnum\itemno=0 \errmessage{No more uppercase letters in @enumerate; get a bigger alphabet} \fi \char\uccode\itemno }% } % Call \doitemize, adding a period to the first argument and supplying the % common last two arguments. Also subtract one from the initial value in % \itemno, since @item increments \itemno. % \def\startenumeration#1{% \advance\itemno by -1 \doitemize{#1.}\flushcr } % @alphaenumerate and @capsenumerate are abbreviations for giving an arg % to @enumerate. % \def\alphaenumerate{\enumerate{a}} \def\capsenumerate{\enumerate{A}} \def\Ealphaenumerate{\Eenumerate} \def\Ecapsenumerate{\Eenumerate} % @multitable macros % Amy Hendrickson, 8/18/94, 3/6/96 % % @multitable ... @end multitable will make as many columns as desired. % Contents of each column will wrap at width given in preamble. Width % can be specified either with sample text given in a template line, % or in percent of \hsize, the current width of text on page. % Table can continue over pages but will only break between lines. % To make preamble: % % Either define widths of columns in terms of percent of \hsize: % @multitable @columnfractions .25 .3 .45 % @item ... % % Numbers following @columnfractions are the percent of the total % current hsize to be used for each column. You may use as many % columns as desired. % Or use a template: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} % @item ... % using the widest term desired in each column. % Each new table line starts with @item, each subsequent new column % starts with @tab. Empty columns may be produced by supplying @tab's % with nothing between them for as many times as empty columns are needed, % ie, @tab@tab@tab will produce two empty columns. % @item, @tab do not need to be on their own lines, but it will not hurt % if they are. % Sample multitable: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} % @item first col stuff @tab second col stuff @tab third col % @item % first col stuff % @tab % second col stuff % @tab % third col % @item first col stuff @tab second col stuff % @tab Many paragraphs of text may be used in any column. % % They will wrap at the width determined by the template. % @item@tab@tab This will be in third column. % @end multitable % Default dimensions may be reset by user. % @multitableparskip is vertical space between paragraphs in table. % @multitableparindent is paragraph indent in table. % @multitablecolmargin is horizontal space to be left between columns. % @multitablelinespace is space to leave between table items, baseline % to baseline. % 0pt means it depends on current normal line spacing. % \newskip\multitableparskip \newskip\multitableparindent \newdimen\multitablecolspace \newskip\multitablelinespace \multitableparskip=0pt \multitableparindent=6pt \multitablecolspace=12pt \multitablelinespace=0pt % Macros used to set up halign preamble: % \let\endsetuptable\relax \def\xendsetuptable{\endsetuptable} \let\columnfractions\relax \def\xcolumnfractions{\columnfractions} \newif\ifsetpercent % #1 is the @columnfraction, usually a decimal number like .5, but might % be just 1. We just use it, whatever it is. % \def\pickupwholefraction#1 {% \global\advance\colcount by 1 \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}% \setuptable } \newcount\colcount \def\setuptable#1{% \def\firstarg{#1}% \ifx\firstarg\xendsetuptable \let\go = \relax \else \ifx\firstarg\xcolumnfractions \global\setpercenttrue \else \ifsetpercent \let\go\pickupwholefraction \else \global\advance\colcount by 1 \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a % separator; typically that is always in the input, anyway. \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% \fi \fi \ifx\go\pickupwholefraction % Put the argument back for the \pickupwholefraction call, so % we'll always have a period there to be parsed. \def\go{\pickupwholefraction#1}% \else \let\go = \setuptable \fi% \fi \go } % multitable-only commands. % % @headitem starts a heading row, which we typeset in bold. % Assignments have to be global since we are inside the implicit group % of an alignment entry. \everycr resets \everytab so we don't have to % undo it ourselves. \def\headitemfont{\b}% for people to use in the template row; not changeable \def\headitem{% \checkenv\multitable \crcr \global\everytab={\bf}% can't use \headitemfont since the parsing differs \the\everytab % for the first item }% % % A \tab used to include \hskip1sp. But then the space in a template % line is not enough. That is bad. So let's go back to just `&' until % we again encounter the problem the 1sp was intended to solve. % --karl, nathan@acm.org, 20apr99. \def\tab{\checkenv\multitable &\the\everytab}% % @multitable ... @end multitable definitions: % \newtoks\everytab % insert after every tab. % \envdef\multitable{% \vskip\parskip \startsavinginserts % % @item within a multitable starts a normal row. % We use \def instead of \let so that if one of the multitable entries % contains an @itemize, we don't choke on the \item (seen as \crcr aka % \endtemplate) expanding \doitemize. \def\item{\crcr}% % \tolerance=9500 \hbadness=9500 \setmultitablespacing \parskip=\multitableparskip \parindent=\multitableparindent \overfullrule=0pt \global\colcount=0 % \everycr = {% \noalign{% \global\everytab={}% \global\colcount=0 % Reset the column counter. % Check for saved footnotes, etc. \checkinserts % Keeps underfull box messages off when table breaks over pages. %\filbreak % Maybe so, but it also creates really weird page breaks when the % table breaks over pages. Wouldn't \vfil be better? Wait until the % problem manifests itself, so it can be fixed for real --karl. }% }% % \parsearg\domultitable } \def\domultitable#1{% % To parse everything between @multitable and @item: \setuptable#1 \endsetuptable % % This preamble sets up a generic column definition, which will % be used as many times as user calls for columns. % \vtop will set a single line and will also let text wrap and % continue for many paragraphs if desired. \halign\bgroup &% \global\advance\colcount by 1 \multistrut \vtop{% % Use the current \colcount to find the correct column width: \hsize=\expandafter\csname col\the\colcount\endcsname % % In order to keep entries from bumping into each other % we will add a \leftskip of \multitablecolspace to all columns after % the first one. % % If a template has been used, we will add \multitablecolspace % to the width of each template entry. % % If the user has set preamble in terms of percent of \hsize we will % use that dimension as the width of the column, and the \leftskip % will keep entries from bumping into each other. Table will start at % left margin and final column will justify at right margin. % % Make sure we don't inherit \rightskip from the outer environment. \rightskip=0pt \ifnum\colcount=1 % The first column will be indented with the surrounding text. \advance\hsize by\leftskip \else \ifsetpercent \else % If user has not set preamble in terms of percent of \hsize % we will advance \hsize by \multitablecolspace. \advance\hsize by \multitablecolspace \fi % In either case we will make \leftskip=\multitablecolspace: \leftskip=\multitablecolspace \fi % Ignoring space at the beginning and end avoids an occasional spurious % blank line, when TeX decides to break the line at the space before the % box from the multistrut, so the strut ends up on a line by itself. % For example: % @multitable @columnfractions .11 .89 % @item @code{#} % @tab Legal holiday which is valid in major parts of the whole country. % Is automatically provided with highlighting sequences respectively % marking characters. \noindent\ignorespaces##\unskip\multistrut }\cr } \def\Emultitable{% \crcr \egroup % end the \halign \global\setpercentfalse } \def\setmultitablespacing{% \def\multistrut{\strut}% just use the standard line spacing % % Compute \multitablelinespace (if not defined by user) for use in % \multitableparskip calculation. We used define \multistrut based on % this, but (ironically) that caused the spacing to be off. % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100. \ifdim\multitablelinespace=0pt \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip \global\advance\multitablelinespace by-\ht0 \fi %% Test to see if parskip is larger than space between lines of %% table. If not, do nothing. %% If so, set to same dimension as multitablelinespace. \ifdim\multitableparskip>\multitablelinespace \global\multitableparskip=\multitablelinespace \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller %% than skip between lines in the table. \fi% \ifdim\multitableparskip=0pt \global\multitableparskip=\multitablelinespace \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller %% than skip between lines in the table. \fi} \message{conditionals,} % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext, % @ifnotxml always succeed. They currently do nothing; we don't % attempt to check whether the conditionals are properly nested. But we % have to remember that they are conditionals, so that @end doesn't % attempt to close an environment group. % \def\makecond#1{% \expandafter\let\csname #1\endcsname = \relax \expandafter\let\csname iscond.#1\endcsname = 1 } \makecond{iftex} \makecond{ifnotdocbook} \makecond{ifnothtml} \makecond{ifnotinfo} \makecond{ifnotplaintext} \makecond{ifnotxml} % Ignore @ignore, @ifhtml, @ifinfo, and the like. % \def\direntry{\doignore{direntry}} \def\documentdescription{\doignore{documentdescription}} \def\docbook{\doignore{docbook}} \def\html{\doignore{html}} \def\ifdocbook{\doignore{ifdocbook}} \def\ifhtml{\doignore{ifhtml}} \def\ifinfo{\doignore{ifinfo}} \def\ifnottex{\doignore{ifnottex}} \def\ifplaintext{\doignore{ifplaintext}} \def\ifxml{\doignore{ifxml}} \def\ignore{\doignore{ignore}} \def\menu{\doignore{menu}} \def\xml{\doignore{xml}} % Ignore text until a line `@end #1', keeping track of nested conditionals. % % A count to remember the depth of nesting. \newcount\doignorecount \def\doignore#1{\begingroup % Scan in ``verbatim'' mode: \obeylines \catcode`\@ = \other \catcode`\{ = \other \catcode`\} = \other % % Make sure that spaces turn into tokens that match what \doignoretext wants. \spaceisspace % % Count number of #1's that we've seen. \doignorecount = 0 % % Swallow text until we reach the matching `@end #1'. \dodoignore{#1}% } { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source. \obeylines % % \gdef\dodoignore#1{% % #1 contains the command name as a string, e.g., `ifinfo'. % % Define a command to find the next `@end #1'. \long\def\doignoretext##1^^M@end #1{% \doignoretextyyy##1^^M@#1\_STOP_}% % % And this command to find another #1 command, at the beginning of a % line. (Otherwise, we would consider a line `@c @ifset', for % example, to count as an @ifset for nesting.) \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}% % % And now expand that command. \doignoretext ^^M% }% } \def\doignoreyyy#1{% \def\temp{#1}% \ifx\temp\empty % Nothing found. \let\next\doignoretextzzz \else % Found a nested condition, ... \advance\doignorecount by 1 \let\next\doignoretextyyy % ..., look for another. % If we're here, #1 ends with ^^M\ifinfo (for example). \fi \next #1% the token \_STOP_ is present just after this macro. } % We have to swallow the remaining "\_STOP_". % \def\doignoretextzzz#1{% \ifnum\doignorecount = 0 % We have just found the outermost @end. \let\next\enddoignore \else % Still inside a nested condition. \advance\doignorecount by -1 \let\next\doignoretext % Look for the next @end. \fi \next } % Finish off ignored text. { \obeylines% % Ignore anything after the last `@end #1'; this matters in verbatim % environments, where otherwise the newline after an ignored conditional % would result in a blank line in the output. \gdef\enddoignore#1^^M{\endgroup\ignorespaces}% } % @set VAR sets the variable VAR to an empty value. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. % % Since we want to separate VAR from REST-OF-LINE (which might be % empty), we can't just use \parsearg; we have to insert a space of our % own to delimit the rest of the line, and then take it out again if we % didn't need it. % We rely on the fact that \parsearg sets \catcode`\ =10. % \parseargdef\set{\setyyy#1 \endsetyyy} \def\setyyy#1 #2\endsetyyy{% {% \makevalueexpandable \def\temp{#2}% \edef\next{\gdef\makecsname{SET#1}}% \ifx\temp\empty \next{}% \else \setzzz#2\endsetzzz \fi }% } % Remove the trailing space \setxxx inserted. \def\setzzz#1 \endsetzzz{\next{#1}} % @clear VAR clears (i.e., unsets) the variable VAR. % \parseargdef\clear{% {% \makevalueexpandable \global\expandafter\let\csname SET#1\endcsname=\relax }% } % @value{foo} gets the text saved in variable foo. \def\value{\begingroup\makevalueexpandable\valuexxx} \def\valuexxx#1{\expandablevalue{#1}\endgroup} { \catcode`\- = \active \catcode`\_ = \active % \gdef\makevalueexpandable{% \let\value = \expandablevalue % We don't want these characters active, ... \catcode`\-=\other \catcode`\_=\other % ..., but we might end up with active ones in the argument if % we're called from @code, as @code{@value{foo-bar_}}, though. % So \let them to their normal equivalents. \let-\realdash \let_\normalunderscore } } % We have this subroutine so that we can handle at least some @value's % properly in indexes (we call \makevalueexpandable in \indexdummies). % The command has to be fully expandable (if the variable is set), since % the result winds up in the index file. This means that if the % variable's value contains other Texinfo commands, it's almost certain % it will fail (although perhaps we could fix that with sufficient work % to do a one-level expansion on the result, instead of complete). % \def\expandablevalue#1{% \expandafter\ifx\csname SET#1\endcsname\relax {[No value for ``#1'']}% \message{Variable `#1', used in @value, is not set.}% \else \csname SET#1\endcsname \fi } % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined % with @set. % % To get special treatment of `@end ifset,' call \makeond and the redefine. % \makecond{ifset} \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} \def\doifset#1#2{% {% \makevalueexpandable \let\next=\empty \expandafter\ifx\csname SET#2\endcsname\relax #1% If not set, redefine \next. \fi \expandafter }\next } \def\ifsetfail{\doignore{ifset}} % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been % defined with @set, or has been undefined with @clear. % % The `\else' inside the `\doifset' parameter is a trick to reuse the % above code: if the variable is not set, do nothing, if it is set, % then redefine \next to \ifclearfail. % \makecond{ifclear} \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} \def\ifclearfail{\doignore{ifclear}} % @dircategory CATEGORY -- specify a category of the dir file % which this file should belong to. Ignore this in TeX. \let\dircategory=\comment % @defininfoenclose. \let\definfoenclose=\comment \message{indexing,} % Index generation facilities % Define \newwrite to be identical to plain tex's \newwrite % except not \outer, so it can be used within macros and \if's. \edef\newwrite{\makecsname{ptexnewwrite}} % \newindex {foo} defines an index named foo. % It automatically defines \fooindex such that % \fooindex ...rest of line... puts an entry in the index foo. % It also defines \fooindfile to be the number of the output channel for % the file that accumulates this index. The file's extension is foo. % The name of an index should be no more than 2 characters long % for the sake of vms. % \def\newindex#1{% \iflinks \expandafter\newwrite \csname#1indfile\endcsname \openout \csname#1indfile\endcsname \jobname.#1 % Open the file \fi \expandafter\xdef\csname#1index\endcsname{% % Define @#1index \noexpand\doindex{#1}} } % @defindex foo == \newindex{foo} % \def\defindex{\parsearg\newindex} % Define @defcodeindex, like @defindex except put all entries in @code. % \def\defcodeindex{\parsearg\newcodeindex} % \def\newcodeindex#1{% \iflinks \expandafter\newwrite \csname#1indfile\endcsname \openout \csname#1indfile\endcsname \jobname.#1 \fi \expandafter\xdef\csname#1index\endcsname{% \noexpand\docodeindex{#1}}% } % @synindex foo bar makes index foo feed into index bar. % Do this instead of @defindex foo if you don't want it as a separate index. % % @syncodeindex foo bar similar, but put all entries made for index foo % inside @code. % \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), % #3 the target index (bar). \def\dosynindex#1#2#3{% % Only do \closeout if we haven't already done it, else we'll end up % closing the target index. \expandafter \ifx\csname donesynindex#2\endcsname \relax % The \closeout helps reduce unnecessary open files; the limit on the % Acorn RISC OS is a mere 16 files. \expandafter\closeout\csname#2indfile\endcsname \expandafter\let\csname donesynindex#2\endcsname = 1 \fi % redefine \fooindfile: \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname \expandafter\let\csname#2indfile\endcsname=\temp % redefine \fooindex: \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% } % Define \doindex, the driver for all \fooindex macros. % Argument #1 is generated by the calling \fooindex macro, % and it is "foo", the name of the index. % \doindex just uses \parsearg; it calls \doind for the actual work. % This is because \doind is more useful to call from other macros. % There is also \dosubind {index}{topic}{subtopic} % which makes an entry in a two-level index such as the operation index. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} \def\singleindexer #1{\doind{\indexname}{#1}} % like the previous two, but they put @code around the argument. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} % Take care of Texinfo commands that can appear in an index entry. % Since there are some commands we want to expand, and others we don't, % we have to laboriously prevent expansion for those that we don't. % \def\indexdummies{% \escapechar = `\\ % use backslash in output files. \def\@{@}% change to @@ when we switch to @ as escape char in index files. \def\ {\realbackslash\space }% % % Need these in case \tex is in effect and \{ is a \delimiter again. % But can't use \lbracecmd and \rbracecmd because texindex assumes % braces and backslashes are used only as delimiters. \let\{ = \mylbrace \let\} = \myrbrace % % I don't entirely understand this, but when an index entry is % generated from a macro call, the \endinput which \scanmacro inserts % causes processing to be prematurely terminated. This is, % apparently, because \indexsorttmp is fully expanded, and \endinput % is an expandable command. The redefinition below makes \endinput % disappear altogether for that purpose -- although logging shows that % processing continues to some further point. On the other hand, it % seems \endinput does not hurt in the printed index arg, since that % is still getting written without apparent harm. % % Sample source (mac-idx3.tex, reported by Graham Percival to % help-texinfo, 22may06): % @macro funindex {WORD} % @findex xyz % @end macro % ... % @funindex commtest % % The above is not enough to reproduce the bug, but it gives the flavor. % % Sample whatsit resulting: % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}} % % So: \let\endinput = \empty % % Do the redefinitions. \commondummies } % For the aux and toc files, @ is the escape character. So we want to % redefine everything using @ as the escape character (instead of % \realbackslash, still used for index files). When everything uses @, % this will be simpler. % \def\atdummies{% \def\@{@@}% \def\ {@ }% \let\{ = \lbraceatcmd \let\} = \rbraceatcmd % % Do the redefinitions. \commondummies \otherbackslash } % Called from \indexdummies and \atdummies. % \def\commondummies{% % % \definedummyword defines \#1 as \string\#1\space, thus effectively % preventing its expansion. This is used only for control% words, % not control letters, because the \space would be incorrect for % control characters, but is needed to separate the control word % from whatever follows. % % For control letters, we have \definedummyletter, which omits the % space. % % These can be used both for control words that take an argument and % those that do not. If it is followed by {arg} in the input, then % that will dutifully get written to the index (or wherever). % \def\definedummyword ##1{\def##1{\string##1\space}}% \def\definedummyletter##1{\def##1{\string##1}}% \let\definedummyaccent\definedummyletter % \commondummiesnofonts % \definedummyletter\_% % % Non-English letters. \definedummyword\AA \definedummyword\AE \definedummyword\DH \definedummyword\L \definedummyword\O \definedummyword\OE \definedummyword\TH \definedummyword\aa \definedummyword\ae \definedummyword\dh \definedummyword\exclamdown \definedummyword\l \definedummyword\o \definedummyword\oe \definedummyword\ordf \definedummyword\ordm \definedummyword\questiondown \definedummyword\ss \definedummyword\th % % Although these internal commands shouldn't show up, sometimes they do. \definedummyword\bf \definedummyword\gtr \definedummyword\hat \definedummyword\less \definedummyword\sf \definedummyword\sl \definedummyword\tclose \definedummyword\tt % \definedummyword\LaTeX \definedummyword\TeX % % Assorted special characters. \definedummyword\bullet \definedummyword\comma \definedummyword\copyright \definedummyword\registeredsymbol \definedummyword\dots \definedummyword\enddots \definedummyword\equiv \definedummyword\error \definedummyword\euro \definedummyword\guillemetleft \definedummyword\guillemetright \definedummyword\guilsinglleft \definedummyword\guilsinglright \definedummyword\expansion \definedummyword\minus \definedummyword\ogonek \definedummyword\pounds \definedummyword\point \definedummyword\print \definedummyword\quotedblbase \definedummyword\quotedblleft \definedummyword\quotedblright \definedummyword\quoteleft \definedummyword\quoteright \definedummyword\quotesinglbase \definedummyword\result \definedummyword\textdegree % % We want to disable all macros so that they are not expanded by \write. \macrolist % \normalturnoffactive % % Handle some cases of @value -- where it does not contain any % (non-fully-expandable) commands. \makevalueexpandable } % \commondummiesnofonts: common to \commondummies and \indexnofonts. % \def\commondummiesnofonts{% % Control letters and accents. \definedummyletter\!% \definedummyaccent\"% \definedummyaccent\'% \definedummyletter\*% \definedummyaccent\,% \definedummyletter\.% \definedummyletter\/% \definedummyletter\:% \definedummyaccent\=% \definedummyletter\?% \definedummyaccent\^% \definedummyaccent\`% \definedummyaccent\~% \definedummyword\u \definedummyword\v \definedummyword\H \definedummyword\dotaccent \definedummyword\ogonek \definedummyword\ringaccent \definedummyword\tieaccent \definedummyword\ubaraccent \definedummyword\udotaccent \definedummyword\dotless % % Texinfo font commands. \definedummyword\b \definedummyword\i \definedummyword\r \definedummyword\sc \definedummyword\t % % Commands that take arguments. \definedummyword\acronym \definedummyword\cite \definedummyword\code \definedummyword\command \definedummyword\dfn \definedummyword\email \definedummyword\emph \definedummyword\env \definedummyword\file \definedummyword\kbd \definedummyword\key \definedummyword\math \definedummyword\option \definedummyword\pxref \definedummyword\ref \definedummyword\samp \definedummyword\strong \definedummyword\tie \definedummyword\uref \definedummyword\url \definedummyword\var \definedummyword\verb \definedummyword\w \definedummyword\xref } % \indexnofonts is used when outputting the strings to sort the index % by, and when constructing control sequence names. It eliminates all % control sequences and just writes whatever the best ASCII sort string % would be for a given command (usually its argument). % \def\indexnofonts{% % Accent commands should become @asis. \def\definedummyaccent##1{\let##1\asis}% % We can just ignore other control letters. \def\definedummyletter##1{\let##1\empty}% % Hopefully, all control words can become @asis. \let\definedummyword\definedummyaccent % \commondummiesnofonts % % Don't no-op \tt, since it isn't a user-level command % and is used in the definitions of the active chars like <, >, |, etc. % Likewise with the other plain tex font commands. %\let\tt=\asis % \def\ { }% \def\@{@}% % how to handle braces? \def\_{\normalunderscore}% % % Non-English letters. \def\AA{AA}% \def\AE{AE}% \def\DH{DZZ}% \def\L{L}% \def\OE{OE}% \def\O{O}% \def\TH{ZZZ}% \def\aa{aa}% \def\ae{ae}% \def\dh{dzz}% \def\exclamdown{!}% \def\l{l}% \def\oe{oe}% \def\ordf{a}% \def\ordm{o}% \def\o{o}% \def\questiondown{?}% \def\ss{ss}% \def\th{zzz}% % \def\LaTeX{LaTeX}% \def\TeX{TeX}% % % Assorted special characters. % (The following {} will end up in the sort string, but that's ok.) \def\bullet{bullet}% \def\comma{,}% \def\copyright{copyright}% \def\dots{...}% \def\enddots{...}% \def\equiv{==}% \def\error{error}% \def\euro{euro}% \def\expansion{==>}% \def\guillemetleft{<<}% \def\guillemetright{>>}% \def\guilsinglleft{<}% \def\guilsinglright{>}% \def\minus{-}% \def\point{.}% \def\pounds{pounds}% \def\print{-|}% \def\quotedblbase{"}% \def\quotedblleft{"}% \def\quotedblright{"}% \def\quoteleft{`}% \def\quoteright{'}% \def\quotesinglbase{,}% \def\registeredsymbol{R}% \def\result{=>}% \def\textdegree{o}% % % We need to get rid of all macros, leaving only the arguments (if present). % Of course this is not nearly correct, but it is the best we can do for now. % makeinfo does not expand macros in the argument to @deffn, which ends up % writing an index entry, and texindex isn't prepared for an index sort entry % that starts with \. % % Since macro invocations are followed by braces, we can just redefine them % to take a single TeX argument. The case of a macro invocation that % goes to end-of-line is not handled. % \macrolist } \let\indexbackslash=0 %overridden during \printindex. \let\SETmarginindex=\relax % put index entries in margin (undocumented)? % Most index entries go through here, but \dosubind is the general case. % #1 is the index name, #2 is the entry text. \def\doind#1#2{\dosubind{#1}{#2}{}} % Workhorse for all \fooindexes. % #1 is name of index, #2 is stuff to put there, #3 is subentry -- % empty if called from \doind, as we usually are (the main exception % is with most defuns, which call us directly). % \def\dosubind#1#2#3{% \iflinks {% % Store the main index entry text (including the third arg). \toks0 = {#2}% % If third arg is present, precede it with a space. \def\thirdarg{#3}% \ifx\thirdarg\empty \else \toks0 = \expandafter{\the\toks0 \space #3}% \fi % \edef\writeto{\csname#1indfile\endcsname}% % \safewhatsit\dosubindwrite }% \fi } % Write the entry in \toks0 to the index file: % \def\dosubindwrite{% % Put the index entry in the margin if desired. \ifx\SETmarginindex\relax\else \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}% \fi % % Remember, we are within a group. \indexdummies % Must do this here, since \bf, etc expand at this stage \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now % so it will be output as is; and it will print as backslash. % % Process the index entry with all font commands turned off, to % get the string to sort by. {\indexnofonts \edef\temp{\the\toks0}% need full expansion \xdef\indexsorttmp{\temp}% }% % % Set up the complete index entry, with both the sort key and % the original text, including any font commands. We write % three arguments to \entry to the .?? file (four in the % subentry case), texindex reduces to two when writing the .??s % sorted result. \edef\temp{% \write\writeto{% \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}% }% \temp } % Take care of unwanted page breaks/skips around a whatsit: % % If a skip is the last thing on the list now, preserve it % by backing up by \lastskip, doing the \write, then inserting % the skip again. Otherwise, the whatsit generated by the % \write or \pdfdest will make \lastskip zero. The result is that % sequences like this: % @end defun % @tindex whatever % @defun ... % will have extra space inserted, because the \medbreak in the % start of the @defun won't see the skip inserted by the @end of % the previous defun. % % But don't do any of this if we're not in vertical mode. We % don't want to do a \vskip and prematurely end a paragraph. % % Avoid page breaks due to these extra skips, too. % % But wait, there is a catch there: % We'll have to check whether \lastskip is zero skip. \ifdim is not % sufficient for this purpose, as it ignores stretch and shrink parts % of the skip. The only way seems to be to check the textual % representation of the skip. % % The following is almost like \def\zeroskipmacro{0.0pt} except that % the ``p'' and ``t'' characters have catcode \other, not 11 (letter). % \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname} % \newskip\whatsitskip \newcount\whatsitpenalty % % ..., ready, GO: % \def\safewhatsit#1{% \ifhmode #1% \else % \lastskip and \lastpenalty cannot both be nonzero simultaneously. \whatsitskip = \lastskip \edef\lastskipmacro{\the\lastskip}% \whatsitpenalty = \lastpenalty % % If \lastskip is nonzero, that means the last item was a % skip. And since a skip is discardable, that means this % -\whatsitskip glue we're inserting is preceded by a % non-discardable item, therefore it is not a potential % breakpoint, therefore no \nobreak needed. \ifx\lastskipmacro\zeroskipmacro \else \vskip-\whatsitskip \fi % #1% % \ifx\lastskipmacro\zeroskipmacro % If \lastskip was zero, perhaps the last item was a penalty, and % perhaps it was >=10000, e.g., a \nobreak. In that case, we want % to re-insert the same penalty (values >10000 are used for various % signals); since we just inserted a non-discardable item, any % following glue (such as a \parskip) would be a breakpoint. For example: % % @deffn deffn-whatever % @vindex index-whatever % Description. % would allow a break between the index-whatever whatsit % and the "Description." paragraph. \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi \else % On the other hand, if we had a nonzero \lastskip, % this make-up glue would be preceded by a non-discardable item % (the whatsit from the \write), so we must insert a \nobreak. \nobreak\vskip\whatsitskip \fi \fi } % The index entry written in the file actually looks like % \entry {sortstring}{page}{topic} % or % \entry {sortstring}{page}{topic}{subtopic} % The texindex program reads in these files and writes files % containing these kinds of lines: % \initial {c} % before the first topic whose initial is c % \entry {topic}{pagelist} % for a topic that is used without subtopics % \primary {topic} % for the beginning of a topic that is used with subtopics % \secondary {subtopic}{pagelist} % for each subtopic. % Define the user-accessible indexing commands % @findex, @vindex, @kindex, @cindex. \def\findex {\fnindex} \def\kindex {\kyindex} \def\cindex {\cpindex} \def\vindex {\vrindex} \def\tindex {\tpindex} \def\pindex {\pgindex} \def\cindexsub {\begingroup\obeylines\cindexsub} {\obeylines % \gdef\cindexsub "#1" #2^^M{\endgroup % \dosubind{cp}{#2}{#1}}} % Define the macros used in formatting output of the sorted index material. % @printindex causes a particular index (the ??s file) to get printed. % It does not print any chapter heading (usually an @unnumbered). % \parseargdef\printindex{\begingroup \dobreak \chapheadingskip{10000}% % \smallfonts \rm \tolerance = 9500 \plainfrenchspacing \everypar = {}% don't want the \kern\-parindent from indentation suppression. % % See if the index file exists and is nonempty. % Change catcode of @ here so that if the index file contains % \initial {@} % as its first line, TeX doesn't complain about mismatched braces % (because it thinks @} is a control sequence). \catcode`\@ = 11 \openin 1 \jobname.#1s \ifeof 1 % \enddoublecolumns gets confused if there is no text in the index, % and it loses the chapter title and the aux file entries for the % index. The easiest way to prevent this problem is to make sure % there is some text. \putwordIndexNonexistent \else % % If the index file exists but is empty, then \openin leaves \ifeof % false. We have to make TeX try to read something from the file, so % it can discover if there is anything in it. \read 1 to \temp \ifeof 1 \putwordIndexIsEmpty \else % Index files are almost Texinfo source, but we use \ as the escape % character. It would be better to use @, but that's too big a change % to make right now. \def\indexbackslash{\backslashcurfont}% \catcode`\\ = 0 \escapechar = `\\ \begindoublecolumns \input \jobname.#1s \enddoublecolumns \fi \fi \closein 1 \endgroup} % These macros are used by the sorted index file itself. % Change them to control the appearance of the index. \def\initial#1{{% % Some minor font changes for the special characters. \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt % % Remove any glue we may have, we'll be inserting our own. \removelastskip % % We like breaks before the index initials, so insert a bonus. \nobreak \vskip 0pt plus 3\baselineskip \penalty 0 \vskip 0pt plus -3\baselineskip % % Typeset the initial. Making this add up to a whole number of % baselineskips increases the chance of the dots lining up from column % to column. It still won't often be perfect, because of the stretch % we need before each entry, but it's better. % % No shrink because it confuses \balancecolumns. \vskip 1.67\baselineskip plus .5\baselineskip \leftline{\secbf #1}% % Do our best not to break after the initial. \nobreak \vskip .33\baselineskip plus .1\baselineskip }} % \entry typesets a paragraph consisting of the text (#1), dot leaders, and % then page number (#2) flushed to the right margin. It is used for index % and table of contents entries. The paragraph is indented by \leftskip. % % A straightforward implementation would start like this: % \def\entry#1#2{... % But this freezes the catcodes in the argument, and can cause problems to % @code, which sets - active. This problem was fixed by a kludge--- % ``-'' was active throughout whole index, but this isn't really right. % % The right solution is to prevent \entry from swallowing the whole text. % --kasal, 21nov03 \def\entry{% \begingroup % % Start a new paragraph if necessary, so our assignments below can't % affect previous text. \par % % Do not fill out the last line with white space. \parfillskip = 0in % % No extra space above this paragraph. \parskip = 0in % % Do not prefer a separate line ending with a hyphen to fewer lines. \finalhyphendemerits = 0 % % \hangindent is only relevant when the entry text and page number % don't both fit on one line. In that case, bob suggests starting the % dots pretty far over on the line. Unfortunately, a large % indentation looks wrong when the entry text itself is broken across % lines. So we use a small indentation and put up with long leaders. % % \hangafter is reset to 1 (which is the value we want) at the start % of each paragraph, so we need not do anything with that. \hangindent = 2em % % When the entry text needs to be broken, just fill out the first line % with blank space. \rightskip = 0pt plus1fil % % A bit of stretch before each entry for the benefit of balancing % columns. \vskip 0pt plus1pt % % Swallow the left brace of the text (first parameter): \afterassignment\doentry \let\temp = } \def\doentry{% \bgroup % Instead of the swallowed brace. \noindent \aftergroup\finishentry % And now comes the text of the entry. } \def\finishentry#1{% % #1 is the page number. % % The following is kludged to not output a line of dots in the index if % there are no page numbers. The next person who breaks this will be % cursed by a Unix daemon. \setbox\boxA = \hbox{#1}% \ifdim\wd\boxA = 0pt \ % \else % % If we must, put the page number on a line of its own, and fill out % this line with blank space. (The \hfil is overwhelmed with the % fill leaders glue in \indexdotfill if the page number does fit.) \hfil\penalty50 \null\nobreak\indexdotfill % Have leaders before the page number. % % The `\ ' here is removed by the implicit \unskip that TeX does as % part of (the primitive) \par. Without it, a spurious underfull % \hbox ensues. \ifpdf \pdfgettoks#1.% \ \the\toksA \else \ #1% \fi \fi \par \endgroup } % Like plain.tex's \dotfill, except uses up at least 1 em. \def\indexdotfill{\cleaders \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill} \def\primary #1{\line{#1\hfil}} \newskip\secondaryindent \secondaryindent=0.5cm \def\secondary#1#2{{% \parfillskip=0in \parskip=0in \hangindent=1in \hangafter=1 \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill \ifpdf \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. \else #2 \fi \par }} % Define two-column mode, which we use to typeset indexes. % Adapted from the TeXbook, page 416, which is to say, % the manmac.tex format used to print the TeXbook itself. \catcode`\@=11 \newbox\partialpage \newdimen\doublecolumnhsize \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns % Grab any single-column material above us. \output = {% % % Here is a possibility not foreseen in manmac: if we accumulate a % whole lot of material, we might end up calling this \output % routine twice in a row (see the doublecol-lose test, which is % essentially a couple of indexes with @setchapternewpage off). In % that case we just ship out what is in \partialpage with the normal % output routine. Generally, \partialpage will be empty when this % runs and this will be a no-op. See the indexspread.tex test case. \ifvoid\partialpage \else \onepageout{\pagecontents\partialpage}% \fi % \global\setbox\partialpage = \vbox{% % Unvbox the main output page. \unvbox\PAGE \kern-\topskip \kern\baselineskip }% }% \eject % run that output routine to set \partialpage % % Use the double-column output routine for subsequent pages. \output = {\doublecolumnout}% % % Change the page size parameters. We could do this once outside this % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 % format, but then we repeat the same computation. Repeating a couple % of assignments once per index is clearly meaningless for the % execution time, so we may as well do it in one place. % % First we halve the line length, less a little for the gutter between % the columns. We compute the gutter based on the line length, so it % changes automatically with the paper format. The magic constant % below is chosen so that the gutter has the same value (well, +-<1pt) % as it did when we hard-coded it. % % We put the result in a separate register, \doublecolumhsize, so we % can restore it in \pagesofar, after \hsize itself has (potentially) % been clobbered. % \doublecolumnhsize = \hsize \advance\doublecolumnhsize by -.04154\hsize \divide\doublecolumnhsize by 2 \hsize = \doublecolumnhsize % % Double the \vsize as well. (We don't need a separate register here, % since nobody clobbers \vsize.) \vsize = 2\vsize } % The double-column output routine for all double-column pages except % the last. % \def\doublecolumnout{% \splittopskip=\topskip \splitmaxdepth=\maxdepth % Get the available space for the double columns -- the normal % (undoubled) page height minus any material left over from the % previous page. \dimen@ = \vsize \divide\dimen@ by 2 \advance\dimen@ by -\ht\partialpage % % box0 will be the left-hand column, box2 the right. \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ \onepageout\pagesofar \unvbox255 \penalty\outputpenalty } % % Re-output the contents of the output page -- any previous material, % followed by the two boxes we just split, in box0 and box2. \def\pagesofar{% \unvbox\partialpage % \hsize = \doublecolumnhsize \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}% } % % All done with double columns. \def\enddoublecolumns{% % The following penalty ensures that the page builder is exercised % _before_ we change the output routine. This is necessary in the % following situation: % % The last section of the index consists only of a single entry. % Before this section, \pagetotal is less than \pagegoal, so no % break occurs before the last section starts. However, the last % section, consisting of \initial and the single \entry, does not % fit on the page and has to be broken off. Without the following % penalty the page builder will not be exercised until \eject % below, and by that time we'll already have changed the output % routine to the \balancecolumns version, so the next-to-last % double-column page will be processed with \balancecolumns, which % is wrong: The two columns will go to the main vertical list, with % the broken-off section in the recent contributions. As soon as % the output routine finishes, TeX starts reconsidering the page % break. The two columns and the broken-off section both fit on the % page, because the two columns now take up only half of the page % goal. When TeX sees \eject from below which follows the final % section, it invokes the new output routine that we've set after % \balancecolumns below; \onepageout will try to fit the two columns % and the final section into the vbox of \pageheight (see % \pagebody), causing an overfull box. % % Note that glue won't work here, because glue does not exercise the % page builder, unlike penalties (see The TeXbook, pp. 280-281). \penalty0 % \output = {% % Split the last of the double-column material. Leave it on the % current page, no automatic page break. \balancecolumns % % If we end up splitting too much material for the current page, % though, there will be another page break right after this \output % invocation ends. Having called \balancecolumns once, we do not % want to call it again. Therefore, reset \output to its normal % definition right away. (We hope \balancecolumns will never be % called on to balance too much material, but if it is, this makes % the output somewhat more palatable.) \global\output = {\onepageout{\pagecontents\PAGE}}% }% \eject \endgroup % started in \begindoublecolumns % % \pagegoal was set to the doubled \vsize above, since we restarted % the current page. We're now back to normal single-column % typesetting, so reset \pagegoal to the normal \vsize (after the % \endgroup where \vsize got restored). \pagegoal = \vsize } % % Called at the end of the double column material. \def\balancecolumns{% \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. \dimen@ = \ht0 \advance\dimen@ by \topskip \advance\dimen@ by-\baselineskip \divide\dimen@ by 2 % target to split to %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% \splittopskip = \topskip % Loop until we get a decent breakpoint. {% \vbadness = 10000 \loop \global\setbox3 = \copy0 \global\setbox1 = \vsplit3 to \dimen@ \ifdim\ht3>\dimen@ \global\advance\dimen@ by 1pt \repeat }% %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% \setbox0=\vbox to\dimen@{\unvbox1}% \setbox2=\vbox to\dimen@{\unvbox3}% % \pagesofar } \catcode`\@ = \other \message{sectioning,} % Chapters, sections, etc. % \unnumberedno is an oxymoron, of course. But we count the unnumbered % sections so that we can refer to them unambiguously in the pdf % outlines by their "section number". We avoid collisions with chapter % numbers by starting them at 10000. (If a document ever has 10000 % chapters, we're in trouble anyway, I'm sure.) \newcount\unnumberedno \unnumberedno = 10000 \newcount\chapno \newcount\secno \secno=0 \newcount\subsecno \subsecno=0 \newcount\subsubsecno \subsubsecno=0 % This counter is funny since it counts through charcodes of letters A, B, ... \newcount\appendixno \appendixno = `\@ % % \def\appendixletter{\char\the\appendixno} % We do the following ugly conditional instead of the above simple % construct for the sake of pdftex, which needs the actual % letter in the expansion, not just typeset. % \def\appendixletter{% \ifnum\appendixno=`A A% \else\ifnum\appendixno=`B B% \else\ifnum\appendixno=`C C% \else\ifnum\appendixno=`D D% \else\ifnum\appendixno=`E E% \else\ifnum\appendixno=`F F% \else\ifnum\appendixno=`G G% \else\ifnum\appendixno=`H H% \else\ifnum\appendixno=`I I% \else\ifnum\appendixno=`J J% \else\ifnum\appendixno=`K K% \else\ifnum\appendixno=`L L% \else\ifnum\appendixno=`M M% \else\ifnum\appendixno=`N N% \else\ifnum\appendixno=`O O% \else\ifnum\appendixno=`P P% \else\ifnum\appendixno=`Q Q% \else\ifnum\appendixno=`R R% \else\ifnum\appendixno=`S S% \else\ifnum\appendixno=`T T% \else\ifnum\appendixno=`U U% \else\ifnum\appendixno=`V V% \else\ifnum\appendixno=`W W% \else\ifnum\appendixno=`X X% \else\ifnum\appendixno=`Y Y% \else\ifnum\appendixno=`Z Z% % The \the is necessary, despite appearances, because \appendixletter is % expanded while writing the .toc file. \char\appendixno is not % expandable, thus it is written literally, thus all appendixes come out % with the same letter (or @) in the toc without it. \else\char\the\appendixno \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} % Each @chapter defines these (using marks) as the number+name, number % and name of the chapter. Page headings and footings can use % these. @section does likewise. \def\thischapter{} \def\thischapternum{} \def\thischaptername{} \def\thissection{} \def\thissectionnum{} \def\thissectionname{} \newcount\absseclevel % used to calculate proper heading level \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count % @raisesections: treat @section as chapter, @subsection as section, etc. \def\raisesections{\global\advance\secbase by -1} \let\up=\raisesections % original BFox name % @lowersections: treat @chapter as section, @section as subsection, etc. \def\lowersections{\global\advance\secbase by 1} \let\down=\lowersections % original BFox name % we only have subsub. \chardef\maxseclevel = 3 % % A numbered section within an unnumbered changes to unnumbered too. % To achive this, remember the "biggest" unnum. sec. we are currently in: \chardef\unmlevel = \maxseclevel % % Trace whether the current chapter is an appendix or not: % \chapheadtype is "N" or "A", unnumbered chapters are ignored. \def\chapheadtype{N} % Choose a heading macro % #1 is heading type % #2 is heading level % #3 is text for heading \def\genhead#1#2#3{% % Compute the abs. sec. level: \absseclevel=#2 \advance\absseclevel by \secbase % Make sure \absseclevel doesn't fall outside the range: \ifnum \absseclevel < 0 \absseclevel = 0 \else \ifnum \absseclevel > 3 \absseclevel = 3 \fi \fi % The heading type: \def\headtype{#1}% \if \headtype U% \ifnum \absseclevel < \unmlevel \chardef\unmlevel = \absseclevel \fi \else % Check for appendix sections: \ifnum \absseclevel = 0 \edef\chapheadtype{\headtype}% \else \if \headtype A\if \chapheadtype N% \errmessage{@appendix... within a non-appendix chapter}% \fi\fi \fi % Check for numbered within unnumbered: \ifnum \absseclevel > \unmlevel \def\headtype{U}% \else \chardef\unmlevel = 3 \fi \fi % Now print the heading: \if \headtype U% \ifcase\absseclevel \unnumberedzzz{#3}% \or \unnumberedseczzz{#3}% \or \unnumberedsubseczzz{#3}% \or \unnumberedsubsubseczzz{#3}% \fi \else \if \headtype A% \ifcase\absseclevel \appendixzzz{#3}% \or \appendixsectionzzz{#3}% \or \appendixsubseczzz{#3}% \or \appendixsubsubseczzz{#3}% \fi \else \ifcase\absseclevel \chapterzzz{#3}% \or \seczzz{#3}% \or \numberedsubseczzz{#3}% \or \numberedsubsubseczzz{#3}% \fi \fi \fi \suppressfirstparagraphindent } % an interface: \def\numhead{\genhead N} \def\apphead{\genhead A} \def\unnmhead{\genhead U} % @chapter, @appendix, @unnumbered. Increment top-level counter, reset % all lower-level sectioning counters to zero. % % Also set \chaplevelprefix, which we prepend to @float sequence numbers % (e.g., figures), q.v. By default (before any chapter), that is empty. \let\chaplevelprefix = \empty % \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz \def\chapterzzz#1{% % section resetting is \global in case the chapter is in a group, such % as an @include file. \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 \global\advance\chapno by 1 % % Used for \float. \gdef\chaplevelprefix{\the\chapno.}% \resetallfloatnos % % \putwordChapter can contain complex things in translations. \toks0=\expandafter{\putwordChapter}% \message{\the\toks0 \space \the\chapno}% % % Write the actual heading. \chapmacro{#1}{Ynumbered}{\the\chapno}% % % So @section and the like are numbered underneath this chapter. \global\let\section = \numberedsec \global\let\subsection = \numberedsubsec \global\let\subsubsection = \numberedsubsubsec } \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz % \def\appendixzzz#1{% \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 \global\advance\appendixno by 1 \gdef\chaplevelprefix{\appendixletter.}% \resetallfloatnos % % \putwordAppendix can contain complex things in translations. \toks0=\expandafter{\putwordAppendix}% \message{\the\toks0 \space \appendixletter}% % \chapmacro{#1}{Yappendix}{\appendixletter}% % \global\let\section = \appendixsec \global\let\subsection = \appendixsubsec \global\let\subsubsection = \appendixsubsubsec } \outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz \def\unnumberedzzz#1{% \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 \global\advance\unnumberedno by 1 % % Since an unnumbered has no number, no prefix for figures. \global\let\chaplevelprefix = \empty \resetallfloatnos % % This used to be simply \message{#1}, but TeX fully expands the % argument to \message. Therefore, if #1 contained @-commands, TeX % expanded them. For example, in `@unnumbered The @cite{Book}', TeX % expanded @cite (which turns out to cause errors because \cite is meant % to be executed, not expanded). % % Anyway, we don't want the fully-expanded definition of @cite to appear % as a result of the \message, we just want `@cite' itself. We use % \the to achieve this: TeX expands \the only once, % simply yielding the contents of . (We also do this for % the toc entries.) \toks0 = {#1}% \message{(\the\toks0)}% % \chapmacro{#1}{Ynothing}{\the\unnumberedno}% % \global\let\section = \unnumberedsec \global\let\subsection = \unnumberedsubsec \global\let\subsubsection = \unnumberedsubsubsec } % @centerchap is like @unnumbered, but the heading is centered. \outer\parseargdef\centerchap{% % Well, we could do the following in a group, but that would break % an assumption that \chapmacro is called at the outermost level. % Thus we are safer this way: --kasal, 24feb04 \let\centerparametersmaybe = \centerparameters \unnmhead0{#1}% \let\centerparametersmaybe = \relax } % @top is like @unnumbered. \let\top\unnumbered % Sections. \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz \def\seczzz#1{% \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% } \outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz \def\appendixsectionzzz#1{% \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% } \let\appendixsec\appendixsection \outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz \def\unnumberedseczzz#1{% \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% } % Subsections. \outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz \def\numberedsubseczzz#1{% \global\subsubsecno=0 \global\advance\subsecno by 1 \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% } \outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz \def\appendixsubseczzz#1{% \global\subsubsecno=0 \global\advance\subsecno by 1 \sectionheading{#1}{subsec}{Yappendix}% {\appendixletter.\the\secno.\the\subsecno}% } \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz \def\unnumberedsubseczzz#1{% \global\subsubsecno=0 \global\advance\subsecno by 1 \sectionheading{#1}{subsec}{Ynothing}% {\the\unnumberedno.\the\secno.\the\subsecno}% } % Subsubsections. \outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz \def\numberedsubsubseczzz#1{% \global\advance\subsubsecno by 1 \sectionheading{#1}{subsubsec}{Ynumbered}% {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% } \outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz \def\appendixsubsubseczzz#1{% \global\advance\subsubsecno by 1 \sectionheading{#1}{subsubsec}{Yappendix}% {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% } \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz \def\unnumberedsubsubseczzz#1{% \global\advance\subsubsecno by 1 \sectionheading{#1}{subsubsec}{Ynothing}% {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}% } % These macros control what the section commands do, according % to what kind of chapter we are in (ordinary, appendix, or unnumbered). % Define them by default for a numbered chapter. \let\section = \numberedsec \let\subsection = \numberedsubsec \let\subsubsection = \numberedsubsubsec % Define @majorheading, @heading and @subheading % NOTE on use of \vbox for chapter headings, section headings, and such: % 1) We use \vbox rather than the earlier \line to permit % overlong headings to fold. % 2) \hyphenpenalty is set to 10000 because hyphenation in a % heading is obnoxious; this forbids it. % 3) Likewise, headings look best if no \parindent is used, and % if justification is not attempted. Hence \raggedright. \def\majorheading{% {\advance\chapheadingskip by 10pt \chapbreak }% \parsearg\chapheadingzzz } \def\chapheading{\chapbreak \parsearg\chapheadingzzz} \def\chapheadingzzz#1{% {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\ptexraggedright \rmisbold #1\hfill}}% \bigskip \par\penalty 200\relax \suppressfirstparagraphindent } % @heading, @subheading, @subsubheading. \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{} \suppressfirstparagraphindent} \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{} \suppressfirstparagraphindent} \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{} \suppressfirstparagraphindent} % These macros generate a chapter, section, etc. heading only % (including whitespace, linebreaking, etc. around it), % given all the information in convenient, parsed form. %%% Args are the skip and penalty (usually negative) \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} %%% Define plain chapter starts, and page on/off switching for it % Parameter controlling skip before chapter headings (if needed) \newskip\chapheadingskip \def\chapbreak{\dobreak \chapheadingskip {-4000}} \def\chappager{\par\vfill\supereject} % Because \domark is called before \chapoddpage, the filler page will % get the headings for the next chapter, which is wrong. But we don't % care -- we just disable all headings on the filler page. \def\chapoddpage{% \chappager \ifodd\pageno \else \begingroup \evenheadline={\hfil}\evenfootline={\hfil}% \oddheadline={\hfil}\oddfootline={\hfil}% \hbox to 0pt{}% \chappager \endgroup \fi } \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} \def\CHAPPAGoff{% \global\let\contentsalignmacro = \chappager \global\let\pchapsepmacro=\chapbreak \global\let\pagealignmacro=\chappager} \def\CHAPPAGon{% \global\let\contentsalignmacro = \chappager \global\let\pchapsepmacro=\chappager \global\let\pagealignmacro=\chappager \global\def\HEADINGSon{\HEADINGSsingle}} \def\CHAPPAGodd{% \global\let\contentsalignmacro = \chapoddpage \global\let\pchapsepmacro=\chapoddpage \global\let\pagealignmacro=\chapoddpage \global\def\HEADINGSon{\HEADINGSdouble}} \CHAPPAGon % Chapter opening. % % #1 is the text, #2 is the section type (Ynumbered, Ynothing, % Yappendix, Yomitfromtoc), #3 the chapter number. % % To test against our argument. \def\Ynothingkeyword{Ynothing} \def\Yomitfromtockeyword{Yomitfromtoc} \def\Yappendixkeyword{Yappendix} % \def\chapmacro#1#2#3{% % Insert the first mark before the heading break (see notes for \domark). \let\prevchapterdefs=\lastchapterdefs \let\prevsectiondefs=\lastsectiondefs \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}% \gdef\thissection{}}% % \def\temptype{#2}% \ifx\temptype\Ynothingkeyword \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% \gdef\thischapter{\thischaptername}}% \else\ifx\temptype\Yomitfromtockeyword \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% \gdef\thischapter{}}% \else\ifx\temptype\Yappendixkeyword \toks0={#1}% \xdef\lastchapterdefs{% \gdef\noexpand\thischaptername{\the\toks0}% \gdef\noexpand\thischapternum{\appendixletter}% % \noexpand\putwordAppendix avoids expanding indigestible % commands in some of the translations. \gdef\noexpand\thischapter{\noexpand\putwordAppendix{} \noexpand\thischapternum: \noexpand\thischaptername}% }% \else \toks0={#1}% \xdef\lastchapterdefs{% \gdef\noexpand\thischaptername{\the\toks0}% \gdef\noexpand\thischapternum{\the\chapno}% % \noexpand\putwordChapter avoids expanding indigestible % commands in some of the translations. \gdef\noexpand\thischapter{\noexpand\putwordChapter{} \noexpand\thischapternum: \noexpand\thischaptername}% }% \fi\fi\fi % % Output the mark. Pass it through \safewhatsit, to take care of % the preceding space. \safewhatsit\domark % % Insert the chapter heading break. \pchapsepmacro % % Now the second mark, after the heading break. No break points % between here and the heading. \let\prevchapterdefs=\lastchapterdefs \let\prevsectiondefs=\lastsectiondefs \domark % {% \chapfonts \rmisbold % % Have to define \lastsection before calling \donoderef, because the % xref code eventually uses it. On the other hand, it has to be called % after \pchapsepmacro, or the headline will change too soon. \gdef\lastsection{#1}% % % Only insert the separating space if we have a chapter/appendix % number, and don't print the unnumbered ``number''. \ifx\temptype\Ynothingkeyword \setbox0 = \hbox{}% \def\toctype{unnchap}% \else\ifx\temptype\Yomitfromtockeyword \setbox0 = \hbox{}% contents like unnumbered, but no toc entry \def\toctype{omit}% \else\ifx\temptype\Yappendixkeyword \setbox0 = \hbox{\putwordAppendix{} #3\enspace}% \def\toctype{app}% \else \setbox0 = \hbox{#3\enspace}% \def\toctype{numchap}% \fi\fi\fi % % Write the toc entry for this chapter. Must come before the % \donoderef, because we include the current node name in the toc % entry, and \donoderef resets it to empty. \writetocentry{\toctype}{#1}{#3}% % % For pdftex, we have to write out the node definition (aka, make % the pdfdest) after any page break, but before the actual text has % been typeset. If the destination for the pdf outline is after the % text, then jumping from the outline may wind up with the text not % being visible, for instance under high magnification. \donoderef{#2}% % % Typeset the actual heading. \nobreak % Avoid page breaks at the interline glue. \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright \hangindent=\wd0 \centerparametersmaybe \unhbox0 #1\par}% }% \nobreak\bigskip % no page break after a chapter title \nobreak } % @centerchap -- centered and unnumbered. \let\centerparametersmaybe = \relax \def\centerparameters{% \advance\rightskip by 3\rightskip \leftskip = \rightskip \parfillskip = 0pt } % I don't think this chapter style is supported any more, so I'm not % updating it with the new noderef stuff. We'll see. --karl, 11aug03. % \def\setchapterstyle #1 {\csname CHAPF#1\endcsname} % \def\unnchfopen #1{% \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\ptexraggedright \rmisbold #1\hfill}}\bigskip \par\nobreak } \def\chfopen #1#2{\chapoddpage {\chapfonts \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% \par\penalty 5000 % } \def\centerchfopen #1{% \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt \hfill {\rmisbold #1}\hfill}}\bigskip \par\nobreak } \def\CHAPFopen{% \global\let\chapmacro=\chfopen \global\let\centerchapmacro=\centerchfopen} % Section titles. These macros combine the section number parts and % call the generic \sectionheading to do the printing. % \newskip\secheadingskip \def\secheadingbreak{\dobreak \secheadingskip{-1000}} % Subsection titles. \newskip\subsecheadingskip \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}} % Subsubsection titles. \def\subsubsecheadingskip{\subsecheadingskip} \def\subsubsecheadingbreak{\subsecheadingbreak} % Print any size, any type, section title. % % #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is % the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the % section number. % \def\seckeyword{sec} % \def\sectionheading#1#2#3#4{% {% % Switch to the right set of fonts. \csname #2fonts\endcsname \rmisbold % \def\sectionlevel{#2}% \def\temptype{#3}% % % Insert first mark before the heading break (see notes for \domark). \let\prevsectiondefs=\lastsectiondefs \ifx\temptype\Ynothingkeyword \ifx\sectionlevel\seckeyword \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}% \gdef\thissection{\thissectionname}}% \fi \else\ifx\temptype\Yomitfromtockeyword % Don't redefine \thissection. \else\ifx\temptype\Yappendixkeyword \ifx\sectionlevel\seckeyword \toks0={#1}% \xdef\lastsectiondefs{% \gdef\noexpand\thissectionname{\the\toks0}% \gdef\noexpand\thissectionnum{#4}% % \noexpand\putwordSection avoids expanding indigestible % commands in some of the translations. \gdef\noexpand\thissection{\noexpand\putwordSection{} \noexpand\thissectionnum: \noexpand\thissectionname}% }% \fi \else \ifx\sectionlevel\seckeyword \toks0={#1}% \xdef\lastsectiondefs{% \gdef\noexpand\thissectionname{\the\toks0}% \gdef\noexpand\thissectionnum{#4}% % \noexpand\putwordSection avoids expanding indigestible % commands in some of the translations. \gdef\noexpand\thissection{\noexpand\putwordSection{} \noexpand\thissectionnum: \noexpand\thissectionname}% }% \fi \fi\fi\fi % % Go into vertical mode. Usually we'll already be there, but we % don't want the following whatsit to end up in a preceding paragraph % if the document didn't happen to have a blank line. \par % % Output the mark. Pass it through \safewhatsit, to take care of % the preceding space. \safewhatsit\domark % % Insert space above the heading. \csname #2headingbreak\endcsname % % Now the second mark, after the heading break. No break points % between here and the heading. \let\prevsectiondefs=\lastsectiondefs \domark % % Only insert the space after the number if we have a section number. \ifx\temptype\Ynothingkeyword \setbox0 = \hbox{}% \def\toctype{unn}% \gdef\lastsection{#1}% \else\ifx\temptype\Yomitfromtockeyword % for @headings -- no section number, don't include in toc, % and don't redefine \lastsection. \setbox0 = \hbox{}% \def\toctype{omit}% \let\sectionlevel=\empty \else\ifx\temptype\Yappendixkeyword \setbox0 = \hbox{#4\enspace}% \def\toctype{app}% \gdef\lastsection{#1}% \else \setbox0 = \hbox{#4\enspace}% \def\toctype{num}% \gdef\lastsection{#1}% \fi\fi\fi % % Write the toc entry (before \donoderef). See comments in \chapmacro. \writetocentry{\toctype\sectionlevel}{#1}{#4}% % % Write the node reference (= pdf destination for pdftex). % Again, see comments in \chapmacro. \donoderef{#3}% % % Interline glue will be inserted when the vbox is completed. % That glue will be a valid breakpoint for the page, since it'll be % preceded by a whatsit (usually from the \donoderef, or from the % \writetocentry if there was no node). We don't want to allow that % break, since then the whatsits could end up on page n while the % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000. \nobreak % % Output the actual section heading. \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright \hangindent=\wd0 % zero if no section number \unhbox0 #1}% }% % Add extra space after the heading -- half of whatever came above it. % Don't allow stretch, though. \kern .5 \csname #2headingskip\endcsname % % Do not let the kern be a potential breakpoint, as it would be if it % was followed by glue. \nobreak % % We'll almost certainly start a paragraph next, so don't let that % glue accumulate. (Not a breakpoint because it's preceded by a % discardable item.) \vskip-\parskip % % This is purely so the last item on the list is a known \penalty > % 10000. This is so \startdefun can avoid allowing breakpoints after % section headings. Otherwise, it would insert a valid breakpoint between: % % @section sec-whatever % @deffn def-whatever \penalty 10001 } \message{toc,} % Table of contents. \newwrite\tocfile % Write an entry to the toc file, opening it if necessary. % Called from @chapter, etc. % % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno} % We append the current node name (if any) and page number as additional % arguments for the \{chap,sec,...}entry macros which will eventually % read this. The node name is used in the pdf outlines as the % destination to jump to. % % We open the .toc file for writing here instead of at @setfilename (or % any other fixed time) so that @contents can be anywhere in the document. % But if #1 is `omit', then we don't do anything. This is used for the % table of contents chapter openings themselves. % \newif\iftocfileopened \def\omitkeyword{omit}% % \def\writetocentry#1#2#3{% \edef\writetoctype{#1}% \ifx\writetoctype\omitkeyword \else \iftocfileopened\else \immediate\openout\tocfile = \jobname.toc \global\tocfileopenedtrue \fi % \iflinks {\atdummies \edef\temp{% \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}% \temp }% \fi \fi % % Tell \shipout to create a pdf destination on each page, if we're % writing pdf. These are used in the table of contents. We can't % just write one on every page because the title pages are numbered % 1 and 2 (the page numbers aren't printed), and so are the first % two pages of the document. Thus, we'd have two destinations named % `1', and two named `2'. \ifpdf \global\pdfmakepagedesttrue \fi } % These characters do not print properly in the Computer Modern roman % fonts, so we must take special care. This is more or less redundant % with the Texinfo input format setup at the end of this file. % \def\activecatcodes{% \catcode`\"=\active \catcode`\$=\active \catcode`\<=\active \catcode`\>=\active \catcode`\\=\active \catcode`\^=\active \catcode`\_=\active \catcode`\|=\active \catcode`\~=\active } % Read the toc file, which is essentially Texinfo input. \def\readtocfile{% \setupdatafile \activecatcodes \input \tocreadfilename } \newskip\contentsrightmargin \contentsrightmargin=1in \newcount\savepageno \newcount\lastnegativepageno \lastnegativepageno = -1 % Prepare to read what we've written to \tocfile. % \def\startcontents#1{% % If @setchapternewpage on, and @headings double, the contents should % start on an odd page, unlike chapters. Thus, we maintain % \contentsalignmacro in parallel with \pagealignmacro. % From: Torbjorn Granlund \contentsalignmacro \immediate\closeout\tocfile % % Don't need to put `Contents' or `Short Contents' in the headline. % It is abundantly clear what they are. \chapmacro{#1}{Yomitfromtoc}{}% % \savepageno = \pageno \begingroup % Set up to handle contents files properly. \raggedbottom % Worry more about breakpoints than the bottom. \advance\hsize by -\contentsrightmargin % Don't use the full line length. % % Roman numerals for page numbers. \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi } % redefined for the two-volume lispref. We always output on % \jobname.toc even if this is redefined. % \def\tocreadfilename{\jobname.toc} % Normal (long) toc. % \def\contents{% \startcontents{\putwordTOC}% \openin 1 \tocreadfilename\space \ifeof 1 \else \readtocfile \fi \vfill \eject \contentsalignmacro % in case @setchapternewpage odd is in effect \ifeof 1 \else \pdfmakeoutlines \fi \closein 1 \endgroup \lastnegativepageno = \pageno \global\pageno = \savepageno } % And just the chapters. \def\summarycontents{% \startcontents{\putwordShortTOC}% % \let\numchapentry = \shortchapentry \let\appentry = \shortchapentry \let\unnchapentry = \shortunnchapentry % We want a true roman here for the page numbers. \secfonts \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl \let\tt=\shortconttt \rm \hyphenpenalty = 10000 \advance\baselineskip by 1pt % Open it up a little. \def\numsecentry##1##2##3##4{} \let\appsecentry = \numsecentry \let\unnsecentry = \numsecentry \let\numsubsecentry = \numsecentry \let\appsubsecentry = \numsecentry \let\unnsubsecentry = \numsecentry \let\numsubsubsecentry = \numsecentry \let\appsubsubsecentry = \numsecentry \let\unnsubsubsecentry = \numsecentry \openin 1 \tocreadfilename\space \ifeof 1 \else \readtocfile \fi \closein 1 \vfill \eject \contentsalignmacro % in case @setchapternewpage odd is in effect \endgroup \lastnegativepageno = \pageno \global\pageno = \savepageno } \let\shortcontents = \summarycontents % Typeset the label for a chapter or appendix for the short contents. % The arg is, e.g., `A' for an appendix, or `3' for a chapter. % \def\shortchaplabel#1{% % This space should be enough, since a single number is .5em, and the % widest letter (M) is 1em, at least in the Computer Modern fonts. % But use \hss just in case. % (This space doesn't include the extra space that gets added after % the label; that gets put in by \shortchapentry above.) % % We'd like to right-justify chapter numbers, but that looks strange % with appendix letters. And right-justifying numbers and % left-justifying letters looks strange when there is less than 10 % chapters. Have to read the whole toc once to know how many chapters % there are before deciding ... \hbox to 1em{#1\hss}% } % These macros generate individual entries in the table of contents. % The first argument is the chapter or section name. % The last argument is the page number. % The arguments in between are the chapter number, section number, ... % Chapters, in the main contents. \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} % % Chapters, in the short toc. % See comments in \dochapentry re vbox and related settings. \def\shortchapentry#1#2#3#4{% \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}% } % Appendices, in the main contents. % Need the word Appendix, and a fixed-size box. % \def\appendixbox#1{% % We use M since it's probably the widest letter. \setbox0 = \hbox{\putwordAppendix{} M}% \hbox to \wd0{\putwordAppendix{} #1\hss}} % \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}} % Unnumbered chapters. \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}} % Sections. \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}} \let\appsecentry=\numsecentry \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}} % Subsections. \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}} \let\appsubsecentry=\numsubsecentry \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} % And subsubsections. \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}} \let\appsubsubsecentry=\numsubsubsecentry \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}} % This parameter controls the indentation of the various levels. % Same as \defaultparindent. \newdimen\tocindent \tocindent = 15pt % Now for the actual typesetting. In all these, #1 is the text and #2 is the % page number. % % If the toc has to be broken over pages, we want it to be at chapters % if at all possible; hence the \penalty. \def\dochapentry#1#2{% \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip \begingroup \chapentryfonts \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup \nobreak\vskip .25\baselineskip plus.1\baselineskip } \def\dosecentry#1#2{\begingroup \secentryfonts \leftskip=\tocindent \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup} \def\dosubsecentry#1#2{\begingroup \subsecentryfonts \leftskip=2\tocindent \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup} \def\dosubsubsecentry#1#2{\begingroup \subsubsecentryfonts \leftskip=3\tocindent \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup} % We use the same \entry macro as for the index entries. \let\tocentry = \entry % Space between chapter (or whatever) number and the title. \def\labelspace{\hskip1em \relax} \def\dopageno#1{{\rm #1}} \def\doshortpageno#1{{\rm #1}} \def\chapentryfonts{\secfonts \rm} \def\secentryfonts{\textfonts} \def\subsecentryfonts{\textfonts} \def\subsubsecentryfonts{\textfonts} \message{environments,} % @foo ... @end foo. % @tex ... @end tex escapes into raw Tex temporarily. % One exception: @ is still an escape character, so that @end tex works. % But \@ or @@ will get a plain tex @ character. \envdef\tex{% \setupmarkupstyle{tex}% \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie \catcode `\%=14 \catcode `\+=\other \catcode `\"=\other \catcode `\|=\other \catcode `\<=\other \catcode `\>=\other \catcode`\`=\other \catcode`\'=\other \escapechar=`\\ % \let\b=\ptexb \let\bullet=\ptexbullet \let\c=\ptexc \let\,=\ptexcomma \let\.=\ptexdot \let\dots=\ptexdots \let\equiv=\ptexequiv \let\!=\ptexexclam \let\i=\ptexi \let\indent=\ptexindent \let\noindent=\ptexnoindent \let\{=\ptexlbrace \let\+=\tabalign \let\}=\ptexrbrace \let\/=\ptexslash \let\*=\ptexstar \let\t=\ptext \expandafter \let\csname top\endcsname=\ptextop % outer \let\frenchspacing=\plainfrenchspacing % \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% \def\@{@}% } % There is no need to define \Etex. % Define @lisp ... @end lisp. % @lisp environment forms a group so it can rebind things, % including the definition of @end lisp (which normally is erroneous). % Amount to narrow the margins by for @lisp. \newskip\lispnarrowing \lispnarrowing=0.4in % This is the definition that ^^M gets inside @lisp, @example, and other % such environments. \null is better than a space, since it doesn't % have any width. \def\lisppar{\null\endgraf} % This space is always present above and below environments. \newskip\envskipamount \envskipamount = 0pt % Make spacing and below environment symmetrical. We use \parskip here % to help in doing that, since in @example-like environments \parskip % is reset to zero; thus the \afterenvbreak inserts no space -- but the % start of the next paragraph will insert \parskip. % \def\aboveenvbreak{{% % =10000 instead of <10000 because of a special case in \itemzzz and % \sectionheading, q.v. \ifnum \lastpenalty=10000 \else \advance\envskipamount by \parskip \endgraf \ifdim\lastskip<\envskipamount \removelastskip % it's not a good place to break if the last penalty was \nobreak % or better ... \ifnum\lastpenalty<10000 \penalty-50 \fi \vskip\envskipamount \fi \fi }} \let\afterenvbreak = \aboveenvbreak % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will % also clear it, so that its embedded environments do the narrowing again. \let\nonarrowing=\relax % @cartouche ... @end cartouche: draw rectangle w/rounded corners around % environment contents. \font\circle=lcircle10 \newdimen\circthick \newdimen\cartouter\newdimen\cartinner \newskip\normbskip\newskip\normpskip\newskip\normlskip \circthick=\fontdimen8\circle % \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth \def\ctr{{\hskip 6pt\circle\char'010}} \def\cbl{{\circle\char'012\hskip -6pt}} \def\cbr{{\hskip 6pt\circle\char'011}} \def\carttop{\hbox to \cartouter{\hskip\lskip \ctl\leaders\hrule height\circthick\hfil\ctr \hskip\rskip}} \def\cartbot{\hbox to \cartouter{\hskip\lskip \cbl\leaders\hrule height\circthick\hfil\cbr \hskip\rskip}} % \newskip\lskip\newskip\rskip \envdef\cartouche{% \ifhmode\par\fi % can't be in the midst of a paragraph. \startsavinginserts \lskip=\leftskip \rskip=\rightskip \leftskip=0pt\rightskip=0pt % we want these *outside*. \cartinner=\hsize \advance\cartinner by-\lskip \advance\cartinner by-\rskip \cartouter=\hsize \advance\cartouter by 18.4pt % allow for 3pt kerns on either % side, and for 6pt waste from % each corner char, and rule thickness \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip % Flag to tell @lisp, etc., not to narrow margin. \let\nonarrowing = t% \vbox\bgroup \baselineskip=0pt\parskip=0pt\lineskip=0pt \carttop \hbox\bgroup \hskip\lskip \vrule\kern3pt \vbox\bgroup \kern3pt \hsize=\cartinner \baselineskip=\normbskip \lineskip=\normlskip \parskip=\normpskip \vskip -\parskip \comment % For explanation, see the end of \def\group. } \def\Ecartouche{% \ifhmode\par\fi \kern3pt \egroup \kern3pt\vrule \hskip\rskip \egroup \cartbot \egroup \checkinserts } % This macro is called at the beginning of all the @example variants, % inside a group. \newdimen\nonfillparindent \def\nonfillstart{% \aboveenvbreak \hfuzz = 12pt % Don't be fussy \sepspaces % Make spaces be word-separators rather than space tokens. \let\par = \lisppar % don't ignore blank lines \obeylines % each line of input is a line of output \parskip = 0pt % Turn off paragraph indentation but redefine \indent to emulate % the normal \indent. \nonfillparindent=\parindent \parindent = 0pt \let\indent\nonfillindent % \emergencystretch = 0pt % don't try to avoid overfull boxes \ifx\nonarrowing\relax \advance \leftskip by \lispnarrowing \exdentamount=\lispnarrowing \else \let\nonarrowing = \relax \fi \let\exdent=\nofillexdent } \begingroup \obeyspaces % We want to swallow spaces (but not other tokens) after the fake % @indent in our nonfill-environments, where spaces are normally % active and set to @tie, resulting in them not being ignored after % @indent. \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}% \gdef\nonfillindentcheck{% \ifx\temp % \expandafter\nonfillindentgobble% \else% \leavevmode\nonfillindentbox% \fi% }% \endgroup \def\nonfillindentgobble#1{\nonfillindent} \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}} % If you want all examples etc. small: @set dispenvsize small. % If you want even small examples the full size: @set dispenvsize nosmall. % This affects the following displayed environments: % @example, @display, @format, @lisp % \def\smallword{small} \def\nosmallword{nosmall} \let\SETdispenvsize\relax \def\setnormaldispenv{% \ifx\SETdispenvsize\smallword % end paragraph for sake of leading, in case document has no blank % line. This is redundant with what happens in \aboveenvbreak, but % we need to do it before changing the fonts, and it's inconvenient % to change the fonts afterward. \ifnum \lastpenalty=10000 \else \endgraf \fi \smallexamplefonts \rm \fi } \def\setsmalldispenv{% \ifx\SETdispenvsize\nosmallword \else \ifnum \lastpenalty=10000 \else \endgraf \fi \smallexamplefonts \rm \fi } % We often define two environments, @foo and @smallfoo. % Let's do it by one command: \def\makedispenv #1#2{ \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2} \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2} \expandafter\let\csname E#1\endcsname \afterenvbreak \expandafter\let\csname Esmall#1\endcsname \afterenvbreak } % Define two synonyms: \def\maketwodispenvs #1#2#3{ \makedispenv{#1}{#3} \makedispenv{#2}{#3} } % @lisp: indented, narrowed, typewriter font; @example: same as @lisp. % % @smallexample and @smalllisp: use smaller fonts. % Originally contributed by Pavel@xerox. % \maketwodispenvs {lisp}{example}{% \nonfillstart \tt\setupmarkupstyle{example}% \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. \gobble % eat return } % @display/@smalldisplay: same as @lisp except keep current font. % \makedispenv {display}{% \nonfillstart \gobble } % @format/@smallformat: same as @display except don't narrow margins. % \makedispenv{format}{% \let\nonarrowing = t% \nonfillstart \gobble } % @flushleft: same as @format, but doesn't obey \SETdispenvsize. \envdef\flushleft{% \let\nonarrowing = t% \nonfillstart \gobble } \let\Eflushleft = \afterenvbreak % @flushright. % \envdef\flushright{% \let\nonarrowing = t% \nonfillstart \advance\leftskip by 0pt plus 1fill \gobble } \let\Eflushright = \afterenvbreak % @raggedright does more-or-less normal line breaking but no right % justification. From plain.tex. \envdef\raggedright{% \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax } \let\Eraggedright\par \envdef\raggedleft{% \parindent=0pt \leftskip0pt plus2em \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt \hbadness=10000 % Last line will usually be underfull, so turn off % badness reporting. } \let\Eraggedleft\par \envdef\raggedcenter{% \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt \hbadness=10000 % Last line will usually be underfull, so turn off % badness reporting. } \let\Eraggedcenter\par % @quotation does normal linebreaking (hence we can't use \nonfillstart) % and narrows the margins. We keep \parskip nonzero in general, since % we're doing normal filling. So, when using \aboveenvbreak and % \afterenvbreak, temporarily make \parskip 0. % \def\quotationstart{% {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip \parindent=0pt % % @cartouche defines \nonarrowing to inhibit narrowing at next level down. \ifx\nonarrowing\relax \advance\leftskip by \lispnarrowing \advance\rightskip by \lispnarrowing \exdentamount = \lispnarrowing \else \let\nonarrowing = \relax \fi \parsearg\quotationlabel } \envdef\quotation{% \setnormaldispenv \quotationstart } \envdef\smallquotation{% \setsmalldispenv \quotationstart } \let\Esmallquotation = \Equotation % We have retained a nonzero parskip for the environment, since we're % doing normal filling. % \def\Equotation{% \par \ifx\quotationauthor\undefined\else % indent a bit. \leftline{\kern 2\leftskip \sl ---\quotationauthor}% \fi {\parskip=0pt \afterenvbreak}% } % If we're given an argument, typeset it in bold with a colon after. \def\quotationlabel#1{% \def\temp{#1}% \ifx\temp\empty \else {\bf #1: }% \fi } % LaTeX-like @verbatim...@end verbatim and @verb{...} % If we want to allow any as delimiter, % we need the curly braces so that makeinfo sees the @verb command, eg: % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org % % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. % % [Knuth] p.344; only we need to do the other characters Texinfo sets % active too. Otherwise, they get lost as the first character on a % verbatim line. \def\dospecials{% \do\ \do\\\do\{\do\}\do\$\do\&% \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% \do\<\do\>\do\|\do\@\do+\do\"% % Don't do the quotes -- if we do, @set txicodequoteundirected and % @set txicodequotebacktick will not have effect on @verb and % @verbatim, and ?` and !` ligatures won't get disabled. %\do\`\do\'% } % % [Knuth] p. 380 \def\uncatcodespecials{% \def\do##1{\catcode`##1=\other}\dospecials} % % Setup for the @verb command. % % Eight spaces for a tab \begingroup \catcode`\^^I=\active \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }} \endgroup % \def\setupverb{% \tt % easiest (and conventionally used) font for verbatim \def\par{\leavevmode\endgraf}% \setupmarkupstyle{verb}% \tabeightspaces % Respect line breaks, % print special symbols as themselves, and % make each space count % must do in this order: \obeylines \uncatcodespecials \sepspaces } % Setup for the @verbatim environment % % Real tab expansion \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount % \def\starttabbox{\setbox0=\hbox\bgroup} % \begingroup \catcode`\^^I=\active \gdef\tabexpand{% \catcode`\^^I=\active \def^^I{\leavevmode\egroup \dimen0=\wd0 % the width so far, or since the previous tab \divide\dimen0 by\tabw \multiply\dimen0 by\tabw % compute previous multiple of \tabw \advance\dimen0 by\tabw % advance to next multiple of \tabw \wd0=\dimen0 \box0 \starttabbox }% } \endgroup % start the verbatim environment. \def\setupverbatim{% \let\nonarrowing = t% \nonfillstart % Easiest (and conventionally used) font for verbatim \tt \def\par{\leavevmode\egroup\box0\endgraf}% \tabexpand \setupmarkupstyle{verbatim}% % Respect line breaks, % print special symbols as themselves, and % make each space count % must do in this order: \obeylines \uncatcodespecials \sepspaces \everypar{\starttabbox}% } % Do the @verb magic: verbatim text is quoted by unique % delimiter characters. Before first delimiter expect a % right brace, after last delimiter expect closing brace: % % \def\doverb'{'#1'}'{#1} % % [Knuth] p. 382; only eat outer {} \begingroup \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] \endgroup % \def\verb{\begingroup\setupverb\doverb} % % % Do the @verbatim magic: define the macro \doverbatim so that % the (first) argument ends when '@end verbatim' is reached, ie: % % \def\doverbatim#1@end verbatim{#1} % % For Texinfo it's a lot easier than for LaTeX, % because texinfo's \verbatim doesn't stop at '\end{verbatim}': % we need not redefine '\', '{' and '}'. % % Inspired by LaTeX's verbatim command set [latex.ltx] % \begingroup \catcode`\ =\active \obeylines % % ignore everything up to the first ^^M, that's the newline at the end % of the @verbatim input line itself. Otherwise we get an extra blank % line in the output. \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}% % We really want {...\end verbatim} in the body of the macro, but % without the active space; thus we have to use \xdef and \gobble. \endgroup % \envdef\verbatim{% \setupverbatim\doverbatim } \let\Everbatim = \afterenvbreak % @verbatiminclude FILE - insert text of file in verbatim environment. % \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude} % \def\doverbatiminclude#1{% {% \makevalueexpandable \setupverbatim \indexnofonts % Allow `@@' and other weird things in file names. \input #1 \afterenvbreak }% } % @copying ... @end copying. % Save the text away for @insertcopying later. % % We save the uninterpreted tokens, rather than creating a box. % Saving the text in a box would be much easier, but then all the % typesetting commands (@smallbook, font changes, etc.) have to be done % beforehand -- and a) we want @copying to be done first in the source % file; b) letting users define the frontmatter in as flexible order as % possible is very desirable. % \def\copying{\checkenv{}\begingroup\scanargctxt\docopying} \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}} % \def\insertcopying{% \begingroup \parindent = 0pt % paragraph indentation looks wrong on title page \scanexp\copyingtext \endgroup } \message{defuns,} % @defun etc. \newskip\defbodyindent \defbodyindent=.4in \newskip\defargsindent \defargsindent=50pt \newskip\deflastargmargin \deflastargmargin=18pt \newcount\defunpenalty % Start the processing of @deffn: \def\startdefun{% \ifnum\lastpenalty<10000 \medbreak \defunpenalty=10003 % Will keep this @deffn together with the % following @def command, see below. \else % If there are two @def commands in a row, we'll have a \nobreak, % which is there to keep the function description together with its % header. But if there's nothing but headers, we need to allow a % break somewhere. Check specifically for penalty 10002, inserted % by \printdefunline, instead of 10000, since the sectioning % commands also insert a nobreak penalty, and we don't want to allow % a break between a section heading and a defun. % % As a minor refinement, we avoid "club" headers by signalling % with penalty of 10003 after the very first @deffn in the % sequence (see above), and penalty of 10002 after any following % @def command. \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi % % Similarly, after a section heading, do not allow a break. % But do insert the glue. \medskip % preceded by discardable penalty, so not a breakpoint \fi % \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent } \def\dodefunx#1{% % First, check whether we are in the right environment: \checkenv#1% % % As above, allow line break if we have multiple x headers in a row. % It's not a great place, though. \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi % % And now, it's time to reuse the body of the original defun: \expandafter\gobbledefun#1% } \def\gobbledefun#1\startdefun{} % \printdefunline \deffnheader{text} % \def\printdefunline#1#2{% \begingroup % call \deffnheader: #1#2 \endheader % common ending: \interlinepenalty = 10000 \advance\rightskip by 0pt plus 1fil \endgraf \nobreak\vskip -\parskip \penalty\defunpenalty % signal to \startdefun and \dodefunx % Some of the @defun-type tags do not enable magic parentheses, % rendering the following check redundant. But we don't optimize. \checkparencounts \endgroup } \def\Edefun{\endgraf\medbreak} % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; % the only thing remaining is to define \deffnheader. % \def\makedefun#1{% \expandafter\let\csname E#1\endcsname = \Edefun \edef\temp{\noexpand\domakedefun \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}% \temp } % \domakedefun \deffn \deffnx \deffnheader % % Define \deffn and \deffnx, without parameters. % \deffnheader has to be defined explicitly. % \def\domakedefun#1#2#3{% \envdef#1{% \startdefun \parseargusing\activeparens{\printdefunline#3}% }% \def#2{\dodefunx#1}% \def#3% } %%% Untyped functions: % @deffn category name args \makedefun{deffn}{\deffngeneral{}} % @deffn category class name args \makedefun{defop}#1 {\defopon{#1\ \putwordon}} % \defopon {category on}class name args \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } % \deffngeneral {subind}category name args % \def\deffngeneral#1#2 #3 #4\endheader{% % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}. \dosubind{fn}{\code{#3}}{#1}% \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% } %%% Typed functions: % @deftypefn category type name args \makedefun{deftypefn}{\deftypefngeneral{}} % @deftypeop category class type name args \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}} % \deftypeopon {category on}class type name args \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } % \deftypefngeneral {subind}category type name args % \def\deftypefngeneral#1#2 #3 #4 #5\endheader{% \dosubind{fn}{\code{#4}}{#1}% \defname{#2}{#3}{#4}\defunargs{#5\unskip}% } %%% Typed variables: % @deftypevr category type var args \makedefun{deftypevr}{\deftypecvgeneral{}} % @deftypecv category class type var args \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}} % \deftypecvof {category of}class type var args \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} } % \deftypecvgeneral {subind}category type var args % \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{% \dosubind{vr}{\code{#4}}{#1}% \defname{#2}{#3}{#4}\defunargs{#5\unskip}% } %%% Untyped variables: % @defvr category var args \makedefun{defvr}#1 {\deftypevrheader{#1} {} } % @defcv category class var args \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}} % \defcvof {category of}class var args \def\defcvof#1#2 {\deftypecvof{#1}#2 {} } %%% Type: % @deftp category name args \makedefun{deftp}#1 #2 #3\endheader{% \doind{tp}{\code{#2}}% \defname{#1}{}{#2}\defunargs{#3\unskip}% } % Remaining @defun-like shortcuts: \makedefun{defun}{\deffnheader{\putwordDeffunc} } \makedefun{defmac}{\deffnheader{\putwordDefmac} } \makedefun{defspec}{\deffnheader{\putwordDefspec} } \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} } \makedefun{defvar}{\defvrheader{\putwordDefvar} } \makedefun{defopt}{\defvrheader{\putwordDefopt} } \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} } \makedefun{defmethod}{\defopon\putwordMethodon} \makedefun{deftypemethod}{\deftypeopon\putwordMethodon} \makedefun{defivar}{\defcvof\putwordInstanceVariableof} \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof} % \defname, which formats the name of the @def (not the args). % #1 is the category, such as "Function". % #2 is the return type, if any. % #3 is the function name. % % We are followed by (but not passed) the arguments, if any. % \def\defname#1#2#3{% % Get the values of \leftskip and \rightskip as they were outside the @def... \advance\leftskip by -\defbodyindent % % How we'll format the type name. Putting it in brackets helps % distinguish it from the body text that may end up on the next line % just below it. \def\temp{#1}% \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} % % Figure out line sizes for the paragraph shape. % The first line needs space for \box0; but if \rightskip is nonzero, % we need only space for the part of \box0 which exceeds it: \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip % The continuations: \dimen2=\hsize \advance\dimen2 by -\defargsindent % (plain.tex says that \dimen1 should be used only as global.) \parshape 2 0in \dimen0 \defargsindent \dimen2 % % Put the type name to the right margin. \noindent \hbox to 0pt{% \hfil\box0 \kern-\hsize % \hsize has to be shortened this way: \kern\leftskip % Intentionally do not respect \rightskip, since we need the space. }% % % Allow all lines to be underfull without complaint: \tolerance=10000 \hbadness=10000 \exdentamount=\defbodyindent {% % defun fonts. We use typewriter by default (used to be bold) because: % . we're printing identifiers, they should be in tt in principle. % . in languages with many accents, such as Czech or French, it's % common to leave accents off identifiers. The result looks ok in % tt, but exceedingly strange in rm. % . we don't want -- and --- to be treated as ligatures. % . this still does not fix the ?` and !` ligatures, but so far no % one has made identifiers using them :). \df \tt \def\temp{#2}% return value type \ifx\temp\empty\else \tclose{\temp} \fi #3% output function name }% {\rm\enskip}% hskip 0.5 em of \tenrm % \boldbrax % arguments will be output next, if any. } % Print arguments in slanted roman (not ttsl), inconsistently with using % tt for the name. This is because literal text is sometimes needed in % the argument list (groff manual), and ttsl and tt are not very % distinguishable. Prevent hyphenation at `-' chars. % \def\defunargs#1{% % use sl by default (not ttsl), % tt for the names. \df \sl \hyphenchar\font=0 % % On the other hand, if an argument has two dashes (for instance), we % want a way to get ttsl. Let's try @var for that. \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}% #1% \sl\hyphenchar\font=45 } % We want ()&[] to print specially on the defun line. % \def\activeparens{% \catcode`\(=\active \catcode`\)=\active \catcode`\[=\active \catcode`\]=\active \catcode`\&=\active } % Make control sequences which act like normal parenthesis chars. \let\lparen = ( \let\rparen = ) % Be sure that we always have a definition for `(', etc. For example, % if the fn name has parens in it, \boldbrax will not be in effect yet, % so TeX would otherwise complain about undefined control sequence. { \activeparens \global\let(=\lparen \global\let)=\rparen \global\let[=\lbrack \global\let]=\rbrack \global\let& = \& \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} \gdef\magicamp{\let&=\amprm} } \newcount\parencount % If we encounter &foo, then turn on ()-hacking afterwards \newif\ifampseen \def\amprm#1 {\ampseentrue{\bf\ }} \def\parenfont{% \ifampseen % At the first level, print parens in roman, % otherwise use the default font. \ifnum \parencount=1 \rm \fi \else % The \sf parens (in \boldbrax) actually are a little bolder than % the contained text. This is especially needed for [ and ] . \sf \fi } \def\infirstlevel#1{% \ifampseen \ifnum\parencount=1 #1% \fi \fi } \def\bfafterword#1 {#1 \bf} \def\opnr{% \global\advance\parencount by 1 {\parenfont(}% \infirstlevel \bfafterword } \def\clnr{% {\parenfont)}% \infirstlevel \sl \global\advance\parencount by -1 } \newcount\brackcount \def\lbrb{% \global\advance\brackcount by 1 {\bf[}% } \def\rbrb{% {\bf]}% \global\advance\brackcount by -1 } \def\checkparencounts{% \ifnum\parencount=0 \else \badparencount \fi \ifnum\brackcount=0 \else \badbrackcount \fi } % these should not use \errmessage; the glibc manual, at least, actually % has such constructs (when documenting function pointers). \def\badparencount{% \message{Warning: unbalanced parentheses in @def...}% \global\parencount=0 } \def\badbrackcount{% \message{Warning: unbalanced square brackets in @def...}% \global\brackcount=0 } \message{macros,} % @macro. % To do this right we need a feature of e-TeX, \scantokens, % which we arrange to emulate with a temporary file in ordinary TeX. \ifx\eTeXversion\undefined \newwrite\macscribble \def\scantokens#1{% \toks0={#1}% \immediate\openout\macscribble=\jobname.tmp \immediate\write\macscribble{\the\toks0}% \immediate\closeout\macscribble \input \jobname.tmp } \fi \def\scanmacro#1{% \begingroup \newlinechar`\^^M \let\xeatspaces\eatspaces % Undo catcode changes of \startcontents and \doprintindex % When called from @insertcopying or (short)caption, we need active % backslash to get it printed correctly. Previously, we had % \catcode`\\=\other instead. We'll see whether a problem appears % with macro expansion. --kasal, 19aug04 \catcode`\@=0 \catcode`\\=\active \escapechar=`\@ % ... and \example \spaceisspace % % Append \endinput to make sure that TeX does not see the ending newline. % I've verified that it is necessary both for e-TeX and for ordinary TeX % --kasal, 29nov03 \scantokens{#1\endinput}% \endgroup } \def\scanexp#1{% \edef\temp{\noexpand\scanmacro{#1}}% \temp } \newcount\paramno % Count of parameters \newtoks\macname % Macro name \newif\ifrecursive % Is it recursive? % List of all defined macros in the form % \definedummyword\macro1\definedummyword\macro2... % Currently is also contains all @aliases; the list can be split % if there is a need. \def\macrolist{} % Add the macro to \macrolist \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname} \def\addtomacrolistxxx#1{% \toks0 = \expandafter{\macrolist\definedummyword#1}% \xdef\macrolist{\the\toks0}% } % Utility routines. % This does \let #1 = #2, with \csnames; that is, % \let \csname#1\endcsname = \csname#2\endcsname % (except of course we have to play expansion games). % \def\cslet#1#2{% \expandafter\let \csname#1\expandafter\endcsname \csname#2\endcsname } % Trim leading and trailing spaces off a string. % Concepts from aro-bend problem 15 (see CTAN). {\catcode`\@=11 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} \def\unbrace#1{#1} \unbrace{\gdef\trim@@@ #1 } #2@{#1} } % Trim a single trailing ^^M off a string. {\catcode`\^^M=\other \catcode`\Q=3% \gdef\eatcr #1{\eatcra #1Q^^MQ}% \gdef\eatcra#1^^MQ{\eatcrb#1Q}% \gdef\eatcrb#1Q#2Q{#1}% } % Macro bodies are absorbed as an argument in a context where % all characters are catcode 10, 11 or 12, except \ which is active % (as in normal texinfo). It is necessary to change the definition of \. % Non-ASCII encodings make 8-bit characters active, so un-activate % them to avoid their expansion. Must do this non-globally, to % confine the change to the current group. % It's necessary to have hard CRs when the macro is executed. This is % done by making ^^M (\endlinechar) catcode 12 when reading the macro % body, and then making it the \newlinechar in \scanmacro. \def\scanctxt{% \catcode`\"=\other \catcode`\+=\other \catcode`\<=\other \catcode`\>=\other \catcode`\@=\other \catcode`\^=\other \catcode`\_=\other \catcode`\|=\other \catcode`\~=\other \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi } \def\scanargctxt{% \scanctxt \catcode`\\=\other \catcode`\^^M=\other } \def\macrobodyctxt{% \scanctxt \catcode`\{=\other \catcode`\}=\other \catcode`\^^M=\other \usembodybackslash } \def\macroargctxt{% \scanctxt \catcode`\\=\other } % \mbodybackslash is the definition of \ in @macro bodies. % It maps \foo\ => \csname macarg.foo\endcsname => #N % where N is the macro parameter number. % We define \csname macarg.\endcsname to be \realbackslash, so % \\ in macro replacement text gets you a backslash. {\catcode`@=0 @catcode`@\=@active @gdef@usembodybackslash{@let\=@mbodybackslash} @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} } \expandafter\def\csname macarg.\endcsname{\realbackslash} \def\macro{\recursivefalse\parsearg\macroxxx} \def\rmacro{\recursivetrue\parsearg\macroxxx} \def\macroxxx#1{% \getargs{#1}% now \macname is the macname and \argl the arglist \ifx\argl\empty % no arguments \paramno=0% \else \expandafter\parsemargdef \argl;% \fi \if1\csname ismacro.\the\macname\endcsname \message{Warning: redefining \the\macname}% \else \expandafter\ifx\csname \the\macname\endcsname \relax \else \errmessage{Macro name \the\macname\space already defined}\fi \global\cslet{macsave.\the\macname}{\the\macname}% \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% \addtomacrolist{\the\macname}% \fi \begingroup \macrobodyctxt \ifrecursive \expandafter\parsermacbody \else \expandafter\parsemacbody \fi} \parseargdef\unmacro{% \if1\csname ismacro.#1\endcsname \global\cslet{#1}{macsave.#1}% \global\expandafter\let \csname ismacro.#1\endcsname=0% % Remove the macro name from \macrolist: \begingroup \expandafter\let\csname#1\endcsname \relax \let\definedummyword\unmacrodo \xdef\macrolist{\macrolist}% \endgroup \else \errmessage{Macro #1 not defined}% \fi } % Called by \do from \dounmacro on each macro. The idea is to omit any % macro definitions that have been changed to \relax. % \def\unmacrodo#1{% \ifx #1\relax % remove this \else \noexpand\definedummyword \noexpand#1% \fi } % This makes use of the obscure feature that if the last token of a % is #, then the preceding argument is delimited by % an opening brace, and that opening brace is not consumed. \def\getargs#1{\getargsxxx#1{}} \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} \def\getmacname #1 #2\relax{\macname={#1}} \def\getmacargs#1{\def\argl{#1}} % Parse the optional {params} list. Set up \paramno and \paramlist % so \defmacro knows what to do. Define \macarg.blah for each blah % in the params list, to be ##N where N is the position in that list. % That gets used by \mbodybackslash (above). % We need to get `macro parameter char #' into several definitions. % The technique used is stolen from LaTeX: let \hash be something % unexpandable, insert that wherever you need a #, and then redefine % it to # just before using the token list produced. % % The same technique is used to protect \eatspaces till just before % the macro is used. \def\parsemargdef#1;{\paramno=0\def\paramlist{}% \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,} \def\parsemargdefxxx#1,{% \if#1;\let\next=\relax \else \let\next=\parsemargdefxxx \advance\paramno by 1% \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname {\xeatspaces{\hash\the\paramno}}% \edef\paramlist{\paramlist\hash\the\paramno,}% \fi\next} % These two commands read recursive and nonrecursive macro bodies. % (They're different since rec and nonrec macros end differently.) \long\def\parsemacbody#1@end macro% {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% \long\def\parsermacbody#1@end rmacro% {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% % This defines the macro itself. There are six cases: recursive and % nonrecursive macros of zero, one, and many arguments. % Much magic with \expandafter here. % \xdef is used so that macro definitions will survive the file % they're defined in; @include reads the file inside a group. \def\defmacro{% \let\hash=##% convert placeholders to macro parameter chars \ifrecursive \ifcase\paramno % 0 \expandafter\xdef\csname\the\macname\endcsname{% \noexpand\scanmacro{\temp}}% \or % 1 \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\braceorline \expandafter\noexpand\csname\the\macname xxx\endcsname}% \expandafter\xdef\csname\the\macname xxx\endcsname##1{% \egroup\noexpand\scanmacro{\temp}}% \else % many \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\csname\the\macname xx\endcsname}% \expandafter\xdef\csname\the\macname xx\endcsname##1{% \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% \expandafter\expandafter \expandafter\xdef \expandafter\expandafter \csname\the\macname xxx\endcsname \paramlist{\egroup\noexpand\scanmacro{\temp}}% \fi \else \ifcase\paramno % 0 \expandafter\xdef\csname\the\macname\endcsname{% \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \or % 1 \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\braceorline \expandafter\noexpand\csname\the\macname xxx\endcsname}% \expandafter\xdef\csname\the\macname xxx\endcsname##1{% \egroup \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \else % many \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \expandafter\noexpand\csname\the\macname xx\endcsname}% \expandafter\xdef\csname\the\macname xx\endcsname##1{% \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% \expandafter\expandafter \expandafter\xdef \expandafter\expandafter \csname\the\macname xxx\endcsname \paramlist{% \egroup \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \fi \fi} \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} % \braceorline decides whether the next nonwhitespace character is a % {. If so it reads up to the closing }, if not, it reads the whole % line. Whatever was read is then fed to the next control sequence % as an argument (by \parsebrace or \parsearg) \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx} \def\braceorlinexxx{% \ifx\nchar\bgroup\else \expandafter\parsearg \fi \macnamexxx} % @alias. % We need some trickery to remove the optional spaces around the equal % sign. Just make them active and then expand them all to nothing. \def\alias{\parseargusing\obeyspaces\aliasxxx} \def\aliasxxx #1{\aliasyyy#1\relax} \def\aliasyyy #1=#2\relax{% {% \expandafter\let\obeyedspace=\empty \addtomacrolist{#1}% \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}% }% \next } \message{cross references,} \newwrite\auxfile \newif\ifhavexrefs % True if xref values are known. \newif\ifwarnedxrefs % True if we warned once that they aren't known. % @inforef is relatively simple. \def\inforef #1{\inforefzzz #1,,,,**} \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, node \samp{\ignorespaces#1{}}} % @node's only job in TeX is to define \lastnode, which is used in % cross-references. The @node line might or might not have commas, and % might or might not have spaces before the first comma, like: % @node foo , bar , ... % We don't want such trailing spaces in the node name. % \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse} % % also remove a trailing comma, in case of something like this: % @node Help-Cross, , , Cross-refs \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}} \let\nwnode=\node \let\lastnode=\empty % Write a cross-reference definition for the current node. #1 is the % type (Ynumbered, Yappendix, Ynothing). % \def\donoderef#1{% \ifx\lastnode\empty\else \setref{\lastnode}{#1}% \global\let\lastnode=\empty \fi } % @anchor{NAME} -- define xref target at arbitrary point. % \newcount\savesfregister % \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an % anchor), which consists of three parts: % 1) NAME-title - the current sectioning name taken from \lastsection, % or the anchor name. % 2) NAME-snt - section number and type, passed as the SNT arg, or % empty for anchors. % 3) NAME-pg - the page number. % % This is called from \donoderef, \anchor, and \dofloat. In the case of % floats, there is an additional part, which is not written here: % 4) NAME-lof - the text as it should appear in a @listoffloats. % \def\setref#1#2{% \pdfmkdest{#1}% \iflinks {% \atdummies % preserve commands, but don't expand them \edef\writexrdef##1##2{% \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef ##1}{##2}}% these are parameters of \writexrdef }% \toks0 = \expandafter{\lastsection}% \immediate \writexrdef{title}{\the\toks0 }% \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, during \shipout }% \fi } % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is % the node name, #2 the name of the Info cross-reference, #3 the printed % node name, #4 the name of the Info file, #5 the name of the printed % manual. All but the node name can be omitted. % \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} \def\ref#1{\xrefX[#1,,,,,,,]} \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup \unsepspaces \def\printedmanual{\ignorespaces #5}% \def\printedrefname{\ignorespaces #3}% \setbox1=\hbox{\printedmanual\unskip}% \setbox0=\hbox{\printedrefname\unskip}% \ifdim \wd0 = 0pt % No printed node name was explicitly given. \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax % Use the node name inside the square brackets. \def\printedrefname{\ignorespaces #1}% \else % Use the actual chapter/section title appear inside % the square brackets. Use the real section title if we have it. \ifdim \wd1 > 0pt % It is in another manual, so we don't have it. \def\printedrefname{\ignorespaces #1}% \else \ifhavexrefs % We know the real title if we have the xref values. \def\printedrefname{\refx{#1-title}{}}% \else % Otherwise just copy the Info node name. \def\printedrefname{\ignorespaces #1}% \fi% \fi \fi \fi % % Make link in pdf output. \ifpdf {\indexnofonts \turnoffactive % This expands tokens, so do it after making catcode changes, so _ % etc. don't get their TeX definitions. \getfilename{#4}% % % See comments at \activebackslashdouble. {\activebackslashdouble \xdef\pdfxrefdest{#1}% \backslashparens\pdfxrefdest}% % \leavevmode \startlink attr{/Border [0 0 0]}% \ifnum\filenamelength>0 goto file{\the\filename.pdf} name{\pdfxrefdest}% \else goto name{\pdfmkpgn{\pdfxrefdest}}% \fi }% \setcolor{\linkcolor}% \fi % % Float references are printed completely differently: "Figure 1.2" % instead of "[somenode], p.3". We distinguish them by the % LABEL-title being set to a magic string. {% % Have to otherify everything special to allow the \csname to % include an _ in the xref name, etc. \indexnofonts \turnoffactive \expandafter\global\expandafter\let\expandafter\Xthisreftitle \csname XR#1-title\endcsname }% \iffloat\Xthisreftitle % If the user specified the print name (third arg) to the ref, % print it instead of our usual "Figure 1.2". \ifdim\wd0 = 0pt \refx{#1-snt}{}% \else \printedrefname \fi % % if the user also gave the printed manual name (fifth arg), append % "in MANUALNAME". \ifdim \wd1 > 0pt \space \putwordin{} \cite{\printedmanual}% \fi \else % node/anchor (non-float) references. % % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not % insert empty discretionaries after hyphens, which means that it will % not find a line break at a hyphen in a node names. Since some manuals % are best written with fairly long node names, containing hyphens, this % is a loss. Therefore, we give the text of the node name again, so it % is as if TeX is seeing it for the first time. \ifdim \wd1 > 0pt \putwordSection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}% \else % _ (for example) has to be the character _ for the purposes of the % control sequence corresponding to the node, but it has to expand % into the usual \leavevmode...\vrule stuff for purposes of % printing. So we \turnoffactive for the \refx-snt, back on for the % printing, back off for the \refx-pg. {\turnoffactive % Only output a following space if the -snt ref is nonempty; for % @unnumbered and @anchor, it won't be. \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi }% % output the `[mynode]' via a macro so it can be overridden. \xrefprintnodename\printedrefname % % But we always want a comma and a space: ,\space % % output the `page 3'. \turnoffactive \putwordpage\tie\refx{#1-pg}{}% \fi \fi \endlink \endgroup} % This macro is called from \xrefX for the `[nodename]' part of xref % output. It's a separate macro only so it can be changed more easily, % since square brackets don't work well in some documents. Particularly % one that Bob is working on :). % \def\xrefprintnodename#1{[#1]} % Things referred to by \setref. % \def\Ynothing{} \def\Yomitfromtoc{} \def\Ynumbered{% \ifnum\secno=0 \putwordChapter@tie \the\chapno \else \ifnum\subsecno=0 \putwordSection@tie \the\chapno.\the\secno \else \ifnum\subsubsecno=0 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno \else \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno \fi\fi\fi } \def\Yappendix{% \ifnum\secno=0 \putwordAppendix@tie @char\the\appendixno{}% \else \ifnum\subsecno=0 \putwordSection@tie @char\the\appendixno.\the\secno \else \ifnum\subsubsecno=0 \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno \else \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno \fi\fi\fi } % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. % If its value is nonempty, SUFFIX is output afterward. % \def\refx#1#2{% {% \indexnofonts \otherbackslash \expandafter\global\expandafter\let\expandafter\thisrefX \csname XR#1\endcsname }% \ifx\thisrefX\relax % If not defined, say something at least. \angleleft un\-de\-fined\angleright \iflinks \ifhavexrefs \message{\linenumber Undefined cross reference `#1'.}% \else \ifwarnedxrefs\else \global\warnedxrefstrue \message{Cross reference values unknown; you must run TeX again.}% \fi \fi \fi \else % It's defined, so just use it. \thisrefX \fi #2% Output the suffix in any case. } % This is the macro invoked by entries in the aux file. Usually it's % just a \def (we prepend XR to the control sequence name to avoid % collisions). But if this is a float type, we have more work to do. % \def\xrdef#1#2{% {% The node name might contain 8-bit characters, which in our current % implementation are changed to commands like @'e. Don't let these % mess up the control sequence name. \indexnofonts \turnoffactive \xdef\safexrefname{#1}% }% % \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref % % Was that xref control sequence that we just defined for a float? \expandafter\iffloat\csname XR\safexrefname\endcsname % it was a float, and we have the (safe) float type in \iffloattype. \expandafter\let\expandafter\floatlist \csname floatlist\iffloattype\endcsname % % Is this the first time we've seen this float type? \expandafter\ifx\floatlist\relax \toks0 = {\do}% yes, so just \do \else % had it before, so preserve previous elements in list. \toks0 = \expandafter{\floatlist\do}% \fi % % Remember this xref in the control sequence \floatlistFLOATTYPE, % for later use in \listoffloats. \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0 {\safexrefname}}% \fi } % Read the last existing aux file, if any. No error if none exists. % \def\tryauxfile{% \openin 1 \jobname.aux \ifeof 1 \else \readdatafile{aux}% \global\havexrefstrue \fi \closein 1 } \def\setupdatafile{% \catcode`\^^@=\other \catcode`\^^A=\other \catcode`\^^B=\other \catcode`\^^C=\other \catcode`\^^D=\other \catcode`\^^E=\other \catcode`\^^F=\other \catcode`\^^G=\other \catcode`\^^H=\other \catcode`\^^K=\other \catcode`\^^L=\other \catcode`\^^N=\other \catcode`\^^P=\other \catcode`\^^Q=\other \catcode`\^^R=\other \catcode`\^^S=\other \catcode`\^^T=\other \catcode`\^^U=\other \catcode`\^^V=\other \catcode`\^^W=\other \catcode`\^^X=\other \catcode`\^^Z=\other \catcode`\^^[=\other \catcode`\^^\=\other \catcode`\^^]=\other \catcode`\^^^=\other \catcode`\^^_=\other % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. % in xref tags, i.e., node names. But since ^^e4 notation isn't % supported in the main text, it doesn't seem desirable. Furthermore, % that is not enough: for node names that actually contain a ^ % character, we would end up writing a line like this: 'xrdef {'hat % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first % argument, and \hat is not an expandable control sequence. It could % all be worked out, but why? Either we support ^^ or we don't. % % The other change necessary for this was to define \auxhat: % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter % and then to call \auxhat in \setq. % \catcode`\^=\other % % Special characters. Should be turned off anyway, but... \catcode`\~=\other \catcode`\[=\other \catcode`\]=\other \catcode`\"=\other \catcode`\_=\other \catcode`\|=\other \catcode`\<=\other \catcode`\>=\other \catcode`\$=\other \catcode`\#=\other \catcode`\&=\other \catcode`\%=\other \catcode`+=\other % avoid \+ for paranoia even though we've turned it off % % This is to support \ in node names and titles, since the \ % characters end up in a \csname. It's easier than % leaving it active and making its active definition an actual \ % character. What I don't understand is why it works in the *value* % of the xrdef. Seems like it should be a catcode12 \, and that % should not typeset properly. But it works, so I'm moving on for % now. --karl, 15jan04. \catcode`\\=\other % % Make the characters 128-255 be printing characters. {% \count1=128 \def\loop{% \catcode\count1=\other \advance\count1 by 1 \ifnum \count1<256 \loop \fi }% }% % % @ is our escape character in .aux files, and we need braces. \catcode`\{=1 \catcode`\}=2 \catcode`\@=0 } \def\readdatafile#1{% \begingroup \setupdatafile \input\jobname.#1 \endgroup} \message{insertions,} % including footnotes. \newcount \footnoteno % The trailing space in the following definition for supereject is % vital for proper filling; pages come out unaligned when you do a % pagealignmacro call if that space before the closing brace is % removed. (Generally, numeric constants should always be followed by a % space to prevent strange expansion errors.) \def\supereject{\par\penalty -20000\footnoteno =0 } % @footnotestyle is meaningful for info output only. \let\footnotestyle=\comment {\catcode `\@=11 % % Auto-number footnotes. Otherwise like plain. \gdef\footnote{% \let\indent=\ptexindent \let\noindent=\ptexnoindent \global\advance\footnoteno by \@ne \edef\thisfootno{$^{\the\footnoteno}$}% % % In case the footnote comes at the end of a sentence, preserve the % extra spacing after we do the footnote number. \let\@sf\empty \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi % % Remove inadvertent blank space before typesetting the footnote number. \unskip \thisfootno\@sf \dofootnote }% % Don't bother with the trickery in plain.tex to not require the % footnote text as a parameter. Our footnotes don't need to be so general. % % Oh yes, they do; otherwise, @ifset (and anything else that uses % \parseargline) fails inside footnotes because the tokens are fixed when % the footnote is read. --karl, 16nov96. % \gdef\dofootnote{% \insert\footins\bgroup % We want to typeset this text as a normal paragraph, even if the % footnote reference occurs in (for example) a display environment. % So reset some parameters. \hsize=\pagewidth \interlinepenalty\interfootnotelinepenalty \splittopskip\ht\strutbox % top baseline for broken footnotes \splitmaxdepth\dp\strutbox \floatingpenalty\@MM \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip \parindent\defaultparindent % \smallfonts \rm % % Because we use hanging indentation in footnotes, a @noindent appears % to exdent this text, so make it be a no-op. makeinfo does not use % hanging indentation so @noindent can still be needed within footnote % text after an @example or the like (not that this is good style). \let\noindent = \relax % % Hang the footnote text off the number. Use \everypar in case the % footnote extends for more than one paragraph. \everypar = {\hang}% \textindent{\thisfootno}% % % Don't crash into the line above the footnote text. Since this % expands into a box, it must come within the paragraph, lest it % provide a place where TeX can split the footnote. \footstrut \futurelet\next\fo@t } }%end \catcode `\@=11 % In case a @footnote appears in a vbox, save the footnote text and create % the real \insert just after the vbox finished. Otherwise, the insertion % would be lost. % Similarly, if a @footnote appears inside an alignment, save the footnote % text to a box and make the \insert when a row of the table is finished. % And the same can be done for other insert classes. --kasal, 16nov03. % Replace the \insert primitive by a cheating macro. % Deeper inside, just make sure that the saved insertions are not spilled % out prematurely. % \def\startsavinginserts{% \ifx \insert\ptexinsert \let\insert\saveinsert \else \let\checkinserts\relax \fi } % This \insert replacement works for both \insert\footins{foo} and % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}. % \def\saveinsert#1{% \edef\next{\noexpand\savetobox \makeSAVEname#1}% \afterassignment\next % swallow the left brace \let\temp = } \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}} \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1} \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi} \def\placesaveins#1{% \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname {\box#1}% } % eat @SAVE -- beware, all of them have catcode \other: { \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-) \gdef\gobblesave @SAVE{} } % initialization: \def\newsaveins #1{% \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}% \next } \def\newsaveinsX #1{% \csname newbox\endcsname #1% \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts \checksaveins #1}% } % initialize: \let\checkinserts\empty \newsaveins\footins \newsaveins\margin % @image. We use the macros from epsf.tex to support this. % If epsf.tex is not installed and @image is used, we complain. % % Check for and read epsf.tex up front. If we read it only at @image % time, we might be inside a group, and then its definitions would get % undone and the next image would fail. \openin 1 = epsf.tex \ifeof 1 \else % Do not bother showing banner with epsf.tex v2.7k (available in % doc/epsf.tex and on ctan). \def\epsfannounce{\toks0 = }% \input epsf.tex \fi \closein 1 % % We will only complain once about lack of epsf.tex. \newif\ifwarnednoepsf \newhelp\noepsfhelp{epsf.tex must be installed for images to work. It is also included in the Texinfo distribution, or you can get it from ftp://tug.org/tex/epsf.tex.} % \def\image#1{% \ifx\epsfbox\undefined \ifwarnednoepsf \else \errhelp = \noepsfhelp \errmessage{epsf.tex not found, images will be ignored}% \global\warnednoepsftrue \fi \else \imagexxx #1,,,,,\finish \fi } % % Arguments to @image: % #1 is (mandatory) image filename; we tack on .eps extension. % #2 is (optional) width, #3 is (optional) height. % #4 is (ignored optional) html alt text. % #5 is (ignored optional) extension. % #6 is just the usual extra ignored arg for parsing this stuff. \newif\ifimagevmode \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup \catcode`\^^M = 5 % in case we're inside an example \normalturnoffactive % allow _ et al. in names % If the image is by itself, center it. \ifvmode \imagevmodetrue \nobreak\medskip % Usually we'll have text after the image which will insert % \parskip glue, so insert it here too to equalize the space % above and below. \nobreak\vskip\parskip \nobreak \fi % % Leave vertical mode so that indentation from an enclosing % environment such as @quotation is respected. On the other hand, if % it's at the top level, we don't want the normal paragraph indentation. \noindent % % Output the image. \ifpdf \dopdfimage{#1}{#2}{#3}% \else % \epsfbox itself resets \epsf?size at each figure. \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi \epsfbox{#1.eps}% \fi % \ifimagevmode \medskip \fi % space after the standalone image \endgroup} % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables, % etc. We don't actually implement floating yet, we always include the % float "here". But it seemed the best name for the future. % \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish} % There may be a space before second and/or third parameter; delete it. \def\eatcommaspace#1, {#1,} % #1 is the optional FLOATTYPE, the text label for this float, typically % "Figure", "Table", "Example", etc. Can't contain commas. If omitted, % this float will not be numbered and cannot be referred to. % % #2 is the optional xref label. Also must be present for the float to % be referable. % % #3 is the optional positioning argument; for now, it is ignored. It % will somehow specify the positions allowed to float to (here, top, bottom). % % We keep a separate counter for each FLOATTYPE, which we reset at each % chapter-level command. \let\resetallfloatnos=\empty % \def\dofloat#1,#2,#3,#4\finish{% \let\thiscaption=\empty \let\thisshortcaption=\empty % % don't lose footnotes inside @float. % % BEWARE: when the floats start float, we have to issue warning whenever an % insert appears inside a float which could possibly float. --kasal, 26may04 % \startsavinginserts % % We can't be used inside a paragraph. \par % \vtop\bgroup \def\floattype{#1}% \def\floatlabel{#2}% \def\floatloc{#3}% we do nothing with this yet. % \ifx\floattype\empty \let\safefloattype=\empty \else {% % the floattype might have accents or other special characters, % but we need to use it in a control sequence name. \indexnofonts \turnoffactive \xdef\safefloattype{\floattype}% }% \fi % % If label is given but no type, we handle that as the empty type. \ifx\floatlabel\empty \else % We want each FLOATTYPE to be numbered separately (Figure 1, % Table 1, Figure 2, ...). (And if no label, no number.) % \expandafter\getfloatno\csname\safefloattype floatno\endcsname \global\advance\floatno by 1 % {% % This magic value for \lastsection is output by \setref as the % XREFLABEL-title value. \xrefX uses it to distinguish float % labels (which have a completely different output format) from % node and anchor labels. And \xrdef uses it to construct the % lists of floats. % \edef\lastsection{\floatmagic=\safefloattype}% \setref{\floatlabel}{Yfloat}% }% \fi % % start with \parskip glue, I guess. \vskip\parskip % % Don't suppress indentation if a float happens to start a section. \restorefirstparagraphindent } % we have these possibilities: % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap % @float Foo,lbl & no caption: Foo 1.1 % @float Foo & @caption{Cap}: Foo: Cap % @float Foo & no caption: Foo % @float ,lbl & Caption{Cap}: 1.1: Cap % @float ,lbl & no caption: 1.1 % @float & @caption{Cap}: Cap % @float & no caption: % \def\Efloat{% \let\floatident = \empty % % In all cases, if we have a float type, it comes first. \ifx\floattype\empty \else \def\floatident{\floattype}\fi % % If we have an xref label, the number comes next. \ifx\floatlabel\empty \else \ifx\floattype\empty \else % if also had float type, need tie first. \appendtomacro\floatident{\tie}% \fi % the number. \appendtomacro\floatident{\chaplevelprefix\the\floatno}% \fi % % Start the printed caption with what we've constructed in % \floatident, but keep it separate; we need \floatident again. \let\captionline = \floatident % \ifx\thiscaption\empty \else \ifx\floatident\empty \else \appendtomacro\captionline{: }% had ident, so need a colon between \fi % % caption text. \appendtomacro\captionline{\scanexp\thiscaption}% \fi % % If we have anything to print, print it, with space before. % Eventually this needs to become an \insert. \ifx\captionline\empty \else \vskip.5\parskip \captionline % % Space below caption. \vskip\parskip \fi % % If have an xref label, write the list of floats info. Do this % after the caption, to avoid chance of it being a breakpoint. \ifx\floatlabel\empty \else % Write the text that goes in the lof to the aux file as % \floatlabel-lof. Besides \floatident, we include the short % caption if specified, else the full caption if specified, else nothing. {% \atdummies % % since we read the caption text in the macro world, where ^^M % is turned into a normal character, we have to scan it back, so % we don't write the literal three characters "^^M" into the aux file. \scanexp{% \xdef\noexpand\gtemp{% \ifx\thisshortcaption\empty \thiscaption \else \thisshortcaption \fi }% }% \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident \ifx\gtemp\empty \else : \gtemp \fi}}% }% \fi \egroup % end of \vtop % % place the captured inserts % % BEWARE: when the floats start floating, we have to issue warning % whenever an insert appears inside a float which could possibly % float. --kasal, 26may04 % \checkinserts } % Append the tokens #2 to the definition of macro #1, not expanding either. % \def\appendtomacro#1#2{% \expandafter\def\expandafter#1\expandafter{#1#2}% } % @caption, @shortcaption % \def\caption{\docaption\thiscaption} \def\shortcaption{\docaption\thisshortcaption} \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption} \def\defcaption#1#2{\egroup \def#1{#2}} % The parameter is the control sequence identifying the counter we are % going to use. Create it if it doesn't exist and assign it to \floatno. \def\getfloatno#1{% \ifx#1\relax % Haven't seen this figure type before. \csname newcount\endcsname #1% % % Remember to reset this floatno at the next chap. \expandafter\gdef\expandafter\resetallfloatnos \expandafter{\resetallfloatnos #1=0 }% \fi \let\floatno#1% } % \setref calls this to get the XREFLABEL-snt value. We want an @xref % to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we % first read the @float command. % \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}% % Magic string used for the XREFLABEL-title value, so \xrefX can % distinguish floats from other xref types. \def\floatmagic{!!float!!} % #1 is the control sequence we are passed; we expand into a conditional % which is true if #1 represents a float ref. That is, the magic % \lastsection value which we \setref above. % \def\iffloat#1{\expandafter\doiffloat#1==\finish} % % #1 is (maybe) the \floatmagic string. If so, #2 will be the % (safe) float type for this float. We set \iffloattype to #2. % \def\doiffloat#1=#2=#3\finish{% \def\temp{#1}% \def\iffloattype{#2}% \ifx\temp\floatmagic } % @listoffloats FLOATTYPE - print a list of floats like a table of contents. % \parseargdef\listoffloats{% \def\floattype{#1}% floattype {% % the floattype might have accents or other special characters, % but we need to use it in a control sequence name. \indexnofonts \turnoffactive \xdef\safefloattype{\floattype}% }% % % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE. \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax \ifhavexrefs % if the user said @listoffloats foo but never @float foo. \message{\linenumber No `\safefloattype' floats to list.}% \fi \else \begingroup \leftskip=\tocindent % indent these entries like a toc \let\do=\listoffloatsdo \csname floatlist\safefloattype\endcsname \endgroup \fi } % This is called on each entry in a list of floats. We're passed the % xref label, in the form LABEL-title, which is how we save it in the % aux file. We strip off the -title and look up \XRLABEL-lof, which % has the text we're supposed to typeset here. % % Figures without xref labels will not be included in the list (since % they won't appear in the aux file). % \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish} \def\listoffloatsdoentry#1-title\finish{{% % Can't fully expand XR#1-lof because it can contain anything. Just % pass the control sequence. On the other hand, XR#1-pg is just the % page number, and we want to fully expand that so we can get a link % in pdf output. \toksA = \expandafter{\csname XR#1-lof\endcsname}% % % use the same \entry macro we use to generate the TOC and index. \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}% \writeentry }} \message{localization,} % For single-language documents, @documentlanguage is usually given very % early, just after @documentencoding. Single argument is the language % (de) or locale (de_DE) abbreviation. % { \catcode`\_ = \active \globaldefs=1 \parseargdef\documentlanguage{\begingroup \let_=\normalunderscore % normal _ character for filenames \tex % read txi-??.tex file in plain TeX. % Read the file by the name they passed if it exists. \openin 1 txi-#1.tex \ifeof 1 \documentlanguagetrywithoutunderscore{#1_\finish}% \else \globaldefs = 1 % everything in the txi-LL files needs to persist \input txi-#1.tex \fi \closein 1 \endgroup % end raw TeX \endgroup} % % If they passed de_DE, and txi-de_DE.tex doesn't exist, % try txi-de.tex. % \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{% \openin 1 txi-#1.tex \ifeof 1 \errhelp = \nolanghelp \errmessage{Cannot read language file txi-#1.tex}% \else \globaldefs = 1 % everything in the txi-LL files needs to persist \input txi-#1.tex \fi \closein 1 } }% end of special _ catcode % \newhelp\nolanghelp{The given language definition file cannot be found or is empty. Maybe you need to install it? Putting it in the current directory should work if nowhere else does.} % This macro is called from txi-??.tex files; the first argument is the % \language name to set (without the "\lang@" prefix), the second and % third args are \{left,right}hyphenmin. % % The language names to pass are determined when the format is built. % See the etex.log file created at that time, e.g., % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log. % % With TeX Live 2008, etex now includes hyphenation patterns for all % available languages. This means we can support hyphenation in % Texinfo, at least to some extent. (This still doesn't solve the % accented characters problem.) % \catcode`@=11 \def\txisetlanguage#1#2#3{% % do not set the language if the name is undefined in the current TeX. \expandafter\ifx\csname lang@#1\endcsname \relax \message{no patterns for #1}% \else \global\language = \csname lang@#1\endcsname \fi % but there is no harm in adjusting the hyphenmin values regardless. \global\lefthyphenmin = #2\relax \global\righthyphenmin = #3\relax } % Helpers for encodings. % Set the catcode of characters 128 through 255 to the specified number. % \def\setnonasciicharscatcode#1{% \count255=128 \loop\ifnum\count255<256 \global\catcode\count255=#1\relax \advance\count255 by 1 \repeat } \def\setnonasciicharscatcodenonglobal#1{% \count255=128 \loop\ifnum\count255<256 \catcode\count255=#1\relax \advance\count255 by 1 \repeat } % @documentencoding sets the definition of non-ASCII characters % according to the specified encoding. % \parseargdef\documentencoding{% % Encoding being declared for the document. \def\declaredencoding{\csname #1.enc\endcsname}% % % Supported encodings: names converted to tokens in order to be able % to compare them with \ifx. \def\ascii{\csname US-ASCII.enc\endcsname}% \def\latnine{\csname ISO-8859-15.enc\endcsname}% \def\latone{\csname ISO-8859-1.enc\endcsname}% \def\lattwo{\csname ISO-8859-2.enc\endcsname}% \def\utfeight{\csname UTF-8.enc\endcsname}% % \ifx \declaredencoding \ascii \asciichardefs % \else \ifx \declaredencoding \lattwo \setnonasciicharscatcode\active \lattwochardefs % \else \ifx \declaredencoding \latone \setnonasciicharscatcode\active \latonechardefs % \else \ifx \declaredencoding \latnine \setnonasciicharscatcode\active \latninechardefs % \else \ifx \declaredencoding \utfeight \setnonasciicharscatcode\active \utfeightchardefs % \else \message{Unknown document encoding #1, ignoring.}% % \fi % utfeight \fi % latnine \fi % latone \fi % lattwo \fi % ascii } % A message to be logged when using a character that isn't available % the default font encoding (OT1). % \def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}} % Take account of \c (plain) vs. \, (Texinfo) difference. \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi} % First, make active non-ASCII characters in order for them to be % correctly categorized when TeX reads the replacement text of % macros containing the character definitions. \setnonasciicharscatcode\active % % Latin1 (ISO-8859-1) character definitions. \def\latonechardefs{% \gdef^^a0{~} \gdef^^a1{\exclamdown} \gdef^^a2{\missingcharmsg{CENT SIGN}} \gdef^^a3{{\pounds}} \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} \gdef^^a5{\missingcharmsg{YEN SIGN}} \gdef^^a6{\missingcharmsg{BROKEN BAR}} \gdef^^a7{\S} \gdef^^a8{\"{}} \gdef^^a9{\copyright} \gdef^^aa{\ordf} \gdef^^ab{\guillemetleft} \gdef^^ac{$\lnot$} \gdef^^ad{\-} \gdef^^ae{\registeredsymbol} \gdef^^af{\={}} % \gdef^^b0{\textdegree} \gdef^^b1{$\pm$} \gdef^^b2{$^2$} \gdef^^b3{$^3$} \gdef^^b4{\'{}} \gdef^^b5{$\mu$} \gdef^^b6{\P} % \gdef^^b7{$^.$} \gdef^^b8{\cedilla\ } \gdef^^b9{$^1$} \gdef^^ba{\ordm} % \gdef^^bb{\guilletright} \gdef^^bc{$1\over4$} \gdef^^bd{$1\over2$} \gdef^^be{$3\over4$} \gdef^^bf{\questiondown} % \gdef^^c0{\`A} \gdef^^c1{\'A} \gdef^^c2{\^A} \gdef^^c3{\~A} \gdef^^c4{\"A} \gdef^^c5{\ringaccent A} \gdef^^c6{\AE} \gdef^^c7{\cedilla C} \gdef^^c8{\`E} \gdef^^c9{\'E} \gdef^^ca{\^E} \gdef^^cb{\"E} \gdef^^cc{\`I} \gdef^^cd{\'I} \gdef^^ce{\^I} \gdef^^cf{\"I} % \gdef^^d0{\DH} \gdef^^d1{\~N} \gdef^^d2{\`O} \gdef^^d3{\'O} \gdef^^d4{\^O} \gdef^^d5{\~O} \gdef^^d6{\"O} \gdef^^d7{$\times$} \gdef^^d8{\O} \gdef^^d9{\`U} \gdef^^da{\'U} \gdef^^db{\^U} \gdef^^dc{\"U} \gdef^^dd{\'Y} \gdef^^de{\TH} \gdef^^df{\ss} % \gdef^^e0{\`a} \gdef^^e1{\'a} \gdef^^e2{\^a} \gdef^^e3{\~a} \gdef^^e4{\"a} \gdef^^e5{\ringaccent a} \gdef^^e6{\ae} \gdef^^e7{\cedilla c} \gdef^^e8{\`e} \gdef^^e9{\'e} \gdef^^ea{\^e} \gdef^^eb{\"e} \gdef^^ec{\`{\dotless i}} \gdef^^ed{\'{\dotless i}} \gdef^^ee{\^{\dotless i}} \gdef^^ef{\"{\dotless i}} % \gdef^^f0{\dh} \gdef^^f1{\~n} \gdef^^f2{\`o} \gdef^^f3{\'o} \gdef^^f4{\^o} \gdef^^f5{\~o} \gdef^^f6{\"o} \gdef^^f7{$\div$} \gdef^^f8{\o} \gdef^^f9{\`u} \gdef^^fa{\'u} \gdef^^fb{\^u} \gdef^^fc{\"u} \gdef^^fd{\'y} \gdef^^fe{\th} \gdef^^ff{\"y} } % Latin9 (ISO-8859-15) encoding character definitions. \def\latninechardefs{% % Encoding is almost identical to Latin1. \latonechardefs % \gdef^^a4{\euro} \gdef^^a6{\v S} \gdef^^a8{\v s} \gdef^^b4{\v Z} \gdef^^b8{\v z} \gdef^^bc{\OE} \gdef^^bd{\oe} \gdef^^be{\"Y} } % Latin2 (ISO-8859-2) character definitions. \def\lattwochardefs{% \gdef^^a0{~} \gdef^^a1{\ogonek{A}} \gdef^^a2{\u{}} \gdef^^a3{\L} \gdef^^a4{\missingcharmsg{CURRENCY SIGN}} \gdef^^a5{\v L} \gdef^^a6{\'S} \gdef^^a7{\S} \gdef^^a8{\"{}} \gdef^^a9{\v S} \gdef^^aa{\cedilla S} \gdef^^ab{\v T} \gdef^^ac{\'Z} \gdef^^ad{\-} \gdef^^ae{\v Z} \gdef^^af{\dotaccent Z} % \gdef^^b0{\textdegree} \gdef^^b1{\ogonek{a}} \gdef^^b2{\ogonek{ }} \gdef^^b3{\l} \gdef^^b4{\'{}} \gdef^^b5{\v l} \gdef^^b6{\'s} \gdef^^b7{\v{}} \gdef^^b8{\cedilla\ } \gdef^^b9{\v s} \gdef^^ba{\cedilla s} \gdef^^bb{\v t} \gdef^^bc{\'z} \gdef^^bd{\H{}} \gdef^^be{\v z} \gdef^^bf{\dotaccent z} % \gdef^^c0{\'R} \gdef^^c1{\'A} \gdef^^c2{\^A} \gdef^^c3{\u A} \gdef^^c4{\"A} \gdef^^c5{\'L} \gdef^^c6{\'C} \gdef^^c7{\cedilla C} \gdef^^c8{\v C} \gdef^^c9{\'E} \gdef^^ca{\ogonek{E}} \gdef^^cb{\"E} \gdef^^cc{\v E} \gdef^^cd{\'I} \gdef^^ce{\^I} \gdef^^cf{\v D} % \gdef^^d0{\DH} \gdef^^d1{\'N} \gdef^^d2{\v N} \gdef^^d3{\'O} \gdef^^d4{\^O} \gdef^^d5{\H O} \gdef^^d6{\"O} \gdef^^d7{$\times$} \gdef^^d8{\v R} \gdef^^d9{\ringaccent U} \gdef^^da{\'U} \gdef^^db{\H U} \gdef^^dc{\"U} \gdef^^dd{\'Y} \gdef^^de{\cedilla T} \gdef^^df{\ss} % \gdef^^e0{\'r} \gdef^^e1{\'a} \gdef^^e2{\^a} \gdef^^e3{\u a} \gdef^^e4{\"a} \gdef^^e5{\'l} \gdef^^e6{\'c} \gdef^^e7{\cedilla c} \gdef^^e8{\v c} \gdef^^e9{\'e} \gdef^^ea{\ogonek{e}} \gdef^^eb{\"e} \gdef^^ec{\v e} \gdef^^ed{\'\i} \gdef^^ee{\^\i} \gdef^^ef{\v d} % \gdef^^f0{\dh} \gdef^^f1{\'n} \gdef^^f2{\v n} \gdef^^f3{\'o} \gdef^^f4{\^o} \gdef^^f5{\H o} \gdef^^f6{\"o} \gdef^^f7{$\div$} \gdef^^f8{\v r} \gdef^^f9{\ringaccent u} \gdef^^fa{\'u} \gdef^^fb{\H u} \gdef^^fc{\"u} \gdef^^fd{\'y} \gdef^^fe{\cedilla t} \gdef^^ff{\dotaccent{}} } % UTF-8 character definitions. % % This code to support UTF-8 is based on LaTeX's utf8.def, with some % changes for Texinfo conventions. It is included here under the GPL by % permission from Frank Mittelbach and the LaTeX team. % \newcount\countUTFx \newcount\countUTFy \newcount\countUTFz \gdef\UTFviiiTwoOctets#1#2{\expandafter \UTFviiiDefined\csname u8:#1\string #2\endcsname} % \gdef\UTFviiiThreeOctets#1#2#3{\expandafter \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname} % \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname} \gdef\UTFviiiDefined#1{% \ifx #1\relax \message{\linenumber Unicode char \string #1 not defined for Texinfo}% \else \expandafter #1% \fi } \begingroup \catcode`\~13 \catcode`\"12 \def\UTFviiiLoop{% \global\catcode\countUTFx\active \uccode`\~\countUTFx \uppercase\expandafter{\UTFviiiTmp}% \advance\countUTFx by 1 \ifnum\countUTFx < \countUTFy \expandafter\UTFviiiLoop \fi} \countUTFx = "C2 \countUTFy = "E0 \def\UTFviiiTmp{% \xdef~{\noexpand\UTFviiiTwoOctets\string~}} \UTFviiiLoop \countUTFx = "E0 \countUTFy = "F0 \def\UTFviiiTmp{% \xdef~{\noexpand\UTFviiiThreeOctets\string~}} \UTFviiiLoop \countUTFx = "F0 \countUTFy = "F4 \def\UTFviiiTmp{% \xdef~{\noexpand\UTFviiiFourOctets\string~}} \UTFviiiLoop \endgroup \begingroup \catcode`\"=12 \catcode`\<=12 \catcode`\.=12 \catcode`\,=12 \catcode`\;=12 \catcode`\!=12 \catcode`\~=13 \gdef\DeclareUnicodeCharacter#1#2{% \countUTFz = "#1\relax \wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}% \begingroup \parseXMLCharref \def\UTFviiiTwoOctets##1##2{% \csname u8:##1\string ##2\endcsname}% \def\UTFviiiThreeOctets##1##2##3{% \csname u8:##1\string ##2\string ##3\endcsname}% \def\UTFviiiFourOctets##1##2##3##4{% \csname u8:##1\string ##2\string ##3\string ##4\endcsname}% \expandafter\expandafter\expandafter\expandafter \expandafter\expandafter\expandafter \gdef\UTFviiiTmp{#2}% \endgroup} \gdef\parseXMLCharref{% \ifnum\countUTFz < "A0\relax \errhelp = \EMsimple \errmessage{Cannot define Unicode char value < 00A0}% \else\ifnum\countUTFz < "800\relax \parseUTFviiiA,% \parseUTFviiiB C\UTFviiiTwoOctets.,% \else\ifnum\countUTFz < "10000\relax \parseUTFviiiA;% \parseUTFviiiA,% \parseUTFviiiB E\UTFviiiThreeOctets.{,;}% \else \parseUTFviiiA;% \parseUTFviiiA,% \parseUTFviiiA!% \parseUTFviiiB F\UTFviiiFourOctets.{!,;}% \fi\fi\fi } \gdef\parseUTFviiiA#1{% \countUTFx = \countUTFz \divide\countUTFz by 64 \countUTFy = \countUTFz \multiply\countUTFz by 64 \advance\countUTFx by -\countUTFz \advance\countUTFx by 128 \uccode `#1\countUTFx \countUTFz = \countUTFy} \gdef\parseUTFviiiB#1#2#3#4{% \advance\countUTFz by "#10\relax \uccode `#3\countUTFz \uppercase{\gdef\UTFviiiTmp{#2#3#4}}} \endgroup \def\utfeightchardefs{% \DeclareUnicodeCharacter{00A0}{\tie} \DeclareUnicodeCharacter{00A1}{\exclamdown} \DeclareUnicodeCharacter{00A3}{\pounds} \DeclareUnicodeCharacter{00A8}{\"{ }} \DeclareUnicodeCharacter{00A9}{\copyright} \DeclareUnicodeCharacter{00AA}{\ordf} \DeclareUnicodeCharacter{00AB}{\guillemetleft} \DeclareUnicodeCharacter{00AD}{\-} \DeclareUnicodeCharacter{00AE}{\registeredsymbol} \DeclareUnicodeCharacter{00AF}{\={ }} \DeclareUnicodeCharacter{00B0}{\ringaccent{ }} \DeclareUnicodeCharacter{00B4}{\'{ }} \DeclareUnicodeCharacter{00B8}{\cedilla{ }} \DeclareUnicodeCharacter{00BA}{\ordm} \DeclareUnicodeCharacter{00BB}{\guillemetright} \DeclareUnicodeCharacter{00BF}{\questiondown} \DeclareUnicodeCharacter{00C0}{\`A} \DeclareUnicodeCharacter{00C1}{\'A} \DeclareUnicodeCharacter{00C2}{\^A} \DeclareUnicodeCharacter{00C3}{\~A} \DeclareUnicodeCharacter{00C4}{\"A} \DeclareUnicodeCharacter{00C5}{\AA} \DeclareUnicodeCharacter{00C6}{\AE} \DeclareUnicodeCharacter{00C7}{\cedilla{C}} \DeclareUnicodeCharacter{00C8}{\`E} \DeclareUnicodeCharacter{00C9}{\'E} \DeclareUnicodeCharacter{00CA}{\^E} \DeclareUnicodeCharacter{00CB}{\"E} \DeclareUnicodeCharacter{00CC}{\`I} \DeclareUnicodeCharacter{00CD}{\'I} \DeclareUnicodeCharacter{00CE}{\^I} \DeclareUnicodeCharacter{00CF}{\"I} \DeclareUnicodeCharacter{00D0}{\DH} \DeclareUnicodeCharacter{00D1}{\~N} \DeclareUnicodeCharacter{00D2}{\`O} \DeclareUnicodeCharacter{00D3}{\'O} \DeclareUnicodeCharacter{00D4}{\^O} \DeclareUnicodeCharacter{00D5}{\~O} \DeclareUnicodeCharacter{00D6}{\"O} \DeclareUnicodeCharacter{00D8}{\O} \DeclareUnicodeCharacter{00D9}{\`U} \DeclareUnicodeCharacter{00DA}{\'U} \DeclareUnicodeCharacter{00DB}{\^U} \DeclareUnicodeCharacter{00DC}{\"U} \DeclareUnicodeCharacter{00DD}{\'Y} \DeclareUnicodeCharacter{00DE}{\TH} \DeclareUnicodeCharacter{00DF}{\ss} \DeclareUnicodeCharacter{00E0}{\`a} \DeclareUnicodeCharacter{00E1}{\'a} \DeclareUnicodeCharacter{00E2}{\^a} \DeclareUnicodeCharacter{00E3}{\~a} \DeclareUnicodeCharacter{00E4}{\"a} \DeclareUnicodeCharacter{00E5}{\aa} \DeclareUnicodeCharacter{00E6}{\ae} \DeclareUnicodeCharacter{00E7}{\cedilla{c}} \DeclareUnicodeCharacter{00E8}{\`e} \DeclareUnicodeCharacter{00E9}{\'e} \DeclareUnicodeCharacter{00EA}{\^e} \DeclareUnicodeCharacter{00EB}{\"e} \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}} \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}} \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}} \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}} \DeclareUnicodeCharacter{00F0}{\dh} \DeclareUnicodeCharacter{00F1}{\~n} \DeclareUnicodeCharacter{00F2}{\`o} \DeclareUnicodeCharacter{00F3}{\'o} \DeclareUnicodeCharacter{00F4}{\^o} \DeclareUnicodeCharacter{00F5}{\~o} \DeclareUnicodeCharacter{00F6}{\"o} \DeclareUnicodeCharacter{00F8}{\o} \DeclareUnicodeCharacter{00F9}{\`u} \DeclareUnicodeCharacter{00FA}{\'u} \DeclareUnicodeCharacter{00FB}{\^u} \DeclareUnicodeCharacter{00FC}{\"u} \DeclareUnicodeCharacter{00FD}{\'y} \DeclareUnicodeCharacter{00FE}{\th} \DeclareUnicodeCharacter{00FF}{\"y} \DeclareUnicodeCharacter{0100}{\=A} \DeclareUnicodeCharacter{0101}{\=a} \DeclareUnicodeCharacter{0102}{\u{A}} \DeclareUnicodeCharacter{0103}{\u{a}} \DeclareUnicodeCharacter{0104}{\ogonek{A}} \DeclareUnicodeCharacter{0105}{\ogonek{a}} \DeclareUnicodeCharacter{0106}{\'C} \DeclareUnicodeCharacter{0107}{\'c} \DeclareUnicodeCharacter{0108}{\^C} \DeclareUnicodeCharacter{0109}{\^c} \DeclareUnicodeCharacter{0118}{\ogonek{E}} \DeclareUnicodeCharacter{0119}{\ogonek{e}} \DeclareUnicodeCharacter{010A}{\dotaccent{C}} \DeclareUnicodeCharacter{010B}{\dotaccent{c}} \DeclareUnicodeCharacter{010C}{\v{C}} \DeclareUnicodeCharacter{010D}{\v{c}} \DeclareUnicodeCharacter{010E}{\v{D}} \DeclareUnicodeCharacter{0112}{\=E} \DeclareUnicodeCharacter{0113}{\=e} \DeclareUnicodeCharacter{0114}{\u{E}} \DeclareUnicodeCharacter{0115}{\u{e}} \DeclareUnicodeCharacter{0116}{\dotaccent{E}} \DeclareUnicodeCharacter{0117}{\dotaccent{e}} \DeclareUnicodeCharacter{011A}{\v{E}} \DeclareUnicodeCharacter{011B}{\v{e}} \DeclareUnicodeCharacter{011C}{\^G} \DeclareUnicodeCharacter{011D}{\^g} \DeclareUnicodeCharacter{011E}{\u{G}} \DeclareUnicodeCharacter{011F}{\u{g}} \DeclareUnicodeCharacter{0120}{\dotaccent{G}} \DeclareUnicodeCharacter{0121}{\dotaccent{g}} \DeclareUnicodeCharacter{0124}{\^H} \DeclareUnicodeCharacter{0125}{\^h} \DeclareUnicodeCharacter{0128}{\~I} \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}} \DeclareUnicodeCharacter{012A}{\=I} \DeclareUnicodeCharacter{012B}{\={\dotless{i}}} \DeclareUnicodeCharacter{012C}{\u{I}} \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}} \DeclareUnicodeCharacter{0130}{\dotaccent{I}} \DeclareUnicodeCharacter{0131}{\dotless{i}} \DeclareUnicodeCharacter{0132}{IJ} \DeclareUnicodeCharacter{0133}{ij} \DeclareUnicodeCharacter{0134}{\^J} \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}} \DeclareUnicodeCharacter{0139}{\'L} \DeclareUnicodeCharacter{013A}{\'l} \DeclareUnicodeCharacter{0141}{\L} \DeclareUnicodeCharacter{0142}{\l} \DeclareUnicodeCharacter{0143}{\'N} \DeclareUnicodeCharacter{0144}{\'n} \DeclareUnicodeCharacter{0147}{\v{N}} \DeclareUnicodeCharacter{0148}{\v{n}} \DeclareUnicodeCharacter{014C}{\=O} \DeclareUnicodeCharacter{014D}{\=o} \DeclareUnicodeCharacter{014E}{\u{O}} \DeclareUnicodeCharacter{014F}{\u{o}} \DeclareUnicodeCharacter{0150}{\H{O}} \DeclareUnicodeCharacter{0151}{\H{o}} \DeclareUnicodeCharacter{0152}{\OE} \DeclareUnicodeCharacter{0153}{\oe} \DeclareUnicodeCharacter{0154}{\'R} \DeclareUnicodeCharacter{0155}{\'r} \DeclareUnicodeCharacter{0158}{\v{R}} \DeclareUnicodeCharacter{0159}{\v{r}} \DeclareUnicodeCharacter{015A}{\'S} \DeclareUnicodeCharacter{015B}{\'s} \DeclareUnicodeCharacter{015C}{\^S} \DeclareUnicodeCharacter{015D}{\^s} \DeclareUnicodeCharacter{015E}{\cedilla{S}} \DeclareUnicodeCharacter{015F}{\cedilla{s}} \DeclareUnicodeCharacter{0160}{\v{S}} \DeclareUnicodeCharacter{0161}{\v{s}} \DeclareUnicodeCharacter{0162}{\cedilla{t}} \DeclareUnicodeCharacter{0163}{\cedilla{T}} \DeclareUnicodeCharacter{0164}{\v{T}} \DeclareUnicodeCharacter{0168}{\~U} \DeclareUnicodeCharacter{0169}{\~u} \DeclareUnicodeCharacter{016A}{\=U} \DeclareUnicodeCharacter{016B}{\=u} \DeclareUnicodeCharacter{016C}{\u{U}} \DeclareUnicodeCharacter{016D}{\u{u}} \DeclareUnicodeCharacter{016E}{\ringaccent{U}} \DeclareUnicodeCharacter{016F}{\ringaccent{u}} \DeclareUnicodeCharacter{0170}{\H{U}} \DeclareUnicodeCharacter{0171}{\H{u}} \DeclareUnicodeCharacter{0174}{\^W} \DeclareUnicodeCharacter{0175}{\^w} \DeclareUnicodeCharacter{0176}{\^Y} \DeclareUnicodeCharacter{0177}{\^y} \DeclareUnicodeCharacter{0178}{\"Y} \DeclareUnicodeCharacter{0179}{\'Z} \DeclareUnicodeCharacter{017A}{\'z} \DeclareUnicodeCharacter{017B}{\dotaccent{Z}} \DeclareUnicodeCharacter{017C}{\dotaccent{z}} \DeclareUnicodeCharacter{017D}{\v{Z}} \DeclareUnicodeCharacter{017E}{\v{z}} \DeclareUnicodeCharacter{01C4}{D\v{Z}} \DeclareUnicodeCharacter{01C5}{D\v{z}} \DeclareUnicodeCharacter{01C6}{d\v{z}} \DeclareUnicodeCharacter{01C7}{LJ} \DeclareUnicodeCharacter{01C8}{Lj} \DeclareUnicodeCharacter{01C9}{lj} \DeclareUnicodeCharacter{01CA}{NJ} \DeclareUnicodeCharacter{01CB}{Nj} \DeclareUnicodeCharacter{01CC}{nj} \DeclareUnicodeCharacter{01CD}{\v{A}} \DeclareUnicodeCharacter{01CE}{\v{a}} \DeclareUnicodeCharacter{01CF}{\v{I}} \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}} \DeclareUnicodeCharacter{01D1}{\v{O}} \DeclareUnicodeCharacter{01D2}{\v{o}} \DeclareUnicodeCharacter{01D3}{\v{U}} \DeclareUnicodeCharacter{01D4}{\v{u}} \DeclareUnicodeCharacter{01E2}{\={\AE}} \DeclareUnicodeCharacter{01E3}{\={\ae}} \DeclareUnicodeCharacter{01E6}{\v{G}} \DeclareUnicodeCharacter{01E7}{\v{g}} \DeclareUnicodeCharacter{01E8}{\v{K}} \DeclareUnicodeCharacter{01E9}{\v{k}} \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}} \DeclareUnicodeCharacter{01F1}{DZ} \DeclareUnicodeCharacter{01F2}{Dz} \DeclareUnicodeCharacter{01F3}{dz} \DeclareUnicodeCharacter{01F4}{\'G} \DeclareUnicodeCharacter{01F5}{\'g} \DeclareUnicodeCharacter{01F8}{\`N} \DeclareUnicodeCharacter{01F9}{\`n} \DeclareUnicodeCharacter{01FC}{\'{\AE}} \DeclareUnicodeCharacter{01FD}{\'{\ae}} \DeclareUnicodeCharacter{01FE}{\'{\O}} \DeclareUnicodeCharacter{01FF}{\'{\o}} \DeclareUnicodeCharacter{021E}{\v{H}} \DeclareUnicodeCharacter{021F}{\v{h}} \DeclareUnicodeCharacter{0226}{\dotaccent{A}} \DeclareUnicodeCharacter{0227}{\dotaccent{a}} \DeclareUnicodeCharacter{0228}{\cedilla{E}} \DeclareUnicodeCharacter{0229}{\cedilla{e}} \DeclareUnicodeCharacter{022E}{\dotaccent{O}} \DeclareUnicodeCharacter{022F}{\dotaccent{o}} \DeclareUnicodeCharacter{0232}{\=Y} \DeclareUnicodeCharacter{0233}{\=y} \DeclareUnicodeCharacter{0237}{\dotless{j}} \DeclareUnicodeCharacter{02DB}{\ogonek{ }} \DeclareUnicodeCharacter{1E02}{\dotaccent{B}} \DeclareUnicodeCharacter{1E03}{\dotaccent{b}} \DeclareUnicodeCharacter{1E04}{\udotaccent{B}} \DeclareUnicodeCharacter{1E05}{\udotaccent{b}} \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}} \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}} \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}} \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}} \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}} \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}} \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}} \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}} \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}} \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}} \DeclareUnicodeCharacter{1E20}{\=G} \DeclareUnicodeCharacter{1E21}{\=g} \DeclareUnicodeCharacter{1E22}{\dotaccent{H}} \DeclareUnicodeCharacter{1E23}{\dotaccent{h}} \DeclareUnicodeCharacter{1E24}{\udotaccent{H}} \DeclareUnicodeCharacter{1E25}{\udotaccent{h}} \DeclareUnicodeCharacter{1E26}{\"H} \DeclareUnicodeCharacter{1E27}{\"h} \DeclareUnicodeCharacter{1E30}{\'K} \DeclareUnicodeCharacter{1E31}{\'k} \DeclareUnicodeCharacter{1E32}{\udotaccent{K}} \DeclareUnicodeCharacter{1E33}{\udotaccent{k}} \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}} \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}} \DeclareUnicodeCharacter{1E36}{\udotaccent{L}} \DeclareUnicodeCharacter{1E37}{\udotaccent{l}} \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}} \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}} \DeclareUnicodeCharacter{1E3E}{\'M} \DeclareUnicodeCharacter{1E3F}{\'m} \DeclareUnicodeCharacter{1E40}{\dotaccent{M}} \DeclareUnicodeCharacter{1E41}{\dotaccent{m}} \DeclareUnicodeCharacter{1E42}{\udotaccent{M}} \DeclareUnicodeCharacter{1E43}{\udotaccent{m}} \DeclareUnicodeCharacter{1E44}{\dotaccent{N}} \DeclareUnicodeCharacter{1E45}{\dotaccent{n}} \DeclareUnicodeCharacter{1E46}{\udotaccent{N}} \DeclareUnicodeCharacter{1E47}{\udotaccent{n}} \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}} \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}} \DeclareUnicodeCharacter{1E54}{\'P} \DeclareUnicodeCharacter{1E55}{\'p} \DeclareUnicodeCharacter{1E56}{\dotaccent{P}} \DeclareUnicodeCharacter{1E57}{\dotaccent{p}} \DeclareUnicodeCharacter{1E58}{\dotaccent{R}} \DeclareUnicodeCharacter{1E59}{\dotaccent{r}} \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}} \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}} \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}} \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}} \DeclareUnicodeCharacter{1E60}{\dotaccent{S}} \DeclareUnicodeCharacter{1E61}{\dotaccent{s}} \DeclareUnicodeCharacter{1E62}{\udotaccent{S}} \DeclareUnicodeCharacter{1E63}{\udotaccent{s}} \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}} \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}} \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}} \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}} \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}} \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}} \DeclareUnicodeCharacter{1E7C}{\~V} \DeclareUnicodeCharacter{1E7D}{\~v} \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}} \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}} \DeclareUnicodeCharacter{1E80}{\`W} \DeclareUnicodeCharacter{1E81}{\`w} \DeclareUnicodeCharacter{1E82}{\'W} \DeclareUnicodeCharacter{1E83}{\'w} \DeclareUnicodeCharacter{1E84}{\"W} \DeclareUnicodeCharacter{1E85}{\"w} \DeclareUnicodeCharacter{1E86}{\dotaccent{W}} \DeclareUnicodeCharacter{1E87}{\dotaccent{w}} \DeclareUnicodeCharacter{1E88}{\udotaccent{W}} \DeclareUnicodeCharacter{1E89}{\udotaccent{w}} \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}} \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}} \DeclareUnicodeCharacter{1E8C}{\"X} \DeclareUnicodeCharacter{1E8D}{\"x} \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}} \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}} \DeclareUnicodeCharacter{1E90}{\^Z} \DeclareUnicodeCharacter{1E91}{\^z} \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}} \DeclareUnicodeCharacter{1E93}{\udotaccent{z}} \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}} \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}} \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}} \DeclareUnicodeCharacter{1E97}{\"t} \DeclareUnicodeCharacter{1E98}{\ringaccent{w}} \DeclareUnicodeCharacter{1E99}{\ringaccent{y}} \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}} \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}} \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}} \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}} \DeclareUnicodeCharacter{1EBC}{\~E} \DeclareUnicodeCharacter{1EBD}{\~e} \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}} \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}} \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}} \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}} \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}} \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}} \DeclareUnicodeCharacter{1EF2}{\`Y} \DeclareUnicodeCharacter{1EF3}{\`y} \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}} \DeclareUnicodeCharacter{1EF8}{\~Y} \DeclareUnicodeCharacter{1EF9}{\~y} \DeclareUnicodeCharacter{2013}{--} \DeclareUnicodeCharacter{2014}{---} \DeclareUnicodeCharacter{2018}{\quoteleft} \DeclareUnicodeCharacter{2019}{\quoteright} \DeclareUnicodeCharacter{201A}{\quotesinglbase} \DeclareUnicodeCharacter{201C}{\quotedblleft} \DeclareUnicodeCharacter{201D}{\quotedblright} \DeclareUnicodeCharacter{201E}{\quotedblbase} \DeclareUnicodeCharacter{2022}{\bullet} \DeclareUnicodeCharacter{2026}{\dots} \DeclareUnicodeCharacter{2039}{\guilsinglleft} \DeclareUnicodeCharacter{203A}{\guilsinglright} \DeclareUnicodeCharacter{20AC}{\euro} \DeclareUnicodeCharacter{2192}{\expansion} \DeclareUnicodeCharacter{21D2}{\result} \DeclareUnicodeCharacter{2212}{\minus} \DeclareUnicodeCharacter{2217}{\point} \DeclareUnicodeCharacter{2261}{\equiv} }% end of \utfeightchardefs % US-ASCII character definitions. \def\asciichardefs{% nothing need be done \relax } % Make non-ASCII characters printable again for compatibility with % existing Texinfo documents that may use them, even without declaring a % document encoding. % \setnonasciicharscatcode \other \message{formatting,} \newdimen\defaultparindent \defaultparindent = 15pt \chapheadingskip = 15pt plus 4pt minus 2pt \secheadingskip = 12pt plus 3pt minus 2pt \subsecheadingskip = 9pt plus 2pt minus 2pt % Prevent underfull vbox error messages. \vbadness = 10000 % Don't be so finicky about underfull hboxes, either. \hbadness = 2000 % Following George Bush, get rid of widows and orphans. \widowpenalty=10000 \clubpenalty=10000 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're % using an old version of TeX, don't do anything. We want the amount of % stretch added to depend on the line length, hence the dependence on % \hsize. We call this whenever the paper size is set. % \def\setemergencystretch{% \ifx\emergencystretch\thisisundefined % Allow us to assign to \emergencystretch anyway. \def\emergencystretch{\dimen0}% \else \emergencystretch = .15\hsize \fi } % Parameters in order: 1) textheight; 2) textwidth; % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip; % 7) physical page height; 8) physical page width. % % We also call \setleading{\textleading}, so the caller should define % \textleading. The caller should also set \parskip. % \def\internalpagesizes#1#2#3#4#5#6#7#8{% \voffset = #3\relax \topskip = #6\relax \splittopskip = \topskip % \vsize = #1\relax \advance\vsize by \topskip \outervsize = \vsize \advance\outervsize by 2\topandbottommargin \pageheight = \vsize % \hsize = #2\relax \outerhsize = \hsize \advance\outerhsize by 0.5in \pagewidth = \hsize % \normaloffset = #4\relax \bindingoffset = #5\relax % \ifpdf \pdfpageheight #7\relax \pdfpagewidth #8\relax % if we don't reset these, they will remain at "1 true in" of % whatever layout pdftex was dumped with. \pdfhorigin = 1 true in \pdfvorigin = 1 true in \fi % \setleading{\textleading} % \parindent = \defaultparindent \setemergencystretch } % @letterpaper (the default). \def\letterpaper{{\globaldefs = 1 \parskip = 3pt plus 2pt minus 1pt \textleading = 13.2pt % % If page is nothing but text, make it come out even. \internalpagesizes{607.2pt}{6in}% that's 46 lines {\voffset}{.25in}% {\bindingoffset}{36pt}% {11in}{8.5in}% }} % Use @smallbook to reset parameters for 7x9.25 trim size. \def\smallbook{{\globaldefs = 1 \parskip = 2pt plus 1pt \textleading = 12pt % \internalpagesizes{7.5in}{5in}% {-.2in}{0in}% {\bindingoffset}{16pt}% {9.25in}{7in}% % \lispnarrowing = 0.3in \tolerance = 700 \hfuzz = 1pt \contentsrightmargin = 0pt \defbodyindent = .5cm }} % Use @smallerbook to reset parameters for 6x9 trim size. % (Just testing, parameters still in flux.) \def\smallerbook{{\globaldefs = 1 \parskip = 1.5pt plus 1pt \textleading = 12pt % \internalpagesizes{7.4in}{4.8in}% {-.2in}{-.4in}% {0pt}{14pt}% {9in}{6in}% % \lispnarrowing = 0.25in \tolerance = 700 \hfuzz = 1pt \contentsrightmargin = 0pt \defbodyindent = .4cm }} % Use @afourpaper to print on European A4 paper. \def\afourpaper{{\globaldefs = 1 \parskip = 3pt plus 2pt minus 1pt \textleading = 13.2pt % % Double-side printing via postscript on Laserjet 4050 % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. % To change the settings for a different printer or situation, adjust % \normaloffset until the front-side and back-side texts align. Then % do the same for \bindingoffset. You can set these for testing in % your texinfo source file like this: % @tex % \global\normaloffset = -6mm % \global\bindingoffset = 10mm % @end tex \internalpagesizes{673.2pt}{160mm}% that's 51 lines {\voffset}{\hoffset}% {\bindingoffset}{44pt}% {297mm}{210mm}% % \tolerance = 700 \hfuzz = 1pt \contentsrightmargin = 0pt \defbodyindent = 5mm }} % Use @afivepaper to print on European A5 paper. % From romildo@urano.iceb.ufop.br, 2 July 2000. % He also recommends making @example and @lisp be small. \def\afivepaper{{\globaldefs = 1 \parskip = 2pt plus 1pt minus 0.1pt \textleading = 12.5pt % \internalpagesizes{160mm}{120mm}% {\voffset}{\hoffset}% {\bindingoffset}{8pt}% {210mm}{148mm}% % \lispnarrowing = 0.2in \tolerance = 800 \hfuzz = 1.2pt \contentsrightmargin = 0pt \defbodyindent = 2mm \tableindent = 12mm }} % A specific text layout, 24x15cm overall, intended for A4 paper. \def\afourlatex{{\globaldefs = 1 \afourpaper \internalpagesizes{237mm}{150mm}% {\voffset}{4.6mm}% {\bindingoffset}{7mm}% {297mm}{210mm}% % % Must explicitly reset to 0 because we call \afourpaper. \globaldefs = 0 }} % Use @afourwide to print on A4 paper in landscape format. \def\afourwide{{\globaldefs = 1 \afourpaper \internalpagesizes{241mm}{165mm}% {\voffset}{-2.95mm}% {\bindingoffset}{7mm}% {297mm}{210mm}% \globaldefs = 0 }} % @pagesizes TEXTHEIGHT[,TEXTWIDTH] % Perhaps we should allow setting the margins, \topskip, \parskip, % and/or leading, also. Or perhaps we should compute them somehow. % \parseargdef\pagesizes{\pagesizesyyy #1,,\finish} \def\pagesizesyyy#1,#2,#3\finish{{% \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi \globaldefs = 1 % \parskip = 3pt plus 2pt minus 1pt \setleading{\textleading}% % \dimen0 = #1\relax \advance\dimen0 by \voffset % \dimen2 = \hsize \advance\dimen2 by \normaloffset % \internalpagesizes{#1}{\hsize}% {\voffset}{\normaloffset}% {\bindingoffset}{44pt}% {\dimen0}{\dimen2}% }} % Set default to letter. % \letterpaper \message{and turning on texinfo input format.} % DEL is a comment character, in case @c does not suffice. \catcode`\^^? = 14 % Define macros to output various characters with catcode for normal text. \catcode`\"=\other \catcode`\~=\other \catcode`\^=\other \catcode`\_=\other \catcode`\|=\other \catcode`\<=\other \catcode`\>=\other \catcode`\+=\other \catcode`\$=\other \def\normaldoublequote{"} \def\normaltilde{~} \def\normalcaret{^} \def\normalunderscore{_} \def\normalverticalbar{|} \def\normalless{<} \def\normalgreater{>} \def\normalplus{+} \def\normaldollar{$}%$ font-lock fix % This macro is used to make a character print one way in \tt % (where it can probably be output as-is), and another way in other fonts, % where something hairier probably needs to be done. % % #1 is what to print if we are indeed using \tt; #2 is what to print % otherwise. Since all the Computer Modern typewriter fonts have zero % interword stretch (and shrink), and it is reasonable to expect all % typewriter fonts to have this, we can check that font parameter. % \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} % Same as above, but check for italic font. Actually this also catches % non-italic slanted fonts since it is impossible to distinguish them from % italic fonts. But since this is only used by $ and it uses \sl anyway % this is not a problem. \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} % Turn off all special characters except @ % (and those which the user can use as if they were ordinary). % Most of these we simply print from the \tt font, but for some, we can % use math or other variants that look better in normal text. \catcode`\"=\active \def\activedoublequote{{\tt\char34}} \let"=\activedoublequote \catcode`\~=\active \def~{{\tt\char126}} \chardef\hat=`\^ \catcode`\^=\active \def^{{\tt \hat}} \catcode`\_=\active \def_{\ifusingtt\normalunderscore\_} \let\realunder=_ % Subroutine for the previous macro. \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } \catcode`\|=\active \def|{{\tt\char124}} \chardef \less=`\< \catcode`\<=\active \def<{{\tt \less}} \chardef \gtr=`\> \catcode`\>=\active \def>{{\tt \gtr}} \catcode`\+=\active \def+{{\tt \char 43}} \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix % If a .fmt file is being used, characters that might appear in a file % name cannot be active until we have parsed the command line. % So turn them off again, and have \everyjob (or @setfilename) turn them on. % \otherifyactive is called near the end of this file. \def\otherifyactive{\catcode`+=\other \catcode`\_=\other} % Used sometimes to turn off (effectively) the active characters even after % parsing them. \def\turnoffactive{% \normalturnoffactive \otherbackslash } \catcode`\@=0 % \backslashcurfont outputs one backslash character in current font, % as in \char`\\. \global\chardef\backslashcurfont=`\\ \global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work % \realbackslash is an actual character `\' with catcode other, and % \doublebackslash is two of them (for the pdf outlines). {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}} % In texinfo, backslash is an active character; it prints the backslash % in fixed width font. \catcode`\\=\active @def@normalbackslash{{@tt@backslashcurfont}} % On startup, @fixbackslash assigns: % @let \ = @normalbackslash % \rawbackslash defines an active \ to do \backslashcurfont. % \otherbackslash defines an active \ to be a literal `\' character with % catcode other. @gdef@rawbackslash{@let\=@backslashcurfont} @gdef@otherbackslash{@let\=@realbackslash} % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of % the literal character `\'. % @def@normalturnoffactive{% @let\=@normalbackslash @let"=@normaldoublequote @let~=@normaltilde @let^=@normalcaret @let_=@normalunderscore @let|=@normalverticalbar @let<=@normalless @let>=@normalgreater @let+=@normalplus @let$=@normaldollar %$ font-lock fix @markupsetuplqdefault @markupsetuprqdefault @unsepspaces } % Make _ and + \other characters, temporarily. % This is canceled by @fixbackslash. @otherifyactive % If a .fmt file is being used, we don't want the `\input texinfo' to show up. % That is what \eatinput is for; after that, the `\' should revert to printing % a backslash. % @gdef@eatinput input texinfo{@fixbackslash} @global@let\ = @eatinput % On the other hand, perhaps the file did not have a `\input texinfo'. Then % the first `\' in the file would cause an error. This macro tries to fix % that, assuming it is called before the first `\' could plausibly occur. % Also turn back on active characters that might appear in the input % file name, in case not using a pre-dumped format. % @gdef@fixbackslash{% @ifx\@eatinput @let\ = @normalbackslash @fi @catcode`+=@active @catcode`@_=@active } % Say @foo, not \foo, in error messages. @escapechar = `@@ % These look ok in all fonts, so just make them not special. @catcode`@& = @other @catcode`@# = @other @catcode`@% = @other @c Finally, make ` and ' active, so that txicodequoteundirected and @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we @c don't make ` and ' active, @code will not get them as active chars. @c Do this last of all since we use ` in the previous @catcode assignments. @catcode`@'=@active @catcode`@`=@active @markupsetuplqdefault @markupsetuprqdefault @c Local variables: @c eval: (add-hook 'write-file-hooks 'time-stamp) @c page-delimiter: "^\\\\message" @c time-stamp-start: "def\\\\texinfoversion{" @c time-stamp-format: "%:y-%02m-%02d.%02H" @c time-stamp-end: "}" @c End: @c vim:sw=2: @ignore arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115 @end ignore am-utils-6.2+rc20110530/fixmount/000077500000000000000000000000001157065440000162035ustar00rootroot00000000000000am-utils-6.2+rc20110530/fixmount/.cvsignore000066400000000000000000000000141157065440000201760ustar00rootroot00000000000000Makefile.in am-utils-6.2+rc20110530/fixmount/Makefile.am000066400000000000000000000017751157065440000202510ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in # Package: am-utils # Level: Makefile for fixmount/ directory # Author: Erez Zadok sbin_PROGRAMS = fixmount # man pages man_MANS = fixmount.8 # headers this depends on, not to be installed #noinst_HEADERS = fixmount_SOURCES = fixmount.c EXTRA_fixmount_OBJECTS = check_mount.o LDADD = $(EXTRA_fixmount_OBJECTS) ../libamu/libamu.la INCLUDES = -I$(top_srcdir)/include # allow users to add their own flags via "configure --enable-am-flags=ARG" AMU_CFLAGS = @AMU_CFLAGS@ AM_CFLAGS = @CFLAGS@ $(AMU_CFLAGS) # additional files to distribute and clean EXTRA_DIST = $(man_MANS) DISTCLEANFILES = check_mount.c # dependencies $(PROGRAMS): $(LDADD) $(fixmount_OBJECTS) $(EXTRA_fixmount_OBJECTS): \ ../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) am-utils-6.2+rc20110530/fixmount/fixmount.8000066400000000000000000000134001157065440000201430ustar00rootroot00000000000000.\" .\" Copyright (c) 1997-2011 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. 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 .\" 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/fixmount/fixmount.8 .\" .TH FIXMOUNT 8 "26 Feb 1993" .SH NAME fixmount \- fix remote mount entries .SH SYNOPSIS .B fixmount [ .B \-adervq ] [ .B \-h .I name ] .I host \&... .SH DESCRIPTION .IX "fixmount command" "" "\fLfixmount\fP \(em fix remote mount entries" .LP .B fixmount is a variant of .BR showmount (8) that can delete bogus mount entries in remote .BR mountd (8) daemons. The actions specified by the options are performed for each .I host in turn. .SH OPTIONS .TP .B \-a \-d \-e These options work as in .BR showmount (8) except that only entries pertaining to the local host are printed. .TP .B \-r Removes those remote mount entries on .I host that do not correspond to current mounts, i.e., which are left-over from a crash or are the result of improper mount protocol. The actuality of mounts is verified using the entries in .BR /etc/mtab . .TP .B \-v Verify remote mounts. Similar to .B \-r except that only a notification message is printed for each bogus entry found. The remote mount table is not changed. .TP .B \-A Issues a command to the remote mountd declaring that ALL of its filesystems have been unmounted. This should be used with caution, as it removes all remote mount entries pertaining to the local system, whether or not any filesystems are still mounted locally. .TP .B \-q Be quiet. Suppresses error messages due to timeouts and "Program not registered", i.e., due to remote hosts not supporting RPC or not running mountd. .TP .BI \-h \ name Pretend the local hostname is .IR name . This is useful after the local hostname has been changed and rmtab entries using the old name remain on a remote machine. Unfortunately, most mountd's won't be able to successfully handle removal of such entries, so this option is useful in combination with .B \-v only. .br This option also saves time as comparisons of remotely recorded and local hostnames by address are avoided. .SH FILES .TP 20 .B /etc/mtab List of current mounts. .TP .B /etc/rmtab Backup file for remote mount entries on NFS server. .SH "SEE ALSO" .BR showmount (8), .BR mtab (5), .BR rmtab (5), .BR mountd (8C). .LP ``am-utils'' .BR info (1) entry. .LP .I "Linux NFS and Automounter Administration" by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). .LP .I http://www.am-utils.org .LP .I "Amd \- The 4.4 BSD Automounter" .SH BUGS No attempt is made to verify the information in .B /etc/mtab itself. .PP Since swap file mounts are not recorded in .BR /etc/mtab , a heuristic specific to SunOS is used to determine whether such a mount is actual (replacing the string "swap" with "root" and verifying the resulting path). .PP Symbolic links on the server will cause the path in the remote entry to differ from the one in .BR /etc/mtab . To catch those cases, a filesystem is also deemed mounted if its .I local mount point is identical to the remote entry. I.e., on a SunOS diskless client, .B server:/export/share/sunos.4.1.1 is actually .BR /usr/share . Since the local mount point is .B /usr/share as well this will be handled correctly. .PP There is no way to clear a stale entry in a remote mountd after the local hostname (or whatever reverse name resolution returns for it) has been changed. To take care of these cases, the remote /etc/rmtab file has to be edited and mountd restarted. .PP The RPC timeouts for mountd calls can only be changed by recompiling. The defaults are 2 seconds for client handle creation and 5 seconds for RPC calls. .SH AUTHORS Andreas Stolcke . .P Erez Zadok , Computer Science Department, Stony Brook University, Stony Brook, New York, USA. .P Other authors and contributors to am-utils are listed in the .B AUTHORS file distributed with am-utils. am-utils-6.2+rc20110530/fixmount/fixmount.c000066400000000000000000000342401157065440000202230ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/fixmount/fixmount.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #define CREATE_TIMEOUT 2 /* seconds */ #define CALL_TIMEOUT 5 /* seconds */ /* Constant defs */ #define ALL 1 #define DIRS 2 #define DODUMP 0x1 #define DOEXPORTS 0x2 #define DOREMOVE 0x4 #define DOVERIFY 0x8 #define DOREMALL 0x10 extern int fixmount_check_mount(char *host, struct in_addr hostaddr, char *path); static char dir_path[NFS_MAXPATHLEN]; static char localhost[] = "localhost"; static char thishost[MAXHOSTNAMELEN + 1] = ""; static exports mntexports; static int quiet = 0; static int type = 0; static jmp_buf before_rpc; static mountlist mntdump; static struct in_addr thisaddr; static CLIENT *clnt_create_timeout(char *, struct timeval *); RETSIGTYPE create_timeout(int); int is_same_host(char *, char *, struct in_addr); int main(int, char *[]); int remove_all(CLIENT *, char *); int remove_mount(CLIENT *, char *, mountlist, int); void fix_rmtab(CLIENT *, char *, mountlist, int, int); void print_dump(mountlist); void usage(void); void usage(void) { fprintf(stderr, "usage: fixmount [-adervAqf] [-h hostname] host ...\n"); exit(1); } /* * Check hostname against other name and its IP address */ int is_same_host(char *name1, char *name2, struct in_addr addr2) { if (strcasecmp(name1, name2) == 0) { return 1; } else if (addr2.s_addr == INADDR_NONE) { return 0; } else { static char lasthost[MAXHOSTNAMELEN] = ""; static struct in_addr addr1; struct hostent *he; /* * To save nameserver lookups, and because this function * is typically called repeatedly on the same names, * cache the last lookup result and reuse it if possible. */ if (strcasecmp(name1, lasthost) == 0) { return (addr1.s_addr == addr2.s_addr); } else if (!(he = gethostbyname(name1))) { return 0; } else { xstrlcpy(lasthost, name1, sizeof(lasthost)); memcpy(&addr1, he->h_addr, sizeof(addr1)); return (addr1.s_addr == addr2.s_addr); } } } /* * Print the binary tree in inorder so that output is sorted. */ void print_dump(mountlist mp) { if (mp == NULL) return; if (is_same_host(mp->ml_hostname, thishost, thisaddr)) { switch (type) { case ALL: printf("%s:%s\n", mp->ml_hostname, mp->ml_directory); break; case DIRS: printf("%s\n", mp->ml_directory); break; default: printf("%s\n", mp->ml_hostname); break; }; } if (mp->ml_next) print_dump(mp->ml_next); } /* * remove entry from remote rmtab */ int remove_mount(CLIENT *client, char *host, mountlist ml, int fixit) { enum clnt_stat estat; struct timeval tv; char *pathp = dir_path; xstrlcpy(dir_path, ml->ml_directory, sizeof(dir_path)); if (!fixit) { printf("%s: bogus mount %s:%s\n", host, ml->ml_hostname, ml->ml_directory); fflush(stdout); } else { printf("%s: removing %s:%s\n", host, ml->ml_hostname, ml->ml_directory); fflush(stdout); tv.tv_sec = CALL_TIMEOUT; tv.tv_usec = 0; if ((estat = clnt_call(client, MOUNTPROC_UMNT, (XDRPROC_T_TYPE) xdr_dirpath, (char *) &pathp, (XDRPROC_T_TYPE) xdr_void, (char *) NULL, tv)) != RPC_SUCCESS) { fprintf(stderr, "%s:%s MOUNTPROC_UMNT: ", host, ml->ml_directory); clnt_perrno(estat); fflush(stderr); return -1; } } return 0; } /* * fix mount list on remote host */ void fix_rmtab(CLIENT *client, char *host, mountlist mp, int fixit, int force) { mountlist p; struct hostent *he; struct in_addr hostaddr; /* * Obtain remote address for comparisons */ if ((he = gethostbyname(host))) { memcpy(&hostaddr, he->h_addr, sizeof(hostaddr)); } else { hostaddr.s_addr = INADDR_NONE; } for (p = mp; p; p = p->ml_next) { if (is_same_host(p->ml_hostname, thishost, thisaddr)) { if (force || !fixmount_check_mount(host, hostaddr, p->ml_directory)) remove_mount(client, host, p, fixit); } } } /* * remove all entries from remote rmtab */ int remove_all(CLIENT *client, char *host) { enum clnt_stat estat; struct timeval tv; printf("%s: removing ALL\n", host); fflush(stdout); tv.tv_sec = CALL_TIMEOUT; tv.tv_usec = 0; if ((estat = clnt_call(client, MOUNTPROC_UMNTALL, (XDRPROC_T_TYPE) xdr_void, (char *) NULL, (XDRPROC_T_TYPE) xdr_void, (char *) NULL, tv)) != RPC_SUCCESS) { /* * RPC_SYSTEMERROR is returned even if all went well */ if (estat != RPC_SYSTEMERROR) { fprintf(stderr, "%s MOUNTPROC_UMNTALL: ", host); clnt_perrno(estat); fflush(stderr); return -1; } } return 0; } /* * This command queries the NFS mount daemon for it's mount list and/or * it's exports list and prints them out. * See "NFS: Network File System Protocol Specification, RFC1094, Appendix A" * for detailed information on the protocol. */ int main(int argc, char *argv[]) { AUTH *auth; CLIENT *client; char *host; enum clnt_stat estat; exports exp; extern char *optarg; extern int optind; groups grp; int ch; int force = 0; int morethanone; register int rpcs = 0; struct timeval tv; while ((ch = getopt(argc, argv, "adervAqfh:")) != -1) switch ((char) ch) { case 'a': if (type == 0) { type = ALL; rpcs |= DODUMP; } else usage(); break; case 'd': if (type == 0) { type = DIRS; rpcs |= DODUMP; } else usage(); break; case 'e': rpcs |= DOEXPORTS; break; case 'r': rpcs |= DOREMOVE; break; case 'A': rpcs |= DOREMALL; break; case 'v': rpcs |= DOVERIFY; break; case 'q': quiet = 1; break; case 'f': force = 1; break; case 'h': xstrlcpy(thishost, optarg, sizeof(thishost)); break; case '?': default: usage(); } if (optind == argc) usage(); if (rpcs == 0) rpcs = DODUMP; if (!*thishost) { struct hostent *he; if (gethostname(thishost, sizeof(thishost)) < 0) { perror("gethostname"); exit(1); } thishost[sizeof(thishost) - 1] = '\0'; /* * We need the hostname as it appears to the other side's * mountd, so get our own hostname by reverse address * resolution. */ if (!(he = gethostbyname(thishost))) { fprintf(stderr, "gethostbyname failed on %s\n", thishost); exit(1); } memcpy(&thisaddr, he->h_addr, sizeof(thisaddr)); if (!(he = gethostbyaddr((char *) &thisaddr, sizeof(thisaddr), he->h_addrtype))) { fprintf(stderr, "gethostbyaddr failed on %s\n", inet_ntoa(thisaddr)); exit(1); } xstrlcpy(thishost, he->h_name, sizeof(thishost)); } else { thisaddr.s_addr = INADDR_NONE; } if (!(auth = authunix_create_default())) { fprintf(stderr, "couldn't create authentication handle\n"); exit(1); } morethanone = (optind + 1 < argc); for (; optind < argc; optind++) { host = argv[optind]; tv.tv_sec = CREATE_TIMEOUT; tv.tv_usec = 0; if (!(client = clnt_create_timeout(host, &tv))) continue; client->cl_auth = auth; tv.tv_sec = CALL_TIMEOUT; tv.tv_usec = 0; if (rpcs & (DODUMP | DOREMOVE | DOVERIFY)) if ((estat = clnt_call(client, MOUNTPROC_DUMP, (XDRPROC_T_TYPE) xdr_void, (char *) NULL, (XDRPROC_T_TYPE) xdr_mountlist, (char *) &mntdump, tv)) != RPC_SUCCESS) { fprintf(stderr, "%s: MOUNTPROC_DUMP: ", host); clnt_perrno(estat); fflush(stderr); mntdump = NULL; goto next; } if (rpcs & DOEXPORTS) if ((estat = clnt_call(client, MOUNTPROC_EXPORT, (XDRPROC_T_TYPE) xdr_void, (char *) NULL, (XDRPROC_T_TYPE) xdr_exports, (char *) &mntexports, tv)) != RPC_SUCCESS) { fprintf(stderr, "%s: MOUNTPROC_EXPORT: ", host); clnt_perrno(estat); fflush(stderr); mntexports = NULL; goto next; } /* Now just print out the results */ if ((rpcs & (DODUMP | DOEXPORTS)) && morethanone) { printf(">>> %s <<<\n", host); fflush(stdout); } if (rpcs & DODUMP) { print_dump(mntdump); } if (rpcs & DOEXPORTS) { exp = mntexports; while (exp) { printf("%-35s", exp->ex_dir); grp = exp->ex_groups; if (grp == NULL) { printf("Everyone\n"); } else { while (grp) { printf("%s ", grp->gr_name); grp = grp->gr_next; } printf("\n"); } exp = exp->ex_next; } } if (rpcs & DOVERIFY) fix_rmtab(client, host, mntdump, 0, force); if (rpcs & DOREMOVE) fix_rmtab(client, host, mntdump, 1, force); if (rpcs & DOREMALL) remove_all(client, host); next: if (mntdump) (void) clnt_freeres(client, (XDRPROC_T_TYPE) xdr_mountlist, (char *) &mntdump); if (mntexports) (void) clnt_freeres(client, (XDRPROC_T_TYPE) xdr_exports, (char *) &mntexports); clnt_destroy(client); } exit(0); return 0; /* should never reach here */ } RETSIGTYPE create_timeout(int sig) { signal(SIGALRM, SIG_DFL); longjmp(before_rpc, 1); } #ifndef HAVE_TRANSPORT_TYPE_TLI /* * inetresport creates a datagram socket and attempts to bind it to a * secure port. * returns: The bound socket, or -1 to indicate an error. */ static int inetresport(int ty) { int alport; struct sockaddr_in addr; int fd; memset(&addr, 0, sizeof(addr)); /* as per POSIX, sin_len need not be set (used internally by kernel) */ addr.sin_family = AF_INET; /* use internet address family */ addr.sin_addr.s_addr = INADDR_ANY; if ((fd = socket(AF_INET, ty, 0)) < 0) return -1; for (alport = IPPORT_RESERVED - 1; alport > IPPORT_RESERVED / 2 + 1; alport--) { addr.sin_port = htons((u_short) alport); if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) >= 0) return fd; if (errno != EADDRINUSE) { close(fd); return -1; } } close(fd); errno = EAGAIN; return -1; } /* * Privsock() calls inetresport() to attempt to bind a socket to a secure * port. If inetresport() fails, privsock returns a magic socket number which * indicates to RPC that it should make its own socket. * returns: A privileged socket # or RPC_ANYSOCK. */ static int privsock(int ty) { int sock = inetresport(ty); if (sock < 0) { errno = 0; /* Couldn't get a secure port, let RPC make an insecure one */ sock = RPC_ANYSOCK; } return sock; } #endif /* not HAVE_TRANSPORT_TYPE_TLI */ static CLIENT * clnt_create_timeout(char *host, struct timeval *tvp) { CLIENT *clnt; struct sockaddr_in host_addr; struct hostent *hp; #ifndef HAVE_TRANSPORT_TYPE_TLI int s; #endif /* not HAVE_TRANSPORT_TYPE_TLI */ if (setjmp(before_rpc)) { if (!quiet) { fprintf(stderr, "%s: ", host); clnt_perrno(RPC_TIMEDOUT); fprintf(stderr, "\n"); fflush(stderr); } return NULL; } signal(SIGALRM, create_timeout); ualarm(tvp->tv_sec * 1000000 + tvp->tv_usec, 0); /* * Get address of host */ if ((hp = gethostbyname(host)) == 0 && !STREQ(host, localhost)) { fprintf(stderr, "can't get address of %s\n", host); return NULL; } memset(&host_addr, 0, sizeof(host_addr)); /* as per POSIX, sin_len need not be set (used internally by kernel) */ host_addr.sin_family = AF_INET; if (hp) { memmove((voidp) &host_addr.sin_addr, (voidp) hp->h_addr, sizeof(host_addr.sin_addr)); } else { /* fake "localhost" */ host_addr.sin_addr.s_addr = htonl(0x7f000001); } #ifdef HAVE_TRANSPORT_TYPE_TLI /* try TCP first (in case return data is large), then UDP */ clnt = clnt_create(host, MOUNTPROG, MOUNTVERS, "tcp"); if (!clnt) clnt = clnt_create(host, MOUNTPROG, MOUNTVERS, "udp"); #else /* not HAVE_TRANSPORT_TYPE_TLI */ s = RPC_ANYSOCK; clnt = clnttcp_create(&host_addr, MOUNTPROG, MOUNTVERS, &s, 0, 0); if (!clnt) { /* XXX: do we need to close(s) ? */ s = privsock(SOCK_DGRAM); clnt = clntudp_create(&host_addr, MOUNTPROG, MOUNTVERS, *tvp, &s); } #endif /* not HAVE_TRANSPORT_TYPE_TLI */ if (!clnt) { ualarm(0, 0); if (!quiet) { clnt_pcreateerror(host); fflush(stderr); } return NULL; } ualarm(0, 0); return clnt; } am-utils-6.2+rc20110530/fsinfo/000077500000000000000000000000001157065440000156165ustar00rootroot00000000000000am-utils-6.2+rc20110530/fsinfo/.cvsignore000066400000000000000000000000141157065440000176110ustar00rootroot00000000000000Makefile.in am-utils-6.2+rc20110530/fsinfo/Makefile.am000066400000000000000000000031011157065440000176450ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in # Package: am-utils # Level: Makefile for fsinfo/ directory # Author: Erez Zadok sbin_PROGRAMS = fsinfo # man pages man_MANS = fsinfo.8 # headers this depends on, not to be installed noinst_HEADERS = fsi_data.h fsinfo.h # sources needed: note .y and .l files have to be first fsinfo_SOURCES = \ fsi_gram.y \ fsi_lex.l \ null_lex.l \ null_gram.y \ \ fsi_analyze.c \ fsi_dict.c \ fsi_util.c \ fsinfo.c \ wr_atab.c \ wr_bparam.c \ wr_dumpset.c \ wr_exportfs.c \ wr_fstab.c # sources which get auto-built (from yacc/lex) BUILT_SOURCES = fsi_gram.c fsi_gram.h fsi_lex.c \ null_gram.c null_gram.h null_lex.c EXTRA_DIST = $(man_MANS) # do not distribute files that should be generated by lex/yacc locally dist-hook: (cd $(distdir) && rm -f fsi_gram.c fsi_gram.h fsi_lex.c) # clean these files, which get automatically generated by yacc/lex CLEANFILES = $(BUILT_SOURCES) LDADD = $(EXTRA_fsinfo_OBJECTS) ../libamu/libamu.la # must manually add f/lex library to LIBS, and not to LDADD. LIBS = @LIBS@ @LEXLIB@ INCLUDES = -I$(top_srcdir)/include # allow users to add their own flags via "configure --enable-am-flags=ARG" AMU_CFLAGS = @AMU_CFLAGS@ AM_CFLAGS = @CFLAGS@ $(AMU_CFLAGS) AM_YFLAGS = -d # dependencies $(PROGRAMS): $(LDADD) $(fsinfo_OBJECTS): \ ../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) am-utils-6.2+rc20110530/fsinfo/fsi_analyze.c000066400000000000000000000371641157065440000203010ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/fsinfo/fsi_analyze.c * */ /* * Analyze filesystem declarations * * Note: most of this is magic! */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include char *disk_fs_strings[] = { "fstype", "opts", "dumpset", "passno", "freq", "mount", "log", NULL, }; char *mount_strings[] = { "volname", "exportfs", NULL, }; char *fsmount_strings[] = { "as", "volname", "fstype", "opts", "from", NULL, }; char *host_strings[] = { "host", "netif", "config", "arch", "cluster", "os", NULL, }; char *ether_if_strings[] = { "inaddr", "netmask", "hwaddr", NULL, }; /* * Strip off the trailing part of a domain * to produce a short-form domain relative * to the local host domain. * Note that this has no effect if the domain * names do not have the same number of * components. If that restriction proves * to be a problem then the loop needs recoding * to skip from right to left and do partial * matches along the way -- ie more expensive. */ void domain_strip(char *otherdom, char *localdom) { char *p1, *p2; if ((p1 = strchr(otherdom, '.')) && (p2 = strchr(localdom, '.')) && STREQ(p1 + 1, p2 + 1)) *p1 = '\0'; } /* * Take a little-endian domain name and * transform into a big-endian Un*x pathname. * For example: kiska.doc.ic -> ic/doc/kiska */ static char * compute_hostpath(char *hn) { char *p = xmalloc(MAXPATHLEN); char *d; char path[MAXPATHLEN]; xstrlcpy(p, hn, MAXPATHLEN); domain_strip(p, hostname); path[0] = '\0'; do { d = strrchr(p, '.'); if (d) { *d = '\0'; xstrlcat(path, d + 1, sizeof(path)); xstrlcat(path, "/", sizeof(path)); } else { xstrlcat(path, p, sizeof(path)); } } while (d); fsi_log("hostpath of '%s' is '%s'", hn, path); xstrlcpy(p, path, MAXPATHLEN); return p; } static dict_ent * find_volname(char *nn) { dict_ent *de; char *p = strdup(nn); char *q; do { fsi_log("Searching for volname %s", p); de = dict_locate(dict_of_volnames, p); q = strrchr(p, '/'); if (q) *q = '\0'; } while (!de && q); XFREE(p); return de; } static void show_required(ioloc *l, int mask, char *info, char *hostname, char *strings[]) { int i; fsi_log("mask left for %s:%s is %#x", hostname, info, mask); for (i = 0; strings[i]; i++) if (ISSET(mask, i)) lerror(l, "%s:%s needs field \"%s\"", hostname, info, strings[i]); } /* * Check and fill in "exportfs" details. * Make sure the m_exported field references * the most local node with an "exportfs" entry. */ static int check_exportfs(qelem *q, fsi_mount *e) { fsi_mount *mp; int errors = 0; ITER(mp, fsi_mount, q) { if (ISSET(mp->m_mask, DM_EXPORTFS)) { if (e) lwarning(mp->m_ioloc, "%s has duplicate exportfs data", mp->m_name); mp->m_exported = mp; if (!ISSET(mp->m_mask, DM_VOLNAME)) set_mount(mp, DM_VOLNAME, strdup(mp->m_name)); } else { mp->m_exported = e; } /* * Recursively descend the mount tree */ if (mp->m_mount) errors += check_exportfs(mp->m_mount, mp->m_exported); /* * If a volume name has been specified, but this node and none * of its parents has been exported, report an error. */ if (ISSET(mp->m_mask, DM_VOLNAME) && !mp->m_exported) { lerror(mp->m_ioloc, "%s has a volname but no exportfs data", mp->m_name); errors++; } } return errors; } static int analyze_dkmount_tree(qelem *q, fsi_mount *parent, disk_fs *dk) { fsi_mount *mp; int errors = 0; ITER(mp, fsi_mount, q) { fsi_log("Mount %s:", mp->m_name); if (parent) { char n[MAXPATHLEN]; xsnprintf(n, sizeof(n), "%s/%s", parent->m_name, mp->m_name); if (*mp->m_name == '/') lerror(mp->m_ioloc, "sub-directory %s of %s starts with '/'", mp->m_name, parent->m_name); else if (STREQ(mp->m_name, "default")) lwarning(mp->m_ioloc, "sub-directory of %s is named \"default\"", parent->m_name); fsi_log("Changing name %s to %s", mp->m_name, n); XFREE(mp->m_name); mp->m_name = strdup(n); } mp->m_name_len = strlen(mp->m_name); mp->m_parent = parent; mp->m_dk = dk; if (mp->m_mount) analyze_dkmount_tree(mp->m_mount, mp, dk); } return errors; } /* * The mount tree is a singleton list * containing the top-level mount * point for a disk. */ static int analyze_dkmounts(disk_fs *dk, qelem *q) { int errors = 0; fsi_mount *mp, *mp2 = NULL; int i = 0; /* * First scan the list of subdirs to make * sure there is only one - and remember it */ if (q) { ITER(mp, fsi_mount, q) { mp2 = mp; i++; } } /* * Check... */ if (i < 1) { lerror(dk->d_ioloc, "%s:%s has no mount point", dk->d_host->h_hostname, dk->d_dev); return 1; } if (i > 1) { lerror(dk->d_ioloc, "%s:%s has more than one mount point", dk->d_host->h_hostname, dk->d_dev); errors++; } /* * Now see if a default mount point is required */ if (mp2 && STREQ(mp2->m_name, "default")) { if (ISSET(mp2->m_mask, DM_VOLNAME)) { char nbuf[1024]; compute_automount_point(nbuf, sizeof(nbuf), dk->d_host, mp2->m_volname); XFREE(mp2->m_name); mp2->m_name = strdup(nbuf); fsi_log("%s:%s has default mount on %s", dk->d_host->h_hostname, dk->d_dev, mp2->m_name); } else { lerror(dk->d_ioloc, "no volname given for %s:%s", dk->d_host->h_hostname, dk->d_dev); errors++; } } /* * Fill in the disk mount point */ if (!errors && mp2 && mp2->m_name) dk->d_mountpt = strdup(mp2->m_name); else dk->d_mountpt = strdup("error"); /* * Analyze the mount tree */ errors += analyze_dkmount_tree(q, NULL, dk); /* * Analyze the export tree */ errors += check_exportfs(q, NULL); return errors; } static void fixup_required_disk_info(disk_fs *dp) { /* * "fstype" */ if (ISSET(dp->d_mask, DF_FSTYPE)) { if (STREQ(dp->d_fstype, "swap")) { /* * Fixup for a swap device */ if (!ISSET(dp->d_mask, DF_PASSNO)) { dp->d_passno = 0; BITSET(dp->d_mask, DF_PASSNO); } else if (dp->d_freq != 0) { lwarning(dp->d_ioloc, "Pass number for %s:%s is non-zero", dp->d_host->h_hostname, dp->d_dev); } /* * "freq" */ if (!ISSET(dp->d_mask, DF_FREQ)) { dp->d_freq = 0; BITSET(dp->d_mask, DF_FREQ); } else if (dp->d_freq != 0) { lwarning(dp->d_ioloc, "dump frequency for %s:%s is non-zero", dp->d_host->h_hostname, dp->d_dev); } /* * "opts" */ if (!ISSET(dp->d_mask, DF_OPTS)) set_disk_fs(dp, DF_OPTS, strdup("swap")); /* * "mount" */ if (!ISSET(dp->d_mask, DF_MOUNT)) { qelem *q = new_que(); fsi_mount *m = new_mount(); m->m_name = strdup("swap"); m->m_mount = new_que(); ins_que(&m->m_q, q->q_back); dp->d_mount = q; BITSET(dp->d_mask, DF_MOUNT); } else { lerror(dp->d_ioloc, "%s: mount field specified for swap partition", dp->d_host->h_hostname); } } else if (STREQ(dp->d_fstype, "export")) { /* * "passno" */ if (!ISSET(dp->d_mask, DF_PASSNO)) { dp->d_passno = 0; BITSET(dp->d_mask, DF_PASSNO); } else if (dp->d_passno != 0) { lwarning(dp->d_ioloc, "pass number for %s:%s is non-zero", dp->d_host->h_hostname, dp->d_dev); } /* * "freq" */ if (!ISSET(dp->d_mask, DF_FREQ)) { dp->d_freq = 0; BITSET(dp->d_mask, DF_FREQ); } else if (dp->d_freq != 0) { lwarning(dp->d_ioloc, "dump frequency for %s:%s is non-zero", dp->d_host->h_hostname, dp->d_dev); } /* * "opts" */ if (!ISSET(dp->d_mask, DF_OPTS)) set_disk_fs(dp, DF_OPTS, strdup("rw,defaults")); } } } static void fixup_required_mount_info(fsmount *fp, dict_ent *de) { if (!ISSET(fp->f_mask, FM_FROM)) { if (de->de_count != 1) { lerror(fp->f_ioloc, "ambiguous mount: %s is a replicated filesystem", fp->f_volname); } else { dict_data *dd; fsi_mount *mp = NULL; dd = AM_FIRST(dict_data, &de->de_q); mp = (fsi_mount *) dd->dd_data; if (!mp) abort(); fp->f_ref = mp; set_fsmount(fp, FM_FROM, mp->m_dk->d_host->h_hostname); fsi_log("set: %s comes from %s", fp->f_volname, fp->f_from); } } if (!ISSET(fp->f_mask, FM_FSTYPE)) { set_fsmount(fp, FM_FSTYPE, strdup("nfs")); fsi_log("set: fstype is %s", fp->f_fstype); } if (!ISSET(fp->f_mask, FM_OPTS)) { set_fsmount(fp, FM_OPTS, strdup("rw,nosuid,grpid,defaults")); fsi_log("set: opts are %s", fp->f_opts); } if (!ISSET(fp->f_mask, FM_LOCALNAME)) { if (fp->f_ref) { set_fsmount(fp, FM_LOCALNAME, strdup(fp->f_volname)); fsi_log("set: localname is %s", fp->f_localname); } else { lerror(fp->f_ioloc, "cannot determine localname since volname %s is not uniquely defined", fp->f_volname); } } } /* * For each disk on a host * analyze the mount information * and fill in any derivable * details. */ static void analyze_drives(host *hp) { qelem *q = hp->h_disk_fs; disk_fs *dp; ITER(dp, disk_fs, q) { int req; fsi_log("Disk %s:", dp->d_dev); dp->d_host = hp; fixup_required_disk_info(dp); req = ~dp->d_mask & DF_REQUIRED; if (req) show_required(dp->d_ioloc, req, dp->d_dev, hp->h_hostname, disk_fs_strings); analyze_dkmounts(dp, dp->d_mount); } } /* * Check that all static mounts make sense and * that the source volumes exist. */ static void analyze_mounts(host *hp) { qelem *q = hp->h_mount; fsmount *fp; int netbootp = 0; ITER(fp, fsmount, q) { char *p; char *nn = strdup(fp->f_volname); int req; dict_ent *de = (dict_ent *) NULL; int found = 0; int matched = 0; if (ISSET(fp->f_mask, FM_DIRECT)) { found = 1; matched = 1; } else do { p = NULL; de = find_volname(nn); fsi_log("Mount: %s (trying %s)", fp->f_volname, nn); if (de) { found = 1; /* * Check that the from field is really exporting * the filesystem requested. * LBL: If fake mount, then don't care about * consistency check. */ if (ISSET(fp->f_mask, FM_FROM) && !ISSET(fp->f_mask, FM_DIRECT)) { dict_data *dd; fsi_mount *mp2 = NULL; ITER(dd, dict_data, &de->de_q) { fsi_mount *mp = (fsi_mount *) dd->dd_data; if (fp->f_from && STREQ(mp->m_dk->d_host->h_hostname, fp->f_from)) { mp2 = mp; break; } } if (mp2) { fp->f_ref = mp2; matched = 1; break; } } else { matched = 1; break; } } p = strrchr(nn, '/'); if (p) *p = '\0'; } while (de && p); XFREE(nn); if (!found) { lerror(fp->f_ioloc, "volname %s unknown", fp->f_volname); } else if (matched) { if (de) fixup_required_mount_info(fp, de); req = ~fp->f_mask & FM_REQUIRED; if (req) { show_required(fp->f_ioloc, req, fp->f_volname, hp->h_hostname, fsmount_strings); } else if (STREQ(fp->f_localname, "/")) { hp->h_netroot = fp; netbootp |= FM_NETROOT; } else if (STREQ(fp->f_localname, "swap")) { hp->h_netswap = fp; netbootp |= FM_NETSWAP; } } else { lerror(fp->f_ioloc, "volname %s not exported from %s", fp->f_volname, fp->f_from ? fp->f_from : "anywhere"); } } if (netbootp && (netbootp != FM_NETBOOT)) lerror(hp->h_ioloc, "network booting requires both root and swap areas"); } void analyze_hosts(qelem *q) { host *hp; show_area_being_processed("analyze hosts", 5); /* * Check all drives */ ITER(hp, host, q) { fsi_log("disks on host %s", hp->h_hostname); show_new("ana-host"); hp->h_hostpath = compute_hostpath(hp->h_hostname); if (hp->h_disk_fs) analyze_drives(hp); } show_area_being_processed("analyze mounts", 5); /* * Check static mounts */ ITER(hp, host, q) { fsi_log("mounts on host %s", hp->h_hostname); show_new("ana-mount"); if (hp->h_mount) analyze_mounts(hp); } } /* * Check an automount request */ static void analyze_automount(automount *ap) { dict_ent *de = find_volname(ap->a_volname); if (de) { ap->a_mounted = de; } else { if (STREQ(ap->a_volname, ap->a_name)) lerror(ap->a_ioloc, "unknown volname %s automounted", ap->a_volname); else lerror(ap->a_ioloc, "unknown volname %s automounted on %s", ap->a_volname, ap->a_name); } } static void analyze_automount_tree(qelem *q, char *pref, int lvl) { automount *ap; ITER(ap, automount, q) { char nname[1024]; if (lvl > 0 || ap->a_mount) if (ap->a_name[1] && strchr(ap->a_name + 1, '/')) lerror(ap->a_ioloc, "not allowed '/' in a directory name"); xsnprintf(nname, sizeof(nname), "%s/%s", pref, ap->a_name); XFREE(ap->a_name); ap->a_name = strdup(nname[1] == '/' ? nname + 1 : nname); fsi_log("automount point %s:", ap->a_name); show_new("ana-automount"); if (ap->a_mount) { analyze_automount_tree(ap->a_mount, ap->a_name, lvl + 1); } else if (ap->a_hardwiredfs) { fsi_log("\thardwired from %s to %s", ap->a_volname, ap->a_hardwiredfs); } else if (ap->a_volname) { fsi_log("\tautomount from %s", ap->a_volname); analyze_automount(ap); } else if (ap->a_symlink) { fsi_log("\tsymlink to %s", ap->a_symlink); } else { ap->a_volname = strdup(ap->a_name); fsi_log("\timplicit automount from %s", ap->a_volname); analyze_automount(ap); } } } void analyze_automounts(qelem *q) { auto_tree *tp; show_area_being_processed("analyze automount", 5); /* * q is a list of automounts */ ITER(tp, auto_tree, q) analyze_automount_tree(tp->t_mount, "", 0); } am-utils-6.2+rc20110530/fsinfo/fsi_data.h000066400000000000000000000131701157065440000175430ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/fsinfo/fsi_data.h * */ #ifndef _FSI_DATA_H #define _FSI_DATA_H typedef struct auto_tree auto_tree; typedef struct automount automount; typedef struct dict dict; typedef struct dict_data dict_data; typedef struct dict_ent dict_ent; typedef struct disk_fs disk_fs; typedef struct ether_if ether_if; typedef struct fsmount fsmount; typedef struct host host; typedef struct ioloc ioloc; typedef struct fsi_mount fsi_mount; /* * Automount tree */ struct automount { qelem a_q; ioloc *a_ioloc; char *a_name; /* Automount key */ char *a_volname; /* Equivalent volume to be referenced */ char *a_symlink; /* Symlink representation */ char *a_opts; /* opts for mounting */ char *a_hardwiredfs; /* hack to bypass bogus fs definitions */ qelem *a_mount; /* Tree representation */ dict_ent *a_mounted; }; /* * List of automount trees */ struct auto_tree { qelem t_q; ioloc *t_ioloc; char *t_defaults; qelem *t_mount; }; /* * A host */ struct host { qelem q; int h_mask; ioloc *h_ioloc; fsmount *h_netroot, *h_netswap; #define HF_HOST 0 char *h_hostname; /* The full name of the host */ char *h_lochost; /* The name of the host with local domains stripped */ char *h_hostpath; /* The filesystem path to the host (cf compute_hostpath) */ #define HF_ETHER 1 qelem *h_ether; #define HF_CONFIG 2 qelem *h_config; #define HF_ARCH 3 char *h_arch; #define HF_CLUSTER 4 char *h_cluster; #define HF_OS 5 char *h_os; qelem *h_disk_fs; qelem *h_mount; }; /* * An ethernet interface */ struct ether_if { qelem e_q; int e_mask; ioloc *e_ioloc; char *e_if; #define EF_INADDR 0 struct in_addr e_inaddr; #define EF_NETMASK 1 u_long e_netmask; #define EF_HWADDR 2 char *e_hwaddr; }; /* * Disk filesystem structure. * * If the DF_* numbers are changed * disk_fs_strings in analyze.c will * need updating. */ struct disk_fs { qelem d_q; int d_mask; ioloc *d_ioloc; host *d_host; char *d_mountpt; char *d_dev; #define DF_FSTYPE 0 char *d_fstype; #define DF_OPTS 1 char *d_opts; #define DF_DUMPSET 2 char *d_dumpset; #define DF_PASSNO 3 int d_passno; #define DF_FREQ 4 int d_freq; #define DF_MOUNT 5 qelem *d_mount; #define DF_LOG 6 char *d_log; }; #define DF_REQUIRED ((1< #endif /* HAVE_CONFIG_H */ #include #include #include static int dict_hash(char *k) { u_int h; for (h = 0; *k; h += *k++) ; return h % DICTHASH; } dict * new_dict(void) { dict *dp = CALLOC(struct dict); return dp; } static void dict_add_data(dict_ent *de, char *v) { dict_data *dd = CALLOC(struct dict_data); dd->dd_data = v; ins_que(&dd->dd_q, de->de_q.q_back); de->de_count++; } static dict_ent * new_dict_ent(char *k) { dict_ent *de = CALLOC(struct dict_ent); de->de_key = k; init_que(&de->de_q); return de; } dict_ent * dict_locate(dict *dp, char *k) { dict_ent *de = dp->de[dict_hash(k)]; while (de && !STREQ(de->de_key, k)) de = de->de_next; return de; } void dict_add(dict *dp, char *k, char *v) { dict_ent *de = dict_locate(dp, k); if (!de) { dict_ent **dep = &dp->de[dict_hash(k)]; de = new_dict_ent(k); de->de_next = *dep; *dep = de; } dict_add_data(de, v); } int dict_iter(dict *dp, int (*fn) (qelem *)) { int i; int errors = 0; for (i = 0; i < DICTHASH; i++) { dict_ent *de = dp->de[i]; while (de) { errors += (*fn) (&de->de_q); de = de->de_next; } } return errors; } am-utils-6.2+rc20110530/fsinfo/fsi_gram.y000066400000000000000000000226441157065440000176070ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/fsinfo/fsi_gram.y * */ %{ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include extern qelem *list_of_hosts, *list_of_automounts; %} %union { auto_tree *a; disk_fs *d; ether_if *e; host *h; qelem *q; char *s; fsi_mount *m; fsmount *f; } %token tARCH %token tAS %token tAUTOMOUNT %token tCLUSTER %token tCONFIG %token tDUMPSET %token tEQ %token tNFSEQ %token tEXPORTFS %token tFREQ %token tFROM %token tFS %token tFSTYPE %token tHWADDR %token tINADDR %token tHOST %token tLOCALHOST %token tLOG %token tMOUNT %token tNETMASK %token tNETIF %token tVOLNAME %token tOPTS %token tOS %token tPASSNO %token tDIRECT %token tSEL %token tSTR %start list_of_hosts %type automount %type automount_tree %type ether_attr %type dir_tree_info %type filesystem fs_info_list %type host host_attr host_attr_list %type list_of_hosts list_of_filesystems list_of_mounts dir_tree %type localinfo_list %type opt_auto_opts %% list_of_hosts : /* empty */ { $$ = new_que(); } | list_of_hosts host { if ($2) ins_que((qelem *) $2, list_of_hosts->q_back); $$ = $1; } | list_of_hosts automount { if ($2) ins_que((qelem *) $2, list_of_automounts->q_back); $$ = $1; } ; /* * A new host: * * host foo.domain */ host : tHOST host_attr list_of_filesystems list_of_mounts { $$ = $2; $$->h_disk_fs = $3; $$->h_mount = $4; } | error tHOST host_attr list_of_filesystems list_of_mounts { $$ = $3; $$->h_disk_fs = $4; $$->h_mount = $5; } ; host_attr : tSTR { $$ = new_host(); set_host($$, HF_HOST, $1); } | '{' host_attr_list '}' tSTR { $$ = $2; set_host($$, HF_HOST, $4); } ; host_attr_list : /* empty */ { $$ = new_host(); } | host_attr_list tNETIF tSTR '{' ether_attr '}' { if ($5) { $5->e_if = $3; $$ = $1; set_host($$, HF_ETHER, (char *) $5); } } | host_attr_list tCONFIG tSTR { $$ = $1; set_host($$, HF_CONFIG, $3); } | host_attr_list tARCH '=' tSTR { $$ = $1; set_host($$, HF_ARCH, $4); } | host_attr_list tOS '=' tSTR { $$ = $1; set_host($$, HF_OS, $4); } | host_attr_list tCLUSTER '=' tSTR { $$ = $1; set_host($$, HF_CLUSTER, $4); } | host_attr_list error '=' tSTR { yyerror("unknown host attribute"); } ; ether_attr : /* empty */ { $$ = new_ether_if(); } | ether_attr tINADDR '=' tSTR { $$ = $1; set_ether_if($$, EF_INADDR, $4); } | ether_attr tNETMASK '=' tSTR { $$ = $1; set_ether_if($$, EF_NETMASK, $4); } | ether_attr tHWADDR '=' tSTR { $$ = $1; set_ether_if($$, EF_HWADDR, $4); } ; /* * A new automount tree: * * automount /mountpoint { ... } */ automount : tAUTOMOUNT opt_auto_opts automount_tree { if ($3) { $$ = new_auto_tree($2, $3); } else { $$ = 0; } } | tAUTOMOUNT error { $$ = 0; } ; opt_auto_opts : /* empty */ { $$ = strdup(""); } | tOPTS tSTR { $$ = $2; } ; list_of_filesystems : /* empty */ { $$ = 0; } | list_of_filesystems filesystem { if ($2) { if ($1) $$ = $1; else $$ = new_que(); ins_que(&$2->d_q, $$->q_back); } else { $$ = $1; } } ; /* * A new filesystem: * * fs /dev/whatever { ... } */ filesystem : tFS tSTR '{' fs_info_list '}' { $4->d_dev = $2; $$ = $4; } | tFS error '}' { $$ = (disk_fs *) NULL; } ; /* * Per-filesystem information: * * fstype - the type of the filesystem (4.2, nfs, swap, export) * opts - the mount options ("rw,grpid") * passno - fsck pass number * freq - dump frequency * dumpset - tape set for filesystem dumps * mount - where to mount this filesystem * log - log device */ fs_info_list : /* empty */ { $$ = new_disk_fs(); } | fs_info_list tFSTYPE '=' tSTR { $$ = $1; set_disk_fs($$, DF_FSTYPE, $4); } | fs_info_list tOPTS '=' tSTR { $$ = $1; set_disk_fs($$, DF_OPTS, $4); } | fs_info_list tPASSNO '=' tSTR { $$ = $1; set_disk_fs($$, DF_PASSNO, $4); } | fs_info_list tFREQ '=' tSTR { $$ = $1; set_disk_fs($$, DF_FREQ, $4); } | fs_info_list tMOUNT dir_tree { $$ = $1; set_disk_fs($$, DF_MOUNT, (char *) $3); } | fs_info_list tDUMPSET '=' tSTR { $$ = $1; set_disk_fs($$, DF_DUMPSET, $4); } | fs_info_list tLOG '=' tSTR { $$ = $1; set_disk_fs($$, DF_LOG, $4); } | fs_info_list error '=' tSTR { yyerror("unknown filesystem attribute"); } ; /* * An automount tree: * * name = "volname" name is a reference to volname * name -> "string" name is a link to "string" * name nfsalias "string" name is a link to "string", string parsed as NFS * pathname. * name { ... } name is an automount tree */ automount_tree : /* empty */ { $$ = 0; } | automount_tree tSTR opt_auto_opts '=' tSTR { automount *a = new_automount($2); a->a_volname = $5; a->a_opts = $3; if ($1) $$ = $1; else $$ = new_que(); ins_que(&a->a_q, $$->q_back); } | automount_tree tSTR opt_auto_opts tNFSEQ tSTR { automount *a = new_automount($2); a->a_hardwiredfs = $5; a->a_opts = $3; if ($1) $$ = $1; else $$ = new_que(); ins_que(&a->a_q, $$->q_back); } | automount_tree tSTR tEQ tSTR { automount *a = new_automount($2); a->a_symlink = $4; if ($1) $$ = $1; else $$ = new_que(); ins_que(&a->a_q, $$->q_back); } | automount_tree tSTR opt_auto_opts '{' automount_tree '}' { automount *a = new_automount($2); a->a_mount = $5; a->a_opts = $3; if ($1) $$ = $1; else $$ = new_que(); ins_que(&a->a_q, $$->q_back); } ; dir_tree : /* empty */ { $$ = 0; } | dir_tree tSTR '{' dir_tree_info dir_tree '}' { $4->m_mount = $5; $4->m_name = $2; if ($2[0] != '/' && $2[1] && strchr($2+1, '/')) yyerror("not allowed '/' in a directory name"); if ($1) $$ = $1; else $$ = new_que(); ins_que(&$4->m_q, $$->q_back); } ; dir_tree_info : /* empty */ { $$ = new_mount(); } | dir_tree_info tEXPORTFS tSTR { $$ = $1; set_mount($$, DM_EXPORTFS, $3); } | dir_tree_info tVOLNAME tSTR { $$ = $1; set_mount($$, DM_VOLNAME, $3); } | dir_tree_info tSEL tSTR { $$ = $1; set_mount($$, DM_SEL, $3); } | dir_tree_info error '=' tSTR { yyerror("unknown directory attribute"); } ; /* * Additional mounts on a host * * mount "volname" ... */ list_of_mounts : /* empty */ { $$ = 0; } | list_of_mounts tMOUNT tSTR localinfo_list { set_fsmount($4, FM_VOLNAME, $3); if ($1) $$ = $1; else $$ = new_que(); ins_que(&$4->f_q, $$->q_back); } ; /* * Mount info: * * from "hostname" - obtain the object from the named host * as "string" - where to mount, if different from the volname * opts "string" - mount options * fstype "type" - type of filesystem mount, if not nfs * direct - mount entry, no need to create ad-hoc hosts file */ localinfo_list : /* empty */ { $$ = new_fsmount(); } | localinfo_list tDIRECT { $$ = $1; set_fsmount($$, FM_DIRECT, ""); } | localinfo_list tAS tSTR { $$ = $1; set_fsmount($$, FM_LOCALNAME, $3); } | localinfo_list tFROM tSTR { $$ = $1; set_fsmount($$, FM_FROM, $3); } | localinfo_list tFSTYPE tSTR { $$ = $1; set_fsmount($$, FM_FSTYPE, $3); } | localinfo_list tOPTS tSTR { $$ = $1; set_fsmount($$, FM_OPTS, $3); } | localinfo_list error '=' tSTR { yyerror("unknown mount attribute"); } ; am-utils-6.2+rc20110530/fsinfo/fsi_lex.l000066400000000000000000000161511157065440000174300ustar00rootroot00000000000000%{ /* * Copyright (c) 1997-2011 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. * 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. 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 * 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/fsinfo/fsi_lex.l * */ /* * Lexical analyzer for fsinfo. * TODO: Needs rewriting. */ static int ayylineno; #ifdef FLEX_SCANNER # define INIT_STATE { \ switch ((yy_start - 1) / 2) { \ case 0: \ BEGIN F; \ break; \ } \ } #else /* not FLEX_SCANNER */ /* * Using old lex... */ # define INIT_STATE { \ switch (yybgin - yysvec - 1) { \ case 0: \ BEGIN F; \ break; \ } \ } #endif /* end FLEX_SCANNER */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ /* * Some systems include a definition for the macro ECHO in , * and their (bad) version of lex defines it too at the very beginning of * the generated lex.yy.c file (before it can be easily undefined), * resulting in a conflict. So undefine it here before needed. * Luckily, it does not appear that this macro is actually used in the rest * of the generated lex.yy.c file. */ #ifdef ECHO # undef ECHO #endif /* ECHO */ #include #include #include #include /* and once again undefine this, just in case */ #ifdef ECHO # undef ECHO #endif /* ECHO */ /* * There are some things that need to be defined only if using GNU flex. * These must not be defined if using standard lex */ #ifdef FLEX_SCANNER # ifndef ECHO # define ECHO __IGNORE(fwrite( yytext, yyleng, 1, yyout )) # endif /* not ECHO */ #endif /* FLEX_SCANNER */ /* * some systems such as DU-4.x have a different GNU flex in /usr/bin * which automatically generates yywrap macros and symbols. So I must * distinguish between them and when yywrap is actually needed. */ #if !defined(yywrap) || defined(yylex) int yywrap(void); #endif /* not yywrap or yylex */ int yyerror(const char *, ...); YYSTYPE yylval; static char *fsi_filename; static char *optr; static char ostr[1024]; static int find_resword(char *); static int quoted; struct r { char *rw; int tok; } rr[] = { { "->", tEQ }, { "arch", tARCH }, { "as", tAS }, { "automount", tAUTOMOUNT }, { "cluster", tCLUSTER }, { "config", tCONFIG }, { "direct", tDIRECT }, { "dumpset", tDUMPSET }, { "exportfs", tEXPORTFS }, { "freq", tFREQ }, { "from", tFROM }, { "fs", tFS }, { "fstype", tFSTYPE }, { "host", tHOST }, { "hwaddr", tHWADDR }, { "inaddr", tINADDR }, { "localhost", tLOCALHOST }, { "log", tLOG }, { "mount", tMOUNT }, { "netif", tNETIF }, { "netmask", tNETMASK }, { "nfsalias", tNFSEQ }, { "opts", tOPTS }, { "os", tOS }, { "passno", tPASSNO }, { "sel", tSEL }, { "volname", tVOLNAME }, { NULL, 0 }, }; #define NRES_WORDS (sizeof(rr)/sizeof(rr[0])-1) /* no need for input() */ #define YY_NO_INPUT %} /* This option causes Solaris lex to fail. Use flex. See BUGS file */ /* no need to use yyunput() */ %option nounput /* allocate more output slots so lex scanners don't run out of mem */ %o 1024 %start F Q %% INIT_STATE; /* witchcraft */ [^ \t\n"={}]+ { return find_resword(yytext); } /* dummy " */ [ \t] ; "\n" { ayylineno++; } [={}] { return *yytext; } \" { BEGIN Q; optr = ostr; quoted = 1; } \n { ayylineno++; yyerror("\" expected"); BEGIN F; } \\b { *optr++ = '\b'; /* escape */ } \\t { *optr++ = '\t'; /* escape */ } \\\" { *optr++ = '\"'; /* escape */ } \\\\ { *optr++ = '\\'; /* escape */ } \\\n { ayylineno++; /* continue */ } \\r { *optr++ = '\r'; /* escape */ } \\n { *optr++ = '\n'; /* escape */ } \\f { *optr++ = '\f'; /* escape */ } "\\ " { *optr++ = ' '; /* force space */ } \\. { yyerror("Unknown \\ sequence"); } ([ \t]|"\\\n"){2,} { char *p = (char *) yytext-1; while ((p = strchr(p+1, '\n'))) ayylineno++; } \" { BEGIN F; quoted = 0; *optr = '\0'; yylval.s = strdup(ostr); return tSTR; } . { *optr++ = *yytext; } %% static int find_resword(char *s) { int tok = 0; int l = 0, m = NRES_WORDS/2, h = NRES_WORDS-1; int rc = 0; m = NRES_WORDS/2; #define FSTRCMP(p, q) ((*(p) == *(q)) ? strcmp((p)+1, (q)+1) : *(p) - *(q)) while ((l <= h) && (rc = FSTRCMP(s, rr[m].rw))) { if (rc < 0) h = m - 1; else l = m + 1; m = (h + l) / 2; } if (rc == 0) tok = rr[m].tok; switch (tok) { case tLOCALHOST: s = "${host}"; /* fall through... */ case 0: yylval.s = strdup(s); tok = tSTR; /* fall through... */ default: return tok; } } int yyerror(const char *fmt, ...) { va_list ap; va_start(ap, fmt); col_cleanup(0); fprintf(stderr, "%s:%d: ", fsi_filename ? fsi_filename : "/dev/stdin", ayylineno); vfprintf(stderr, fmt, ap); fputc('\n', stderr); parse_errors++; va_end(ap); return 0; } ioloc * current_location(void) { ioloc *ip = CALLOC(struct ioloc); ip->i_line = ayylineno; ip->i_file = fsi_filename; return ip; } /* * some systems such as DU-4.x have a different GNU flex in /usr/bin * which automatically generates yywrap macros and symbols. So I must * distinguish between them and when yywrap is actually needed. */ #if !defined(yywrap) || defined(yylex) int yywrap(void) { return 1; } #endif /* not yywrap or yylex */ am-utils-6.2+rc20110530/fsinfo/fsi_util.c000066400000000000000000000262341157065440000176070ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * All rights reserved. * * 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. 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 * 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/fsinfo/fsi_util.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include /* static variables */ static int show_range = 10; static int col = 0; static int total_shown = 0; static int total_mmm = 8; static int col_output(int len) { int wrapped = 0; col += len; if (col > 77) { fputc('\n', stdout); col = len; wrapped = 1; } return wrapped; } static void show_total(void) { if (total_mmm != -show_range + 1) { char n[8]; int len; if (total_mmm < 0) fputc('*', stdout); xsnprintf(n, sizeof(n), "%d", total_shown); len = strlen(n); if (col_output(len)) fputc(' ', stdout); fputs(n, stdout); fflush(stdout); total_mmm = -show_range; } } void col_cleanup(int eoj) { if (verbose < 0) return; if (eoj) { show_total(); fputs(")]", stdout); } if (col) { fputc('\n', stdout); col = 0; } } /* * Lots of ways of reporting errors... */ void error(char *fmt, ...) { va_list ap; va_start(ap, fmt); col_cleanup(0); fprintf(stderr, "%s: Error, ", progname); vfprintf(stderr, fmt, ap); fputc('\n', stderr); errors++; va_end(ap); } void lerror(ioloc *l, char *fmt, ...) { va_list ap; va_start(ap, fmt); col_cleanup(0); fprintf(stderr, "%s:%d: ", l->i_file, l->i_line); vfprintf(stderr, fmt, ap); fputc('\n', stderr); errors++; va_end(ap); } void lwarning(ioloc *l, char *fmt, ...) { va_list ap; va_start(ap, fmt); col_cleanup(0); fprintf(stderr, "%s:%d: ", l->i_file, l->i_line); vfprintf(stderr, fmt, ap); fputc('\n', stderr); va_end(ap); } void fatal(char *fmt, ...) { va_list ap; va_start(ap, fmt); col_cleanup(1); fprintf(stderr, "%s: Fatal, ", progname); vfprintf(stderr, fmt, ap); fputc('\n', stderr); va_end(ap); exit(1); } /* * Debug log */ void fsi_log(char *fmt, ...) { va_list ap; if (verbose > 0) { va_start(ap, fmt); fputc('#', stdout); fprintf(stdout, "%s: ", progname); vfprintf(stdout, fmt, ap); putc('\n', stdout); va_end(ap); } } void info_hdr(FILE *ef, char *info) { fprintf(ef, "# *** NOTE: This file contains %s info\n", info); } void gen_hdr(FILE *ef, char *hn) { fprintf(ef, "# *** NOTE: Only for use on %s\n", hn); } static void make_banner(FILE *fp) { time_t t = time((time_t *) NULL); char *cp = ctime(&t); fprintf(fp, "\ # *** This file was automatically generated -- DO NOT EDIT HERE ***\n\ # \"%s\" run by %s@%s on %s\ #\n\ ", progname, username, hostname, cp); } void show_new(char *msg) { if (verbose < 0) return; total_shown++; if (total_mmm > show_range) { show_total(); } else if (total_mmm == 0) { fputc('*', stdout); fflush(stdout); col += 1; } total_mmm++; } void show_area_being_processed(char *area, int n) { static char *last_area = NULL; if (verbose < 0) return; if (last_area) { if (total_shown) show_total(); fputs(")", stdout); col += 1; } if (!last_area || !STREQ(area, last_area)) { if (last_area) { col_cleanup(0); total_shown = 0; total_mmm = show_range + 1; } (void) col_output(strlen(area) + 2); fprintf(stdout, "[%s", area); last_area = area; } fputs(" (", stdout); col += 2; show_range = n; total_mmm = n + 1; fflush(stdout); } /* * Open a file with the given prefix and name */ FILE * pref_open(char *pref, char *hn, void (*hdr) (FILE *, char *), char *arg) { char p[MAXPATHLEN]; FILE *ef; xsnprintf(p, sizeof(p), "%s%s", pref, hn); fsi_log("Writing %s info for %s to %s", pref, hn, p); ef = fopen(p, "w"); if (ef) { (*hdr) (ef, arg); make_banner(ef); } else { error("can't open %s for writing", p); } return ef; } int pref_close(FILE *fp) { return fclose(fp) == 0; } /* * Determine where Amd would automount the host/volname pair */ void compute_automount_point(char *buf, size_t l, host *hp, char *vn) { xsnprintf(buf, l, "%s/%s%s", autodir, hp->h_lochost, vn); } /* * Data constructors.. */ automount * new_automount(char *name) { automount *ap = CALLOC(struct automount); ap->a_ioloc = current_location(); ap->a_name = name; ap->a_volname = NULL; ap->a_mount = NULL; ap->a_opts = NULL; show_new("automount"); return ap; } auto_tree * new_auto_tree(char *def, qelem *ap) { auto_tree *tp = CALLOC(struct auto_tree); tp->t_ioloc = current_location(); tp->t_defaults = def; tp->t_mount = ap; show_new("auto_tree"); return tp; } host * new_host(void) { host *hp = CALLOC(struct host); hp->h_ioloc = current_location(); hp->h_mask = 0; show_new("host"); return hp; } void set_host(host *hp, int k, char *v) { int m = 1 << k; if (hp->h_mask & m) { fsi_yyerror("host field \"%s\" already set", host_strings[k]); return; } hp->h_mask |= m; switch (k) { case HF_HOST:{ char *p = strdup(v); dict_ent *de = dict_locate(dict_of_hosts, v); if (de) fsi_yyerror("duplicate host %s!", v); else dict_add(dict_of_hosts, v, (char *) hp); hp->h_hostname = v; domain_strip(p, hostname); if (strchr(p, '.') != 0) XFREE(p); else hp->h_lochost = p; } break; case HF_CONFIG:{ qelem *q; qelem *vq = (qelem *) v; hp->h_mask &= ~m; if (hp->h_config) q = hp->h_config; else q = hp->h_config = new_que(); ins_que(vq, q->q_back); } break; case HF_ETHER:{ qelem *q; qelem *vq = (qelem *) v; hp->h_mask &= ~m; if (hp->h_ether) q = hp->h_ether; else q = hp->h_ether = new_que(); ins_que(vq, q->q_back); } break; case HF_ARCH: hp->h_arch = v; break; case HF_OS: hp->h_os = v; break; case HF_CLUSTER: hp->h_cluster = v; break; default: abort(); break; } } ether_if * new_ether_if(void) { ether_if *ep = CALLOC(struct ether_if); ep->e_mask = 0; ep->e_ioloc = current_location(); show_new("ether_if"); return ep; } void set_ether_if(ether_if *ep, int k, char *v) { int m = 1 << k; if (ep->e_mask & m) { fsi_yyerror("netif field \"%s\" already set", ether_if_strings[k]); return; } ep->e_mask |= m; switch (k) { case EF_INADDR:{ ep->e_inaddr.s_addr = inet_addr(v); if ((int) ep->e_inaddr.s_addr == (int) INADDR_NONE) fsi_yyerror("malformed IP dotted quad: %s", v); XFREE(v); } break; case EF_NETMASK:{ u_long nm = 0; if ((sscanf(v, "0x%lx", &nm) == 1 || sscanf(v, "%lx", &nm) == 1) && nm != 0) ep->e_netmask = htonl(nm); else fsi_yyerror("malformed netmask: %s", v); XFREE(v); } break; case EF_HWADDR: ep->e_hwaddr = v; break; default: abort(); break; } } void set_disk_fs(disk_fs *dp, int k, char *v) { int m = 1 << k; if (dp->d_mask & m) { fsi_yyerror("fs field \"%s\" already set", disk_fs_strings[k]); return; } dp->d_mask |= m; switch (k) { case DF_FSTYPE: dp->d_fstype = v; break; case DF_OPTS: dp->d_opts = v; break; case DF_DUMPSET: dp->d_dumpset = v; break; case DF_LOG: dp->d_log = v; break; case DF_PASSNO: dp->d_passno = atoi(v); XFREE(v); break; case DF_FREQ: dp->d_freq = atoi(v); XFREE(v); break; case DF_MOUNT: dp->d_mount = &((fsi_mount *) v)->m_q; break; default: abort(); break; } } disk_fs * new_disk_fs(void) { disk_fs *dp = CALLOC(struct disk_fs); dp->d_ioloc = current_location(); show_new("disk_fs"); return dp; } void set_mount(fsi_mount *mp, int k, char *v) { int m = 1 << k; if (mp->m_mask & m) { fsi_yyerror("mount tree field \"%s\" already set", mount_strings[k]); return; } mp->m_mask |= m; switch (k) { case DM_VOLNAME: dict_add(dict_of_volnames, v, (char *) mp); mp->m_volname = v; break; case DM_EXPORTFS: mp->m_exportfs = v; break; case DM_SEL: mp->m_sel = v; break; default: abort(); break; } } fsi_mount * new_mount(void) { fsi_mount *fp = CALLOC(struct fsi_mount); fp->m_ioloc = current_location(); show_new("mount"); return fp; } void set_fsmount(fsmount *fp, int k, char *v) { int m = 1 << k; if (fp->f_mask & m) { fsi_yyerror("mount field \"%s\" already set", fsmount_strings[k]); return; } fp->f_mask |= m; switch (k) { case FM_LOCALNAME: fp->f_localname = v; break; case FM_VOLNAME: fp->f_volname = v; break; case FM_FSTYPE: fp->f_fstype = v; break; case FM_OPTS: fp->f_opts = v; break; case FM_FROM: fp->f_from = v; break; case FM_DIRECT: break; default: abort(); break; } } fsmount * new_fsmount(void) { fsmount *fp = CALLOC(struct fsmount); fp->f_ioloc = current_location(); show_new("fsmount"); return fp; } void init_que(qelem *q) { q->q_forw = q->q_back = q; } qelem * new_que(void) { qelem *q = CALLOC(qelem); init_que(q); return q; } void ins_que(qelem *elem, qelem *pred) { qelem *p; p = pred->q_forw; elem->q_back = pred; elem->q_forw = p; pred->q_forw = elem; p->q_back = elem; } void rem_que(qelem *elem) { qelem *p, *p2; p = elem->q_forw; p2 = elem->q_back; p2->q_forw = p; p->q_back = p2; } am-utils-6.2+rc20110530/fsinfo/fsinfo.8000066400000000000000000000063241157065440000172000ustar00rootroot00000000000000.\" .\" Copyright (c) 1997-2011 Erez Zadok .\" Copyright (c) 1993 Jan-Simon Pendry. .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" 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. 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 .\" 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/fsinfo/fsinfo.8 .\" .TH FSINFO 8 "June 28, 1993" .SH NAME fsinfo \- coordinate site-wide filesystem information .SH SYNOPSIS .B fsinfo [ .B \-v ] [ .B \-a .I autodir ] [ .B \-b .I bootparams ] [ .B \-d .I dumpsets ] [ .B \-e .I exports ] [ .B \-f .I fstabs ] [ .B \-h .I hostname ] [ .B \-m .I automounts ] [ .B \-I .I dir ] [ .B \-D .I string[=string] ] [ .B \-U .I string[=string] ] .I config .I ... .SH DESCRIPTION The .B fsinfo utility takes a set of system configuration information, and generates a coordinated set of .I amd , .I mount and .I mountd configuration files. .PP The .B fsinfo command is fully described in the document .I "Amd - The 4.4BSD Automounter" .SH "SEE ALSO" .BR amd (8), .BR mount (8), .BR mountd (8). .LP ``am-utils'' .BR info (1) entry. .LP .I "Linux NFS and Automounter Administration" by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). .LP .I http://www.am-utils.org .LP .I "Amd \- The 4.4 BSD Automounter" .SH HISTORY The .B fsinfo command first appeared in 4.4BSD. .SH AUTHORS Jan-Simon Pendry , Department of Computing, Imperial College, London, UK. .P Erez Zadok , Computer Science Department, Stony Brook University, Stony Brook, New York, USA. .P Other authors and contributors to am-utils are listed in the .B AUTHORS file distributed with am-utils. am-utils-6.2+rc20110530/fsinfo/fsinfo.c000066400000000000000000000143411157065440000172510ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/fsinfo/fsinfo.c * */ /* * fsinfo */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include #include /* globals */ char **g_argv; char *autodir = "/a"; char *progname; char hostname[MAXHOSTNAMELEN + 1]; char *username; char idvbuf[1024]; dict *dict_of_hosts; dict *dict_of_volnames; int errors; int file_io_errors; int parse_errors; int verbose; qelem *list_of_automounts; qelem *list_of_hosts; /* * Output file prefixes */ char *bootparams_pref; char *dumpset_pref; char *exportfs_pref; char *fstab_pref; char *mount_pref; /* * Argument cracking... */ static void fsi_get_args(int c, char *v[]) { int ch; int usage = 0; char *iptr = idvbuf; /* * Determine program name */ if (v[0]) { progname = strrchr(v[0], '/'); if (progname && progname[1]) progname++; else progname = v[0]; } if (!progname) progname = "fsinfo"; while ((ch = getopt(c, v, "a:b:d:e:f:h:m:D:U:I:qv")) != -1) switch (ch) { case 'a': autodir = optarg; break; case 'b': if (bootparams_pref) fatal("-b option specified twice"); bootparams_pref = optarg; break; case 'd': if (dumpset_pref) fatal("-d option specified twice"); dumpset_pref = optarg; break; case 'h': xstrlcpy(hostname, optarg, sizeof(hostname)); break; case 'e': if (exportfs_pref) fatal("-e option specified twice"); exportfs_pref = optarg; break; case 'f': if (fstab_pref) fatal("-f option specified twice"); fstab_pref = optarg; break; case 'm': if (mount_pref) fatal("-m option specified twice"); mount_pref = optarg; break; case 'q': verbose = -1; break; case 'v': verbose = 1; break; case 'I': case 'D': case 'U': /* sizeof(iptr) is actually that of idvbuf. See declaration above */ xsnprintf(iptr, sizeof(idvbuf), "-%c%s ", ch, optarg); iptr += strlen(iptr); break; default: usage++; break; } if (c != optind) { g_argv = v + optind - 1; #ifdef yywrap if (yywrap()) #endif /* yywrap */ fatal("Cannot read any input files"); } else { usage++; } if (usage) { fprintf(stderr, "\ Usage: %s [-v] [-a autodir] [-h hostname] [-b bootparams] [-d dumpsets]\n\ \t[-e exports] [-f fstabs] [-m automounts]\n\ \t[-I dir] [-D|-U string[=string]] config ...\n", progname); exit(1); } if (g_argv[0]) fsi_log("g_argv[0] = %s", g_argv[0]); else fsi_log("g_argv[0] = (nil)"); } /* * Determine username of caller */ static char * find_username(void) { const char *u = getlogin(); if (!u) { struct passwd *pw = getpwuid(getuid()); if (pw) u = pw->pw_name; } if (!u) u = getenv("USER"); if (!u) u = getenv("LOGNAME"); if (!u) u = "root"; return strdup(u); } /* * MAIN */ int main(int argc, char *argv[]) { /* * Process arguments */ fsi_get_args(argc, argv); /* * If no hostname given then use the local name */ if (!*hostname && gethostname(hostname, sizeof(hostname)) < 0) { perror("gethostname"); exit(1); } hostname[sizeof(hostname) - 1] = '\0'; /* * Get the username */ username = find_username(); /* * New hosts and automounts */ list_of_hosts = new_que(); list_of_automounts = new_que(); /* * New dictionaries */ dict_of_volnames = new_dict(); dict_of_hosts = new_dict(); /* * Parse input */ show_area_being_processed("read config", 11); if (fsi_yyparse()) errors = 1; errors += file_io_errors + parse_errors; if (errors == 0) { /* * Do semantic analysis of input */ analyze_hosts(list_of_hosts); analyze_automounts(list_of_automounts); } /* * Give up if errors */ if (errors == 0) { /* * Output data files */ write_atab(list_of_automounts); write_bootparams(list_of_hosts); write_dumpset(list_of_hosts); write_exportfs(list_of_hosts); write_fstab(list_of_hosts); } col_cleanup(1); exit(errors); return errors; /* should never reach here */ } am-utils-6.2+rc20110530/fsinfo/fsinfo.h000066400000000000000000000130731157065440000172570ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/fsinfo/fsinfo.h * */ extern FILE *pref_open(char *pref, char *hn, void (*hdr) (FILE *, char *), char *arg); extern auto_tree *new_auto_tree(char *, qelem *); extern automount *new_automount(char *); extern char **g_argv; extern char *autodir; extern char *bootparams_pref; extern char *disk_fs_strings[]; extern char *dumpset_pref; extern char *ether_if_strings[]; extern char *exportfs_pref; extern char *fsmount_strings[]; extern char *fstab_pref; extern char *host_strings[]; extern char *mount_pref; extern char *mount_strings[]; extern char *progname; extern char *username; extern char *xcalloc(int, int); extern char hostname[]; extern char idvbuf[]; extern dict *dict_of_hosts; extern dict *dict_of_volnames; extern dict *new_dict(void); extern dict_ent *dict_locate(dict *, char *); extern disk_fs *new_disk_fs(void); extern ether_if *new_ether_if(void); extern fsmount *new_fsmount(void); extern host *new_host(void); extern int dict_iter(dict *, int (*)(qelem *)); extern int errors; extern int file_io_errors; extern int parse_errors; extern int pref_close(FILE *fp); extern int verbose; extern ioloc *current_location(void); extern fsi_mount *new_mount(void); extern qelem *new_que(void); extern void analyze_automounts(qelem *); extern void analyze_hosts(qelem *); extern void compute_automount_point(char *, size_t, host *, char *); extern void dict_add(dict *, char *, char *); extern void error(char *fmt, ...) __attribute__((__format__(__printf__, 1, 2))); extern void fatal(char *fmt, ...) __attribute__((__format__(__printf__, 1, 2))); extern void gen_hdr(FILE *ef, char *hn); extern void info_hdr(FILE *ef, char *info); extern void init_que(qelem *); extern void ins_que(qelem *, qelem *); extern void lerror(ioloc *l, char *fmt, ...) __attribute__((__format__(__printf__, 2, 3))); extern void fsi_log(char *fmt, ...) __attribute__((__format__(__printf__, 1, 2))); extern void lwarning(ioloc *l, char *fmt, ...) __attribute__((__format__(__printf__, 2, 3))); extern void rem_que(qelem *); extern void set_disk_fs(disk_fs *, int, char *); extern void set_fsmount(fsmount *, int, char *); extern void set_mount(fsi_mount *, int, char *); extern void show_area_being_processed(char *area, int n); extern void show_new(char *msg); extern void warning(void); extern int yyerror(const char *fmt, ...) __attribute__((__format__(__printf__, 1, 2))); extern int fsi_yyerror(const char *fmt, ...) __attribute__((__format__(__printf__, 1, 2))); extern void domain_strip(char *otherdom, char *localdom); /* * some systems such as DU-4.x have a different GNU flex in /usr/bin * which automatically generates yywrap macros and symbols. So I must * distinguish between them and when yywrap is actually needed. */ #ifndef yywrap extern int yywrap(void); #endif /* not yywrap */ extern int yyparse(void); extern int fsi_yyparse(void); extern int write_atab(qelem *q); extern int write_bootparams(qelem *q); extern int write_dumpset(qelem *q); extern int write_exportfs(qelem *q); extern int write_fstab(qelem *q); extern void col_cleanup(int eoj); extern void set_host(host *hp, int k, char *v); extern void set_ether_if(ether_if *ep, int k, char *v); extern int yylex(void); extern int fsi_yylex(void); #define BITSET(m,b) ((m) |= (1<<(b))) #define AM_FIRST(ty, q) ((ty *) ((q)->q_forw)) #define HEAD(ty, q) ((ty *) q) #define ISSET(m,b) ((m) & (1<<(b))) #define ITER(v, ty, q) for ((v) = AM_FIRST(ty,(q)); (v) != HEAD(ty,(q)); (v) = NEXT(ty,(v))) #define AM_LAST(ty, q) ((ty *) ((q)->q_back)) #define NEXT(ty, q) ((ty *) (((qelem *) q)->q_forw)) am-utils-6.2+rc20110530/fsinfo/null_gram.y000066400000000000000000000001161157065440000177660ustar00rootroot00000000000000%{ void yyerror(const char *fmt, ...); extern int yylex(void); %} %% token: am-utils-6.2+rc20110530/fsinfo/null_lex.l000066400000000000000000000002121157065440000176100ustar00rootroot00000000000000%{ #include "null_gram.h" #define YY_NO_INPUT void yyerror(const char *fmt, ...) {} int yywrap(void) { return 0; } %} %option nounput %% am-utils-6.2+rc20110530/fsinfo/wr_atab.c000066400000000000000000000215251157065440000174060ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/fsinfo/wr_atab.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include /* * Write a sequence of automount mount map entries */ static int write_amount_info(FILE *af, automount *ap, u_int sk) { int errors = 0; if (ap->a_mount) { /* * A pseudo-directory. * This can also be a top-level directory, in which * case the type:=auto is not wanted... * * type:=auto;fs:=${map};pref:=whatever/ */ automount *ap2; if (strlen(ap->a_name) > sk) { fprintf(af, "%s type:=auto;fs:=${map};pref:=%s/\n", ap->a_name + sk, ap->a_name + sk); } ITER(ap2, automount, ap->a_mount) errors += write_amount_info(af, ap2, sk); } else if (ap->a_hardwiredfs) { /* * A hardwired filesystem "hostname:path" * rhost:=hostname;rfs:=path */ char *key = ap->a_name + sk; char *hostname = ap->a_hardwiredfs; char *path = strrchr(hostname, (int) ':'); if (path == NULL) { fprintf(stderr, "%s: %s not an NFS filesystem\n", ap->a_name, ap->a_hardwiredfs); errors++; } else { *path = '\0'; path++; /* * Output the map key */ fputs(key, af); fprintf(af, " rhost:=%s", hostname); fprintf(af, ";rfs:=%s", path); if (ap->a_opts && !STREQ(ap->a_opts, "")) { fprintf(af, ";%s", ap->a_opts); } fputc('\n', af); path--; *path = ':'; } } else if (ap->a_mounted) { /* * A mounted partition * type:=link [ link entries ] type:=nfs [ nfs entries ] */ dict_data *dd; dict_ent *de = ap->a_mounted; int done_type_link = 0; char *key = ap->a_name + sk; /* * Output the map key */ fputs(key, af); /* * First output any Link locations that would not * otherwise be correctly mounted. These refer * to filesystem which are not mounted in the same * place which the automounter would use. */ ITER(dd, dict_data, &de->de_q) { fsi_mount *mp = (fsi_mount *) dd->dd_data; /* * If the mount point and the exported volname are the * same then this filesystem will be recognized by * the restart code - so we don't need to put out a * special rule for it. */ if (mp->m_dk->d_host->h_lochost) { char amountpt[1024]; compute_automount_point(amountpt, sizeof(amountpt), mp->m_dk->d_host, mp->m_exported->m_volname); if (!STREQ(mp->m_dk->d_mountpt, amountpt)) { /* * ap->a_volname is the name of the aliased volume * mp->m_name is the mount point of the filesystem * mp->m_volname is the volume name of the filesystems */ /* * Find length of key and volume names */ int avlen = strlen(ap->a_volname); int mnlen = strlen(mp->m_volname); /* * Make sure a -type:=link is output once */ if (!done_type_link) { done_type_link = 1; fputs(" -type:=link", af); } /* * Output a selector for the hostname, * the device from which to mount and * where to mount. This will correspond * to the values output for the fstab. */ if (mp->m_dk->d_host->h_lochost) fprintf(af, " host==%s", mp->m_dk->d_host->h_lochost); else fprintf(af, " hostd==%s", mp->m_dk->d_host->h_hostname); fprintf(af, ";fs:=%s", mp->m_name); /* * ... and a sublink if needed */ if (mnlen < avlen) { char *sublink = ap->a_volname + mnlen + 1; fprintf(af, "/%s", sublink); } fputs(" ||", af); } } } /* * Next do the NFS locations */ if (done_type_link) fputs(" -", af); ITER(dd, dict_data, &de->de_q) { fsi_mount *mp = (fsi_mount *) dd->dd_data; int namelen = mp->m_name_len; int exp_namelen = mp->m_exported->m_name_len; int volnlen = strlen(ap->a_volname); int mvolnlen = strlen(mp->m_volname); fputc(' ', af); /* * Output any selectors */ if (mp->m_sel) fprintf(af, "%s;", mp->m_sel); /* * Print host and volname of exported filesystem */ fprintf(af, "rhost:=%s", mp->m_dk->d_host->h_lochost ? mp->m_dk->d_host->h_lochost : mp->m_dk->d_host->h_hostname); fprintf(af, ";rfs:=%s", mp->m_exported->m_volname); if (ap->a_opts && !STREQ(ap->a_opts, "")) { fprintf(af, ";%s", ap->a_opts); } /* * Now determine whether a sublink is required. */ if (exp_namelen < namelen || mvolnlen < volnlen) { char sublink[1024]; sublink[0] = '\0'; if (exp_namelen < namelen) { xstrlcat(sublink, mp->m_name + exp_namelen + 1, sizeof(sublink)); if (mvolnlen < volnlen) xstrlcat(sublink, "/", sizeof(sublink)); } if (mvolnlen < volnlen) xstrlcat(sublink, ap->a_volname + mvolnlen + 1, sizeof(sublink)); fprintf(af, ";sublink:=%s", sublink); } } fputc('\n', af); } else if (ap->a_symlink) { /* * A specific link. * * type:=link;fs:=whatever */ fprintf(af, "%s type:=link;fs:=%s\n", ap->a_name + sk, ap->a_symlink); } return errors; } /* * Write a single automount configuration file */ static int write_amount( qelem *q, char *def) { automount *ap; int errors = 0; int direct = 0; /* * Output all indirect maps */ ITER(ap, automount, q) { FILE *af; char *p; /* * If there is no a_mount node then this is really * a direct mount, so just keep a count and continue. * Direct mounts are output into a special file during * the second pass below. */ if (!ap->a_mount) { direct++; continue; } p = strrchr(ap->a_name, '/'); if (!p) p = ap->a_name; else p++; af = pref_open(mount_pref, p, gen_hdr, ap->a_name); if (af) { show_new(ap->a_name); fputs("/defaults ", af); if (*def) fprintf(af, "%s;", def); fputs("type:=nfs\n", af); errors += write_amount_info(af, ap, strlen(ap->a_name) + 1); errors += pref_close(af); } } /* * Output any direct map entries which were found during the * previous pass over the data. */ if (direct) { FILE *af = pref_open(mount_pref, "direct.map", info_hdr, "direct mount"); if (af) { show_new("direct mounts"); fputs("/defaults ", af); if (*def) fprintf(af, "%s;", def); fputs("type:=nfs\n", af); ITER(ap, automount, q) if (!ap->a_mount) errors += write_amount_info(af, ap, 1); errors += pref_close(af); } } return errors; } /* * Write all the needed automount configuration files */ int write_atab(qelem *q) { int errors = 0; if (mount_pref) { auto_tree *tp; show_area_being_processed("write automount", 5); ITER(tp, auto_tree, q) errors += write_amount(tp->t_mount, tp->t_defaults); } return errors; } am-utils-6.2+rc20110530/fsinfo/wr_bparam.c000066400000000000000000000063631157065440000177440ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/fsinfo/wr_bparam.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include /* * Write a host/path in NFS format */ static int write_nfsname(FILE *ef, fsmount *fp, char *hn) { int errors = 0; char *h = strdup(fp->f_ref->m_dk->d_host->h_hostname); domain_strip(h, hn); fprintf(ef, "%s:%s", h, fp->f_volname); XFREE(h); return errors; } /* * Write a bootparams entry for a host */ static int write_boot_info(FILE *ef, host *hp) { int errors = 0; fprintf(ef, "%s\troot=", hp->h_hostname); errors += write_nfsname(ef, hp->h_netroot, hp->h_hostname); fputs(" swap=", ef); errors += write_nfsname(ef, hp->h_netswap, hp->h_hostname); fputs("\n", ef); return 0; } /* * Output a bootparams file */ int write_bootparams(qelem *q) { int errors = 0; if (bootparams_pref) { FILE *ef = pref_open(bootparams_pref, "bootparams", info_hdr, "bootparams"); if (ef) { host *hp; ITER(hp, host, q) if (hp->h_netroot && hp->h_netswap) errors += write_boot_info(ef, hp); errors += pref_close(ef); } else { errors++; } } return errors; } am-utils-6.2+rc20110530/fsinfo/wr_dumpset.c000066400000000000000000000057301157065440000201600ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/fsinfo/wr_dumpset.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include static int write_dumpset_info(FILE *ef, qelem *q) { int errors = 0; disk_fs *dp; ITER(dp, disk_fs, q) { if (dp->d_dumpset) { fprintf(ef, "%s\t%s:%-30s\t# %s\n", dp->d_dumpset, dp->d_host->h_lochost ? dp->d_host->h_lochost : dp->d_host->h_hostname, dp->d_mountpt, dp->d_dev); } } return errors; } int write_dumpset(qelem *q) { int errors = 0; if (dumpset_pref) { FILE *ef = pref_open(dumpset_pref, "dumpsets", info_hdr, "exabyte dumpset"); if (ef) { host *hp; ITER(hp, host, q) { if (hp->h_disk_fs) { errors += write_dumpset_info(ef, hp->h_disk_fs); } } errors += pref_close(ef); } else { errors++; } } return errors; } am-utils-6.2+rc20110530/fsinfo/wr_exportfs.c000066400000000000000000000062721157065440000203530ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/fsinfo/wr_exportfs.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include static int write_export_info(FILE *ef, qelem *q, int errors) { fsi_mount *mp; ITER(mp, fsi_mount, q) { if (mp->m_mask & (1 << DM_EXPORTFS)) fprintf(ef, "%s\t%s\n", mp->m_volname, mp->m_exportfs); if (mp->m_mount) errors += write_export_info(ef, mp->m_mount, 0); } return errors; } static int write_dkexports(FILE *ef, qelem *q) { int errors = 0; disk_fs *dp; ITER(dp, disk_fs, q) { if (dp->d_mount) errors += write_export_info(ef, dp->d_mount, 0); } return errors; } int write_exportfs(qelem *q) { int errors = 0; if (exportfs_pref) { host *hp; show_area_being_processed("write exportfs", 5); ITER(hp, host, q) { if (hp->h_disk_fs) { FILE *ef = pref_open(exportfs_pref, hp->h_hostname, gen_hdr, hp->h_hostname); if (ef) { show_new(hp->h_hostname); errors += write_dkexports(ef, hp->h_disk_fs); errors += pref_close(ef); } else { errors++; } } } } return errors; } am-utils-6.2+rc20110530/fsinfo/wr_fstab.c000066400000000000000000000205201157065440000175700ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/fsinfo/wr_fstab.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #include #define GENERIC_OS_NAME "generic" /* forward definitions */ static void write_aix1_dkfstab(FILE *ef, disk_fs *dp); static void write_aix1_dkrmount(FILE *ef, char *hn, fsmount *fp); static void write_aix3_dkfstab(FILE *ef, disk_fs *dp); static void write_aix3_dkrmount(FILE *ef, char *hn, fsmount *fp); static int write_dkfstab(FILE *ef, qelem *q, void (*output) (FILE *, disk_fs *)); static int write_dkrmount(FILE *ef, qelem *q, char *hn, void (*output) (FILE *, char *, fsmount *)); static void write_generic_dkfstab(FILE *ef, disk_fs *dp); static void write_generic_dkrmount(FILE *ef, char *hn, fsmount *fp); static void write_ultrix_dkfstab(FILE *ef, disk_fs *dp); static void write_ultrix_dkrmount(FILE *ef, char *hn, fsmount *fp); /* ----------------------------------------------- */ static struct os_fstab_type { char *os_name; void (*op_fstab) (FILE *ef, disk_fs *dp); void (*op_mount) (FILE *ef, char *hn, fsmount *fp); } os_tabs[] = { { "aix1", write_aix1_dkfstab, write_aix1_dkrmount }, /* AIX 1 */ { "aix3", write_aix3_dkfstab, write_aix3_dkrmount }, /* AIX 3 */ { "generic", write_generic_dkfstab, write_generic_dkrmount }, /* Generic */ { "u2_0", write_ultrix_dkfstab, write_ultrix_dkrmount }, /* Ultrix */ { "u3_0", write_ultrix_dkfstab, write_ultrix_dkrmount }, /* Ultrix */ { "u4_0", write_ultrix_dkfstab, write_ultrix_dkrmount }, /* Ultrix */ { NULL, NULL, NULL } }; /* ---------- AIX 1 ------------------------------ */ /* * AIX 1 format */ static void write_aix1_dkfstab(FILE *ef, disk_fs *dp) { char *hp = strdup(dp->d_host->h_hostname); char *p = strchr(hp, '.'); if (p) *p = '\0'; fprintf(ef, "\n%s:\n\tdev = %s\n\tvfs = %s\n\ttype = %s\n\tlog = %s\n\tvol = %s\n\topts = %s\n\tmount = true\n\tcheck = true\n\tfree = false\n", dp->d_mountpt, dp->d_dev, dp->d_fstype, dp->d_fstype, dp->d_log, dp->d_mountpt, dp->d_opts); XFREE(hp); } static void write_aix1_dkrmount(FILE *ef, char *hn, fsmount *fp) { char *h = strdup(fp->f_ref->m_dk->d_host->h_hostname); char *hp = strdup(h); char *p = strchr(hp, '.'); if (p) *p = '\0'; domain_strip(h, hn); fprintf(ef, "\n%s:\n\tsite = %s\n\tdev = %s:%s\n\tvfs = %s\n\ttype = %s\n\tvol = %s\n\topts = %s\n\tmount = true\n\tcheck = true\n\tfree = false\n", fp->f_localname, hp, h, fp->f_volname, fp->f_fstype, fp->f_fstype, fp->f_localname, fp->f_opts); XFREE(hp); XFREE(h); } /* ---------- AIX 3 ------------------------------ */ /* * AIX 3 format */ static void write_aix3_dkfstab(FILE *ef, disk_fs *dp) { if (STREQ(dp->d_fstype, "jfs") && NSTREQ(dp->d_dev, "/dev/", 5) && !dp->d_log) error("aix 3 needs a log device for journalled filesystem (jfs) mounts"); fprintf(ef, "\n%s:\n\tdev = %s\n\tvfs = %s\n\ttype = %s\n\tlog = %s\n\tvol = %s\n\topts = %s\n\tmount = true\n\tcheck = true\n\tfree = false\n", dp->d_mountpt, dp->d_dev, dp->d_fstype, dp->d_fstype, dp->d_log, dp->d_mountpt, dp->d_opts); } static void write_aix3_dkrmount(FILE *ef, char *hn, fsmount *fp) { char *h = strdup(fp->f_ref->m_dk->d_host->h_hostname); domain_strip(h, hn); fprintf(ef, "\n%s:\n\tdev = %s:%s\n\tvfs = %s\n\ttype = %s\n\tvol = %s\n\topts = %s\n\tmount = true\n\tcheck = true\n\tfree = false\n", fp->f_localname, h, fp->f_volname, fp->f_fstype, fp->f_fstype, fp->f_localname, fp->f_opts); XFREE(h); } /* ---------- Ultrix ----------------------------- */ static void write_ultrix_dkfstab(FILE *ef, disk_fs *dp) { fprintf(ef, "%s:%s:%s:%s:%d:%d\n", dp->d_dev, dp->d_mountpt, dp->d_fstype, dp->d_opts, dp->d_freq, dp->d_passno); } static void write_ultrix_dkrmount(FILE *ef, char *hn, fsmount *fp) { char *h = strdup(fp->f_ref->m_dk->d_host->h_hostname); domain_strip(h, hn); fprintf(ef, "%s@%s:%s:%s:%s:0:0\n", fp->f_volname, h, fp->f_localname, fp->f_fstype, fp->f_opts); XFREE(h); } /* ---------- Generic ---------------------------- */ /* * Generic (BSD, SunOS, HPUX) format */ static void write_generic_dkfstab(FILE *ef, disk_fs *dp) { fprintf(ef, "%s %s %s %s %d %d\n", dp->d_dev, dp->d_mountpt, dp->d_fstype, dp->d_opts, dp->d_freq, dp->d_passno); } static void write_generic_dkrmount(FILE *ef, char *hn, fsmount *fp) { char *h; if (fp->f_ref) { h = strdup(fp->f_ref->m_dk->d_host->h_hostname); } else { h = strdup(fp->f_from); } domain_strip(h, hn); fprintf(ef, "%s:%s %s %s %s 0 0\n", h, fp->f_volname, fp->f_localname, fp->f_fstype, fp->f_opts); XFREE(h); } static struct os_fstab_type * find_fstab_type(host *hp) { struct os_fstab_type *op = NULL; char *os_name = NULL; again:; if (os_name == 0) { if (ISSET(hp->h_mask, HF_OS)) os_name = hp->h_os; else os_name = GENERIC_OS_NAME; } for (op = os_tabs; op->os_name; op++) if (STREQ(os_name, op->os_name)) return op; os_name = GENERIC_OS_NAME; goto again; } static int write_dkfstab(FILE *ef, qelem *q, void (*output) (FILE *, disk_fs *)) { int errors = 0; disk_fs *dp; ITER(dp, disk_fs, q) if (!STREQ(dp->d_fstype, "export")) (*output) (ef, dp); return errors; } static int write_dkrmount(FILE *ef, qelem *q, char *hn, void (*output) (FILE *, char *, fsmount *)) { int errors = 0; fsmount *fp; ITER(fp, fsmount, q) (*output) (ef, hn, fp); return errors; } int write_fstab(qelem *q) { int errors = 0; if (fstab_pref) { host *hp; show_area_being_processed("write fstab", 4); ITER(hp, host, q) { if (hp->h_disk_fs || hp->h_mount) { FILE *ef = pref_open(fstab_pref, hp->h_hostname, gen_hdr, hp->h_hostname); if (ef) { struct os_fstab_type *op = find_fstab_type(hp); show_new(hp->h_hostname); if (hp->h_disk_fs) errors += write_dkfstab(ef, hp->h_disk_fs, op->op_fstab); else fsi_log("No local disk mounts on %s", hp->h_hostname); if (hp->h_mount) errors += write_dkrmount(ef, hp->h_mount, hp->h_hostname, op->op_mount); pref_close(ef); } } else { error("no disk mounts on %s", hp->h_hostname); } } } return errors; } am-utils-6.2+rc20110530/hlfsd/000077500000000000000000000000001157065440000154325ustar00rootroot00000000000000am-utils-6.2+rc20110530/hlfsd/.cvsignore000066400000000000000000000000141157065440000174250ustar00rootroot00000000000000Makefile.in am-utils-6.2+rc20110530/hlfsd/Makefile.am000066400000000000000000000016531157065440000174730ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in # Package: am-utils # Level: Makefile for hlfsd/ directory # Author: Erez Zadok sbin_PROGRAMS = hlfsd # man pages man_MANS = hlfsd.8 # headers this depends on, not to be installed noinst_HEADERS = hlfsd.h hlfsd_SOURCES = \ hlfsd.c \ homedir.c \ nfs_prot_svc.c \ stubs.c LDADD = ../libamu/libamu.la INCLUDES = -I$(top_srcdir)/include # allow users to add their own flags via "configure --enable-am-flags=ARG" AMU_CFLAGS = @AMU_CFLAGS@ AM_CFLAGS = @CFLAGS@ $(AMU_CFLAGS) # additional files to distribute and clean EXTRA_DIST = $(man_MANS) # dependencies $(PROGRAMS): $(LDADD) $(hlfsd_OBJECTS): \ ../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) am-utils-6.2+rc20110530/hlfsd/hlfsd.8000066400000000000000000000232451157065440000166310ustar00rootroot00000000000000.\" .\" Copyright (c) 1997-2011 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. .\" 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. 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 .\" 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/hlfsd/hlfsd.8 .\" .\" HLFSD was written at Columbia University Computer Science Department, by .\" Erez Zadok and Alexander Dupuy .\" It is distributed under the same terms and conditions as AMD. .\" .TH HLFSD 8 "14 September 1993" .SH NAME hlfsd \- home-link file system daemon .SH SYNOPSIS .B hlfsd [ .B \-fhnpvC ] [ .BI \-a " alt_dir" ] [ .BI \-c " cache-interval" ] [ .BI \-g " group" ] [ .BI \-i " reload-interval" ] [ .BI \-l " logfile" ] [ .BI \-o " mount-options" ] [ .BI \-x " log-options" ] [ .BI \-D " debug-options" ] [ .BI \-P " password-file" ] [ .I linkname .RI [ " subdir " ] ] .SH DESCRIPTION .B Hlfsd is a daemon which implements a filesystem containing a symbolic link to subdirectory within a user's home directory, depending on the user which accessed that link. It was primarily designed to redirect incoming mail to users' home directories, so that it can read from anywhere. .LP .B Hlfsd operates by mounting itself as an .SM NFS server for the directory containing .IR linkname , which defaults to .BR /hlfs/home . Lookups within that directory are handled by .BR hlfsd , which uses the password map to determine how to resolve the lookup. The directory will be created if it doesn't already exist. The symbolic link will be to the accessing user's home directory, with .I subdir appended to it. If not specified, .I subdir defaults to .BR .hlfsdir . This directory will also be created if it does not already exist. .LP A SIGTERM sent to .B hlfsd will cause it to shutdown. A SIGHUP will flush the internal caches, and reload the password map. It will also close and reopen the log file, to enable the original log file to be removed or rotated. A SIGUSR1 will cause it to dump its internal table of user IDs and home directories to the file .BR /usr/tmp/hlfsd.dump.XXXXXX . .SH OPTIONS .TP .BI \-a " alt_dir" Alternate directory. The name of the directory to which the symbolic link returned by .B hlfsd will point, if it cannot access the home directory of the user. This defaults to .BR /var/hlfs . This directory will be created if it doesn't exist. It is expected that either users will read these files, or the system administrators will run a script to resend this "lost mail" to its owner. .TP .BI \-c " cache-interval" Caching interval. .B Hlfsd will cache the validity of home directories for this interval, in seconds. Entries which have been verified within the last .I cache-interval seconds will not be verified again, since the operation could be expensive, and the entries are most likely still valid. After the interval has expired, .B hlfsd will re-verify the validity of the user's home directory, and reset the cache time-counter. The default value for .I cache-interval is 300 seconds (5 minutes). .TP .B \-f Force fast startup. This option tells .B hlfsd to skip startup-time consistency checks such as existence of mount directory, alternate spool directory, symlink to be hidden under the mount directory, their permissions and validity. .TP .BI \-g " group" Set the special group HLFS_GID to .IR group . Programs such as .B from or .BR comsat , which access the mailboxes of other users) must be setgid HLFS_GID to work properly. The default group is "hlfs". If no group is provided, and there is no group "hlfs", this feature is disabled. .TP .B \-h Help. Print a brief help message, and exit. .TP .BI \-i " reload-interval" Map-reloading interval. Each .I reload-interval seconds, .B hlfsd will reload the password map. .B Hlfsd needs the password map for the UIDs and home directory pathnames. .B Hlfsd schedules a SIGALRM to reload the password maps. A SIGHUP sent to .B hlfsd will force it to reload the maps immediately. The default value for .I reload-interval is 900 seconds (15 minutes.) .TP .BI \-l " logfile" Specify a log file to which .B hlfsd will record events. If .I logfile is the string .B syslog then the log messages will be sent to the system log daemon by .IR syslog (3), using the LOG_DAEMON facility. This is also the default. .TP .B \-n No verify. .B Hlfsd will not verify the validity of the symbolic link it will be returning, or that the user's home directory contains sufficient disk-space for spooling. This can speed up .B hlfsd at the cost of possibly returning symbolic links to home directories which are not currently accessible or are full. By default, .B hlfsd validates the symbolic-link in the background. The .B \-n option overrides the meaning of the .B \-c option, since no caching is necessary. .TP .BI \-o " mount-options" Mount options. Mount options which .B hlfsd will use to mount itself on top of .I dirname. By default, .IR mount-options is set to "ro". If the system supports symbolic-link caching, default options are set to "ro,nocache". .TP .B \-p Print PID. Outputs the process-id of .B hlfsd to standard output where it can be saved into a file. .TP .B \-v Version. Displays version information to standard error. .TP .BI \-x " log-options" Specify run-time logging options. The options are a comma separated list chosen from: fatal, error, user, warn, info, map, stats, all. .TP .BI \-C Force .B hlfsd to run on systems that cannot turn off the NFS attribute-cache. Use of this option on those systems is discouraged, as it may result in loss or mis-delivery of mail. The option is ignored on systems that can turn off the attribute-cache. .TP .BI \-D " log-options" Select from a variety of debugging options. Prefixing an option with the string .B no reverses the effect of that option. Options are cumulative. The most useful option is .BR all . Since this option is only used for debugging other options are not documented here. A fuller description is available in the program source. A SIGUSR1 sent to .B hlfsd will cause it to dump its internal password map to the file .BR /usr/tmp/hlfsd.dump.XXXXXX . .TP .BI \-P " password-file" Read the user-name, user-id, and home directory information from the file .I password-file. Normally, .B hlfsd will use .IR getpwent (3) to read the password database. This option allows you to override the default database, and is useful if you want to map users' mail files to a directory other than their home directory. Only the username, uid, and home-directory fields of the file .I password-file are read and checked. All other fields are ignored. The file .I password-file must otherwise be compliant with Unix System 7 colon-delimited format .IR passwd (4). .SH FILES .TP 5 .B /hlfs directory under which .B hlfsd mounts itself and manages the symbolic link .BR home . .TP 5 .B .hlfsdir default sub-directory in the user's home directory, to which the .B home symbolic link returned by .B hlfsd points. .TP 5 .B /var/hlfs directory to which .B home symbolic link returned by .B hlfsd points if it is unable to verify the that user's home directory is accessible. .SH "SEE ALSO" .BR mail(1), .BR getgrent (3), .BR getpwent (3), .BR mnttab (4), .BR passwd (4), .BR mtab (5), .BR amd (8), .BR automount (8), .BR cron(8), .BR mount (8), .BR sendmail (8), .BR umount (8). .LP .IR "HLFSD: Delivering Email to Your $HOME" , in .IR "Proc. LISA-VII, The 7th Usenix System Administration Conference" , November 1993. .LP ``am-utils'' .BR info (1) entry. .LP .I "Linux NFS and Automounter Administration" by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). .LP .I http://www.am-utils.org .SH AUTHORS Erez Zadok , Computer Science Department, Stony Brook University, Stony Brook, New York, USA. and Alexander Dupuy , System Management ARTS, White Plains, New York, USA. .P Other authors and contributors to am-utils are listed in the .B AUTHORS file distributed with am-utils. am-utils-6.2+rc20110530/hlfsd/hlfsd.c000066400000000000000000000616521157065440000167100ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/hlfsd/hlfsd.c * * HLFSD was written at Columbia University Computer Science Department, by * Erez Zadok and Alexander Dupuy * It is being distributed under the same terms and conditions as amd does. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * STATIC VARIABLES: */ static RETSIGTYPE proceed(int); static RETSIGTYPE reaper(int); static RETSIGTYPE reload(int); static char *hlfs_group = DEFAULT_HLFS_GROUP; static char default_dir_name[] = DEFAULT_DIRNAME; static char *dir_name = default_dir_name; static int printpid = 0; static int stoplight = 0; static void hlfsd_init(void); static void usage(void); static struct itimerval reloadinterval = { {DEFAULT_INTERVAL, 0}, {DEFAULT_INTERVAL, 0} }; /* * default mount options. */ static char default_mntopts[] = "ro,noac"; /* * GLOBALS: */ SVCXPRT *nfsxprt; char *alt_spooldir = ALT_SPOOLDIR; char *home_subdir = HOME_SUBDIR; char *logfile = DEFAULT_LOGFILE; char *passwdfile = NULL; /* alternate passwd file to use */ char *slinkname = NULL; char hostname[MAXHOSTNAMELEN + 1] = "localhost"; u_int cache_interval = DEFAULT_CACHE_INTERVAL; gid_t hlfs_gid = (gid_t) INVALIDID; int masterpid = 0; int noverify = 0; int orig_umask = 022; int serverpid = 0; nfstime startup; u_short nfs_port; /* symbol must be available always */ #ifdef MNTTAB_FILE_NAME char *mnttab_file_name = MNTTAB_FILE_NAME; #else /* not MNTTAB_FILE_NAME */ char *mnttab_file_name = NULL; #endif /* not MNTTAB_FILE_NAME */ /* forward declarations */ void hlfsd_going_down(int rc); void fatalerror(char *str); static void usage(void) { fprintf(stderr, "Usage: %s [-Cfhnpv] [-a altdir] [-c cache-interval] [-g group]\n", am_get_progname()); fprintf(stderr, "\t[-i interval] [-l logfile] [-o mntopts] [-P passwdfile]\n"); show_opts('x', xlog_opt); #ifdef DEBUG show_opts('D', dbg_opt); #endif /* DEBUG */ fprintf(stderr, "\t[dir_name [subdir]]\n"); exit(2); } void fatalerror(char *str) { #define ERRM ": %m" size_t l = strlen(str) + sizeof(ERRM) - 1; char *tmp = strnsave(str, l); xstrlcat(tmp, ERRM, l); fatal(tmp); } int main(int argc, char *argv[]) { char *dot; char *mntopts = (char *) NULL; char hostpid_fs[MAXHOSTNAMELEN + 1 + 16]; /* room for ":(pid###)" */ char progpid_fs[PROGNAMESZ + 1 + 11]; /* room for ":pid" */ char preopts[128]; char *progname; int forcecache = 0; int forcefast = 0; int genflags = 0; int opt, ret; int opterrs = 0; int retry; int soNFS; /* NFS socket */ int s = -99; mntent_t mnt; nfs_args_t nfs_args; am_nfs_handle_t anh; struct dirent *direntry; struct group *grp; struct stat stmodes; DIR *mountdir; MTYPE_TYPE type = MOUNT_TYPE_NFS; #ifdef HAVE_SIGACTION struct sigaction sa; #endif /* not HAVE_SIGACTION */ #ifndef HAVE_TRANSPORT_TYPE_TLI struct sockaddr_in localsocket; #endif /* not HAVE_TRANSPORT_TYPE_TLI */ /* get program name and truncate so we don't overflow progpid_fs */ if ((progname = strrchr(argv[0], '/')) != NULL) progname++; else progname = argv[0]; if ((int) strlen(progname) > PROGNAMESZ) /* truncate to reasonable size */ progname[PROGNAMESZ] = '\0'; am_set_progname(progname); while ((opt = getopt(argc, argv, "a:c:CD:fg:hi:l:no:pP:x:v")) != -1) switch (opt) { case 'a': if (!optarg || optarg[0] != '/') { printf("%s: invalid directory for -a: %s\n", am_get_progname(), optarg); exit(3); } alt_spooldir = optarg; break; case 'c': if (!atoi(optarg)) { printf("%s: invalid interval for -c: %s\n", am_get_progname(), optarg); exit(3); } cache_interval = atoi(optarg); break; case 'C': forcecache++; break; case 'f': forcefast++; break; case 'g': hlfs_group = optarg; break; case 'i': if (!atoi(optarg)) { printf("%s: invalid interval for -i: %s\n", am_get_progname(), optarg); exit(3); } reloadinterval.it_interval.tv_sec = atoi(optarg); reloadinterval.it_value.tv_sec = atoi(optarg); break; case 'l': logfile = optarg; break; case 'n': noverify++; break; case 'o': mntopts = optarg; break; case 'p': printpid++; break; case 'P': passwdfile = optarg; break; case 'v': fprintf(stderr, "%s\n", HLFSD_VERSION); exit(0); case 'x': opterrs += switch_option(optarg); break; case 'D': #ifdef DEBUG opterrs += debug_option(optarg); #else /* not DEBUG */ fprintf(stderr, "%s: not compiled with DEBUG -- sorry.\n", am_get_progname()); #endif /* not DEBUG */ break; case 'h': case '?': opterrs++; } /* need my pid before any dlog/plog */ am_set_mypid(); #ifdef DEBUG switch_option("debug"); #endif /* DEBUG */ /* * Terminate if did not ask to forcecache (-C) and hlfsd would not be able * to set the minimum cache intervals. */ #if !defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNT2_NFS_OPT_NOAC) && !defined(HAVE_NFS_ARGS_T_ACREGMIN) if (!forcecache) { fprintf(stderr, "%s: will not be able to turn off attribute caches.\n", am_get_progname()); exit(1); } #endif /* !defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNT2_NFS_OPT_NOAC) && !defined(HAVE_NFS_ARGS_T_ACREGMIN) */ switch (argc - optind) { case 2: home_subdir = argv[optind + 1]; case 1: dir_name = argv[optind]; case 0: break; default: opterrs++; } if (opterrs) usage(); /* ensure that only root can run hlfsd */ if (geteuid()) { fprintf(stderr, "hlfsd can only be run as root\n"); exit(1); } setbuf(stdout, (char *) NULL); umask(0); /* find gid for hlfs_group */ if ((grp = getgrnam(hlfs_group)) == (struct group *) NULL) { fprintf(stderr, "%s: cannot get gid for group \"%s\".\n", am_get_progname(), hlfs_group); } else { hlfs_gid = grp->gr_gid; } /* get hostname for logging and open log before we reset umask */ gethostname(hostname, sizeof(hostname)); hostname[sizeof(hostname) - 1] = '\0'; if ((dot = strchr(hostname, '.')) != NULL) *dot = '\0'; orig_umask = umask(0); if (logfile) switch_to_logfile(logfile, orig_umask, 0); #ifndef MOUNT_TABLE_ON_FILE if (amuDebug(D_MTAB)) dlog("-D mtab option ignored"); #endif /* not MOUNT_TABLE_ON_FILE */ /* avoid hanging on other NFS servers if started elsewhere */ if (chdir("/") < 0) fatal("cannot chdir to /: %m"); if (geteuid() != 0) fatal("must be root to mount filesystems"); /* * dir_name must match "^(/.*)/([^/]+)$", and is split at last '/' with * slinkname = `basename $dir_name` - requires dir_name be writable */ if (dir_name[0] != '/' || ((slinkname = strrchr(dir_name, '/')), *slinkname++ = '\0', (dir_name[0] == '\0' || slinkname[0] == '\0'))) { if (slinkname) *--slinkname = '/'; printf("%s: invalid mount directory/link %s\n", am_get_progname(), dir_name); exit(3); } if (!forcefast) { /* make sure mount point exists and is at least mode 555 */ if (stat(dir_name, &stmodes) < 0) if (errno != ENOENT || mkdirs(dir_name, 0555) < 0 || stat(dir_name, &stmodes) < 0) fatalerror(dir_name); if ((stmodes.st_mode & 0555) != 0555) { fprintf(stderr, "%s: directory %s not read/executable\n", am_get_progname(), dir_name); plog(XLOG_WARNING, "directory %s not read/executable", dir_name); } /* warn if extraneous stuff will be hidden by mount */ if ((mountdir = opendir(dir_name)) == NULL) fatalerror(dir_name); while ((direntry = readdir(mountdir)) != NULL) { if (!NSTREQ(".", direntry->d_name, NAMLEN(direntry)) && !NSTREQ("..", direntry->d_name, NAMLEN(direntry)) && !NSTREQ(slinkname, direntry->d_name, NAMLEN(direntry))) break; } if (direntry != NULL) { fprintf(stderr, "%s: %s/%s will be hidden by mount\n", am_get_progname(), dir_name, direntry->d_name); plog(XLOG_WARNING, "%s/%s will be hidden by mount\n", dir_name, direntry->d_name); } closedir(mountdir); /* make sure alternate spool dir exists */ if ((errno = mkdirs(alt_spooldir, OPEN_SPOOLMODE))) { fprintf(stderr, "%s: cannot create alternate dir ", am_get_progname()); perror(alt_spooldir); plog(XLOG_ERROR, "cannot create alternate dir %s: %m", alt_spooldir); } chmod(alt_spooldir, OPEN_SPOOLMODE); /* create failsafe link to alternate spool directory */ *(slinkname-1) = '/'; /* unsplit dir_name to include link */ if (lstat(dir_name, &stmodes) == 0 && (stmodes.st_mode & S_IFMT) != S_IFLNK) { fprintf(stderr, "%s: failsafe %s not a symlink\n", am_get_progname(), dir_name); plog(XLOG_WARNING, "failsafe %s not a symlink\n", dir_name); } else { unlink(dir_name); if (symlink(alt_spooldir, dir_name) < 0) { fprintf(stderr, "%s: cannot create failsafe symlink %s -> ", am_get_progname(), dir_name); perror(alt_spooldir); plog(XLOG_WARNING, "cannot create failsafe symlink %s -> %s: %m", dir_name, alt_spooldir); } } *(slinkname-1) = '\0'; /* resplit dir_name */ } /* end of "if (!forcefast) {" */ /* * Register hlfsd as an nfs service with the portmapper. */ #ifdef HAVE_TRANSPORT_TYPE_TLI ret = create_nfs_service(&soNFS, &nfs_port, &nfsxprt, nfs_program_2); #else /* not HAVE_TRANSPORT_TYPE_TLI */ ret = create_nfs_service(&soNFS, &nfs_port, &nfsxprt, nfs_program_2); #endif /* not HAVE_TRANSPORT_TYPE_TLI */ if (ret != 0) fatal("cannot create NFS service"); #ifdef HAVE_SIGACTION sa.sa_handler = proceed; sa.sa_flags = 0; sigemptyset(&(sa.sa_mask)); sigaddset(&(sa.sa_mask), SIGUSR2); sigaction(SIGUSR2, &sa, NULL); #else /* not HAVE_SIGACTION */ signal(SIGUSR2, proceed); #endif /* not HAVE_SIGACTION */ plog(XLOG_INFO, "Initializing hlfsd..."); hlfsd_init(); /* start up child (forking) to run svc_run */ #ifdef HAVE_SIGACTION sa.sa_handler = reaper; sa.sa_flags = 0; sigemptyset(&(sa.sa_mask)); sigaddset(&(sa.sa_mask), SIGCHLD); sigaction(SIGCHLD, &sa, NULL); #else /* not HAVE_SIGACTION */ signal(SIGCHLD, reaper); #endif /* not HAVE_SIGACTION */ /* * In the parent, if -D nodaemon, we don't need to * set this signal handler. */ if (amuDebug(D_DAEMON)) { s = -99; while (stoplight != SIGUSR2) { plog(XLOG_INFO, "parent waits for child to setup (stoplight=%d)", stoplight); #ifdef HAVE_SIGSUSPEND { sigset_t mask; sigemptyset(&mask); s = sigsuspend(&mask); /* wait for child to set up */ } #else /* not HAVE_SIGSUSPEND */ s = sigpause(0); /* wait for child to set up */ #endif /* not HAVE_SIGSUSPEND */ sleep(1); } } /* * setup options to mount table (/etc/{mtab,mnttab}) entry */ xsnprintf(hostpid_fs, sizeof(hostpid_fs), "%s:(pid%d)", hostname, masterpid); memset((char *) &mnt, 0, sizeof(mnt)); mnt.mnt_dir = dir_name; /* i.e., "/mail" */ mnt.mnt_fsname = hostpid_fs; if (mntopts) { mnt.mnt_opts = mntopts; } else { xstrlcpy(preopts, default_mntopts, sizeof(preopts)); /* * Turn off all kinds of attribute and symlink caches as * much as possible. Also make sure that mount does not * show up to df. */ #ifdef MNTTAB_OPT_INTR xstrlcat(preopts, ",", sizeof(preopts)); xstrlcat(preopts, MNTTAB_OPT_INTR, sizeof(preopts)); #endif /* MNTTAB_OPT_INTR */ #ifdef MNTTAB_OPT_IGNORE xstrlcat(preopts, ",", sizeof(preopts)); xstrlcat(preopts, MNTTAB_OPT_IGNORE, sizeof(preopts)); #endif /* MNTTAB_OPT_IGNORE */ #ifdef MNT2_GEN_OPT_CACHE xstrlcat(preopts, ",nocache", sizeof(preopts)); #endif /* MNT2_GEN_OPT_CACHE */ #ifdef MNT2_NFS_OPT_SYMTTL xstrlcat(preopts, ",symttl=0", sizeof(preopts)); #endif /* MNT2_NFS_OPT_SYMTTL */ mnt.mnt_opts = preopts; } /* * Make sure that amd's top-level NFS mounts are hidden by default * from df. * If they don't appear to support the either the "ignore" mnttab * option entry, or the "auto" one, set the mount type to "nfs". */ #ifdef HIDE_MOUNT_TYPE mnt.mnt_type = HIDE_MOUNT_TYPE; #else /* not HIDE_MOUNT_TYPE */ mnt.mnt_type = "nfs"; #endif /* not HIDE_MOUNT_TYPE */ /* some systems don't have a mount type, but a mount flag */ #ifndef HAVE_TRANSPORT_TYPE_TLI amu_get_myaddress(&localsocket.sin_addr, NULL); localsocket.sin_family = AF_INET; localsocket.sin_port = htons(nfsxprt->xp_port); #endif /* not HAVE_TRANSPORT_TYPE_TLI */ /* * Update hostname field. * Make some name prog:pid (i.e., hlfsd:174) for hostname */ xsnprintf(progpid_fs, sizeof(progpid_fs), "%s:%d", am_get_progname(), masterpid); /* Most kernels have a name length restriction. */ if ((int) strlen(progpid_fs) >= (int) MAXHOSTNAMELEN) xstrlcpy(progpid_fs + MAXHOSTNAMELEN - 3, "..", sizeof(progpid_fs) - MAXHOSTNAMELEN + 3); genflags = compute_mount_flags(&mnt); retry = hasmntval(&mnt, MNTTAB_OPT_RETRY); if (retry <= 0) retry = 1; /* XXX */ memmove(&anh.v2, root_fhp, sizeof(*root_fhp)); #ifdef HAVE_TRANSPORT_TYPE_TLI compute_nfs_args(&nfs_args, &mnt, genflags, nfsncp, NULL, /* remote host IP addr is set below */ NFS_VERSION, /* version 2 */ "udp", /* XXX: shouldn't this be "udp"? */ &anh, progpid_fs, /* host name for kernel */ hostpid_fs); /* filesystem name for kernel */ /* * IMPORTANT: set the correct IP address AFTERWARDS. It cannot * be done using the normal mechanism of compute_nfs_args(), because * that one will allocate a new address and use NFS_SA_DREF() to copy * parts to it, while assuming that the ip_addr passed is always * a "struct sockaddr_in". That assumption is incorrect on TLI systems, * because they define a special macro HOST_SELF which is DIFFERENT * than localhost (127.0.0.1)! */ nfs_args.addr = &nfsxprt->xp_ltaddr; #else /* not HAVE_TRANSPORT_TYPE_TLI */ compute_nfs_args(&nfs_args, &mnt, genflags, NULL, &localsocket, NFS_VERSION, /* version 2 */ "udp", /* XXX: shouldn't this be "udp"? */ &anh, progpid_fs, /* host name for kernel */ hostpid_fs); /* filesystem name for kernel */ #endif /* not HAVE_TRANSPORT_TYPE_TLI */ /************************************************************************* * NOTE: while compute_nfs_args() works ok for regular NFS mounts * * the toplvl one is not, and so some options must be corrected by hand * * more carefully, *after* compute_nfs_args() runs. * *************************************************************************/ compute_automounter_nfs_args(&nfs_args, &mnt); /* * For some reason, this mount may have to be done in the background, if I am * using -D daemon. I suspect that the actual act of mounting requires * calling to hlfsd itself to invoke one or more of its nfs calls, to stat * /mail. That means that even if you say -D daemon, at least the mount * of hlfsd itself on top of /mail will be done in the background. * The other alternative I have is to run svc_run, but set a special * signal handler to perform the mount in N seconds via some alarm. * -Erez Zadok. */ if (!amuDebug(D_DAEMON)) { /* Normal case */ plog(XLOG_INFO, "normal NFS mounting hlfsd service points"); if (mount_fs(&mnt, genflags, (caddr_t) &nfs_args, retry, type, 0, NULL, mnttab_file_name, 0) < 0) fatal("nfsmount: %m"); } else { /* asked for -D daemon */ if (fork() == 0) { /* child runs mount */ am_set_mypid(); foreground = 0; plog(XLOG_INFO, "child NFS mounting hlfsd service points"); if (mount_fs(&mnt, genflags, (caddr_t) &nfs_args, retry, type, 0, NULL, mnttab_file_name, 0) < 0) { fatal("nfsmount: %m"); } exit(0); /* all went well */ } else { /* fork failed or parent running */ plog(XLOG_INFO, "parent waiting 1sec for mount..."); } } #ifdef HAVE_TRANSPORT_TYPE_TLI /* * XXX: this free_knetconfig() was not done for hlfsd before, * and apparently there was a reason for it, but why? -Erez */ free_knetconfig(nfs_args.knconf); /* * local automounter mounts do not allocate a special address, so * no need to XFREE(nfs_args.addr) under TLI. */ #endif /* HAVE_TRANSPORT_TYPE_TLI */ if (printpid) printf("%d\n", masterpid); plog(XLOG_INFO, "hlfsd ready to serve"); /* * If asked not to fork a daemon (-D nodaemon), then hlfsd_init() * will not run svc_run. We must start svc_run here. */ if (!amuDebug(D_DAEMON)) { plog(XLOG_DEBUG, "starting no-daemon debugging svc_run"); svc_run(); } cleanup(0); /* should never happen here */ return (0); /* everything went fine? */ } static void hlfsd_init(void) { int child = 0; #ifdef HAVE_SIGACTION struct sigaction sa; #endif /* HAVE_SIGACTION */ /* * Initialize file handles. */ plog(XLOG_INFO, "initializing hlfsd file handles"); hlfsd_init_filehandles(); /* * If -D daemon then we must fork. */ if (amuDebug(D_DAEMON)) child = fork(); if (child < 0) fatal("fork: %m"); if (child != 0) { /* parent process - save child pid */ masterpid = child; am_set_mypid(); /* for logging routines */ return; } /* * CHILD CODE: * initialize server */ plog(XLOG_INFO, "initializing home directory database"); plt_init(); /* initialize database */ plog(XLOG_INFO, "home directory database initialized"); masterpid = serverpid = am_set_mypid(); /* for logging routines */ /* * SIGALRM/SIGHUP: reload password database if timer expired * or user sent HUP signal. */ #ifdef HAVE_SIGACTION sa.sa_handler = reload; sa.sa_flags = 0; sigemptyset(&(sa.sa_mask)); sigaddset(&(sa.sa_mask), SIGALRM); sigaddset(&(sa.sa_mask), SIGHUP); sigaction(SIGALRM, &sa, NULL); sigaction(SIGHUP, &sa, NULL); #else /* not HAVE_SIGACTION */ signal(SIGALRM, reload); signal(SIGHUP, reload); #endif /* not HAVE_SIGACTION */ /* * SIGTERM: cleanup and exit. */ #ifdef HAVE_SIGACTION sa.sa_handler = cleanup; sa.sa_flags = 0; sigemptyset(&(sa.sa_mask)); sigaddset(&(sa.sa_mask), SIGTERM); sigaction(SIGTERM, &sa, NULL); #else /* not HAVE_SIGACTION */ signal(SIGTERM, cleanup); #endif /* not HAVE_SIGACTION */ /* * SIGCHLD: interlock synchronization and testing */ #ifdef HAVE_SIGACTION sa.sa_handler = interlock; sa.sa_flags = 0; sigemptyset(&(sa.sa_mask)); sigaddset(&(sa.sa_mask), SIGCHLD); sigaction(SIGCHLD, &sa, NULL); #else /* not HAVE_SIGACTION */ signal(SIGCHLD, interlock); #endif /* not HAVE_SIGACTION */ /* * SIGUSR1: dump internal hlfsd maps/cache to file */ #ifdef HAVE_SIGACTION # if defined(DEBUG) || defined(DEBUG_PRINT) sa.sa_handler = plt_print; # else /* not defined(DEBUG) || defined(DEBUG_PRINT) */ sa.sa_handler = SIG_IGN; # endif /* not defined(DEBUG) || defined(DEBUG_PRINT) */ sa.sa_flags = 0; sigemptyset(&(sa.sa_mask)); sigaddset(&(sa.sa_mask), SIGUSR1); sigaction(SIGUSR1, &sa, NULL); #else /* not HAVE_SIGACTION */ # if defined(DEBUG) || defined(DEBUG_PRINT) signal(SIGUSR1, plt_print); # else /* not defined(DEBUG) || defined(DEBUG_PRINT) */ signal(SIGUSR1, SIG_IGN); # endif /* not defined(DEBUG) || defined(DEBUG_PRINT) */ #endif /* not HAVE_SIGACTION */ if (setitimer(ITIMER_REAL, &reloadinterval, (struct itimerval *) NULL) < 0) fatal("setitimer: %m"); clocktime(&startup); /* * If -D daemon, then start serving here in the child, * and the parent will exit. But if -D nodaemon, then * skip this code and make sure svc_run is entered elsewhere. */ if (amuDebug(D_DAEMON)) { /* * Dissociate from the controlling terminal */ amu_release_controlling_tty(); /* * signal parent we are ready. parent should * mount(2) and die. */ if (kill(getppid(), SIGUSR2) < 0) fatal("kill: %m"); plog(XLOG_INFO, "starting svc_run"); svc_run(); cleanup(0); /* should never happen, just in case */ } } static RETSIGTYPE proceed(int signum) { stoplight = signum; } static RETSIGTYPE reload(int signum) { int child; int status; if (getpid() != masterpid) return; /* * If received a SIGHUP, close and reopen the log file (so that it * can be rotated) */ if (signum == SIGHUP && logfile) switch_to_logfile(logfile, orig_umask, 0); /* * parent performs the reload, while the child continues to serve * clients accessing the home dir link. */ if ((child = fork()) > 0) { serverpid = child; /* parent runs here */ am_set_mypid(); plt_init(); if (kill(child, SIGKILL) < 0) { plog(XLOG_ERROR, "kill child: %m"); } else { /* wait for child to die before continue */ if (wait(&status) != child) { /* * I took out this line because it generates annoying output. It * indicates a very small bug in hlfsd which is totally harmless. * It causes hlfsd to work a bit harder than it should. * Nevertheless, I intend on fixing it in a future release. * -Erez Zadok */ /* plog(XLOG_ERROR, "unknown child"); */ } } serverpid = masterpid; } else if (child < 0) { plog(XLOG_ERROR, "unable to fork: %m"); } else { /* let child handle requests while we reload */ serverpid = getpid(); am_set_mypid(); } } RETSIGTYPE cleanup(int signum) { struct stat stbuf; int umount_result; if (amuDebug(D_DAEMON)) { if (getpid() != masterpid) return; if (fork() != 0) { masterpid = 0; am_set_mypid(); return; } } am_set_mypid(); for (;;) { while ((umount_result = UMOUNT_FS(dir_name, mnttab_file_name, 0)) == EBUSY) { dlog("cleanup(): umount delaying for 10 seconds"); sleep(10); } if (stat(dir_name, &stbuf) == 0 && stbuf.st_ino == ROOTID) { plog(XLOG_ERROR, "unable to unmount %s", dir_name); plog(XLOG_ERROR, "suspending, unmount before terminating"); kill(am_mypid, SIGSTOP); continue; /* retry unmount */ } break; } if (amuDebug(D_DAEMON)) { plog(XLOG_INFO, "cleanup(): killing processes and terminating"); kill(masterpid, SIGKILL); kill(serverpid, SIGKILL); } plog(XLOG_INFO, "hlfsd terminating with status 0\n"); _exit(0); } static RETSIGTYPE reaper(int signum) { int result; if (wait(&result) == masterpid) { _exit(4); } } void hlfsd_going_down(int rc) { int mypid = getpid(); /* XXX: should this be the global am_mypid */ if (mypid == masterpid) cleanup(0); else if (mypid == serverpid) kill(masterpid, SIGTERM); exit(rc); } void fatal(char *mess) { if (logfile && !STREQ(logfile, "stderr")) { char lessmess[128]; int messlen; messlen = strlen(mess); if (!STREQ(&mess[messlen + 1 - sizeof(ERRM)], ERRM)) fprintf(stderr, "%s: %s\n", am_get_progname(), mess); else { xstrlcpy(lessmess, mess, sizeof(lessmess)); lessmess[messlen - 4] = '\0'; fprintf(stderr, "%s: %s: %s\n", am_get_progname(), lessmess, strerror(errno)); } } plog(XLOG_FATAL, "%s", mess); hlfsd_going_down(1); } am-utils-6.2+rc20110530/hlfsd/hlfsd.h000066400000000000000000000130221157065440000167010ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/hlfsd/hlfsd.h * * HLFSD was written at Columbia University Computer Science Department, by * Erez Zadok and Alexander Dupuy * It is being distributed under the same terms and conditions as amd does. */ #ifndef _HLFSD_HLFS_H #define _HLFSD_HLFS_H /* * MACROS AND CONSTANTS: */ #define HLFSD_VERSION "hlfsd 1.2 (1993-2002)" #define PERS_SPOOLMODE 0755 #define OPEN_SPOOLMODE 01777 #define DOTSTRING "." /* * ROOTID and SLINKID are the fixed "faked" node IDs (inodes) for * the '.' (also '..') and the one symlink within the hlfs. * They must always be unique, and should never match what a UID * could be. * They used to be -1 and -2, respectively. * * I used to cast these to (uid_t) but it failed to compile * with /opt/SUNWspro/bin/cc because uid_t is long, while struct fattr's * uid field is u_int. Then it failed to compile on some linux systems * which define uid_t to be unsigned short, so I used the lowest common * size which is unsigned short. */ /* * XXX: this will cause problems to systems with UIDs greater than * MAX_UNSIGNED_SHORT-3. */ #define ROOTID (((unsigned short) ~0) - 1) #define SLINKID (((unsigned short) ~0) - 2) #ifndef INVALIDID /* this is also defined in include/am_utils.h */ # define INVALIDID (((unsigned short) ~0) - 3) #endif /* not INVALIDID */ #define DOTCOOKIE 1 #define DOTDOTCOOKIE 2 #define SLINKCOOKIE 3 #define ALT_SPOOLDIR "/var/hlfs" /* symlink to use if others fail */ #define HOME_SUBDIR ".hlfsdir" /* dirname in user's home dir */ #define DEFAULT_DIRNAME "/hlfs/home" #define DEFAULT_INTERVAL 900 /* secs b/t re-reads of the password maps */ #define DEFAULT_CACHE_INTERVAL 300 /* secs during which assume a link is up */ #define DEFAULT_HLFS_GROUP "hlfs" /* Group name for special hlfs_gid */ #define PROGNAMESZ (MAXHOSTNAMELEN - 5) #ifdef HAVE_SYSLOG # define DEFAULT_LOGFILE "syslog" #else /* not HAVE)_SYSLOG */ # define DEFAULT_LOGFILE 0 #endif /* not HAVE)_SYSLOG */ /* * TYPEDEFS: */ typedef struct uid2home_t uid2home_t; typedef struct username2uid_t username2uid_t; /* * STRUCTURES: */ struct uid2home_t { uid_t uid; /* XXX: with or without UID_OFFSET? */ pid_t child; char *home; /* really allocated */ char *uname; /* an xref ptr to username2uid_t->username */ u_long last_access_time; int last_status; /* 0=used $HOME/.hlfsspool; !0=used alt dir */ }; struct username2uid_t { char *username; /* really allocated */ uid_t uid; /* XXX: with or without UID_OFFSET? */ char *home; /* an xref ptr to uid2home_t->home */ }; /* * EXTERNALS: */ extern RETSIGTYPE cleanup(int); extern RETSIGTYPE interlock(int); extern SVCXPRT *nfs_program_2_transp; /* For quick_reply() */ extern SVCXPRT *nfsxprt; extern char *alt_spooldir; extern char *home_subdir; extern char *homedir(int, int); extern char *mailbox(int, char *); extern char *passwdfile; extern char *slinkname; extern gid_t hlfs_gid; extern u_int cache_interval; extern int noverify; extern int serverpid; extern int untab_index(char *username); extern am_nfs_fh *root_fhp; extern am_nfs_fh root; extern nfstime startup; extern uid2home_t *plt_search(u_int); extern username2uid_t *untab; /* user name table */ extern void fatal(char *); extern void plt_init(void); extern void hlfsd_init_filehandles(void); #if defined(DEBUG) || defined(DEBUG_PRINT) extern void plt_dump(uid2home_t *, pid_t); extern void plt_print(int); #endif /* defined(DEBUG) || defined(DEBUG_PRINT) */ #endif /* _HLFSD_HLFS_H */ am-utils-6.2+rc20110530/hlfsd/homedir.c000066400000000000000000000526301157065440000172330ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/hlfsd/homedir.c * * HLFSD was written at Columbia University Computer Science Department, by * Erez Zadok and Alexander Dupuy * It is being distributed under the same terms and conditions as amd does. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * STATIC VARIABLES AND FUNCTIONS: */ static FILE *passwd_fp = NULL; static char pw_name[16], pw_dir[128]; static int cur_pwtab_num = 0, max_pwtab_num = 0; static int hlfsd_diskspace(char *); static int hlfsd_stat(char *, struct stat *); static int passwd_line = 0; static int plt_reset(void); static struct passwd passwd_ent; static uid2home_t *lastchild; static uid2home_t *pwtab; static void delay(uid2home_t *, int); static void table_add(u_int, const char *, const char *); static char mboxfile[MAXPATHLEN]; static char *root_home; /* root's home directory */ /* GLOBAL FUNCTIONS */ char *homeof(char *username); int uidof(char *username); /* GLOBALS VARIABLES */ username2uid_t *untab; /* user name table */ /* * Return the home directory pathname for the user with uid "userid". */ char * homedir(int userid, int groupid) { static char linkval[MAXPATHLEN + 1]; static struct timeval tp; uid2home_t *found; char *homename; struct stat homestat; int old_groupid, old_userid; if ((found = plt_search(userid)) == (uid2home_t *) NULL) { return alt_spooldir; /* use alt spool for unknown uid */ } homename = found->home; if (homename[0] != '/' || homename[1] == '\0') { found->last_status = 1; return alt_spooldir; /* use alt spool for / or rel. home */ } if ((int) userid == 0) /* force all uid 0 to use root's home */ xsnprintf(linkval, sizeof(linkval), "%s/%s", root_home, home_subdir); else xsnprintf(linkval, sizeof(linkval), "%s/%s", homename, home_subdir); if (noverify) { found->last_status = 0; return linkval; } /* * To optimize hlfsd, we don't actually check the validity of the * symlink if it has been checked in the last N seconds. It is * very likely that the link, machine, and filesystem are still * valid, as long as N is small. But if N is large, that may not be * true. That's why the default N is 5 minutes, but we allow the * user to override this value via a command line option. Note that * we do not update the last_access_time each time it is accessed, * but only once every N seconds. */ if (gettimeofday(&tp, (struct timezone *) NULL) < 0) { tp.tv_sec = 0; } else { if ((tp.tv_sec - found->last_access_time) < cache_interval) { if (found->last_status == 0) { return linkval; } else { return alt_spooldir; } } else { found->last_access_time = tp.tv_sec; } } /* * Only run this forking code if ask for -D fork (default). * Disable forking using -D nofork. */ if (amuDebug(D_FORK)) { /* fork child to process request if none in progress */ if (found->child && kill(found->child, 0)) found->child = 0; if (found->child) delay(found, 5); /* wait a bit if in progress */ if (found->child) { /* better safe than sorry - maybe */ found->last_status = 1; return alt_spooldir; } if ((found->child = fork()) < 0) { found->last_status = 1; return alt_spooldir; } if (found->child) { /* PARENT */ if (lastchild) dlog("cache spill uid = %ld, pid = %ld, home = %s", (long) lastchild->uid, (long) lastchild->child, lastchild->home); lastchild = found; return (char *) NULL; /* return NULL to parent, so it can continue */ } } /* * CHILD: (or parent if -D fork) * * Check and create dir if needed. * Check disk space and/or quotas too. * * We don't need to set the _last_status field of found after the fork * in the child, b/c that information would be later determined in * nfsproc_readlink_2() and the correct exit status would be returned * to the parent upon SIGCHLD in interlock(). * */ am_set_mypid(); /* for logging routines */ if ((old_groupid = setgid(groupid)) < 0) { plog(XLOG_WARNING, "could not setgid to %d: %m", groupid); return linkval; } if ((old_userid = seteuid(userid)) < 0) { plog(XLOG_WARNING, "could not seteuid to %d: %m", userid); setgid(old_groupid); return linkval; } if (hlfsd_stat(linkval, &homestat) < 0) { if (errno == ENOENT) { /* make the spool dir if possible */ /* don't use recursive mkdirs here */ if (mkdir(linkval, PERS_SPOOLMODE) < 0) { seteuid(old_userid); setgid(old_groupid); plog(XLOG_WARNING, "can't make directory %s: %m", linkval); return alt_spooldir; } /* fall through to testing the disk space / quota */ } else { /* the home dir itself must not exist then */ seteuid(old_userid); setgid(old_groupid); plog(XLOG_WARNING, "bad link to %s: %m", linkval); return alt_spooldir; } } /* * If gets here, then either the spool dir in the home dir exists, * or it was just created. In either case, we now need to * test if we can create a small file and write at least one * byte into it. This will test that we have both enough inodes * and disk blocks to spare, or they fall within the user's quotas too. * We are still seteuid to the user at this point. */ if (hlfsd_diskspace(linkval) < 0) { seteuid(old_userid); setgid(old_groupid); plog(XLOG_WARNING, "no more space in %s: %m", linkval); return alt_spooldir; } else { seteuid(old_userid); setgid(old_groupid); return linkval; } } static int hlfsd_diskspace(char *path) { char buf[MAXPATHLEN]; int fd, len; xsnprintf(buf, sizeof(buf), "%s/._hlfstmp_%lu", path, (long) getpid()); if ((fd = open(buf, O_RDWR | O_CREAT, 0600)) < 0) { plog(XLOG_ERROR, "cannot open %s: %m", buf); return -1; } len = strlen(buf); if (write(fd, buf, len) < len) { plog(XLOG_ERROR, "cannot write \"%s\" (%d bytes) to %s : %m", buf, len, buf); close(fd); unlink(buf); /* cleanup just in case */ return -1; } if (unlink(buf) < 0) { plog(XLOG_ERROR, "cannot unlink %s : %m", buf); } close(fd); return 0; } static int hlfsd_stat(char *path, struct stat *statp) { if (stat(path, statp) < 0) return -1; else if (!S_ISDIR(statp->st_mode)) { errno = ENOTDIR; return -1; } return 0; } static void delay(uid2home_t *found, int secs) { struct timeval tv; if (found) dlog("delaying on child %ld for %d seconds", (long) found->child, secs); tv.tv_usec = 0; do { tv.tv_sec = secs; if (select(0, NULL, NULL, NULL, &tv) == 0) break; } while (--secs && found->child); } /* * This function is called when a child has terminated after * servicing an nfs request. We need to check the exit status and * update the last_status field of the requesting user. */ RETSIGTYPE interlock(int signum) { int child; uid2home_t *lostchild; int status; #ifdef HAVE_WAITPID while ((child = waitpid((pid_t) -1, &status, WNOHANG)) > 0) { #else /* not HAVE_WAITPID */ while ((child = wait3(&status, WNOHANG, (struct rusage *) NULL)) > 0) { #endif /* not HAVE_WAITPID */ /* high chances this was the last child forked */ if (lastchild && lastchild->child == child) { lastchild->child = 0; if (WIFEXITED(status)) lastchild->last_status = WEXITSTATUS(status); lastchild = (uid2home_t *) NULL; } else { /* and if not, we have to search for it... */ for (lostchild = pwtab; lostchild < &pwtab[cur_pwtab_num]; lostchild++) { if (lostchild->child == child) { if (WIFEXITED(status)) lostchild->last_status = WEXITSTATUS(status); lostchild->child = 0; break; } } } } } /* * PASSWORD AND USERNAME LOOKUP TABLES FUNCTIONS */ /* * get index of UserName table entry which matches username. * must not return uid_t because we want to return a negative number. */ int untab_index(char *username) { int max, min, mid, cmp; max = cur_pwtab_num - 1; min = 0; do { mid = (max + min) / 2; cmp = strcmp(untab[mid].username, username); if (cmp == 0) /* record found! */ return mid; if (cmp > 0) max = mid; else min = mid; } while (max > min + 1); if (STREQ(untab[max].username, username)) return max; if (STREQ(untab[min].username, username)) return min; /* if gets here then record was not found */ return -1; } /* * Don't make this return a uid_t, because we need to return negative * numbers as well (error codes.) */ int uidof(char *username) { int idx; if ((idx = untab_index(username)) < 0) /* not found */ return INVALIDID; /* an invalid user id */ return untab[idx].uid; } /* * Don't make this return a uid_t, because we need to return negative * numbers as well (error codes.) */ char * homeof(char *username) { int idx; if ((idx = untab_index(username)) < 0) /* not found */ return (char *) NULL; /* an invalid user id */ return untab[idx].home; } char * mailbox(int uid, char *username) { char *home; if (uid < 0) return (char *) NULL; /* not found */ if ((home = homeof(username)) == (char *) NULL) return (char *) NULL; if (STREQ(home, "/")) xsnprintf(mboxfile, sizeof(mboxfile), "/%s/%s", home_subdir, username); else xsnprintf(mboxfile, sizeof(mboxfile), "%s/%s/%s", home, home_subdir, username); return mboxfile; } static int plt_compare_fxn(const voidp x, const voidp y) { uid2home_t *i = (uid2home_t *) x; uid2home_t *j = (uid2home_t *) y; return i->uid - j->uid; } static int unt_compare_fxn(const voidp x, const voidp y) { username2uid_t *i = (username2uid_t *) x; username2uid_t *j = (username2uid_t *) y; return strcmp(i->username, j->username); } /* perform initialization of user passwd database */ static void hlfsd_setpwent(void) { if (!passwdfile) { setpwent(); return; } passwd_fp = fopen(passwdfile, "r"); if (!passwd_fp) { plog(XLOG_ERROR, "unable to read passwd file %s: %m", passwdfile); return; } plog(XLOG_INFO, "reading password entries from file %s", passwdfile); passwd_line = 0; memset((char *) &passwd_ent, 0, sizeof(struct passwd)); passwd_ent.pw_name = (char *) &pw_name; passwd_ent.pw_dir = (char *) &pw_dir; } /* perform de-initialization of user passwd database */ static void hlfsd_endpwent(void) { if (!passwdfile) { /* * Don't actually run this because we will be making more passwd calls * afterwards. On Solaris 2.5.1, making getpwent() calls after calling * endpwent() results in a memory leak! (and no, even Purify didn't * detect it...) * endpwent(); */ return; } if (passwd_fp) { fclose(passwd_fp); } } /* perform record reading/parsing of individual passwd database records */ static struct passwd * hlfsd_getpwent(void) { char buf[256], *cp; /* check if to perform standard unix function */ if (!passwdfile) { return getpwent(); } /* return here to read another entry */ readent: /* return NULL if reached end of file */ if (feof(passwd_fp)) return NULL; pw_name[0] = pw_dir[0] = '\0'; /* read records */ buf[0] = '\0'; if (fgets(buf, 256, passwd_fp) == NULL) return NULL; passwd_line++; if (buf[0] == '\0') goto readent; /* read user name */ cp = strtok(buf, ":"); if (!cp || cp[0] == '\0') { plog(XLOG_ERROR, "no user name on line %d of %s", passwd_line, passwdfile); goto readent; } /* pw_name will show up in passwd_ent.pw_name */ xstrlcpy(pw_name, cp, sizeof(pw_name)); /* skip passwd */ strtok(NULL, ":"); /* read uid */ cp = strtok(NULL, ":"); if (!cp || cp[0] == '\0') { plog(XLOG_ERROR, "no uid on line %d of %s", passwd_line, passwdfile); goto readent; } passwd_ent.pw_uid = atoi(cp); /* skip gid and gcos */ strtok(NULL, ":"); strtok(NULL, ":"); /* read home dir */ cp = strtok(NULL, ":"); if (!cp || cp[0] == '\0') { plog(XLOG_ERROR, "no home dir on line %d of %s", passwd_line, passwdfile); goto readent; } /* pw_dir will show up in passwd_ent.pw_dir */ xstrlcpy(pw_dir, cp, sizeof(pw_dir)); /* the rest of the fields are unimportant and not being considered */ plog(XLOG_USER, "hlfsd_getpwent: name=%s, uid=%ld, dir=%s", passwd_ent.pw_name, (long) passwd_ent.pw_uid, passwd_ent.pw_dir); return &passwd_ent; } /* * read and hash the passwd file or NIS map */ void plt_init(void) { struct passwd *pent_p; if (plt_reset() < 0) /* could not reset table. skip. */ return; plog(XLOG_INFO, "reading password map"); hlfsd_setpwent(); /* prepare to read passwd entries */ while ((pent_p = hlfsd_getpwent()) != (struct passwd *) NULL) { table_add(pent_p->pw_uid, pent_p->pw_dir, pent_p->pw_name); if (STREQ("root", pent_p->pw_name)) { int len; if (root_home) XFREE(root_home); root_home = strdup(pent_p->pw_dir); len = strlen(root_home); /* remove any trailing '/' chars from root's home (even if just one) */ while (len > 0 && root_home[len - 1] == '/') { len--; root_home[len] = '\0'; } } } hlfsd_endpwent(); qsort((char *) pwtab, cur_pwtab_num, sizeof(uid2home_t), plt_compare_fxn); qsort((char *) untab, cur_pwtab_num, sizeof(username2uid_t), unt_compare_fxn); if (!root_home) root_home = strdup(""); plog(XLOG_INFO, "password map read and sorted"); } /* * This is essentially so that we don't reset known good lookup tables when a * YP server goes down. */ static int plt_reset(void) { int i; hlfsd_setpwent(); if (hlfsd_getpwent() == (struct passwd *) NULL) { hlfsd_endpwent(); return -1; /* did not reset table */ } hlfsd_endpwent(); lastchild = (uid2home_t *) NULL; if (max_pwtab_num > 0) /* was used already. cleanup old table */ for (i = 0; i < cur_pwtab_num; ++i) { if (pwtab[i].home) { XFREE(pwtab[i].home); pwtab[i].home = (char *) NULL; } pwtab[i].uid = INVALIDID; /* not a valid uid (yet...) */ pwtab[i].child = (pid_t) 0; pwtab[i].uname = (char *) NULL; /* only a ptr to untab[i].username */ if (untab[i].username) { XFREE(untab[i].username); untab[i].username = (char *) NULL; } untab[i].uid = INVALIDID; /* invalid uid */ untab[i].home = (char *) NULL; /* only a ptr to pwtab[i].home */ } cur_pwtab_num = 0; /* zero current size */ if (root_home) XFREE(root_home); return 0; /* resetting ok */ } /* * u: uid number * h: home directory * n: user ID name */ static void table_add(u_int u, const char *h, const char *n) { int i; if (max_pwtab_num <= 0) { /* was never initialized */ max_pwtab_num = 1; pwtab = (uid2home_t *) xmalloc(max_pwtab_num * sizeof(uid2home_t)); memset((char *) &pwtab[0], 0, max_pwtab_num * sizeof(uid2home_t)); untab = (username2uid_t *) xmalloc(max_pwtab_num * sizeof(username2uid_t)); memset((char *) &untab[0], 0, max_pwtab_num * sizeof(username2uid_t)); } /* check if need more space. */ if (cur_pwtab_num + 1 > max_pwtab_num) { /* need more space in table */ max_pwtab_num *= 2; plog(XLOG_INFO, "reallocating table spaces to %d entries", max_pwtab_num); pwtab = (uid2home_t *) xrealloc(pwtab, sizeof(uid2home_t) * max_pwtab_num); untab = (username2uid_t *) xrealloc(untab, sizeof(username2uid_t) * max_pwtab_num); /* zero out newly added entries */ for (i=cur_pwtab_num; i u) max = mid; else min = mid; } while (max > min + 1); if (pwtab[max].uid == u) return &pwtab[max]; if (pwtab[min].uid == u) return &pwtab[min]; /* if gets here then record was not found */ return (uid2home_t *) NULL; } #if defined(DEBUG) || defined(DEBUG_PRINT) void plt_print(int signum) { FILE *dumpfile; int dumpfd; char dumptmp[] = "/usr/tmp/hlfsd.dump.XXXXXX"; int i; #ifdef HAVE_MKSTEMP dumpfd = mkstemp(dumptmp); #else /* not HAVE_MKSTEMP */ mktemp(dumptmp); if (!dumptmp) { plog(XLOG_ERROR, "cannot create temporary dump file"); return; } dumpfd = open(dumptmp, O_RDONLY); #endif /* not HAVE_MKSTEMP */ if (dumpfd < 0) { plog(XLOG_ERROR, "cannot open temporary dump file"); return; } if ((dumpfile = fdopen(dumpfd, "a")) != NULL) { plog(XLOG_INFO, "dumping internal state to file %s", dumptmp); fprintf(dumpfile, "\n\nNew plt_dump():\n"); for (i = 0; i < cur_pwtab_num; ++i) fprintf(dumpfile, "%4d %5lu %10lu %1d %4lu \"%s\" uname=\"%s\"\n", i, (long) pwtab[i].child, pwtab[i].last_access_time, pwtab[i].last_status, (long) pwtab[i].uid, pwtab[i].home, pwtab[i].uname); fprintf(dumpfile, "\nUserName table by plt_print():\n"); for (i = 0; i < cur_pwtab_num; ++i) fprintf(dumpfile, "%4d : \"%s\" %4lu \"%s\"\n", i, untab[i].username, (long) untab[i].uid, untab[i].home); close(dumpfd); fclose(dumpfile); } } void plt_dump(uid2home_t *lastc, pid_t this) { FILE *dumpfile; int i; if ((dumpfile = fopen("/var/tmp/hlfsdump", "a")) != NULL) { fprintf(dumpfile, "\n\nNEW PLT_DUMP -- "); fprintf(dumpfile, "lastchild->child=%d ", (int) (lastc ? lastc->child : -999)); fprintf(dumpfile, ", child from wait3=%lu:\n", (long) this); for (i = 0; i < cur_pwtab_num; ++i) fprintf(dumpfile, "%4d %5lu: %4lu \"%s\" uname=\"%s\"\n", i, (long) pwtab[i].child, (long) pwtab[i].uid, pwtab[i].home, pwtab[i].uname); fprintf(dumpfile, "\nUserName table by plt_dump():\n"); for (i = 0; i < cur_pwtab_num; ++i) fprintf(dumpfile, "%4d : \"%s\" %4lu \"%s\"\n", i, untab[i].username, (long) untab[i].uid, untab[i].home); fprintf(dumpfile, "ezk: ent=%d, uid=%lu, home=\"%s\"\n", untab_index("ezk"), (long) untab[untab_index("ezk")].uid, pwtab[untab[untab_index("ezk")].uid].home); fprintf(dumpfile, "rezk: ent=%d, uid=%lu, home=\"%s\"\n", untab_index("rezk"), (long) untab[untab_index("rezk")].uid, pwtab[untab[untab_index("rezk")].uid].home); fclose(dumpfile); } } #endif /* defined(DEBUG) || defined(DEBUG_PRINT) */ am-utils-6.2+rc20110530/hlfsd/nfs_prot_svc.c000066400000000000000000000206101157065440000203020ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/hlfsd/nfs_prot_svc.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* EXTERNAL FUNCTIONS */ extern voidp nfsproc_null_2_svc(voidp, struct svc_req *); extern nfsattrstat *nfsproc_getattr_2_svc(am_nfs_fh *, struct svc_req *); extern nfsattrstat *nfsproc_setattr_2_svc(nfssattrargs *, struct svc_req *); extern voidp nfsproc_root_2_svc(voidp, struct svc_req *); extern nfsdiropres *nfsproc_lookup_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreadlinkres *nfsproc_readlink_2_svc(am_nfs_fh *, struct svc_req *); extern nfsreadres *nfsproc_read_2_svc(nfsreadargs *, struct svc_req *); extern voidp nfsproc_writecache_2_svc(voidp, struct svc_req *); extern nfsattrstat *nfsproc_write_2_svc(nfswriteargs *, struct svc_req *); extern nfsdiropres *nfsproc_create_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_remove_2_svc(nfsdiropargs *, struct svc_req *); extern nfsstat *nfsproc_rename_2_svc(nfsrenameargs *, struct svc_req *); extern nfsstat *nfsproc_link_2_svc(nfslinkargs *, struct svc_req *); extern nfsstat *nfsproc_symlink_2_svc(nfssymlinkargs *, struct svc_req *); extern nfsdiropres *nfsproc_mkdir_2_svc(nfscreateargs *, struct svc_req *); extern nfsstat *nfsproc_rmdir_2_svc(nfsdiropargs *, struct svc_req *); extern nfsreaddirres *nfsproc_readdir_2_svc(nfsreaddirargs *, struct svc_req *); extern nfsstatfsres *nfsproc_statfs_2_svc(am_nfs_fh *, struct svc_req *); /* GLOBALS */ SVCXPRT *nfs_program_2_transp; /* TYPEDEFS */ typedef char *(*nfssvcproc_t)(voidp, struct svc_req *); void nfs_program_2(struct svc_req *rqstp, SVCXPRT *transp) { union { am_nfs_fh nfsproc_getattr_2_arg; nfssattrargs nfsproc_setattr_2_arg; nfsdiropargs nfsproc_lookup_2_arg; am_nfs_fh nfsproc_readlink_2_arg; nfsreadargs nfsproc_read_2_arg; nfswriteargs nfsproc_write_2_arg; nfscreateargs nfsproc_create_2_arg; nfsdiropargs nfsproc_remove_2_arg; nfsrenameargs nfsproc_rename_2_arg; nfslinkargs nfsproc_link_2_arg; nfssymlinkargs nfsproc_symlink_2_arg; nfscreateargs nfsproc_mkdir_2_arg; nfsdiropargs nfsproc_rmdir_2_arg; nfsreaddirargs nfsproc_readdir_2_arg; am_nfs_fh nfsproc_statfs_2_arg; } argument; char *result; xdrproc_t xdr_argument, xdr_result; nfssvcproc_t local; nfs_program_2_transp = NULL; switch (rqstp->rq_proc) { case NFSPROC_NULL: xdr_argument = (xdrproc_t) xdr_void; xdr_result = (xdrproc_t) xdr_void; local = (nfssvcproc_t) nfsproc_null_2_svc; break; case NFSPROC_GETATTR: xdr_argument = (xdrproc_t) xdr_nfs_fh; xdr_result = (xdrproc_t) xdr_attrstat; local = (nfssvcproc_t) nfsproc_getattr_2_svc; break; case NFSPROC_SETATTR: xdr_argument = (xdrproc_t) xdr_sattrargs; xdr_result = (xdrproc_t) xdr_attrstat; local = (nfssvcproc_t) nfsproc_setattr_2_svc; break; case NFSPROC_ROOT: xdr_argument = (xdrproc_t) xdr_void; xdr_result = (xdrproc_t) xdr_void; local = (nfssvcproc_t) nfsproc_root_2_svc; break; case NFSPROC_LOOKUP: xdr_argument = (xdrproc_t) xdr_diropargs; xdr_result = (xdrproc_t) xdr_diropres; local = (nfssvcproc_t) nfsproc_lookup_2_svc; /* * Cheap way to pass transp down to afs_lookuppn so it can * be stored in the am_node structure and later used for * quick_reply(). */ nfs_program_2_transp = transp; break; case NFSPROC_READLINK: xdr_argument = (xdrproc_t) xdr_nfs_fh; xdr_result = (xdrproc_t) xdr_readlinkres; local = (nfssvcproc_t) nfsproc_readlink_2_svc; break; case NFSPROC_READ: xdr_argument = (xdrproc_t) xdr_readargs; xdr_result = (xdrproc_t) xdr_readres; local = (nfssvcproc_t) nfsproc_read_2_svc; break; case NFSPROC_WRITECACHE: xdr_argument = (xdrproc_t) xdr_void; xdr_result = (xdrproc_t) xdr_void; local = (nfssvcproc_t) nfsproc_writecache_2_svc; break; case NFSPROC_WRITE: xdr_argument = (xdrproc_t) xdr_writeargs; xdr_result = (xdrproc_t) xdr_attrstat; local = (nfssvcproc_t) nfsproc_write_2_svc; break; case NFSPROC_CREATE: xdr_argument = (xdrproc_t) xdr_createargs; xdr_result = (xdrproc_t) xdr_diropres; local = (nfssvcproc_t) nfsproc_create_2_svc; break; case NFSPROC_REMOVE: xdr_argument = (xdrproc_t) xdr_diropargs; xdr_result = (xdrproc_t) xdr_nfsstat; local = (nfssvcproc_t) nfsproc_remove_2_svc; break; case NFSPROC_RENAME: xdr_argument = (xdrproc_t) xdr_renameargs; xdr_result = (xdrproc_t) xdr_nfsstat; local = (nfssvcproc_t) nfsproc_rename_2_svc; break; case NFSPROC_LINK: xdr_argument = (xdrproc_t) xdr_linkargs; xdr_result = (xdrproc_t) xdr_nfsstat; local = (nfssvcproc_t) nfsproc_link_2_svc; break; case NFSPROC_SYMLINK: xdr_argument = (xdrproc_t) xdr_symlinkargs; xdr_result = (xdrproc_t) xdr_nfsstat; local = (nfssvcproc_t) nfsproc_symlink_2_svc; break; case NFSPROC_MKDIR: xdr_argument = (xdrproc_t) xdr_createargs; xdr_result = (xdrproc_t) xdr_diropres; local = (nfssvcproc_t) nfsproc_mkdir_2_svc; break; case NFSPROC_RMDIR: xdr_argument = (xdrproc_t) xdr_diropargs; xdr_result = (xdrproc_t) xdr_nfsstat; local = (nfssvcproc_t) nfsproc_rmdir_2_svc; break; case NFSPROC_READDIR: xdr_argument = (xdrproc_t) xdr_readdirargs; xdr_result = (xdrproc_t) xdr_readdirres; local = (nfssvcproc_t) nfsproc_readdir_2_svc; break; case NFSPROC_STATFS: xdr_argument = (xdrproc_t) xdr_nfs_fh; xdr_result = (xdrproc_t) xdr_statfsres; local = (nfssvcproc_t) nfsproc_statfs_2_svc; break; default: svcerr_noproc(transp); return; } memset((char *) &argument, 0, sizeof(argument)); if (!svc_getargs(transp, (XDRPROC_T_TYPE) xdr_argument, (SVC_IN_ARG_TYPE) &argument)) { plog(XLOG_ERROR, "NFS xdr decode failed for %d %d %d", (int) rqstp->rq_prog, (int) rqstp->rq_vers, (int) rqstp->rq_proc); svcerr_decode(transp); return; } result = (*local) (&argument, rqstp); nfs_program_2_transp = NULL; if (result != NULL && !svc_sendreply(transp, (XDRPROC_T_TYPE) xdr_result, result)) { svcerr_systemerr(transp); } if (!svc_freeargs(transp, (XDRPROC_T_TYPE) xdr_argument, (SVC_IN_ARG_TYPE) & argument)) { plog(XLOG_FATAL, "unable to free rpc arguments in nfs_program_2"); going_down(1); } } am-utils-6.2+rc20110530/hlfsd/stubs.c000066400000000000000000000342571157065440000167510ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/hlfsd/stubs.c * * HLFSD was written at Columbia University Computer Science Department, by * Erez Zadok and Alexander Dupuy * It is being distributed under the same terms and conditions as amd does. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * STATIC VARIABLES: */ static nfsfattr rootfattr = {NFDIR, 0040555, 2, 0, 0, 512, 512, 0, 1, 0, ROOTID}; static nfsfattr slinkfattr = {NFLNK, 0120777, 1, 0, 0, NFS_MAXPATHLEN, 512, 0, (NFS_MAXPATHLEN + 1) / 512, 0, SLINKID}; /* user name file attributes */ static nfsfattr un_fattr = {NFLNK, 0120777, 1, 0, 0, NFS_MAXPATHLEN, 512, 0, (NFS_MAXPATHLEN + 1) / 512, 0, INVALIDID}; static int started; static am_nfs_fh slink; static am_nfs_fh un_fhandle; /* * GLOBALS: */ am_nfs_fh root; am_nfs_fh *root_fhp = &root; /* initialize NFS file handles for hlfsd */ void hlfsd_init_filehandles(void) { u_int ui; ui = ROOTID; memcpy(root.fh_data, &ui, sizeof(ui)); ui = SLINKID; memcpy(slink.fh_data, &ui, sizeof(ui)); ui = INVALIDID; memcpy(un_fhandle.fh_data, &ui, sizeof(ui)); } voidp nfsproc_null_2_svc(voidp argp, struct svc_req *rqstp) { static char res; return (voidp) &res; } /* compare if two filehandles are equal */ static int eq_fh(const am_nfs_fh *fh1, const am_nfs_fh *fh2) { return (!memcmp((char *) fh1, (char *) fh2, sizeof(am_nfs_fh))); } nfsattrstat * nfsproc_getattr_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) { static nfsattrstat res; uid_t uid = (uid_t) INVALIDID; gid_t gid = (gid_t) INVALIDID; if (!started) { started++; rootfattr.na_ctime = startup; rootfattr.na_mtime = startup; slinkfattr.na_ctime = startup; slinkfattr.na_mtime = startup; un_fattr.na_ctime = startup; un_fattr.na_mtime = startup; } if (getcreds(rqstp, &uid, &gid, nfsxprt) < 0) { res.ns_status = NFSERR_STALE; return &res; } if (eq_fh(argp, &root)) { #if 0 /* * XXX: increment mtime of parent directory, causes NFS clients to * invalidate their cache for that directory. * Some NFS clients may need this code. */ if (uid != rootfattr.na_uid) { clocktime(&rootfattr.na_mtime); rootfattr.na_uid = uid; } #endif /* 0 */ res.ns_status = NFS_OK; res.ns_u.ns_attr_u = rootfattr; } else if (eq_fh(argp, &slink)) { #ifndef MNT2_NFS_OPT_SYMTTL /* * This code is needed to defeat Solaris 2.4's (and newer) symlink * values cache. It forces the last-modified time of the symlink to be * current. It is not needed if the O/S has an nfs flag to turn off the * symlink-cache at mount time (such as Irix 5.x and 6.x). -Erez. * * Additionally, Linux currently ignores the nt_useconds field, * so we must update the nt_seconds field every time. */ if (uid != slinkfattr.na_uid) { clocktime(&slinkfattr.na_mtime); slinkfattr.na_uid = uid; } #endif /* not MNT2_NFS_OPT_SYMTTL */ res.ns_status = NFS_OK; res.ns_u.ns_attr_u = slinkfattr; } else { if (gid != hlfs_gid) { res.ns_status = NFSERR_STALE; } else { (void)memcpy(&uid, argp->fh_data, sizeof(uid)); if (plt_search(uid) != (uid2home_t *) NULL) { res.ns_status = NFS_OK; un_fattr.na_fileid = uid; res.ns_u.ns_attr_u = un_fattr; dlog("nfs_getattr: successful search for uid=%ld, gid=%ld", (long) uid, (long) gid); } else { /* not found */ res.ns_status = NFSERR_STALE; } } } return &res; } nfsattrstat * nfsproc_setattr_2_svc(nfssattrargs *argp, struct svc_req *rqstp) { static nfsattrstat res = {NFSERR_ROFS}; return &res; } voidp nfsproc_root_2_svc(voidp argp, struct svc_req *rqstp) { static char res; return (voidp) &res; } nfsdiropres * nfsproc_lookup_2_svc(nfsdiropargs *argp, struct svc_req *rqstp) { static nfsdiropres res; int idx; uid_t uid = (uid_t) INVALIDID; gid_t gid = (gid_t) INVALIDID; if (!started) { started++; rootfattr.na_ctime = startup; rootfattr.na_mtime = startup; slinkfattr.na_ctime = startup; slinkfattr.na_mtime = startup; un_fattr.na_ctime = startup; un_fattr.na_mtime = startup; } if (eq_fh(&argp->da_fhandle, &slink)) { res.dr_status = NFSERR_NOTDIR; return &res; } if (getcreds(rqstp, &uid, &gid, nfsxprt) < 0) { res.dr_status = NFSERR_NOENT; return &res; } if (eq_fh(&argp->da_fhandle, &root)) { if (argp->da_name[0] == '.' && (argp->da_name[1] == '\0' || (argp->da_name[1] == '.' && argp->da_name[2] == '\0'))) { #if 0 /* * XXX: increment mtime of parent directory, causes NFS clients to * invalidate their cache for that directory. * Some NFS clients may need this code. */ if (uid != rootfattr.na_uid) { clocktime(&rootfattr.na_mtime); rootfattr.na_uid = uid; } #endif /* 0 */ res.dr_u.dr_drok_u.drok_fhandle = root; res.dr_u.dr_drok_u.drok_attributes = rootfattr; res.dr_status = NFS_OK; return &res; } if (STREQ(argp->da_name, slinkname)) { #ifndef MNT2_NFS_OPT_SYMTTL /* * This code is needed to defeat Solaris 2.4's (and newer) symlink * values cache. It forces the last-modified time of the symlink to be * current. It is not needed if the O/S has an nfs flag to turn off the * symlink-cache at mount time (such as Irix 5.x and 6.x). -Erez. * * Additionally, Linux currently ignores the nt_useconds field, * so we must update the nt_seconds field every time. */ if (uid != slinkfattr.na_uid) { clocktime(&slinkfattr.na_mtime); slinkfattr.na_uid = uid; } #endif /* not MNT2_NFS_OPT_SYMTTL */ res.dr_u.dr_drok_u.drok_fhandle = slink; res.dr_u.dr_drok_u.drok_attributes = slinkfattr; res.dr_status = NFS_OK; return &res; } if (gid != hlfs_gid) { res.dr_status = NFSERR_NOENT; return &res; } /* if gets here, gid == hlfs_gid */ if ((idx = untab_index(argp->da_name)) < 0) { res.dr_status = NFSERR_NOENT; return &res; } else { /* entry found and gid is permitted */ un_fattr.na_fileid = untab[idx].uid; res.dr_u.dr_drok_u.drok_attributes = un_fattr; memset(&un_fhandle, 0, sizeof(un_fhandle)); memcpy(un_fhandle.fh_data, &untab[idx].uid, sizeof(untab[idx].uid)); xstrlcpy((char *) &un_fhandle.fh_data[sizeof(int)], untab[idx].username, sizeof(am_nfs_fh) - sizeof(int)); res.dr_u.dr_drok_u.drok_fhandle = un_fhandle; res.dr_status = NFS_OK; dlog("nfs_lookup: successful lookup for uid=%ld, gid=%ld: username=%s", (long) uid, (long) gid, untab[idx].username); return &res; } } /* end of "if (eq_fh(argp->dir.data, root.data)) {" */ res.dr_status = NFSERR_STALE; return &res; } nfsreadlinkres * nfsproc_readlink_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) { static nfsreadlinkres res; uid_t userid = (uid_t) INVALIDID; gid_t groupid = hlfs_gid + 1; /* anything not hlfs_gid */ int retval = 0; char *path_val = (char *) NULL; char *username; static uid_t last_uid = (uid_t) INVALIDID; if (eq_fh(argp, &root)) { res.rlr_status = NFSERR_ISDIR; } else if (eq_fh(argp, &slink)) { if (getcreds(rqstp, &userid, &groupid, nfsxprt) < 0) return (nfsreadlinkres *) NULL; clocktime(&slinkfattr.na_atime); res.rlr_status = NFS_OK; if (groupid == hlfs_gid) { res.rlr_u.rlr_data_u = DOTSTRING; } else if (!(res.rlr_u.rlr_data_u = path_val = homedir(userid, groupid))) { /* * parent process (fork in homedir()) continues * processing, by getting a NULL returned as a * "special". Child returns result. */ return (nfsreadlinkres *) NULL; } } else { /* check if asked for user mailbox */ if (getcreds(rqstp, &userid, &groupid, nfsxprt) < 0) { return (nfsreadlinkres *) NULL; } if (groupid == hlfs_gid) { memcpy(&userid, argp->fh_data, sizeof(userid)); username = (char *) &argp->fh_data[sizeof(int)]; if (!(res.rlr_u.rlr_data_u = mailbox(userid, username))) return (nfsreadlinkres *) NULL; } else { res.rlr_status = NFSERR_STALE; } } /* print info, but try to avoid repetitions */ if (userid != last_uid) { plog(XLOG_USER, "mailbox for uid=%ld, gid=%ld is %s", (long) userid, (long) groupid, (char *) res.rlr_u.rlr_data_u); last_uid = userid; } /* I don't think it will pass this if -D fork */ if (serverpid == getpid()) return &res; if (!svc_sendreply(nfsxprt, (XDRPROC_T_TYPE) xdr_readlinkres, (SVC_IN_ARG_TYPE) &res)) svcerr_systemerr(nfsxprt); /* * Child exists here. We need to determine which * exist status to return. The exit status * is gathered using wait() and determines * if we returned $HOME/.hlfsspool or $ALTDIR. The parent * needs this info so it can update the lookup table. */ if (path_val && alt_spooldir && STREQ(path_val, alt_spooldir)) retval = 1; /* could not get real home dir (or uid 0 user) */ else retval = 0; /* * If asked for -D nofork, then must return the value, * NOT exit, or else the main hlfsd server exits. * If -D fork (default), then we do want to exit from the process. * Bug: where is that status information being collected? */ if (amuDebug(D_FORK)) exit(retval); else return &res; } nfsreadres * nfsproc_read_2_svc(nfsreadargs *argp, struct svc_req *rqstp) { static nfsreadres res = {NFSERR_ACCES}; return &res; } voidp nfsproc_writecache_2_svc(voidp argp, struct svc_req *rqstp) { static char res; return (voidp) &res; } nfsattrstat * nfsproc_write_2_svc(nfswriteargs *argp, struct svc_req *rqstp) { static nfsattrstat res = {NFSERR_ROFS}; return &res; } nfsdiropres * nfsproc_create_2_svc(nfscreateargs *argp, struct svc_req *rqstp) { static nfsdiropres res = {NFSERR_ROFS}; return &res; } nfsstat * nfsproc_remove_2_svc(nfsdiropargs *argp, struct svc_req *rqstp) { static nfsstat res = {NFSERR_ROFS}; return &res; } nfsstat * nfsproc_rename_2_svc(nfsrenameargs *argp, struct svc_req *rqstp) { static nfsstat res = {NFSERR_ROFS}; return &res; } nfsstat * nfsproc_link_2_svc(nfslinkargs *argp, struct svc_req *rqstp) { static nfsstat res = {NFSERR_ROFS}; return &res; } nfsstat * nfsproc_symlink_2_svc(nfssymlinkargs *argp, struct svc_req *rqstp) { static nfsstat res = {NFSERR_ROFS}; return &res; } nfsdiropres * nfsproc_mkdir_2_svc(nfscreateargs *argp, struct svc_req *rqstp) { static nfsdiropres res = {NFSERR_ROFS}; return &res; } nfsstat * nfsproc_rmdir_2_svc(nfsdiropargs *argp, struct svc_req *rqstp) { static nfsstat res = {NFSERR_ROFS}; return &res; } nfsreaddirres * nfsproc_readdir_2_svc(nfsreaddirargs *argp, struct svc_req *rqstp) { static nfsreaddirres res; static nfsentry slinkent = {SLINKID, NULL, {SLINKCOOKIE}}; static nfsentry dotdotent = {ROOTID, "..", {DOTDOTCOOKIE}, &slinkent}; static nfsentry dotent = {ROOTID, ".", {DOTCOOKIE}, &dotdotent}; slinkent.ne_name = slinkname; if (eq_fh(&argp->rda_fhandle, &slink)) { res.rdr_status = NFSERR_NOTDIR; } else if (eq_fh(&argp->rda_fhandle, &root)) { clocktime(&rootfattr.na_atime); res.rdr_status = NFS_OK; switch (argp->rda_cookie[0]) { case 0: res.rdr_u.rdr_reply_u.dl_entries = &dotent; break; case DOTCOOKIE: res.rdr_u.rdr_reply_u.dl_entries = &dotdotent; break; case DOTDOTCOOKIE: res.rdr_u.rdr_reply_u.dl_entries = &slinkent; break; case SLINKCOOKIE: res.rdr_u.rdr_reply_u.dl_entries = (nfsentry *) NULL; break; } res.rdr_u.rdr_reply_u.dl_eof = TRUE; } else { res.rdr_status = NFSERR_STALE; } return &res; } nfsstatfsres * nfsproc_statfs_2_svc(am_nfs_fh *argp, struct svc_req *rqstp) { static nfsstatfsres res = {NFS_OK}; res.sfr_u.sfr_reply_u.sfrok_tsize = 1024; res.sfr_u.sfr_reply_u.sfrok_bsize = 1024; /* * Some "df" programs automatically assume that file systems * with zero blocks are meta-filesystems served by automounters. */ res.sfr_u.sfr_reply_u.sfrok_blocks = 0; res.sfr_u.sfr_reply_u.sfrok_bfree = 0; res.sfr_u.sfr_reply_u.sfrok_bavail = 0; return &res; } am-utils-6.2+rc20110530/include/000077500000000000000000000000001157065440000157555ustar00rootroot00000000000000am-utils-6.2+rc20110530/include/am_compat.h000066400000000000000000000414421157065440000200730ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/include/am_compat.h * */ /* * * This file contains compatibility functions and macros, all of which * should be auto-discovered, but for one reason or another (mostly * brain-damage on the part of system designers and header files) they cannot. * * Each compatibility macro/function must include instructions on how/when * it can be removed the am-utils code. * */ #ifndef _AM_COMPAT_H # define _AM_COMPAT_H /* * incomplete mount options definitions (sunos4, irix6, linux, etc.) */ /* * Complete MNTTAB_OPT_* options based on MNT2_NFS_OPT_* mount options. */ #if defined(MNT2_NFS_OPT_ACDIRMAX) && !defined(MNTTAB_OPT_ACDIRMAX) # define MNTTAB_OPT_ACDIRMAX "acdirmax" #endif /* defined(MNT2_NFS_OPT_ACDIRMAX) && !defined(MNTTAB_OPT_ACDIRMAX) */ #if defined(MNT2_NFS_OPT_ACDIRMIN) && !defined(MNTTAB_OPT_ACDIRMIN) # define MNTTAB_OPT_ACDIRMIN "acdirmin" #endif /* defined(MNT2_NFS_OPT_ACDIRMIN) && !defined(MNTTAB_OPT_ACDIRMIN) */ #if defined(MNT2_NFS_OPT_ACREGMAX) && !defined(MNTTAB_OPT_ACREGMAX) # define MNTTAB_OPT_ACREGMAX "acregmax" #endif /* defined(MNT2_NFS_OPT_ACREGMAX) && !defined(MNTTAB_OPT_ACREGMAX) */ #if defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNTTAB_OPT_ACREGMIN) # define MNTTAB_OPT_ACREGMIN "acregmin" #endif /* defined(MNT2_NFS_OPT_ACREGMIN) && !defined(MNTTAB_OPT_ACREGMIN) */ #if !defined(MNTTAB_OPT_IGNORE) /* SunOS 4.1.x and others define "noauto" option, but not "auto" */ # if defined(MNTTAB_OPT_NOAUTO) && !defined(MNTTAB_OPT_AUTO) # define MNTTAB_OPT_AUTO "auto" # endif /* defined(MNTTAB_OPT_NOAUTO) && !defined(MNTTAB_OPT_AUTO) */ #endif /* !defined(MNTTAB_OPT_IGNORE) */ #if defined(MNT2_NFS_OPT_NOAC) && !defined(MNTTAB_OPT_NOAC) # define MNTTAB_OPT_NOAC "noac" #endif /* defined(MNT2_NFS_OPT_NOAC) && !defined(MNTTAB_OPT_NOAC) */ #if defined(MNT2_NFS_OPT_NOCONN) && !defined(MNTTAB_OPT_NOCONN) # define MNTTAB_OPT_NOCONN "noconn" # ifndef MNTTAB_OPT_CONN # define MNTTAB_OPT_CONN "conn" # endif /* MNTTAB_OPT_CONN */ #endif /* defined(MNT2_NFS_OPT_NOCONN) && !defined(MNTTAB_OPT_NOCONN) */ #if defined(MNT2_NFS_OPT_PGTHRESH) && !defined(MNTTAB_OPT_PGTHRESH) # define MNTTAB_OPT_PGTHRESH "pgthresh" #endif /* defined(MNT2_NFS_OPT_PGTHRESH) && !defined(MNTTAB_OPT_PGTHRESH) */ #if defined(MNT2_NFS_OPT_PRIVATE) && !defined(MNTTAB_OPT_PRIVATE) # define MNTTAB_OPT_PRIVATE "private" #endif /* defined(MNT2_NFS_OPT_PRIVATE) && !defined(MNTTAB_OPT_PRIVATE) */ #if defined(MNT2_NFS_OPT_RETRANS) && !defined(MNTTAB_OPT_RETRANS) # define MNTTAB_OPT_RETRANS "retrans" #endif /* defined(MNT2_NFS_OPT_RETRANS) && !defined(MNTTAB_OPT_RETRANS) */ #if defined(MNT2_NFS_OPT_RSIZE) && !defined(MNTTAB_OPT_RSIZE) # define MNTTAB_OPT_RSIZE "rsize" #endif /* defined(MNT2_NFS_OPT_RSIZE) && !defined(MNTTAB_OPT_RSIZE) */ #if defined(MNT2_NFS_OPT_SOFT) && !defined(MNTTAB_OPT_SOFT) # define MNTTAB_OPT_SOFT "soft" # ifndef MNTTAB_OPT_HARD # define MNTTAB_OPT_HARD "hard" # endif /* not MNTTAB_OPT_HARD */ #endif /* defined(MNT2_NFS_OPT_SOFT) && !defined(MNTTAB_OPT_SOFT) */ #if defined(MNT2_NFS_OPT_TIMEO) && !defined(MNTTAB_OPT_TIMEO) # define MNTTAB_OPT_TIMEO "timeo" #endif /* defined(MNT2_NFS_OPT_TIMEO) && !defined(MNTTAB_OPT_TIMEO) */ #if defined(MNT2_NFS_OPT_WSIZE) && !defined(MNTTAB_OPT_WSIZE) # define MNTTAB_OPT_WSIZE "wsize" #endif /* defined(MNT2_NFS_OPT_WSIZE) && !defined(MNTTAB_OPT_WSIZE) */ #if defined(MNT2_NFS_OPT_MAXGRPS) && !defined(MNTTAB_OPT_MAXGROUPS) # define MNTTAB_OPT_MAXGROUPS "maxgroups" #endif /* defined(MNT2_NFS_OPT_MAXGRPS) && !defined(MNTTAB_OPT_MAXGROUPS) */ #if defined(MNT2_NFS_OPT_PROPLIST) && !defined(MNTTAB_OPT_PROPLIST) # define MNTTAB_OPT_PROPLIST "proplist" #endif /* defined(MNT2_NFS_OPT_PROPLIST) && !defined(MNTTAB_OPT_PROPLIST) */ #if defined(MNT2_NFS_OPT_NONLM) && !defined(MNTTAB_OPT_NOLOCK) # define MNTTAB_OPT_NOLOCK "nolock" #endif /* defined(MNT2_NFS_OPT_NONLM) && !defined(MNTTAB_OPT_NOLOCK) */ #if defined(MNT2_NFS_OPT_XLATECOOKIE) && !defined(MNTTAB_OPT_XLATECOOKIE) # define MNTTAB_OPT_XLATECOOKIE "xlatecookie" #endif /* defined(MNT2_NFS_OPT_XLATECOOKIE) && !defined(MNTTAB_OPT_XLATECOOKIE) */ /* * Complete MNTTAB_OPT_* options based on MNT2_CDFS_OPT_* mount options. */ #if defined(MNT2_CDFS_OPT_DEFPERM) && !defined(MNTTAB_OPT_DEFPERM) # define MNTTAB_OPT_DEFPERM "defperm" #endif /* defined(MNT2_CDFS_OPT_DEFPERM) && !defined(MNTTAB_OPT_DEFPERM) */ #if defined(MNT2_CDFS_OPT_NODEFPERM) && !defined(MNTTAB_OPT_NODEFPERM) # define MNTTAB_OPT_NODEFPERM "nodefperm" /* * DEC OSF/1 V3.x/Digital UNIX V4.0 have M_NODEFPERM only, but * both mnttab ops. */ # ifndef MNTTAB_OPT_DEFPERM # define MNTTAB_OPT_DEFPERM "defperm" # endif /* not MNTTAB_OPT_DEFPERM */ #endif /* defined(MNT2_CDFS_OPT_NODEFPERM) && !defined(MNTTAB_OPT_NODEFPERM) */ #if defined(MNT2_CDFS_OPT_NOVERSION) && !defined(MNTTAB_OPT_NOVERSION) # define MNTTAB_OPT_NOVERSION "noversion" #endif /* defined(MNT2_CDFS_OPT_NOVERSION) && !defined(MNTTAB_OPT_NOVERSION) */ #if defined(MNT2_CDFS_OPT_RRIP) && !defined(MNTTAB_OPT_RRIP) # define MNTTAB_OPT_RRIP "rrip" #endif /* defined(MNT2_CDFS_OPT_RRIP) && !defined(MNTTAB_OPT_RRIP) */ #if defined(MNT2_CDFS_OPT_NORRIP) && !defined(MNTTAB_OPT_NORRIP) # define MNTTAB_OPT_NORRIP "norrip" #endif /* defined(MNT2_CDFS_OPT_NORRIP) && !defined(MNTTAB_OPT_NORRIP) */ #if defined(MNT2_CDFS_OPT_GENS) && !defined(MNTTAB_OPT_GENS) # define MNTTAB_OPT_GENS "gens" #endif /* defined(MNT2_CDFS_OPT_GENS) && !defined(MNTTAB_OPT_GENS) */ #if defined(MNT2_CDFS_OPT_EXTATT) && !defined(MNTTAB_OPT_EXTATT) # define MNTTAB_OPT_EXTATT "extatt" #endif /* defined(MNT2_CDFS_OPT_EXTATT) && !defined(MNTTAB_OPT_EXTATT) */ #if defined(MNT2_CDFS_OPT_NOJOLIET) && !defined(MNTTAB_OPT_NOJOLIET) # define MNTTAB_OPT_NOJOLIET "nojoliet" #endif /* defined(MNT2_CDFS_OPT_NOJOLIET) && !defined(MNTTAB_OPT_NOJOLIET) */ #if defined(MNT2_CDFS_OPT_NOCASETRANS) && !defined(MNTTAB_OPT_NOCASETRANS) # define MNTTAB_OPT_NOCASETRANS "nocasetrans" #endif /* defined(MNT2_CDFS_OPT_NOCASETRANS) && !defined(MNTTAB_OPT_NOCASETRANS) */ #if defined(MNT2_CDFS_OPT_RRCASEINS) && !defined(MNTTAB_OPT_RRCASEINS) # define MNTTAB_OPT_RRCASEINS "rrcaseins" #endif /* defined(MNT2_CDFS_OPT_RRCASEINS) && !defined(MNTTAB_OPT_RRCASEINS) */ /* * Complete MNTTAB_OPT_* options based on MNT2_UDF_OPT_* mount options. */ #if defined(MNT2_UDF_OPT_CLOSESESSION) && !defined(MNTTAB_OPT_CLOSESESSION) # define MNTTAB_OPT_CLOSESESSION "closesession" #endif /* defined(MNT2_UDF_OPT_CLOSESESSION) && !defined(MNTTAB_OPT_CLOSESESSION) */ /* * Complete MNTTAB_OPT_* options based on MNT2_PCFS_OPT_* mount options. */ #if defined(MNT2_PCFS_OPT_LONGNAME) && !defined(MNTTAB_OPT_LONGNAME) # define MNTTAB_OPT_LONGNAME "longnames" #endif /* defined(MNT2_PCFS_OPT_LONGNAME) && !defined(MNTTAB_OPT_LONGNAME) */ #if defined(MNT2_PCFS_OPT_NOWIN95) && !defined(MNTTAB_OPT_NOWIN95) # define MNTTAB_OPT_NOWIN95 "nowin95" #endif /* defined(MNT2_PCFS_OPT_NOWIN95) && !defined(MNTTAB_OPT_NOWIN95) */ #if defined(MNT2_PCFS_OPT_SHORTNAME) && !defined(MNTTAB_OPT_SHORTNAME) # define MNTTAB_OPT_SHORTNAME "shortnames" #endif /* defined(MNT2_PCFS_OPT_SHORTNAME) && !defined(MNTTAB_OPT_SHORTNAME) */ /* * Complete MNTTAB_OPT_* options based on MNT2_GEN_OPT_* mount options. */ #if defined(MNT2_GEN_OPT_GRPID) && !defined(MNTTAB_OPT_GRPID) # define MNTTAB_OPT_GRPID "grpid" #endif /* defined(MNT2_GEN_OPT_GRPID) && !defined(MNTTAB_OPT_GRPID) */ #if defined(MNT2_GEN_OPT_NOCACHE) && !defined(MNTTAB_OPT_NOCACHE) # define MNTTAB_OPT_NOCACHE "nocache" #endif /* defined(MNT2_GEN_OPT_NOCACHE) && !defined(MNTTAB_OPT_NOCACHE) */ #if defined(MNT2_GEN_OPT_NOSUID) && !defined(MNTTAB_OPT_NOSUID) # define MNTTAB_OPT_NOSUID "nosuid" #endif /* defined(MNT2_GEN_OPT_NOSUID) && !defined(MNTTAB_OPT_NOSUID) */ #if defined(MNT2_GEN_OPT_OVERLAY) && !defined(MNTTAB_OPT_OVERLAY) # define MNTTAB_OPT_OVERLAY "overlay" #endif /* defined(MNT2_GEN_OPT_OVERLAY) && !defined(MNTTAB_OPT_OVERLAY) */ /* * Complete MNTTAB_OPT_* options and their inverse based on MNT2_GEN_OPT_* * options. */ #if defined(MNT2_GEN_OPT_NODEV) && !defined(MNTTAB_OPT_NODEV) # define MNTTAB_OPT_NODEV "nodev" #endif /* defined(MNT2_GEN_OPT_NODEV) && !defined(MNTTAB_OPT_NODEV) */ #if defined(MNT2_GEN_OPT_NOEXEC) && !defined(MNTTAB_OPT_NOEXEC) # define MNTTAB_OPT_NOEXEC "noexec" /* this is missing under some versions of Linux */ # ifndef MNTTAB_OPT_EXEC # define MNTTAB_OPT_EXEC "exec" # endif /* not MNTTAB_OPT_EXEC */ #endif /* defined(MNT2_GEN_OPT_NOEXEC) && !defined(MNTTAB_OPT_NOEXEC) */ #if defined(MNT2_GEN_OPT_QUOTA) && !defined(MNTTAB_OPT_QUOTA) # define MNTTAB_OPT_QUOTA "quota" #endif /* defined(MNT2_GEN_OPT_QUOTA) && !defined(MNTTAB_OPT_QUOTA) */ #if defined(MNT2_GEN_OPT_SYNC) && !defined(MNTTAB_OPT_SYNC) # define MNTTAB_OPT_SYNC "sync" #endif /* defined(MNT2_GEN_OPT_SYNC) && !defined(MNTTAB_OPT_SYNC) */ #if defined(MNT2_GEN_OPT_LOG) && !defined(MNTTAB_OPT_LOG) # define MNTTAB_OPT_LOG "log" #endif /* defined(MNT2_GEN_OPT_LOG) && !defined(MNTTAB_OPT_LOG) */ #if defined(MNT2_GEN_OPT_NOATIME) && !defined(MNTTAB_OPT_NOATIME) # define MNTTAB_OPT_LOG "noatime" #endif /* defined(MNT2_GEN_OPT_NOATIME) && !defined(MNTTAB_OPT_NOATIME) */ #if defined(MNT2_GEN_OPT_NODEVMTIME) && !defined(MNTTAB_OPT_NODEVMTIME) # define MNTTAB_OPT_LOG "nodevmtime" #endif /* defined(MNT2_GEN_OPT_NODEVMTIME) && !defined(MNTTAB_OPT_NODEVMTIME) */ #if defined(MNT2_GEN_OPT_SOFTDEP) && !defined(MNTTAB_OPT_SOFTDEP) # define MNTTAB_OPT_LOG "softdep" #endif /* defined(MNT2_GEN_OPT_SOFTDEP) && !defined(MNTTAB_OPT_SOFTDEP) */ #if defined(MNT2_GEN_OPT_SYMPERM) && !defined(MNTTAB_OPT_SYMPERM) # define MNTTAB_OPT_LOG "symperm" #endif /* defined(MNT2_GEN_OPT_SYMPERM) && !defined(MNTTAB_OPT_SYMPERM) */ #if defined(MNT2_GEN_OPT_UNION) && !defined(MNTTAB_OPT_UNION) # define MNTTAB_OPT_LOG "union" #endif /* defined(MNT2_GEN_OPT_UNION) && !defined(MNTTAB_OPT_UNION) */ /* * Add missing MNTTAB_OPT_* options. */ #ifndef MNTTAB_OPT_ACTIMEO # define MNTTAB_OPT_ACTIMEO "actimeo" #endif /* not MNTTAB_OPT_ACTIMEO */ #ifndef MNTTAB_OPT_INTR # define MNTTAB_OPT_INTR "intr" #endif /* not MNTTAB_OPT_INTR */ #ifndef MNTTAB_OPT_PORT # define MNTTAB_OPT_PORT "port" #endif /* not MNTTAB_OPT_PORT */ #ifndef MNTTAB_OPT_PUBLIC # define MNTTAB_OPT_PUBLIC "public" #endif /* not MNTTAB_OPT_PUBLIC */ #ifndef MNTTAB_OPT_RETRANS # define MNTTAB_OPT_RETRANS "retrans" #endif /* not MNTTAB_OPT_RETRANS */ #ifndef MNTTAB_OPT_RETRY # define MNTTAB_OPT_RETRY "retry" #endif /* not MNTTAB_OPT_RETRY */ #ifndef MNTTAB_OPT_RO # define MNTTAB_OPT_RO "ro" #endif /* not MNTTAB_OPT_RO */ #ifndef MNTTAB_OPT_RSIZE # define MNTTAB_OPT_RSIZE "rsize" #endif /* not MNTTAB_OPT_RSIZE */ #ifndef MNTTAB_OPT_RW # define MNTTAB_OPT_RW "rw" #endif /* not MNTTAB_OPT_RW */ #ifndef MNTTAB_OPT_TIMEO # define MNTTAB_OPT_TIMEO "timeo" #endif /* not MNTTAB_OPT_TIMEO */ #ifndef MNTTAB_OPT_WSIZE # define MNTTAB_OPT_WSIZE "wsize" #endif /* not MNTTAB_OPT_WSIZE */ /* next four are useful for pcfs mounts */ #ifndef MNTTAB_OPT_USER # define MNTTAB_OPT_USER "user" #endif /* not MNTTAB_OPT_USER */ #ifndef MNTTAB_OPT_GROUP # define MNTTAB_OPT_GROUP "group" #endif /* not MNTTAB_OPT_GROUP */ #ifndef MNTTAB_OPT_MASK # define MNTTAB_OPT_MASK "mask" #endif /* not MNTTAB_OPT_MASK */ #ifndef MNTTAB_OPT_DIRMASK # define MNTTAB_OPT_DIRMASK "dirmask" #endif /* not MNTTAB_OPT_DIRMASK */ /* useful for udf mounts */ #ifndef MNTTAB_OPT_USER # define MNTTAB_OPT_USER "user" #endif /* not MNTTAB_OPT_USER */ #ifndef MNTTAB_OPT_GROUP # define MNTTAB_OPT_GROUP "group" #endif /* not MNTTAB_OPT_GROUP */ #ifndef MNTTAB_OPT_GMTOFF # define MNTTAB_OPT_GMTOFF "gmtoff" #endif /* not MNTTAB_OPT_GMTOFF */ #ifndef MNTTAB_OPT_SESSIONNR # define MNTTAB_OPT_SESSIONNR "sessionnr" #endif /* not MNTTAB_OPT_SESSIONNR */ /* * Incomplete filesystem definitions (sunos4, irix6, solaris2) */ #if defined(HAVE_FS_CDFS) && defined(MOUNT_TYPE_CDFS) && !defined(MNTTYPE_CDFS) # define MNTTYPE_CDFS "hsfs" #endif /* defined(HAVE_FS_CDFS) && defined(MOUNT_TYPE_CDFS) && !defined(MNTTYPE_CDFS) */ #ifndef cdfs_args_t /* * Solaris has an HSFS filesystem, but does not define hsfs_args. * XXX: the definition here for solaris is wrong, since under solaris, * hsfs_args should be a single integer used as a bit-field for options. * so this code has to be fixed later. -Erez. */ struct hsfs_args { char *fspec; /* name of filesystem to mount */ int norrip; }; # define cdfs_args_t struct hsfs_args # define HAVE_CDFS_ARGS_T_NORRIP #endif /* not cdfs_args_t */ /* * if does not define struct pc_args, assume integer bit-field (irix6) */ #if defined(HAVE_FS_PCFS) && !defined(pcfs_args_t) # define pcfs_args_t u_int #endif /* defined(HAVE_FS_PCFS) && !defined(pcfs_args_t) */ /* * if does not define struct ufs_args, assume integer bit-field (linux) */ #if defined(HAVE_FS_UFS) && !defined(ufs_args_t) # define ufs_args_t u_int #endif /* defined(HAVE_FS_UFS) && !defined(ufs_args_t) */ /* * if does not define struct udf_args, assume integer bit-field (linux) */ #if defined(HAVE_FS_UDF) && !defined(udf_args_t) # define udf_args_t u_int #endif /* defined(HAVE_FS_UDF) && !defined(udf_args_t) */ /* * if does not define struct efs_args, assume integer bit-field (linux) */ #if defined(HAVE_FS_EFS) && !defined(efs_args_t) # define efs_args_t u_int #endif /* defined(HAVE_FS_EFS) && !defined(efs_args_t) */ #if defined(HAVE_FS_TMPFS) && !defined(tmpfs_args_t) # define tmpfs_args_t u_int #endif /* defined(HAVE_FS_TMPFS) && !defined(tmpfs_args_t) */ /* * if does not define struct xfs_args, assume integer bit-field (linux) */ #if defined(HAVE_FS_XFS) && !defined(xfs_args_t) # define xfs_args_t u_int #endif /* defined(HAVE_FS_XFS) && !defined(xfs_args_t) */ #if defined(HAVE_FS_AUTOFS) && defined(MOUNT_TYPE_AUTOFS) && !defined(MNTTYPE_AUTOFS) # define MNTTYPE_AUTOFS "autofs" #endif /* defined(HAVE_FS_AUTOFS) && defined(MOUNT_TYPE_AUTOFS) && !defined(MNTTYPE_AUTOFS) */ /* * If NFS3, then make sure that "proto" and "vers" mnttab options * are available. */ #ifdef HAVE_FS_NFS3 # ifndef MNTTAB_OPT_VERS # define MNTTAB_OPT_VERS "vers" # endif /* not MNTTAB_OPT_VERS */ # ifndef MNTTAB_OPT_PROTO # define MNTTAB_OPT_PROTO "proto" # endif /* not MNTTAB_OPT_PROTO */ #endif /* not HAVE_FS_NFS3 */ /* * If loop device (header file) exists, define mount table option */ #if defined(HAVE_LOOP_DEVICE) && !defined(MNTTAB_OPT_LOOP) # define MNTTAB_OPT_LOOP "loop" #endif /* defined(HAVE_LOOP_DEVICE) && !defined(MNTTAB_OPT_LOOP) */ /* * Define a dummy struct netconfig for non-TLI systems */ #if !defined(HAVE_NETCONFIG_H) && !defined(HAVE_SYS_NETCONFIG_H) struct netconfig { int dummy; }; #endif /* not HAVE_NETCONFIG_H and not HAVE_SYS_NETCONFIG_H */ /* some OSs don't define INADDR_NONE and assume it's unsigned -1 */ #ifndef INADDR_NONE # define INADDR_NONE 0xffffffffU #endif /* INADDR_NONE */ /* some OSs don't define INADDR_LOOPBACK */ #ifndef INADDR_LOOPBACK # define INADDR_LOOPBACK 0x7f000001 #endif /* not INADDR_LOOPBACK */ #endif /* not _AM_COMPAT_H */ am-utils-6.2+rc20110530/include/am_defs.h000066400000000000000000001207401157065440000175300ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/include/am_defs.h * */ /* * Definitions that are not specific to the am-utils package, but * are rather generic, and can be used elsewhere. */ #ifndef _AM_DEFS_H #define _AM_DEFS_H /* * Actions to take if ANSI C. */ #if STDC_HEADERS # include /* for function prototypes */ # define P(x) x # define P_void void #else /* not STDC_HEADERS */ /* empty function prototypes */ # define P(x) () # define P_void # ifndef HAVE_STRCHR # define strchr index # define strrchr rindex # endif /* not HAVE_STRCHR */ char *strchr(), *strrchr(), *strdup(); #endif /* not STDC_HEADERS */ /* * Handle gcc __attribute__ if available. */ #ifndef __attribute__ /* This feature is available in gcc versions 2.5 and later. */ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ # define __attribute__(Spec) /* empty */ # endif /* __GNUC__ < 2 ... */ /* * The __-protected variants of `format' and `printf' attributes * are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) # define __format__ format # define __printf__ printf # endif /* __GNUC__ < 2 ... */ #endif /* not __attribute__ */ #define __IGNORE(result) \ __ignore((unsigned long)result) static __inline void __ignore(unsigned long result) { (void)&result; } /* * How to handle signals of any type */ #ifdef HAVE_SYS_WAIT_H # include #endif /* HAVE_SYS_WAIT_H */ #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) #endif /* not WEXITSTATUS */ #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif /* not WIFEXITED */ /* * Actions to take regarding and . */ #if TIME_WITH_SYS_TIME # include # ifdef _ALL_SOURCE /* * AIX 5.2 needs struct sigevent from signal.h to be defined, but I * don't want to move the inclusion of signal.h this early into this * file. Luckily, amd doesn't need the size of this structure in any * other structure that it uses. So we sidestep it for now. */ struct sigevent; # endif /* _ALL_SOURCE */ # include #else /* not TIME_WITH_SYS_TIME */ # if HAVE_SYS_TIME_H # include # else /* not HAVE_SYS_TIME_H */ # include # endif /* not HAVE_SYS_TIME_H */ #endif /* not TIME_WITH_SYS_TIME */ /* * Actions to take if exists. */ #ifdef HAVE_MACHINE_ENDIAN_H # include #endif /* HAVE_MACHINE_ENDIAN_H */ /* * Big-endian or little-endian? */ #ifndef BYTE_ORDER # if defined(WORDS_BIGENDIAN) # define ARCH_ENDIAN "big" # else /* not WORDS_BIGENDIAN */ # define ARCH_ENDIAN "little" # endif /* not WORDS_BIGENDIAN */ #else # if BYTE_ORDER == BIG_ENDIAN # define ARCH_ENDIAN "big" # else # define ARCH_ENDIAN "little" # endif #endif /* * Actions to take if HAVE_SYS_TYPES_H is defined. */ #if HAVE_SYS_TYPES_H # include #endif /* HAVE_SYS_TYPES_H */ /* * Actions to take if HAVE_LIMITS_H is defined. */ #if HAVE_LIMITS_H_H # include #endif /* HAVE_LIMITS_H */ /* * Actions to take if HAVE_UNISTD_H is defined. */ #if HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ /* after , check if this is a POSIX.1 system */ #ifdef _POSIX_VERSION /* Code for POSIX.1 systems. */ #endif /* _POSIX_VERSION */ /* * Variable length argument lists. * Must use only one of the two! */ #ifdef HAVE_STDARG_H # include /* * On Solaris 2.6, is included in * So this ensures that only one is included. */ # ifndef _SYS_VARARGS_H # define _SYS_VARARGS_H # endif /* not _SYS_VARARGS_H */ #else /* not HAVE_STDARG_H */ # ifdef HAVE_VARARGS_H # include # endif /* HAVE_VARARGS_H */ #endif /* not HAVE_STDARG_H */ /* * Pick the right header file and macros for directory processing functions. */ #if HAVE_DIRENT_H # include # define NAMLEN(dirent) strlen((dirent)->d_name) #else /* not HAVE_DIRENT_H */ # define dirent direct # define NAMLEN(dirent) (dirent)->d_namlen # if HAVE_SYS_NDIR_H # include # endif /* HAVE_SYS_NDIR_H */ # if HAVE_SYS_DIR_H # include # endif /* HAVE_SYS_DIR_H */ # if HAVE_NDIR_H # include # endif /* HAVE_NDIR_H */ #endif /* not HAVE_DIRENT_H */ /* * Actions to take if HAVE_FCNTL_H is defined. */ #if HAVE_FCNTL_H # include #endif /* HAVE_FCNTL_H */ /* * Actions to take if HAVE_MEMORY_H is defined. */ #if HAVE_MEMORY_H # include #endif /* HAVE_MEMORY_H */ /* * Actions to take if HAVE_SYS_FILE_H is defined. */ #if HAVE_SYS_FILE_H # include #endif /* HAVE_SYS_FILE_H */ /* * Actions to take if HAVE_SYS_IOCTL_H is defined. */ #if HAVE_SYS_IOCTL_H # include #endif /* HAVE_SYS_IOCTL_H */ /* * Actions to take if HAVE_SYSLOG_H or HAVE_SYS_SYSLOG_H is defined. */ #ifdef HAVE_SYSLOG_H # include #else /* not HAVE_SYSLOG_H */ # if HAVE_SYS_SYSLOG_H # include # endif /* HAVE_SYS_SYSLOG_H */ #endif /* HAVE_SYSLOG_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_PARAM_H # include #endif /* HAVE_SYS_PARAM_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_SOCKET_H # include #endif /* HAVE_SYS_SOCKET_H */ /* * Actions to take if exists. */ #ifdef HAVE_RPC_RPC_H /* * Turn on PORTMAP, so that additional header files would get included * and the important definition for UDPMSGSIZE is included too. */ # ifndef PORTMAP # define PORTMAP # endif /* not PORTMAP */ # include # ifndef XDRPROC_T_TYPE typedef bool_t (*xdrproc_t) __P ((XDR *, __ptr_t, ...)); # endif /* not XDRPROC_T_TYPE */ #endif /* HAVE_RPC_RPC_H */ /* * Actions to take if exists. */ #ifdef HAVE_RPC_TYPES_H # include #endif /* HAVE_RPC_TYPES_H */ /* * Actions to take if exists. */ /* Prevent multiple inclusion on Ultrix 4 */ #if defined(HAVE_RPC_XDR_H) && !defined(__XDR_HEADER__) # include #endif /* defined(HAVE_RPC_XDR_H) && !defined(__XDR_HEADER__) */ /* * Actions to take if exists. * Don't include malloc.h if stdlib.h exists, because modern * systems complain if you use malloc.h instead of stdlib.h. * XXX: let's hope there are no systems out there that need both. */ #if defined(HAVE_MALLOC_H) && !defined(HAVE_STDLIB_H) # include #endif /* defined(HAVE_MALLOC_H) && !defined(HAVE_STDLIB_H) */ /* * Actions to take if exists. */ #ifdef HAVE_MNTENT_H /* some systems need before is included */ # ifdef HAVE_STDIO_H # include # endif /* HAVE_STDIO_H */ # include #endif /* HAVE_MNTENT_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_FSID_H # include #endif /* HAVE_SYS_FSID_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_UTSNAME_H # include #endif /* HAVE_SYS_UTSNAME_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_MNTENT_H # include #endif /* HAVE_SYS_MNTENT_H */ /* * Actions to take if or exist. * Should be included before because on some systems * like Linux, it also defines "struct datum". */ #ifdef HAVE_MAP_NDBM # include NEW_DBM_H # ifndef DATUM /* ensure that struct datum is not included again from */ # define DATUM # endif /* not DATUM */ #endif /* HAVE_MAP_NDBM */ /* * Actions to take if exists. */ #ifdef HAVE_NET_ERRNO_H # include #endif /* HAVE_NET_ERRNO_H */ /* * Actions to take if exists. */ #ifdef HAVE_NET_IF_H # include #endif /* HAVE_NET_IF_H */ /* * Actions to take if exists. */ #ifdef HAVE_NET_ROUTE_H # include #endif /* HAVE_NET_ROUTE_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_MBUF_H # include /* * OSF4 (DU-4.0) defines m_next and m_data also in so I must # undefine them here to avoid conflicts. */ # ifdef m_next # undef m_next # endif /* m_next */ # ifdef m_data # undef m_data # endif /* m_data */ /* * AIX 3 defines MFREE and m_flags also in . */ # ifdef m_flags # undef m_flags # endif /* m_flags */ # ifdef MFREE # undef MFREE # endif /* MFREE */ #endif /* HAVE_SYS_MBUF_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_MMAN_H # include #endif /* HAVE_SYS_MMAN_H */ /* * Actions to take if exists. */ #ifdef HAVE_NETDB_H # include #endif /* HAVE_NETDB_H */ /* * Actions to take if exists. */ #ifdef HAVE_NETDIR_H # include #endif /* HAVE_NETDIR_H */ /* * Actions to take if exists. */ #ifdef HAVE_NET_IF_VAR_H # include #endif /* HAVE_NET_IF_VAR_H */ /* * Actions to take if exists. */ #ifdef HAVE_NETINET_IF_ETHER_H # include #endif /* HAVE_NETINET_IF_ETHER_H */ /* * Actions to take if exists. */ #ifdef HAVE_NETINET_IN_H # include #endif /* HAVE_NETINET_IN_H */ /* * Actions to take if exists. */ #ifdef HAVE_RPCSVC_YP_PROT_H # ifdef HAVE_BAD_HEADERS /* avoid circular dependency in aix 4.3 with */ struct ypall_callback; # endif /* HAVE_BAD_HEADERS */ # include #endif /* HAVE_RPCSVC_YP_PROT_H */ /* * Actions to take if exists. */ #ifdef HAVE_RPCSVC_YPCLNT_H # include #endif /* HAVE_RPCSVC_YPCLNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_UCRED_H # include #endif /* HAVE_SYS_UCRED_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_MOUNT_H /* * Some operating systems must define these variables to get * NFS and other definitions included. */ # ifndef NFSCLIENT # define NFSCLIENT 1 # endif /* not NFSCLIENT */ # ifndef NFS # define NFS 1 # endif /* not NFS */ # ifndef PCFS # define PCFS 1 # endif /* not PCFS */ # ifndef LOFS # define LOFS 1 # endif /* not LOFS */ # ifndef RFS # define RFS 1 # endif /* not RFS */ # ifndef MSDOSFS # define MSDOSFS 1 # endif /* not MSDOSFS */ # ifndef MFS # define MFS 1 # endif /* not MFS */ # ifndef CD9660 # define CD9660 1 # endif /* not CD9660 */ # include #endif /* HAVE_SYS_MOUNT_H */ #ifdef HAVE_SYS_VMOUNT_H # include #endif /* HAVE_SYS_VMOUNT_H */ /* * Actions to take if exists. * There is no point in including this on a glibc2 system, * we're only asking for trouble */ #if defined HAVE_LINUX_FS_H && (!defined __GLIBC__ || __GLIBC__ < 2) /* * There are various conflicts in definitions between RedHat Linux, newer * 2.2 kernels, and and . */ # ifdef HAVE_SOCKETBITS_H /* conflicts with */ # define _LINUX_SOCKET_H # undef BLKFLSBUF # undef BLKGETSIZE # undef BLKRAGET # undef BLKRASET # undef BLKROGET # undef BLKROSET # undef BLKRRPART # undef MS_MGC_VAL # undef MS_RMT_MASK # if defined(__GLIBC__) && __GLIBC__ >= 2 /* conflicts with */ # undef WNOHANG # undef WUNTRACED # endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */ /* conflicts with */ # define _SYS_STATFS_H # endif /* HAVE_SOCKETBITS_H */ # ifdef _SYS_WAIT_H # if defined(__GLIBC__) && __GLIBC__ >= 2 /* conflicts with (RedHat/Linux 6.0 and kernels 2.2 */ # undef WNOHANG # undef WUNTRACED # endif /* defined(__GLIBC__) && __GLIBC__ >= 2 */ # endif /* _SYS_WAIT_H */ # ifdef HAVE_LINUX_POSIX_TYPES_H # include # endif /* HAVE_LINUX_POSIX_TYPES_H */ # ifndef _LINUX_BYTEORDER_GENERIC_H # define _LINUX_BYTEORDER_GENERIC_H # endif /* _LINUX_BYTEORDER_GENERIC_H */ /* conflicts with in 2.[12] kernels */ # ifdef _SYS_MOUNT_H # undef BLKFLSBUF # undef BLKGETSIZE # undef BLKRAGET # undef BLKRASET # undef BLKROGET # undef BLKROSET # undef BLKRRPART # undef BLOCK_SIZE # undef MS_MANDLOCK # undef MS_MGC_VAL # undef MS_NOATIME # undef MS_NODEV # undef MS_NODIRATIME # undef MS_NOEXEC # undef MS_NOSUID # undef MS_RDONLY # undef MS_REMOUNT # undef MS_RMT_MASK # undef MS_SYNCHRONOUS # undef S_APPEND # undef S_IMMUTABLE /* conflicts with */ # define _SYS_STATFS_H # endif /* _SYS_MOUNT_H */ # ifndef _LINUX_STRING_H_ # define _LINUX_STRING_H_ # endif /* not _LINUX_STRING_H_ */ # ifdef HAVE_LINUX_KDEV_T_H # define __KERNEL__ # include # undef __KERNEL__ # endif /* HAVE_LINUX_KDEV_T_H */ # ifdef HAVE_LINUX_LIST_H # define __KERNEL__ # include # undef __KERNEL__ # endif /* HAVE_LINUX_LIST_H */ # include #endif /* HAVE_LINUX_FS_H && (!__GLIBC__ || __GLIBC__ < 2) */ #ifdef HAVE_CDFS_CDFS_MOUNT_H # include #endif /* HAVE_CDFS_CDFS_MOUNT_H */ #ifdef HAVE_CDFS_CDFSMOUNT_H # include #endif /* HAVE_CDFS_CDFSMOUNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_LINUX_LOOP_H # ifdef HAVE_LINUX_POSIX_TYPES_H # include # endif /* HAVE_LINUX_POSIX_TYPES_H */ /* next dev_t lines needed due to changes in kernel code */ # undef dev_t # define dev_t unsigned short /* compatible with Red Hat and SuSE */ # include #endif /* HAVE_LINUX_LOOP_H */ /* * AUTOFS PROTOCOL HEADER FILES: */ /* * Actions to take if exists. * We really don't want pulled in here */ #ifndef _LINUX_FS_H #define _LINUX_FS_H #endif /* _LINUX_FS_H */ #ifdef HAVE_LINUX_AUTO_FS4_H # include #else /* not HAVE_LINUX_AUTO_FS4_H */ # ifdef HAVE_LINUX_AUTO_FS_H # include # endif /* HAVE_LINUX_AUTO_FS_H */ #endif /* not HAVE_LINUX_AUTO_FS4_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_FS_AUTOFS_H # include #endif /* HAVE_SYS_FS_AUTOFS_H */ /* * Actions to take if or exist. */ #ifdef HAVE_RPCSVC_AUTOFS_PROT_H # include #else /* not HAVE_RPCSVC_AUTOFS_PROT_H */ # ifdef HAVE_SYS_FS_AUTOFS_PROT_H # include # endif /* HAVE_SYS_FS_AUTOFS_PROT_H */ #endif /* not HAVE_RPCSVC_AUTOFS_PROT_H */ /* * Actions to take if exists. * This header file is required before can be included. */ #ifdef HAVE_LBER_H # include #endif /* HAVE_LBER_H */ /* * Actions to take if exists. */ #ifdef HAVE_LDAP_H # include #endif /* HAVE_LDAP_H */ /**************************************************************************** ** IMPORTANT!!! ** ** We always include am-utils' amu_autofs_prot.h. ** ** That is actually defined in "conf/autofs/autofs_${autofs_style}.h" ** ****************************************************************************/ #include /* * NFS PROTOCOL HEADER FILES: */ /* * Actions to take if exists. */ #ifdef HAVE_NFS_EXPORT_H # include #endif /* HAVE_NFS_EXPORT_H */ /**************************************************************************** ** IMPORTANT!!! ** ** We always include am-utils' amu_nfs_prot.h. ** ** That is actually defined in "conf/nfs_prot/nfs_prot_${host_os_name}.h" ** ****************************************************************************/ #include /* * DO NOT INCLUDE THESE FILES: * They conflicts with other NFS headers and are generally not needed. */ #ifdef DO_NOT_INCLUDE # ifdef HAVE_NFS_NFS_CLNT_H # include # endif /* HAVE_NFS_NFS_CLNT_H */ # ifdef HAVE_LINUX_NFS_H # include # endif /* HAVE_LINUX_NFS_H */ #endif /* DO NOT INCLUDE */ /* * Actions to take if one of the nfs headers exists. */ #ifdef HAVE_NFS_NFS_GFS_H # include #endif /* HAVE_NFS_NFS_GFS_H */ #ifdef HAVE_NFS_MOUNT_H # include #endif /* HAVE_NFS_MOUNT_H */ #ifdef HAVE_NFS_NFS_MOUNT_H_off /* broken on nextstep3 (includes non-existing headers) */ # include #endif /* HAVE_NFS_NFS_MOUNT_H */ #ifdef HAVE_NFS_PATHCONF_H # include #endif /* HAVE_NFS_PATHCONF_H */ #ifdef HAVE_SYS_FS_NFS_MOUNT_H # include #endif /* HAVE_SYS_FS_NFS_MOUNT_H */ #ifdef HAVE_SYS_FS_NFS_NFS_CLNT_H # include #endif /* HAVE_SYS_FS_NFS_NFS_CLNT_H */ #ifdef HAVE_SYS_FS_NFS_CLNT_H # include #endif /* HAVE_SYS_FS_NFS_CLNT_H */ /* complex rules for linux/nfs_mount.h: broken on so many systems */ #ifdef HAVE_LINUX_NFS_MOUNT_H # ifndef _LINUX_NFS_H # define _LINUX_NFS_H # endif /* not _LINUX_NFS_H */ # ifndef _LINUX_NFS2_H # define _LINUX_NFS2_H # endif /* not _LINUX_NFS2_H */ # ifndef _LINUX_NFS3_H # define _LINUX_NFS3_H # endif /* not _LINUX_NFS3_H */ # ifndef _LINUX_NFS_FS_H # define _LINUX_NFS_FS_H # endif /* not _LINUX_NFS_FS_H */ # ifndef _LINUX_IN_H # define _LINUX_IN_H # endif /* not _LINUX_IN_H */ # ifndef __KERNEL__ # define __KERNEL__ # endif /* __KERNEL__ */ # include # undef __KERNEL__ #endif /* HAVE_LINUX_NFS_MOUNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_PWD_H # include #endif /* HAVE_PWD_H */ /* * Actions to take if exists. */ #ifdef HAVE_HESIOD_H # include #endif /* HAVE_HESIOD_H */ /* * Actions to take if exists. * Should be included before . */ #ifdef HAVE_ARPA_NAMESER_H # ifdef NOERROR # undef NOERROR # endif /* NOERROR */ /* * Conflicts with which is included from * on Solaris 2.6 systems. So undefine it first. */ # ifdef T_UNSPEC # undef T_UNSPEC # endif /* T_UNSPEC */ # include #endif /* HAVE_ARPA_NAMESER_H */ /* * Actions to take if exists. */ #ifdef HAVE_ARPA_INET_H # ifdef HAVE_BAD_HEADERS /* aix 4.3: avoid including */ struct sockaddr_dl; # endif /* HAVE_BAD_HEADERS */ # include #endif /* HAVE_ARPA_INET_H */ /* * Actions to take if exists. */ #ifdef HAVE_RESOLV_H /* * On AIX 5.2, both and define MAXDNAME, * if compiling with gcc -D_USE_IRS (so that we get extern definitions for * hstrerror() and others). */ # if defined(_AIX) && defined(MAXDNAME) && defined(_USE_IRS) # undef MAXDNAME # endif /* defined(_AIX) && defined(MAXDNAME) && defined(_USE_IRS) */ # include #endif /* HAVE_RESOLV_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_UIO_H # include #endif /* HAVE_SYS_UIO_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_FS_CACHEFS_FS_H # include #endif /* HAVE_SYS_FS_CACHEFS_FS_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_FS_PC_FS_H # include #endif /* HAVE_SYS_FS_PC_FS_H */ /* * Actions to take if exists. */ #ifdef HAVE_MSDOSFS_MSDOSFSMOUNT_H # include #endif /* HAVE_MSDOSFS_MSDOSFSMOUNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H # include #endif /* HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_FS_TMP_H # include #endif /* HAVE_SYS_FS_TMP_H */ #ifdef HAVE_FS_TMPFS_TMPFS_ARGS_H # include #endif /* HAVE_FS_TMPFS_TMPFS_ARGS_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_FS_UFS_MOUNT_H # include #endif /* HAVE_SYS_FS_UFS_MOUNT_H */ #ifdef HAVE_UFS_UFS_UFSMOUNT_H_off # error do not include this file here because on netbsd/openbsd it # error causes errors with other header files. Instead, add it to the # error specific conf/nfs_prot_*.h file. # include #endif /* HAVE_UFS_UFS_UFSMOUNT_H_off */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_FS_EFS_CLNT_H # include #endif /* HAVE_SYS_FS_EFS_CLNT_H */ #ifdef HAVE_FS_EFS_EFS_MOUNT_H # include #endif /* HAVE_FS_EFS_EFS_MOUNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_FS_XFS_CLNT_H # include #endif /* HAVE_SYS_FS_XFS_CLNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_ASSERT_H # include #endif /* HAVE_ASSERT_H */ /* * Actions to take if exists. */ #ifdef HAVE_CFS_H # include #endif /* HAVE_CFS_H */ /* * Actions to take if exists. */ #ifdef HAVE_CLUSTER_H # include #endif /* HAVE_CLUSTER_H */ /* * Actions to take if exists. */ #ifdef HAVE_CTYPE_H # include #endif /* HAVE_CTYPE_H */ /* * Actions to take if exists. */ #ifdef HAVE_ERRNO_H # include #else /* * Actions to take if exists. */ # ifdef HAVE_SYS_ERRNO_H # include extern int errno; # endif /* HAVE_SYS_ERRNO_H */ #endif /* HAVE_ERRNO_H */ /* * Actions to take if exists. */ #ifdef HAVE_GRP_H # include #endif /* HAVE_GRP_H */ /* * Actions to take if exists. */ #ifdef HAVE_HSFS_HSFS_H # include #endif /* HAVE_HSFS_HSFS_H */ /* * Actions to take if exists. */ #ifdef HAVE_CDFS_CDFSMOUNT_H # include #endif /* HAVE_CDFS_CDFSMOUNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_ISOFS_CD9660_CD9660_MOUNT_H # include #endif /* HAVE_ISOFS_CD9660_CD9660_MOUNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_FS_UDF_UDF_MOUNT_H # include #endif /* HAVE_FS_UDF_UDF_MOUNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_MOUNT_H # include #endif /* HAVE_MOUNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_NSSWITCH_H # include #endif /* HAVE_NSSWITCH_H */ /* * Actions to take if exists. */ #ifdef HAVE_RPC_AUTH_DES_H # include #endif /* HAVE_RPC_AUTH_DES_H */ /* * Actions to take if exists. */ #ifdef HAVE_RPC_PMAP_CLNT_H # include #endif /* HAVE_RPC_PMAP_CLNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_RPC_PMAP_PROT_H # include #endif /* HAVE_RPC_PMAP_PROT_H */ /* * Actions to take if exists. * AIX does not protect against this file doubly included, * so I have to do my own protection here. */ #ifdef HAVE_RPCSVC_MOUNT_H # ifndef _RPCSVC_MOUNT_H # include # endif /* not _RPCSVC_MOUNT_H */ #endif /* HAVE_RPCSVC_MOUNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_RPCSVC_NIS_H /* * Solaris 10 (build 72) defines GROUP_OBJ in , which is included * in many other header files. uses GROUP_OBJ inside enum * zotypes. So if you're unlucky enough to include both headers, you get a * compile error because the two symbols conflict. * A similar conflict arises with Sun cc and the definition of "GROUP". * * Temp hack: undefine acl.h's GROUP_OBJ and GROUP because they're not needed * for am-utils. */ # ifdef GROUP_OBJ # undef GROUP_OBJ # endif /* GROUP_OBJ */ # ifdef GROUP # undef GROUP # endif /* GROUP */ # include #endif /* HAVE_RPCSVC_NIS_H */ /* * Actions to take if exists. */ #ifdef HAVE_SETJMP_H # include #endif /* HAVE_SETJMP_H */ /* * Actions to take if exists. */ #ifdef HAVE_SIGNAL_H # include #endif /* HAVE_SIGNAL_H */ /* * Actions to take if exists. */ #ifdef HAVE_STRING_H # include #endif /* HAVE_STRING_H */ /* * Actions to take if exists. */ #ifdef HAVE_STRINGS_H # include #endif /* HAVE_STRINGS_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_CONFIG_H # include #endif /* HAVE_SYS_CONFIG_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_DG_MOUNT_H # include #endif /* HAVE_SYS_DG_MOUNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_FS_TYPES_H /* * Define KERNEL here to avoid multiple definitions of gt_names[] on * Ultrix 4.3. */ # define KERNEL # include # undef KERNEL #endif /* HAVE_SYS_FS_TYPES_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_FSTYP_H # include #endif /* HAVE_SYS_FSTYP_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_LOCK_H # include #endif /* HAVE_SYS_LOCK_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_MACHINE_H # include #endif /* HAVE_SYS_MACHINE_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_MNTCTL_H # include #endif /* HAVE_SYS_MNTCTL_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_MNTTAB_H # include #endif /* HAVE_SYS_MNTTAB_H */ /* * Actions to take if exists. * Do not include it if MNTTAB is already defined because it probably * came from and we do not want conflicting definitions. */ #if defined(HAVE_MNTTAB_H) && !defined(MNTTAB) # include #endif /* defined(HAVE_MNTTAB_H) && !defined(MNTTAB) */ /* * Actions to take if exists. */ #ifdef HAVE_NETCONFIG_H # include /* Some systems (Solaris 2.5.1) don't declare this external */ extern char *nc_sperror(void); #endif /* HAVE_NETCONFIG_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_NETCONFIG_H # include #endif /* HAVE_SYS_NETCONFIG_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_PATHCONF_H # include #endif /* HAVE_SYS_PATHCONF_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_RESOURCE_H # include #endif /* HAVE_SYS_RESOURCE_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_SEMA_H # include #endif /* HAVE_SYS_SEMA_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_SIGNAL_H # include #endif /* HAVE_SYS_SIGNAL_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_SOCKIO_H # include #endif /* HAVE_SYS_SOCKIO_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_SYSCALL_H # include #endif /* HAVE_SYS_SYSCALL_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_SYSLIMITS_H # include #endif /* HAVE_SYS_SYSLIMITS_H */ /* * Actions to take if exists. */ #ifdef HAVE_TIUSER_H /* * Some systems like AIX have multiple definitions for T_NULL and others * that are defined first in . */ # ifdef HAVE_ARPA_NAMESER_H # ifdef T_NULL # undef T_NULL # endif /* T_NULL */ # ifdef T_UNSPEC # undef T_UNSPEC # endif /* T_UNSPEC */ # ifdef T_IDLE # undef T_IDLE # endif /* T_IDLE */ # endif /* HAVE_ARPA_NAMESER_H */ # include #endif /* HAVE_TIUSER_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_TIUSER_H # include #endif /* HAVE_SYS_TIUSER_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_STATFS_H # include #endif /* HAVE_SYS_STATFS_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_STATVFS_H # include #endif /* HAVE_SYS_STATVFS_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_VFS_H # include #endif /* HAVE_SYS_VFS_H */ /* * Actions to take if exists. */ #ifdef HAVE_SYS_VMOUNT_H # include #endif /* HAVE_SYS_VMOUNT_H */ /* * Actions to take if exists. */ #ifdef HAVE_UFS_UFS_MOUNT_H # include #endif /* HAVE_UFS_UFS_MOUNT_H */ /* * Are S_ISDIR, S_ISREG, et al broken? If not, include . * Turned off the not using sys/stat.h based on if the macros are * "broken", because they incorrectly get reported as broken on * ncr2. */ #ifndef STAT_MACROS_BROKEN_notused /* * RedHat Linux 4.2 (alpha) has a problem in the headers that causes * duplicate definitions, and also some other nasty bugs. Upgrade to Redhat * 5.0! */ # ifdef HAVE_SYS_STAT_H /* avoid duplicates or conflicts with (RedHat alpha linux) */ # if defined(S_IFREG) && defined(HAVE_STATBUF_H) # include # undef S_IFBLK # undef S_IFCHR # undef S_IFDIR # undef S_IFIFO # undef S_IFLNK # undef S_IFMT # undef S_IFREG # undef S_IFSOCK # undef S_IRGRP # undef S_IROTH # undef S_IRUSR # undef S_IRWXG # undef S_IRWXO # undef S_IRWXU # undef S_ISBLK # undef S_ISCHR # undef S_ISDIR # undef S_ISFIFO # undef S_ISGID # undef S_ISLNK # undef S_ISREG # undef S_ISSOCK # undef S_ISUID # undef S_ISVTX # undef S_IWGRP # undef S_IWOTH # undef S_IWUSR # undef S_IXGRP # undef S_IXOTH # undef S_IXUSR # endif /* defined(S_IFREG) && defined(HAVE_STATBUF_H) */ # include # endif /* HAVE_SYS_STAT_H */ #endif /* not STAT_MACROS_BROKEN_notused */ /* * Actions to take if exists. */ #ifdef HAVE_STDIO_H # include #endif /* HAVE_STDIO_H */ /* * Actions to take if exists. */ #ifdef HAVE_STDLIB_H # include #endif /* HAVE_STDLIB_H */ /* * Actions to take if exists. */ #ifdef HAVE_REGEX_H # include #endif /* HAVE_REGEX_H */ /* * Actions to take if exists. */ #if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) # include #endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) */ /****************************************************************************/ /* * Specific macros we're looking for. */ #ifndef HAVE_MEMSET # ifdef HAVE_BZERO # define memset(ptr, val, len) bzero((ptr), (len)) # else /* not HAVE_BZERO */ # error Cannot find either memset or bzero! # endif /* not HAVE_BZERO */ #endif /* not HAVE_MEMSET */ #ifndef HAVE_MEMMOVE # ifdef HAVE_BCOPY # define memmove(to, from, len) bcopy((from), (to), (len)) # else /* not HAVE_BCOPY */ # error Cannot find either memmove or bcopy! # endif /* not HAVE_BCOPY */ #endif /* not HAVE_MEMMOVE */ /* * memcmp() is more problematic: * Systems that don't have it, but have bcmp(), will use bcmp() instead. * Those that have it, but it is bad (SunOS 4 doesn't handle * 8 bit comparisons correctly), will get to use am_memcmp(). * Otherwise if you have memcmp() and it is good, use it. */ #ifdef HAVE_MEMCMP # ifdef HAVE_BAD_MEMCMP # define memcmp am_memcmp extern int am_memcmp(const voidp s1, const voidp s2, size_t len); # endif /* HAVE_BAD_MEMCMP */ #else /* not HAVE_MEMCMP */ # ifdef HAVE_BCMP # define memcmp(a, b, len) bcmp((a), (b), (len)) # endif /* HAVE_BCMP */ #endif /* not HAVE_MEMCMP */ #ifndef HAVE_SETEUID # ifdef HAVE_SETRESUID # define seteuid(x) setresuid(-1,(x),-1) # else /* not HAVE_SETRESUID */ # error Cannot find either seteuid or setresuid! # endif /* not HAVE_SETRESUID */ #endif /* not HAVE_SETEUID */ /* * Define type of mntent_t. * Defaults to struct mntent, else struct mnttab. If neither is found, and * the operating system does keep not mount tables in the kernel, then flag * it as an error. If neither is found and the OS keeps mount tables in the * kernel, then define our own version of mntent; it will be needed for amd * to keep its own internal version of the mount tables. */ #ifdef HAVE_STRUCT_MNTENT typedef struct mntent mntent_t; #else /* not HAVE_STRUCT_MNTENT */ # ifdef HAVE_STRUCT_MNTTAB typedef struct mnttab mntent_t; /* map struct mnttab field names to struct mntent field names */ # define mnt_fsname mnt_special # define mnt_dir mnt_mountp # define mnt_opts mnt_mntopts # define mnt_type mnt_fstype # else /* not HAVE_STRUCT_MNTTAB */ # ifdef MOUNT_TABLE_ON_FILE # error Could not find definition for struct mntent or struct mnttab! # else /* not MOUNT_TABLE_ON_FILE */ typedef struct _am_mntent { char *mnt_fsname; /* name of mounted file system */ char *mnt_dir; /* file system path prefix */ char *mnt_type; /* MNTTAB_TYPE_* */ char *mnt_opts; /* MNTTAB_OPT_* */ int mnt_freq; /* dump frequency, in days */ int mnt_passno; /* pass number on parallel fsck */ } mntent_t; # endif /* not MOUNT_TABLE_ON_FILE */ # endif /* not HAVE_STRUCT_MNTTAB */ #endif /* not HAVE_STRUCT_MNTENT */ /* * Provide FD_* macros for systems that lack them. */ #ifndef FD_SET # define FD_SET(fd, set) (*(set) |= (1 << (fd))) # define FD_ISSET(fd, set) (*(set) & (1 << (fd))) # define FD_CLR(fd, set) (*(set) &= ~(1 << (fd))) # define FD_ZERO(set) (*(set) = 0) #endif /* not FD_SET */ /* * Complete external definitions missing from some systems. */ #ifndef HAVE_EXTERN_SYS_ERRLIST extern const char *const sys_errlist[]; #endif /* not HAVE_EXTERN_SYS_ERRLIST */ #ifndef HAVE_EXTERN_OPTARG extern char *optarg; extern int optind; #endif /* not HAVE_EXTERN_OPTARG */ #if defined(HAVE_CLNT_SPCREATEERROR) && !defined(HAVE_EXTERN_CLNT_SPCREATEERROR) extern char *clnt_spcreateerror(const char *s); #endif /* defined(HAVE_CLNT_SPCREATEERROR) && !defined(HAVE_EXTERN_CLNT_SPCREATEERROR) */ #if defined(HAVE_CLNT_SPERRNO) && !defined(HAVE_EXTERN_CLNT_SPERRNO) extern char *clnt_sperrno(const enum clnt_stat num); #endif /* defined(HAVE_CLNT_SPERRNO) && !defined(HAVE_EXTERN_CLNT_SPERRNO) */ #ifndef HAVE_EXTERN_FREE extern void free(voidp); #endif /* not HAVE_EXTERN_FREE */ #if defined(HAVE_GET_MYADDRESS) && !defined(HAVE_EXTERN_GET_MYADDRESS) extern void get_myaddress(struct sockaddr_in *addr); #endif /* defined(HAVE_GET_MYADDRESS) && !defined(HAVE_EXTERN_GET_MYADDRESS) */ #if defined(HAVE_GETDOMAINNAME) && !defined(HAVE_EXTERN_GETDOMAINNAME) # if defined(HAVE_MAP_NIS) || defined(HAVE_MAP_NISPLUS) extern int getdomainname(char *name, int namelen); # endif /* defined(HAVE_MAP_NIS) || defined(HAVE_MAP_NISPLUS) */ #endif /* defined(HAVE_GETDOMAINNAME) && !defined(HAVE_EXTERN_GETDOMAINNAME) */ #if defined(HAVE_GETDTABLESIZE) && !defined(HAVE_EXTERN_GETDTABLESIZE) extern int getdtablesize(void); #endif /* defined(HAVE_GETDTABLESIZE) && !defined(HAVE_EXTERN_GETDTABLESIZE) */ #if defined(HAVE_GETHOSTNAME) && !defined(HAVE_EXTERN_GETHOSTNAME) extern int gethostname(char *name, int namelen); #endif /* defined(HAVE_GETHOSTNAME) && !defined(HAVE_EXTERN_GETHOSTNAME) */ #ifndef HAVE_EXTERN_GETLOGIN extern char *getlogin(void); #endif /* not HAVE_EXTERN_GETLOGIN */ #if defined(HAVE_GETPAGESIZE) && !defined(HAVE_EXTERN_GETPAGESIZE) extern int getpagesize(void); #endif /* defined(HAVE_GETPAGESIZE) && !defined(HAVE_EXTERN_GETPAGESIZE) */ #ifndef HAVE_EXTERN_GETWD extern char *getwd(char *s); #endif /* not HAVE_EXTERN_GETWD */ #if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) && !defined(HAVE_EXTERN_HOSTS_CTL) extern int hosts_ctl(char *daemon, char *client_name, char *client_addr, char *client_user); #endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) && !defined(HAVE_EXTERN_HOSTS_CTL) */ #ifndef HAVE_EXTERN_INNETGR extern int innetgr(char *, char *, char *, char *); #endif /* not HAVE_EXTERN_INNETGR */ #if defined(HAVE_MKSTEMP) && !defined(HAVE_EXTERN_MKSTEMP) extern int mkstemp(char *); #endif /* defined(HAVE_MKSTEMP) && !defined(HAVE_EXTERN_MKSTEMP) */ #ifndef HAVE_EXTERN_SBRK extern caddr_t sbrk(int incr); #endif /* not HAVE_EXTERN_SBRK */ #if defined(HAVE_SETEUID) && !defined(HAVE_EXTERN_SETEUID) extern int seteuid(uid_t euid); #endif /* not defined(HAVE_SETEUID) && !defined(HAVE_EXTERN_SETEUID) */ #if defined(HAVE_SETITIMER) && !defined(HAVE_EXTERN_SETITIMER) extern int setitimer(int, struct itimerval *, struct itimerval *); #endif /* defined(HAVE_SETITIMER) && !defined(HAVE_EXTERN_SETITIMER) */ #ifndef HAVE_EXTERN_SLEEP extern unsigned int sleep(unsigned int seconds); #endif /* not HAVE_EXTERN_SETITIMER */ #ifndef HAVE_EXTERN_STRCASECMP /* * define this extern even if function does not exist, for it will * be filled in by libamu/strcasecmp.c */ extern int strcasecmp(const char *s1, const char *s2); #endif /* not HAVE_EXTERN_STRCASECMP */ #ifndef HAVE_EXTERN_STRDUP /* * define this extern even if function does not exist, for it will * be filled in by libamu/strdup.c */ extern char *strdup(const char *s); #endif /* not HAVE_EXTERN_STRDUP */ #ifndef HAVE_EXTERN_STRLCAT /* * define this extern even if function does not exist, for it will * be filled in by libamu/strlcat.c */ extern size_t strlcat(char *dst, const char *src, size_t siz); #endif /* not HAVE_EXTERN_STRLCAT */ #ifndef HAVE_EXTERN_STRLCPY /* * define this extern even if function does not exist, for it will * be filled in by libamu/strlcpy.c */ extern size_t strlcpy(char *dst, const char *src, size_t siz); #endif /* not HAVE_EXTERN_STRLCPY */ #if defined(HAVE_STRSTR) && !defined(HAVE_EXTERN_STRSTR) extern char *strstr(const char *s1, const char *s2); #endif /* defined(HAVE_STRSTR) && !defined(HAVE_EXTERN_STRSTR) */ #if defined(HAVE_USLEEP) && !defined(HAVE_EXTERN_USLEEP) extern int usleep(u_int useconds); #endif /* defined(HAVE_USLEEP) && !defined(HAVE_EXTERN_USLEEP) */ #ifndef HAVE_EXTERN_UALARM extern u_int ualarm(u_int usecs, u_int interval); #endif /* not HAVE_EXTERN_UALARM */ #if defined(HAVE_WAIT3) && !defined(HAVE_EXTERN_WAIT3) extern int wait3(int *statusp, int options, struct rusage *rusage); #endif /* defined(HAVE_WAIT3) && !defined(HAVE_EXTERN_WAIT3) */ #if defined(HAVE_VSNPRINTF) && !defined(HAVE_EXTERN_VSNPRINTF) extern int vsnprintf(char *, int, const char *, ...); #endif /* defined(HAVE_VSNPRINTF) && !defined(HAVE_EXTERN_VSNPRINTF) */ #ifndef HAVE_EXTERN_XDR_CALLMSG extern bool_t xdr_callmsg(XDR *xdrs, struct rpc_msg *msg); #endif /* not HAVE_EXTERN_XDR_CALLMSG */ #ifndef HAVE_EXTERN_XDR_OPAQUE_AUTH extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *auth); #endif /* not HAVE_EXTERN_XDR_OPAQUE_AUTH */ /****************************************************************************/ /* * amd-specific header files. */ #ifdef THIS_HEADER_FILE_IS_INCLUDED_ABOVE # include #endif /* THIS_HEADER_FILE_IS_INCLUDED_ABOVE */ #include #include #include #include #include /****************************************************************************/ /* * External definitions that depend on other macros available (or not) * and those are probably declared in any of the above headers. */ #ifdef HAVE_HASMNTOPT # ifdef HAVE_BAD_HASMNTOPT extern char *amu_hasmntopt(mntent_t *mnt, char *opt); # else /* not HAVE_BAD_HASMNTOPT */ # define amu_hasmntopt hasmntopt # endif /* not HAVE_BAD_HASMNTOPT */ #else /* not HAVE_HASMNTOPT */ extern char *amu_hasmntopt(mntent_t *mnt, char *opt); #endif /* not HAVE_HASMNTOPT */ #endif /* not _AM_DEFS_H */ am-utils-6.2+rc20110530/include/am_utils.h000066400000000000000000000451021157065440000177450ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/include/am_utils.h * */ /* * Definitions that are specific to the am-utils package. */ #ifndef _AM_UTILS_H #define _AM_UTILS_H #include "aux_conf.h" /**************************************************************************/ /*** MACROS ***/ /**************************************************************************/ /* * General macros. */ #ifndef FALSE # define FALSE 0 #endif /* not FALSE */ #ifndef TRUE # define TRUE 1 #endif /* not TRUE */ #ifndef MAX # define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif /* not MAX */ #ifndef MIN # define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif /* not MIN */ #define ONE_HOUR (60 * 60) /* One hour in seconds */ #ifndef MAXHOSTNAMELEN # ifdef HOSTNAMESZ # define MAXHOSTNAMELEN HOSTNAMESZ # else /* not HOSTNAMESZ */ # define MAXHOSTNAMELEN 256 # endif /* not HOSTNAMESZ */ #endif /* not MAXHOSTNAMELEN */ /* * for hlfsd, and amd for detecting uid/gid */ #ifndef INVALIDID /* this is also defined in include/am_utils.h */ # define INVALIDID (((unsigned short) ~0) - 3) #endif /* not INVALIDID */ /* * String comparison macros */ #define STREQ(s1, s2) (strcmp((s1), (s2)) == 0) #define STRCEQ(s1, s2) (strcasecmp((s1), (s2)) == 0) #define NSTREQ(s1, s2, n) (strncmp((s1), (s2), (n)) == 0) #define NSTRCEQ(s1, s2, n) (strncasecmp((s1), (s2), (n)) == 0) #define FSTREQ(s1, s2) ((*(s1) == *(s2)) && STREQ((s1),(s2))) /* * Logging options/flags */ #define XLOG_FATAL 0x0001 #define XLOG_ERROR 0x0002 #define XLOG_USER 0x0004 #define XLOG_WARNING 0x0008 #define XLOG_INFO 0x0010 #define XLOG_DEBUG 0x0020 #define XLOG_MAP 0x0040 #define XLOG_STATS 0x0080 /* log option compositions */ #define XLOG_MASK 0x00ff /* mask for all flags */ #define XLOG_MANDATORY (XLOG_FATAL|XLOG_ERROR) /* cannot turn these off */ #define XLOG_ALL (XLOG_FATAL|XLOG_ERROR|XLOG_USER|XLOG_WARNING|XLOG_INFO|XLOG_MAP|XLOG_STATS) /* default: fatal + error + user + warning + info */ #define XLOG_DEFAULT (XLOG_MASK & (XLOG_ALL & ~XLOG_MAP & ~XLOG_STATS)) /* default: no logging options */ #define NO_SUBNET "notknown" /* default subnet name for no subnet */ #define NEXP_AP (1022) /* gdmr: was 254 */ #define NEXP_AP_MARGIN (128) /* ???? not used */ /* * Linked list macros */ #define AM_FIRST(ty, q) ((ty *) ((q)->q_forw)) #define AM_LAST(ty, q) ((ty *) ((q)->q_back)) #define NEXT(ty, q) ((ty *) (((qelem *) q)->q_forw)) #define PREV(ty, q) ((ty *) (((qelem *) q)->q_back)) #define HEAD(ty, q) ((ty *) q) #define ITER(v, ty, q) \ for ((v) = AM_FIRST(ty,(q)); (v) != HEAD(ty,(q)); (v) = NEXT(ty,(v))) /* allocate anything of type ty */ #define ALLOC(ty) ((ty *) xmalloc(sizeof(ty))) #define CALLOC(ty) ((ty *) xzalloc(sizeof(ty))) /* simply allocate b bytes */ #define SALLOC(b) xmalloc((b)) /* * Systems which have the mount table in a file need to read it before * they can perform an unmount() system call. */ #define UMOUNT_FS(dir, mtb_name, unmount_flags) umount_fs(dir, mtb_name, unmount_flags) /* next two are imported via $srcdir/conf/umount/umount_*.c */ extern int umount_fs(char *mntdir, const char *mnttabname, u_int unmount_flags); #ifdef MNT2_GEN_OPT_FORCE extern int umount2_fs(const char *mntdir, u_int unmount_flags); #endif /* MNT2_GEN_OPT_FORCE */ /* unmount-related flags (special handling of autofs, forced/lazy, etc.) */ #define AMU_UMOUNT_FORCE 0x1 #define AMU_UMOUNT_DETACH 0x2 #define AMU_UMOUNT_AUTOFS 0x4 /* * The following values can be tuned... */ #define ALLOWED_MOUNT_TIME 40 /* 40s for a mount */ /* * RPC-related macros. */ #define RPC_XID_PORTMAP 0 #define RPC_XID_MOUNTD 1 #define RPC_XID_NFSPING 2 #define RPC_XID_WEBNFS 3 #define RPC_XID_MASK (0x0f) /* 16 id's for now */ #define MK_RPC_XID(type_id, uniq) ((type_id) | ((uniq) << 4)) /* * What level of AMD are we backward compatible with? * This only applies to externally visible characteristics. * Rev.Minor.Branch.Patch (2 digits each) */ #define AMD_COMPAT 5000000 /* 5.0 */ /**************************************************************************/ /*** STRUCTURES AND TYPEDEFS ***/ /**************************************************************************/ /* some typedefs must come first */ typedef char *amq_string; typedef struct _qelem qelem; typedef struct mntlist mntlist; /* * Linked list * (the name 'struct qelem' conflicts with linux's unistd.h) */ struct _qelem { qelem *q_forw; qelem *q_back; }; /* * Option tables */ struct opt_tab { char *opt; int flag; }; /* * Server states */ typedef enum { Start, Run, Finishing, Quit, Done } serv_state; /* * List of mount table entries */ struct mntlist { struct mntlist *mnext; mntent_t *mnt; }; /* * Mount map */ typedef struct mnt_map mnt_map; /**************************************************************************/ /*** EXTERNALS ***/ /**************************************************************************/ /* * Useful constants */ extern char *mnttab_file_name; /* Mount table */ extern char *cpu; /* "CPU type" */ extern char *endian; /* "big" */ extern char *hostdomain; /* "southseas.nz" */ extern char copyright[]; /* Copyright info */ extern char version[]; /* Version info */ /* * Global variables. */ extern AUTH *nfs_auth; /* Dummy authorization for remote servers */ extern FILE *logfp; /* Log file */ extern SVCXPRT *nfsxprt; extern char *PrimNetName; /* Name of primary connected network */ extern char *PrimNetNum; /* Name of primary connected network */ extern char *SubsNetName; /* Name of subsidiary connected network */ extern char *SubsNetNum; /* Name of subsidiary connected network */ extern void am_set_progname(char *pn); /* "amd" */ extern const char *am_get_progname(void); /* "amd" */ extern void am_set_hostname(char *hn); extern const char *am_get_hostname(void); extern pid_t am_set_mypid(void); extern pid_t am_mypid; extern int foreground; /* Foreground process */ extern int orig_umask; /* umask() on startup */ extern serv_state amd_state; /* Should we go now */ extern struct in_addr myipaddr; /* (An) IP address of this host */ extern struct opt_tab xlog_opt[]; extern u_short nfs_port; /* Our NFS service port */ /* * Global routines */ extern CLIENT *get_mount_client(char *unused_host, struct sockaddr_in *sin, struct timeval *tv, int *sock, u_long mnt_version); extern RETSIGTYPE sigchld(int); extern bool_t xdr_amq_string(XDR *xdrs, amq_string *objp); extern bool_t xdr_dirpath(XDR *xdrs, dirpath *objp); extern char **strsplit(char *, int, int); extern char *expand_selectors(char *); extern char *get_version_string(void); extern char *inet_dquad(char *, size_t, u_long); extern char *print_wires(void); extern char *str3cat(char *, char *, char *, char *); extern char *strealloc(char *, char *); extern char *strip_selectors(char *, char *); extern char *strnsave(const char *, int); extern int amu_close(int fd); extern int bind_resv_port(int, u_short *); extern int cmdoption(char *, struct opt_tab *, u_int *); extern int compute_automounter_mount_flags(mntent_t *); extern int compute_mount_flags(mntent_t *); extern u_long get_amd_program_number(void); extern int getcreds(struct svc_req *, uid_t *, gid_t *, SVCXPRT *); extern int hasmntval(mntent_t *, char *); extern unsigned int hasmntvalerr(mntent_t *, char *, int *); extern char *hasmntstr(mntent_t *, char *); extern char *hasmnteq(mntent_t *, char *); extern char *haseq(char *); extern int is_network_member(const char *net); extern int is_interface_local(u_long); extern int islocalnet(u_long); extern int make_rpc_packet(char *, int, u_long, struct rpc_msg *, voidp, XDRPROC_T_TYPE, AUTH *); extern int mkdirs(char *, int); extern int mount_fs(mntent_t *, int, caddr_t, int, MTYPE_TYPE, u_long, const char *, const char *, int); extern void nfs_program_2(struct svc_req *rqstp, SVCXPRT *transp); extern int pickup_rpc_reply(voidp, int, voidp, XDRPROC_T_TYPE); extern int switch_option(char *); extern int switch_to_logfile(char *logfile, int orig_umask, int truncate_log); extern mntlist *read_mtab(char *, const char *); #ifndef HAVE_TRANSPORT_TYPE_TLI extern struct sockaddr_in *amu_svc_getcaller(SVCXPRT *xprt); #endif /* not HAVE_TRANSPORT_TYPE_TLI */ extern time_t time(time_t *); extern void amu_get_myaddress(struct in_addr *iap, const char *preferred_localhost); extern void amu_release_controlling_tty(void); extern void compute_automounter_nfs_args(nfs_args_t *nap, mntent_t *mntp); extern void discard_mntlist(mntlist *mp); extern void free_mntlist(mntlist *); extern void getwire(char **name1, char **number1); extern void going_down(int); extern void mnt_free(mntent_t *); extern void plog(int, const char *,...) __attribute__ ((__format__ (__printf__, 2, 3))); extern void rmdirs(char *); extern void rpc_msg_init(struct rpc_msg *, u_long, u_long, u_long); extern void set_amd_program_number(u_long program); extern void show_opts(int ch, struct opt_tab *); extern void unregister_amq(void); extern voidp xmalloc(int); extern voidp xrealloc(voidp, int); extern voidp xzalloc(int); extern int check_pmap_up(char *host, struct sockaddr_in* sin); extern u_long get_nfs_version(char *host, struct sockaddr_in *sin, u_long nfs_version, const char *proto); extern long get_server_pid(void); extern void setup_sighandler(int signum, void (*handler)(int)); extern time_t clocktime(nfstime *nt); #if defined(DEBUG) && (defined(HAVE_C99_VARARGS_MACROS) || defined(HAVE_GCC_VARARGS_MACROS)) # ifdef HAVE_C99_VARARGS_MACROS #define xsnprintf(str,size,fmt,...) _xsnprintf(__FILE__,__LINE__,(str),(size),(fmt),__VA_ARGS__) # endif /* HAVE_C99_VARARGS_MACROS */ # ifdef HAVE_GCC_VARARGS_MACROS #define xsnprintf(str,size,fmt,args...) _xsnprintf(__FILE__,__LINE__,(str),(size),(fmt),args) # endif /* HAVE_GCC_VARARGS_MACROS */ extern int _xsnprintf(const char *filename, int lineno, char *str, size_t size, const char *format, ...); #define xvsnprintf(str,size,fmt,ap) _xvsnprintf(__FILE__,__LINE__,(str),(size),(fmt),(ap)) extern int _xvsnprintf(const char *filename, int lineno, char *str, size_t size, const char *format, va_list ap); #else /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ extern int xsnprintf(char *str, size_t size, const char *format, ...); extern int xvsnprintf(char *str, size_t size, const char *format, va_list ap); #endif /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ #ifdef DEBUG extern void _xstrlcat(const char *filename, int lineno, char *dst, const char *src, size_t len); # define xstrlcat(d,s,l) _xstrlcat(__FILE__,__LINE__,(d),(s),(l)) extern void _xstrlcpy(const char *filename, int lineno, char *dst, const char *src, size_t len); # define xstrlcpy(d,s,l) _xstrlcpy(__FILE__,__LINE__,(d),(s),(l)) #else /* not DEBUG */ extern void xstrlcat(char *dst, const char *src, size_t len); extern void xstrlcpy(char *dst, const char *src, size_t len); #endif /* not DEBUG */ #ifdef MOUNT_TABLE_ON_FILE extern void rewrite_mtab(mntlist *, const char *); extern void unlock_mntlist(void); extern void write_mntent(mntent_t *, const char *); #endif /* MOUNT_TABLE_ON_FILE */ #if defined(HAVE_SYSLOG_H) || defined(HAVE_SYS_SYSLOG_H) extern int syslogging; #endif /* defined(HAVE_SYSLOG_H) || defined(HAVE_SYS_SYSLOG_H) */ extern 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); extern int create_amq_service(int *udp_soAMQp, SVCXPRT **udp_amqpp, struct netconfig **udp_amqncpp, int *tcp_soAMQp, SVCXPRT **tcp_amqpp, struct netconfig **tcp_amqncpp, u_short preferred_amq_port); extern int create_nfs_service(int *soNFSp, u_short *nfs_portp, SVCXPRT **nfs_xprtp, void (*dispatch_fxn)(struct svc_req *rqstp, SVCXPRT *transp)); extern int amu_svc_register(SVCXPRT *, u_long, u_long, void (*)(struct svc_req *, SVCXPRT *), u_long, struct netconfig *); #ifdef HAVE_TRANSPORT_TYPE_TLI extern int get_knetconfig(struct knetconfig **kncpp, struct netconfig *in_ncp, char *nc_protoname); extern struct netconfig *nfsncp; extern void free_knetconfig(struct knetconfig *kncp); #endif /* HAVE_TRANSPORT_TYPE_TLI */ #ifdef HAVE_FS_AUTOFS extern int register_autofs_service(char *autofs_conftype, void (*autofs_dispatch)(struct svc_req *rqstp, SVCXPRT *xprt)); extern int unregister_autofs_service(char *autofs_conftype); #endif /* HAVE_FS_AUTOFS */ #ifndef HAVE_STRUCT_FHSTATUS_FHS_FH # define fhs_fh fhstatus_u.fhs_fhandle #endif /* not HAVE_STRUCT_FHSTATUS_FHS_FH */ /* * Network File System: the new generation * NFS V.3 */ #ifdef HAVE_FS_NFS3 # ifndef NFS_VERSION3 # define NFS_VERSION3 ((u_int) 3) # endif /* not NFS_VERSION3 */ #endif /* HAVE_FS_NFS3 */ /**************************************************************************/ /*** DEBUGGING ***/ /**************************************************************************/ /* * DEBUGGING: */ #ifdef DEBUG # define D_DAEMON 0x0001 /* Enter daemon mode */ # define D_TRACE 0x0002 /* Do protocol trace */ # define D_FULL 0x0004 /* Do full trace */ # define D_MTAB 0x0008 /* Use local mtab */ # define D_AMQ 0x0010 /* Register amq program */ # define D_STR 0x0020 /* Debug string munging */ # ifdef DEBUG_MEM # define D_MEM 0x0040 /* Trace memory allocations */ # else /* not DEBUG_MEM */ # define D_MEM 0x0000 /* Dummy */ # endif /* not DEBUG_MEM */ # define D_FORK 0x0080 /* Fork server (hlfsd only) */ # define D_INFO 0x0100 /* info service specific debugging (hesiod, nis, etc) */ # define D_HRTIME 0x0200 /* Print high resolution time stamps */ # define D_XDRTRACE 0x0400 /* Trace xdr routines */ # define D_READDIR 0x0800 /* Show browsable_dir progress */ /* debug option compositions */ # define D_MASK 0x0fff /* mask of known flags */ # define D_BASIC (D_TRACE|D_FULL|D_STR|D_MEM|D_INFO|D_XDRTRACE|D_READDIR) # define D_CONTROL (D_DAEMON|D_AMQ|D_FORK) /* immutable flags: cannot be changed via "amq -D" */ # define D_IMMUTABLE (D_MTAB | D_CONTROL) # define D_ALL (D_BASIC | D_CONTROL) # define D_DEFAULT (D_MASK & D_ALL & ~D_XDRTRACE) /* test mode: nodaemon, noamq, nofork, (local) mtab */ # define D_TEST (D_BASIC | D_MTAB) # define amuDebug(x) (debug_flags & (x)) # define dlog if (amuDebug(D_FULL)) dplog /* my favorite debugging tool -Erez */ #define EZKDBG plog(XLOG_INFO,"EZK:%s:%s:%d\n",__FILE__,__FUNCTION__,__LINE__) # ifdef DEBUG_MEM /* * If debugging memory, then call a special freeing function that logs * more info, and resets the pointer to NULL so it cannot be used again. */ # define XFREE(x) dxfree(__FILE__,__LINE__,x) extern void dxfree(char *file, int line, voidp ptr); extern void malloc_verify(void); # else /* not DEBUG_MEM */ /* * If regular debugging, then free the pointer and reset to NULL. * This should remain so for as long as am-utils is in alpha/beta testing. */ # define XFREE(x) do { free((voidp)x); x = NULL;} while (0) # endif /* not DEBUG_MEM */ /* functions that depend solely on debugging */ extern void print_nfs_args(const nfs_args_t *nap, u_long nfs_version); extern int debug_option (char *opt); extern void dplog(const char *fmt, ...) __attribute__ ((__format__ (__printf__, 1, 2))); #else /* not DEBUG */ /* set dummy flags to zero */ # define D_DAEMON 0x0001 /* Enter daemon mode */ # define D_TRACE 0x0000 /* dummy: Do protocol trace */ # define D_FULL 0x0000 /* dummy: Do full trace */ # define D_MTAB 0x0000 /* dummy: Use local mtab */ # define D_AMQ 0x0010 /* Register amq program */ # define D_STR 0x0000 /* dummy: Debug string munging */ # define D_MEM 0x0000 /* dummy: Trace memory allocations */ # define D_FORK 0x0080 /* Fork server (hlfsd only) */ # define D_INFO 0x0000 /* dummy: info service debugging */ # define D_HRTIME 0x0000 /* dummy: hi-res time stamps */ # define D_XDRTRACE 0x0000 /* dummy: Trace xdr routines */ # define D_READDIR 0x0000 /* dummy: browsable_dir progress */ # define D_CONTROL (D_DAEMON|D_AMQ|D_FORK) # define amuDebug(x) (debug_flags & (x)) /* * If not debugging, then also reset the pointer. * It's safer -- and besides, free() should do that anyway. */ # define XFREE(x) do { free((voidp)x); x = NULL;} while (0) # if defined(HAVE_GCC_VARARGS_MACROS) # define dlog(fmt...) # elif defined(HAVE_C99_VARARGS_MACROS) # define dlog(...) # else /* no c99 varargs */ /* this define means that we CCP leaves code behind the (list,of,args) */ # define dlog # endif /* no c99 varargs */ # define print_nfs_args(nap, nfs_version) # define debug_option(x) (1) #endif /* not DEBUG */ extern u_int debug_flags; /* Debug options */ extern struct opt_tab dbg_opt[]; /**************************************************************************/ /*** MISC (stuff left to autoconfiscate) ***/ /**************************************************************************/ #endif /* not _AM_UTILS_H */ am-utils-6.2+rc20110530/include/am_xdr_func.h000066400000000000000000000246061157065440000204230ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/include/am_xdr_func.h * */ #ifdef HAVE_FS_NFS3 #define AM_FHSIZE3 64 /* size in bytes of a file handle (v3) */ #define AM_MOUNTVERS3 ((unsigned long)(3)) /* NFSv3 handle */ struct am_nfs_fh3 { u_int am_fh3_length; char am_fh3_data[AM_FHSIZE3]; }; typedef struct am_nfs_fh3 am_nfs_fh3; #define AM_NFSPROC3_LOOKUP ((u_long) 3) enum am_nfsstat3 { AM_NFS3_OK = 0, AM_NFS3ERR_PERM = 1, AM_NFS3ERR_NOENT = 2, AM_NFS3ERR_IO = 5, AM_NFS3ERR_NXIO = 6, AM_NFS3ERR_ACCES = 13, AM_NFS3ERR_EXIST = 17, AM_NFS3ERR_XDEV = 18, AM_NFS3ERR_NODEV = 19, AM_NFS3ERR_NOTDIR = 20, AM_NFS3ERR_ISDIR = 21, AM_NFS3ERR_INVAL = 22, AM_NFS3ERR_FBIG = 27, AM_NFS3ERR_NOSPC = 28, AM_NFS3ERR_ROFS = 30, AM_NFS3ERR_MLINK = 31, AM_NFS3ERR_NAMETOOLONG = 63, AM_NFS3ERR_NOTEMPTY = 66, AM_NFS3ERR_DQUOT = 69, AM_NFS3ERR_STALE = 70, AM_NFS3ERR_REMOTE = 71, AM_NFS3ERR_BADHANDLE = 10001, AM_NFS3ERR_NOT_SYNC = 10002, AM_NFS3ERR_BAD_COOKIE = 10003, AM_NFS3ERR_NOTSUPP = 10004, AM_NFS3ERR_TOOSMALL = 10005, AM_NFS3ERR_SERVERFAULT = 10006, AM_NFS3ERR_BADTYPE = 10007, AM_NFS3ERR_JUKEBOX = 10008 }; typedef enum am_nfsstat3 am_nfsstat3; typedef struct { u_int fhandle3_len; char *fhandle3_val; } am_fhandle3; enum am_mountstat3 { AM_MNT3_OK = 0, AM_MNT3ERR_PERM = 1, AM_MNT3ERR_NOENT = 2, AM_MNT3ERR_IO = 5, AM_MNT3ERR_ACCES = 13, AM_MNT3ERR_NOTDIR = 20, AM_MNT3ERR_INVAL = 22, AM_MNT3ERR_NAMETOOLONG = 63, AM_MNT3ERR_NOTSUPP = 10004, AM_MNT3ERR_SERVERFAULT = 10006 }; typedef enum am_mountstat3 am_mountstat3; struct am_mountres3_ok { am_fhandle3 fhandle; struct { u_int auth_flavors_len; int *auth_flavors_val; } auth_flavors; }; typedef struct am_mountres3_ok am_mountres3_ok; struct am_mountres3 { am_mountstat3 fhs_status; union { am_mountres3_ok mountinfo; } mountres3_u; }; typedef struct am_mountres3 am_mountres3; typedef char *am_filename3; struct am_diropargs3 { am_nfs_fh3 dir; am_filename3 name; }; typedef struct am_diropargs3 am_diropargs3; struct am_LOOKUP3args { am_diropargs3 what; }; typedef struct am_LOOKUP3args am_LOOKUP3args; struct am_LOOKUP3resok { am_nfs_fh3 object; #if 0 post_op_attr obj_attributes; post_op_attr dir_attributes; #endif /* 0 */ }; typedef struct am_LOOKUP3resok am_LOOKUP3resok; struct am_LOOKUP3resfail { #if 0 post_op_attr dir_attributes; #else /* !0 */ char dummy; /* cannot have an empty declaration */ #endif /* !0 */ }; typedef struct am_LOOKUP3resfail am_LOOKUP3resfail; struct am_LOOKUP3res { am_nfsstat3 status; union { am_LOOKUP3resok ok; am_LOOKUP3resfail fail; } res_u; }; typedef struct am_LOOKUP3res am_LOOKUP3res; #endif /* HAVE_FS_NFS3 */ /* * Multi-protocol NFS file handle */ union am_nfs_handle { /* placeholder for V4 file handle */ #ifdef HAVE_FS_NFS3 am_nfs_fh3 v3; /* NFS version 3 handle */ #endif /* HAVE_FS_NFS3 */ am_nfs_fh v2; /* NFS version 2 handle */ }; typedef union am_nfs_handle am_nfs_handle_t; /* * Definitions of all possible xdr functions that are otherwise * not defined elsewhere. */ #ifndef _AM_XDR_FUNC_H #define _AM_XDR_FUNC_H #ifndef HAVE_XDR_ATTRSTAT bool_t xdr_attrstat(XDR *xdrs, nfsattrstat *objp); #endif /* not HAVE_XDR_ATTRSTAT */ #ifndef HAVE_XDR_CREATEARGS bool_t xdr_createargs(XDR *xdrs, nfscreateargs *objp); #endif /* not HAVE_XDR_CREATEARGS */ #ifndef HAVE_XDR_DIRLIST bool_t xdr_dirlist(XDR *xdrs, nfsdirlist *objp); #endif /* not HAVE_XDR_DIRLIST */ #ifndef HAVE_XDR_DIROPARGS bool_t xdr_diropargs(XDR *xdrs, nfsdiropargs *objp); #endif /* not HAVE_XDR_DIROPARGS */ #ifndef HAVE_XDR_DIROPOKRES bool_t xdr_diropokres(XDR *xdrs, nfsdiropokres *objp); #endif /* not HAVE_XDR_DIROPOKRES */ #ifndef HAVE_XDR_DIROPRES bool_t xdr_diropres(XDR *xdrs, nfsdiropres *objp); #endif /* not HAVE_XDR_DIROPRES */ #ifndef HAVE_XDR_DIRPATH bool_t xdr_dirpath(XDR *xdrs, dirpath *objp); #endif /* not HAVE_XDR_DIRPATH */ #ifndef HAVE_XDR_ENTRY bool_t xdr_entry(XDR *xdrs, nfsentry *objp); #endif /* not HAVE_XDR_ENTRY */ #ifndef HAVE_XDR_EXPORTNODE bool_t xdr_exportnode(XDR *xdrs, exportnode *objp); #endif /* not HAVE_XDR_EXPORTNODE */ #ifndef HAVE_XDR_EXPORTS bool_t xdr_exports(XDR *xdrs, exports *objp); #endif /* not HAVE_XDR_EXPORTS */ #ifndef HAVE_XDR_FATTR bool_t xdr_fattr(XDR *xdrs, nfsfattr *objp); #endif /* not HAVE_XDR_FATTR */ #ifndef HAVE_XDR_FHANDLE bool_t xdr_fhandle(XDR *xdrs, fhandle objp); #endif /* not HAVE_XDR_FHANDLE */ #ifndef HAVE_XDR_FHSTATUS bool_t xdr_fhstatus(XDR *xdrs, fhstatus *objp); #endif /* not HAVE_XDR_FHSTATUS */ #ifndef HAVE_XDR_FILENAME bool_t xdr_filename(XDR *xdrs, filename *objp); #endif /* not HAVE_XDR_FILENAME */ #ifndef HAVE_XDR_FTYPE bool_t xdr_ftype(XDR *xdrs, nfsftype *objp); #endif /* not HAVE_XDR_FTYPE */ #ifndef HAVE_XDR_GROUPNODE bool_t xdr_groupnode(XDR *xdrs, groupnode *objp); #endif /* not HAVE_XDR_GROUPNODE */ #ifndef HAVE_XDR_GROUPS bool_t xdr_groups(XDR *xdrs, groups *objp); #endif /* not HAVE_XDR_GROUPS */ #ifndef HAVE_XDR_LINKARGS bool_t xdr_linkargs(XDR *xdrs, nfslinkargs *objp); #endif /* not HAVE_XDR_LINKARGS */ #ifndef HAVE_XDR_MOUNTBODY bool_t xdr_mountbody(XDR *xdrs, mountbody *objp); #endif /* not HAVE_XDR_MOUNTBODY */ #ifndef HAVE_XDR_MOUNTLIST bool_t xdr_mountlist(XDR *xdrs, mountlist *objp); #endif /* not HAVE_XDR_MOUNTLIST */ #ifndef HAVE_XDR_NAME bool_t xdr_name(XDR *xdrs, name *objp); #endif /* not HAVE_XDR_NAME */ #ifndef HAVE_XDR_NFS_FH bool_t xdr_nfs_fh(XDR *xdrs, am_nfs_fh *objp); #endif /* not HAVE_XDR_NFS_FH */ #ifndef HAVE_XDR_NFSCOOKIE bool_t xdr_nfscookie(XDR *xdrs, nfscookie objp); #endif /* not HAVE_XDR_NFSCOOKIE */ #ifndef HAVE_XDR_NFSPATH bool_t xdr_nfspath(XDR *xdrs, nfspath *objp); #endif /* not HAVE_XDR_NFSPATH */ #ifndef HAVE_XDR_NFSSTAT bool_t xdr_nfsstat(XDR *xdrs, nfsstat *objp); #endif /* not HAVE_XDR_NFSSTAT */ #ifndef HAVE_XDR_NFSTIME bool_t xdr_nfstime(XDR *xdrs, nfstime *objp); #endif /* not HAVE_XDR_NFSTIME */ #ifndef HAVE_XDR_POINTER bool_t xdr_pointer(register XDR *xdrs, char **objpp, u_int obj_size, XDRPROC_T_TYPE xdr_obj); #endif /* not HAVE_XDR_POINTER */ #ifndef HAVE_XDR_READARGS bool_t xdr_readargs(XDR *xdrs, nfsreadargs *objp); #endif /* not HAVE_XDR_READARGS */ #ifndef HAVE_XDR_READDIRARGS bool_t xdr_readdirargs(XDR *xdrs, nfsreaddirargs *objp); #endif /* not HAVE_XDR_READDIRARGS */ #ifndef HAVE_XDR_READDIRRES bool_t xdr_readdirres(XDR *xdrs, nfsreaddirres *objp); #endif /* not HAVE_XDR_READDIRRES */ #ifndef HAVE_XDR_READLINKRES bool_t xdr_readlinkres(XDR *xdrs, nfsreadlinkres *objp); #endif /* not HAVE_XDR_READLINKRES */ #ifndef HAVE_XDR_READOKRES bool_t xdr_readokres(XDR *xdrs, nfsreadokres *objp); #endif /* not HAVE_XDR_READOKRES */ #ifndef HAVE_XDR_READRES bool_t xdr_readres(XDR *xdrs, nfsreadres *objp); #endif /* not HAVE_XDR_READRES */ #ifndef HAVE_XDR_RENAMEARGS bool_t xdr_renameargs(XDR *xdrs, nfsrenameargs *objp); #endif /* not HAVE_XDR_RENAMEARGS */ #ifndef HAVE_XDR_SATTR bool_t xdr_sattr(XDR *xdrs, nfssattr *objp); #endif /* not HAVE_XDR_SATTR */ #ifndef HAVE_XDR_SATTRARGS bool_t xdr_sattrargs(XDR *xdrs, nfssattrargs *objp); #endif /* not HAVE_XDR_SATTRARGS */ #ifndef HAVE_XDR_STATFSOKRES bool_t xdr_statfsokres(XDR *xdrs, nfsstatfsokres *objp); #endif /* not HAVE_XDR_STATFSOKRES */ #ifndef HAVE_XDR_STATFSRES bool_t xdr_statfsres(XDR *xdrs, nfsstatfsres *objp); #endif /* not HAVE_XDR_STATFSRES */ #ifndef HAVE_XDR_SYMLINKARGS bool_t xdr_symlinkargs(XDR *xdrs, nfssymlinkargs *objp); #endif /* not HAVE_XDR_SYMLINKARGS */ #ifndef HAVE_XDR_WRITEARGS bool_t xdr_writeargs(XDR *xdrs, nfswriteargs *objp); #endif /* not HAVE_XDR_WRITEARGS */ /* * NFS3 XDR FUNCTIONS: */ #ifdef HAVE_FS_NFS3 bool_t xdr_am_fhandle3(XDR *xdrs, am_fhandle3 *objp); bool_t xdr_am_mountstat3(XDR *xdrs, am_mountstat3 *objp); bool_t xdr_am_mountres3_ok(XDR *xdrs, am_mountres3_ok *objp); bool_t xdr_am_mountres3(XDR *xdrs, am_mountres3 *objp); bool_t xdr_am_diropargs3(XDR *xdrs, am_diropargs3 *objp); bool_t xdr_am_filename3(XDR *xdrs, am_filename3 *objp); bool_t xdr_am_LOOKUP3args(XDR *xdrs, am_LOOKUP3args *objp); bool_t xdr_am_LOOKUP3res(XDR *xdrs, am_LOOKUP3res *objp); bool_t xdr_am_LOOKUP3resfail(XDR *xdrs, am_LOOKUP3resfail *objp); bool_t xdr_am_LOOKUP3resok(XDR *xdrs, am_LOOKUP3resok *objp); bool_t xdr_am_nfsstat3(XDR *xdrs, am_nfsstat3 *objp); bool_t xdr_am_nfs_fh3(XDR *xdrs, am_nfs_fh3 *objp); #endif /* HAVE_FS_NFS3 */ #endif /* not _AM_XDR_FUNC_H */ am-utils-6.2+rc20110530/include/amq_defs.h000066400000000000000000000131221157065440000177040ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/include/amq_defs.h * */ #ifndef _AMQ_DEFS_H #define _AMQ_DEFS_H /* * MACROS */ #ifndef AMQ_SIZE # define AMQ_SIZE 16384 #endif /* not AMQ_SIZE */ #define AMQ_STRLEN 16384 #define AMQ_PROGRAM ((u_long)300019) #define AMQ_VERSION ((u_long)1) #define AMQPROC_NULL ((u_long)0) #define AMQPROC_MNTTREE ((u_long)1) #define AMQPROC_UMNT ((u_long)2) /* asynchronous unmount */ #define AMQPROC_STATS ((u_long)3) #define AMQPROC_EXPORT ((u_long)4) #define AMQPROC_SETOPT ((u_long)5) #define AMQPROC_GETMNTFS ((u_long)6) #define AMQPROC_MOUNT ((u_long)7) #define AMQPROC_GETVERS ((u_long)8) #define AMQPROC_GETPID ((u_long)9) #define AMQPROC_PAWD ((u_long)10) #define AMQPROC_SYNC_UMNT ((u_long)11) /* synchronous unmount */ /* * TYPEDEFS */ typedef long *time_type; typedef struct amq_mount_info amq_mount_info; typedef struct amq_mount_stats amq_mount_stats; typedef struct amq_mount_tree amq_mount_tree; typedef struct amq_setopt amq_setopt; typedef struct amq_sync_umnt amq_sync_umnt; typedef amq_mount_tree *amq_mount_tree_p; /* * STRUCTURES: */ struct amq_mount_tree { amq_string mt_mountinfo; amq_string mt_directory; amq_string mt_mountpoint; amq_string mt_type; time_type mt_mounttime; u_short mt_mountuid; int mt_getattr; int mt_lookup; int mt_readdir; int mt_readlink; int mt_statfs; struct amq_mount_tree *mt_next; struct amq_mount_tree *mt_child; }; struct amq_mount_info { amq_string mi_type; amq_string mi_mountpt; amq_string mi_mountinfo; amq_string mi_fserver; int mi_error; int mi_refc; int mi_up; }; typedef struct { u_int amq_mount_info_list_len; amq_mount_info *amq_mount_info_list_val; } amq_mount_info_list; typedef struct { u_int amq_mount_tree_list_len; amq_mount_tree_p *amq_mount_tree_list_val; } amq_mount_tree_list; struct amq_mount_stats { int as_drops; int as_stale; int as_mok; int as_merr; int as_uerr; }; typedef enum { AMQ_UMNT_OK = 0, /* must be zero! */ AMQ_UMNT_FAILED = 1, /* unmount failed */ AMQ_UMNT_FORK = 2, /* fork failed */ AMQ_UMNT_READ = 3, /* pipe read failed */ AMQ_UMNT_SERVER = 4, /* server down */ AMQ_UMNT_SIGNAL = 5 /* received signal */ } au_etype; struct amq_sync_umnt { au_etype au_etype; /* error type */ int au_errno; /* error number */ int au_signal; /* signal received */ }; enum amq_opt { AMOPT_DEBUG = 0, AMOPT_LOGFILE = 1, AMOPT_XLOG = 2, AMOPT_FLUSHMAPC = 3 }; typedef enum amq_opt amq_opt; /* enum typedefs should be after enum */ struct amq_setopt { amq_opt as_opt; amq_string as_str; }; /* * EXTERNALS: * * external definitions for amqproc_*_1() have been moved off to private * headers in lib/amu.h, amd/amd.h, etc. They have to be private since the * same named functions appear in different places with different prototypes * an functionality. */ extern bool_t xdr_amq_mount_info(XDR *xdrs, amq_mount_info *objp); extern bool_t xdr_amq_mount_info_list(XDR *xdrs, amq_mount_info_list *objp); extern bool_t xdr_amq_mount_stats(XDR *xdrs, amq_mount_stats *objp); extern bool_t xdr_amq_mount_tree(XDR *xdrs, amq_mount_tree *objp); extern bool_t xdr_amq_mount_tree_list(XDR *xdrs, amq_mount_tree_list *objp); extern bool_t xdr_amq_mount_tree_p(XDR *xdrs, amq_mount_tree_p *objp); extern bool_t xdr_amq_opt(XDR *xdrs, amq_opt *objp); extern bool_t xdr_amq_setopt(XDR *xdrs, amq_setopt *objp); extern bool_t xdr_amq_sync_umnt(XDR *xdrs, amq_sync_umnt *objp); extern bool_t xdr_pri_free(XDRPROC_T_TYPE xdr_args, caddr_t args_ptr); extern bool_t xdr_time_type(XDR *xdrs, time_type *objp); #endif /* not _AMQ_DEFS_H */ am-utils-6.2+rc20110530/include/mount_headers1.h000066400000000000000000000157601157065440000210550ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/include/mount_headers1.h * */ #ifdef HAVE_SYS_TYPES_H # include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_ERRNO_H # include #endif /* HAVE_SYS_ERRNO_H */ #ifdef HAVE_SYS_PARAM_H # include #endif /* HAVE_SYS_PARAM_H */ #ifdef HAVE_SYS_TIME_H # include #endif /* HAVE_SYS_TIME_H */ #ifdef HAVE_SYS_UCRED_H # include #endif /* HAVE_SYS_UCRED_H */ #ifdef HAVE_SYS_SOCKET_H # include #endif /* HAVE_SYS_SOCKET_H */ #ifdef HAVE_NETINET_IN_H # include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_NET_IF_H # include #endif /* HAVE_NET_IF_H */ #ifdef HAVE_STDIO_H # include #endif /* HAVE_STDIO_H */ #ifndef KERNEL # define KERNEL_off_for_now_breaks_FreeBSD #endif /* not KERNEL */ #ifdef HAVE_SYS_MNTENT_H # include #endif /* HAVE_SYS_MNTENT_H */ #ifdef HAVE_MNTENT_H # include #endif /* HAVE_MNTENT_H */ #ifdef HAVE_SYS_MNTTAB_H # include #endif /* HAVE_SYS_MNTTAB_H */ #if defined(HAVE_MNTTAB_H) && !defined(MNTTAB) /* * Do not include it if MNTTAB is already defined because it probably * came from and we do not want conflicting definitions. */ # include #endif /* defined(HAVE_MNTTAB_H) && !defined(MNTTAB) */ #ifdef HAVE_SYS_MOUNT_H # ifndef NFSCLIENT # define NFSCLIENT # endif /* not NFSCLIENT */ # ifndef PCFS # define PCFS # endif /* not PCFS */ # ifndef LOFS # define LOFS # endif /* not LOFS */ # ifndef RFS # define RFS # endif /* not RFS */ # ifndef MSDOSFS # define MSDOSFS # endif /* not MSDOSFS */ # ifndef MFS # define MFS 1 # endif /* not MFS */ # ifndef CD9660 # define CD9660 # endif /* not CD9660 */ # ifndef NFS # define NFS # endif /* not NFS */ # include #endif /* HAVE_SYS_MOUNT_H */ #ifdef HAVE_SYS_VMOUNT_H # include #endif /* HAVE_SYS_VMOUNT_H */ /* * There is no point in including this on a glibc2 system * we're only asking for trouble */ #if defined HAVE_LINUX_FS_H && (!defined __GLIBC__ || __GLIBC__ < 2) /* * There's a conflict of definitions on redhat alpha linux between * and . * Also a conflict in definitions of ntohl/htonl in RH-5.1 sparc64 * between and (2.1 kernels). */ # ifdef HAVE_SOCKETBITS_H # define _LINUX_SOCKET_H # undef BLKFLSBUF # undef BLKGETSIZE # undef BLKRAGET # undef BLKRASET # undef BLKROGET # undef BLKROSET # undef BLKRRPART # undef MS_MGC_VAL # undef MS_RMT_MASK # endif /* HAVE_SOCKETBITS_H */ # ifdef HAVE_LINUX_POSIX_TYPES_H # include # endif /* HAVE_LINUX_POSIX_TYPES_H */ # ifndef _LINUX_BYTEORDER_GENERIC_H # define _LINUX_BYTEORDER_GENERIC_H # endif /* _LINUX_BYTEORDER_GENERIC_H */ # ifndef _LINUX_STRING_H_ # define _LINUX_STRING_H_ # endif /* not _LINUX_STRING_H_ */ # ifdef HAVE_LINUX_KDEV_T_H # define __KERNEL__ # include # undef __KERNEL__ # endif /* HAVE_LINUX_KDEV_T_H */ # ifdef HAVE_LINUX_LIST_H # define __KERNEL__ # include # undef __KERNEL__ # endif /* HAVE_LINUX_LIST_H */ # include #endif /* HAVE_LINUX_FS_H && (!__GLIBC__ || __GLIBC__ < 2) */ #ifdef HAVE_SYS_FS_TYPES_H # include #endif /* HAVE_SYS_FS_TYPES_H */ #ifdef HAVE_UFS_UFS_MOUNT_H # include #endif /* HAVE_UFS_UFS_MOUNT_H */ #ifdef HAVE_UFS_UFS_UFSMOUNT_H_off # error do not include this file here because on *bsd it # error causes errors with other header files. Instead, add it to the # error specific conf/nfs_prot_*.h file. # include #endif /* HAVE_UFS_UFS_UFSMOUNT_H_off */ #ifdef HAVE_CDFS_CDFS_MOUNT_H # include #endif /* HAVE_CDFS_CDFS_MOUNT_H */ #ifdef HAVE_CDFS_CDFSMOUNT_H # include #endif /* HAVE_CDFS_CDFSMOUNT_H */ #ifdef HAVE_ISOFS_CD9660_CD9660_MOUNT_H # include #endif /* HAVE_ISOFS_CD9660_CD9660_MOUNT_H */ #ifdef HAVE_FS_UDF_UDF_MOUNT_H # include #endif /* HAVE_FS_UDF_UDF_MOUNT_H */ #ifdef HAVE_SYS_FS_PC_FS_H # include #endif /* HAVE_SYS_FS_PC_FS_H */ #ifdef HAVE_MSDOSFS_MSDOSFSMOUNT_H # include #endif /* HAVE_MSDOSFS_MSDOSFSMOUNT_H */ #ifdef HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H # include #endif /* HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H */ #ifdef HAVE_FS_TMPFS_TMPFS_ARGS_H # include #endif /* HAVE_FS_TMPFS_TMPFS_ARGS_H */ #ifdef HAVE_FS_EFS_EFS_MOUNT_H # include #endif /* HAVE_FS_EFS_EFS_MOUNT_H */ #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ #ifdef HAVE_RPC_TYPES_H # include #endif /* HAVE_RPC_TYPES_H */ /* Prevent multiple inclusion on Ultrix 4 */ #if defined(HAVE_RPC_XDR_H) && !defined(__XDR_HEADER__) # include #endif /* defined(HAVE_RPC_XDR_H) && !defined(__XDR_HEADER__) */ /* ALWAYS INCLUDE AM-UTILS' SPECIFIC NFS PROTOCOL HEADER NEXT! */ am-utils-6.2+rc20110530/include/mount_headers2.h000066400000000000000000000061101157065440000210430ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/include/mount_headers2.h * */ #ifdef HAVE_RPCSVC_MOUNT_H # include #endif /* HAVE_RPCSVC_MOUNT_H */ #ifdef HAVE_MOUNT_H # include #endif /* HAVE_MOUNT_H */ #ifdef HAVE_NFS_NFS_GFS_H # include #endif /* HAVE_NFS_NFS_GFS_H */ #ifdef HAVE_NFS_MOUNT_H # include #endif /* HAVE_NFS_MOUNT_H */ #ifdef HAVE_SYS_FS_NFS_CLNT_H # include #endif /* HAVE_SYS_FS_NFS_CLNT_H */ #ifdef HAVE_LINUX_NFS_MOUNT_H # ifndef _LINUX_NFS_H # define _LINUX_NFS_H # endif /* not _LINUX_NFS_H */ # ifndef _LINUX_NFS2_H # define _LINUX_NFS2_H # endif /* not _LINUX_NFS2_H */ # ifndef _LINUX_NFS3_H # define _LINUX_NFS3_H # endif /* not _LINUX_NFS3_H */ # ifndef _LINUX_NFS_FS_H # define _LINUX_NFS_FS_H # endif /* not _LINUX_NFS_FS_H */ # ifndef _LINUX_IN_H # define _LINUX_IN_H # endif /* not _LINUX_IN_H */ # ifndef __KERNEL__ # define __KERNEL__ # endif /* __KERNEL__ */ # include # undef __KERNEL__ #endif /* HAVE_LINUX_NFS_MOUNT_H */ am-utils-6.2+rc20110530/install-sh000077500000000000000000000325371157065440000163500ustar00rootroot00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2009-04-28.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then trap '(exit $?); exit' 1 2 13 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names starting with `-'. case $src in -*) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # Protect names starting with `-'. case $dst in -*) dst=./$dst;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; -*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test -z "$d" && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: am-utils-6.2+rc20110530/ldap-id.ms000066400000000000000000000224231157065440000162100ustar00rootroot00000000000000.pl 10.0i .po 0 .ll 8.5i .lt 8.5i .nr LL 8.5i .nr LT 8.5i .ds LF Johansson .ds RF [Page %] .ds CF .ds LH Internet draft .ds RH 30 March 1998 .ds CH Berkeley AMD LDAP Schema .hy 0 .ad l .in 0 INTERNET-DRAFT Leif Johansson Intented Category: Experimental Stockholm University .ce A directory (X.500 and LDAPv3) schema for Berkely automounter .ti 0 1. Status of this Memo .fi .in 3 This memo describes a directory (LDAP or X.500) schema for storing amd (Berkely-style automounter) mount info maps. The schema is currently beeing supported by the (beta version of the) am-utils version 6 package [AMUTILS]. .ti 0 2. Overview and Rationale Directory services such as X.500 [X500] or LDAP [RFC2251] are a natural choice of repository for amd mount map databases. All Object Identifiers in this document are prefixed by amdSchema-id to be assigned later. The relation between this schema and the automount schema elements in [HOWARD] are mostly superficial. The model for the elements in [HOWARD] was the SUN automounter which has quite a different syntax for mount maps. Furthermore the intended usage of this schema differs from that of [HOWARD] in many respects. .ti 0 3. DSA requirements Directory servers implementing this schema SHOULD maintain the modifyTimestamp operational attribute. If not the amdMapCacheTtl attribute SHOULD be set to 0 indicating to clients that caching of map entries SHOULD be turned off. Clients wishing to use the amdMap schema MAY use the modifyTimestamp information to set the ttl for internal caching schemes. A value of 0 for the amdMapCacheTtl must result in clients turning off any local caching. .ti 0 4. Syntax definitions The following attribute syntax is defined in this document: amdlocationlist This syntax represents a amd map value. This is the syntax expressed in BNF using definitions from [RFC2252]: amdlocationlist = amdlocationselection | amdlocationlist whsp "||" whsp amdlocationselection amdlocationselection = amdlocation | amdlocationselection whsp amdlocation amdlocation = amdlocationinfo | "-" amdlocationinfo | "-" amdlocationinfo = seloropt | amdlocationinfo ";" seloropt | ";" seloropt = seletion | optass selection = keystring "==" printablestring keystring "!=" printablestring optass = keystring \":=\" printablestring X.500 servers or LDAPv3 servers (supporting the binary attribute option) may use the following syntax definition: AmdLocationList ::= SEQUENCE OF { SEQUENCE OF { location AmdLocation } } AmdLocation ::= SET OF { CHOICE { location [0] AmdLocationInfo notlocation [1] AmdLocationInfo not [2] NULL } } AmdLocationInfo ::= SET OF { CHOICE { selection [0] AmdSelection option [1] AmdOption } } AmdSelection ::= CHOICE { eq [0] AttributeAndValue ne [1] AttributeAndValue } AmdOption ::= AttributeAndValue AttributeAndValue ::= SEQUENCE { attribute IA5String value IA5String } .ti 0 5. Attribute types The following attribute types are defined in this document: amdMapName amdMapCacheTtl amdMapEntry amdMapEntryKey amdMapEntryValue amdSchema-a OBJECT IDENTIFIER ::= { amdSchema-id 1 } amdMapName ATTRIBUTE ::= { WITH SYNTAX IA5String EQUALITY MATCHING RULE caseIgoreExactMatch --ID { amdSchema-a 1 } DESCRIPTION "This attribute is the symbolic and in the naming context unique name of an amd map. This corresponds in the case of a flat file database to the name of the file or the mount-point of the map." } amdMapCacheTtl ATTRIBUTE ::= { WITH SYNTAX Integer EQUALITY MATCHING RULE integerExactMatch --ID { amdSchema-a 2 } SINGLE VALUED DESCRIPTION "The maximum time-to-live for the entries in this map. After this many milliseconds the map has to be cleared from local caches and reloaded. A value of 0 disables caching." } amdMapEntry ATTRIBUTE ::= { WITH SYNTAX DistinguishedName EQUALITY MATHCING RULE dNCaseIgnoreExactMatch --ID { amdSchema-a 3 } DESCRIPTION "A multivalued attribute listing the distinguished names of the amdMapEntries making up this amdMap object." } amdMapEntryKey ::= { ATTRIBUTE ::= { WITH SYNTAX IA5String EQUALITY MATCHING RULE stringExactMatch --ID { amdSchema-a 4 } SINGLE VALUED DESCRIPTION "The value of this attribute is usually the name of a mountpoint for this amdMapEntry." } amdMapEntryValue ::= { ATTRIBUTE ::= { WITH SYNTAX AmdLocationList --ID { amdSchema-a 5 } DESCRIPTION "This is the actual mount information for the amdMapEntry using the syntax described above." } amdMapEntryKey ::= { ATTRIBUTE ::= { WITH SYNTAX IA5String EQUALITY MATCHING RULE stringExactMatch --ID { amdSchema-a 4 } SINGLE VALUED DESCRIPTION "The value of this attribute is usually the name of a mountpoint for this amdMapEntry." } amdMapEntryValue ::= { ATTRIBUTE ::= { WITH SYNTAX AmdLocationList --ID { amdSchema-a 5 } DESCRIPTION "This is the actual mount information for the amdMapEntry using the syntax described above." } .ti 0 6. Object classes The following object classes are defined in this document: amdMap amdMapEntry defined as follows: amdSchema-oc ::= { amdSchema-id 2 } amdMap OBJECT-CLASS ::= { SUBCLASS OF { top } KIND auxiliary --ID { amdSchema-oc 1 } MAY CONTAIN { amdMapCacheTtl , cn } MUST CONTAIN { amdMapName , amdMapEntry } } amdMapEntry OBJECT-CLASS ::= { SUBCLASS OF { top } KIND structural --ID { amdSchema-oc 2 } MUST CONTAIN { amdMapName , amdEntryKey , amdEntryValue , } MAY CONTAIN { cn } DESCRIPTION "An entry of this object class describes mount information relative to a certain amdMap entry" } .ti 0 7. Examples .ti 0 8. Security Considerations Due to the security problems posed by NFS care should be taken not to advertise exported filesystems. Therefore it is often desirable to limit access to entries carrying amd mount map information to those systems to which the corresponding filesystems have been exported. .ti 0 9. References [AMUTILS] am-utils homepage: http://shekel.cs.columbia.edu/~erez/am-utils.html [RFC2251] M. Wahl, T. Howes, S. Kille, "Lightweight Directory Access Protocol (v3)", RFC 2251, December 1997. [RFC2252] M. Wahl, A. Coulbeck, T. Howes, S. Kille, "Lightweight Directory Access Protocol (v3): Attribute Syntax Definitions", RFC 2252, December 1997. [RFC2253] M. Wahl, S. Kille, T. Howes, "Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names", RFC 2253, December 1997. [HOWARD] Luke Howard, "An Approach for Using LDAP as a Network Information Service", draft-howard-nis-schema-??.txt, Internet draft. [X500] ITU something or other. .in 3 .ti 0 Author's Address .nf Leif Johansson Department of Mathematics Stockholm University S-106 91 Stockholm SWEDEN Email: leifj AT matematik.su.se am-utils-6.2+rc20110530/ldap-id.txt000066400000000000000000000251131157065440000164070ustar00rootroot00000000000000 INTERNET-DRAFT Leif Johansson Intented Category: Experimental Stockholm University A directory (X.500 and LDAPv3) schema for Berkely automounter 1. Status of this Memo This memo describes a directory (LDAP or X.500) schema for storing amd (Berkely- style automounter) mount info maps. The schema is currently beeing supported by the (beta version of the) am-utils version 6 package [AMUTILS]. 2. Overview and Rationale Directory services such as X.500 [X500] or LDAP [RFC2251] are a natural choice of repository for amd mount map databases. All Object Identifiers in this document are prefixed by amdSchema-id to be assigned later. The relation between this schema and the automount schema elements in [HOWARD] are mostly superficial. The model for the elements in [HOWARD] was the SUN automounter which has quite a different syntax for mount maps. Furthermore the intended usage of this schema differs from that of [HOWARD] in many respects. 3. DSA requirements Directory servers implementing this schema SHOULD maintain the modifyTimestamp operational attribute. If not the amdMapCacheTtl attribute SHOULD be set to 0 indicating to clients that caching of map entries SHOULD be turned off. Clients wishing to use the amdMap schema MAY use the modifyTimestamp information to set the ttl for internal caching schemes. A value of 0 for the amdMapCacheTtl must result in clients turning off any local caching. 4. Syntax definitions The following attribute syntax is defined in this document: amdlocationlist This syntax represents a amd map value. This is the syntax expressed in BNF using definitions from [RFC2252]: amdlocationlist = amdlocationselection | amdlocationlist whsp "||" whsp amdlocationselection amdlocationselection = amdlocation | amdlocationselection whsp amdlocation Johansson [Page 1] Internet draft Berkeley AMD LDAP Schema 30 March 1998 amdlocation = amdlocationinfo | "-" amdlocationinfo | "-" amdlocationinfo = seloropt | amdlocationinfo ";" seloropt | ";" seloropt = seletion | optass selection = keystring "==" printablestring keystring "!=" printablestring optass = keystring X.500 servers or LDAPv3 servers (supporting the binary attribute option) may use the following syntax definition: AmdLocationList ::= SEQUENCE OF { SEQUENCE OF { location AmdLocation } } AmdLocation ::= SET OF { CHOICE { location [0] AmdLocationInfo notlocation [1] AmdLocationInfo not [2] NULL } } AmdLocationInfo ::= SET OF { CHOICE { selection [0] AmdSelection option [1] AmdOption } } AmdSelection ::= CHOICE { eq [0] AttributeAndValue ne [1] AttributeAndValue } AmdOption ::= AttributeAndValue AttributeAndValue ::= SEQUENCE { attribute IA5String Johansson [Page 2] Internet draft Berkeley AMD LDAP Schema 30 March 1998 value IA5String } 5. Attribute types The following attribute types are defined in this document: amdMapName amdMapCacheTtl amdMapEntry amdMapEntryKey amdMapEntryValue amdSchema-a OBJECT IDENTIFIER ::= { amdSchema-id 1 } amdMapName ATTRIBUTE ::= { WITH SYNTAX IA5String EQUALITY MATCHING RULE caseIgoreExactMatch --ID { amdSchema-a 1 } DESCRIPTION "This attribute is the symbolic and in the naming context unique name of an amd map. This corresponds in the case of a flat file database to the name of the file or the mount-point of the map." } amdMapCacheTtl ATTRIBUTE ::= { WITH SYNTAX Integer EQUALITY MATCHING RULE integerExactMatch --ID { amdSchema-a 2 } SINGLE VALUED DESCRIPTION "The maximum time-to-live for the entries in this map. After this many milliseconds the map has to be cleared from local caches and reloaded. A value of 0 disables caching." } amdMapEntry ATTRIBUTE ::= { WITH SYNTAX DistinguishedName EQUALITY MATHCING RULE dNCaseIgnoreExactMatch --ID { amdSchema-a 3 } DESCRIPTION "A multivalued attribute listing the distinguished names of the amdMapEntries making up this amdMap Johansson [Page 3] Internet draft Berkeley AMD LDAP Schema 30 March 1998 object." } amdMapEntryKey ::= { ATTRIBUTE ::= { WITH SYNTAX IA5String EQUALITY MATCHING RULE stringExactMatch --ID { amdSchema-a 4 } SINGLE VALUED DESCRIPTION "The value of this attribute is usually the name of a mountpoint for this amdMapEntry." } amdMapEntryValue ::= { ATTRIBUTE ::= { WITH SYNTAX AmdLocationList --ID { amdSchema-a 5 } DESCRIPTION "This is the actual mount information for the amdMapEntry using the syntax described above." } amdMapEntryKey ::= { ATTRIBUTE ::= { WITH SYNTAX IA5String EQUALITY MATCHING RULE stringExactMatch --ID { amdSchema-a 4 } SINGLE VALUED DESCRIPTION "The value of this attribute is usually the name of a mountpoint for this amdMapEntry." } amdMapEntryValue ::= { ATTRIBUTE ::= { WITH SYNTAX AmdLocationList --ID { amdSchema-a 5 } DESCRIPTION "This is the actual mount information for the amdMapEntry using the syntax described above." } 6. Object classes The following object classes are defined in this document: amdMap Johansson [Page 4] Internet draft Berkeley AMD LDAP Schema 30 March 1998 amdMapEntry defined as follows: amdSchema-oc ::= { amdSchema-id 2 } amdMap OBJECT-CLASS ::= { SUBCLASS OF { top } KIND auxiliary --ID { amdSchema-oc 1 } MAY CONTAIN { amdMapCacheTtl , cn } MUST CONTAIN { amdMapName , amdMapEntry } } amdMapEntry OBJECT-CLASS ::= { SUBCLASS OF { top } KIND structural --ID { amdSchema-oc 2 } MUST CONTAIN { amdMapName , amdEntryKey , amdEntryValue , } MAY CONTAIN { cn } DESCRIPTION "An entry of this object class describes mount information relative to a certain amdMap entry" } 7. Examples 8. Security Considerations Due to the security problems posed by NFS care should be taken not to advertise exported filesystems. Therefore it is often desirable to limit access to entries carrying amd mount map information to those systems to which the corresponding filesystems have been exported. 9. References [AMUTILS] am-utils homepage: http://shekel.cs.columbia.edu/~erez/am-utils.html [RFC2251] M. Wahl, T. Howes, S. Kille, "Lightweight Directory Access Protocol (v3)", RFC 2251, December 1997. Johansson [Page 5] Internet draft Berkeley AMD LDAP Schema 30 March 1998 [RFC2252] M. Wahl, A. Coulbeck, T. Howes, S. Kille, "Lightweight Directory Access Protocol (v3): Attribute Syntax Definitions", RFC 2252, December 1997. [RFC2253] M. Wahl, S. Kille, T. Howes, "Lightweight Directory Access Protocol (v3): UTF-8 String Representation of Distinguished Names", RFC 2253, December 1997. [HOWARD] Luke Howard, "An Approach for Using LDAP as a Network Information Service", draft-howard-nis-schema-??.txt, Internet draft. [X500] ITU something or other. Author's Address Leif Johansson Department of Mathematics Stockholm University S-106 91 Stockholm SWEDEN Email: leifj AT matematik.su.se Johansson [Page 6] am-utils-6.2+rc20110530/ldap.schema000066400000000000000000000027471157065440000164460ustar00rootroot00000000000000# A schema for the Berkeley automounter (AMD) # Authored by Erez Zadok and/or source maintainers # Definition by Tim Colles # Revised by Adam Morley # OID Base is 1.3.6.1.4.1.10180 # # Syntaxes are under 1.3.6.1.4.1.10180.3.175-199 # Attribute types are under 1.3.6.1.4.1.10180.2.175-199 # Object classes are under 1.3.6.1.4.1.10180.1.175-199 # Attribute Type Definitions attributetype ( 1.3.6.1.4.1.10180.2.175 NAME 'amdmapTimestamp' DESC 'Probably the time the map was last modified' EQUALITY integerMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.10180.2.176 NAME 'amdmapName' DESC 'The symbolic name of the map, ie. map_name' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.10180.2.177 NAME 'amdmapKey' DESC 'The key value for this entry' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) attributetype ( 1.3.6.1.4.1.10180.2.178 NAME 'amdmapValue' DESC 'The mount information for this entry' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE ) # Object Class Definitions objectclass ( 1.3.6.1.4.1.10180.1.175 NAME 'amdmapTimestamp' SUP top STRUCTURAL DESC 'Timestamp for an AMD map' MUST ( cn $ amdmapName $ amdmapTimestamp ) ) objectclass ( 1.3.6.1.4.1.10180.1.176 NAME 'amdmap' SUP top STRUCTURAL DESC 'Defines an AMD map entry' MUST ( cn $ amdmapName $ amdmapKey $ amdmapValue ) ) am-utils-6.2+rc20110530/libamu/000077500000000000000000000000001157065440000156035ustar00rootroot00000000000000am-utils-6.2+rc20110530/libamu/.cvsignore000066400000000000000000000000141157065440000175760ustar00rootroot00000000000000Makefile.in am-utils-6.2+rc20110530/libamu/Makefile.am000066400000000000000000000041371157065440000176440ustar00rootroot00000000000000## 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 \ strdup.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 # strdup.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@ INCLUDES = -I$(top_srcdir)/include # allow users to add their own flags via "configure --enable-am-flags=ARG" AMU_CFLAGS = @AMU_CFLAGS@ AM_CFLAGS = @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) am-utils-6.2+rc20110530/libamu/amu.h000066400000000000000000000063571157065440000165510ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/amu.h * */ #ifndef _AMU_H #define _AMU_H /* * Decide what maximum level of NFS server to try and mount with. */ #ifdef 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 */ /* some systems like ncr2 do not define this in */ #ifndef MNTPATHLEN # define MNTPATHLEN 1024 #endif /* not MNTPATHLEN */ #ifndef MNTNAMLEN # define MNTNAMLEN 255 #endif /* not MNTNAMLEN */ /* * external definitions for building libamu.a */ extern voidp amqproc_null_1(voidp argp, CLIENT *rqstp); extern amq_mount_tree_p *amqproc_mnttree_1(amq_string *argp, CLIENT *rqstp); extern voidp amqproc_umnt_1(amq_string *argp, CLIENT *rqstp); extern amq_mount_stats *amqproc_stats_1(voidp argp, CLIENT *rqstp); extern amq_mount_tree_list *amqproc_export_1(voidp argp, CLIENT *rqstp); extern int *amqproc_setopt_1(amq_setopt *argp, CLIENT *rqstp); extern amq_mount_info_list *amqproc_getmntfs_1(voidp argp, CLIENT *rqstp); extern int *amqproc_mount_1(voidp argp, CLIENT *rqstp); extern amq_string *amqproc_getvers_1(voidp argp, CLIENT *rqstp); extern long get_server_pid(void); #endif /* not _AMU_H */ am-utils-6.2+rc20110530/libamu/clnt_sperrno.c000066400000000000000000000116601157065440000204630ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/clnt_sperrno.c * */ /* * Early RPC seems to be missing these.. * Extracted from the RPC 3.9 sources as indicated */ /* @(#)clnt_perror.c 1.1 87/11/04 3.9 RPCSRC */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * 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 * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include struct rpc_errtab { enum clnt_stat status; char *message; }; static struct rpc_errtab rpc_errlist[] = { {RPC_SUCCESS, "RPC: Success"}, {RPC_CANTENCODEARGS, "RPC: Can't encode arguments"}, {RPC_CANTDECODERES, "RPC: Can't decode result"}, {RPC_CANTSEND, "RPC: Unable to send"}, {RPC_CANTRECV, "RPC: Unable to receive"}, {RPC_TIMEDOUT, "RPC: Timed out"}, {RPC_VERSMISMATCH, "RPC: Incompatible versions of RPC"}, {RPC_AUTHERROR, "RPC: Authentication error"}, {RPC_PROGUNAVAIL, "RPC: Program unavailable"}, {RPC_PROGVERSMISMATCH, "RPC: Program/version mismatch"}, {RPC_PROCUNAVAIL, "RPC: Procedure unavailable"}, {RPC_CANTDECODEARGS, "RPC: Server can't decode arguments"}, {RPC_SYSTEMERROR, "RPC: Remote system error"}, {RPC_UNKNOWNHOST, "RPC: Unknown host"}, /* { RPC_UNKNOWNPROTO, * "RPC: Unknown protocol" }, */ {RPC_PMAPFAILURE, "RPC: Port mapper failure"}, {RPC_PROGNOTREGISTERED, "RPC: Program not registered"}, {RPC_FAILED, "RPC: Failed (unspecified error)"} }; /* * This interface for use by clntrpc */ char * clnt_sperrno(enum clnt_stat stat) { int i; for (i = 0; i < sizeof(rpc_errlist) / sizeof(struct rpc_errtab); i++) { if (rpc_errlist[i].status == stat) { return (rpc_errlist[i].message); } } return ("RPC: (unknown error code)"); } am-utils-6.2+rc20110530/libamu/hasmntopt.c000066400000000000000000000063131157065440000177670ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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 n * 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. 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 * 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/hasmntopt.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #ifndef MNTMAXSTR # define MNTMAXSTR 256 #endif /* not MNTMAXSTR */ /* * Some systems don't provide these to the user, * but amd needs them, so... * * From: Piete Brooks */ static char * nextmntopt(char **p) { char *cp = *p; char *rp; /* * Skip past white space */ while (*cp && isspace((unsigned char) *cp)) cp++; /* * Word starts here */ rp = cp; /* * Scan to send of string or separator */ while (*cp && *cp != ',') cp++; /* * If separator found the overwrite with null char. */ if (*cp) { *cp = '\0'; cp++; } /* * Return value for next call */ *p = cp; return rp; } /* * replacement for hasmntopt if the system does not have it. */ char * amu_hasmntopt(mntent_t *mnt, char *opt) { char t[MNTMAXSTR]; char *f; char *o = t; size_t l = strlen(opt); xstrlcpy(t, mnt->mnt_opts, sizeof(t)); while (*(f = nextmntopt(&o))) if (NSTREQ(opt, f, l)) return f - t + mnt->mnt_opts; return 0; } am-utils-6.2+rc20110530/libamu/memcmp.c000066400000000000000000000054371157065440000172360ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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 #endif /* HAVE_CONFIG_H */ #include #include /* * 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; } am-utils-6.2+rc20110530/libamu/misc_rpc.c000066400000000000000000000131271157065440000175520ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/misc_rpc.c * */ /* * Additions to Sun RPC. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Some systems renamed _seterr_reply to __seterr_reply (with two * leading underscores) */ #if !defined(HAVE__SETERR_REPLY) && defined(HAVE___SETERR_REPLY) # define _seterr_reply __seterr_reply #endif /* !defined(HAVE__SETERR_REPLY) && defined(HAVE___SETERR_REPLY) */ void rpc_msg_init(struct rpc_msg *mp, u_long prog, u_long vers, u_long proc) { /* * Initialize the message */ memset((voidp) mp, 0, sizeof(*mp)); mp->rm_xid = 0; mp->rm_direction = CALL; mp->rm_call.cb_rpcvers = RPC_MSG_VERSION; mp->rm_call.cb_prog = prog; mp->rm_call.cb_vers = vers; mp->rm_call.cb_proc = proc; } /* * Field reply to call to mountd */ int pickup_rpc_reply(voidp pkt, int len, voidp where, XDRPROC_T_TYPE where_xdr) { XDR reply_xdr; int ok; struct rpc_err err; struct rpc_msg reply_msg; int error = 0; /* memset((voidp) &err, 0, sizeof(err)); */ memset((voidp) &reply_msg, 0, sizeof(reply_msg)); memset((voidp) &reply_xdr, 0, sizeof(reply_xdr)); reply_msg.acpted_rply.ar_results.where = where; reply_msg.acpted_rply.ar_results.proc = where_xdr; xdrmem_create(&reply_xdr, pkt, len, XDR_DECODE); ok = xdr_replymsg(&reply_xdr, &reply_msg); if (!ok) { error = EIO; goto drop; } _seterr_reply(&reply_msg, &err); if (err.re_status != RPC_SUCCESS) { error = EIO; goto drop; } drop: if (reply_msg.rm_reply.rp_stat == MSG_ACCEPTED && reply_msg.acpted_rply.ar_verf.oa_base) { reply_xdr.x_op = XDR_FREE; (void) xdr_opaque_auth(&reply_xdr, &reply_msg.acpted_rply.ar_verf); } xdr_destroy(&reply_xdr); return error; } int make_rpc_packet(char *buf, int buflen, u_long proc, struct rpc_msg *mp, voidp arg, XDRPROC_T_TYPE arg_xdr, AUTH *auth) { XDR msg_xdr; int len; /* * Never cast pointers between different integer types, it breaks badly * on big-endian platforms if those types have different sizes. * * Cast to a local variable instead, and use that variable's address. */ enum_t local_proc = (enum_t) proc; xdrmem_create(&msg_xdr, buf, buflen, XDR_ENCODE); /* * Basic protocol header */ if (!xdr_callhdr(&msg_xdr, mp)) return -EIO; /* * Called procedure number */ if (!xdr_enum(&msg_xdr, &local_proc)) return -EIO; /* * Authorization */ if (!AUTH_MARSHALL(auth, &msg_xdr)) return -EIO; /* * Arguments */ if (!(*arg_xdr) (&msg_xdr, arg)) return -EIO; /* * Determine length */ len = xdr_getpos(&msg_xdr); /* * Throw away xdr */ xdr_destroy(&msg_xdr); return len; } /* get uid/gid from RPC credentials */ int getcreds(struct svc_req *rp, uid_t *u, gid_t *g, SVCXPRT *nfsxprt) { struct authunix_parms *aup = (struct authunix_parms *) NULL; #ifdef HAVE_RPC_AUTH_DES_H struct authdes_cred *adp; #endif /* HAVE_RPC_AUTH_DES_H */ switch (rp->rq_cred.oa_flavor) { case AUTH_UNIX: aup = (struct authunix_parms *) rp->rq_clntcred; *u = aup->aup_uid; *g = aup->aup_gid; break; #ifdef HAVE_RPC_AUTH_DES_H case AUTH_DES: adp = (struct authdes_cred *) rp->rq_clntcred; *g = INVALIDID; /* some unknown group id */ if (sscanf(adp->adc_fullname.name, "unix.%lu@", (u_long *) u) == 1) break; /* fall through */ #endif /* HAVE_RPC_AUTH_DES_H */ default: *u = *g = INVALIDID; /* just in case */ svcerr_weakauth(nfsxprt); return -1; } return 0; /* everything is ok */ } am-utils-6.2+rc20110530/libamu/mount_fs.c000066400000000000000000001047151157065440000176110ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/mount_fs.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* ensure that mount table options are delimited by a comma */ #define append_opts(old, l, new) { \ if (*(old) != '\0') \ xstrlcat(old, ",", l); \ xstrlcat(old, new, l); } /* * Standard mount flags */ struct opt_tab mnt_flags[] = { #if defined(MNT2_GEN_OPT_RDONLY) && defined(MNTTAB_OPT_RO) {MNTTAB_OPT_RO, MNT2_GEN_OPT_RDONLY}, #endif /* defined(MNT2_GEN_OPT_RDONLY) && defined(MNTTAB_OPT_RO) */ #if defined(MNT2_GEN_OPT_NOCACHE) && defined(MNTTAB_OPT_NOCACHE) {MNTTAB_OPT_NOCACHE, MNT2_GEN_OPT_NOCACHE}, #endif /* defined(MNT2_GEN_OPT_NOCACHE) && defined(MNTTAB_OPT_NOCACHE) */ /* the "grpid" mount option can be offered as generic of NFS */ #ifdef MNTTAB_OPT_GRPID # ifdef MNT2_GEN_OPT_GRPID {MNTTAB_OPT_GRPID, MNT2_GEN_OPT_GRPID}, # endif /* MNT2_GEN_OPT_GRPID */ # ifdef MNT2_NFS_OPT_GRPID {MNTTAB_OPT_GRPID, MNT2_NFS_OPT_GRPID}, # endif /* MNT2_NFS_OPT_GRPID */ #endif /* MNTTAB_OPT_GRPID */ #if defined(MNT2_GEN_OPT_MULTI) && defined(MNTTAB_OPT_MULTI) {MNTTAB_OPT_MULTI, MNT2_GEN_OPT_MULTI}, #endif /* defined(MNT2_GEN_OPT_MULTI) && defined(MNTTAB_OPT_MULTI) */ #if defined(MNT2_GEN_OPT_NODEV) && defined(MNTTAB_OPT_NODEV) {MNTTAB_OPT_NODEV, MNT2_GEN_OPT_NODEV}, #endif /* defined(MNT2_GEN_OPT_NODEV) && defined(MNTTAB_OPT_NODEV) */ #if defined(MNT2_GEN_OPT_NOEXEC) && defined(MNTTAB_OPT_NOEXEC) {MNTTAB_OPT_NOEXEC, MNT2_GEN_OPT_NOEXEC}, #endif /* defined(MNT2_GEN_OPT_NOEXEC) && defined(MNTTAB_OPT_NOEXEC) */ #if defined(MNT2_GEN_OPT_NOSUB) && defined(MNTTAB_OPT_NOSUB) {MNTTAB_OPT_NOSUB, MNT2_GEN_OPT_NOSUB}, #endif /* defined(MNT2_GEN_OPT_NOSUB) && defined(MNTTAB_OPT_NOSUB) */ #if defined(MNT2_GEN_OPT_NOSUID) && defined(MNTTAB_OPT_NOSUID) {MNTTAB_OPT_NOSUID, MNT2_GEN_OPT_NOSUID}, #endif /* defined(MNT2_GEN_OPT_NOSUID) && defined(MNTTAB_OPT_NOSUID) */ #if defined(MNT2_GEN_OPT_SYNC) && defined(MNTTAB_OPT_SYNC) {MNTTAB_OPT_SYNC, MNT2_GEN_OPT_SYNC}, #endif /* defined(MNT2_GEN_OPT_SYNC) && defined(MNTTAB_OPT_SYNC) */ #if defined(MNT2_GEN_OPT_OVERLAY) && defined(MNTTAB_OPT_OVERLAY) {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 * something here, it's probably not the right place: see * include/am_compat.h. */ {0, 0} }; /* compute generic mount flags */ int compute_mount_flags(mntent_t *mntp) { struct opt_tab *opt; int flags = 0; #ifdef MNT2_GEN_OPT_NEWTYPE flags |= MNT2_GEN_OPT_NEWTYPE; #endif /* MNT2_GEN_OPT_NEWTYPE */ #ifdef MNT2_GEN_OPT_AUTOMOUNTED flags |= MNT2_GEN_OPT_AUTOMOUNTED; #endif /* not MNT2_GEN_OPT_AUTOMOUNTED */ /* * Crack basic mount options */ for (opt = mnt_flags; opt->opt; opt++) { flags |= amu_hasmntopt(mntp, opt->opt) ? opt->flag : 0; } return flags; } /* compute generic mount flags for automounter mounts */ int compute_automounter_mount_flags(mntent_t *mntp) { int flags = 0; #ifdef MNT2_GEN_OPT_IGNORE flags |= MNT2_GEN_OPT_IGNORE; #endif /* not MNT2_GEN_OPT_IGNORE */ #ifdef MNT2_GEN_OPT_AUTOMNTFS flags |= MNT2_GEN_OPT_AUTOMNTFS; #endif /* not MNT2_GEN_OPT_AUTOMNTFS */ return flags; } 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) { int error = 0; #ifdef MOUNT_TABLE_ON_FILE char *zopts = NULL, *xopts = NULL; size_t l; #endif /* MOUNT_TABLE_ON_FILE */ char *mnt_dir = NULL; #ifdef NEED_AUTOFS_SPACE_HACK 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); dlog("'%s' fstype " MTYPE_PRINTF_TYPE " (%s) flags %#x (%s)", mnt_dir, type, mnt->mnt_type, flags, mnt->mnt_opts); again: error = MOUNT_TRAP(type, mnt, flags, mnt_data); if (error < 0) { plog(XLOG_ERROR, "'%s': mount: %m", mnt_dir); /* * The following code handles conditions which shouldn't * occur. They are possible either because amd screws up * in preparing for the mount, or because some human * messed with the mount point. Both have been known to * happen. -- stolcke 2/22/95 */ if (errno == EBUSY) { /* * Also, sometimes unmount isn't called, e.g., because * our mountlist is garbled. This leaves old mount * points around which need to be removed before we * can mount something new in their place. */ errno = umount_fs(mnt_dir, mnttabname, on_autofs); if (errno != 0) plog(XLOG_ERROR, "'%s': umount: %m", mnt_dir); else { plog(XLOG_WARNING, "extra umount required for '%s'", mnt_dir); error = MOUNT_TRAP(type, mnt, flags, mnt_data); } } } if (error < 0 && --retry > 0) { sleep(1); goto again; } #ifdef NEED_AUTOFS_SPACE_HACK /* Undo space hack */ if (on_autofs) mnt->mnt_dir = old_mnt_dir; #endif /* NEED_AUTOFS_SPACE_HACK */ if (error < 0) { error = errno; goto out; } #ifdef MOUNT_TABLE_ON_FILE /* * Allocate memory for options: * dev=..., vers={2,3}, proto={tcp,udp} */ l = strlen(mnt->mnt_opts) + 48; zopts = (char *) xmalloc(l); /* copy standard options */ xopts = mnt->mnt_opts; xstrlcpy(zopts, xopts, l); # ifdef MNTTAB_OPT_DEV { /* add the extra dev= field to the mount table */ struct stat stb; if (lstat(mnt_dir, &stb) == 0) { char optsbuf[48]; if (sizeof(stb.st_dev) == 2) /* e.g. SunOS 4.1 */ xsnprintf(optsbuf, sizeof(optsbuf), "%s=%04lx", MNTTAB_OPT_DEV, (u_long) stb.st_dev & 0xffff); else /* e.g. System Vr4 */ xsnprintf(optsbuf, sizeof(optsbuf), "%s=%08lx", MNTTAB_OPT_DEV, (u_long) stb.st_dev); append_opts(zopts, l, optsbuf); } } # endif /* MNTTAB_OPT_DEV */ # 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); } # endif /* defined(HAVE_FS_NFS3) && defined(MNTTAB_OPT_VERS) */ # ifdef MNTTAB_OPT_PROTO /* * add the extra proto={tcp,udp} field to the mount table, * unless already specified by user. */ if (nfs_proto && !amu_hasmntopt(mnt, MNTTAB_OPT_PROTO)) { char optsbuf[48]; xsnprintf(optsbuf, sizeof(optsbuf), "%s=%s", MNTTAB_OPT_PROTO, nfs_proto); append_opts(zopts, l, optsbuf); } # endif /* MNTTAB_OPT_PROTO */ /* finally, store the options into the mount table structure */ mnt->mnt_opts = zopts; /* * Additional fields in mntent_t * are fixed up here */ # ifdef HAVE_MNTENT_T_MNT_CNODE mnt->mnt_cnode = 0; # endif /* HAVE_MNTENT_T_MNT_CNODE */ # ifdef HAVE_MNTENT_T_MNT_RO mnt->mnt_ro = (amu_hasmntopt(mnt, MNTTAB_OPT_RO) != NULL); # endif /* HAVE_MNTENT_T_MNT_RO */ # ifdef HAVE_MNTENT_T_MNT_TIME # ifdef HAVE_MNTENT_T_MNT_TIME_STRING { /* allocate enough space for a long */ size_t l = 13 * sizeof(char); char *str = (char *) xmalloc(l); xsnprintf(str, l, "%ld", time((time_t *) NULL)); mnt->mnt_time = str; } # else /* not HAVE_MNTENT_T_MNT_TIME_STRING */ mnt->mnt_time = time((time_t *) NULL); # endif /* not HAVE_MNTENT_T_MNT_TIME_STRING */ # endif /* HAVE_MNTENT_T_MNT_TIME */ write_mntent(mnt, mnttabname); # ifdef MNTTAB_OPT_DEV if (xopts) { XFREE(mnt->mnt_opts); mnt->mnt_opts = xopts; } # endif /* MNTTAB_OPT_DEV */ #endif /* MOUNT_TABLE_ON_FILE */ out: XFREE(mnt_dir); return error; } /* * Compute all NFS attribute cache related flags separately. Note that this * function now computes attribute-cache flags for both Amd's automount * points (NFS) as well as any normal NFS mount that Amd performs. Edit * with caution. */ static void compute_nfs_attrcache_flags(nfs_args_t *nap, mntent_t *mntp) { int acval = 0; int err_acval = 1; /* 1 means we found no 'actimeo' value */ #if defined(HAVE_NFS_ARGS_T_ACREGMIN) || defined(HAVE_NFS_ARGS_T_ACREGMAX) || defined(HAVE_NFS_ARGS_T_ACDIRMIN) || defined(HAVE_NFS_ARGS_T_ACDIRMAX) int err_acrdmm; /* for ac{reg,dir}{min,max} */ #endif /* HAVE_NFS_ARGS_T_AC{REG,DIR}{MIN,MAX} */ /************************************************************************/ /*** ATTRIBUTE CACHES ***/ /************************************************************************/ /* * acval is set to 0 at the top of the function. If actimeo mount option * exists and defined in mntopts, then its acval is set to it. * If the value is non-zero, then we set all attribute cache fields to it. * If acval is zero, it means it was never defined in mntopts or the * actimeo mount option does not exist, in which case we check for * individual mount options per attribute cache. * Regardless of the value of acval, mount flags are set based directly * on the values of the attribute caches. */ #ifdef MNTTAB_OPT_ACTIMEO err_acval = hasmntvalerr(mntp, MNTTAB_OPT_ACTIMEO, &acval); /* attr cache timeout (sec) */ #endif /* MNTTAB_OPT_ACTIMEO */ /*** acregmin ***/ #ifdef HAVE_NFS_ARGS_T_ACREGMIN err_acrdmm = 1; /* 1 means we found no acregmin value */ if (!err_acval) { 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); # else /* not MNTTAB_OPT_ACREGMIN */ nap->acregmin = 0; # endif /* not MNTTAB_OPT_ACREGMIN */ } /* set this flag iff we changed acregmin (possibly to zero) */ # ifdef MNT2_NFS_OPT_ACREGMIN if (!err_acval || !err_acrdmm) nap->flags |= MNT2_NFS_OPT_ACREGMIN; # endif /* MNT2_NFS_OPT_ACREGMIN */ #endif /* HAVE_NFS_ARGS_T_ACREGMIN */ /*** acregmax ***/ #ifdef HAVE_NFS_ARGS_T_ACREGMAX err_acrdmm = 1; /* 1 means we found no acregmax value */ if (!err_acval) { 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); # else /* not MNTTAB_OPT_ACREGMAX */ nap->acregmax = 0; # endif /* not MNTTAB_OPT_ACREGMAX */ } /* set this flag iff we changed acregmax (possibly to zero) */ # ifdef MNT2_NFS_OPT_ACREGMAX if (!err_acval || !err_acrdmm) nap->flags |= MNT2_NFS_OPT_ACREGMAX; # endif /* MNT2_NFS_OPT_ACREGMAX */ #endif /* HAVE_NFS_ARGS_T_ACREGMAX */ /*** acdirmin ***/ #ifdef HAVE_NFS_ARGS_T_ACDIRMIN err_acrdmm = 1; /* 1 means we found no acdirmin value */ if (!err_acval) { nap->acdirmin = acval; /* min ac timeout for dirs (sec) */ } else { # ifdef MNTTAB_OPT_ACDIRMIN err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACDIRMIN, (int *) &nap->acdirmin); # else /* not MNTTAB_OPT_ACDIRMIN */ nap->acdirmin = 0; # endif /* not MNTTAB_OPT_ACDIRMIN */ } /* set this flag iff we changed acdirmin (possibly to zero) */ # ifdef MNT2_NFS_OPT_ACDIRMIN if (!err_acval || !err_acrdmm) nap->flags |= MNT2_NFS_OPT_ACDIRMIN; # endif /* MNT2_NFS_OPT_ACDIRMIN */ #endif /* HAVE_NFS_ARGS_T_ACDIRMIN */ /*** acdirmax ***/ #ifdef HAVE_NFS_ARGS_T_ACDIRMAX err_acrdmm = 1; /* 1 means we found no acdirmax value */ if (!err_acval) { nap->acdirmax = acval; /* max ac timeout for dirs (sec) */ } else { # ifdef MNTTAB_OPT_ACDIRMAX err_acrdmm = hasmntvalerr(mntp, MNTTAB_OPT_ACDIRMAX, (int *) &nap->acdirmax); # else /* not MNTTAB_OPT_ACDIRMAX */ nap->acdirmax = 0; # endif /* not MNTTAB_OPT_ACDIRMAX */ } /* set this flag iff we changed acdirmax (possibly to zero) */ # ifdef MNT2_NFS_OPT_ACDIRMAX if (!err_acval || !err_acrdmm) nap->flags |= MNT2_NFS_OPT_ACDIRMAX; # endif /* MNT2_NFS_OPT_ACDIRMAX */ #endif /* HAVE_NFS_ARGS_T_ACDIRMAX */ /* don't cache attributes */ #if defined(MNTTAB_OPT_NOAC) && defined(MNT2_NFS_OPT_NOAC) if (amu_hasmntopt(mntp, MNTTAB_OPT_NOAC) != NULL) nap->flags |= MNT2_NFS_OPT_NOAC; #endif /* defined(MNTTAB_OPT_NOAC) && defined(MNT2_NFS_OPT_NOAC) */ } /* * 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 ***/ /************************************************************************/ #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) nap->flags |= MNT2_NFS_OPT_NOCONN; else if (amu_hasmntopt(mntp, MNTTAB_OPT_CONN) != NULL) nap->flags &= ~MNT2_NFS_OPT_NOCONN; else { /* * Some OSs want you to set noconn always. Some want you to always turn * it off. Others want you to turn it on/off only if NFS V.3 is used. * And all of that changes from revision to another. This is * particularly true of OpenBSD, NetBSD, and FreeBSD. So, rather than * attempt to auto-detect this, I'm forced to "fix" it in the individual * conf/nfs_prot/nfs_prot_*.h files. */ # ifdef USE_UNCONNECTED_NFS_SOCKETS if (!(nap->flags & MNT2_NFS_OPT_NOCONN)) { nap->flags |= MNT2_NFS_OPT_NOCONN; plog(XLOG_WARNING, "noconn option not specified, and was just turned ON (OS override)! (May cause NFS hangs on some systems...)"); } # endif /* USE_UNCONNECTED_NFS_SOCKETS */ # ifdef USE_CONNECTED_NFS_SOCKETS if (nap->flags & MNT2_NFS_OPT_NOCONN) { nap->flags &= ~MNT2_NFS_OPT_NOCONN; plog(XLOG_WARNING, "noconn option specified, and was just turned OFF (OS override)! (May cause NFS hangs on some systems...)"); } # endif /* USE_CONNECTED_NFS_SOCKETS */ } #endif /* MNT2_NFS_OPT_NOCONN */ #ifdef MNT2_NFS_OPT_RESVPORT # ifdef MNTTAB_OPT_RESVPORT if (amu_hasmntopt(mntp, MNTTAB_OPT_RESVPORT) != NULL) nap->flags |= MNT2_NFS_OPT_RESVPORT; # else /* not MNTTAB_OPT_RESVPORT */ nap->flags |= MNT2_NFS_OPT_RESVPORT; # 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) nap->flags |= MNT2_NFS_OPT_RSIZE; #endif /* MNT2_NFS_OPT_RSIZE */ if (nfs_version == NFS_VERSION && nap->rsize > 8192) nap->rsize = 8192; nap->wsize = hasmntval(mntp, MNTTAB_OPT_WSIZE); #ifdef MNT2_NFS_OPT_WSIZE if (nap->wsize) nap->flags |= MNT2_NFS_OPT_WSIZE; #endif /* MNT2_NFS_OPT_WSIZE */ if (nfs_version == NFS_VERSION && nap->wsize > 8192) nap->wsize = 8192; nap->timeo = hasmntval(mntp, MNTTAB_OPT_TIMEO); #ifdef MNT2_NFS_OPT_TIMEO if (nap->timeo) nap->flags |= MNT2_NFS_OPT_TIMEO; #endif /* MNT2_NFS_OPT_TIMEO */ nap->retrans = hasmntval(mntp, MNTTAB_OPT_RETRANS); #ifdef MNT2_NFS_OPT_RETRANS if (nap->retrans) 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; #endif /* MNT2_NFS_OPT_SOFT */ #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) { plog(XLOG_USER, "Mount opts soft and spongy are incompatible - soft ignored"); nap->flags &= ~MNT2_NFS_OPT_SOFT; } } #endif /* MNT2_NFS_OPT_SPONGY */ #if defined(MNT2_GEN_OPT_RONLY) && defined(MNT2_NFS_OPT_RONLY) /* Ultrix has separate generic and NFS ro flags */ if (genflags & MNT2_GEN_OPT_RONLY) nap->flags |= MNT2_NFS_OPT_RONLY; #endif /* defined(MNT2_GEN_OPT_RONLY) && defined(MNT2_NFS_OPT_RONLY) */ #ifdef MNTTAB_OPT_INTR if (amu_hasmntopt(mntp, MNTTAB_OPT_INTR) != NULL) /* * Either turn on the "allow interrupts" option, or * turn off the "disallow interrupts" option" */ # ifdef MNT2_NFS_OPT_INTR nap->flags |= MNT2_NFS_OPT_INTR; # endif /* MNT2_NFS_OPT_INTR */ # ifdef MNT2_NFS_OPT_NOINTR nap->flags &= ~MNT2_NFS_OPT_NOINTR; # endif /* MNT2_NFS_OPT_NOINTR */ # ifdef MNT2_NFS_OPT_INT nap->flags |= MNT2_NFS_OPT_INT; # endif /* MNT2_NFS_OPT_INT */ # ifdef MNT2_NFS_OPT_NOINT nap->flags &= ~MNT2_NFS_OPT_NOINT; # endif /* MNT2_NFS_OPT_NOINT */ #endif /* MNTTAB_OPT_INTR */ #ifdef MNTTAB_OPT_NODEVS if (amu_hasmntopt(mntp, MNTTAB_OPT_NODEVS) != NULL) nap->flags |= MNT2_NFS_OPT_NODEVS; #endif /* MNTTAB_OPT_NODEVS */ #ifdef MNTTAB_OPT_COMPRESS if (amu_hasmntopt(mntp, MNTTAB_OPT_COMPRESS) != NULL) nap->flags |= MNT2_NFS_OPT_COMPRESS; #endif /* MNTTAB_OPT_COMPRESS */ #ifdef MNTTAB_OPT_PRIVATE /* mount private, single-client tree */ if (amu_hasmntopt(mntp, MNTTAB_OPT_PRIVATE) != NULL) 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; # 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_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; #endif /* defined(MNT2_NFS_OPT_NONLM) && defined(MNTTAB_OPT_NOLOCK) */ #if defined(MNT2_NFS_OPT_XLATECOOKIE) && defined(MNTTAB_OPT_XLATECOOKIE) 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) { #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 */ compute_nfs_attrcache_flags(nap, mntp); /* * 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 DEBUG /* get string version (in hex) of identifier */ static char * get_hex_string(u_int len, const char *fhdata) { u_int i; static char buf[128]; /* better not go over it! */ char str[16]; short int arr[64]; if (!fhdata) return NULL; buf[0] = '\0'; memset(&arr[0], 0, (64 * sizeof(short int))); memcpy(&arr[0], &fhdata[0], len); for (i=0; iaddr; plog(XLOG_DEBUG, "NA->addr {netbuf} (maxlen=%d, len=%d) = \"%s\"", nbp->maxlen, nbp->len, get_hex_string(nbp->len, nbp->buf)); nbp = nap->syncaddr; plog(XLOG_DEBUG, "NA->syncaddr {netbuf} %p", nbp); kncp = nap->knconf; plog(XLOG_DEBUG, "NA->knconf->semantics %lu", (u_long) kncp->knc_semantics); plog(XLOG_DEBUG, "NA->knconf->protofmly \"%s\"", kncp->knc_protofmly); plog(XLOG_DEBUG, "NA->knconf->proto \"%s\"", kncp->knc_proto); plog(XLOG_DEBUG, "NA->knconf->rdev %lu", (u_long) kncp->knc_rdev); /* don't print knconf->unused field */ #else /* not HAVE_TRANSPORT_TYPE_TLI */ # ifdef NFS_ARGS_T_ADDR_IS_POINTER sap = (struct sockaddr_in *) nap->addr; # 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)); #endif /* not HAVE_TRANSPORT_TYPE_TLI */ #ifdef HAVE_NFS_ARGS_T_ADDRLEN plog(XLOG_DEBUG, "NA->addrlen = %d", nap->addrlen); #endif /* ifdef HAVE_NFS_ARGS_T_ADDRLEN */ plog(XLOG_DEBUG, "NA->hostname = \"%s\"", nap->hostname ? nap->hostname : "null"); #ifdef HAVE_NFS_ARGS_T_NAMLEN plog(XLOG_DEBUG, "NA->namlen = %d", nap->namlen); #endif /* HAVE_NFS_ARGS_T_NAMLEN */ #ifdef MNT2_NFS_OPT_FSNAME plog(XLOG_DEBUG, "NA->fsname = \"%s\"", nap->fsname ? nap->fsname : "null"); #endif /* MNT2_NFS_OPT_FSNAME */ #ifdef HAVE_NFS_ARGS_T_FHSIZE plog(XLOG_DEBUG, "NA->fhsize = %d", nap->fhsize); fhlen = nap->fhsize; #endif /* HAVE_NFS_ARGS_T_FHSIZE */ #ifdef HAVE_NFS_ARGS_T_FH_LEN plog(XLOG_DEBUG, "NA->fh_len = %d", nap->fh_len); fhlen = nap->fh_len; #endif /* HAVE_NFS_ARGS_T_FH_LEN */ /* * XXX: need to figure out how to correctly print file handles, * since some times they are pointers, and sometimes the real structure * is stored in nfs_args. Even if it is a pointer, it can be the actual * char[] array, or a structure containing multiple fields. */ plog(XLOG_DEBUG, "NA->filehandle = \"%s\"", get_hex_string(fhlen, (const char *) &nap->NFS_FH_FIELD)); #ifdef HAVE_NFS_ARGS_T_SOTYPE plog(XLOG_DEBUG, "NA->sotype = %d", nap->sotype); #endif /* HAVE_NFS_ARGS_T_SOTYPE */ #ifdef HAVE_NFS_ARGS_T_PROTO plog(XLOG_DEBUG, "NA->proto = %d", (int) nap->proto); #endif /* HAVE_NFS_ARGS_T_PROTO */ #ifdef HAVE_NFS_ARGS_T_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); 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 */ #ifdef MNTTAB_OPT_PG_THRESH plog(XLOG_DEBUG, "NA->pg_thresh = %d", nap->pg_thresh); #endif /* MNTTAB_OPT_PG_THRESH */ #ifdef MNT2_NFS_OPT_BIODS plog(XLOG_DEBUG, "NA->biods = %d", nap->biods); #endif /* MNT2_NFS_OPT_BIODS */ } #endif /* DEBUG */ am-utils-6.2+rc20110530/libamu/mtab.c000066400000000000000000000153211157065440000166740ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/mtab.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Firewall /etc/mtab entries */ void mnt_free(mntent_t *mp) { XFREE(mp->mnt_fsname); XFREE(mp->mnt_dir); XFREE(mp->mnt_type); XFREE(mp->mnt_opts); #ifdef HAVE_MNTENT_T_MNT_TIME # ifdef HAVE_MNTENT_T_MNT_TIME_STRING XFREE(mp->mnt_time); # endif /* HAVE_MNTENT_T_MNT_TIME_STRING */ #endif /* HAVE_MNTENT_T_MNT_TIME */ XFREE(mp); } /* * Discard memory allocated for mount list */ void discard_mntlist(mntlist *mp) { mntlist *mp2; while ((mp2 = mp)) { mp = mp->mnext; if (mp2->mnt) mnt_free(mp2->mnt); XFREE(mp2); } } /* * Throw away a mount list */ void free_mntlist(mntlist *mp) { discard_mntlist(mp); #ifdef MOUNT_TABLE_ON_FILE unlock_mntlist(); #endif /* MOUNT_TABLE_ON_FILE */ } /* * Utility routine which returns a pointer to whatever follows an = in a * string. Returns null if = is not found in the string. */ char * haseq(char *instr) { if (instr) { char *eq = strchr(instr, '='); if (eq) return ++eq; } return NULL; } /* * Utility routine which returns a pointer to whatever * follows an = in a mount option. Returns null if option * doesn't exist or doesn't have an '='. Won't fail for opt,foo=. */ char * hasmnteq(mntent_t *mnt, char *opt) { if (mnt && opt) { /* disallow null input pointers */ if ( *opt ) { /* disallow the null string as an opt */ char *str = amu_hasmntopt(mnt, opt); if ( str ) { /* option was there */ char *eq = str + strlen(opt); /* Look at char just after option */ if (*eq == '=') /* Is it '=' ? */ return ++eq; /* If so, return pointer to remaining str */ } } } return NULL; } /* * Wrapper around hasmntvalerr(), which retains backwards compatibiliy with * older use of hasmntval(). * * XXX: eventually, all use of hasmntval() should be replaced with * hasmntvalerr(). */ int hasmntval(mntent_t *mnt, char *opt) { int err, val = 0; err = hasmntvalerr(mnt, opt, &val); if (err) /* if there was an error (hasmntvalerr returned 1) */ return 0; /* redundant: val==0 above, but leave here for clarity */ /* otherwise there was no error */ return val; } /* * Utility routine which determines the value of a numeric option in the * mount options (such as port=%d), and fills in the value in the argument * valp (argument won't be touched if no value is set, for example due to an * error). * * Returns non-zero (1) on error; returns 0 on success. * * XXX: eventually, all use of hasmntval() should be replaced with * hasmntvalerr(). */ unsigned int hasmntvalerr(mntent_t *mnt, char *opt, int *valp) { char *str = amu_hasmntopt(mnt, opt); int err = 1; /* 1 means no good value was set (an error) */ char *eq, *endptr; long int i; /* exit if no option specificed */ if (!str) { goto out; } eq = hasmnteq(mnt, opt); if (!eq) { /* no argument to option ('=' sign was missing) */ plog(XLOG_MAP, "numeric option to \"%s\" missing", opt); goto out; } /* if got here, then we had an '=' after option name */ endptr = NULL; i = strtol(eq, &endptr, 0); /* hex and octal allowed ;-) */ if (!endptr || (endptr != eq && (*endptr == ',' || *endptr == '\0'))) { /* * endptr set means strtol saw a non-digit. If the non-digit is a * comma, it's probably the start of the next option. If the comma is * the first char though, complain about it (foo=,bar is made * noticeable by this). * * Similar reasoning for '\0' instead of comma, it's the end of the * string. */ *valp = (int) i; /* set good value */ err = 0; /* no error */ } else { /* whatever was after the '=' sign wasn't a number */ plog(XLOG_MAP, "invalid numeric option in \"%s\": \"%s\"", opt, str); /* fall through to error/exit processing */ } out: return err; } /* * Utility routine which returns the string value of * an option in the mount options (such as proto=udp). * Returns NULL if the option is not specified. * Returns malloc'ed string (caller must free!) */ char * hasmntstr(mntent_t *mnt, char *opt) { char *str = amu_hasmntopt(mnt, opt); if (str) { /* The option was there */ char *eq = hasmnteq(mnt, opt); if (eq) { /* and had an = after it */ char *endptr = strchr(eq, ','); /* if saw no comma, return strdup'd string */ if (!endptr) return strdup(eq); else { /* else we need to copy only the chars needed */ int len = endptr - eq; char *buf = xmalloc(len + 1); strncpy(buf, eq, len); buf[len] = '\0'; return buf; } } } return NULL; } am-utils-6.2+rc20110530/libamu/nfs_prot_xdr.c000066400000000000000000000050021157065440000204530ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. * 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. 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 * 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/nfs_prot_xdr.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include bool_t xdr_amq_string(XDR *xdrs, amq_string *objp) { if (!xdr_string(xdrs, objp, AMQ_STRLEN)) { return (FALSE); } 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); } am-utils-6.2+rc20110530/libamu/strcasecmp.c000066400000000000000000000050451157065440000201170ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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 #endif /* HAVE_CONFIG_H */ #include #include /* * 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)); } am-utils-6.2+rc20110530/libamu/strdup.c000066400000000000000000000045741157065440000173020ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/strdup.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Dup a string */ char * strdup(const char *s) { int len = strlen(s); char *sp = (char *) xmalloc(len + 1); memmove(sp, s, len); sp[len] = '\0'; return sp; } am-utils-6.2+rc20110530/libamu/strerror.c000066400000000000000000000052521157065440000176350ustar00rootroot00000000000000/* * Copyright (c) 2002-2011 Ion Badulescu * Copyright (c) 1997-2011 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. 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 * 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/strerror.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Convert errno to a string */ char * strerror(int errnum) { #ifdef HAVE_EXTERN_SYS_ERRLIST if (errnum < 0 || errnum >= (sizeof(sys_errlist) >> 2)) { static char errstr[30]; xsnprintf(errstr, sizeof(errstr), "Unknown error #%d", errnum); return errstr; } return sys_errlist[error]; #else /* not HAVE_EXTERN_SYS_ERRLIST */ return "unknown (strerror not available)"; #endif /* not HAVE_EXTERN_SYS_ERRLIST */ } am-utils-6.2+rc20110530/libamu/strlcat.c000066400000000000000000000060521157065440000174260ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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 #endif /* HAVE_CONFIG_H */ #include #include /* * 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 */ } am-utils-6.2+rc20110530/libamu/strlcpy.c000066400000000000000000000056671157065440000174650ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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 #endif /* HAVE_CONFIG_H */ #include #include /* * 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 */ } am-utils-6.2+rc20110530/libamu/strstr.c000066400000000000000000000070071157065440000173140ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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 #endif /* HAVE_CONFIG_H */ #include #include /* 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; } am-utils-6.2+rc20110530/libamu/strutil.c000066400000000000000000000201101157065440000174470ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/strutil.c * */ /* * String Utilities. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include char * strnsave(const char *str, int len) { char *sp = (char *) xmalloc(len + 1); memmove(sp, str, len); sp[len] = '\0'; return sp; } /* * Concatenate three strings and store the result in the buffer pointed to * by p, making p large enough to hold the strings */ char * str3cat(char *p, char *s1, char *s2, char *s3) { int l1 = strlen(s1); int l2 = strlen(s2); int l3 = strlen(s3); p = (char *) xrealloc(p, l1 + l2 + l3 + 1); memmove(p, s1, l1); memmove(p + l1, s2, l2); memmove(p + l1 + l2, s3, l3 + 1); return p; } /* * Split s using ch as delimiter and qc as quote character */ char ** strsplit(char *s, int ch, int qc) { char **ivec; int ic = 0; int done = 0; ivec = (char **) xmalloc((ic + 1) * sizeof(char *)); while (!done) { char *v; /* * skip to split char */ while (*s && (ch == ' ' ? (isascii((unsigned char)*s) && isspace((unsigned char)*s)) : *s == ch)) *s++ = '\0'; /* * End of string? */ if (!*s) break; /* * remember start of string */ v = s; /* * skip to split char */ while (*s && !(ch == ' ' ? (isascii((unsigned char)*s) && isspace((unsigned char)*s)) : *s == ch)) { if (*s++ == qc) { /* * Skip past string. */ s++; while (*s && *s != qc) s++; if (*s == qc) s++; } } if (!*s) done = 1; *s++ = '\0'; /* * save string in new ivec slot */ ivec[ic++] = v; ivec = (char **) xrealloc((voidp) ivec, (ic + 1) * sizeof(char *)); if (amuDebug(D_STR)) plog(XLOG_DEBUG, "strsplit saved \"%s\"", v); } if (amuDebug(D_STR)) plog(XLOG_DEBUG, "strsplit saved a total of %d strings", ic); ivec[ic] = NULL; return ivec; } /* * Use generic strlcpy to copy a string more carefully, null-terminating it * as needed. However, if the copied string was truncated due to lack of * space, then warn us. * * For now, xstrlcpy returns VOID because it doesn't look like anywhere in * the Amd code do we actually use the return value of strncpy/strlcpy. */ void #ifdef DEBUG _xstrlcpy(const char *filename, int lineno, char *dst, const char *src, size_t len) #else /* not DEBUG */ xstrlcpy(char *dst, const char *src, size_t len) #endif /* not DEBUG */ { if (len == 0) return; if (strlcpy(dst, src, len) >= len) #ifdef DEBUG plog(XLOG_ERROR, "xstrlcpy(%s:%d): string \"%s\" truncated to \"%s\"", filename, lineno, src, dst); #else /* not DEBUG */ plog(XLOG_ERROR, "xstrlcpy: string \"%s\" truncated to \"%s\"", src, dst); #endif /* not DEBUG */ } /* * Use generic strlcat to concatenate a string more carefully, * null-terminating it as needed. However, if the copied string was * truncated due to lack of space, then warn us. * * For now, xstrlcat returns VOID because it doesn't look like anywhere in * the Amd code do we actually use the return value of strncat/strlcat. */ void #ifdef DEBUG _xstrlcat(const char *filename, int lineno, char *dst, const char *src, size_t len) #else /* not DEBUG */ xstrlcat(char *dst, const char *src, size_t len) #endif /* not DEBUG */ { if (len == 0) return; if (strlcat(dst, src, len) >= len) { /* strlcat does not null terminate if the size of src is equal to len. */ dst[strlen(dst) - 1] = '\0'; #ifdef DEBUG plog(XLOG_ERROR, "xstrlcat(%s:%d): string \"%s\" truncated to \"%s\"", filename, lineno, src, dst); #else /* not DEBUG */ plog(XLOG_ERROR, "xstrlcat: string \"%s\" truncated to \"%s\"", src, dst); #endif /* not DEBUG */ } } /* our version of snprintf */ int #if defined(DEBUG) && (defined(HAVE_C99_VARARGS_MACROS) || defined(HAVE_GCC_VARARGS_MACROS)) _xsnprintf(const char *filename, int lineno, char *str, size_t size, const char *format, ...) #else /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ xsnprintf(char *str, size_t size, const char *format, ...) #endif /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ { va_list ap; int ret = 0; va_start(ap, format); #if defined(DEBUG) && (defined(HAVE_C99_VARARGS_MACROS) || defined(HAVE_GCC_VARARGS_MACROS)) ret = _xvsnprintf(filename, lineno, str, size, format, ap); #else /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ ret = xvsnprintf(str, size, format, ap); #endif /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ va_end(ap); return ret; } /* our version of vsnprintf */ int #if defined(DEBUG) && (defined(HAVE_C99_VARARGS_MACROS) || defined(HAVE_GCC_VARARGS_MACROS)) _xvsnprintf(const char *filename, int lineno, char *str, size_t size, const char *format, va_list ap) #else /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ xvsnprintf(char *str, size_t size, const char *format, va_list ap) #endif /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ { int ret = 0; #ifdef HAVE_VSNPRINTF ret = vsnprintf(str, size, format, ap); #else /* not HAVE_VSNPRINTF */ ret = vsprintf(str, format, ap); /* less secure version */ #endif /* not HAVE_VSNPRINTF */ /* * If error or truncation, plog error. * * WARNING: we use the static 'maxtrunc' variable below to break out any * possible infinite recursion between plog() and xvsnprintf(). If it * ever happens, it'd indicate a bug in Amd. */ if (ret < 0 || (size_t) ret >= size) { /* error or truncation occured */ static int maxtrunc; /* hack to avoid inifinite loop */ if (++maxtrunc > 10) #if defined(DEBUG) && (defined(HAVE_C99_VARARGS_MACROS) || defined(HAVE_GCC_VARARGS_MACROS)) plog(XLOG_ERROR, "xvsnprintf(%s:%d): string %p truncated (ret=%d, format=\"%s\")", filename, lineno, str, ret, format); #else /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ plog(XLOG_ERROR, "xvsnprintf: string %p truncated (ret=%d, format=\"%s\")", str, ret, format); #endif /* not DEBUG or no C99/GCC-style vararg cpp macros supported */ } return ret; } am-utils-6.2+rc20110530/libamu/ualarm.c000066400000000000000000000054461157065440000172410ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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 #endif /* HAVE_CONFIG_H */ #include #include #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; } am-utils-6.2+rc20110530/libamu/wire.c000066400000000000000000000372161157065440000167260ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/wire.c * */ /* * This function returns the subnet (address&netmask) for the primary network * interface. If the resulting address has an entry in the hosts file, the * corresponding name is returned, otherwise the address is returned in * standard internet format. * As a side-effect, a list of local IP/net address is recorded for use * by the islocalnet() function. * * Derived from original by Paul Anderson (23/4/90) * Updates from Dirk Grunwald (11/11/91) */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #ifdef HAVE_IFADDRS_H #include #endif /* HAVE_IFADDRS_H */ #ifdef HAVE_IRS_H # include #endif /* HAVE_IRS_H */ /* * List of locally connected networks */ typedef struct addrlist addrlist; struct addrlist { addrlist *ip_next; u_long ip_addr; /* address of network */ u_long ip_mask; char *ip_net_num; /* number of network */ char *ip_net_name; /* name of network */ }; static addrlist *localnets = NULL; #if defined(IFF_LOCAL_LOOPBACK) && !defined(IFF_LOOPBACK) # define IFF_LOOPBACK IFF_LOCAL_LOOPBACK #endif /* defined(IFF_LOCAL_LOOPBACK) && !defined(IFF_LOOPBACK) */ #define C(x) ((x) & 0xff) #define GFBUFLEN 1024 #define S2IN(s) (((struct sockaddr_in *)(s))->sin_addr.s_addr) /* return malloc'ed buffer. caller must free it */ char * print_wires(void) { addrlist *al; char s[256]; int i; char *buf; int bufcount = 0; int buf_size = 1024; buf = SALLOC(buf_size); /* initial allocation (may grow!) */ if (!buf) return NULL; if (!localnets) { xstrlcpy(buf, "No networks\n", buf_size); return buf; } /* check if there's more than one network */ if (!localnets->ip_next) { /* use buf_size for sizeof(buf) because of the realloc() below */ xsnprintf(buf, buf_size, "Network: wire=\"%s\" (netnumber=%s).\n", localnets->ip_net_name, localnets->ip_net_num); return buf; } buf[0] = '\0'; /* null out buffer before appending */ for (i = 1, al = localnets; al; al = al->ip_next, i++) { xsnprintf(s, sizeof(s), "Network %d: wire=\"%s\" (netnumber=%s).\n", i, al->ip_net_name, al->ip_net_num); bufcount += strlen(s); if (bufcount > buf_size) { buf_size *= 2; buf = xrealloc(buf, buf_size); } xstrlcat(buf, s, buf_size); } return buf; } static struct addrlist * getwire_lookup(u_long address, u_long netmask, int ishost) { struct addrlist *al; u_long subnet; char netNumberBuf[64]; char buf[GFBUFLEN], *s; #ifdef HAVE_IRS_H struct nwent *np; #else /* not HAVE_IRS_H */ struct netent *np; #endif /* not HAVE_IRS_H */ /* * Add interface to local network singly linked list */ al = ALLOC(struct addrlist); al->ip_addr = address; al->ip_mask = netmask; al->ip_net_name = NO_SUBNET; /* fill in a bit later */ al->ip_net_num = "0.0.0.0"; /* fill in a bit later */ al->ip_next = NULL; subnet = ntohl(address) & ntohl(netmask); if (ishost) np = NULL; else { #ifdef HAVE_IRS_H u_long mask = ntohl(netmask); static struct irs_acc *irs_gen; static struct irs_nw *irs_nw; u_long net; int maskbits; u_char addr[4]; if (irs_gen == NULL) #ifdef irs_irp_acc /* * bsdi4 added another argument to this function, without changing * its name. The irs_irp_acc is the one (hacky) distinguishing * feature found in that can differentiate between bsdi3 and * bsdi4. */ irs_gen = irs_gen_acc("", NULL); #else /* not irs_irp_acc */ irs_gen = irs_gen_acc(""); #endif /* not irs_irp_acc */ if (irs_gen && irs_nw == NULL) irs_nw = (*irs_gen->nw_map)(irs_gen); net = ntohl(address) & (mask = ntohl(netmask)); addr[0] = (0xFF000000 & net) >> 24; addr[1] = (0x00FF0000 & net) >> 16; addr[2] = (0x0000FF00 & net) >> 8; addr[3] = (0x000000FF & net); for (maskbits = 32; !(mask & 1); mask >>= 1) maskbits--; np = (*irs_nw->byaddr)(irs_nw, addr, maskbits, AF_INET); #else /* not HAVE_IRS_H */ np = getnetbyaddr(subnet, AF_INET); /* * Some systems (IRIX 6.4) cannot getnetbyaddr on networks such as * "128.59.16.0". Instead, they need to look for the short form of * the network, "128.59.16". So if the first getnetbyaddr failed, we * shift the subnet way from zeros and try again. */ if (!np) { u_long short_subnet = subnet; while (short_subnet && (short_subnet & 0x000000ff) == 0) short_subnet >>= 8; np = getnetbyaddr(short_subnet, AF_INET); if (np) plog(XLOG_WARNING, "getnetbyaddr failed on 0x%x, succeeded on 0x%x", (u_int) subnet, (u_int) short_subnet); } #endif /* not HAVE_IRS_H */ } if ((subnet & 0xffffff) == 0) { xsnprintf(netNumberBuf, sizeof(netNumberBuf), "%lu", C(subnet >> 24)); } else if ((subnet & 0xffff) == 0) { xsnprintf(netNumberBuf, sizeof(netNumberBuf), "%lu.%lu", C(subnet >> 24), C(subnet >> 16)); } else if ((subnet & 0xff) == 0) { xsnprintf(netNumberBuf, sizeof(netNumberBuf), "%lu.%lu.%lu", C(subnet >> 24), C(subnet >> 16), C(subnet >> 8)); } else { xsnprintf(netNumberBuf, sizeof(netNumberBuf), "%lu.%lu.%lu.%lu", C(subnet >> 24), C(subnet >> 16), C(subnet >> 8), C(subnet)); } /* fill in network number (string) */ al->ip_net_num = strdup(netNumberBuf); if (np != NULL) s = np->n_name; else { struct hostent *hp; subnet = address & netmask; hp = gethostbyaddr((char *) &subnet, 4, AF_INET); if (hp != NULL) s = (char *) hp->h_name; else s = inet_dquad(buf, sizeof(buf), subnet); } /* fill in network name (string) */ al->ip_net_name = strdup(s); /* Let's be cautious here about buffer overflows -Ion */ if (strlen(s) > MAXHOSTNAMELEN) { al->ip_net_name[MAXHOSTNAMELEN] = '\0'; plog(XLOG_WARNING, "Long hostname %s truncated to %d characters", s, MAXHOSTNAMELEN); } return (al); } /* * Make a dotted quad from a 32bit IP address * addr is in network byte order. * sizeof(buf) needs to be at least 16. */ char * inet_dquad(char *buf, size_t l, u_long addr) { addr = ntohl(addr); xsnprintf(buf, l, "%ld.%ld.%ld.%ld", ((addr >> 24) & 0xff), ((addr >> 16) & 0xff), ((addr >> 8) & 0xff), ((addr >> 0) & 0xff)); return buf; } /* * Determine whether a network is on a local network * (addr) is in network byte order. */ int islocalnet(u_long addr) { addrlist *al; for (al = localnets; al; al = al->ip_next) if (((addr ^ al->ip_addr) & al->ip_mask) == 0) return TRUE; #ifdef DEBUG { char buf[16]; plog(XLOG_INFO, "%s is on a remote network", inet_dquad(buf, sizeof(buf), addr)); } #endif /* DEBUG */ return FALSE; } /* * Determine whether a network name is one of the local networks * of a host. */ int is_network_member(const char *net) { addrlist *al; /* * If the network name string does not contain a '/', use old behavior. * If it does contain a '/' then interpret the string as a network/netmask * pair. If "netmask" doesn't exist, use the interface's own netmask. * Also support fully explicit netmasks such as 255.255.255.0 as well as * bit-length netmask such as /24 (hex formats such 0xffffff00 work too). */ if (strchr(net, '/') == NULL) { for (al = localnets; al; al = al->ip_next) if (STREQ(net, al->ip_net_name) || STREQ(net, al->ip_net_num)) return TRUE; } else { char *netstr = strdup(net), *maskstr; u_long netnum, masknum = 0; maskstr = strchr(netstr, '/'); maskstr[0] = '\0'; /* null terminate netstr */ maskstr++; if (*maskstr == '\0') /* if empty string, make it NULL */ maskstr = NULL; /* check if netmask uses a dotted-quad or bit-length, or not defined at all */ if (maskstr) { if (strchr(maskstr, '.')) { /* XXX: inet_addr is obsolste, convert to inet_aton() */ masknum = inet_addr(maskstr); if (masknum == INADDR_NONE) /* can be invalid (-1) or all-1s */ masknum = 0xffffffff; } else if (NSTRCEQ(maskstr, "0x", 2)) { masknum = strtoul(maskstr, NULL, 16); } else { int bits = atoi(maskstr); if (bits < 0) bits = 0; if (bits > 32) bits = 32; masknum = 0xffffffff << (32-bits); } } netnum = inet_addr(netstr); /* not checking return value, b/c -1 (0xffffffff) is valid */ XFREE(netstr); /* netstr not needed any longer */ /* now check against each local interface */ for (al = localnets; al; al = al->ip_next) { if ((al->ip_addr & (maskstr ? masknum : al->ip_mask)) == netnum) return TRUE; } } return FALSE; } /* * Determine whether a IP address (netnum) is one of the local interfaces, * returns TRUE/FALSE. * Does not include the loopback interface: caller needs to check that. */ int is_interface_local(u_long netnum) { addrlist *al; for (al = localnets; al; al = al->ip_next) { if (al->ip_addr == netnum) return TRUE; } return FALSE; } #ifdef HAVE_GETIFADDRS void getwire(char **name1, char **number1) { addrlist *al = NULL, *tail = NULL; struct ifaddrs *ifaddrs, *ifap; #ifndef HAVE_STRUCT_IFADDRS_IFA_NEXT int count = 0, i; #endif /* not HAVE_STRUCT_IFADDRS_IFA_NEXT */ ifaddrs = NULL; #ifdef HAVE_STRUCT_IFADDRS_IFA_NEXT if (getifaddrs(&ifaddrs) < 0) goto out; for (ifap = ifaddrs; ifap != NULL; ifap = ifap->ifa_next) { #else /* not HAVE_STRUCT_IFADDRS_IFA_NEXT */ if (getifaddrs(&ifaddrs, &count) < 0) goto out; for (i = 0,ifap = ifaddrs; i < count; ifap++, i++) { #endif /* HAVE_STRUCT_IFADDRS_IFA_NEXT */ if (!ifap || !ifap->ifa_addr || ifap->ifa_addr->sa_family != AF_INET) continue; /* * If the interface is the loopback, or it's not running, * then ignore it. */ if (S2IN(ifap->ifa_addr) == htonl(INADDR_LOOPBACK)) continue; if ((ifap->ifa_flags & IFF_RUNNING) == 0) continue; if ((ifap->ifa_flags & IFF_POINTOPOINT) == 0) al = getwire_lookup(S2IN(ifap->ifa_addr), S2IN(ifap->ifa_netmask), 0); else al = getwire_lookup(S2IN(ifap->ifa_dstaddr), 0xffffffff, 1); /* append to the end of the list */ if (!localnets || tail == NULL) { localnets = tail = al; tail->ip_next = NULL; } else { tail->ip_next = al; tail = al; } } out: if (ifaddrs) XFREE(ifaddrs); if (localnets) { *name1 = localnets->ip_net_name; *number1 = localnets->ip_net_num; } else { *name1 = NO_SUBNET; *number1 = "0.0.0.0"; } } #else /* not HAVE_GETIFADDRS */ #if defined(HAVE_STRUCT_IFREQ_IFR_ADDR) && defined(HAVE_STRUCT_SOCKADDR_SA_LEN) # define SIZE(ifr) (MAX((ifr)->ifr_addr.sa_len, sizeof((ifr)->ifr_addr)) + sizeof(ifr->ifr_name)) #else /* not defined(HAVE_STRUCT_IFREQ_IFR_ADDR) && defined(HAVE_STRUCT_SOCKADDR_SA_LEN) */ # define SIZE(ifr) sizeof(struct ifreq) #endif /* not defined(HAVE_STRUCT_IFREQ_IFR_ADDR) && defined(HAVE_STRUCT_SOCKADDR_SA_LEN) */ #define clist (ifc.ifc_ifcu.ifcu_req) #define count (ifc.ifc_len/sizeof(struct ifreq)) void getwire(char **name1, char **number1) { struct ifconf ifc; struct ifreq *ifr, ifrpool; caddr_t cp, cplim; int fd = -1; u_long address; addrlist *al = NULL, *tail = NULL; char buf[GFBUFLEN]; #ifndef SIOCGIFFLAGS /* if cannot get interface flags, return nothing */ plog(XLOG_ERROR, "getwire unable to get interface flags"); localnets = NULL; return; #endif /* not SIOCGIFFLAGS */ /* * Get suitable socket */ if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) goto out; /* * Fill in ifconf details */ memset(&buf[0], 0, GFBUFLEN); ifc.ifc_len = sizeof(buf); ifc.ifc_buf = buf; /* * Get network interface configurations */ if (ioctl(fd, SIOCGIFCONF, (caddr_t) & ifc) < 0) goto out; /* * Upper bound on array */ cplim = buf + ifc.ifc_len; /* * This is some magic to cope with both "traditional" and the * new 4.4BSD-style struct sockaddrs. The new structure has * variable length and a size field to support longer addresses. * AF_LINK is a new definition for 4.4BSD. */ /* * Scan the list looking for a suitable interface */ for (cp = buf; cp < cplim; /* increment in the loop body */) { memcpy(&ifrpool, cp, sizeof(ifrpool)); ifr = &ifrpool; cp += SIZE(ifr); if (ifr->ifr_addr.sa_family != AF_INET) continue; address = ((struct sockaddr_in *) &ifr->ifr_addr)->sin_addr.s_addr; /* * Get interface flags */ if (ioctl(fd, SIOCGIFFLAGS, (caddr_t) ifr) < 0) continue; /* * If the interface is the loopback, or it's not running, * then ignore it. */ if (address == htonl(INADDR_LOOPBACK)) continue; /* * Fix for 0.0.0.0 loopback on SunOS 3.X which defines IFF_ROUTE * instead of IFF_LOOPBACK. */ #ifdef IFF_ROUTE if (ifr->ifr_flags == (IFF_UP|IFF_RUNNING)) continue; #endif /* IFF_ROUTE */ /* if the interface is not UP or not RUNNING, skip it */ if ((ifr->ifr_flags & IFF_RUNNING) == 0 || (ifr->ifr_flags & IFF_UP) == 0) continue; if ((ifr->ifr_flags & IFF_POINTOPOINT) == 0) { /* * Get the netmask of this interface */ if (ioctl(fd, SIOCGIFNETMASK, (caddr_t) ifr) < 0) continue; al = getwire_lookup(address, S2IN(&ifr->ifr_addr), 0); } else al = getwire_lookup(address, 0xffffffff, 1); /* append to the end of the list */ if (!localnets) { localnets = tail = al; tail->ip_next = NULL; } else { tail->ip_next = al; tail = al; } } out: if (fd >= 0) close(fd); if (localnets) { *name1 = localnets->ip_net_name; *number1 = localnets->ip_net_num; } else { *name1 = NO_SUBNET; *number1 = "0.0.0.0"; } } #endif /* not HAVE_GETIFADDRS */ am-utils-6.2+rc20110530/libamu/xdr_func.c000066400000000000000000000550151157065440000175650ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/xdr_func.c * */ /* * Complete list of all possible xdr functions which may be needed. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include #ifdef __RPCSVC_MOUNT_H__ # error IRIX6 should not include rpcsvc/mount.h #endif /* __RPCSVC_MOUNT_H__ */ /* * MACROS: */ #ifdef HAVE_FS_AUTOFS # ifndef AUTOFS_MAXCOMPONENTLEN # define AUTOFS_MAXCOMPONENTLEN 255 # endif /* not AUTOFS_MAXCOMPONENTLEN */ # ifndef AUTOFS_MAXOPTSLEN # define AUTOFS_MAXOPTSLEN 255 # endif /* not AUTOFS_MAXOPTSLEN */ # ifndef AUTOFS_MAXPATHLEN # define AUTOFS_MAXPATHLEN 1024 # endif /* not AUTOFS_MAXPATHLEN */ #endif /* HAVE_FS_AUTOFS */ /* forward definitions, are they needed? */ extern bool_t xdr_exportnode(XDR *xdrs, exportnode *objp); extern bool_t xdr_groupnode(XDR *xdrs, groupnode *objp); extern bool_t xdr_name(XDR *xdrs, name *objp); #ifndef HAVE_XDR_ATTRSTAT bool_t xdr_attrstat(XDR *xdrs, nfsattrstat *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_attrstat:"); if (!xdr_nfsstat(xdrs, &objp->ns_status)) { return (FALSE); } switch (objp->ns_status) { case NFS_OK: if (!xdr_fattr(xdrs, &objp->ns_u.ns_attr_u)) { return (FALSE); } break; default: break; } return (TRUE); } #endif /* not HAVE_XDR_ATTRSTAT */ #ifndef HAVE_XDR_CREATEARGS bool_t xdr_createargs(XDR *xdrs, nfscreateargs *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_createargs:"); if (!xdr_diropargs(xdrs, &objp->ca_where)) { return (FALSE); } if (!xdr_sattr(xdrs, &objp->ca_attributes)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_CREATEARGS */ #ifndef HAVE_XDR_DIRLIST bool_t xdr_dirlist(XDR *xdrs, nfsdirlist *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_dirlist:"); if (!xdr_pointer(xdrs, (char **) &objp->dl_entries, sizeof(nfsentry), (XDRPROC_T_TYPE) xdr_entry)) { return (FALSE); } if (!xdr_bool(xdrs, &objp->dl_eof)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_DIRLIST */ #ifndef HAVE_XDR_DIROPARGS bool_t xdr_diropargs(XDR *xdrs, nfsdiropargs *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_diropargs:"); if (!xdr_nfs_fh(xdrs, &objp->da_fhandle)) { return (FALSE); } if (!xdr_filename(xdrs, &objp->da_name)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_DIROPARGS */ #ifndef HAVE_XDR_DIROPOKRES bool_t xdr_diropokres(XDR *xdrs, nfsdiropokres *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_diropokres:"); if (!xdr_nfs_fh(xdrs, &objp->drok_fhandle)) { return (FALSE); } if (!xdr_fattr(xdrs, &objp->drok_attributes)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_DIROPOKRES */ #ifndef HAVE_XDR_DIROPRES bool_t xdr_diropres(XDR *xdrs, nfsdiropres *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_diropres:"); if (!xdr_nfsstat(xdrs, &objp->dr_status)) { return (FALSE); } switch (objp->dr_status) { case NFS_OK: if (!xdr_diropokres(xdrs, &objp->dr_u.dr_drok_u)) { return (FALSE); } break; default: break; } return (TRUE); } #endif /* not HAVE_XDR_DIROPRES */ #ifndef HAVE_XDR_DIRPATH bool_t xdr_dirpath(XDR *xdrs, dirpath *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_dirpath:"); if (!xdr_string(xdrs, objp, MNTPATHLEN)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_DIRPATH */ #ifndef HAVE_XDR_ENTRY bool_t xdr_entry(XDR *xdrs, nfsentry *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_entry:"); if (!xdr_u_int(xdrs, &objp->ne_fileid)) { return (FALSE); } if (!xdr_filename(xdrs, &objp->ne_name)) { return (FALSE); } if (!xdr_nfscookie(xdrs, objp->ne_cookie)) { return (FALSE); } if (!xdr_pointer(xdrs, (char **) &objp->ne_nextentry, sizeof(nfsentry), (XDRPROC_T_TYPE) xdr_entry)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_ENTRY */ #ifndef HAVE_XDR_EXPORTNODE bool_t xdr_exportnode(XDR *xdrs, exportnode *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_exportnode:"); if (!xdr_dirpath(xdrs, &objp->ex_dir)) { return (FALSE); } if (!xdr_groups(xdrs, &objp->ex_groups)) { return (FALSE); } if (!xdr_exports(xdrs, &objp->ex_next)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_EXPORTNODE */ #ifndef HAVE_XDR_EXPORTS bool_t xdr_exports(XDR *xdrs, exports *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_exports:"); if (!xdr_pointer(xdrs, (char **) objp, sizeof(exportnode), (XDRPROC_T_TYPE) xdr_exportnode)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_EXPORTS */ #ifndef HAVE_XDR_FATTR bool_t xdr_fattr(XDR *xdrs, nfsfattr *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_fattr:"); if (!xdr_ftype(xdrs, &objp->na_type)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->na_mode)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->na_nlink)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->na_uid)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->na_gid)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->na_size)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->na_blocksize)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->na_rdev)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->na_blocks)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->na_fsid)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->na_fileid)) { return (FALSE); } if (!xdr_nfstime(xdrs, &objp->na_atime)) { return (FALSE); } if (!xdr_nfstime(xdrs, &objp->na_mtime)) { return (FALSE); } if (!xdr_nfstime(xdrs, &objp->na_ctime)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_FATTR */ #ifndef HAVE_XDR_FHANDLE bool_t xdr_fhandle(XDR *xdrs, fhandle objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_fhandle:"); if (!xdr_opaque(xdrs, objp, NFS_FHSIZE)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_FHANDLE */ #ifndef HAVE_XDR_FHSTATUS bool_t xdr_fhstatus(XDR *xdrs, fhstatus *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_fhstatus:"); if (!xdr_u_int(xdrs, &objp->fhs_status)) { return (FALSE); } if (objp->fhs_status == 0 && !xdr_fhandle(xdrs, objp->fhs_fh)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_FHSTATUS */ #ifndef HAVE_XDR_FILENAME bool_t xdr_filename(XDR *xdrs, filename *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_filename:"); if (!xdr_string(xdrs, objp, NFS_MAXNAMLEN)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_FILENAME */ #ifndef HAVE_XDR_FTYPE bool_t xdr_ftype(XDR *xdrs, nfsftype *objp) { enum_t local_obj = *objp; if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_ftype:"); if (!xdr_enum(xdrs, &local_obj)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_FTYPE */ #ifndef HAVE_XDR_GROUPNODE bool_t xdr_groupnode(XDR *xdrs, groupnode *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_groupnode:"); if (!xdr_name(xdrs, &objp->gr_name)) { return (FALSE); } if (!xdr_groups(xdrs, &objp->gr_next)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_GROUPNODE */ #ifndef HAVE_XDR_GROUPS bool_t xdr_groups(XDR *xdrs, groups *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_groups:"); if (!xdr_pointer(xdrs, (char **) objp, sizeof(groupnode), (XDRPROC_T_TYPE) xdr_groupnode)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_GROUPS */ #ifndef HAVE_XDR_LINKARGS bool_t xdr_linkargs(XDR *xdrs, nfslinkargs *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_linkargs:"); if (!xdr_nfs_fh(xdrs, &objp->la_fhandle)) { return (FALSE); } if (!xdr_diropargs(xdrs, &objp->la_to)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_LINKARGS */ #ifndef HAVE_XDR_MOUNTBODY bool_t xdr_mountbody(XDR *xdrs, mountbody *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_mountbody:"); if (!xdr_name(xdrs, &objp->ml_hostname)) { return (FALSE); } if (!xdr_dirpath(xdrs, &objp->ml_directory)) { return (FALSE); } if (!xdr_mountlist(xdrs, &objp->ml_next)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_MOUNTBODY */ #ifndef HAVE_XDR_MOUNTLIST bool_t xdr_mountlist(XDR *xdrs, mountlist *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_mountlist:"); if (!xdr_pointer(xdrs, (char **) objp, sizeof(mountbody), (XDRPROC_T_TYPE) xdr_mountbody)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_MOUNTLIST */ #ifndef HAVE_XDR_NAME bool_t xdr_name(XDR *xdrs, name *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_name:"); if (!xdr_string(xdrs, objp, MNTNAMLEN)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_NAME */ #ifndef HAVE_XDR_NFS_FH bool_t xdr_nfs_fh(XDR *xdrs, am_nfs_fh *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_nfs_fh:"); if (!xdr_opaque(xdrs, (caddr_t) objp->fh_data, NFS_FHSIZE)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_NFS_FH */ #ifndef HAVE_XDR_NFSCOOKIE bool_t xdr_nfscookie(XDR *xdrs, nfscookie objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_nfscookie:"); if (!xdr_opaque(xdrs, objp, NFS_COOKIESIZE)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_NFSCOOKIE */ #ifndef HAVE_XDR_NFSPATH bool_t xdr_nfspath(XDR *xdrs, nfspath *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_nfspath:"); if (!xdr_string(xdrs, objp, NFS_MAXPATHLEN)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_NFSPATH */ #ifndef HAVE_XDR_NFSSTAT bool_t xdr_nfsstat(XDR *xdrs, nfsstat *objp) { enum_t local_obj = *objp; if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_nfsstat:"); if (!xdr_enum(xdrs, &local_obj)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_NFSSTAT */ #ifndef HAVE_XDR_NFSTIME bool_t xdr_nfstime(XDR *xdrs, nfstime *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_nfstime:"); if (!xdr_u_int(xdrs, (u_int *) &objp->nt_seconds)) { return (FALSE); } if (!xdr_u_int(xdrs, (u_int *) &objp->nt_useconds)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_NFSTIME */ #ifndef HAVE_XDR_POINTER bool_t xdr_pointer(register XDR *xdrs, char **objpp, u_int obj_size, XDRPROC_T_TYPE xdr_obj) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_pointer:"); bool_t more_data; more_data = (*objpp != NULL); if (!xdr_bool(xdrs, &more_data)) { return (FALSE); } if (!more_data) { *objpp = NULL; return (TRUE); } return (xdr_reference(xdrs, objpp, obj_size, xdr_obj)); } #endif /* not HAVE_XDR_POINTER */ #ifndef HAVE_XDR_READARGS bool_t xdr_readargs(XDR *xdrs, nfsreadargs *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_readargs:"); if (!xdr_nfs_fh(xdrs, &objp->ra_fhandle)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->ra_offset)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->ra_count)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->ra_totalcount)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_READARGS */ #ifndef HAVE_XDR_READDIRARGS bool_t xdr_readdirargs(XDR *xdrs, nfsreaddirargs *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_readdirargs:"); if (!xdr_nfs_fh(xdrs, &objp->rda_fhandle)) { return (FALSE); } if (!xdr_nfscookie(xdrs, objp->rda_cookie)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->rda_count)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_READDIRARGS */ #ifndef HAVE_XDR_READDIRRES bool_t xdr_readdirres(XDR *xdrs, nfsreaddirres *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_readdirres:"); if (!xdr_nfsstat(xdrs, &objp->rdr_status)) { return (FALSE); } switch (objp->rdr_status) { case NFS_OK: if (!xdr_dirlist(xdrs, &objp->rdr_u.rdr_reply_u)) { return (FALSE); } break; default: break; } return (TRUE); } #endif /* not HAVE_XDR_READDIRRES */ #ifndef HAVE_XDR_READLINKRES bool_t xdr_readlinkres(XDR *xdrs, nfsreadlinkres *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_readlinkres:"); if (!xdr_nfsstat(xdrs, &objp->rlr_status)) { return (FALSE); } switch (objp->rlr_status) { case NFS_OK: if (!xdr_nfspath(xdrs, &objp->rlr_u.rlr_data_u)) { return (FALSE); } break; default: break; } return (TRUE); } #endif /* not HAVE_XDR_READLINKRES */ #ifndef HAVE_XDR_READOKRES bool_t xdr_readokres(XDR *xdrs, nfsreadokres *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_readokres:"); if (!xdr_fattr(xdrs, &objp->raok_attributes)) { return (FALSE); } if (!xdr_bytes(xdrs, (char **) & objp->raok_u.raok_val_u, (u_int *) & objp->raok_u.raok_len_u, NFS_MAXDATA)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_READOKRES */ #ifndef HAVE_XDR_READRES bool_t xdr_readres(XDR *xdrs, nfsreadres *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_readres:"); if (!xdr_nfsstat(xdrs, &objp->rr_status)) { return (FALSE); } switch (objp->rr_status) { case NFS_OK: if (!xdr_readokres(xdrs, &objp->rr_u.rr_reply_u)) { return (FALSE); } break; default: break; } return (TRUE); } #endif /* not HAVE_XDR_READRES */ #ifndef HAVE_XDR_RENAMEARGS bool_t xdr_renameargs(XDR *xdrs, nfsrenameargs *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_renameargs:"); if (!xdr_diropargs(xdrs, &objp->rna_from)) { return (FALSE); } if (!xdr_diropargs(xdrs, &objp->rna_to)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_RENAMEARGS */ #ifndef HAVE_XDR_SATTR bool_t xdr_sattr(XDR *xdrs, nfssattr *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_sattr:"); if (!xdr_u_int(xdrs, &objp->sa_mode)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->sa_uid)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->sa_gid)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->sa_size)) { return (FALSE); } if (!xdr_nfstime(xdrs, &objp->sa_atime)) { return (FALSE); } if (!xdr_nfstime(xdrs, &objp->sa_mtime)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_SATTR */ #ifndef HAVE_XDR_SATTRARGS bool_t xdr_sattrargs(XDR *xdrs, nfssattrargs *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_sattrargs:"); if (!xdr_nfs_fh(xdrs, &objp->sag_fhandle)) { return (FALSE); } if (!xdr_sattr(xdrs, &objp->sag_attributes)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_SATTRARGS */ #ifndef HAVE_XDR_STATFSOKRES bool_t xdr_statfsokres(XDR *xdrs, nfsstatfsokres *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_statfsokres:"); if (!xdr_u_int(xdrs, &objp->sfrok_tsize)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->sfrok_bsize)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->sfrok_blocks)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->sfrok_bfree)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->sfrok_bavail)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_STATFSOKRES */ #ifndef HAVE_XDR_STATFSRES bool_t xdr_statfsres(XDR *xdrs, nfsstatfsres *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_statfsres:"); if (!xdr_nfsstat(xdrs, &objp->sfr_status)) { return (FALSE); } switch (objp->sfr_status) { case NFS_OK: if (!xdr_statfsokres(xdrs, &objp->sfr_u.sfr_reply_u)) { return (FALSE); } break; default: break; } return (TRUE); } #endif /* not HAVE_XDR_STATFSRES */ #ifndef HAVE_XDR_SYMLINKARGS bool_t xdr_symlinkargs(XDR *xdrs, nfssymlinkargs *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_symlinkargs:"); if (!xdr_diropargs(xdrs, &objp->sla_from)) { return (FALSE); } if (!xdr_nfspath(xdrs, &objp->sla_to)) { return (FALSE); } if (!xdr_sattr(xdrs, &objp->sla_attributes)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_SYMLINKARGS */ #ifndef HAVE_XDR_WRITEARGS bool_t xdr_writeargs(XDR *xdrs, nfswriteargs *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_writeargs:"); if (!xdr_nfs_fh(xdrs, &objp->wra_fhandle)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->wra_beginoffset)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->wra_offset)) { return (FALSE); } if (!xdr_u_int(xdrs, &objp->wra_totalcount)) { return (FALSE); } if (!xdr_bytes(xdrs, (char **) & objp->wra_u.wra_val_u, (u_int *) & objp->wra_u.wra_len_u, NFS_MAXDATA)) { return (FALSE); } return (TRUE); } #endif /* not HAVE_XDR_WRITEARGS */ /* * NFS V3 XDR FUNCTIONS: */ #ifdef HAVE_FS_NFS3 bool_t xdr_am_fhandle3(XDR *xdrs, am_fhandle3 *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_am_fhandle3:"); if (!xdr_bytes(xdrs, (char **) &objp->fhandle3_val, (u_int *) &objp->fhandle3_len, AM_FHSIZE3)) return (FALSE); return (TRUE); } bool_t xdr_am_mountstat3(XDR *xdrs, am_mountstat3 *objp) { enum_t local_obj = *objp; if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_am_mountstat3:"); if (!xdr_enum(xdrs, &local_obj)) return (FALSE); return (TRUE); } bool_t xdr_am_mountres3_ok(XDR *xdrs, am_mountres3_ok *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_am_mountres3_ok:"); if (!xdr_am_fhandle3(xdrs, &objp->fhandle)) return (FALSE); if (!xdr_array(xdrs, (char **) ((voidp) &objp->auth_flavors.auth_flavors_val), (u_int *) &objp->auth_flavors.auth_flavors_len, ~0, sizeof(int), (XDRPROC_T_TYPE) xdr_int)) return (FALSE); return (TRUE); } bool_t xdr_am_mountres3(XDR *xdrs, am_mountres3 *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_am_mountres3:"); if (!xdr_am_mountstat3(xdrs, &objp->fhs_status)) return (FALSE); if (objp->fhs_status == AM_MNT3_OK) { if (!xdr_am_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo)) return (FALSE); } return (TRUE); } bool_t xdr_am_diropargs3(XDR *xdrs, am_diropargs3 *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_am_diropargs3:"); if (!xdr_am_nfs_fh3(xdrs, &objp->dir)) return (FALSE); if (!xdr_am_filename3(xdrs, &objp->name)) return (FALSE); return (TRUE); } bool_t xdr_am_filename3(XDR *xdrs, am_filename3 *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_am_filename3:"); if (!xdr_string(xdrs, objp, ~0)) return (FALSE); return (TRUE); } bool_t xdr_am_LOOKUP3args(XDR *xdrs, am_LOOKUP3args *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_am_LOOKUP3args:"); if (!xdr_am_diropargs3(xdrs, &objp->what)) return (FALSE); return (TRUE); } bool_t xdr_am_LOOKUP3res(XDR *xdrs, am_LOOKUP3res *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_am_LOOKUP3res:"); if (!xdr_am_nfsstat3(xdrs, &objp->status)) return (FALSE); switch (objp->status) { case AM_NFS3_OK: if (!xdr_am_LOOKUP3resok(xdrs, &objp->res_u.ok)) return (FALSE); break; default: if (!xdr_am_LOOKUP3resfail(xdrs, &objp->res_u.fail)) return (FALSE); break; } 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)) return (FALSE); #endif /* 0 */ return (TRUE); } bool_t xdr_am_LOOKUP3resok(XDR *xdrs, am_LOOKUP3resok *objp) { if (amuDebug(D_XDRTRACE)) plog(XLOG_DEBUG, "xdr_am_LOOKUP3resok:"); 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)) return (FALSE); if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) return (FALSE); #endif /* 0 */ 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); } #endif /* not HAVE_FS_NFS3 */ am-utils-6.2+rc20110530/libamu/xutil.c000066400000000000000000000642301157065440000171210ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/xutil.c * */ /* * Miscellaneous Utilities: Logging, TTY, timers, signals, RPC, memory, etc. */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #include /* * Logfp is the default logging device, and is initialized to stderr by * default in dplog/plog below, and in * amd/amfs_program.c:amfs_program_exec(). */ FILE *logfp = NULL; static char *am_progname = "unknown"; /* "amd" */ 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 */ u_int debug_flags = D_CONTROL; /* set regardless if compiled with debugging */ #ifdef HAVE_SYSLOG int syslogging; #endif /* HAVE_SYSLOG */ 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) static int mem_bytes; static int orig_mem_bytes; # endif /* not defined(HAVE_MALLINFO) && defined(HAVE_MALLOC_VERIFY) */ #endif /* DEBUG_MEM */ /* forward definitions */ /* for GCC format string auditing */ static void real_plog(int lvl, const char *fmt, va_list vargs) __attribute__((__format__(__printf__, 2, 0))); #ifdef DEBUG /* * List of debug options. */ struct opt_tab dbg_opt[] = { {"all", D_ALL}, /* All non-disruptive options */ {"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", 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 */ {"trace", D_TRACE}, /* Protocol trace */ {"xdrtrace", D_XDRTRACE}, /* Trace xdr routines */ {NULL, 0} }; #endif /* DEBUG */ /* * List of log options */ 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 */ {"error", XLOG_ERROR}, /* Non-fatal system errors */ {"fatal", XLOG_FATAL}, /* Fatal errors */ {"info", XLOG_INFO}, /* Information */ {"map", XLOG_MAP}, /* Map errors */ {"stats", XLOG_STATS}, /* Additional statistical information */ {"user", XLOG_USER}, /* Non-fatal user errors */ {"warn", XLOG_WARNING}, /* Warnings */ {"warning", XLOG_WARNING}, /* Warnings */ {NULL, 0} }; void am_set_progname(char *pn) { am_progname = pn; } const char * am_get_progname(void) { return am_progname; } void am_set_hostname(char *hn) { xstrlcpy(am_hostname, hn, sizeof(am_hostname)); } const char * am_get_hostname(void) { return am_hostname; } pid_t am_set_mypid(void) { am_mypid = getpid(); return am_mypid; } long get_server_pid() { return (long) (foreground ? am_mypid : getppid()); } voidp xmalloc(int len) { voidp p; int retries = 600; /* * Avoid malloc's which return NULL for malloc(0) */ if (len == 0) len = 1; do { p = (voidp) malloc((unsigned) len); if (p) { if (amuDebug(D_MEM)) plog(XLOG_DEBUG, "Allocated size %d; block %p", len, p); return p; } if (retries > 0) { plog(XLOG_ERROR, "Retrying memory allocation"); sleep(1); } } while (--retries); plog(XLOG_FATAL, "Out of memory"); going_down(1); abort(); return 0; } /* like xmalloc, but zeros out the bytes */ voidp xzalloc(int len) { voidp p = xmalloc(len); if (p) memset(p, 0, len); return p; } voidp xrealloc(voidp ptr, int len) { if (amuDebug(D_MEM)) plog(XLOG_DEBUG, "Reallocated size %d; block %p", len, ptr); if (len == 0) len = 1; if (ptr) ptr = (voidp) realloc(ptr, (unsigned) len); else ptr = (voidp) xmalloc((unsigned) len); if (!ptr) { plog(XLOG_FATAL, "Out of memory in realloc"); going_down(1); abort(); } return ptr; } #ifdef DEBUG_MEM void dxfree(char *file, int line, voidp ptr) { if (amuDebug(D_MEM)) plog(XLOG_DEBUG, "Free in %s:%d: block %p", file, line, ptr); /* this is the only place that must NOT use XFREE()!!! */ free(ptr); ptr = NULL; /* paranoid */ } # if defined(HAVE_MALLINFO) && defined(HAVE_MALLOC_VERIFY) static void checkup_mem(void) { struct mallinfo mi = mallinfo(); u_long uordbytes = mi.uordblks * 4096; if (mem_bytes != uordbytes) { if (orig_mem_bytes == 0) mem_bytes = orig_mem_bytes = uordbytes; else { fprintf(logfp, "%s[%ld]: ", am_get_progname(), (long) am_mypid); if (mem_bytes < uordbytes) { fprintf(logfp, "ALLOC: %ld bytes", uordbytes - mem_bytes); } else { fprintf(logfp, "FREE: %ld bytes", mem_bytes - uordbytes); } mem_bytes = uordbytes; fprintf(logfp, ", making %d missing\n", mem_bytes - orig_mem_bytes); } } malloc_verify(); } # endif /* not defined(HAVE_MALLINFO) && defined(HAVE_MALLOC_VERIFY) */ #endif /* DEBUG_MEM */ /* * Take a log format string and expand occurrences of %m * with the current error code taken from errno. Make sure * 'e' never gets longer than maxlen characters. */ static const char * expand_error(const char *f, char *e, size_t maxlen) { const char *p; char *q; int error = errno; int len = 0; for (p = f, q = e; (*q = *p) && (size_t) len < maxlen; len++, q++, p++) { if (p[0] == '%' && p[1] == 'm') { xstrlcpy(q, strerror(error), maxlen); len += strlen(q) - 1; q += strlen(q) - 1; p++; } } e[maxlen-1] = '\0'; /* null terminate, to be sure */ return e; } /* * Output the time of day and hostname to the logfile */ static void show_time_host_and_name(int lvl) { static time_t last_t = 0; static char *last_ctime = NULL; time_t t; #if defined(HAVE_CLOCK_GETTIME) && defined(DEBUG) struct timespec ts; #endif /* defined(HAVE_CLOCK_GETTIME) && defined(DEBUG) */ char nsecs[11]; /* '.' + 9 digits + '\0' */ char *sev; nsecs[0] = '\0'; #if defined(HAVE_CLOCK_GETTIME) && defined(DEBUG) /* * Some systems (AIX 4.3) seem to implement clock_gettime() as stub * returning ENOSYS. */ if (clock_gettime(CLOCK_REALTIME, &ts) == 0) { t = ts.tv_sec; if (amuDebug(D_HRTIME)) xsnprintf(nsecs, sizeof(nsecs), ".%09ld", ts.tv_nsec); } else #endif /* defined(HAVE_CLOCK_GETTIME) && defined(DEBUG) */ t = clocktime(NULL); if (t != last_t) { last_ctime = ctime(&t); last_t = t; } switch (lvl) { case XLOG_FATAL: sev = "fatal:"; break; case XLOG_ERROR: sev = "error:"; break; case XLOG_USER: sev = "user: "; break; case XLOG_WARNING: sev = "warn: "; break; case XLOG_INFO: sev = "info: "; break; case XLOG_DEBUG: sev = "debug:"; break; case XLOG_MAP: sev = "map: "; break; case XLOG_STATS: sev = "stats:"; break; default: sev = "hmm: "; break; } fprintf(logfp, "%15.15s%s %s %s[%ld]/%s ", last_ctime + 4, nsecs, am_get_hostname(), am_get_progname(), (long) am_mypid, sev); } #ifdef DEBUG /* * Switch on/off debug options */ int debug_option(char *opt) { 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, ...) { va_list ap; if (!logfp) logfp = stderr; /* initialize before possible first use */ va_start(ap, fmt); real_plog(XLOG_DEBUG, fmt, ap); va_end(ap); } #endif /* DEBUG */ void plog(int lvl, const char *fmt, ...) { va_list ap; if (!logfp) logfp = stderr; /* initialize before possible first use */ va_start(ap, fmt); real_plog(lvl, fmt, ap); va_end(ap); } static void real_plog(int lvl, const char *fmt, va_list vargs) { char msg[1024]; char efmt[1024]; char *ptr = msg; static char last_msg[1024]; static int last_count = 0, last_lvl = 0; if (!(xlog_level & lvl)) return; #ifdef DEBUG_MEM # if defined(HAVE_MALLINFO) && defined(HAVE_MALLOC_VERIFY) checkup_mem(); # endif /* not defined(HAVE_MALLINFO) && defined(HAVE_MALLOC_VERIFY) */ #endif /* DEBUG_MEM */ /* * Note: xvsnprintf() may call plog() if a truncation happened, but the * latter has some code to break out of an infinite loop. See comment in * xsnprintf() below. */ xvsnprintf(ptr, 1023, expand_error(fmt, efmt, 1024), vargs); ptr += strlen(ptr); if (*(ptr-1) == '\n') *--ptr = '\0'; #ifdef HAVE_SYSLOG if (syslogging) { switch (lvl) { /* from mike */ case XLOG_FATAL: lvl = LOG_CRIT; break; case XLOG_ERROR: lvl = LOG_ERR; break; case XLOG_USER: lvl = LOG_WARNING; break; case XLOG_WARNING: lvl = LOG_WARNING; break; case XLOG_INFO: lvl = LOG_INFO; break; case XLOG_DEBUG: lvl = LOG_DEBUG; break; case XLOG_MAP: lvl = LOG_DEBUG; break; case XLOG_STATS: lvl = LOG_INFO; break; default: lvl = LOG_ERR; break; } syslog(lvl, "%s", msg); return; } #endif /* HAVE_SYSLOG */ *ptr++ = '\n'; *ptr = '\0'; /* * mimic syslog behavior: only write repeated strings if they differ */ switch (last_count) { case 0: /* never printed at all */ last_count = 1; 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 */ __IGNORE(fwrite(msg, ptr - msg, 1, logfp)); fflush(logfp); break; case 1: /* item printed once, if same, don't repeat */ if (STREQ(last_msg, msg)) { last_count++; } else { /* last msg printed once, new one differs */ /* last_count remains at 1 */ 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 */ __IGNORE(fwrite(msg, ptr - msg, 1, logfp)); fflush(logfp); } break; case 100: /* * Don't allow repetitions longer than 100, so you can see when something * cycles like crazy. */ show_time_host_and_name(last_lvl); xsnprintf(last_msg, sizeof(last_msg), "last message repeated %d times\n", last_count); __IGNORE(fwrite(last_msg, strlen(last_msg), 1, logfp)); fflush(logfp); last_count = 0; /* start from scratch */ break; default: /* item repeated multiple times */ if (STREQ(last_msg, msg)) { last_count++; } else { /* last msg repeated+skipped, new one differs */ show_time_host_and_name(last_lvl); xsnprintf(last_msg, sizeof(last_msg), "last message repeated %d times\n", last_count); __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 */ __IGNORE(fwrite(msg, ptr - msg, 1, logfp)); fflush(logfp); } break; } } /* * Display current debug options */ void show_opts(int ch, struct opt_tab *opts) { int i; int s = '{'; fprintf(stderr, "\t[-%c {no}", ch); for (i = 0; opts[i].opt; i++) { fprintf(stderr, "%c%s", s, opts[i].opt); s = ','; } fputs("}]\n", stderr); } int cmdoption(char *s, struct opt_tab *optb, u_int *flags) { char *p = s; int errs = 0; while (p && *p) { int neg; char *opt; struct opt_tab *dp, *dpn = NULL; s = p; p = strchr(p, ','); if (p) *p = '\0'; /* check for "no" prefix to options */ if (s[0] == 'n' && s[1] == 'o') { opt = s + 2; neg = 1; } else { opt = s; neg = 0; } /* * Scan the array of debug options to find the * corresponding flag value. If it is found * then set (or clear) the flag (depending on * whether the option was prefixed with "no"). */ for (dp = optb; dp->opt; dp++) { if (STREQ(opt, dp->opt)) break; if (opt != s && !dpn && STREQ(s, dp->opt)) dpn = dp; } if (dp->opt || dpn) { if (!dp->opt) { dp = dpn; neg = !neg; } if (neg) *flags &= ~dp->flag; else *flags |= dp->flag; } else { /* * This will log to stderr when parsing the command line * since any -l option will not yet have taken effect. */ plog(XLOG_ERROR, "option \"%s\" not recognized", s); errs++; } /* * Put the comma back */ if (p) *p++ = ','; } return errs; } /* * Switch on/off logging options */ int switch_option(char *opt) { u_int xl = xlog_level; int rc = cmdoption(opt, xlog_opt, &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; } #ifdef LOG_DAEMON /* * get syslog facility to use. * logfile can be "syslog", "syslog:daemon", "syslog:local7", etc. */ static int get_syslog_facility(const char *logfile) { char *facstr; /* parse facility string */ facstr = strchr(logfile, ':'); if (!facstr) /* log file was "syslog" */ return LOG_DAEMON; facstr++; if (!facstr || facstr[0] == '\0') { /* log file was "syslog:" */ plog(XLOG_WARNING, "null syslog facility, using LOG_DAEMON"); return LOG_DAEMON; } #ifdef LOG_KERN if (STREQ(facstr, "kern")) return LOG_KERN; #endif /* not LOG_KERN */ #ifdef LOG_USER if (STREQ(facstr, "user")) return LOG_USER; #endif /* not LOG_USER */ #ifdef LOG_MAIL if (STREQ(facstr, "mail")) return LOG_MAIL; #endif /* not LOG_MAIL */ if (STREQ(facstr, "daemon")) return LOG_DAEMON; #ifdef LOG_AUTH if (STREQ(facstr, "auth")) return LOG_AUTH; #endif /* not LOG_AUTH */ #ifdef LOG_SYSLOG if (STREQ(facstr, "syslog")) return LOG_SYSLOG; #endif /* not LOG_SYSLOG */ #ifdef LOG_LPR if (STREQ(facstr, "lpr")) return LOG_LPR; #endif /* not LOG_LPR */ #ifdef LOG_NEWS if (STREQ(facstr, "news")) return LOG_NEWS; #endif /* not LOG_NEWS */ #ifdef LOG_UUCP if (STREQ(facstr, "uucp")) return LOG_UUCP; #endif /* not LOG_UUCP */ #ifdef LOG_CRON if (STREQ(facstr, "cron")) return LOG_CRON; #endif /* not LOG_CRON */ #ifdef LOG_LOCAL0 if (STREQ(facstr, "local0")) return LOG_LOCAL0; #endif /* not LOG_LOCAL0 */ #ifdef LOG_LOCAL1 if (STREQ(facstr, "local1")) return LOG_LOCAL1; #endif /* not LOG_LOCAL1 */ #ifdef LOG_LOCAL2 if (STREQ(facstr, "local2")) return LOG_LOCAL2; #endif /* not LOG_LOCAL2 */ #ifdef LOG_LOCAL3 if (STREQ(facstr, "local3")) return LOG_LOCAL3; #endif /* not LOG_LOCAL3 */ #ifdef LOG_LOCAL4 if (STREQ(facstr, "local4")) return LOG_LOCAL4; #endif /* not LOG_LOCAL4 */ #ifdef LOG_LOCAL5 if (STREQ(facstr, "local5")) return LOG_LOCAL5; #endif /* not LOG_LOCAL5 */ #ifdef LOG_LOCAL6 if (STREQ(facstr, "local6")) return LOG_LOCAL6; #endif /* not LOG_LOCAL6 */ #ifdef LOG_LOCAL7 if (STREQ(facstr, "local7")) return LOG_LOCAL7; #endif /* not LOG_LOCAL7 */ /* didn't match anything else */ plog(XLOG_WARNING, "unknown syslog facility \"%s\", using LOG_DAEMON", facstr); return LOG_DAEMON; } #endif /* not LOG_DAEMON */ /* * Change current logfile */ int switch_to_logfile(char *logfile, int old_umask, int truncate_log) { FILE *new_logfp = stderr; if (logfile) { #ifdef HAVE_SYSLOG syslogging = 0; #endif /* HAVE_SYSLOG */ if (STREQ(logfile, "/dev/stderr")) new_logfp = stderr; else if (NSTREQ(logfile, "syslog", strlen("syslog"))) { #ifdef HAVE_SYSLOG syslogging = 1; new_logfp = stderr; openlog(am_get_progname(), LOG_PID # ifdef LOG_NOWAIT | LOG_NOWAIT # endif /* LOG_NOWAIT */ # ifdef LOG_DAEMON , get_syslog_facility(logfile) # endif /* LOG_DAEMON */ ); #else /* not HAVE_SYSLOG */ plog(XLOG_WARNING, "syslog option not supported, logging unchanged"); #endif /* not HAVE_SYSLOG */ } else { /* regular log file */ (void) umask(old_umask); if (truncate_log) __IGNORE(truncate(logfile, 0)); new_logfp = fopen(logfile, "a"); umask(0); } } /* * If we couldn't open a new file, then continue using the old. */ if (!new_logfp && logfile) { plog(XLOG_USER, "%s: Can't open logfile: %m", logfile); return 1; } /* * Close the previous file */ if (logfp && logfp != stderr) (void) fclose(logfp); logfp = new_logfp; if (logfile) plog(XLOG_INFO, "switched to logfile \"%s\"", logfile); else plog(XLOG_INFO, "no logfile defined; using stderr"); return 0; } void unregister_amq(void) { if (amuDebug(D_AMQ)) { /* find which instance of amd to unregister */ u_long amd_prognum = get_amd_program_number(); if (pmap_unset(amd_prognum, AMQ_VERSION) != 1) dlog("failed to de-register Amd program %lu, version %lu", amd_prognum, AMQ_VERSION); } } void going_down(int rc) { if (foreground) { if (amd_state != Start) { if (amd_state != Done) return; unregister_amq(); } } #ifdef MOUNT_TABLE_ON_FILE /* * Call unlock_mntlist to free any important resources such as an on-disk * lock file (/etc/mtab~). */ unlock_mntlist(); #endif /* MOUNT_TABLE_ON_FILE */ if (foreground) { plog(XLOG_INFO, "Finishing with status %d", rc); } else { dlog("background process exiting with status %d", rc); } /* bye bye... */ exit(rc); } /* return the rpc program number under which amd was used */ u_long get_amd_program_number(void) { return amd_program_number; } /* set the rpc program number used for amd */ void set_amd_program_number(u_long program) { amd_program_number = program; } /* * Release the controlling tty of the process pid. * * Algorithm: try these in order, if available, until one of them * succeeds: setsid(), ioctl(fd, TIOCNOTTY, 0). * Do not use setpgid(): on some OSs it may release the controlling tty, * even if the man page does not mention it, but on other OSs it does not. * Also avoid setpgrp(): it works on some systems, and on others it is * identical to setpgid(). */ void amu_release_controlling_tty(void) { int fd; /* * In daemon mode, leaving open file descriptors to terminals or pipes * can be a really bad idea. * Case in point: the redhat startup script calls us through their 'initlog' * program, which exits as soon as the original amd process exits. If, * at some point, a misbehaved library function decides to print something * to the screen, we get a SIGPIPE and die. * And guess what: NIS glibc functions will attempt to print to stderr * "YPBINDPROC_DOMAIN: Domain not bound" if ypbind is running but can't find * a ypserver. * * So we close all of our "terminal" filedescriptors, i.e. 0, 1 and 2, then * reopen them as /dev/null. * * XXX We should also probably set the SIGPIPE handler to SIG_IGN. */ fd = open("/dev/null", O_RDWR); if (fd < 0) { plog(XLOG_WARNING, "Could not open /dev/null for rw: %m"); } else { fflush(stdin); close(0); dup2(fd, 0); fflush(stdout); close(1); dup2(fd, 1); fflush(stderr); close(2); dup2(fd, 2); close(fd); } #ifdef HAVE_SETSID /* XXX: one day maybe use vhangup(2) */ if (setsid() < 0) { plog(XLOG_WARNING, "Could not release controlling tty using setsid(): %m"); } else { plog(XLOG_INFO, "released controlling tty using setsid()"); return; } #endif /* HAVE_SETSID */ #ifdef TIOCNOTTY fd = open("/dev/tty", O_RDWR); if (fd < 0) { /* not an error if already no controlling tty */ if (errno != ENXIO) plog(XLOG_WARNING, "Could not open controlling tty: %m"); } else { if (ioctl(fd, TIOCNOTTY, 0) < 0 && errno != ENOTTY) plog(XLOG_WARNING, "Could not disassociate tty (TIOCNOTTY): %m"); else plog(XLOG_INFO, "released controlling tty using ioctl(TIOCNOTTY)"); close(fd); } return; #endif /* not TIOCNOTTY */ plog(XLOG_ERROR, "unable to release controlling tty"); } /* setup a single signal handler */ void setup_sighandler(int signum, void (*handler)(int)) { #ifdef HAVE_SIGACTION struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_flags = 0; /* unnecessary */ sa.sa_handler = handler; sigemptyset(&(sa.sa_mask)); /* probably unnecessary too */ sigaddset(&(sa.sa_mask), signum); sigaction(signum, &sa, NULL); #else /* not HAVE_SIGACTION */ (void) signal(signum, handler); #endif /* not HAVE_SIGACTION */ } /* * Return current time in seconds. If passed a non-null argyument, then * fill it in with the current time in seconds and microseconds (useful * for mtime updates). */ time_t clocktime(nfstime *nt) { static struct timeval now; /* keep last time, as default */ if (gettimeofday(&now, NULL) < 0) { plog(XLOG_ERROR, "clocktime: gettimeofday: %m"); /* hack: force time to have incremented by at least 1 second */ now.tv_sec++; } /* copy seconds and microseconds. may demote a long to an int */ if (nt) { nt->nt_seconds = (u_int) now.tv_sec; nt->nt_useconds = (u_int) now.tv_usec; } return (time_t) now.tv_sec; } /* * Make all the directories in the path. */ int mkdirs(char *path, int mode) { /* * take a copy in case path is in readonly store */ char *p2 = strdup(path); char *sp = p2; struct stat stb; int error_so_far = 0; /* * Skip through the string make the directories. * Mostly ignore errors - the result is tested at the end. * * This assumes we are root so that we can do mkdir in a * mode 555 directory... */ while ((sp = strchr(sp + 1, '/'))) { *sp = '\0'; if (mkdir(p2, mode) < 0) { error_so_far = errno; } else { dlog("mkdir(%s)", p2); } *sp = '/'; } if (mkdir(p2, mode) < 0) { error_so_far = errno; } else { dlog("mkdir(%s)", p2); } XFREE(p2); return stat(path, &stb) == 0 && (stb.st_mode & S_IFMT) == S_IFDIR ? 0 : error_so_far; } /* * Remove as many directories in the path as possible. * Give up if the directory doesn't appear to have * been created by Amd (not mode dr-x) or an rmdir * fails for any reason. */ void rmdirs(char *dir) { char *xdp = strdup(dir); char *dp; do { struct stat stb; /* * Try to find out whether this was * created by amd. Do this by checking * for owner write permission. */ if (stat(xdp, &stb) == 0 && (stb.st_mode & 0200) == 0) { if (rmdir(xdp) < 0) { if (errno != ENOTEMPTY && errno != EBUSY && errno != EEXIST && errno != EROFS && errno != EINVAL) plog(XLOG_ERROR, "rmdir(%s): %m", xdp); break; } else { dlog("rmdir(%s)", xdp); } } else { break; } dp = strrchr(xdp, '/'); if (dp) *dp = '\0'; } while (dp && dp > xdp); XFREE(xdp); } am-utils-6.2+rc20110530/ltmain.sh000066400000000000000000010501711157065440000161570ustar00rootroot00000000000000 # libtool (GNU libtool) 2.4 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool 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 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION=2.4 TIMESTAMP="" package_revision=1.3293 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${EGREP="grep -E"} : ${FGREP="grep -F"} : ${GREP="grep"} : ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SED="sed"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=: for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -e 's/\([\\"]\)/\\\1/g' \ -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$dir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_apped perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" if test -n "$hardcode_libdir_flag_spec_ld"; then eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" else eval dep_rpath=\"$hardcode_libdir_flag_spec\" fi fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 am-utils-6.2+rc20110530/m4/000077500000000000000000000000001157065440000146525ustar00rootroot00000000000000am-utils-6.2+rc20110530/m4/GNUmakefile000066400000000000000000000105061157065440000167260ustar00rootroot00000000000000# # THIS MAKEFILE IS FOR am-utils maintainers only! # # GNUmakefile for remaking configuration files. # # Erez Zadok # AUTOCONF=autoconf --localdir=./m4 ./m4/configure.in AUTOHEADER=autoheader --localdir=./m4 ./m4/configure.in #AUTOMAKE=./m4/automake --include-deps --amdir=./m4/amdir #AUTOMAKE=automake --include-deps --no-intermediates --localdir=./m4 #AUTOMAKE=automake --include-deps --localdir=./m4 AUTOMAKE=automake --include-deps --altdir=./m4 ACLOCAL=aclocal --altdir=./m4 MK_ACLOCAL=./mk-aclocal CUTWARNMSG="warning: AC_TRY_RUN called without default to allow cross compilin" CUTWARNMSG2="AC_OUTPUT_COMMANDS|autoupdate" AMFILES=../Makefile.am $(wildcard ../*/Makefile.am) INAMFILES=$(AMFILES:.am=.in) ACFILES=$(wildcard macros/*.m4 macros/HEADER macros/TRAILER m4/aclocal.m4) LOG=/tmp/amu-${USER}.log TOPDIR=.. VPATH= all: testdir ${TOPDIR}/configure config.h.in ${TOPDIR}/Makefile.in \ GNUmakefile stamp-h.in config: all $(TOPDIR)/buildall aux_conf.h.in (cd ${TOPDIR} && ./buildall -c) dconfig: all $(TOPDIR)/buildall aux_conf.h.in (cd ${TOPDIR} && ./buildall -C) qconfig: all $(TOPDIR)/buildall aux_conf.h.in (cd ${TOPDIR} && ./buildall -q) build: all $(TOPDIR)/buildall aux_conf.h.in (cd ${TOPDIR} && ./buildall -b) world: all $(TOPDIR)/buildall aux_conf.h.in (cd ${TOPDIR} && ./buildall) testdir: ${TOPDIR}/amd/amd.c ${TOPDIR}/configure: configure.in aclocal.m4 -(cd ${TOPDIR} && ${AUTOCONF} > configure.new 2> ${LOG}) -@egrep -v ${CUTWARNMSG} ${LOG} > ${LOG}.new ; mv ${LOG}.new ${LOG} @echo '############################################################' @echo 'Checking for "AC_OUTPUT_COMMANDS" warnings:' @echo ' (If you see any output, fix this when autoconf/automake are' @echo ' back in sync in their CVS trees. -ezk, 2/10/00)' -@egrep ${CUTWARNMSG2} ${LOG} -@egrep -v ${CUTWARNMSG2} ${LOG} > ${LOG}.new ; mv ${LOG}.new ${LOG} @echo '############################################################' @if test -s ${LOG}; then cat ${LOG}; exit 2; fi -mv ../configure ../configure.old mv ../configure.new ../configure rm -f ../configure.old chmod a+rx $@ config.h.in: configure.in acconfig.h -(cd ${TOPDIR} && ${AUTOHEADER} > ./m4/config.h.in 2> ${LOG}) -@egrep -v ${CUTWARNMSG} ${LOG} > ${LOG}.new ; mv ${LOG}.new ${LOG} @echo '############################################################' @echo 'Checking for "AC_OUTPUT_COMMANDS" warnings:' @echo ' (If you see any output, fix this when autoconf/automake are' @echo ' back in sync in their CVS trees. -ezk, 2/10/00)' -@egrep ${CUTWARNMSG2} ${LOG} -@egrep -v ${CUTWARNMSG2} ${LOG} > ${LOG}.new ; mv ${LOG}.new ${LOG} @echo '############################################################' @if test -s ${LOG}; then cat ${LOG}; exit 2; fi ${TOPDIR}/Makefile.in: ${AMFILES} configure.in aclocal.m4 (cd ${TOPDIR} && ${AUTOMAKE}) @rm -f ${LOG} aclocal.m4: ${ACFILES} configure.in rm -f $@ ${MK_ACLOCAL} > acinclude.m4 (cd ${TOPDIR} && ${ACLOCAL}) stamp-h.in: ${AMFILES} config.h.in aclocal.m4 aux_conf.h.in echo timestamp > $@ clean: rm -f ${TOPDIR}/configure config.h.in $(INAMFILES) aclocal.m4 stamp.h.in ############################################################################## # maintainer rules to update autoconf/automake/libtool files distributed with # am-utils. -Erez. P1s=/usr/share/automake P2s=/usr/share/libtool P1=/usr/local/gnu/lib/automake P2=/usr/local/gnu/lib/libtool P3=/misc/mirror/gnu/prep/config P4=/misc/mirror/gnu/prep/GNUinfo ICMD=./m4/copy-if-newbig CPCMD=cp -p update: \ config.guess \ config.sub \ doc/texinfo.tex # depcomp \ # install-sh \ # ltconfig \ # ltmain.sh \ # mdate-sh \ # missing \ # mkinstalldirs \ config.guess:: $(P1s)*/config.guess $(ICMD) $? $@ config.guess:: $(P2s)/config.guess $(ICMD) $? $@ config.guess:: $(P3)/config.guess $(ICMD) $? $@ config.sub:: $(P1s)*/config.sub $(ICMD) $? $@ config.sub:: $(P2s)/config.sub $(ICMD) $? $@ config.sub:: $(P3)/config.sub $(ICMD) $? $@ depcomp:: $(P1)/depcomp $(CPCMD) $? $@ install-sh: $(P1)/install-sh $(CPCMD) $? $@ ltconfig: $(P2)/ltconfig $(CPCMD) $? $@ ltmain.sh: $(P2)/ltmain.sh $(CPCMD) $? $@ mdate-sh: $(P1)/mdate-sh $(CPCMD) $? $@ missing: $(P1)/missing $(CPCMD) $? $@ mkinstalldirs: $(P1)/mkinstalldirs $(CPCMD) $? $@ doc/texinfo.tex: $(P4)/texinfo.tex $(CPCMD) $? $@ ############################################################################## am-utils-6.2+rc20110530/m4/amdgrep000077500000000000000000000002071157065440000162160ustar00rootroot00000000000000#!/bin/sh exec egrep -n "$*" \ [a-z]*/*.[hcyl] \ conf/*/*.[hc] \ Makefile.am \ [a-z]*/Makefile.am \ m4/macros/*.m4 am-utils-6.2+rc20110530/m4/amindent000077500000000000000000000075701157065440000164100ustar00rootroot00000000000000#!/bin/sh # indent all am-utils files if [ ! -f amd/amd.c ]; then # maybe we are in a subdir echo cd .. cd .. fi if [ ! -f amd/amd.c ]; then echo "please run $0 from the top level of the am-utils source tree" exit 2 fi # files=" # */*.[hc] # */*.h.in # conf/*/*.[hc] # OLD/*/*.[hc] # " #files="conf/*/*.[hc]" files="specify_the_file.c" sunopts=" -npro -nbad -bap -bbb -nbc -br -ncdb -d0 -di0 -nei -eei -nfc1 -i2 -lp -nsc -TIntFuncPtr -Tadd_fn -Taddrlist -Tam_node -Tam_ops -Tam_opts -Tam_stats -Tamq_mount_info -Tamq_mount_info_list -Tamq_mount_stats -Tamq_mount_tree -Tamq_mount_tree_list -Tamq_mount_tree_p -Tamq_opt -Tamq_setopt -Tamq_string -Tattrstat -Tauto_tree -Tautomount -Tcallout -Tcreateargs -Tdict -Tdict_data -Tdict_ent -Tdirlist -Tdiropargs -Tdiropokres -Tdiropres -Tdirpath -Tdisk_fs -Tentry -Tether_if -Texportnode -Texports -Tfattr -Tfh_cache -Tfhandle -Tfhandle_t -Tfhstatus -Tfilename -Tfserver -Tfsmount -Tftype -Tfwd_fun -Tgid_t -Tgroupnode -Tgroups -Thost -Tioloc -Tkv -Tlinkargs -Tmap_type -Tmnt_map -Tmntfs -Tmntlist -Tmount -Tmountbody -Tmountlist -Tname -Tnfs_fh -Tnfs_private -Tnfscookie -Tnfspath -Tnfsstat -Tnfstime -Tnfsx_mnt -Tnsw_lookup -Tnsw_switchconfig -Topt_apply -Tpid_t -Tpjob -Tqelem -Treadargs -Treaddirargs -Treaddirres -Treadlinkres -Treadokres -Treadres -Trenameargs -Trpc_forward -Tsattr -Tsattrargs -Tserv_state -Tstatfsokres -Tstatfsres -Tsymlinkargs -Ttask_fun -Ttime_t -Ttime_type -Tuid2home_t -Tuid_t -Tusername2uid_t -Tvffserver -Tvfmount_fs -Tvfs_init -Tvfs_match -Tvfumount_fs -Tvmount_fs -Tvmounted -Tvoidp -Tvumount_fs -Tvumounted -Twriteargs " gnuopts=" -npro -nbad -bap -sob -fca -nfc1 -ncdb -br -ce -ss -npcs -cs -nbc -psl -lp -sc -T IntFuncPtr -T add_fn -T addrlist -T am_node -T am_ops -T am_opts -T am_stats -T amq_mount_info -T amq_mount_info_list -T amq_mount_stats -T amq_mount_tree -T amq_mount_tree_list -T amq_mount_tree_p -T amq_opt -T amq_setopt -T amq_string -T attrstat -T auto_tree -T automount -T callout -T createargs -T dict -T dict_data -T dict_ent -T dirlist -T diropargs -T diropokres -T diropres -T dirpath -T disk_fs -T entry -T ether_if -T exportnode -T exports -T fattr -T fh_cache -T fhandle -T fhandle_t -T fhstatus -T filename -T fserver -T fsmount -T ftype -T fwd_fun -T gid_t -T groupnode -T groups -T host -T ioloc -T kv -T linkargs -T map_type -T mnt_map -T mntfs -T mntlist -T mount -T mountbody -T mountlist -T name -T nfs_fh -T nfs_private -T nfscookie -T nfspath -T nfsstat -T nfstime -T nfsx_mnt -T nsw_lookup -T nsw_switchconfig -T opt_apply -T pid_t -T pjob -T qelem -T readargs -T readdirargs -T readdirres -T readlinkres -T readokres -T readres -T renameargs -T rpc_forward -T sattr -T sattrargs -T serv_state -T statfsokres -T statfsres -T symlinkargs -T task_fun -T time_t -T time_type -T uid2home_t -T uid_t -T username2uid_t -T vffserver -T vfmount_fs -T vfs_init -T vfs_match -T vfumount_fs -T vmount_fs -T vmounted -T voidp -T vumount_fs -T vumounted -T writeargs " #prefix=".C" # check args if [ $# -lt 1 ]; then echo "Usage: $0 <-g|-s> [files...]" exit 1 fi if [ $1 = "-g" -o "$1" = "-s" ]; then OPT=$1 shift else echo "Usage: $0 <-g|-s> [files...]" exit 1 fi # check if specified files to process if [ $# -gt 0 ]; then files="$*" fi for i in ${files}; do if [ ! -f $i ]; then echo "No such file: $i" continue fi case $OPT in -g ) icmd="/usr/local/gnu/bin/indent" cmd="${icmd} $i -o $i$prefix $gnuopts" showcmd="${icmd} $i -o $i$prefix" ;; -s ) icmd="/opt/SUNWspro/bin/indent" cmd="${icmd} $i $i$prefix $sunopts" showcmd="${icmd} $i $i$prefix" ;; * ) echo "Usage: $0 <-g|-s>" exit 1 ;; esac echo ${showcmd} ${cmd} if [ $? != 0 ]; then echo Failed! exit $? fi # remove trailing spaces cmd="./m4/rmtspc $i" echo ${cmd} ${cmd} if [ $? != 0 ]; then echo Failed! exit $? fi done am-utils-6.2+rc20110530/m4/autopat000077500000000000000000000013501157065440000162540ustar00rootroot00000000000000#!/bin/bash -norc # find patterns of cache entries to automatically remove from config.cache # Used by am-utils developers. # Erez Zadok #set -x macdir="../m4/macros" # find the right directory if [ ! -d $macdir ]; then echo "Could not find $macdir directory." exit 2 fi # skip if no config.cache file if [ ! -f config.cache ]; then echo "Not in the A.cpu-company-system." exit 2 fi # look for files that changed vs. config.cache pat="" for i in ${macdir}/*.m4; do if test $i -nt config.cache; then n=`egrep '^ac_cv_' $i |sed 's/[^a-zA-Z0-9_].*//g'|sort|uniq` if test -z "$n"; then continue; fi if test -z "$pat"; then pat="$n" else pat="$pat|$n" fi fi done echo "$pat" am-utils-6.2+rc20110530/m4/chop-aclocal.pl000077500000000000000000000006101157065440000175340ustar00rootroot00000000000000#!/bin/perl -w $seq = 1; $file = ""; $file = sprintf("tmp/%02d.m4", $seq); open(FILE, ">$file") || die "cannot open \"$file\": $!"; printf(STDOUT "FILE: $file\n"); while (<>) { if (/^$/) { close(FILE); $seq++; $file = sprintf("tmp/%02d.m4", $seq); open(FILE, ">$file") || die "cannot open \"$file\": $!"; printf(STDOUT "FILE: $file\n"); next; } printf FILE; } close(FILE); am-utils-6.2+rc20110530/m4/copy-if-newbig000077500000000000000000000014061157065440000174200ustar00rootroot00000000000000#!/usr/bin/perl -w # copy a file if it is both newer and bigger in size # if copying, first rename older file to .orig $src = $ARGV[0]; $dst = $ARGV[1]; # dev,ino,mode,nlink,uid,gid,rdev,size,atime,mtime,ctime,blksize,blocks @srcstat = stat($src); @dststat = stat($dst); $srcsize = $srcstat[7]; $srcmtime = $srcstat[9]; $dstsize = $dststat[7]; $dstmtime = $dststat[9]; # copy if src file is bigger and newer if ($srcsize > $dstsize && $srcmtime > $dstmtime) { print "mv -f $dst $dst.orig\n"; system("mv -f $dst $dst.orig"); print "cp -p $src $dst\n"; system("cp -p $src $dst"); die "cp command failed" if ($? != 0); } # make sure dst file has newer timestamp if ($srcmtime > $dstmtime) { print "touch $dst\n"; system("touch $dst"); } exit(0); am-utils-6.2+rc20110530/m4/macros/000077500000000000000000000000001157065440000161365ustar00rootroot00000000000000am-utils-6.2+rc20110530/m4/macros/HEADER000066400000000000000000000010101157065440000170010ustar00rootroot00000000000000dnl aclocal.m4 file for am-utils-6.x dnl Contains definitions for specialized GNU-autoconf macros. dnl Author: Erez Zadok dnl dnl DO NOT EDIT DIRECTLY! Generated automatically by maintainers from dnl m4/GNUmakefile! dnl dnl ###################################################################### dnl UNCOMMENT THE NEXT FEW LINES FOR DEBUGGING CONFIGURE dnl define([AC_CACHE_LOAD], )dnl dnl define([AC_CACHE_SAVE], )dnl dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/TRAILER000066400000000000000000000001621157065440000171620ustar00rootroot00000000000000dnl ###################################################################### dnl end of aclocal.m4 for am-utils-6.x am-utils-6.2+rc20110530/m4/macros/c_void_p.m4000066400000000000000000000007741157065440000201720ustar00rootroot00000000000000dnl ###################################################################### dnl check if compiler can handle "void *" AC_DEFUN([AMU_C_VOID_P], [ AC_CACHE_CHECK(if compiler can handle void *, ac_cv_c_void_p, [ # try to compile a program which uses void * AC_TRY_COMPILE( [ ], [ void *vp; ], ac_cv_c_void_p=yes, ac_cv_c_void_p=no) ]) if test "$ac_cv_c_void_p" = yes then AC_DEFINE(voidp, void *) else AC_DEFINE(voidp, char *) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/cache_check_dynamic.m4000066400000000000000000000020541157065440000223050ustar00rootroot00000000000000dnl ###################################################################### dnl New versions of the cache functions which also dynamically evaluate the dnl cache-id field, so that it may contain shell variables to expand dnl dynamically for the creation of $ac_cv_* variables on the fly. dnl In addition, this function allows you to call COMMANDS which generate dnl output on the command line, because it prints its own AC_MSG_CHECKING dnl after COMMANDS are run. dnl dnl ====================================================================== dnl AMU_CACHE_CHECK_DYNAMIC(MESSAGE, CACHE-ID, COMMANDS) define(AMU_CACHE_CHECK_DYNAMIC, [ ac_tmp=`echo $2` if eval "test \"`echo '$''{'$ac_tmp'+set}'`\" = set"; then AC_MSG_CHECKING([$1]) echo $ECHO_N "(cached) $ECHO_C" 1>&AS_MESSAGE_FD([]) dnl XXX: for older autoconf versions dnl echo $ac_n "(cached) $ac_c" 1>&AS_MESSAGE_FD([]) else $3 AC_MSG_CHECKING([$1]) fi ac_tmp_val=`eval eval "echo '$''{'$ac_tmp'}'"` AC_MSG_RESULT($ac_tmp_val) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_amu_fs.m4000066400000000000000000000025161157065440000210130ustar00rootroot00000000000000dnl ###################################################################### dnl check if an automounter filesystem exists (it almost always does). dnl Usage: AC_CHECK_AMU_FS(, , []) dnl Print the message in , and declare HAVE_AMU_FS_ true. dnl If is defined, then define this filesystem as tru only of the dnl filesystem for is true. AC_DEFUN([AMU_CHECK_AMU_FS], [ # store variable name of fs ac_upcase_am_fs_name=`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ac_safe=HAVE_AMU_FS_$ac_upcase_am_fs_name # check for cache and set it if needed AMU_CACHE_CHECK_DYNAMIC(for $2 filesystem ($1), ac_cv_am_fs_$1, [ # true by default eval "ac_cv_am_fs_$1=yes" # if exists but is defined to "no", set this filesystem to no. if test -n "$3" then # flse by default if arg 3 was supplied eval "ac_cv_am_fs_$1=no" if test "`eval echo '$''{ac_cv_fs_'$3'}'`" = yes then eval "ac_cv_am_fs_$1=yes" fi # some filesystems do not have a mnttab entry, but exist based on headers if test "`eval echo '$''{ac_cv_fs_header_'$3'}'`" = yes then eval "ac_cv_am_fs_$1=yes" fi fi ]) # check if need to define variable if test "`eval echo '$''{ac_cv_am_fs_'$1'}'`" = yes then AC_DEFINE_UNQUOTED($ac_safe) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_autofs_style.m4000066400000000000000000000025741157065440000222660ustar00rootroot00000000000000dnl ###################################################################### dnl check the autofs flavor AC_DEFUN([AMU_CHECK_AUTOFS_STYLE], [ AC_CACHE_CHECK(autofs style, ac_cv_autofs_style, [ # select the correct style to mount(2) a filesystem case "${host_os}" in solaris1* | solaris2.[[0-4]] ) ac_cv_autofs_style=default ;; solaris2.5* ) ac_cv_autofs_style=solaris_v1 ;; # Solaris 8+ uses the AutoFS V3/V4 protocols, but they are very similar # to V2, so use one style for all. solaris* ) ac_cv_autofs_style=solaris_v2_v3 ;; irix6* ) ac_cv_autofs_style=solaris_v1 ;; linux* ) ac_cv_autofs_style=linux ;; * ) ac_cv_autofs_style=default ;; esac ]) # always make a link and include the file name, otherwise on systems where # autofs support has not been ported yet check_fs_{headers, mntent}.m4 add # ops_autofs.o to AMD_FS_OBJS, but there's no way to build it. am_utils_link_files=${am_utils_link_files}amd/ops_autofs.c:conf/autofs/autofs_${ac_cv_autofs_style}.c" "amu_autofs_prot.h:conf/autofs/autofs_${ac_cv_autofs_style}.h" " # set headers in a macro for Makefile.am files to use (for dependencies) AMU_AUTOFS_PROT_HEADER='${top_builddir}/'amu_autofs_prot.h AC_SUBST(AMU_AUTOFS_PROT_HEADER) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_checkmount_style.m4000066400000000000000000000017001157065440000231130ustar00rootroot00000000000000dnl ###################################################################### dnl check style of fixmount check_mount() function AC_DEFUN([AMU_CHECK_CHECKMOUNT_STYLE], [ AC_CACHE_CHECK(style of fixmount check_mount(), ac_cv_style_checkmount, [ # select the correct style for unmounting filesystems case "${host_os_name}" in svr4* | sysv4* | solaris2* | sunos5* ) ac_cv_style_checkmount=svr4 ;; bsd44* | bsdi* | freebsd* | netbsd* | openbsd* | darwin* | macosx* | rhapsody* ) ac_cv_style_checkmount=bsd44 ;; aix* ) ac_cv_style_checkmount=aix ;; osf* ) ac_cv_style_checkmount=osf ;; ultrix* ) ac_cv_style_checkmount=ultrix ;; * ) ac_cv_style_checkmount=default ;; esac ]) am_utils_checkmount_style_file="check_mount.c" am_utils_link_files=${am_utils_link_files}fixmount/${am_utils_checkmount_style_file}:conf/checkmount/checkmount_${ac_cv_style_checkmount}.c" " ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_extern.m4000066400000000000000000000065131157065440000210470ustar00rootroot00000000000000dnl ###################################################################### dnl check for external definition for a function (not external variables) dnl Usage AMU_CHECK_EXTERN(extern) dnl Checks for external definition for "extern" that is delimited on the dnl left and the right by a character that is not a valid symbol character. dnl dnl Note that $pattern below is very carefully crafted to match any system dnl external definition, with __P posix prototypes, with or without an extern dnl word, etc. Think twice before changing this. AC_DEFUN([AMU_CHECK_EXTERN], [ # store variable name for external definition ac_upcase_extern_name=`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ac_safe=HAVE_EXTERN_$ac_upcase_extern_name # check for cached value and set it if needed AMU_CACHE_CHECK_DYNAMIC(external function definition for $1, ac_cv_extern_$1, [ # the old pattern assumed that the complete external definition is on one # line but on some systems it is split over several lines, so only match # beginning of the extern definition including the opening parenthesis. #pattern="(extern)?.*[^a-zA-Z0-9_]$1[^a-zA-Z0-9_]?.*\(.*\).*;" pattern="(extern)?.*[[^a-zA-Z0-9_]]$1[[^a-zA-Z0-9_]]?.*\(" AC_EGREP_CPP(${pattern}, [ #ifdef HAVE_SYS_TYPES_H # include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_WAIT_H # include #endif /* HAVE_SYS_WAIT_H */ #if TIME_WITH_SYS_TIME # include # include #else /* not TIME_WITH_SYS_TIME */ # if HAVE_SYS_TIME_H # include # else /* not HAVE_SYS_TIME_H */ # include # endif /* not HAVE_SYS_TIME_H */ #endif /* not TIME_WITH_SYS_TIME */ #if defined(_AIX) && defined(HAVE_SYS_VMOUNT_H) # include #endif /* defined(_AIX) && defined(HAVE_SYS_VMOUNT_H) */ #ifdef HAVE_STDIO_H # include #endif /* HAVE_STDIO_H */ #ifdef HAVE_STDLIB_H # include #endif /* HAVE_STDLIB_H */ #if HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ #if HAVE_STRING_H # include #endif /* HAVE_STRING_H */ #ifdef HAVE_STRINGS_H # include #endif /* HAVE_STRINGS_H */ #ifdef HAVE_NETDB_H # include #endif /* HAVE_NETDB_H */ #ifdef HAVE_CLUSTER_H # include #endif /* HAVE_CLUSTER_H */ #ifdef HAVE_RPC_RPC_H /* * Turn on PORTMAP, so that additional header files would get included * and the important definition for UDPMSGSIZE is included too. */ # ifndef PORTMAP # define PORTMAP # endif /* not PORTMAP */ # include # ifndef XDRPROC_T_TYPE typedef bool_t (*xdrproc_t) __P ((XDR *, __ptr_t, ...)); # endif /* not XDRPROC_T_TYPE */ #endif /* HAVE_RPC_RPC_H */ #if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) # include #endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) */ ], eval "ac_cv_extern_$1=yes", eval "ac_cv_extern_$1=no") ]) # check if need to define variable if test "`eval echo '$''{ac_cv_extern_'$1'}'`" = yes then AC_DEFINE_UNQUOTED($ac_safe) fi ]) dnl ====================================================================== dnl ###################################################################### dnl run AMU_CHECK_EXTERN on each argument given dnl Usage: AMU_CHECK_EXTERNS(arg arg arg ...) AC_DEFUN([AMU_CHECK_EXTERNS], [ for ac_tmp_arg in $1 do AMU_CHECK_EXTERN($ac_tmp_arg) done ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_extern_ldap.m4000066400000000000000000000062111157065440000220420ustar00rootroot00000000000000dnl ###################################################################### dnl check for external definition for an LDAP function (not external variables) dnl Usage AMU_CHECK_EXTERN_LDAP(extern) dnl Checks for external definition for "extern" that is delimited on the dnl left and the right by a character that is not a valid symbol character. dnl dnl Note that $pattern below is very carefully crafted to match any system dnl external definition, with __P posix prototypes, with or without an extern dnl word, etc. Think twice before changing this. AC_DEFUN([AMU_CHECK_EXTERN_LDAP], [ # store variable name for external definition ac_upcase_extern_name=`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ac_safe=HAVE_EXTERN_$ac_upcase_extern_name # check for cached value and set it if needed AMU_CACHE_CHECK_DYNAMIC(external function definition for $1, ac_cv_extern_$1, [ # the old pattern assumed that the complete external definition is on one # line but on some systems it is split over several lines, so only match # beginning of the extern definition including the opening parenthesis. #pattern="(extern)?.*[^a-zA-Z0-9_]$1[^a-zA-Z0-9_]?.*\(.*\).*;" dnl This expression is a bit different than check_extern.m4 because of the dnl way that openldap wrote their externs in . pattern="(extern)?.*([[^a-zA-Z0-9_]])?$1[[^a-zA-Z0-9_]]?.*\(" AC_EGREP_CPP(${pattern}, [ #ifdef HAVE_SYS_TYPES_H # include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_WAIT_H # include #endif /* HAVE_SYS_WAIT_H */ #if TIME_WITH_SYS_TIME # include # include #else /* not TIME_WITH_SYS_TIME */ # if HAVE_SYS_TIME_H # include # else /* not HAVE_SYS_TIME_H */ # include # endif /* not HAVE_SYS_TIME_H */ #endif /* not TIME_WITH_SYS_TIME */ #ifdef HAVE_STDIO_H # include #endif /* HAVE_STDIO_H */ #ifdef HAVE_STDLIB_H # include #endif /* HAVE_STDLIB_H */ #if HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ #if HAVE_STRING_H # include #endif /* HAVE_STRING_H */ #ifdef HAVE_STRINGS_H # include #endif /* HAVE_STRINGS_H */ #ifdef HAVE_NETDB_H # include #endif /* HAVE_NETDB_H */ #ifdef HAVE_CLUSTER_H # include #endif /* HAVE_CLUSTER_H */ #ifdef HAVE_RPC_RPC_H /* * Turn on PORTMAP, so that additional header files would get included * and the important definition for UDPMSGSIZE is included too. */ # ifndef PORTMAP # define PORTMAP # endif /* not PORTMAP */ # include # ifndef XDRPROC_T_TYPE typedef bool_t (*xdrproc_t) __P ((XDR *, __ptr_t, ...)); # endif /* not XDRPROC_T_TYPE */ #endif /* HAVE_RPC_RPC_H */ #if defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) # include #endif /* defined(HAVE_TCPD_H) && defined(HAVE_LIBWRAP) */ #ifdef HAVE_LDAP_H # include #endif /* HAVE_LDAP_H */ #ifdef HAVE_LBER_H # include #endif /* HAVE_LBER_H */ ], eval "ac_cv_extern_$1=yes", eval "ac_cv_extern_$1=no") ]) # check if need to define variable if test "`eval echo '$''{ac_cv_extern_'$1'}'`" = yes then AC_DEFINE_UNQUOTED($ac_safe) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_fhandle.m4000066400000000000000000000011641157065440000211400ustar00rootroot00000000000000dnl ###################################################################### dnl Find if type 'fhandle' exists AC_DEFUN([AMU_CHECK_FHANDLE], [ AC_CACHE_CHECK(if plain fhandle type exists, ac_cv_have_fhandle, [ # try to compile a program which may have a definition for the type # set to a default value ac_cv_have_fhandle=no # look for "struct nfs_fh" if test "$ac_cv_have_fhandle" = no then AC_TRY_COMPILE_NFS( [ fhandle a; ], ac_cv_have_fhandle=yes, ac_cv_have_fhandle=no) fi ]) if test "$ac_cv_have_fhandle" != no then AC_DEFINE(HAVE_FHANDLE) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_field.m4000066400000000000000000000072071157065440000206260ustar00rootroot00000000000000dnl ###################################################################### dnl FIXED VERSION OF AUTOCONF 2.59 AC_CHECK_MEMBER. g/cc will fail to check dnl a member if the .member is itself a data structure, because you cannot dnl compare, in C, a data structure against NULL; you can compare a native dnl data type (int, char) or a pointer. Solution: do what I did in my dnl original member checking macro: try to take the address of the member. dnl You can always take the address of anything. dnl -Erez Zadok, Feb 19, 2005. dnl # AC_CHECK_MEMBER2(AGGREGATE.MEMBER, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], # [INCLUDES]) # --------------------------------------------------------- # AGGREGATE.MEMBER is for instance `struct passwd.pw_gecos', shell # variables are not a valid argument. AC_DEFUN([AC_CHECK_MEMBER2], [AS_LITERAL_IF([$1], [], [AC_FATAL([$0: requires literal arguments])])dnl m4_bmatch([$1], [\.], , [m4_fatal([$0: Did not see any dot in `$1'])])dnl AS_VAR_PUSHDEF([ac_Member], [ac_cv_member_$1])dnl dnl Extract the aggregate name, and the member name AC_CACHE_CHECK([for $1], ac_Member, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])], [dnl AGGREGATE ac_aggr; static m4_bpatsubst([$1], [\..*]) ac_aggr; dnl ac_aggr.MEMBER; if (&(ac_aggr.m4_bpatsubst([$1], [^[^.]*\.]))) return 0;])], [AS_VAR_SET(ac_Member, yes)], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])], [dnl AGGREGATE ac_aggr; static m4_bpatsubst([$1], [\..*]) ac_aggr; dnl sizeof ac_aggr.MEMBER; if (sizeof ac_aggr.m4_bpatsubst([$1], [^[^.]*\.])) return 0;])], [AS_VAR_SET(ac_Member, yes)], [AS_VAR_SET(ac_Member, no)])])]) AS_IF([test AS_VAR_GET(ac_Member) = yes], [$2], [$3])dnl AS_VAR_POPDEF([ac_Member])dnl ])# AC_CHECK_MEMBER # AC_CHECK_MEMBERS2([AGGREGATE.MEMBER, ...], # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND] # [INCLUDES]) # --------------------------------------------------------- # The first argument is an m4 list. AC_DEFUN([AC_CHECK_MEMBERS2], [m4_foreach([AC_Member], [$1], [AC_CHECK_MEMBER2(AC_Member, [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_Member), 1, [Define to 1 if `]m4_bpatsubst(AC_Member, [^[^.]*\.])[' is member of `]m4_bpatsubst(AC_Member, [\..*])['.]) $2], [$3], [$4])])]) dnl ###################################################################### dnl find if structure $1 has field field $2 AC_DEFUN([AMU_CHECK_FIELD], [ AC_CHECK_MEMBERS2($1, , ,[ AMU_MOUNT_HEADERS( [ /* now set the typedef */ #ifdef HAVE_STRUCT_MNTENT typedef struct mntent mntent_t; #else /* not HAVE_STRUCT_MNTENT */ # ifdef HAVE_STRUCT_MNTTAB typedef struct mnttab mntent_t; # endif /* HAVE_STRUCT_MNTTAB */ #endif /* not HAVE_STRUCT_MNTENT */ /* * for various filesystem specific mount arguments */ #ifdef HAVE_SYS_FS_EFS_CLNT_H # include #endif /* HAVE_SYS_FS_EFS_CLNT_H */ #ifdef HAVE_SYS_FS_XFS_CLNT_H # include #endif /* HAVE_SYS_FS_XFS_CLNT_H */ #ifdef HAVE_SYS_FS_UFS_MOUNT_H # include #endif /* HAVE_SYS_FS_UFS_MOUNT_H */ #ifdef HAVE_SYS_FS_AUTOFS_H # include #endif /* HAVE_SYS_FS_AUTOFS_H */ #ifdef HAVE_RPCSVC_AUTOFS_PROT_H # include #else /* not HAVE_RPCSVC_AUTOFS_PROT_H */ # ifdef HAVE_SYS_FS_AUTOFS_PROT_H # include # endif /* HAVE_SYS_FS_AUTOFS_PROT_H */ #endif /* not HAVE_RPCSVC_AUTOFS_PROT_H */ #ifdef HAVE_HSFS_HSFS_H # include #endif /* HAVE_HSFS_HSFS_H */ #ifdef HAVE_IFADDRS_H # include #endif /* HAVE_IFADDRS_H */ ]) ]) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_fs_headers.m4000066400000000000000000000033301157065440000216370ustar00rootroot00000000000000dnl ###################################################################### dnl check if a filesystem exists (if any of its header files exist). dnl Usage: AC_CHECK_FS_HEADERS(..., , []) dnl Check if any of the headers exist. If any exist, then dnl define HAVE_FS_. If exits, then define dnl HAVE_FS_ instead... AC_DEFUN([AMU_CHECK_FS_HEADERS], [ # find what name to give to the fs if test -n "$3" then ac_fs_name=$3 else ac_fs_name=$2 fi # store variable name of fs ac_upcase_fs_name=`echo $2 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ac_fs_headers_safe=HAVE_FS_$ac_upcase_fs_name # check for cache and set it if needed AMU_CACHE_CHECK_DYNAMIC(for $ac_fs_name filesystem in <$1>, ac_cv_fs_header_$ac_fs_name, [ # define to "no" by default eval "ac_cv_fs_header_$ac_fs_name=no" # and look to see if it was found AC_CHECK_HEADERS($1, [ eval "ac_cv_fs_header_$ac_fs_name=yes" break ])]) # check if need to define variable if test "`eval echo '$''{ac_cv_fs_header_'$ac_fs_name'}'`" = yes then AC_DEFINE_UNQUOTED($ac_fs_headers_safe) # append ops_.o object to AMD_FS_OBJS for automatic compilation # if first time we add something to this list, then also tell autoconf # to replace instances of it in Makefiles. if test -z "$AMD_FS_OBJS" then AMD_FS_OBJS="ops_${ac_fs_name}.o" AC_SUBST(AMD_FS_OBJS) else # since this object file could have already been added before # we need to ensure we do not add it twice. case "${AMD_FS_OBJS}" in *ops_${ac_fs_name}.o* ) ;; * ) AMD_FS_OBJS="$AMD_FS_OBJS ops_${ac_fs_name}.o" ;; esac fi fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_fs_mntent.m4000066400000000000000000000117531157065440000215410ustar00rootroot00000000000000dnl ###################################################################### dnl check if a filesystem type exists (if its header files exist) dnl Usage: AC_CHECK_FS_MNTENT(, []) dnl dnl Check in some headers for MNTTYPE_ macro. If that exist, dnl then define HAVE_FS_. If exits, then define dnl HAVE_FS_ instead... AC_DEFUN([AMU_CHECK_FS_MNTENT], [ # find what name to give to the fs if test -n "$2" then ac_fs_name=$2 ac_fs_as_name=" (from: $1)" else ac_fs_name=$1 ac_fs_as_name="" fi # store variable name of filesystem ac_upcase_fs_name=`echo $ac_fs_name | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ac_safe=HAVE_FS_$ac_upcase_fs_name # check for cache and set it if needed AMU_CACHE_CHECK_DYNAMIC(for $ac_fs_name$ac_fs_as_name mntent definition, ac_cv_fs_$ac_fs_name, [ # assume not found eval "ac_cv_fs_$ac_fs_name=no" for ac_fs_tmp in $1 do ac_upcase_fs_symbol=`echo $ac_fs_tmp | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` # first look for MNTTYPE_* AC_EGREP_CPP(yes, AMU_MOUNT_HEADERS( [ #ifdef MNTTYPE_$ac_upcase_fs_symbol yes #endif /* MNTTYPE_$ac_upcase_fs_symbol */ ]), [eval "ac_cv_fs_$ac_fs_name=yes"], [eval "ac_cv_fs_$ac_fs_name=no"] ) # check if need to terminate "for" loop if test "`eval echo '$''{ac_cv_fs_'$ac_fs_name'}'`" != no then break fi # now try to look for MOUNT_ macro AC_EGREP_CPP(yes, AMU_MOUNT_HEADERS( [ #ifdef MOUNT_$ac_upcase_fs_symbol yes #endif /* MOUNT_$ac_upcase_fs_symbol */ ]), [eval "ac_cv_fs_$ac_fs_name=yes"], [eval "ac_cv_fs_$ac_fs_name=no"] ) # check if need to terminate "for" loop if test "`eval echo '$''{ac_cv_fs_'$ac_fs_name'}'`" != no then break fi # now try to look for MNT_ macro AC_EGREP_CPP(yes, AMU_MOUNT_HEADERS( [ #ifdef MNT_$ac_upcase_fs_symbol yes #endif /* MNT_$ac_upcase_fs_symbol */ ]), [eval "ac_cv_fs_$ac_fs_name=yes"], [eval "ac_cv_fs_$ac_fs_name=no"] ) # check if need to terminate "for" loop if test "`eval echo '$''{ac_cv_fs_'$ac_fs_name'}'`" != no then break fi # now try to look for GT_ macro (ultrix) AC_EGREP_CPP(yes, AMU_MOUNT_HEADERS( [ #ifdef GT_$ac_upcase_fs_symbol yes #endif /* GT_$ac_upcase_fs_symbol */ ]), [eval "ac_cv_fs_$ac_fs_name=yes"], [eval "ac_cv_fs_$ac_fs_name=no"] ) # check if need to terminate "for" loop if test "`eval echo '$''{ac_cv_fs_'$ac_fs_name'}'`" != no then break fi # look for a loadable filesystem module (linux) if test -f /lib/modules/$host_os_version/fs/$ac_fs_tmp.ko then eval "ac_cv_fs_$ac_fs_name=yes" break fi if test -f /lib/modules/$host_os_version/fs/$ac_fs_tmp.o then eval "ac_cv_fs_$ac_fs_name=yes" break fi # look for a loadable filesystem module (linux 2.4+) if test -f /lib/modules/$host_os_version/kernel/fs/$ac_fs_tmp/$ac_fs_tmp.ko then eval "ac_cv_fs_$ac_fs_name=yes" break fi if test -f /lib/modules/$host_os_version/kernel/fs/$ac_fs_tmp/$ac_fs_tmp.o then eval "ac_cv_fs_$ac_fs_name=yes" break fi # look for a loadable filesystem module (linux redhat-5.1) if test -f /lib/modules/preferred/fs/$ac_fs_tmp.ko then eval "ac_cv_fs_$ac_fs_name=yes" break fi if test -f /lib/modules/preferred/fs/$ac_fs_tmp.o then eval "ac_cv_fs_$ac_fs_name=yes" break fi # in addition look for statically compiled filesystem (linux) if egrep "[[^a-zA-Z0-9_]]$ac_fs_tmp$" /proc/filesystems >/dev/null 2>&1 then eval "ac_cv_fs_$ac_fs_name=yes" break fi if test "$ac_fs_tmp" = "nfs3" -a "$ac_cv_header_linux_nfs_mount_h" = "yes" then # hack hack hack # in 6.1, which has fallback to v2/udp, we might want # to always use version 4. # in 6.0 we do not have much choice # let nfs_mount_version="`grep NFS_MOUNT_VERSION /usr/include/linux/nfs_mount.h | awk '{print $''3;}'`" if test $nfs_mount_version -ge 4 then eval "ac_cv_fs_$ac_fs_name=yes" break fi fi # run a test program for bsdi3 AC_TRY_RUN( [ #include #include main() { int i; struct vfsconf vf; i = getvfsbyname("$ac_fs_tmp", &vf); if (i < 0) exit(1); else exit(0); } ], [eval "ac_cv_fs_$ac_fs_name=yes" break ] ) done ]) # check if need to define variable if test "`eval echo '$''{ac_cv_fs_'$ac_fs_name'}'`" = yes then AC_DEFINE_UNQUOTED($ac_safe) # append ops_.o object to AMD_FS_OBJS for automatic compilation # if first time we add something to this list, then also tell autoconf # to replace instances of it in Makefiles. if test -z "$AMD_FS_OBJS" then AMD_FS_OBJS="ops_${ac_fs_name}.o" AC_SUBST(AMD_FS_OBJS) else # since this object file could have already been added before # we need to ensure we do not add it twice. case "${AMD_FS_OBJS}" in *ops_${ac_fs_name}.o* ) ;; * ) AMD_FS_OBJS="$AMD_FS_OBJS ops_${ac_fs_name}.o" ;; esac fi fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_gnu_getopt.m4000066400000000000000000000015131157065440000217100ustar00rootroot00000000000000dnl ###################################################################### dnl Do we have a GNUish getopt AC_DEFUN([AMU_CHECK_GNU_GETOPT], [ AC_CACHE_CHECK([for GNU getopt], ac_cv_sys_gnu_getopt, [ AC_TRY_RUN([ #include #include int main() { int argc = 3; char *argv[] = { "actest", "arg", "-x", NULL }; int c; FILE* rf; int isGNU = 0; rf = fopen("conftestresult", "w"); if (rf == NULL) exit(1); while ( (c = getopt(argc, argv, "x")) != -1 ) { switch ( c ) { case 'x': isGNU=1; break; default: exit(1); } } fprintf(rf, isGNU ? "yes" : "no"); exit(0); } ],[ ac_cv_sys_gnu_getopt="`cat conftestresult`" ],[ ac_cv_sys_gnu_getopt="fail" ]) ]) if test "$ac_cv_sys_gnu_getopt" = "yes" then AC_DEFINE(HAVE_GNU_GETOPT) fi ]) am-utils-6.2+rc20110530/m4/macros/check_hide_mount_type.m4000066400000000000000000000020371157065440000227330ustar00rootroot00000000000000dnl ###################################################################### dnl Define mount type to hide amd mounts from df(1) dnl dnl This has to be determined individually per OS. Depending on whatever dnl mount options are defined in the system header files such as dnl MNTTYPE_IGNORE or MNTTYPE_AUTO, or others does not work: some OSs define dnl some of these then use other stuff; some do not define them at all in dnl the headers, but still use it; and more. After a long attempt to get dnl this automatically configured, I came to the conclusion that the semi- dnl automatic per-host-os determination here is the best. dnl AC_DEFUN([AMU_CHECK_HIDE_MOUNT_TYPE], [ AC_CACHE_CHECK(for mount type to hide from df, ac_cv_hide_mount_type, [ case "${host_os}" in irix* | hpux* ) ac_cv_hide_mount_type="ignore" ;; sunos4* ) ac_cv_hide_mount_type="auto" ;; * ) ac_cv_hide_mount_type="nfs" ;; esac ]) AC_DEFINE_UNQUOTED(HIDE_MOUNT_TYPE, "$ac_cv_hide_mount_type") ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_lib2.m4000066400000000000000000000041521157065440000203670ustar00rootroot00000000000000dnl a bug-fixed version of autoconf 2.12. dnl first try to link library without $5, and only of that failed, dnl try with $5 if specified. dnl it adds $5 to $LIBS if it was needed -Erez. dnl AC_CHECK_LIB2(LIBRARY, FUNCTION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND dnl [, OTHER-LIBRARIES]]]) AC_DEFUN([AMU_CHECK_LIB2], [AC_MSG_CHECKING([for $2 in -l$1]) dnl Use a cache variable name containing both the library and function name, dnl because the test really is for library $1 defining function $2, not dnl just for library $1. Separate tests with the same $1 and different $2s dnl may have different results. ac_lib_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'` AC_CACHE_VAL(ac_cv_lib_$ac_lib_var, [ac_save_LIBS="$LIBS" # first try with base library, without auxiliary library LIBS="-l$1 $LIBS" AC_TRY_LINK(dnl ifelse([$2], [main], , dnl Avoid conflicting decl of main. [/* Override any gcc2 internal prototype to avoid an error. */ ] [/* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $2(); ]), [$2()], eval "ac_cv_lib_$ac_lib_var=\"$1\"", eval "ac_cv_lib_$ac_lib_var=no") # if OK, set to no auxiliary library, else try auxiliary library if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = no"; then LIBS="-l$1 $5 $LIBS" AC_TRY_LINK(dnl ifelse([$2], [main], , dnl Avoid conflicting decl of main. [/* Override any gcc2 internal prototype to avoid an error. */ ] [/* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $2(); ]), [$2()], eval "ac_cv_lib_$ac_lib_var=\"$1 $5\"", eval "ac_cv_lib_$ac_lib_var=no") fi LIBS="$ac_save_LIBS" ])dnl ac_tmp="`eval echo '$''{ac_cv_lib_'$ac_lib_var'}'`" if test "${ac_tmp}" != no; then AC_MSG_RESULT(-l$ac_tmp) ifelse([$3], , [ ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[[^a-zA-Z0-9_]]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` AC_DEFINE_UNQUOTED($ac_tr_lib) LIBS="-l$ac_tmp $LIBS" ], [$3]) else AC_MSG_RESULT(no) ifelse([$4], , , [$4 ])dnl fi ]) am-utils-6.2+rc20110530/m4/macros/check_libwrap_severity.m4000066400000000000000000000021341157065440000231270ustar00rootroot00000000000000dnl ###################################################################### dnl check if libwrap (if exists), requires the caller to define the variables dnl deny_severity and allow_severity. AC_DEFUN([AMU_CHECK_LIBWRAP_SEVERITY], [ AC_CACHE_CHECK([if libwrap wants caller to define allow_severity and deny_severity], ac_cv_need_libwrap_severity_vars, [ # save, then reset $LIBS back to original value SAVEDLIBS="$LIBS" LIBS="$LIBS -lwrap" # run program one without defining our own severity variables AC_TRY_RUN( [ int main() { exit(0); } ],[ac_tmp_val1="yes"],[ac_tmp_val1="no"]) # run program two with defining our own severity variables AC_TRY_RUN( [ int deny_severity, allow_severity, rfc931_timeout; int main() { exit(0); } ],[ac_tmp_val2="yes"],[ac_tmp_val2="no"]) # restore original value of $LIBS LIBS="$SAVEDLIBS" # now decide what to do if test "$ac_tmp_val1" = "no" && test "$ac_tmp_val2" = "yes" then ac_cv_need_libwrap_severity_vars="yes" else ac_cv_need_libwrap_severity_vars="no" fi ]) if test "$ac_cv_need_libwrap_severity_vars" = "yes" then AC_DEFINE(NEED_LIBWRAP_SEVERITY_VARIABLES) fi ]) am-utils-6.2+rc20110530/m4/macros/check_map_funcs.m4000066400000000000000000000027701157065440000215160ustar00rootroot00000000000000dnl ###################################################################### dnl check if a map exists (if some library function exists). dnl Usage: AC_CHECK_MAP_FUNCS(..., , []) dnl Check if any of the functions exist. If any exist, then dnl define HAVE_MAP_. If exits, then defined dnl HAVE_MAP_ instead... AC_DEFUN([AMU_CHECK_MAP_FUNCS], [ # find what name to give to the map if test -n "$3" then ac_map_name=$3 else ac_map_name=$2 fi # store variable name of map ac_upcase_map_name=`echo $ac_map_name | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ac_safe=HAVE_MAP_$ac_upcase_map_name # check for cache and set it if needed AMU_CACHE_CHECK_DYNAMIC(for $ac_map_name maps, ac_cv_map_$ac_map_name, [ # define to "no" by default eval "ac_cv_map_$ac_map_name=no" # and look to see if it was found AC_CHECK_FUNCS($1, [ eval "ac_cv_map_$ac_map_name=yes" break ])]) # check if need to define variable if test "`eval echo '$''{ac_cv_map_'$ac_map_name'}'`" = yes then AC_DEFINE_UNQUOTED($ac_safe) # append info_.o object to AMD_INFO_OBJS for automatic compilation # if first time we add something to this list, then also tell autoconf # to replace instances of it in Makefiles. if test -z "$AMD_INFO_OBJS" then AMD_INFO_OBJS="info_${ac_map_name}.o" AC_SUBST(AMD_INFO_OBJS) else AMD_INFO_OBJS="$AMD_INFO_OBJS info_${ac_map_name}.o" fi fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mnt2_cdfs_opt.m4000066400000000000000000000050551157065440000223030ustar00rootroot00000000000000dnl ###################################################################### dnl Find CDFS-specific mount(2) options (hex numbers) dnl Usage: AMU_CHECK_MNT2_CDFS_OPT() dnl Check if there is an entry for MS_ or M_ in sys/mntent.h or dnl mntent.h, then define MNT2_CDFS_OPT_ to the hex number. AC_DEFUN([AMU_CHECK_MNT2_CDFS_OPT], [ # what name to give to the fs ac_fs_name=$1 # store variable name of fs ac_upcase_fs_name=`echo $ac_fs_name | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ac_safe=MNT2_CDFS_OPT_$ac_upcase_fs_name # check for cache and set it if needed AMU_CACHE_CHECK_DYNAMIC(for CDFS-specific mount(2) option $ac_fs_name, ac_cv_mnt2_cdfs_opt_$ac_fs_name, [ # undefine by default eval "ac_cv_mnt2_cdfs_opt_$ac_fs_name=notfound" value=notfound # first, try MS_* (most systems). Must be the first test! if test "$value" = notfound then AMU_EXPAND_CPP_HEX( AMU_MOUNT_HEADERS , MS_$ac_upcase_fs_name) fi # if failed, try MNT_* (bsd44 systems) if test "$value" = notfound then AMU_EXPAND_CPP_HEX( AMU_MOUNT_HEADERS , MNT_$ac_upcase_fs_name) fi # if failed, try MS_* as an integer (linux systems) if test "$value" = notfound then AMU_EXPAND_CPP_INT( AMU_MOUNT_HEADERS , MS_$ac_upcase_fs_name) fi # If failed try M_* (must be last test since svr4 systems define M_DATA etc. # in # This test was off for now, because of the conflicts with other systems. # but I turned it back on by faking the inclusion of already. if test "$value" = notfound then AMU_EXPAND_CPP_HEX( #ifndef _sys_stream_h # define _sys_stream_h #endif /* not _sys_stream_h */ #ifndef _SYS_STREAM_H # define _SYS_STREAM_H #endif /* not _SYS_STREAM_H */ AMU_MOUNT_HEADERS , M_$ac_upcase_fs_name) fi # if failed, try ISOFSMNT_* as a hex (bsdi4 systems) if test "$value" = notfound then AMU_EXPAND_CPP_HEX( AMU_MOUNT_HEADERS , ISOFSMNT_$ac_upcase_fs_name) fi # set cache variable to value eval "ac_cv_mnt2_cdfs_opt_$ac_fs_name=$value" ]) # outside cache check, if ok, define macro ac_tmp=`eval echo '$''{ac_cv_mnt2_cdfs_opt_'$ac_fs_name'}'` if test "${ac_tmp}" != notfound then AC_DEFINE_UNQUOTED($ac_safe, $ac_tmp) fi ]) dnl ====================================================================== dnl ###################################################################### dnl run AMU_CHECK_MNT2_CDFS_OPT on each argument given dnl Usage: AMU_CHECK_MNT2_CDFS_OPTS(arg arg arg ...) AC_DEFUN([AMU_CHECK_MNT2_CDFS_OPTS], [ for ac_tmp_arg in $1 do AMU_CHECK_MNT2_CDFS_OPT($ac_tmp_arg) done ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mnt2_gen_opt.m4000066400000000000000000000046411157065440000221350ustar00rootroot00000000000000dnl ###################################################################### dnl Find generic mount(2) options (hex numbers) dnl Usage: AMU_CHECK_MNT2_GEN_OPT() dnl Check if there is an entry for MS_, MNT_, or M_ dnl (in that order) in mntent.h, sys/mntent.h, or mount.h... dnl then define MNT2_GEN_OPT_ to the hex number. AC_DEFUN([AMU_CHECK_MNT2_GEN_OPT], [ # what name to give to the fs ac_fs_name=$1 # store variable name of fs ac_upcase_fs_name=`echo $ac_fs_name | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ac_safe=MNT2_GEN_OPT_$ac_upcase_fs_name # check for cache and set it if needed AMU_CACHE_CHECK_DYNAMIC(for generic mount(2) option $ac_fs_name, ac_cv_mnt2_gen_opt_$ac_fs_name, [ # undefine by default eval "ac_cv_mnt2_gen_opt_$ac_fs_name=notfound" value=notfound # first, try MS_* (most systems). Must be the first test! if test "$value" = notfound then AMU_EXPAND_CPP_HEX( AMU_MOUNT_HEADERS , MS_$ac_upcase_fs_name) fi # if failed, try MNT_* (bsd44 systems) if test "$value" = notfound then AMU_EXPAND_CPP_HEX( AMU_MOUNT_HEADERS , MNT_$ac_upcase_fs_name) fi # if failed, try MS_* as an integer (linux systems) if test "$value" = notfound then AMU_EXPAND_CPP_INT( AMU_MOUNT_HEADERS , MS_$ac_upcase_fs_name) fi # If failed try M_* (must be last test since svr4 systems define M_DATA etc. # in # This test was off for now, because of the conflicts with other systems. # but I turned it back on by faking the inclusion of already. if test "$value" = notfound then AMU_EXPAND_CPP_HEX( #ifndef _sys_stream_h # define _sys_stream_h #endif /* not _sys_stream_h */ #ifndef _SYS_STREAM_H # define _SYS_STREAM_H #endif /* not _SYS_STREAM_H */ AMU_MOUNT_HEADERS , M_$ac_upcase_fs_name) fi # set cache variable to value eval "ac_cv_mnt2_gen_opt_$ac_fs_name=$value" ]) # outside cache check, if ok, define macro ac_tmp=`eval echo '$''{ac_cv_mnt2_gen_opt_'$ac_fs_name'}'` if test "${ac_tmp}" != notfound then AC_DEFINE_UNQUOTED($ac_safe, $ac_tmp) fi ]) dnl ====================================================================== dnl ###################################################################### dnl run AMU_CHECK_MNT2_GEN_OPT on each argument given dnl Usage: AMU_CHECK_MNT2_GEN_OPTS(arg arg arg ...) AC_DEFUN([AMU_CHECK_MNT2_GEN_OPTS], [ for ac_tmp_arg in $1 do AMU_CHECK_MNT2_GEN_OPT($ac_tmp_arg) done ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mnt2_nfs_opt.m4000066400000000000000000000033311157065440000221450ustar00rootroot00000000000000dnl ###################################################################### dnl Find NFS-specific mount(2) options (hex numbers) dnl Usage: AMU_CHECK_MNT2_NFS_OPT() dnl Check if there is an entry for NFSMNT_ in sys/mntent.h or dnl mntent.h, then define MNT2_NFS_OPT_ to the hex number. AC_DEFUN([AMU_CHECK_MNT2_NFS_OPT], [ # what name to give to the fs ac_fs_name=$1 # store variable name of fs ac_upcase_fs_name=`echo $ac_fs_name | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ac_safe=MNT2_NFS_OPT_$ac_upcase_fs_name # check for cache and set it if needed AMU_CACHE_CHECK_DYNAMIC(for NFS-specific mount(2) option $ac_fs_name, ac_cv_mnt2_nfs_opt_$ac_fs_name, [ # undefine by default eval "ac_cv_mnt2_nfs_opt_$ac_fs_name=notfound" value=notfound # first try NFSMNT_* (most systems) if test "$value" = notfound then AMU_EXPAND_CPP_HEX( AMU_MOUNT_HEADERS , NFSMNT_$ac_upcase_fs_name) fi # next try NFS_MOUNT_* (linux) if test "$value" = notfound then AMU_EXPAND_CPP_HEX( AMU_MOUNT_HEADERS , NFS_MOUNT_$ac_upcase_fs_name) fi # set cache variable to value eval "ac_cv_mnt2_nfs_opt_$ac_fs_name=$value" ]) # outside cache check, if ok, define macro ac_tmp=`eval echo '$''{ac_cv_mnt2_nfs_opt_'$ac_fs_name'}'` if test "${ac_tmp}" != notfound then AC_DEFINE_UNQUOTED($ac_safe, $ac_tmp) fi ]) dnl ====================================================================== dnl ###################################################################### dnl run AMU_CHECK_MNT2_NFS_OPT on each argument given dnl Usage: AMU_CHECK_MNT2_NFS_OPTS(arg arg arg ...) AC_DEFUN([AMU_CHECK_MNT2_NFS_OPTS], [ for ac_tmp_arg in $1 do AMU_CHECK_MNT2_NFS_OPT($ac_tmp_arg) done ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mnt2_pcfs_opt.m4000066400000000000000000000050611157065440000223140ustar00rootroot00000000000000dnl ###################################################################### dnl Find PCFS-specific mount(2) options (hex numbers) dnl Usage: AMU_CHECK_MNT2_PCFS_OPT() dnl Check if there is an entry for MS_ or M_ in sys/mntent.h or dnl mntent.h, then define MNT2_PCFS_OPT_ to the hex number. AC_DEFUN([AMU_CHECK_MNT2_PCFS_OPT], [ # what name to give to the fs ac_fs_name=$1 # store variable name of fs ac_upcase_fs_name=`echo $ac_fs_name | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ac_safe=MNT2_PCFS_OPT_$ac_upcase_fs_name # check for cache and set it if needed AMU_CACHE_CHECK_DYNAMIC(for PCFS-specific mount(2) option $ac_fs_name, ac_cv_mnt2_pcfs_opt_$ac_fs_name, [ # undefine by default eval "ac_cv_mnt2_pcfs_opt_$ac_fs_name=notfound" value=notfound # first, try MS_* (most systems). Must be the first test! if test "$value" = notfound then AMU_EXPAND_CPP_HEX( AMU_MOUNT_HEADERS , MS_$ac_upcase_fs_name) fi # if failed, try MNT_* (bsd44 systems) if test "$value" = notfound then AMU_EXPAND_CPP_HEX( AMU_MOUNT_HEADERS , MNT_$ac_upcase_fs_name) fi # if failed, try MS_* as an integer (linux systems) if test "$value" = notfound then AMU_EXPAND_CPP_INT( AMU_MOUNT_HEADERS , MS_$ac_upcase_fs_name) fi # If failed try M_* (must be last test since svr4 systems define M_DATA etc. # in # This test was off for now, because of the conflicts with other systems. # but I turned it back on by faking the inclusion of already. if test "$value" = notfound then AMU_EXPAND_CPP_HEX( #ifndef _sys_stream_h # define _sys_stream_h #endif /* not _sys_stream_h */ #ifndef _SYS_STREAM_H # define _SYS_STREAM_H #endif /* not _SYS_STREAM_H */ AMU_MOUNT_HEADERS , M_$ac_upcase_fs_name) fi # if failed, try MSDOSFSMNT_* as a hex (bsd44 systems) if test "$value" = notfound then AMU_EXPAND_CPP_HEX( AMU_MOUNT_HEADERS , MSDOSFSMNT_$ac_upcase_fs_name) fi # set cache variable to value eval "ac_cv_mnt2_pcfs_opt_$ac_fs_name=$value" ]) # outside cache check, if ok, define macro ac_tmp=`eval echo '$''{ac_cv_mnt2_pcfs_opt_'$ac_fs_name'}'` if test "${ac_tmp}" != notfound then AC_DEFINE_UNQUOTED($ac_safe, $ac_tmp) fi ]) dnl ====================================================================== dnl ###################################################################### dnl run AMU_CHECK_MNT2_PCFS_OPT on each argument given dnl Usage: AMU_CHECK_MNT2_PCFS_OPTS(arg arg arg ...) AC_DEFUN([AMU_CHECK_MNT2_PCFS_OPTS], [ for ac_tmp_arg in $1 do AMU_CHECK_MNT2_PCFS_OPT($ac_tmp_arg) done ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mnt2_udf_opt.m4000066400000000000000000000032351157065440000221400ustar00rootroot00000000000000dnl ###################################################################### dnl Find UDF-specific mount(2) options (hex numbers) dnl Usage: AMU_CHECK_MNT2_UDF_OPT() dnl Check if there is an entry for MS_ or M_ in sys/mntent.h or dnl mntent.h, then define MNT2_UDF_OPT_ to the hex number. AC_DEFUN([AMU_CHECK_MNT2_UDF_OPT], [ # what name to give to the fs ac_fs_name=$1 # store variable name of fs ac_upcase_fs_name=`echo $ac_fs_name | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ac_safe=MNT2_UDF_OPT_$ac_upcase_fs_name # check for cache and set it if needed AMU_CACHE_CHECK_DYNAMIC(for UDF-specific mount(2) option $ac_fs_name, ac_cv_mnt2_udf_opt_$ac_fs_name, [ # undefine by default eval "ac_cv_mnt2_udf_opt_$ac_fs_name=notfound" value=notfound # XXX - tests for other systems need to be added here! # if failed, try UDFMNT_* as a hex (netbsd systems) if test "$value" = notfound then AMU_EXPAND_CPP_HEX( AMU_MOUNT_HEADERS , UDFMNT_$ac_upcase_fs_name) fi # set cache variable to value eval "ac_cv_mnt2_udf_opt_$ac_fs_name=$value" ]) # outside cache check, if ok, define macro ac_tmp=`eval echo '$''{ac_cv_mnt2_udf_opt_'$ac_fs_name'}'` if test "${ac_tmp}" != notfound then AC_DEFINE_UNQUOTED($ac_safe, $ac_tmp) fi ]) dnl ====================================================================== dnl ###################################################################### dnl run AMU_CHECK_MNT2_UDF_OPT on each argument given dnl Usage: AMU_CHECK_MNT2_UDF_OPTS(arg arg arg ...) AC_DEFUN([AMU_CHECK_MNT2_UDF_OPTS], [ for ac_tmp_arg in $1 do AMU_CHECK_MNT2_UDF_OPT($ac_tmp_arg) done ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mnttab_file_name.m4000066400000000000000000000030601157065440000230200ustar00rootroot00000000000000dnl ###################################################################### dnl Find name of mount table file, and define it as MNTTAB_FILE_NAME dnl dnl Solaris defines MNTTAB as /etc/mnttab, the file where /sbin/mount dnl stores its cache of mounted filesystems. But under SunOS, the same dnl macro MNTTAB, is defined as the _source_ of filesystems to mount, and dnl is set to /etc/fstab. That is why I have to first check out dnl if MOUNTED exists, and if not, check for the MNTTAB macro. dnl AC_DEFUN([AMU_CHECK_MNTTAB_FILE_NAME], [ AC_CACHE_CHECK(for name of mount table file name, ac_cv_mnttab_file_name, [ # expand cpp value for MNTTAB AMU_EXPAND_CPP_STRING( AMU_MOUNT_HEADERS( [ /* see M4 comment at the top of the definition of this macro */ #ifdef MOUNTED # define _MNTTAB_FILE_NAME MOUNTED # else /* not MOUNTED */ # ifdef MNTTAB # define _MNTTAB_FILE_NAME MNTTAB # endif /* MNTTAB */ #endif /* not MOUNTED */ ]), _MNTTAB_FILE_NAME, [ ac_cv_mnttab_file_name=$value ], [ ac_cv_mnttab_file_name=notfound # check explicitly for /etc/mnttab if test "$ac_cv_mnttab_file_name" = notfound then if test -f /etc/mnttab then ac_cv_mnttab_file_name="/etc/mnttab" fi fi # check explicitly for /etc/mtab if test "$ac_cv_mnttab_file_name" = notfound then if test -f /etc/mtab then ac_cv_mnttab_file_name="/etc/mtab" fi fi ]) ]) # test value and create macro as needed if test "$ac_cv_mnttab_file_name" != notfound then AC_DEFINE_UNQUOTED(MNTTAB_FILE_NAME, "$ac_cv_mnttab_file_name") fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mnttab_location.m4000066400000000000000000000016011157065440000227100ustar00rootroot00000000000000dnl ###################################################################### dnl check if the mount table is kept in a file or in the kernel. AC_DEFUN([AMU_CHECK_MNTTAB_LOCATION], [ AMU_CACHE_CHECK_DYNAMIC(where mount table is kept, ac_cv_mnttab_location, [ # assume location is on file ac_cv_mnttab_location=file AC_CHECK_FUNCS(mntctl getmntinfo getmountent, ac_cv_mnttab_location=kernel) # Solaris 8 Beta Refresh and up use the mntfs pseudo filesystem to store the # mount table in kernel (cf. mnttab(4): the MS_NOMNTTAB option in # inhibits that a mount shows up there and thus can be used to # check for the in-kernel mount table if test "$ac_cv_mnt2_gen_opt_nomnttab" != notfound then ac_cv_mnttab_location=kernel fi ]) if test "$ac_cv_mnttab_location" = file then AC_DEFINE(MOUNT_TABLE_ON_FILE) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mnttab_opt.m4000066400000000000000000000033071157065440000217070ustar00rootroot00000000000000dnl ###################################################################### dnl check the string type of the name of a filesystem mount table entry dnl option. dnl Usage: AMU_CHECK_MNTTAB_OPT() dnl Check if there is an entry for MNTOPT_ in sys/mntent.h or mntent.h dnl define MNTTAB_OPT_ to the string name (e.g., "ro"). AC_DEFUN([AMU_CHECK_MNTTAB_OPT], [ # what name to give to the fs ac_fs_name=$1 # store variable name of fs ac_upcase_fs_name=`echo $ac_fs_name | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ac_safe=MNTTAB_OPT_$ac_upcase_fs_name # check for cache and set it if needed AMU_CACHE_CHECK_DYNAMIC(for mount table option $ac_fs_name, ac_cv_mnttab_opt_$ac_fs_name, [ # undefine by default eval "ac_cv_mnttab_opt_$ac_fs_name=notfound" # and look to see if it was found AMU_EXPAND_CPP_STRING( AMU_MOUNT_HEADERS , MNTOPT_$ac_upcase_fs_name) # set cache variable to value if test "${value}" != notfound then eval "ac_cv_mnttab_opt_$ac_fs_name=\\\"$value\\\"" else eval "ac_cv_mnttab_opt_$ac_fs_name=$value" fi dnl DO NOT CHECK FOR MNT_* b/c bsd44 systems don't use /etc/mnttab, ]) # outside cache check, if ok, define macro ac_tmp=`eval echo '$''{ac_cv_mnttab_opt_'$ac_fs_name'}'` if test "${ac_tmp}" != notfound then AC_DEFINE_UNQUOTED($ac_safe, $ac_tmp) fi ]) dnl ====================================================================== dnl ###################################################################### dnl run AMU_CHECK_MNTTAB_OPT on each argument given dnl Usage: AMU_CHECK_MNTTAB_OPTS(arg arg arg ...) AC_DEFUN([AMU_CHECK_MNTTAB_OPTS], [ for ac_tmp_arg in $1 do AMU_CHECK_MNTTAB_OPT($ac_tmp_arg) done ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mnttab_style.m4000066400000000000000000000020251157065440000222410ustar00rootroot00000000000000dnl ###################################################################### dnl check style of accessing the mount table file AC_DEFUN([AMU_CHECK_MNTTAB_STYLE], [ AC_CACHE_CHECK(mount table style, ac_cv_style_mnttab, [ # select the correct style for mount table manipulation functions case "${host_os_name}" in aix* ) ac_cv_style_mnttab=aix ;; bsd* | bsdi* | freebsd* | netbsd* | openbsd* | darwin* | macosx* | rhapsody* ) ac_cv_style_mnttab=bsd ;; isc3* ) ac_cv_style_mnttab=isc3 ;; mach3* ) ac_cv_style_mnttab=mach3 ;; osf* ) ac_cv_style_mnttab=osf ;; svr4* | sysv4* | solaris2* | sunos5* | aoi* ) ac_cv_style_mnttab=svr4 ;; ultrix* ) ac_cv_style_mnttab=ultrix ;; linux*) ac_cv_style_mnttab=linux ;; * ) ac_cv_style_mnttab=file ;; esac ]) am_utils_link_files=${am_utils_link_files}libamu/mtabutil.c:conf/mtab/mtab_${ac_cv_style_mnttab}.c" " # append mtab utilities object to LIBOBJS for automatic compilation AC_LIBOBJ(mtabutil) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mnttab_type.m4000066400000000000000000000120761157065440000220710ustar00rootroot00000000000000dnl ###################################################################### dnl check the string type of the name of a filesystem mount table entry. dnl Usage: AC_CHECK_MNTTAB_TYPE(, [fssymbol]) dnl Check if there is an entry for MNTTYPE_ in sys/mntent.h and mntent.h dnl define MNTTAB_TYPE_ to the string name (e.g., "nfs"). If dnl exist, then define MNTTAB_TYPE_ instead. If is dnl defined, then can be a list of fs strings to look for. dnl If no symbols have been defined, but the filesystem has been found dnl earlier, then set the mount-table type to "" anyway... AC_DEFUN([AMU_CHECK_MNTTAB_TYPE], [ # find what name to give to the fs if test -n "$2" then ac_fs_name=$2 else ac_fs_name=$1 fi # store variable name of fs ac_upcase_fs_name=`echo $ac_fs_name | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ac_safe=MNTTAB_TYPE_$ac_upcase_fs_name # check for cache and set it if needed AMU_CACHE_CHECK_DYNAMIC(for mnttab name for $ac_fs_name filesystem, ac_cv_mnttab_type_$ac_fs_name, [ # undefine by default eval "ac_cv_mnttab_type_$ac_fs_name=notfound" # and look to see if it was found for ac_fs_tmp in $1 do if test "$ac_fs_tmp" = "nfs3" -a "$ac_cv_fs_nfs3" = "yes" -a "$ac_cv_header_linux_nfs_h" = "yes" then eval "ac_cv_mnttab_type_$ac_fs_name=\\\"$ac_cv_mnttab_type_nfs\\\"" break fi ac_upcase_fs_symbol=`echo $ac_fs_tmp | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | tr -d '.'` # first look for MNTTYPE_* AC_EGREP_CPP(yes, AMU_MOUNT_HEADERS( [ #ifdef MNTTYPE_$ac_upcase_fs_symbol yes #endif /* MNTTYPE_$ac_upcase_fs_symbol */ ]), [ eval "ac_cv_mnttab_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" ]) # check if need to terminate "for" loop if test "`eval echo '$''{ac_cv_mnttab_type_'$ac_fs_name'}'`" != notfound then break fi # look for a loadable filesystem module (linux) if test -f /lib/modules/$host_os_version/fs/$ac_fs_tmp.ko then eval "ac_cv_mnttab_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi if test -f /lib/modules/$host_os_version/fs/$ac_fs_tmp.o then eval "ac_cv_mnttab_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi # look for a loadable filesystem module (linux 2.4+) if test -f /lib/modules/$host_os_version/kernel/fs/$ac_fs_tmp/$ac_fs_tmp.ko then eval "ac_cv_mnttab_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi if test -f /lib/modules/$host_os_version/kernel/fs/$ac_fs_tmp/$ac_fs_tmp.o then eval "ac_cv_mnttab_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi # look for a loadable filesystem module (linux redhat-5.1) if test -f /lib/modules/preferred/fs/$ac_fs_tmp.ko then eval "ac_cv_mnttab_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi if test -f /lib/modules/preferred/fs/$ac_fs_tmp.o then eval "ac_cv_mnttab_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi # next look for statically compiled filesystem (linux) if egrep "[[^a-zA-Z0-9_]]$ac_fs_tmp$" /proc/filesystems >/dev/null 2>&1 then eval "ac_cv_mnttab_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi # then try to run a program that derefences a static array (bsd44) AMU_EXPAND_RUN_STRING( AMU_MOUNT_HEADERS( [ #ifndef INITMOUNTNAMES # error INITMOUNTNAMES not defined #endif /* not INITMOUNTNAMES */ ]), [ char const *namelist[] = INITMOUNTNAMES; if (argc > 1) printf("\"%s\"", namelist[MOUNT_$ac_upcase_fs_symbol]); ], [ eval "ac_cv_mnttab_type_$ac_fs_name=\\\"$value\\\"" ]) # check if need to terminate "for" loop if test "`eval echo '$''{ac_cv_mnttab_type_'$ac_fs_name'}'`" != notfound then break fi # then run a test program for bsdi3, tru64, and others AC_TRY_RUN( [ #include #include main() { int i; struct vfsconf vf; i = getvfsbyname("$ac_fs_tmp", &vf); if (i < 0) exit(1); else exit(0); } ], [eval "ac_cv_mnttab_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break ] ) # check if need to terminate "for" loop if test "`eval echo '$''{ac_cv_mnttab_type_'$ac_fs_name'}'`" != notfound then break fi # finally try to run a program that derefences a static array (bsd44) AMU_EXPAND_RUN_STRING( AMU_MOUNT_HEADERS( [ ]), [ if (argc > 1) printf("\"%s\"", MOUNT_$ac_upcase_fs_symbol); ], [ eval "ac_cv_mnttab_type_$ac_fs_name=\\\"$value\\\"" ]) # check if need to terminate "for" loop if test "`eval echo '$''{ac_cv_mnttab_type_'$ac_fs_name'}'`" != notfound then break fi done # check if not defined, yet the filesystem is defined if test "`eval echo '$''{ac_cv_mnttab_type_'$ac_fs_name'}'`" = notfound then # this should test if $ac_cv_fs_ is "yes" if test "`eval echo '$''{ac_cv_fs_'$ac_fs_name'}'`" = yes || test "`eval echo '$''{ac_cv_fs_header_'$ac_fs_name'}'`" = yes then eval "ac_cv_mnttab_type_$ac_fs_name=\\\"$ac_fs_name\\\"" fi fi ]) # check if need to define variable ac_tmp=`eval echo '$''{ac_cv_mnttab_type_'$ac_fs_name'}'` if test "$ac_tmp" != notfound then AC_DEFINE_UNQUOTED($ac_safe, $ac_tmp) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mount_style.m4000066400000000000000000000024251157065440000221220ustar00rootroot00000000000000dnl ###################################################################### dnl check style of mounting filesystems AC_DEFUN([AMU_CHECK_MOUNT_STYLE], [ AC_CACHE_CHECK(style of mounting filesystems, ac_cv_style_mount, [ # select the correct style for mounting filesystems case "${host_os_name}" in solaris1* | sunos[[34]]* | bsdi[[12]]* ) ac_cv_style_mount=default ;; hpux[[6-9]]* | hpux10* ) ac_cv_style_mount=hpux ;; svr4* | sysv4* | solaris* | sunos* | aoi* | hpux* ) ac_cv_style_mount=svr4 ;; bsdi* ) ac_cv_style_mount=bsdi3 ;; aix3* | aix4* ) ac_cv_style_mount=aix3 ;; aix* ) ac_cv_style_mount=aix ;; irix5* ) ac_cv_style_mount=irix5 ;; irix* ) ac_cv_style_mount=irix6 ;; isc3* ) ac_cv_style_mount=isc3 ;; linux* ) ac_cv_style_mount=linux ;; mach3* ) ac_cv_style_mount=mach3 ;; stellix* ) ac_cv_style_mount=stellix ;; * ) # no style needed. Use default filesystem calls ala BSD ac_cv_style_mount=default ;; esac ]) am_utils_mount_style_file="mountutil.c" am_utils_link_files=${am_utils_link_files}libamu/${am_utils_mount_style_file}:conf/mount/mount_${ac_cv_style_mount}.c" " # append mount utilities object to LIBOBJS for automatic compilation AC_LIBOBJ(mountutil) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mount_trap.m4000066400000000000000000000023261157065440000217300ustar00rootroot00000000000000dnl ###################################################################### dnl check the mount system call trap needed to mount(2) a filesystem AC_DEFUN([AMU_CHECK_MOUNT_TRAP], [ AC_CACHE_CHECK(mount trap system-call style, ac_cv_mount_trap, [ # select the correct style to mount(2) a filesystem case "${host_os_name}" in solaris1* | sunos[[34]]* ) ac_cv_mount_trap=default ;; hpux[[6-9]]* | hpux10* ) ac_cv_mount_trap=hpux ;; svr4* | sysv4* | solaris* | sunos* | aoi* | hpux* ) ac_cv_mount_trap=svr4 ;; news4* | riscix* ) ac_cv_mount_trap=news4 ;; linux* ) ac_cv_mount_trap=linux ;; irix* ) ac_cv_mount_trap=irix ;; aux* ) ac_cv_mount_trap=aux ;; hcx* ) ac_cv_mount_trap=hcx ;; rtu6* ) ac_cv_mount_trap=rtu6 ;; dgux* ) ac_cv_mount_trap=dgux ;; aix* ) ac_cv_mount_trap=aix3 ;; mach2* | mach3* ) ac_cv_mount_trap=mach3 ;; ultrix* ) ac_cv_mount_trap=ultrix ;; isc3* ) ac_cv_mount_trap=isc3 ;; stellix* ) ac_cv_mount_trap=stellix ;; netbsd* ) ac_cv_mount_trap=netbsd ;; * ) ac_cv_mount_trap=default ;; esac ]) am_utils_mount_trap=$srcdir"/conf/trap/trap_"$ac_cv_mount_trap".h" AC_SUBST_FILE(am_utils_mount_trap) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mount_type.m4000066400000000000000000000125351157065440000217460ustar00rootroot00000000000000dnl ###################################################################### dnl check the string type of the name of a filesystem mount table entry. dnl Usage: AC_CHECK_MOUNT_TYPE(, [fssymbol]) dnl Check if there is an entry for MNTTYPE_ in sys/mntent.h and mntent.h dnl define MOUNT_TYPE_ to the string name (e.g., "nfs"). If dnl exist, then define MOUNT_TYPE_ instead. If is dnl defined, then can be a list of fs strings to look for. dnl If no symbols have been defined, but the filesystem has been found dnl earlier, then set the mount-table type to "" anyway... AC_DEFUN([AMU_CHECK_MOUNT_TYPE], [ # find what name to give to the fs if test -n "$2" then ac_fs_name=$2 else ac_fs_name=$1 fi # prepare upper-case name of filesystem ac_upcase_fs_name=`echo $ac_fs_name | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` ############################################################################## # check for cache and set it if needed AMU_CACHE_CHECK_DYNAMIC(for mount(2) type/name for $ac_fs_name filesystem, ac_cv_mount_type_$ac_fs_name, [ # undefine by default eval "ac_cv_mount_type_$ac_fs_name=notfound" # and look to see if it was found for ac_fs_tmp in $1 do ac_upcase_fs_symbol=`echo $ac_fs_tmp | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' | tr -d '.'` # first look for MNTTYPE_ AC_EGREP_CPP(yes, AMU_MOUNT_HEADERS( [ #ifdef MNTTYPE_$ac_upcase_fs_symbol yes #endif /* MNTTYPE_$ac_upcase_fs_symbol */ ]), [eval "ac_cv_mount_type_$ac_fs_name=MNTTYPE_$ac_upcase_fs_symbol"], [eval "ac_cv_mount_type_$ac_fs_name=notfound"] ) # check if need to terminate "for" loop if test "`eval echo '$''{ac_cv_mount_type_'$ac_fs_name'}'`" != notfound then break fi # next look for MOUNT_ AC_EGREP_CPP(yes, AMU_MOUNT_HEADERS( [ #ifdef MOUNT_$ac_upcase_fs_symbol yes #endif /* MOUNT_$ac_upcase_fs_symbol */ ]), [eval "ac_cv_mount_type_$ac_fs_name=MOUNT_$ac_upcase_fs_symbol"], [eval "ac_cv_mount_type_$ac_fs_name=notfound"] ) # check if need to terminate "for" loop if test "`eval echo '$''{ac_cv_mount_type_'$ac_fs_name'}'`" != notfound then break fi # next look for MNT_ AC_EGREP_CPP(yes, AMU_MOUNT_HEADERS( [ #ifdef MNT_$ac_upcase_fs_symbol yes #endif /* MNT_$ac_upcase_fs_symbol */ ]), [eval "ac_cv_mount_type_$ac_fs_name=MNT_$ac_upcase_fs_symbol"], [eval "ac_cv_mount_type_$ac_fs_name=notfound"] ) # check if need to terminate "for" loop if test "`eval echo '$''{ac_cv_mount_type_'$ac_fs_name'}'`" != notfound then break fi # next look for GT_ (ultrix) AC_EGREP_CPP(yes, AMU_MOUNT_HEADERS( [ #ifdef GT_$ac_upcase_fs_symbol yes #endif /* GT_$ac_upcase_fs_symbol */ ]), [eval "ac_cv_mount_type_$ac_fs_name=GT_$ac_upcase_fs_symbol"], [eval "ac_cv_mount_type_$ac_fs_name=notfound"] ) # check if need to terminate "for" loop if test "`eval echo '$''{ac_cv_mount_type_'$ac_fs_name'}'`" != notfound then break fi # look for a loadable filesystem module (linux) if test -f /lib/modules/$host_os_version/fs/$ac_fs_tmp.ko then eval "ac_cv_mount_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi if test -f /lib/modules/$host_os_version/fs/$ac_fs_tmp.o then eval "ac_cv_mount_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi # look for a loadable filesystem module (linux 2.4+) if test -f /lib/modules/$host_os_version/kernel/fs/$ac_fs_tmp/$ac_fs_tmp.ko then eval "ac_cv_mount_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi if test -f /lib/modules/$host_os_version/kernel/fs/$ac_fs_tmp/$ac_fs_tmp.o then eval "ac_cv_mount_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi # look for a loadable filesystem module (linux redhat-5.1) if test -f /lib/modules/preferred/fs/$ac_fs_tmp.ko then eval "ac_cv_mount_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi if test -f /lib/modules/preferred/fs/$ac_fs_tmp.o then eval "ac_cv_mount_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi # in addition look for statically compiled filesystem (linux) if egrep "[[^a-zA-Z0-9_]]$ac_fs_tmp$" /proc/filesystems >/dev/null 2>&1 then eval "ac_cv_mount_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break fi # run a test program for bsdi3 AC_TRY_RUN( [ #include #include main() { int i; struct vfsconf vf; i = getvfsbyname("$ac_fs_tmp", &vf); if (i < 0) exit(1); else exit(0); } ], [eval "ac_cv_mount_type_$ac_fs_name=\\\"$ac_fs_tmp\\\"" break ] ) done # check if not defined, yet the filesystem is defined if test "`eval echo '$''{ac_cv_mount_type_'$ac_fs_name'}'`" = notfound then # this should test if $ac_cv_fs_ is "yes" if test "`eval echo '$''{ac_cv_fs_'$ac_fs_name'}'`" = yes || test "`eval echo '$''{ac_cv_fs_header_'$ac_fs_name'}'`" = yes then eval "ac_cv_mount_type_$ac_fs_name=MNTTYPE_$ac_upcase_fs_name" fi fi ]) # end of cache check for ac_cv_mount_type_$ac_fs_name ############################################################################## # check if need to define variable if test "`eval echo '$''{ac_cv_mount_type_'$ac_fs_name'}'`" != notfound then ac_safe=MOUNT_TYPE_$ac_upcase_fs_name ac_tmp=`eval echo '$''{ac_cv_mount_type_'$ac_fs_name'}'` AC_DEFINE_UNQUOTED($ac_safe, $ac_tmp) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mtype_printf_type.m4000066400000000000000000000013621157065440000233200ustar00rootroot00000000000000dnl ###################################################################### dnl check the correct printf-style type for the mount type in the mount() dnl system call. dnl If you change this one, you must also fix the check_mtype_type.m4. AC_DEFUN([AMU_CHECK_MTYPE_PRINTF_TYPE], [ AC_CACHE_CHECK(printf string to print type field of mount() call, ac_cv_mtype_printf_type, [ # select the correct printf type case "${host_os_name}" in osf* | freebsd2* | bsdi2* | aix* | ultrix* ) ac_cv_mtype_printf_type="%d" ;; irix3 | isc3 ) ac_cv_mtype_printf_type="0x%x" ;; * ) ac_cv_mtype_printf_type="%s" ;; esac ]) AC_DEFINE_UNQUOTED(MTYPE_PRINTF_TYPE, "$ac_cv_mtype_printf_type") ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_mtype_type.m4000066400000000000000000000011721157065440000217350ustar00rootroot00000000000000dnl ###################################################################### dnl check the correct type for the mount type in the mount() system call dnl If you change this one, you must also fix the check_mtype_printf_type.m4. AC_DEFUN([AMU_CHECK_MTYPE_TYPE], [ AC_CACHE_CHECK(type of mount type field in mount() call, ac_cv_mtype_type, [ # select the correct type case "${host_os_name}" in osf* | freebsd2* | bsdi2* | aix* | ultrix* ) ac_cv_mtype_type=int ;; * ) ac_cv_mtype_type="char *" ;; esac ]) AC_DEFINE_UNQUOTED(MTYPE_TYPE, $ac_cv_mtype_type) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_network_transport_type.m4000066400000000000000000000015171157065440000244070ustar00rootroot00000000000000dnl ###################################################################### dnl check the correct network transport type to use AC_DEFUN([AMU_CHECK_NETWORK_TRANSPORT_TYPE], [ AC_CACHE_CHECK(network transport type, ac_cv_transport_type, [ # select the correct type case "${host_os_name}" in solaris1* | sunos[[34]]* | hpux[[6-9]]* | hpux10* ) ac_cv_transport_type=sockets ;; solaris* | sunos* | hpux* ) ac_cv_transport_type=tli ;; * ) ac_cv_transport_type=sockets ;; esac ]) am_utils_link_files=${am_utils_link_files}libamu/transputil.c:conf/transp/transp_${ac_cv_transport_type}.c" " # append transport utilities object to LIBOBJS for automatic compilation AC_LIBOBJ(transputil) if test $ac_cv_transport_type = tli then AC_DEFINE(HAVE_TRANSPORT_TYPE_TLI) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_nfs_fh_dref.m4000066400000000000000000000027461157065440000220110ustar00rootroot00000000000000dnl ###################################################################### dnl check the correct way to dereference the address part of the nfs fhandle AC_DEFUN([AMU_CHECK_NFS_FH_DREF], [ AC_CACHE_CHECK(nfs file-handle address dereferencing style, ac_cv_nfs_fh_dref_style, [ # select the correct nfs address dereferencing style case "${host_os}" in hpux[[6-9]]* | hpux10* ) ac_cv_nfs_fh_dref_style=hpux ;; sunos3* ) ac_cv_nfs_fh_dref_style=sunos3 ;; sunos4* | solaris1* ) ac_cv_nfs_fh_dref_style=sunos4 ;; svr4* | sysv4* | solaris* | sunos* | hpux* ) ac_cv_nfs_fh_dref_style=svr4 ;; bsd44* | bsdi2* | freebsd2.[[01]]* ) ac_cv_nfs_fh_dref_style=bsd44 ;; # all new BSDs changed the type of the # filehandle in nfs_args from nfsv2fh_t to u_char. freebsd* | freebsdelf* | bsdi* | netbsd* | openbsd* | darwin* | macosx* | rhapsody* ) ac_cv_nfs_fh_dref_style=freebsd22 ;; aix[[1-3]]* | aix4.[[01]]* ) ac_cv_nfs_fh_dref_style=aix3 ;; aix* ) ac_cv_nfs_fh_dref_style=aix42 ;; irix* ) ac_cv_nfs_fh_dref_style=irix ;; linux* ) ac_cv_nfs_fh_dref_style=linux ;; isc3 ) ac_cv_nfs_fh_dref_style=isc3 ;; osf[[1-3]]* ) ac_cv_nfs_fh_dref_style=osf2 ;; osf* ) ac_cv_nfs_fh_dref_style=osf4 ;; nextstep* ) ac_cv_nfs_fh_dref_style=nextstep ;; * ) ac_cv_nfs_fh_dref_style=default ;; esac ]) am_utils_nfs_fh_dref=$srcdir"/conf/fh_dref/fh_dref_"$ac_cv_nfs_fh_dref_style".h" AC_SUBST_FILE(am_utils_nfs_fh_dref) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_nfs_hn_dref.m4000066400000000000000000000012441157065440000220110ustar00rootroot00000000000000dnl ###################################################################### dnl check the correct way to dereference the hostname part of the nfs fhandle AC_DEFUN([AMU_CHECK_NFS_HN_DREF], [ AC_CACHE_CHECK(nfs hostname dereferencing style, ac_cv_nfs_hn_dref_style, [ # select the correct nfs address dereferencing style case "${host_os_name}" in linux* ) ac_cv_nfs_hn_dref_style=linux ;; isc3 ) ac_cv_nfs_hn_dref_style=isc3 ;; * ) ac_cv_nfs_hn_dref_style=default ;; esac ]) am_utils_nfs_hn_dref=$srcdir"/conf/hn_dref/hn_dref_"$ac_cv_nfs_hn_dref_style".h" AC_SUBST_FILE(am_utils_nfs_hn_dref) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_nfs_prot_headers.m4000066400000000000000000000054721157065440000230720ustar00rootroot00000000000000dnl ###################################################################### dnl check if system has NFS protocol headers AC_DEFUN([AMU_CHECK_NFS_PROT_HEADERS], [ AC_CACHE_CHECK(location of NFS protocol header files, ac_cv_nfs_prot_headers, [ # select the correct style for mounting filesystems case "${host_os}" in irix5* ) ac_cv_nfs_prot_headers=irix5 ;; irix* ) ac_cv_nfs_prot_headers=irix6 ;; sunos3* ) ac_cv_nfs_prot_headers=sunos3 ;; sunos4* | solaris1* ) ac_cv_nfs_prot_headers=sunos4 ;; sunos5.[[0-3]] | solaris2.[[0-3]] ) ac_cv_nfs_prot_headers=sunos5_3 ;; sunos5.4* | solaris2.4* ) ac_cv_nfs_prot_headers=sunos5_4 ;; sunos5.5* | solaris2.5* ) ac_cv_nfs_prot_headers=sunos5_5 ;; sunos5.6* | solaris2.6* ) ac_cv_nfs_prot_headers=sunos5_6 ;; sunos5.7* | solaris2.7* ) ac_cv_nfs_prot_headers=sunos5_7 ;; sunos5* | solaris2* ) ac_cv_nfs_prot_headers=sunos5_8 ;; bsdi2*) ac_cv_nfs_prot_headers=bsdi2 ;; bsdi* ) ac_cv_nfs_prot_headers=bsdi3 ;; freebsd2* ) ac_cv_nfs_prot_headers=freebsd2 ;; freebsd* | freebsdelf* ) ac_cv_nfs_prot_headers=freebsd3 ;; netbsd1.[[0-2]]* ) ac_cv_nfs_prot_headers=netbsd ;; netbsd1.3* ) ac_cv_nfs_prot_headers=netbsd1_3 ;; netbsd* | netbsdelf* ) ac_cv_nfs_prot_headers=netbsd1_4 ;; openbsd* ) ac_cv_nfs_prot_headers=openbsd ;; hpux[[6-9]]* | hpux10* ) ac_cv_nfs_prot_headers=hpux ;; hpux* ) ac_cv_nfs_prot_headers=hpux11 ;; aix[[1-3]]* ) ac_cv_nfs_prot_headers=aix3 ;; aix4.[[01]]* ) ac_cv_nfs_prot_headers=aix4 ;; aix4.2* ) ac_cv_nfs_prot_headers=aix4_2 ;; aix4.3* ) ac_cv_nfs_prot_headers=aix4_3 ;; aix5.1* ) ac_cv_nfs_prot_headers=aix5_1 ;; aix* ) ac_cv_nfs_prot_headers=aix5_2 ;; osf[[1-3]]* ) ac_cv_nfs_prot_headers=osf2 ;; osf4* ) ac_cv_nfs_prot_headers=osf4 ;; osf* ) ac_cv_nfs_prot_headers=osf5 ;; svr4* ) ac_cv_nfs_prot_headers=svr4 ;; sysv4* ) # this is for NCR2 machines ac_cv_nfs_prot_headers=ncr2 ;; linux* ) ac_cv_nfs_prot_headers=linux ;; nextstep* ) ac_cv_nfs_prot_headers=nextstep ;; ultrix* ) ac_cv_nfs_prot_headers=ultrix ;; darwin* | macosx* | rhapsody* ) ac_cv_nfs_prot_headers=darwin ;; * ) ac_cv_nfs_prot_headers=default ;; esac ]) # make sure correct header is linked in top build directory am_utils_nfs_prot_file="amu_nfs_prot.h" am_utils_link_files=${am_utils_link_files}${am_utils_nfs_prot_file}:conf/nfs_prot/nfs_prot_${ac_cv_nfs_prot_headers}.h" " # define the name of the header to be included for other M4 macros AC_DEFINE_UNQUOTED(AMU_NFS_PROTOCOL_HEADER, "${srcdir}/conf/nfs_prot/nfs_prot_${ac_cv_nfs_prot_headers}.h") # set headers in a macro for Makefile.am files to use (for dependencies) AMU_NFS_PROT_HEADER='${top_builddir}/'$am_utils_nfs_prot_file AC_SUBST(AMU_NFS_PROT_HEADER) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_nfs_sa_dref.m4000066400000000000000000000021071157065440000220060ustar00rootroot00000000000000dnl ###################################################################### dnl check the correct way to dereference the address part of the nfs fhandle AC_DEFUN([AMU_CHECK_NFS_SA_DREF], [ AC_CACHE_CHECK(nfs address dereferencing style, ac_cv_nfs_sa_dref_style, [ # select the correct nfs address dereferencing style case "${host_os}" in hpux[[6-9]]* | hpux10* | sunos[[34]]* | solaris1* ) ac_cv_nfs_sa_dref_style=default ;; svr4* | sysv4* | solaris* | sunos* | hpux* ) ac_cv_nfs_sa_dref_style=svr4 ;; 386bsd* | bsdi1* ) ac_cv_nfs_sa_dref_style=386bsd ;; bsd44* | bsdi* | freebsd* | netbsd* | openbsd* | darwin* | macosx* | rhapsody* ) ac_cv_nfs_sa_dref_style=bsd44 ;; linux* ) ac_cv_nfs_sa_dref_style=linux ;; aix* ) ac_cv_nfs_sa_dref_style=aix3 ;; aoi* ) ac_cv_nfs_sa_dref_style=aoi ;; isc3 ) ac_cv_nfs_sa_dref_style=isc3 ;; * ) ac_cv_nfs_sa_dref_style=default ;; esac ]) am_utils_nfs_sa_dref=$srcdir"/conf/sa_dref/sa_dref_"$ac_cv_nfs_sa_dref_style".h" AC_SUBST_FILE(am_utils_nfs_sa_dref) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_nfs_socket_connection.m4000066400000000000000000000014111157065440000241070ustar00rootroot00000000000000dnl ###################################################################### dnl check if need to turn on, off, or leave alone the NFS "noconn" option AC_DEFUN([AMU_CHECK_NFS_SOCKET_CONNECTION], [ AC_CACHE_CHECK(if to turn on/off noconn option, ac_cv_nfs_socket_connection, [ # set default to no-change ac_cv_nfs_socket_connection=none # select the correct style case "${host_os}" in openbsd2.[[01]]* ) ac_cv_nfs_socket_connection=noconn ;; openbsd* | freebsd* | freebsdelf* ) ac_cv_nfs_socket_connection=conn ;; esac ]) # set correct value case "$ac_cv_nfs_socket_connection" in noconn ) AC_DEFINE(USE_UNCONNECTED_NFS_SOCKETS) ;; conn ) AC_DEFINE(USE_CONNECTED_NFS_SOCKETS) ;; esac ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_os_libs.m4000066400000000000000000000016521157065440000211730ustar00rootroot00000000000000dnl ###################################################################### dnl set OS libraries specific to an OS: dnl libnsl/libsocket are needed only on solaris and some svr4 systems. dnl Using a typical macro has proven unsuccesful, because on some other dnl systems such as irix, including libnsl and or libsocket actually breaks dnl lots of code. So I am forced to use a special purpose macro that sets dnl the libraries based on the OS. Sigh. -Erez. AC_DEFUN([AMU_CHECK_OS_LIBS], [ AC_CACHE_CHECK(for additional OS libraries, ac_cv_os_libs, [ # select the correct set of libraries to link with case "${host_os_name}" in svr4* | sysv4* | solaris2* | sunos5* | aoi* ) ac_cv_os_libs="-lsocket -lnsl" ;; * ) ac_cv_os_libs=none ;; esac ]) # set list of libraries to link with if test "$ac_cv_os_libs" != none then LIBS="$ac_cv_os_libs $LIBS" fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_restartable_signal_handler.m4000066400000000000000000000013461157065440000251030ustar00rootroot00000000000000dnl ###################################################################### dnl check if a system needs to restart its signal handlers AC_DEFUN([AMU_CHECK_RESTARTABLE_SIGNAL_HANDLER], [ AC_CACHE_CHECK(if system needs to restart signal handlers, ac_cv_restartable_signal_handler, [ # select the correct systems to restart signal handlers case "${host_os_name}" in svr3* | svr4* | sysv4* | solaris2* | sunos5* | aoi* | irix* ) ac_cv_restartable_signal_handler=yes ;; * ) ac_cv_restartable_signal_handler=no ;; esac ]) # define REINSTALL_SIGNAL_HANDLER if need to if test "$ac_cv_restartable_signal_handler" = yes then AC_DEFINE(REINSTALL_SIGNAL_HANDLER) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_umount_style.m4000066400000000000000000000016241157065440000223070ustar00rootroot00000000000000dnl ###################################################################### dnl check style of unmounting filesystems AC_DEFUN([AMU_CHECK_UMOUNT_STYLE], [ AC_CACHE_CHECK(style of unmounting filesystems, ac_cv_style_umount, [ # select the correct style for unmounting filesystems case "${host_os_name}" in linux* ) ac_cv_style_umount=linux ;; bsd44* | bsdi* | freebsd* | netbsd* | openbsd* | darwin* | macosx* | rhapsody* ) ac_cv_style_umount=bsd44 ;; osf* ) ac_cv_style_umount=osf ;; aix* ) ac_cv_style_umount=aix ;; * ) ac_cv_style_umount=default ;; esac ]) am_utils_umount_style_file="umount_fs.c" am_utils_link_files=${am_utils_link_files}libamu/${am_utils_umount_style_file}:conf/umount/umount_${ac_cv_style_umount}.c" " # append un-mount utilities object to LIBOBJS for automatic compilation AC_LIBOBJ(umount_fs) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_unmount_args.m4000066400000000000000000000011571157065440000222620ustar00rootroot00000000000000dnl ###################################################################### dnl check the unmount system call arguments needed for AC_DEFUN([AMU_CHECK_UNMOUNT_ARGS], [ AC_CACHE_CHECK(unmount system-call arguments, ac_cv_unmount_args, [ # select the correct style to mount(2) a filesystem case "${host_os_name}" in aix* ) ac_cv_unmount_args="mnt->mnt_passno, 0" ;; ultrix* ) ac_cv_unmount_args="mnt->mnt_passno" ;; * ) ac_cv_unmount_args="mnt->mnt_dir" ;; esac ]) am_utils_unmount_args=$ac_cv_unmount_args AC_SUBST(am_utils_unmount_args) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_unmount_call.m4000066400000000000000000000015321157065440000222360ustar00rootroot00000000000000dnl ###################################################################### dnl check for the correct system call to unmount a filesystem. AC_DEFUN([AMU_CHECK_UNMOUNT_CALL], [ dnl make sure this one is called before [AC_CHECK_UNMOUNT_ARGS] AC_BEFORE([$0], [AC_CHECK_UNMOUNT_ARGS]) AC_CACHE_CHECK(the system call to unmount a filesystem, ac_cv_unmount_call, [ # check for various unmount a filesystem calls if test "$ac_cv_func_uvmount" = yes ; then ac_cv_unmount_call=uvmount elif test "$ac_cv_func_unmount" = yes ; then ac_cv_unmount_call=unmount elif test "$ac_cv_func_umount" = yes ; then ac_cv_unmount_call=umount else ac_cv_unmount_call=no fi ]) if test "$ac_cv_unmount_call" != no then am_utils_unmount_call=$ac_cv_unmount_call AC_SUBST(am_utils_unmount_call) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/check_varargs_macros.m4000066400000000000000000000020631157065440000225470ustar00rootroot00000000000000dnl ###################################################################### dnl check if compiler can handle variable-length argument macros AC_DEFUN([AMU_VARARGS_MACROS], [ AC_CACHE_CHECK(if compiler can handle variable-length macros, ac_cv_varargs_macros, [ # try C99 style AC_TRY_COMPILE( [ #define foo(str,size,fmt,...) bar(__FILE__,__LINE__,(str),(size),(fmt),__VA_ARGS__) ], [ char a[80]; foo(a, sizeof(a), "%d,%d", 1, 2); ], ac_cv_varargs_macros=c99, # else try gcc style AC_TRY_COMPILE( [ #define foo(str,size,args...) bar(__FILE__,__LINE__,(str),(size),(fmt),args) ], [ char a[80]; foo(a, sizeof(a), "%d,%d", 1, 2); ], ac_cv_varargs_macros=gcc, ac_cv_varargs_macros=none)) ]) if test "$ac_cv_varargs_macros" = c99 then AC_DEFINE(HAVE_C99_VARARGS_MACROS, 1, [System supports C99-style variable-length argument macros]) else if test "$ac_cv_varargs_macros" = gcc then AC_DEFINE(HAVE_GCC_VARARGS_MACROS, 1, [System supports GCC-style variable-length argument macros]) fi fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/expand_cpp_hex.m4000066400000000000000000000015311157065440000213650ustar00rootroot00000000000000dnl ###################################################################### dnl Expand the value of a CPP macro into a printable hex number. dnl Takes: header, macro, [action-if-found, [action-if-not-found]] dnl It runs the header through CPP looking for a match between the macro dnl and a string pattern, and if sucessful, it prints the string value out. AC_DEFUN([AMU_EXPAND_CPP_HEX], [ # we are looking for a regexp of a string AC_EGREP_CPP(0x, [$1] $2, value="notfound" AC_TRY_RUN( [ [$1] main(argc) int argc; { #ifdef $2 if (argc > 1) printf("0x%x", $2); exit(0); #else # error no such option $2 #endif exit(1); }], value=`./conftest dummy 2>>config.log`, value="notfound", value="notfound") , value="notfound" ) if test "$value" = notfound then : $4 else : $3 fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/expand_cpp_int.m4000066400000000000000000000016331157065440000213760ustar00rootroot00000000000000dnl ###################################################################### dnl Expand the value of a CPP macro into a printable integer number. dnl Takes: header, macro, [action-if-found, [action-if-not-found]] dnl It runs the header through CPP looking for a match between the macro dnl and a string pattern, and if sucessful, it prints the string value out. AC_DEFUN([AMU_EXPAND_CPP_INT], [ # we are looking for a regexp of an integer (must not start with 0 --- those # are octals). AC_EGREP_CPP( [[1-9]][[0-9]]*, [$1] $2, value="notfound" AC_TRY_RUN( [ [$1] main(argc) int argc; { #ifdef $2 if (argc > 1) printf("%d", $2); exit(0); #else # error no such option $2 #endif exit(1); }], value=`./conftest dummy 2>>config.log`, value="notfound", value="notfound") , value="notfound" ) if test "$value" = notfound then : $4 else : $3 fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/expand_cpp_string.m4000066400000000000000000000015321157065440000221100ustar00rootroot00000000000000dnl ###################################################################### dnl Expand the value of a CPP macro into a printable string. dnl Takes: header, macro, [action-if-found, [action-if-not-found]] dnl It runs the header through CPP looking for a match between the macro dnl and a string pattern, and if sucessful, it prints the string value out. AC_DEFUN([AMU_EXPAND_CPP_STRING], [ # we are looking for a regexp of a string AC_EGREP_CPP(\".*\", [$1] $2, value="notfound" AC_TRY_RUN( [ [$1] main(argc) int argc; { #ifdef $2 if (argc > 1) printf("%s", $2); exit(0); #else # error no such option $2 #endif exit(1); }], value=`./conftest dummy 2>>config.log`, value="notfound", value="notfound") , value="notfound" ) if test "$value" = notfound then : $4 else : $3 fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/expand_run_string.m4000066400000000000000000000010641157065440000221320ustar00rootroot00000000000000dnl ###################################################################### dnl Run a program and print its output as a string dnl Takes: (header, code-to-run, [action-if-found, [action-if-not-found]]) AC_DEFUN([AMU_EXPAND_RUN_STRING], [ value="notfound" AC_TRY_RUN( [ $1 main(argc) int argc; { $2 exit(0); }], [ value=`./conftest dummy 2>>config.log` test -z "$value" && value="notfound" ], value="notfound", value="notfound") if test "$value" = notfound then : $4 else : $3 fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/extern_optarg.m4000066400000000000000000000015711157065440000212650ustar00rootroot00000000000000dnl ###################################################################### dnl find if "extern char *optarg" exists in headers AC_DEFUN([AMU_EXTERN_OPTARG], [ AC_CACHE_CHECK(if external definition for optarg[] exists, ac_cv_extern_optarg, [ # try to compile program that uses the variable AC_TRY_COMPILE( [ #ifdef HAVE_STDIO_H # include #endif /* HAVE_STDIO_H */ #ifdef HAVE_UNISTD_H # include #endif /* HAVE_UNISTD_H */ #ifdef HAVE_STDLIB_H # include #endif /* HAVE_STDLIB_H */ #ifdef HAVE_SYS_ERRNO_H # include #endif /* HAVE_SYS_ERRNO_H */ #ifdef HAVE_ERRNO_H # include #endif /* HAVE_ERRNO_H */ ], [ char *cp = optarg; ], ac_cv_extern_optarg=yes, ac_cv_extern_optarg=no) ]) if test "$ac_cv_extern_optarg" = yes then AC_DEFINE(HAVE_EXTERN_OPTARG) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/extern_sys_errlist.m4000066400000000000000000000015731157065440000223550ustar00rootroot00000000000000dnl ###################################################################### dnl find if "extern char *sys_errlist[]" exist in headers AC_DEFUN([AMU_EXTERN_SYS_ERRLIST], [ AC_CACHE_CHECK(if external definition for sys_errlist[] exists, ac_cv_extern_sys_errlist, [ # try to locate pattern in header files #pattern="(extern)?.*char.*sys_errlist.*\[\]" pattern="(extern)?.*char.*sys_errlist.*" AC_EGREP_CPP(${pattern}, [ #ifdef HAVE_STDIO_H # include #endif /* HAVE_STDIO_H */ #ifdef HAVE_SYS_ERRNO_H # include #endif /* HAVE_SYS_ERRNO_H */ #ifdef HAVE_ERRNO_H # include #endif /* HAVE_ERRNO_H */ ], ac_cv_extern_sys_errlist=yes, ac_cv_extern_sys_errlist=no) ]) # check if need to define variable if test "$ac_cv_extern_sys_errlist" = yes then AC_DEFINE(HAVE_EXTERN_SYS_ERRLIST) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/field_mntent_t_mnt_time_string.m4000066400000000000000000000020711157065440000246550ustar00rootroot00000000000000fdnl ###################################################################### dnl find if mntent_t field mnt_time exists and is of type "char *" AC_DEFUN([AMU_FIELD_MNTENT_T_MNT_TIME_STRING], [ AC_CACHE_CHECK(if mntent_t field mnt_time exist as type string, ac_cv_field_mntent_t_mnt_time_string, [ # try to compile a program AC_TRY_COMPILE( AMU_MOUNT_HEADERS( [ /* now set the typedef */ #ifdef HAVE_STRUCT_MNTENT typedef struct mntent mntent_t; #else /* not HAVE_STRUCT_MNTENT */ # ifdef HAVE_STRUCT_MNTTAB typedef struct mnttab mntent_t; # else /* not HAVE_STRUCT_MNTTAB */ # error XXX: could not find definition for struct mntent or struct mnttab! # endif /* not HAVE_STRUCT_MNTTAB */ #endif /* not HAVE_STRUCT_MNTENT */ ]), [ mntent_t mtt; char *cp = "test"; int i; mtt.mnt_time = cp; i = mtt.mnt_time[0]; ], ac_cv_field_mntent_t_mnt_time_string=yes, ac_cv_field_mntent_t_mnt_time_string=no) ]) if test "$ac_cv_field_mntent_t_mnt_time_string" = yes then AC_DEFINE(HAVE_MNTENT_T_MNT_TIME_STRING) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/func_bad_hasmntopt.m4000066400000000000000000000030231157065440000222340ustar00rootroot00000000000000dnl ###################################################################### dnl Check if we have as buggy hasmntopt() libc function AC_DEFUN([AMU_FUNC_BAD_HASMNTOPT], [ AC_CACHE_CHECK([for working hasmntopt], ac_cv_func_hasmntopt_working, [AC_TRY_RUN( AMU_MOUNT_HEADERS( [[ #ifdef HAVE_MNTENT_H /* some systems need before is included */ # ifdef HAVE_STDIO_H # include # endif /* HAVE_STDIO_H */ # include #endif /* HAVE_MNTENT_H */ #ifdef HAVE_SYS_MNTENT_H # include #endif /* HAVE_SYS_MNTENT_H */ #ifdef HAVE_SYS_MNTTAB_H # include #endif /* HAVE_SYS_MNTTAB_H */ #if defined(HAVE_MNTTAB_H) && !defined(MNTTAB) # include #endif /* defined(HAVE_MNTTAB_H) && !defined(MNTTAB) */ #ifdef HAVE_STRUCT_MNTENT typedef struct mntent mntent_t; #else /* not HAVE_STRUCT_MNTENT */ # ifdef HAVE_STRUCT_MNTTAB typedef struct mnttab mntent_t; /* map struct mnttab field names to struct mntent field names */ # define mnt_opts mnt_mntopts # endif /* not HAVE_STRUCT_MNTTAB */ #endif /* not HAVE_STRUCT_MNTENT */ int main() { mntent_t mnt; char *tmp = NULL; /* * Test if hasmntopt will incorrectly find the string "soft", which * is part of the large "softlookup" function. */ mnt.mnt_opts = "hard,softlookup,ro"; if ((tmp = hasmntopt(&mnt, "soft"))) exit(1); exit(0); } ]]), [ac_cv_func_hasmntopt_working=yes], [ac_cv_func_hasmntopt_working=no] )]) if test $ac_cv_func_hasmntopt_working = no then AC_LIBOBJ([hasmntopt]) AC_DEFINE(HAVE_BAD_HASMNTOPT) fi ]) am-utils-6.2+rc20110530/m4/macros/func_bad_memcmp.m4000066400000000000000000000005121157065440000214750ustar00rootroot00000000000000dnl My version is similar to the one from Autoconf 2.52, but I also dnl define HAVE_BAD_MEMCMP so that I can do smarter things to avoid dnl linkage conflicts with bad memcmp versions that are in libc. AC_DEFUN([AMU_FUNC_BAD_MEMCMP], [ AC_FUNC_MEMCMP if test "$ac_cv_func_memcmp_working" = no then AC_DEFINE(HAVE_BAD_MEMCMP) fi ]) am-utils-6.2+rc20110530/m4/macros/func_bad_yp_all.m4000066400000000000000000000012241157065440000215000ustar00rootroot00000000000000dnl Check for a yp_all() function that does not leak a file descriptor dnl to the ypserv process. AC_DEFUN([AMU_FUNC_BAD_YP_ALL], [ AC_CACHE_CHECK(for a file-descriptor leakage clean yp_all, ac_cv_func_yp_all_clean, [ # clean by default ac_cv_func_yp_all_clean=yes # select the correct type case "${host_os_name}" in irix* ) ac_cv_func_yp_all_clean=no ;; linux* ) # RedHat 5.1 systems with glibc glibc-2.0.7-19 or below # leak a UDP socket from yp_all() case "`cat /etc/redhat-release /dev/null 2>/dev/null`" in *5.1* ) ac_cv_func_yp_all_clean=no ;; esac esac ]) if test $ac_cv_func_yp_all_clean = no then AC_DEFINE(HAVE_BAD_YP_ALL) fi ]) am-utils-6.2+rc20110530/m4/macros/header_templates.m4000066400000000000000000000640441157065440000217160ustar00rootroot00000000000000dnl FILE: m4/macros/header_templates.m4 dnl defines descriptions for various am-utils specific macros AH_TEMPLATE([HAVE_AMU_FS_AUTO], [Define if have automount filesystem]) AH_TEMPLATE([HAVE_AMU_FS_DIRECT], [Define if have direct automount filesystem]) AH_TEMPLATE([HAVE_AMU_FS_TOPLVL], [Define if have "top-level" filesystem]) AH_TEMPLATE([HAVE_AMU_FS_ERROR], [Define if have error filesystem]) AH_TEMPLATE([HAVE_AMU_FS_PROGRAM], [Define if have program filesystem]) AH_TEMPLATE([HAVE_AMU_FS_LINK], [Define if have symbolic-link filesystem]) AH_TEMPLATE([HAVE_AMU_FS_LINKX], [Define if have symlink with existence check filesystem]) AH_TEMPLATE([HAVE_AMU_FS_HOST], [Define if have NFS host-tree filesystem]) AH_TEMPLATE([HAVE_AMU_FS_NFSL], [Define if have nfsl (NFS with local link check) filesystem]) AH_TEMPLATE([HAVE_AMU_FS_NFSX], [Define if have multi-NFS filesystem]) AH_TEMPLATE([HAVE_AMU_FS_UNION], [Define if have union filesystem]) AH_TEMPLATE([HAVE_MAP_FILE], [Define if have file maps (everyone should have it!)]) AH_TEMPLATE([HAVE_MAP_NIS], [Define if have NIS maps]) AH_TEMPLATE([HAVE_MAP_NISPLUS], [Define if have NIS+ maps]) AH_TEMPLATE([HAVE_MAP_DBM], [Define if have DBM maps]) AH_TEMPLATE([HAVE_MAP_NDBM], [Define if have NDBM maps]) AH_TEMPLATE([HAVE_MAP_HESIOD], [Define if have HESIOD maps]) AH_TEMPLATE([HAVE_MAP_LDAP], [Define if have LDAP maps]) AH_TEMPLATE([HAVE_MAP_PASSWD], [Define if have PASSWD maps]) AH_TEMPLATE([HAVE_MAP_SUN], [Define if have Sun-syntax maps]) AH_TEMPLATE([HAVE_MAP_UNION], [Define if have UNION maps]) AH_TEMPLATE([HAVE_MAP_EXEC], [Define if have executable maps]) AH_TEMPLATE([HAVE_FS_UFS], [Define if have UFS filesystem]) AH_TEMPLATE([HAVE_FS_FFS], [Define if have FFS filesystem]) AH_TEMPLATE([HAVE_FS_XFS], [Define if have XFS filesystem (irix)]) AH_TEMPLATE([HAVE_FS_EFS], [Define if have EFS filesystem (irix)]) AH_TEMPLATE([HAVE_FS_NFS], [Define if have NFS filesystem]) AH_TEMPLATE([HAVE_FS_NFS3], [Define if have NFS3 filesystem]) AH_TEMPLATE([HAVE_FS_PCFS], [Define if have PCFS filesystem]) AH_TEMPLATE([HAVE_FS_LOFS], [Define if have LOFS filesystem]) AH_TEMPLATE([HAVE_FS_HSFS], [Define if have HSFS filesystem]) AH_TEMPLATE([HAVE_FS_CDFS], [Define if have CDFS filesystem]) AH_TEMPLATE([HAVE_FS_UDF], [Define if have UDF filesystem]) AH_TEMPLATE([HAVE_FS_TFS], [Define if have TFS filesystem]) AH_TEMPLATE([HAVE_FS_TMPFS], [Define if have TMPFS filesystem]) AH_TEMPLATE([HAVE_FS_MFS], [Define if have MFS filesystem]) AH_TEMPLATE([HAVE_FS_CFS], [Define if have CFS (crypto) filesystem]) AH_TEMPLATE([HAVE_FS_AUTOFS], [Define if have AUTOFS filesystem]) AH_TEMPLATE([HAVE_FS_CACHEFS], [Define if have CACHEFS filesystem]) AH_TEMPLATE([HAVE_FS_NULLFS], [Define if have NULLFS (loopback on bsd44) filesystem]) AH_TEMPLATE([HAVE_FS_UNIONFS], [Define if have UNIONFS filesystem]) AH_TEMPLATE([HAVE_FS_UMAPFS], [Define if have UMAPFS (uid/gid mapping) filesystem]) AH_TEMPLATE([MOUNT_TYPE_UFS], [Mount(2) type/name for UFS filesystem]) AH_TEMPLATE([MOUNT_TYPE_FFS], [Mount(2) type/name for FFS filesystem]) AH_TEMPLATE([MOUNT_TYPE_XFS], [Mount(2) type/name for XFS filesystem (irix)]) AH_TEMPLATE([MOUNT_TYPE_EFS], [Mount(2) type/name for EFS filesystem (irix)]) AH_TEMPLATE([MOUNT_TYPE_NFS], [Mount(2) type/name for NFS filesystem]) AH_TEMPLATE([MOUNT_TYPE_NFS3], [Mount(2) type/name for NFS3 filesystem]) AH_TEMPLATE([MOUNT_TYPE_PCFS], [Mount(2) type/name for PCFS filesystem. XXX: conf/trap/trap_hpux.h may override this definition for HPUX 9.0]) AH_TEMPLATE([MOUNT_TYPE_LOFS], [Mount(2) type/name for LOFS filesystem]) AH_TEMPLATE([MOUNT_TYPE_CDFS], [Mount(2) type/name for CDFS filesystem]) AH_TEMPLATE([MOUNT_TYPE_UDF], [Mount(2) type/name for UDF filesystem]) AH_TEMPLATE([MOUNT_TYPE_TFS], [Mount(2) type/name for TFS filesystem]) AH_TEMPLATE([MOUNT_TYPE_TMPFS], [Mount(2) type/name for TMPFS filesystem]) AH_TEMPLATE([MOUNT_TYPE_MFS], [Mount(2) type/name for MFS filesystem]) AH_TEMPLATE([MOUNT_TYPE_CFS], [Mount(2) type/name for CFS (crypto) filesystem]) AH_TEMPLATE([MOUNT_TYPE_AUTOFS], [Mount(2) type/name for AUTOFS filesystem]) AH_TEMPLATE([MOUNT_TYPE_CACHEFS], [Mount(2) type/name for CACHEFS filesystem]) AH_TEMPLATE([MOUNT_TYPE_IGNORE], [Mount(2) type/name for IGNORE filesystem (not real just ignore for df)]) AH_TEMPLATE([MOUNT_TYPE_NULLFS], [Mount(2) type/name for NULLFS (loopback on bsd44) filesystem]) AH_TEMPLATE([MOUNT_TYPE_UNIONFS], [Mount(2) type/name for UNIONFS filesystem]) AH_TEMPLATE([MOUNT_TYPE_UMAPFS], [Mount(2) type/name for UMAPFS (uid/gid mapping) filesystem]) AH_TEMPLATE([MNTTAB_TYPE_UFS], [Mount-table entry name for UFS filesystem]) AH_TEMPLATE([MNTTAB_TYPE_FFS], [Mount-table entry name for FFS filesystem]) AH_TEMPLATE([MNTTAB_TYPE_XFS], [Mount-table entry name for XFS filesystem (irix)]) AH_TEMPLATE([MNTTAB_TYPE_EFS], [Mount-table entry name for EFS filesystem (irix)]) AH_TEMPLATE([MNTTAB_TYPE_NFS], [Mount-table entry name for NFS filesystem]) AH_TEMPLATE([MNTTAB_TYPE_NFS3], [Mount-table entry name for NFS3 filesystem]) AH_TEMPLATE([MNTTAB_TYPE_PCFS], [Mount-table entry name for PCFS filesystem]) AH_TEMPLATE([MNTTAB_TYPE_LOFS], [Mount-table entry name for LOFS filesystem]) AH_TEMPLATE([MNTTAB_TYPE_CDFS], [Mount-table entry name for CDFS filesystem]) AH_TEMPLATE([MNTTAB_TYPE_UDF], [Mount-table entry name for UDF filesystem]) AH_TEMPLATE([MNTTAB_TYPE_TFS], [Mount-table entry name for TFS filesystem]) AH_TEMPLATE([MNTTAB_TYPE_TMPFS], [Mount-table entry name for TMPFS filesystem]) AH_TEMPLATE([MNTTAB_TYPE_MFS], [Mount-table entry name for MFS filesystem]) AH_TEMPLATE([MNTTAB_TYPE_CFS], [Mount-table entry name for CFS (crypto) filesystem]) AH_TEMPLATE([MNTTAB_TYPE_AUTOFS], [Mount-table entry name for AUTOFS filesystem]) AH_TEMPLATE([MNTTAB_TYPE_CACHEFS], [Mount-table entry name for CACHEFS filesystem]) AH_TEMPLATE([MNTTAB_TYPE_NULLFS], [Mount-table entry name for NULLFS (loopback on bsd44) filesystem]) AH_TEMPLATE([MNTTAB_TYPE_UNIONFS], [Mount-table entry name for UNIONFS filesystem]) AH_TEMPLATE([MNTTAB_TYPE_UMAPFS], [Mount-table entry name for UMAPFS (uid/gid mapping) filesystem]) AH_TEMPLATE([MNTTAB_FILE_NAME], [Name of mount table file name]) AH_TEMPLATE([HIDE_MOUNT_TYPE], [Name of mount type to hide amd mount from df(1)]) AH_TEMPLATE([MNTTAB_OPT_RO], [Mount Table option string: Read only]) AH_TEMPLATE([MNTTAB_OPT_RW], [Mount Table option string: Read/write]) AH_TEMPLATE([MNTTAB_OPT_RQ], [Mount Table option string: Read/write with quotas]) AH_TEMPLATE([MNTTAB_OPT_QUOTA], [Mount Table option string: Check quotas]) AH_TEMPLATE([MNTTAB_OPT_NOQUOTA], [Mount Table option string: Don't check quotas]) AH_TEMPLATE([MNTTAB_OPT_ONERROR], [Mount Table option string: action to taken on error]) AH_TEMPLATE([MNTTAB_OPT_TOOSOON], [Mount Table option string: min. time between inconsistencies]) AH_TEMPLATE([MNTTAB_OPT_SOFT], [Mount Table option string: Soft mount]) AH_TEMPLATE([MNTTAB_OPT_SPONGY], [Mount Table option string: spongy mount]) AH_TEMPLATE([MNTTAB_OPT_HARD], [Mount Table option string: Hard mount]) AH_TEMPLATE([MNTTAB_OPT_SUID], [Mount Table option string: Set uid allowed]) AH_TEMPLATE([MNTTAB_OPT_NOSUID], [Mount Table option string: Set uid not allowed]) AH_TEMPLATE([MNTTAB_OPT_GRPID], [Mount Table option string: SysV-compatible gid on create]) AH_TEMPLATE([MNTTAB_OPT_REMOUNT], [Mount Table option string: Change mount options]) AH_TEMPLATE([MNTTAB_OPT_NOSUB], [Mount Table option string: Disallow mounts on subdirs]) AH_TEMPLATE([MNTTAB_OPT_MULTI], [Mount Table option string: Do multi-component lookup]) AH_TEMPLATE([MNTTAB_OPT_INTR], [Mount Table option string: Allow NFS ops to be interrupted]) AH_TEMPLATE([MNTTAB_OPT_NOINTR], [Mount Table option string: Don't allow interrupted ops]) AH_TEMPLATE([MNTTAB_OPT_PORT], [Mount Table option string: NFS server IP port number]) AH_TEMPLATE([MNTTAB_OPT_SECURE], [Mount Table option string: Secure (AUTH_DES) mounting]) AH_TEMPLATE([MNTTAB_OPT_KERB], [Mount Table option string: Secure (AUTH_Kerb) mounting]) AH_TEMPLATE([MNTTAB_OPT_RSIZE], [Mount Table option string: Max NFS read size (bytes)]) AH_TEMPLATE([MNTTAB_OPT_WSIZE], [Mount Table option string: Max NFS write size (bytes)]) AH_TEMPLATE([MNTTAB_OPT_TIMEO], [Mount Table option string: NFS timeout (1/10 sec)]) AH_TEMPLATE([MNTTAB_OPT_RETRANS], [Mount Table option string: Max retransmissions (soft mnts)]) AH_TEMPLATE([MNTTAB_OPT_ACTIMEO], [Mount Table option string: Attr cache timeout (sec)]) AH_TEMPLATE([MNTTAB_OPT_ACREGMIN], [Mount Table option string: Min attr cache timeout (files)]) AH_TEMPLATE([MNTTAB_OPT_ACREGMAX], [Mount Table option string: Max attr cache timeout (files)]) AH_TEMPLATE([MNTTAB_OPT_ACDIRMIN], [Mount Table option string: Min attr cache timeout (dirs)]) AH_TEMPLATE([MNTTAB_OPT_ACDIRMAX], [Mount Table option string: Max attr cache timeout (dirs)]) AH_TEMPLATE([MNTTAB_OPT_NOAC], [Mount Table option string: Don't cache attributes at all]) AH_TEMPLATE([MNTTAB_OPT_NOCTO], [Mount Table option string: No close-to-open consistency]) AH_TEMPLATE([MNTTAB_OPT_BG], [Mount Table option string: Do mount retries in background]) AH_TEMPLATE([MNTTAB_OPT_FG], [Mount Table option string: Do mount retries in foreground]) AH_TEMPLATE([MNTTAB_OPT_RETRY], [Mount Table option string: Number of mount retries]) AH_TEMPLATE([MNTTAB_OPT_DEV], [Mount Table option string: Device id of mounted fs]) AH_TEMPLATE([MNTTAB_OPT_FSID], [Mount Table option string: Filesystem id of mounted fs]) AH_TEMPLATE([MNTTAB_OPT_POSIX], [Mount Table option string: Get static pathconf for mount]) AH_TEMPLATE([MNTTAB_OPT_PRIVATE], [Mount Table option string: Use local locking]) AH_TEMPLATE([MNTTAB_OPT_MAP], [Mount Table option string: Automount map]) AH_TEMPLATE([MNTTAB_OPT_DIRECT], [Mount Table option string: Automount direct map mount]) AH_TEMPLATE([MNTTAB_OPT_INDIRECT], [Mount Table option string: Automount indirect map mount]) AH_TEMPLATE([MNTTAB_OPT_LLOCK], [Mount Table option string: Local locking (no lock manager)]) AH_TEMPLATE([MNTTAB_OPT_IGNORE], [Mount Table option string: Ignore this entry]) AH_TEMPLATE([MNTTAB_OPT_NOAUTO], [Mount Table option string: No auto (what?)]) AH_TEMPLATE([MNTTAB_OPT_NOCONN], [Mount Table option string: No connection]) AH_TEMPLATE([MNTTAB_OPT_VERS], [Mount Table option string: protocol version number indicator]) AH_TEMPLATE([MNTTAB_OPT_PROTO], [Mount Table option string: protocol network_id indicator]) AH_TEMPLATE([MNTTAB_OPT_SYNCDIR], [Mount Table option string: Synchronous local directory ops]) AH_TEMPLATE([MNTTAB_OPT_NOSETSEC], [Mount Table option string: Do no allow setting sec attrs]) AH_TEMPLATE([MNTTAB_OPT_SYMTTL], [Mount Table option string: set symlink cache time-to-live]) AH_TEMPLATE([MNTTAB_OPT_COMPRESS], [Mount Table option string: compress]) AH_TEMPLATE([MNTTAB_OPT_PGTHRESH], [Mount Table option string: paging threshold]) AH_TEMPLATE([MNTTAB_OPT_MAXGROUPS], [Mount Table option string: max groups]) AH_TEMPLATE([MNTTAB_OPT_PROPLIST], [Mount Table option string: support property lists (ACLs)]) AH_TEMPLATE([MNTTAB_OPT_LONGNAME], [Force Win95 long names]) AH_TEMPLATE([MNTTAB_OPT_NOWIN95], [Completely ignore Win95 entries]) AH_TEMPLATE([MNTTAB_OPT_SHORTNAME], [Force old DOS short names only]) AH_TEMPLATE([MNT2_GEN_OPT_ASYNC], [asynchronous filesystem access]) AH_TEMPLATE([MNT2_GEN_OPT_AUTOMNTFS], [automounter filesystem (ignore) flag, used in bsdi-4.1]) AH_TEMPLATE([MNT2_GEN_OPT_AUTOMOUNTED], [automounter filesystem flag, used in Mac OS X / Darwin]) AH_TEMPLATE([MNT2_GEN_OPT_BIND], [directory hardlink]) AH_TEMPLATE([MNT2_GEN_OPT_CACHE], [cache (what?)]) AH_TEMPLATE([MNT2_GEN_OPT_DATA], [6-argument mount]) AH_TEMPLATE([MNT2_GEN_OPT_DETACH], [Use a lazy unmount (detach)]) AH_TEMPLATE([MNT2_GEN_OPT_FORCE], [Use a forced unmount]) AH_TEMPLATE([MNT2_GEN_OPT_FSS], [old (4-argument) mount (compatibility)]) AH_TEMPLATE([MNT2_GEN_OPT_IGNORE], [ignore mount entry in df output]) AH_TEMPLATE([MNT2_GEN_OPT_JFS], [journaling filesystem (AIX's UFS/FFS)]) AH_TEMPLATE([MNT2_GEN_OPT_GRPID], [old BSD group-id on create]) AH_TEMPLATE([MNT2_GEN_OPT_MULTI], [do multi-component lookup on files]) AH_TEMPLATE([MNT2_GEN_OPT_NEWTYPE], [use type string instead of int]) AH_TEMPLATE([MNT2_GEN_OPT_NFS], [NFS mount]) AH_TEMPLATE([MNT2_GEN_OPT_NOCACHE], [nocache (what?)]) AH_TEMPLATE([MNT2_GEN_OPT_NODEV], [do not interpret special device files]) AH_TEMPLATE([MNT2_GEN_OPT_NOEXEC], [no exec calls allowed]) AH_TEMPLATE([MNT2_GEN_OPT_NONDEV], [do not interpret special device files]) AH_TEMPLATE([MNT2_GEN_OPT_NOSUB], [Disallow mounts beneath this mount]) AH_TEMPLATE([MNT2_GEN_OPT_NOSUID], [Setuid programs disallowed]) AH_TEMPLATE([MNT2_GEN_OPT_NOTRUNC], [Return ENAMETOOLONG for long filenames]) AH_TEMPLATE([MNT2_GEN_OPT_OPTIONSTR], [Pass mount option string to kernel]) AH_TEMPLATE([MNT2_GEN_OPT_OVERLAY], [allow overlay mounts]) AH_TEMPLATE([MNT2_GEN_OPT_QUOTA], [check quotas]) AH_TEMPLATE([MNT2_GEN_OPT_RDONLY], [Read-only]) AH_TEMPLATE([MNT2_GEN_OPT_REMOUNT], [change options on an existing mount]) AH_TEMPLATE([MNT2_GEN_OPT_RONLY], [read only]) AH_TEMPLATE([MNT2_GEN_OPT_SYNC], [synchronize data immediately to filesystem]) AH_TEMPLATE([MNT2_GEN_OPT_SYNCHRONOUS], [synchronous filesystem access (same as SYNC)]) AH_TEMPLATE([MNT2_GEN_OPT_SYS5], [Mount with Sys 5-specific semantics]) AH_TEMPLATE([MNT2_GEN_OPT_UNION], [Union mount]) AH_TEMPLATE([MNT2_NFS_OPT_AUTO], [hide mount type from df(1)]) AH_TEMPLATE([MNT2_NFS_OPT_ACDIRMAX], [set max secs for dir attr cache]) AH_TEMPLATE([MNT2_NFS_OPT_ACDIRMIN], [set min secs for dir attr cache]) AH_TEMPLATE([MNT2_NFS_OPT_ACREGMAX], [set max secs for file attr cache]) AH_TEMPLATE([MNT2_NFS_OPT_ACREGMIN], [set min secs for file attr cache]) AH_TEMPLATE([MNT2_NFS_OPT_AUTHERR], [Authentication error]) AH_TEMPLATE([MNT2_NFS_OPT_DEADTHRESH], [set dead server retry thresh]) AH_TEMPLATE([MNT2_NFS_OPT_DISMINPROG], [Dismount in progress]) AH_TEMPLATE([MNT2_NFS_OPT_DISMNT], [Dismounted]) AH_TEMPLATE([MNT2_NFS_OPT_DUMBTIMR], [Don't estimate rtt dynamically]) AH_TEMPLATE([MNT2_NFS_OPT_GRPID], [System V-style gid inheritance]) AH_TEMPLATE([MNT2_NFS_OPT_HASAUTH], [Has authenticator]) AH_TEMPLATE([MNT2_NFS_OPT_FSNAME], [provide name of server's fs to system]) AH_TEMPLATE([MNT2_NFS_OPT_HOSTNAME], [set hostname for error printf]) AH_TEMPLATE([MNT2_NFS_OPT_IGNORE], [ignore mount point]) AH_TEMPLATE([MNT2_NFS_OPT_INT], [allow interrupts on hard mount]) AH_TEMPLATE([MNT2_NFS_OPT_INTR], [allow interrupts on hard mount]) AH_TEMPLATE([MNT2_NFS_OPT_INTERNAL], [Bits set internally]) AH_TEMPLATE([MNT2_NFS_OPT_KERB], [Use Kerberos authentication]) AH_TEMPLATE([MNT2_NFS_OPT_KERBEROS], [use kerberos credentials]) AH_TEMPLATE([MNT2_NFS_OPT_KNCONF], [transport's knetconfig structure]) AH_TEMPLATE([MNT2_NFS_OPT_LEASETERM], [set lease term (nqnfs)]) AH_TEMPLATE([MNT2_NFS_OPT_LLOCK], [Local locking (no lock manager)]) AH_TEMPLATE([MNT2_NFS_OPT_MAXGRPS], [set maximum grouplist size]) AH_TEMPLATE([MNT2_NFS_OPT_MNTD], [Mnt server for mnt point]) AH_TEMPLATE([MNT2_NFS_OPT_MYWRITE], [Assume writes were mine]) AH_TEMPLATE([MNT2_NFS_OPT_NFSV3], [mount NFS Version 3]) AH_TEMPLATE([MNT2_NFS_OPT_NOAC], [don't cache attributes]) AH_TEMPLATE([MNT2_NFS_OPT_NOCONN], [Don't Connect the socket]) AH_TEMPLATE([MNT2_NFS_OPT_NOCTO], [no close-to-open consistency]) AH_TEMPLATE([MNT2_NFS_OPT_NOINT], [disallow interrupts on hard mounts]) AH_TEMPLATE([MNT2_NFS_OPT_NQLOOKLEASE], [Get lease for lookup]) AH_TEMPLATE([MNT2_NFS_OPT_NONLM], [Don't use locking]) AH_TEMPLATE([MNT2_NFS_OPT_NQNFS], [Use Nqnfs protocol]) AH_TEMPLATE([MNT2_NFS_OPT_POSIX], [static pathconf kludge info]) AH_TEMPLATE([MNT2_NFS_OPT_PRIVATE], [Use local locking]) AH_TEMPLATE([MNT2_NFS_OPT_RCVLOCK], [Rcv socket lock]) AH_TEMPLATE([MNT2_NFS_OPT_RDIRALOOK], [Do lookup with readdir (nqnfs)]) AH_TEMPLATE([MNT2_NFS_OPT_PROPLIST], [allow property list operations (ACLs over NFS)]) AH_TEMPLATE([MNT2_NFS_OPT_RDIRPLUS], [Use Readdirplus for NFSv3]) AH_TEMPLATE([MNT2_NFS_OPT_READAHEAD], [set read ahead]) AH_TEMPLATE([MNT2_NFS_OPT_READDIRSIZE], [Set readdir size]) AH_TEMPLATE([MNT2_NFS_OPT_RESVPORT], [Allocate a reserved port]) AH_TEMPLATE([MNT2_NFS_OPT_RETRANS], [set number of request retries]) AH_TEMPLATE([MNT2_NFS_OPT_RONLY], [read only]) AH_TEMPLATE([MNT2_NFS_OPT_RPCTIMESYNC], [use RPC to do secure NFS time sync]) AH_TEMPLATE([MNT2_NFS_OPT_RSIZE], [set read size]) AH_TEMPLATE([MNT2_NFS_OPT_SECURE], [secure mount]) AH_TEMPLATE([MNT2_NFS_OPT_SNDLOCK], [Send socket lock]) AH_TEMPLATE([MNT2_NFS_OPT_SOFT], [soft mount (hard is default)]) AH_TEMPLATE([MNT2_NFS_OPT_SPONGY], [spongy mount]) AH_TEMPLATE([MNT2_NFS_OPT_TIMEO], [set initial timeout]) AH_TEMPLATE([MNT2_NFS_OPT_TCP], [use TCP for mounts]) AH_TEMPLATE([MNT2_NFS_OPT_VER3], [linux NFSv3]) AH_TEMPLATE([MNT2_NFS_OPT_WAITAUTH], [Wait for authentication]) AH_TEMPLATE([MNT2_NFS_OPT_WANTAUTH], [Wants an authenticator]) AH_TEMPLATE([MNT2_NFS_OPT_WANTRCV], [Want receive socket lock]) AH_TEMPLATE([MNT2_NFS_OPT_WANTSND], [Want send socket lock]) AH_TEMPLATE([MNT2_NFS_OPT_WSIZE], [set write size]) AH_TEMPLATE([MNT2_NFS_OPT_SYMTTL], [set symlink cache time-to-live]) AH_TEMPLATE([MNT2_NFS_OPT_PGTHRESH], [paging threshold]) AH_TEMPLATE([MNT2_NFS_OPT_XLATECOOKIE], [32<->64 dir cookie translation]) AH_TEMPLATE([MNT2_CDFS_OPT_DEFPERM], [Ignore permission bits]) AH_TEMPLATE([MNT2_CDFS_OPT_EXTATT], [Enable external attributes]) AH_TEMPLATE([MNT2_CDFS_OPT_GENS], [Show file generations]) AH_TEMPLATE([MNT2_CDFS_OPT_NOCASETRANS], [Disable filename case translation]) AH_TEMPLATE([MNT2_CDFS_OPT_NODEFPERM], [Use on-disk permission bits]) AH_TEMPLATE([MNT2_CDFS_OPT_NOJOLIET], [Disable Joliet extensions]) AH_TEMPLATE([MNT2_CDFS_OPT_NORRIP], [Disable Rock Ridge Interchange Protocol (RRIP) extensions]) AH_TEMPLATE([MNT2_CDFS_OPT_NOVERSION], [Strip off extension from version string]) AH_TEMPLATE([MNT2_CDFS_OPT_RRCASEINS], [Enable Rock Ridge Interchange Protocol (RRIP) case insensitive filename extensions]) AH_TEMPLATE([MNT2_CDFS_OPT_RRIP], [Use Rock Ridge Interchange Protocol (RRIP) extensions]) AH_TEMPLATE([MNT2_UDF_OPT_CLOSESESSION], [Close session when unmounting]) AH_TEMPLATE([MNT2_PCFS_OPT_LONGNAME], [Force Win95 long names]) AH_TEMPLATE([MNT2_PCFS_OPT_NOWIN95], [Completely ignore Win95 entries]) AH_TEMPLATE([MNT2_PCFS_OPT_SHORTNAME], [Force old DOS short names only]) AH_TEMPLATE([HAVE_MNTENT_T_MNT_TIME_STRING], [does mntent_t have mnt_time field and is of type "char *" ?]) AH_TEMPLATE([REINSTALL_SIGNAL_HANDLER], [should signal handlers be reinstalled?]) AH_TEMPLATE([DEBUG], [Turn off general debugging by default]) AH_TEMPLATE([DEBUG_MEM], [Turn off memory debugging by default]) AH_TEMPLATE([PACKAGE_NAME], [Define package name (must be defined by configure.in)]) AH_TEMPLATE([PACKAGE_VERSION], [Define version of package (must be defined by configure.in)]) AH_TEMPLATE([PACKAGE_BUGREPORT], [Define bug-reporting address (must be defined by configure.in)]) AH_TEMPLATE([HOST_CPU], [Define name of host machine's cpu (eg. sparc)]) AH_TEMPLATE([HOST_ARCH], [Define name of host machine's architecture (eg. sun4)]) AH_TEMPLATE([DISTRO_NAME], [Define name of host OS's distribution name (eg. debian, redhat, suse, etc.)]) AH_TEMPLATE([HOST_VENDOR], [Define name of host machine's vendor (eg. sun)]) AH_TEMPLATE([HOST_OS], [Define name and version of host machine (eg. solaris2.5.1)]) AH_TEMPLATE([HOST_OS_NAME], [Define only name of host machine OS (eg. solaris2)]) AH_TEMPLATE([HOST_OS_VERSION], [Define only version of host machine (eg. 2.5.1)]) AH_TEMPLATE([HOST_HEADER_VERSION], [Define the header version of (linux) hosts (eg. 2.2.10)]) AH_TEMPLATE([HOST_NAME], [Define name of host]) AH_TEMPLATE([USER_NAME], [Define user name]) AH_TEMPLATE([CONFIG_DATE], [Define configuration date]) AH_TEMPLATE([HAVE_TRANSPORT_TYPE_TLI], [what type of network transport type is in use? TLI or sockets?]) AH_TEMPLATE([time_t], [Define to `long' if doesn't define time_t]) AH_TEMPLATE([voidp], [Define to "void *" if compiler can handle, otherwise "char *"]) AH_TEMPLATE([am_nfs_fh], [Define a type/structure for an NFS V2 filehandle]) AH_TEMPLATE([am_nfs_fh3], [Define a type/structure for an NFS V3 filehandle]) AH_TEMPLATE([HAVE_NFS_PROT_HEADERS], [define if the host has NFS protocol headers in system headers]) AH_TEMPLATE([AMU_NFS_PROTOCOL_HEADER], [define name of am-utils' NFS protocol header]) AH_TEMPLATE([nfs_args_t], [Define a type for the nfs_args structure]) AH_TEMPLATE([NFS_FH_FIELD], [Define the field name for the filehandle within nfs_args_t]) AH_TEMPLATE([HAVE_FHANDLE], [Define if plain fhandle type exists]) AH_TEMPLATE([SVC_IN_ARG_TYPE], [Define the type of the 3rd argument ('in') to svc_getargs()]) AH_TEMPLATE([XDRPROC_T_TYPE], [Define to the type of xdr procedure type]) AH_TEMPLATE([MOUNT_TABLE_ON_FILE], [Define if mount table is on file, undefine if in kernel]) AH_TEMPLATE([HAVE_STRUCT_MNTENT], [Define if have struct mntent in one of the standard headers]) AH_TEMPLATE([HAVE_STRUCT_MNTTAB], [Define if have struct mnttab in one of the standard headers]) AH_TEMPLATE([HAVE_STRUCT_NFS_ARGS], [Define if have struct nfs_args in one of the standard nfs headers]) AH_TEMPLATE([HAVE_STRUCT_NFS_GFS_MOUNT], [Define if have struct nfs_gfs_mount in one of the standard nfs headers]) AH_TEMPLATE([YP_ORDER_OUTORDER_TYPE], [Type of the 3rd argument to yp_order()]) AH_TEMPLATE([RECVFROM_FROMLEN_TYPE], [Type of the 6th argument to recvfrom()]) AH_TEMPLATE([AUTH_CREATE_GIDLIST_TYPE], [Type of the 5rd argument to authunix_create()]) AH_TEMPLATE([MTYPE_PRINTF_TYPE], [The string used in printf to print the mount-type field of mount(2)]) AH_TEMPLATE([MTYPE_TYPE], [Type of the mount-type field in the mount() system call]) AH_TEMPLATE([pcfs_args_t], [Define a type for the pcfs_args structure]) AH_TEMPLATE([autofs_args_t], [Define a type for the autofs_args structure]) AH_TEMPLATE([cachefs_args_t], [Define a type for the cachefs_args structure]) AH_TEMPLATE([tmpfs_args_t], [Define a type for the tmpfs_args structure]) AH_TEMPLATE([ufs_args_t], [Define a type for the ufs_args structure]) AH_TEMPLATE([efs_args_t], [Define a type for the efs_args structure]) AH_TEMPLATE([xfs_args_t], [Define a type for the xfs_args structure]) AH_TEMPLATE([lofs_args_t], [Define a type for the lofs_args structure]) AH_TEMPLATE([cdfs_args_t], [Define a type for the cdfs_args structure]) AH_TEMPLATE([udf_args_t], [Define a type for the udf_args structure]) AH_TEMPLATE([mfs_args_t], [Define a type for the mfs_args structure]) AH_TEMPLATE([rfs_args_t], [Define a type for the rfs_args structure]) AH_TEMPLATE([HAVE_BAD_HASMNTOPT], [define if have a bad version of hasmntopt()]) AH_TEMPLATE([HAVE_BAD_MEMCMP], [define if have a bad version of memcmp()]) AH_TEMPLATE([HAVE_BAD_YP_ALL], [define if have a bad version of yp_all()]) AH_TEMPLATE([USE_UNCONNECTED_NFS_SOCKETS], [define if must use NFS "noconn" option]) AH_TEMPLATE([USE_CONNECTED_NFS_SOCKETS], [define if must NOT use NFS "noconn" option]) AH_TEMPLATE([HAVE_GNU_GETOPT], [define if your system's getopt() is GNU getopt() (are you using glibc)]) AH_TEMPLATE([HAVE_EXTERN_SYS_ERRLIST], [does extern definition for sys_errlist[] exist?]) AH_TEMPLATE([HAVE_EXTERN_OPTARG], [does extern definition for optarg exist?]) AH_TEMPLATE([HAVE_EXTERN_CLNT_SPCREATEERROR], [does extern definition for clnt_spcreateerror() exist?]) AH_TEMPLATE([HAVE_EXTERN_CLNT_SPERRNO], [does extern definition for clnt_sperrno() exist?]) AH_TEMPLATE([HAVE_EXTERN_FREE], [does extern definition for free() exist?]) AH_TEMPLATE([HAVE_EXTERN_GET_MYADDRESS], [does extern definition for get_myaddress() exist?]) AH_TEMPLATE([HAVE_EXTERN_GETCCENT], [does extern definition for getccent() (hpux) exist?]) AH_TEMPLATE([HAVE_EXTERN_GETDOMAINNAME], [does extern definition for getdomainname() exist?]) AH_TEMPLATE([HAVE_EXTERN_GETDTABLESIZE], [does extern definition for getdtablesize() exist?]) AH_TEMPLATE([HAVE_EXTERN_GETHOSTNAME], [does extern definition for gethostname() exist?]) AH_TEMPLATE([HAVE_EXTERN_GETLOGIN], [does extern definition for getlogin() exist?]) AH_TEMPLATE([HAVE_EXTERN_GETTABLESIZE], [does extern definition for gettablesize() exist?]) AH_TEMPLATE([HAVE_EXTERN_GETPAGESIZE], [does extern definition for getpagesize() exist?]) AH_TEMPLATE([HAVE_EXTERN_GETWD], [does extern definition for getwd() exist?]) AH_TEMPLATE([HAVE_EXTERN_HOSTS_CTL], [does extern definition for hosts_ctl() exist?]) AH_TEMPLATE([HAVE_EXTERN_INNETGR], [does extern definition for innetgr() exist?]) AH_TEMPLATE([HAVE_EXTERN_MKSTEMP], [does extern definition for mkstemp() exist?]) AH_TEMPLATE([HAVE_EXTERN_MNTCTL], [does extern definition for mntctl() exist?]) AH_TEMPLATE([HAVE_EXTERN_SBRK], [does extern definition for sbrk() exist?]) AH_TEMPLATE([HAVE_EXTERN_SETEUID], [does extern definition for seteuid() exist?]) AH_TEMPLATE([HAVE_EXTERN_SETITIMER], [does extern definition for setitimer() exist?]) AH_TEMPLATE([HAVE_EXTERN_SLEEP], [does extern definition for sleep() exist?]) AH_TEMPLATE([HAVE_EXTERN_STRCASECMP], [does extern definition for strcasecmp() exist?]) AH_TEMPLATE([HAVE_EXTERN_STRDUP], [does extern definition for strdup() exist?]) AH_TEMPLATE([HAVE_EXTERN_STRLCAT], [does extern definition for strlcat() exist?]) AH_TEMPLATE([HAVE_EXTERN_STRLCPY], [does extern definition for strlcpy() exist?]) AH_TEMPLATE([HAVE_EXTERN_STRSTR], [does extern definition for strstr() exist?]) AH_TEMPLATE([HAVE_EXTERN_UALARM], [does extern definition for ualarm() exist?]) AH_TEMPLATE([HAVE_EXTERN_USLEEP], [does extern definition for usleep() exist?]) AH_TEMPLATE([HAVE_EXTERN_WAIT3], [does extern definition for wait3() exist?]) AH_TEMPLATE([HAVE_EXTERN_VSNPRINTF], [does extern definition for vsnprintf() exist?]) AH_TEMPLATE([HAVE_EXTERN_XDR_CALLMSG], [does extern definition for xdr_callmsg() exist?]) AH_TEMPLATE([HAVE_EXTERN_XDR_OPAQUE_AUTH], [does extern definition for xdr_opaque_auth() exist?]) AH_TEMPLATE([NEW_DBM_H], [Defined to the header file containing ndbm-compatible definitions]) AH_TEMPLATE([HAVE_LIBWRAP], [does libwrap exist?]) AH_TEMPLATE([NEED_LIBWRAP_SEVERITY_VARIABLES], [does libwrap expect caller to define the variables allow_severity and deny_severity]) AH_TEMPLATE([HAVE_EXTERN_LDAP_ENABLE_CACHE], [does extern definition for ldap_enable_cache() exist?]) am-utils-6.2+rc20110530/m4/macros/host_macros.m4000066400000000000000000000073431157065440000207300ustar00rootroot00000000000000dnl ###################################################################### dnl AC_HOST_MACROS: define HOST_CPU, HOST_VENDOR, and HOST_OS AC_DEFUN([AMU_HOST_MACROS], [ # these are defined already by the macro 'CANONICAL_HOST' AC_MSG_CHECKING([host cpu]) AC_DEFINE_UNQUOTED(HOST_CPU, "$host_cpu") AC_MSG_RESULT($host_cpu) AC_MSG_CHECKING([vendor]) AC_DEFINE_UNQUOTED(HOST_VENDOR, "$host_vendor") AC_MSG_RESULT($host_vendor) # if vendor is apple, then check values in /usr/bin/sw_vers if test "${host_vendor}" = "apple" then pn=`sw_vers -productName 2>/dev/null` pv=`sw_vers -productVersion 2>/dev/null` if test -n "${pn}" && test -n "${pv}" then host_os_name=`echo ${pn} | tr -d ' ' | tr '[A-Z]' '[a-z]'` host_os_version="${pv}" host_os="${host_os_name}-${host_os_version}" fi fi AC_MSG_CHECKING([host full OS name and version]) # normalize some host OS names case ${host_os} in # linux is linux is linux, regardless of RMS. linux-gnu* | lignux* ) host_os=linux ;; # NetBSD systems today are elf, so no need to distinguish netbsdelf* ) host_os=`echo ${host_os} | sed 's/^netbsdelf/netbsd/'`;; esac AC_DEFINE_UNQUOTED(HOST_OS, "$host_os") AC_MSG_RESULT($host_os) # break host_os into host_os_name and host_os_version AC_MSG_CHECKING([host OS name]) host_os_name=`echo $host_os | sed 's/\..*//g'` # normalize some OS names case ${host_os_name} in # linux is linux is linux, regardless of RMS. linux-gnu* | lignux* ) host_os_name=linux ;; # all NetBSD systems today should just show up as "netbsd" netbsd* ) host_os_name=netbsd;; esac AC_DEFINE_UNQUOTED(HOST_OS_NAME, "$host_os_name") AC_MSG_RESULT($host_os_name) # parse out the OS version of the host AC_MSG_CHECKING([host OS version]) host_os_version=`echo $host_os | sed 's/^[[^0-9]]*//g'` if test -z "$host_os_version" then host_os_version=`(uname -r) 2>/dev/null` || host_os_version=unknown fi case ${host_os_version} in # fixes for some OS versions (solaris used to be here) * ) # do nothing for now ;; esac AC_DEFINE_UNQUOTED(HOST_OS_VERSION, "$host_os_version") AC_MSG_RESULT($host_os_version) # figure out host architecture (different than CPU) AC_MSG_CHECKING([host OS architecture]) host_arch=`(uname -m) 2>/dev/null` || host_arch=unknown # normalize some names case ${host_arch} in sun4* ) host_arch=sun4 ;; sun3x ) host_arch=sun3 ;; sun ) host_arch=`(arch) 2>/dev/null` || host_arch=unknown ;; i?86 ) host_arch=i386 ;; # all x86 should show up as i386 Power*Macintosh ) host_arch=powerpc ;; esac AC_DEFINE_UNQUOTED(HOST_ARCH, "$host_arch") AC_MSG_RESULT($host_arch) # figure out (linux) distribution, if any AC_MSG_CHECKING([OS system distribution]) ac_config_distro=`$SHELL $ac_aux_dir/config.guess.long | cut -d'-' -f4-` if test -z "$ac_config_distro" then ac_config_distro="none" fi AC_DEFINE_UNQUOTED(DISTRO_NAME, "$ac_config_distro") AC_MSG_RESULT($ac_config_distro) # figure out host name AC_MSG_CHECKING([host name]) host_name=`(hostname || uname -n) 2>/dev/null` || host_name=unknown AC_DEFINE_UNQUOTED(HOST_NAME, "$host_name") AC_MSG_RESULT($host_name) # figure out user name AC_MSG_CHECKING([user name]) if test -n "$USER" then user_name="$USER" else if test -n "$LOGNAME" then user_name="$LOGNAME" else user_name=`(whoami) 2>/dev/null` || user_name=unknown fi fi AC_DEFINE_UNQUOTED(USER_NAME, "$user_name") AC_MSG_RESULT($user_name) # figure out configuration date AC_MSG_CHECKING([configuration date]) config_date=`(date) 2>/dev/null` || config_date=unknown_date AC_DEFINE_UNQUOTED(CONFIG_DATE, "$config_date") AC_MSG_RESULT($config_date) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/libtool.m4000066400000000000000000010447131157065440000200560ustar00rootroot00000000000000# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, # Inc. # Written by Gordon Matzigkeit, 1996 # # This file 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. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, # Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool 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 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # `#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test $lt_write_fail = 0 && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2010 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_REPLACE_SHELLFNS mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES # -------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script which will find a shell with a builtin # printf (which we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case "$ECHO" in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified).], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([${with_sysroot}]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and in which our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[123]]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; haiku*) version_type=linux need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Xcompiler -fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ F* | *Sun*Fortran*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; freebsd1*) _LT_TAGVAR(ld_shlibs, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS="$save_LDFLAGS"]) if test "$lt_cv_irix_exported_symbol" = yes; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], [[If ld is used when linking, flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd[[12]]*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; gnu*) ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) # ------------------------------------------------------ # In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and # '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. m4_defun([_LT_PROG_FUNCTION_REPLACE], [dnl { sed -e '/^$1 ()$/,/^} # $1 /c\ $1 ()\ {\ m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) } # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: ]) # _LT_PROG_REPLACE_SHELLFNS # ------------------------- # Replace existing portable implementations of several shell functions with # equivalent extended shell implementations where those features are available.. m4_defun([_LT_PROG_REPLACE_SHELLFNS], [if test x"$xsi_shell" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"}]) _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl func_split_long_opt_name=${1%%=*} func_split_long_opt_arg=${1#*=}]) _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) fi if test x"$lt_shell_append" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl func_quote_for_eval "${2}" dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) fi ]) # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine which file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS am-utils-6.2+rc20110530/m4/macros/linux_headers.m4000066400000000000000000000026041157065440000212340ustar00rootroot00000000000000dnl ###################################################################### dnl ensure that linux kernel headers match running kernel AC_DEFUN([AMU_LINUX_HEADERS], [ # test sanity of running kernel vs. kernel headers AC_MSG_CHECKING("host headers version") case ${host_os} in linux ) host_header_version="bad" AMU_EXPAND_RUN_STRING( [ #include #include ], [ if (argc > 1) #ifdef UTS_RELEASE printf("%s", UTS_RELEASE); #else # define AMU_MA(a) ((a) >> 16) # define AMU_MI(a) (((a) & 0xffff) >> 8) # define AMU_PL(a) ((a) & 0xff) printf("%d.%d.%d", AMU_MA(LINUX_VERSION_CODE), AMU_MI(LINUX_VERSION_CODE), AMU_PL(LINUX_VERSION_CODE)); #endif ], [ host_header_version=$value ], [ echo AC_MSG_ERROR([cannot find UTS_RELEASE in . This Linux system may be misconfigured or unconfigured!]) ]) ;; * ) host_header_version=$host_os_version ;; esac AC_DEFINE_UNQUOTED(HOST_HEADER_VERSION, "$host_header_version") AC_MSG_RESULT($host_header_version) case ${host_os} in linux ) if test "$host_os_version" != $host_header_version then AC_MSG_WARN([Linux kernel $host_os_version mismatch with $host_header_version headers!]) fi ;; esac dnl cache these two for debugging purposes ac_cv_os_version=$host_os_version ac_cv_header_version=$host_header_version ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/localconfig.m4000066400000000000000000000006001157065440000206540ustar00rootroot00000000000000dnl ###################################################################### dnl check if a local configuration file exists AC_DEFUN([AMU_LOCALCONFIG], [AC_MSG_CHECKING(a local configuration file) if test -f localconfig.h then AC_DEFINE(HAVE_LOCALCONFIG_H) AC_MSG_RESULT(yes) else AC_MSG_RESULT(no) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/mount_headers.m4000066400000000000000000000006011157065440000212320ustar00rootroot00000000000000dnl ###################################################################### dnl an M4 macro to include a list of common headers being used everywhere define(AMU_MOUNT_HEADERS, [ #include "${srcdir}/include/mount_headers1.h" #include AMU_NFS_PROTOCOL_HEADER #include "${srcdir}/include/mount_headers2.h" $1 ] ) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/opt_amu_cflags.m4000066400000000000000000000015441157065440000213670ustar00rootroot00000000000000dnl ###################################################################### dnl Which options to add to CFLAGS for compilation? dnl NOTE: this is only for final compiltions, not for configure tests) AC_DEFUN([AMU_OPT_AMU_CFLAGS], [AC_MSG_CHECKING(for additional C option compilation flags) AC_ARG_ENABLE(am-cflags, AC_HELP_STRING([--enable-am-cflags=ARG], [compile package with ARG additional C flags]), [ if test "$enableval" = "" || test "$enableval" = "yes" || test "$enableval" = "no"; then AC_MSG_ERROR(am-cflags must be supplied if option is used) fi # user supplied a cflags option to configure AMU_CFLAGS="$enableval" AC_SUBST(AMU_CFLAGS) AC_MSG_RESULT($enableval) ], [ # default is to have no additional C flags AMU_CFLAGS="" AC_SUBST(AMU_CFLAGS) AC_MSG_RESULT(none) ]) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/opt_cppflags.m4000066400000000000000000000014461157065440000210660ustar00rootroot00000000000000dnl ###################################################################### dnl Initial settings for CPPFLAGS (-I options) dnl NOTE: this is for configuration as well as compilations! AC_DEFUN([AMU_OPT_CPPFLAGS], [AC_MSG_CHECKING(for configuration/compilation (-I) preprocessor flags) AC_ARG_ENABLE(cppflags, AC_HELP_STRING([--enable-cppflags=ARG], [configure/compile with ARG (-I) preprocessor flags]), [ if test "$enableval" = "" || test "$enableval" = "yes" || test "$enableval" = "no"; then AC_MSG_ERROR(cppflags must be supplied if option is used) fi # use supplied options CPPFLAGS="$CPPFLAGS $enableval" export CPPFLAGS AC_MSG_RESULT($enableval) ], [ # default is to have no additional flags AC_MSG_RESULT(none) ]) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/opt_debug.m4000066400000000000000000000015401157065440000203500ustar00rootroot00000000000000dnl ###################################################################### dnl Debugging: "yes" means general, "mem" means general and memory debugging, dnl and "no" means none. AC_DEFUN([AMU_OPT_DEBUG], [AC_MSG_CHECKING(for debugging options) AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug=ARG],[enable debugging (yes/mem/no)]), [ if test "$enableval" = yes; then AC_MSG_RESULT(yes) AC_DEFINE(DEBUG) ac_cv_opt_debug=yes elif test "$enableval" = mem; then AC_MSG_RESULT(mem) AC_DEFINE(DEBUG) AC_DEFINE(DEBUG_MEM) AC_CHECK_FUNC(malloc_verify,,AC_CHECK_LIB(mapmalloc, malloc_verify)) AC_CHECK_FUNC(mallinfo,,AC_CHECK_LIB(malloc, mallinfo)) ac_cv_opt_debug=mem else AC_MSG_RESULT(no) ac_cv_opt_debug=no fi ], [ # default is no debugging AC_MSG_RESULT(no) ]) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/opt_ldflags.m4000066400000000000000000000014251157065440000207000ustar00rootroot00000000000000dnl ###################################################################### dnl Initial settings for LDFLAGS (-L options) dnl NOTE: this is for configuration as well as compilations! AC_DEFUN([AMU_OPT_LDFLAGS], [AC_MSG_CHECKING(for configuration/compilation (-L) library flags) AC_ARG_ENABLE(ldflags, AC_HELP_STRING([--enable-ldflags=ARG], [configure/compile with ARG (-L) library flags]), [ if test "$enableval" = "" || test "$enableval" = "yes" || test "$enableval" = "no"; then AC_MSG_ERROR(ldflags must be supplied if option is used) fi # use supplied options LDFLAGS="$LDFLAGS $enableval" export LDFLAGS AC_MSG_RESULT($enableval) ], [ # default is to have no additional flags AC_MSG_RESULT(none) ]) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/opt_libs.m4000066400000000000000000000013751157065440000202210ustar00rootroot00000000000000dnl ###################################################################### dnl Initial settings for LIBS (-l options) dnl NOTE: this is for configuration as well as compilations! AC_DEFUN([AMU_OPT_LIBS], [AC_MSG_CHECKING(for configuration/compilation (-l) library flags) AC_ARG_ENABLE(libs, AC_HELP_STRING([--enable-libs=ARG], [configure/compile with ARG (-l) library flags]), [ if test "$enableval" = "" || test "$enableval" = "yes" || test "$enableval" = "no"; then AC_MSG_ERROR(libs must be supplied if option is used) fi # use supplied options LIBS="$LIBS $enableval" export LIBS AC_MSG_RESULT($enableval) ], [ # default is to have no additional flags AC_MSG_RESULT(none) ]) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/os_cflags.m4000066400000000000000000000042151157065440000203420ustar00rootroot00000000000000dnl ###################################################################### dnl Specify additional compile options based on the OS and the compiler AC_DEFUN([AMU_OS_CFLAGS], [ AC_CACHE_CHECK(additional compiler flags, ac_cv_os_cflags, [ case "${host_os}" in irix6* ) case "${CC}" in cc ) # do not use 64-bit compiler ac_cv_os_cflags="-n32 -mips3 -Wl,-woff,84" ;; esac ;; osf[[1-3]]* ) # get the right version of struct sockaddr case "${CC}" in cc ) ac_cv_os_cflags="-std -D_SOCKADDR_LEN -D_NO_PROTO" ;; * ) ac_cv_os_cflags="-D_SOCKADDR_LEN -D_NO_PROTO" ;; esac ;; osf* ) # get the right version of struct sockaddr case "${CC}" in cc ) ac_cv_os_cflags="-std -D_SOCKADDR_LEN" ;; * ) ac_cv_os_cflags="-D_SOCKADDR_LEN" ;; esac ;; aix[[1-3]]* ) ac_cv_os_cflags="" ;; aix4.[[0-2]]* ) # turn on additional headers ac_cv_os_cflags="-D_XOPEN_EXTENDED_SOURCE" ;; aix5.3* ) # avoid circular dependencies in yp headers, and more ac_cv_os_cflags="-DHAVE_BAD_HEADERS -D_XOPEN_EXTENDED_SOURCE -D_USE_IRS -D_MSGQSUPPORT" ;; aix* ) # avoid circular dependencies in yp headers ac_cv_os_cflags="-DHAVE_BAD_HEADERS -D_XOPEN_EXTENDED_SOURCE -D_USE_IRS" ;; OFF-sunos4* ) # make sure passing whole structures is handled in gcc case "${CC}" in gcc ) ac_cv_os_cflags="-fpcc-struct-return" ;; esac ;; sunos[[34]]* | solaris1* | solaris2.[[0-5]] | sunos5.[[0-5]] | solaris2.5.* | sunos5.5.* ) ac_cv_os_cflags="" ;; solaris2* | sunos5* ) # turn on 64-bit file offset interface case "${CC}" in * ) ac_cv_os_cflags="-D_LARGEFILE64_SOURCE" ;; esac ;; hpux* ) # use Ansi compiler on HPUX case "${CC}" in cc ) ac_cv_os_cflags="-Ae" ;; esac ;; darwin* | macosx* | rhapsody* ) ac_cv_os_cflags="-D_P1003_1B_VISIBLE" ;; linux* ) ac_cv_os_cflags="-D_GNU_SOURCE" ;; * ) ac_cv_os_cflags="" ;; esac ]) AMU_CFLAGS="$AMU_CFLAGS $ac_cv_os_cflags" # use same flags for configuring, so it matches what we do at compile time CFLAGS="$CFLAGS $ac_cv_os_cflags" export CFLAGS ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/os_cppflags.m4000066400000000000000000000010271157065440000207000ustar00rootroot00000000000000dnl ###################################################################### dnl Specify additional cpp options based on the OS and the compiler AC_DEFUN([AMU_OS_CPPFLAGS], [ AC_CACHE_CHECK(additional preprocessor flags, ac_cv_os_cppflags, [ case "${host_os}" in # off for now, posix may be a broken thing for nextstep3... # nextstep* ) # ac_cv_os_cppflags="-D_POSIX_SOURCE" # ;; * ) ac_cv_os_cppflags="" ;; esac ]) CPPFLAGS="$CPPFLAGS $ac_cv_os_cppflags" ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/os_ldflags.m4000066400000000000000000000010701157065440000205130ustar00rootroot00000000000000dnl ###################################################################### dnl Specify additional linker options based on the OS and the compiler AC_DEFUN([AMU_OS_LDFLAGS], [ AC_CACHE_CHECK(additional linker flags, ac_cv_os_ldflags, [ case "${host_os}" in solaris2.7* | sunos5.7* ) # find LDAP: off until Sun includes ldap headers. case "${CC}" in * ) #ac_cv_os_ldflags="-L/usr/lib/fn" ;; esac ;; * ) ac_cv_os_ldflags="" ;; esac ]) LDFLAGS="$LDFLAGS $ac_cv_os_ldflags" ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/package_bugreport.m4000066400000000000000000000004701157065440000220650ustar00rootroot00000000000000dnl ###################################################################### dnl Bugreport name AC_DEFUN([AMU_PACKAGE_BUGREPORT], [AC_MSG_CHECKING(bug-reporting address) AC_DEFINE_UNQUOTED(PACKAGE_BUGREPORT, "$1") AC_MSG_RESULT(\"$1\") ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/package_name.m4000066400000000000000000000004431157065440000207740ustar00rootroot00000000000000dnl ###################################################################### dnl Package name AC_DEFUN([AMU_PACKAGE_NAME], [AC_MSG_CHECKING(package name) AC_DEFINE_UNQUOTED(PACKAGE_NAME, "$1") AC_MSG_RESULT(\"$1\") ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/package_version.m4000066400000000000000000000004651157065440000215450ustar00rootroot00000000000000dnl ###################################################################### dnl Version of package AC_DEFUN([AMU_PACKAGE_VERSION], [AC_MSG_CHECKING(version of package) AC_DEFINE_UNQUOTED(PACKAGE_VERSION, "$1") AC_MSG_RESULT(\"$1\") ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/prog_lex.m4000066400000000000000000000005561157065440000202250ustar00rootroot00000000000000dnl find f/lex, but error if none found AC_DEFUN_ONCE([AMU_PROG_LEX], [AC_CHECK_PROGS(LEX, flex lex, :) if test -z "$LEXLIB" then AC_CHECK_LIB(fl, yywrap, LEXLIB="-lfl", [AC_CHECK_LIB(l, yywrap, LEXLIB="-ll")]) fi AC_SUBST(LEXLIB) if test "x$LEX" != "x:"; then _AC_PROG_LEX_YYTEXT_DECL else AC_MSG_ERROR([cannot find flex/lex -- needed for am-utils]) fi]) am-utils-6.2+rc20110530/m4/macros/prog_yacc.m4000066400000000000000000000003401157065440000203430ustar00rootroot00000000000000dnl find bison/yacc, but error if none found AC_DEFUN([AMU_PROG_YACC], [AC_CHECK_PROGS(YACC, 'bison -y' byacc yacc, :) if test "x$YACC" = "x:"; then AC_MSG_ERROR([cannot find bison/yacc/byacc -- needed for am-utils]) fi]) am-utils-6.2+rc20110530/m4/macros/save_state.m4000066400000000000000000000007041157065440000205370ustar00rootroot00000000000000dnl ###################################################################### dnl AC_SAVE_STATE: save confdefs.h onto dbgcf.h and write $ac_cv_* cache dnl variables that are known so far. define(AMU_SAVE_STATE, dnl AC_MSG_NOTICE(*** SAVING CONFIGURE STATE ***) if test -f confdefs.h then cp confdefs.h dbgcf.h fi [AC_CACHE_SAVE AC_MSG_NOTICE([*** SAVING CONFIGURE STATE ***])] ) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/struct_field_nfs_fh.m4000066400000000000000000000021231157065440000224100ustar00rootroot00000000000000dnl ###################################################################### dnl Find the name of the nfs filehandle field in nfs_args_t. AC_DEFUN([AMU_STRUCT_FIELD_NFS_FH], [ dnl make sure this is called before macros which depend on it AC_BEFORE([$0], [AC_TYPE_NFS_FH]) AC_CACHE_CHECK(for the name of the nfs filehandle field in nfs_args_t, ac_cv_struct_field_nfs_fh, [ # set to a default value ac_cv_struct_field_nfs_fh=notfound # look for name "fh" (most systems) if test "$ac_cv_struct_field_nfs_fh" = notfound then AC_TRY_COMPILE_NFS( [ nfs_args_t nat; char *cp = (char *) &(nat.fh); ], ac_cv_struct_field_nfs_fh=fh, ac_cv_struct_field_nfs_fh=notfound) fi # look for name "root" (for example Linux) if test "$ac_cv_struct_field_nfs_fh" = notfound then AC_TRY_COMPILE_NFS( [ nfs_args_t nat; char *cp = (char *) &(nat.root); ], ac_cv_struct_field_nfs_fh=root, ac_cv_struct_field_nfs_fh=notfound) fi ]) if test "$ac_cv_struct_field_nfs_fh" != notfound then AC_DEFINE_UNQUOTED(NFS_FH_FIELD, $ac_cv_struct_field_nfs_fh) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/struct_mntent.m4000066400000000000000000000011241157065440000213070ustar00rootroot00000000000000dnl ###################################################################### dnl Find if struct mntent exists anywhere in mount.h or mntent.h headers AC_DEFUN([AMU_STRUCT_MNTENT], [ AC_CACHE_CHECK(for struct mntent, ac_cv_have_struct_mntent, [ # try to compile a program which may have a definition for the structure AC_TRY_COMPILE( AMU_MOUNT_HEADERS , [ struct mntent mt; ], ac_cv_have_struct_mntent=yes, ac_cv_have_struct_mntent=no) ]) if test "$ac_cv_have_struct_mntent" = yes then AC_DEFINE(HAVE_STRUCT_MNTENT) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/struct_mnttab.m4000066400000000000000000000011241157065440000212670ustar00rootroot00000000000000dnl ###################################################################### dnl Find if struct mnttab exists anywhere in mount.h or mnttab.h headers AC_DEFUN([AMU_STRUCT_MNTTAB], [ AC_CACHE_CHECK(for struct mnttab, ac_cv_have_struct_mnttab, [ # try to compile a program which may have a definition for the structure AC_TRY_COMPILE( AMU_MOUNT_HEADERS , [ struct mnttab mt; ], ac_cv_have_struct_mnttab=yes, ac_cv_have_struct_mnttab=no) ]) if test "$ac_cv_have_struct_mnttab" = yes then AC_DEFINE(HAVE_STRUCT_MNTTAB) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/struct_nfs_args.m4000066400000000000000000000033161157065440000216110ustar00rootroot00000000000000dnl ###################################################################### dnl Find if struct nfs_args exists anywhere in typical headers AC_DEFUN([AMU_STRUCT_NFS_ARGS], [ dnl make sure this is called before [AC_TYPE_NFS_FH] AC_BEFORE([$0], [AC_TYPE_NFS_FH]) AC_BEFORE([$0], [AC_STRUCT_FIELD_NFS_FH]) AC_CACHE_CHECK(for struct nfs_args, ac_cv_have_struct_nfs_args, [ # try to compile a program which may have a definition for the structure # assume not found ac_cv_have_struct_nfs_args=notfound # look for "struct irix5_nfs_args" (specially set in conf/nfs_prot/) if test "$ac_cv_have_struct_nfs_args" = notfound then AC_TRY_COMPILE_NFS( [ struct irix5_nfs_args na; ], ac_cv_have_struct_nfs_args="struct irix5_nfs_args", ac_cv_have_struct_nfs_args=notfound) fi # look for "struct aix5_nfs_args" (specially set in conf/nfs_prot/) if test "$ac_cv_have_struct_nfs_args" = notfound then AC_TRY_COMPILE_NFS( [ struct aix5_nfs_args na; ], ac_cv_have_struct_nfs_args="struct aix5_nfs_args", ac_cv_have_struct_nfs_args=notfound) fi # look for "struct aix4_nfs_args" (specially set in conf/nfs_prot/) if test "$ac_cv_have_struct_nfs_args" = notfound then AC_TRY_COMPILE_NFS( [ struct aix4_nfs_args na; ], ac_cv_have_struct_nfs_args="struct aix4_nfs_args", ac_cv_have_struct_nfs_args=notfound) fi # look for "struct nfs_args" if test "$ac_cv_have_struct_nfs_args" = notfound then AC_TRY_COMPILE_NFS( [ struct nfs_args na; ], ac_cv_have_struct_nfs_args="struct nfs_args", ac_cv_have_struct_nfs_args=notfound) fi ]) if test "$ac_cv_have_struct_nfs_args" != notfound then AC_DEFINE(HAVE_STRUCT_NFS_ARGS) AC_DEFINE_UNQUOTED(nfs_args_t, $ac_cv_have_struct_nfs_args) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/struct_nfs_fh.m4000066400000000000000000000032361157065440000212530ustar00rootroot00000000000000dnl ###################################################################### dnl Find the structure of an nfs filehandle. dnl if found, defined am_nfs_fh to it, else leave it undefined. dnl THE ORDER OF LOOKUPS IN THIS FILE IS VERY IMPORTANT!!! AC_DEFUN([AMU_STRUCT_NFS_FH], [ AC_CACHE_CHECK(for type/structure of NFS V2 filehandle, ac_cv_struct_nfs_fh, [ # try to compile a program which may have a definition for the type dnl need a series of compilations, which will test out every possible type dnl such as struct nfs_fh, fhandle_t, nfsv2fh_t, etc. # set to a default value ac_cv_struct_nfs_fh=notfound # look for "nfs_fh" if test "$ac_cv_struct_nfs_fh" = notfound then AC_TRY_COMPILE_NFS( [ nfs_fh nh; ], ac_cv_struct_nfs_fh="nfs_fh", ac_cv_struct_nfs_fh=notfound) fi # look for "struct nfs_fh" if test "$ac_cv_struct_nfs_fh" = notfound then AC_TRY_COMPILE_NFS( [ struct nfs_fh nh; ], ac_cv_struct_nfs_fh="struct nfs_fh", ac_cv_struct_nfs_fh=notfound) fi # look for "struct nfssvcfh" if test "$ac_cv_struct_nfs_fh" = notfound then AC_TRY_COMPILE_NFS( [ struct nfssvcfh nh; ], ac_cv_struct_nfs_fh="struct nfssvcfh", ac_cv_struct_nfs_fh=notfound) fi # look for "nfsv2fh_t" if test "$ac_cv_struct_nfs_fh" = notfound then AC_TRY_COMPILE_NFS( [ nfsv2fh_t nh; ], ac_cv_struct_nfs_fh="nfsv2fh_t", ac_cv_struct_nfs_fh=notfound) fi # look for "fhandle_t" if test "$ac_cv_struct_nfs_fh" = notfound then AC_TRY_COMPILE_NFS( [ fhandle_t nh; ], ac_cv_struct_nfs_fh="fhandle_t", ac_cv_struct_nfs_fh=notfound) fi ]) if test "$ac_cv_struct_nfs_fh" != notfound then AC_DEFINE_UNQUOTED(am_nfs_fh, $ac_cv_struct_nfs_fh) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/struct_nfs_fh3.m4000066400000000000000000000022251157065440000213330ustar00rootroot00000000000000dnl ###################################################################### dnl Find the structure of an nfs filehandle. dnl if found, defined am_nfs_fh3 to it, else leave it undefined. dnl THE ORDER OF LOOKUPS IN THIS FILE IS VERY IMPORTANT!!! AC_DEFUN([AMU_STRUCT_NFS_FH3], [ AC_CACHE_CHECK(for type/structure of NFS V2 filehandle, ac_cv_struct_nfs_fh3, [ # try to compile a program which may have a definition for the type dnl need a series of compilations, which will test out every possible type dnl such as struct nfs_fh3, XXX - what else?, etc. # set to a default value ac_cv_struct_nfs_fh3=notfound # look for "nfs_fh3" if test "$ac_cv_struct_nfs_fh3" = notfound then AC_TRY_COMPILE_NFS( [ nfs_fh3 nh; ], ac_cv_struct_nfs_fh3="nfs_fh3_netbsd20", ac_cv_struct_nfs_fh3=notfound) fi # look for "struct nfs_fh3" if test "$ac_cv_struct_nfs_fh3" = notfound then AC_TRY_COMPILE_NFS( [ struct nfs_fh3 nh; ], ac_cv_struct_nfs_fh3="struct nfs_fh3", ac_cv_struct_nfs_fh3=notfound) fi ]) if test "$ac_cv_struct_nfs_fh3" != notfound then AC_DEFINE_UNQUOTED(am_nfs_fh3, $ac_cv_struct_nfs_fh3) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/struct_nfs_gfs_mount.m4000066400000000000000000000014471157065440000226610ustar00rootroot00000000000000dnl ###################################################################### dnl Find if struct nfs_gfs_mount exists anywhere in typical headers AC_DEFUN([AMU_STRUCT_NFS_GFS_MOUNT], [ dnl make sure this is called before [AC_TYPE_NFS_FH] AC_BEFORE([$0], [AC_TYPE_NFS_FH]) AC_BEFORE([$0], [AC_STRUCT_FIELD_NFS_FH]) AC_CACHE_CHECK(for struct nfs_gfs_mount, ac_cv_have_struct_nfs_gfs_mount, [ # try to compile a program which may have a definition for the structure AC_TRY_COMPILE_NFS( [ struct nfs_gfs_mount ngm; ], ac_cv_have_struct_nfs_gfs_mount=yes, ac_cv_have_struct_nfs_gfs_mount=no) ]) if test "$ac_cv_have_struct_nfs_gfs_mount" = yes then AC_DEFINE(HAVE_STRUCT_NFS_GFS_MOUNT) AC_DEFINE(nfs_args_t, struct nfs_gfs_mount) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/try_compile_anyfs.m4000066400000000000000000000122661157065440000221350ustar00rootroot00000000000000dnl ###################################################################### dnl Compile a program with FS headers to try and find a feature. dnl The headers part are fixed. Only three arguments are allowed: dnl [$1] is the program to compile (2nd arg to AC_TRY_COMPILE) dnl [$2] action to take if the program compiled (3rd arg to AC_TRY_COMPILE) dnl [$3] action to take if program did not compile (4rd arg to AC_TRY_COMPILE) AC_DEFUN([AC_TRY_COMPILE_ANYFS], [# try to compile a program which may have a definition for a structure AC_TRY_COMPILE( [ #ifdef HAVE_SYS_TYPES_H # include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_ERRNO_H # include #endif /* HAVE_SYS_ERRNO_H */ #ifdef HAVE_SYS_PARAM_H # include #endif /* HAVE_SYS_PARAM_H */ #if TIME_WITH_SYS_TIME # include # include #else /* not TIME_WITH_SYS_TIME */ # if HAVE_SYS_TIME_H # include # else /* not HAVE_SYS_TIME_H */ # include # endif /* not HAVE_SYS_TIME_H */ #endif /* not TIME_WITH_SYS_TIME */ #ifdef HAVE_NETINET_IN_H # include #endif /* HAVE_NETINET_IN_H */ #ifdef HAVE_SYS_TIUSER_H # include #endif /* HAVE_SYS_TIUSER_H */ #ifdef HAVE_SYS_MOUNT_H # ifndef NFSCLIENT # define NFSCLIENT # endif /* not NFSCLIENT */ # ifndef PCFS # define PCFS # endif /* not PCFS */ # ifndef LOFS # define LOFS # endif /* not LOFS */ # ifndef RFS # define RFS # endif /* not RFS */ # ifndef MSDOSFS # define MSDOSFS # endif /* not MSDOSFS */ # ifndef MFS # define MFS 1 # endif /* not MFS */ # ifndef CD9660 # define CD9660 # endif /* not CD9660 */ # ifndef NFS # define NFS # endif /* not NFS */ # include #endif /* HAVE_SYS_MOUNT_H */ #ifdef HAVE_SYS_VMOUNT_H # include #endif /* HAVE_SYS_VMOUNT_H */ /* * There is no point in including this on a glibc2 system * we're only asking for trouble */ #if defined HAVE_LINUX_FS_H && (!defined __GLIBC__ || __GLIBC__ < 2) /* * There's a conflict of definitions on redhat alpha linux between * and . * Also a conflict in definitions of ntohl/htonl in RH-5.1 sparc64 * between and (2.1 kernels). */ # ifdef HAVE_SOCKETBITS_H # define _LINUX_SOCKET_H # undef BLKFLSBUF # undef BLKGETSIZE # undef BLKRAGET # undef BLKRASET # undef BLKROGET # undef BLKROSET # undef BLKRRPART # undef MS_MGC_VAL # undef MS_RMT_MASK # endif /* HAVE_SOCKETBITS_H */ # ifdef HAVE_LINUX_POSIX_TYPES_H # include # endif /* HAVE_LINUX_POSIX_TYPES_H */ # ifndef _LINUX_BYTEORDER_GENERIC_H # define _LINUX_BYTEORDER_GENERIC_H # endif /* _LINUX_BYTEORDER_GENERIC_H */ # ifndef _LINUX_STRING_H_ # define _LINUX_STRING_H_ # endif /* not _LINUX_STRING_H_ */ # ifdef HAVE_LINUX_KDEV_T_H # define __KERNEL__ # include # undef __KERNEL__ # endif /* HAVE_LINUX_KDEV_T_H */ # ifdef HAVE_LINUX_LIST_H # define __KERNEL__ # include # undef __KERNEL__ # endif /* HAVE_LINUX_LIST_H */ # include #endif /* HAVE_LINUX_FS_H && (!__GLIBC__ || __GLIBC__ < 2) */ #ifdef HAVE_SYS_FS_AUTOFS_H # include #endif /* HAVE_SYS_FS_AUTOFS_H */ #ifdef HAVE_SYS_FS_CACHEFS_FS_H # include #endif /* HAVE_SYS_FS_CACHEFS_FS_H */ #ifdef HAVE_SYS_FS_PC_FS_H # include #endif /* HAVE_SYS_FS_PC_FS_H */ #ifdef HAVE_MSDOSFS_MSDOSFSMOUNT_H # include #endif /* HAVE_MSDOSFS_MSDOSFSMOUNT_H */ #ifdef HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H # include #endif /* HAVE_FS_MSDOSFS_MSDOSFSMOUNT_H */ #ifdef HAVE_SYS_FS_TMP_H # include #endif /* HAVE_SYS_FS_TMP_H */ #ifdef HAVE_FS_TMPFS_TMPFS_ARGS_H # include #endif /* HAVE_FS_TMPFS_TMPFS_ARGS_H */ #ifdef HAVE_UFS_UFS_MOUNT_H # include #endif /* HAVE_UFS_UFS_MOUNT_H */ #ifdef HAVE_UFS_UFS_UFSMOUNT_H # ifndef MAXQUOTAS # define MAXQUOTAS 2 # endif /* not MAXQUOTAS */ struct netexport { int this_is_SO_wrong; }; /* for bsdi-2.1 */ /* netbsd-1.4 does't protect */ # ifndef _UFS_UFS_UFSMOUNT_H # include # define _UFS_UFS_UFSMOUNT_H # endif /* not _UFS_UFS_UFSMOUNT_H */ #endif /* HAVE_UFS_UFS_UFSMOUNT_H */ #ifdef HAVE_SYS_FS_UFS_MOUNT_H # include #endif /* HAVE_SYS_FS_UFS_MOUNT_H */ #ifdef HAVE_SYS_FS_EFS_CLNT_H # include #endif /* HAVE_SYS_FS_EFS_CLNT_H */ #ifdef HAVE_FS_EFS_EFS_MOUNT_H # include #endif /* HAVE_FS_EFS_EFS_MOUNT_H */ #ifdef HAVE_SYS_FS_XFS_CLNT_H # include #endif /* HAVE_SYS_FS_XFS_CLNT_H */ #ifdef HAVE_CDFS_CDFS_MOUNT_H # include #endif /* HAVE_CDFS_CDFS_MOUNT_H */ #ifdef HAVE_HSFS_HSFS_H # include #endif /* HAVE_HSFS_HSFS_H */ #ifdef HAVE_CDFS_CDFSMOUNT_H # include #endif /* HAVE_CDFS_CDFSMOUNT_H */ #ifdef HAVE_ISOFS_CD9660_CD9660_MOUNT_H # include #endif /* HAVE_ISOFS_CD9660_CD9660_MOUNT_H */ #ifdef HAVE_FS_UDF_UDF_MOUNT_H # include #endif /* HAVE_FS_UDF_UDF_MOUNT_H */ ], [$1], [$2], [$3]) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/try_compile_nfs.m4000066400000000000000000000012251157065440000215740ustar00rootroot00000000000000dnl ###################################################################### dnl Compile a program with NFS headers to try and find a feature. dnl The headers part are fixed. Only three arguments are allowed: dnl [$1] is the program to compile (2nd arg to AC_TRY_COMPILE) dnl [$2] action to take if the program compiled (3rd arg to AC_TRY_COMPILE) dnl [$3] action to take if program did not compile (4rd arg to AC_TRY_COMPILE) AC_DEFUN([AC_TRY_COMPILE_NFS], [# try to compile a program which may have a definition for a structure AC_TRY_COMPILE( AMU_MOUNT_HEADERS , [$1], [$2], [$3]) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/try_compile_rpc.m4000066400000000000000000000017301157065440000215730ustar00rootroot00000000000000dnl ###################################################################### dnl Compile a program with RPC headers to try and find a feature. dnl The headers part are fixed. Only three arguments are allowed: dnl [$1] is the program to compile (2nd arg to AC_TRY_COMPILE) dnl [$2] action to take if the program compiled (3rd arg to AC_TRY_COMPILE) dnl [$3] action to take if program did not compile (4rd arg to AC_TRY_COMPILE) AC_DEFUN([AC_TRY_COMPILE_RPC], [# try to compile a program which may have a definition for a structure AC_TRY_COMPILE( [ #ifdef HAVE_SYS_TYPES_H # include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_RPC_RPC_H # include #endif /* HAVE_RPC_RPC_H */ /* Prevent multiple inclusion on Ultrix 4 */ #if defined(HAVE_RPC_XDR_H) && !defined(__XDR_HEADER__) # include #endif /* defined(HAVE_RPC_XDR_H) && !defined(__XDR_HEADER__) */ ], [$1], [$2], [$3]) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_auth_create_gidlist.m4000066400000000000000000000015221157065440000234440ustar00rootroot00000000000000dnl ###################################################################### dnl check the correct type for the 5th argument to authunix_create() AC_DEFUN([AMU_TYPE_AUTH_CREATE_GIDLIST], [ AC_CACHE_CHECK(argument type of 5rd argument to authunix_create(), ac_cv_auth_create_gidlist, [ # select the correct type case "${host_os_name}" in sunos[[34]]* | bsdi2* | sysv4* | hpux10.10 | ultrix* | aix4* ) ac_cv_auth_create_gidlist="int" ;; # old macosx used "gid_t" but all newer ones use int macosx-10.[[0-3]]* ) ac_cv_auth_create_gidlist="gid_t" ;; macosx* ) ac_cv_auth_create_gidlist="int" ;; netbsd* ) ac_cv_auth_create_gidlist="int" ;; * ) ac_cv_auth_create_gidlist="gid_t" ;; esac ]) AC_DEFINE_UNQUOTED(AUTH_CREATE_GIDLIST_TYPE, $ac_cv_auth_create_gidlist) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_autofs_args.m4000066400000000000000000000016541157065440000217640ustar00rootroot00000000000000dnl ###################################################################### dnl Find the correct type for AUTOFS mount(2) arguments structure AC_DEFUN([AMU_TYPE_AUTOFS_ARGS], [ AC_CACHE_CHECK(for structure type of autofs mount(2) arguments, ac_cv_type_autofs_args, [ # set to a default value ac_cv_type_autofs_args=notfound # look for "struct auto_args" if test "$ac_cv_type_autofs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct auto_args a; ], ac_cv_type_autofs_args="struct auto_args", ac_cv_type_autofs_args=notfound) fi # look for "struct autofs_args" if test "$ac_cv_type_autofs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct autofs_args a; ], ac_cv_type_autofs_args="struct autofs_args", ac_cv_type_autofs_args=notfound) fi ]) if test "$ac_cv_type_autofs_args" != notfound then AC_DEFINE_UNQUOTED(autofs_args_t, $ac_cv_type_autofs_args) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_cachefs_args.m4000066400000000000000000000013701157065440000220520ustar00rootroot00000000000000dnl ###################################################################### dnl Find the correct type for CACHEFS mount(2) arguments structure AC_DEFUN([AMU_TYPE_CACHEFS_ARGS], [ AC_CACHE_CHECK(for structure type of cachefs mount(2) arguments, ac_cv_type_cachefs_args, [ # set to a default value ac_cv_type_cachefs_args=notfound # look for "struct cachefs_mountargs" if test "$ac_cv_type_cachefs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct cachefs_mountargs a; ], ac_cv_type_cachefs_args="struct cachefs_mountargs", ac_cv_type_cachefs_args=notfound) fi ]) if test "$ac_cv_type_cachefs_args" != notfound then AC_DEFINE_UNQUOTED(cachefs_args_t, $ac_cv_type_cachefs_args) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_cdfs_args.m4000066400000000000000000000027751157065440000214070ustar00rootroot00000000000000dnl ###################################################################### dnl Find the correct type for CDFS mount(2) arguments structure AC_DEFUN([AMU_TYPE_CDFS_ARGS], [ AC_CACHE_CHECK(for structure type of cdfs mount(2) arguments, ac_cv_type_cdfs_args, [ # set to a default value ac_cv_type_cdfs_args=notfound # look for "struct iso_args" if test "$ac_cv_type_cdfs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct iso_args a; ], ac_cv_type_cdfs_args="struct iso_args", ac_cv_type_cdfs_args=notfound) fi # look for "struct iso9660_args" if test "$ac_cv_type_cdfs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct iso9660_args a; ], ac_cv_type_cdfs_args="struct iso9660_args", ac_cv_type_cdfs_args=notfound) fi # look for "struct cdfs_args" if test "$ac_cv_type_cdfs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct cdfs_args a; ], ac_cv_type_cdfs_args="struct cdfs_args", ac_cv_type_cdfs_args=notfound) fi # look for "struct hsfs_args" if test "$ac_cv_type_cdfs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct hsfs_args a; ], ac_cv_type_cdfs_args="struct hsfs_args", ac_cv_type_cdfs_args=notfound) fi # look for "struct iso_specific" (ultrix) if test "$ac_cv_type_cdfs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct iso_specific a; ], ac_cv_type_cdfs_args="struct iso_specific", ac_cv_type_cdfs_args=notfound) fi ]) if test "$ac_cv_type_cdfs_args" != notfound then AC_DEFINE_UNQUOTED(cdfs_args_t, $ac_cv_type_cdfs_args) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_efs_args.m4000066400000000000000000000012631157065440000212340ustar00rootroot00000000000000dnl ###################################################################### dnl Find the correct type for EFS mount(2) arguments structure AC_DEFUN([AMU_TYPE_EFS_ARGS], [ AC_CACHE_CHECK(for structure type of efs mount(2) arguments, ac_cv_type_efs_args, [ # set to a default value ac_cv_type_efs_args=notfound # look for "struct efs_args" if test "$ac_cv_type_efs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct efs_args a; ], ac_cv_type_efs_args="struct efs_args", ac_cv_type_efs_args=notfound) fi ]) if test "$ac_cv_type_efs_args" != notfound then AC_DEFINE_UNQUOTED(efs_args_t, $ac_cv_type_efs_args) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_lofs_args.m4000066400000000000000000000016011157065440000214160ustar00rootroot00000000000000dnl ###################################################################### dnl Find the correct type for LOFS mount(2) arguments structure AC_DEFUN([AMU_TYPE_LOFS_ARGS], [ AC_CACHE_CHECK(for structure type of lofs mount(2) arguments, ac_cv_type_lofs_args, [ # set to a default value ac_cv_type_lofs_args=notfound # look for "struct lofs_args" if test "$ac_cv_type_lofs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct lofs_args a; ], ac_cv_type_lofs_args="struct lofs_args", ac_cv_type_lofs_args=notfound) fi # look for "struct lo_args" if test "$ac_cv_type_lofs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct lo_args a; ], ac_cv_type_lofs_args="struct lo_args", ac_cv_type_lofs_args=notfound) fi ]) if test "$ac_cv_type_lofs_args" != notfound then AC_DEFINE_UNQUOTED(lofs_args_t, $ac_cv_type_lofs_args) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_mfs_args.m4000066400000000000000000000012611157065440000212420ustar00rootroot00000000000000dnl ###################################################################### dnl Find the correct type for MFS mount(2) arguments structure AC_DEFUN([AMU_TYPE_MFS_ARGS], [ AC_CACHE_CHECK(for structure type of mfs mount(2) arguments, ac_cv_type_mfs_args, [ # set to a default value ac_cv_type_mfs_args=notfound # look for "struct mfs_args" if test "$ac_cv_type_mfs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct mfs_args a; ], ac_cv_type_mfs_args="struct mfs_args", ac_cv_type_mfs_args=notfound) fi ]) if test "$ac_cv_type_mfs_args" != notfound then AC_DEFINE_UNQUOTED(mfs_args_t, $ac_cv_type_mfs_args) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_pcfs_args.m4000066400000000000000000000024441157065440000214140ustar00rootroot00000000000000dnl ###################################################################### dnl Find the correct type for PC/FS mount(2) arguments structure AC_DEFUN([AMU_TYPE_PCFS_ARGS], [ AC_CACHE_CHECK(for structure type of pcfs mount(2) arguments, ac_cv_type_pcfs_args, [ # set to a default value ac_cv_type_pcfs_args=notfound # look for "struct msdos_args" if test "$ac_cv_type_pcfs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct msdos_args a; ], ac_cv_type_pcfs_args="struct msdos_args", ac_cv_type_pcfs_args=notfound) fi # look for "struct pc_args" if test "$ac_cv_type_pcfs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct pc_args a; ], ac_cv_type_pcfs_args="struct pc_args", ac_cv_type_pcfs_args=notfound) fi # look for "struct pcfs_args" if test "$ac_cv_type_pcfs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct pcfs_args a; ], ac_cv_type_pcfs_args="struct pcfs_args", ac_cv_type_pcfs_args=notfound) fi # look for "struct msdosfs_args" if test "$ac_cv_type_pcfs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct msdosfs_args a; ], ac_cv_type_pcfs_args="struct msdosfs_args", ac_cv_type_pcfs_args=notfound) fi ]) if test "$ac_cv_type_pcfs_args" != notfound then AC_DEFINE_UNQUOTED(pcfs_args_t, $ac_cv_type_pcfs_args) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_pte_t.m4000066400000000000000000000011711157065440000205540ustar00rootroot00000000000000dnl ###################################################################### dnl check for type of pte_t (for Irix, usually in ) dnl Note: some gcc's on Irix 6.5 are broken and don't recognize pte_t, dnl so I'm defining it here to unsigned int, which is not necessarily correct, dnl but at least it gets am-utils to compile. AC_DEFUN([AMU_TYPE_PTE_T], [AC_CHECK_TYPE(pte_t, , [AC_DEFINE_UNQUOTED(pte_t, unsigned int, [Check if pte_t is defined in ])], [ #ifdef HAVE_SYS_IMMU_H # include #endif /* HAVE_SYS_IMMU_H */ ])]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_recvfrom_fromlen.m4000066400000000000000000000015561157065440000230150ustar00rootroot00000000000000dnl ###################################################################### dnl check the correct type for the 6th argument to recvfrom() AC_DEFUN([AMU_TYPE_RECVFROM_FROMLEN], [ AC_CACHE_CHECK(non-pointer type of 6th (fromlen) argument to recvfrom(), ac_cv_recvfrom_fromlen, [ # select the correct type case "${host_os}" in linux* ) ac_cv_recvfrom_fromlen="unsigned int" ;; aix[[1-3]]* ) ac_cv_recvfrom_fromlen="int" ;; aix* ) ac_cv_recvfrom_fromlen="size_t" ;; # old macosx used "int" but all newer ones use socklen_t macosx-10.[[0-3]]* ) ac_cv_recvfrom_fromlen="int" ;; macosx* ) ac_cv_recvfrom_fromlen="socklen_t" ;; netbsd* ) ac_cv_recvfrom_fromlen="socklen_t" ;; * ) ac_cv_recvfrom_fromlen="int" ;; esac ]) AC_DEFINE_UNQUOTED(RECVFROM_FROMLEN_TYPE, $ac_cv_recvfrom_fromlen) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_rfs_args.m4000066400000000000000000000012611157065440000212470ustar00rootroot00000000000000dnl ###################################################################### dnl Find the correct type for RFS mount(2) arguments structure AC_DEFUN([AMU_TYPE_RFS_ARGS], [ AC_CACHE_CHECK(for structure type of rfs mount(2) arguments, ac_cv_type_rfs_args, [ # set to a default value ac_cv_type_rfs_args=notfound # look for "struct rfs_args" if test "$ac_cv_type_rfs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct rfs_args a; ], ac_cv_type_rfs_args="struct rfs_args", ac_cv_type_rfs_args=notfound) fi ]) if test "$ac_cv_type_rfs_args" != notfound then AC_DEFINE_UNQUOTED(rfs_args_t, $ac_cv_type_rfs_args) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_rpcvers_t.m4000066400000000000000000000007031157065440000214500ustar00rootroot00000000000000dnl ###################################################################### dnl check for type of rpcvers_t (usually in ) AC_DEFUN([AMU_TYPE_RPCVERS_T], [AC_CHECK_TYPE(rpcvers_t, , [AC_DEFINE_UNQUOTED(rpcvers_t, unsigned long, [Check if rpcvers_t is defined in ])], [ #ifdef HAVE_RPC_TYPES_H # include #endif /* HAVE_RPC_TYPES_H */ ])]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_svc_in_arg.m4000066400000000000000000000022061157065440000215530ustar00rootroot00000000000000dnl ###################################################################### dnl Find the type of the 3rd argument (in) to svc_sendreply() call AC_DEFUN([AMU_TYPE_SVC_IN_ARG], [ AC_CACHE_CHECK(for type of 3rd arg ('in') arg to svc_sendreply(), ac_cv_type_svc_in_arg, [ # try to compile a program which may have a definition for the type dnl need a series of compilations, which will test out every possible type dnl such as caddr_t, char *, etc. # set to a default value ac_cv_type_svc_in_arg=notfound # look for "caddr_t" if test "$ac_cv_type_svc_in_arg" = notfound then AC_TRY_COMPILE_RPC( [ SVCXPRT *SX; xdrproc_t xp; caddr_t p; svc_sendreply(SX, xp, p); ], ac_cv_type_svc_in_arg="caddr_t", ac_cv_type_svc_in_arg=notfound) fi # look for "char *" if test "$ac_cv_type_svc_in_arg" = notfound then AC_TRY_COMPILE_RPC( [ SVCXPRT *SX; xdrproc_t xp; char *p; svc_sendreply(SX, xp, p); ], ac_cv_type_svc_in_arg="char *", ac_cv_type_svc_in_arg=notfound) fi ]) if test "$ac_cv_type_svc_in_arg" != notfound then AC_DEFINE_UNQUOTED(SVC_IN_ARG_TYPE, $ac_cv_type_svc_in_arg) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_time_t.m4000066400000000000000000000004111157065440000207160ustar00rootroot00000000000000dnl ###################################################################### dnl check for type of time_t (usually in ) AC_DEFUN([AMU_TYPE_TIME_T], [AC_CHECK_TYPE(time_t, long)]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_tmpfs_args.m4000066400000000000000000000013151157065440000216060ustar00rootroot00000000000000dnl ###################################################################### dnl Find the correct type for TMPFS mount(2) arguments structure AC_DEFUN([AMU_TYPE_TMPFS_ARGS], [ AC_CACHE_CHECK(for structure type of tmpfs mount(2) arguments, ac_cv_type_tmpfs_args, [ # set to a default value ac_cv_type_tmpfs_args=notfound # look for "struct tmpfs_args" if test "$ac_cv_type_tmpfs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct tmpfs_args a; ], ac_cv_type_tmpfs_args="struct tmpfs_args", ac_cv_type_tmpfs_args=notfound) fi ]) if test "$ac_cv_type_tmpfs_args" != notfound then AC_DEFINE_UNQUOTED(tmpfs_args_t, $ac_cv_type_tmpfs_args) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_udf_args.m4000066400000000000000000000012631157065440000212350ustar00rootroot00000000000000dnl ###################################################################### dnl Find the correct type for UDF mount(2) arguments structure AC_DEFUN([AMU_TYPE_UDF_ARGS], [ AC_CACHE_CHECK(for structure type of udf mount(2) arguments, ac_cv_type_udf_args, [ # set to a default value ac_cv_type_udf_args=notfound # look for "struct udf_args" if test "$ac_cv_type_udf_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct udf_args a; ], ac_cv_type_udf_args="struct udf_args", ac_cv_type_udf_args=notfound) fi ]) if test "$ac_cv_type_udf_args" != notfound then AC_DEFINE_UNQUOTED(udf_args_t, $ac_cv_type_udf_args) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_ufs_args.m4000066400000000000000000000021251157065440000212520ustar00rootroot00000000000000dnl ###################################################################### dnl Find the correct type for UFS mount(2) arguments structure AC_DEFUN([AMU_TYPE_UFS_ARGS], [ AC_CACHE_CHECK(for structure type of ufs mount(2) arguments, ac_cv_type_ufs_args, [ # set to a default value ac_cv_type_ufs_args=notfound # look for "struct ufs_args" if test "$ac_cv_type_ufs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct ufs_args a; ], ac_cv_type_ufs_args="struct ufs_args", ac_cv_type_ufs_args=notfound) fi # look for "struct efs_args" (irix) if test "$ac_cv_type_ufs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct efs_args a; ], ac_cv_type_ufs_args="struct efs_args", ac_cv_type_ufs_args=notfound) fi # look for "struct ufs_specific" (ultrix) if test "$ac_cv_type_ufs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct ufs_specific a; ], ac_cv_type_ufs_args="struct ufs_specific", ac_cv_type_ufs_args=notfound) fi ]) if test "$ac_cv_type_ufs_args" != notfound then AC_DEFINE_UNQUOTED(ufs_args_t, $ac_cv_type_ufs_args) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_xdrproc_t.m4000066400000000000000000000012171157065440000214460ustar00rootroot00000000000000dnl ###################################################################### dnl check for type of xdrproc_t (usually in ) AC_DEFUN([AMU_TYPE_XDRPROC_T], [ AC_CACHE_CHECK(for xdrproc_t, ac_cv_type_xdrproc_t, [ # try to compile a program which may have a definition for the type dnl need a series of compilations, which will test out every possible type # look for "xdrproc_t" AC_TRY_COMPILE_RPC( [ xdrproc_t xdr_int; ], ac_cv_type_xdrproc_t=yes, ac_cv_type_xdrproc_t=no) ]) if test "$ac_cv_type_xdrproc_t" = yes then AC_DEFINE_UNQUOTED(XDRPROC_T_TYPE, xdrproc_t) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_xfs_args.m4000066400000000000000000000012631157065440000212570ustar00rootroot00000000000000dnl ###################################################################### dnl Find the correct type for XFS mount(2) arguments structure AC_DEFUN([AMU_TYPE_XFS_ARGS], [ AC_CACHE_CHECK(for structure type of xfs mount(2) arguments, ac_cv_type_xfs_args, [ # set to a default value ac_cv_type_xfs_args=notfound # look for "struct xfs_args" if test "$ac_cv_type_xfs_args" = notfound then AC_TRY_COMPILE_ANYFS( [ struct xfs_args a; ], ac_cv_type_xfs_args="struct xfs_args", ac_cv_type_xfs_args=notfound) fi ]) if test "$ac_cv_type_xfs_args" != notfound then AC_DEFINE_UNQUOTED(xfs_args_t, $ac_cv_type_xfs_args) fi ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/type_yp_order_outorder.m4000066400000000000000000000014371157065440000232140ustar00rootroot00000000000000dnl ###################################################################### dnl check the correct type for the 3rd argument to yp_order() AC_DEFUN([AMU_TYPE_YP_ORDER_OUTORDER], [ AC_CACHE_CHECK(pointer type of 3rd argument to yp_order(), ac_cv_yp_order_outorder, [ # select the correct type case "${host_os}" in aix[[1-3]]* | aix4.[[0-2]]* | sunos[[34]]* | solaris1* ) ac_cv_yp_order_outorder=int ;; solaris* | svr4* | sysv4* | sunos* | hpux* | aix* ) ac_cv_yp_order_outorder="unsigned long" ;; linux* | osf* ) # DU4 man page is wrong, headers are right ac_cv_yp_order_outorder="unsigned int" ;; * ) ac_cv_yp_order_outorder=int ;; esac ]) AC_DEFINE_UNQUOTED(YP_ORDER_OUTORDER_TYPE, $ac_cv_yp_order_outorder) ]) dnl ====================================================================== am-utils-6.2+rc20110530/m4/macros/with_addon.m4000066400000000000000000000012631157065440000205220ustar00rootroot00000000000000dnl ###################################################################### dnl Do we want to compile with "ADDON" support? (hesiod, ldap, etc.) AC_DEFUN([AMU_WITH_ADDON], [AC_MSG_CHECKING([if $1 is wanted]) ac_upcase=`echo $1|tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` AC_ARG_WITH($1, AC_HELP_STRING([--with-$1], [enable $2 support (default=yes if found)] ),[ if test "$withval" = "yes"; then with_$1=yes elif test "$withval" = "no"; then with_$1=no else AC_MSG_ERROR(please use \"yes\" or \"no\" with --with-$1) fi ],[ with_$1=yes ]) if test "$with_$1" = "yes" then AC_MSG_RESULT([yes, will enable if all libraries are found]) else AC_MSG_RESULT([no]) fi ]) am-utils-6.2+rc20110530/m4/mk-aclocal000077500000000000000000000004351157065440000166050ustar00rootroot00000000000000#!/bin/sh # # Make am-utils' aclocal.m4 file (concatendated from others). # For maintainers only. # Erez Zadok if [ ! -d macros ]; then echo no macros directory found! exit 2 fi cd macros for i in HEADER *.m4; do cat $i echo echo done cat TRAILER exit 0 am-utils-6.2+rc20110530/m4/mkconf000077500000000000000000000004651157065440000160620ustar00rootroot00000000000000#!/bin/bash -norc # (re)make the autoconf configuration files. # Used by am-utils maintainers only! # # Erez Zadok # #set -x if [ ! -f amd/amd.c ]; then cd .. fi if [ ! -f amd/amd.c ]; then cd .. fi if [ ! -f amd/amd.c ]; then echo "wrong directory!" exit 1 fi cd m4 && make $* am-utils-6.2+rc20110530/m4/rmtspc000077500000000000000000000002061157065440000161060ustar00rootroot00000000000000#!/bin/sh # remove trailing spaces from C code #set -x for i in $*; do sed 's/[ ]*$//g' < $i > $i.tmp_$$ && mv $i.tmp_$$ $i done am-utils-6.2+rc20110530/m4/update_build_version000077500000000000000000000020621157065440000210060ustar00rootroot00000000000000#!/bin/sh # Update the build version file for am-utils # Erez Zadok #set -x file="build_version.h" vers=1 if test -f $file then egrep AMU_BUILD_VERSION $file | while read a b vers do vers=`expr $vers + 1` echo '/* do not edit this file by hand */' > $file echo '/* auto-generated by update_build_version script */' >> $file echo '#define AMU_BUILD_VERSION '$vers >> $file done else echo '/* do not edit this file by hand */' > $file echo '/* auto-generated by update_build_version script */' >> $file echo '#define AMU_BUILD_VERSION '$vers >> $file fi if test -n "$USER" then build_user="$USER" else if test -n "$LOGNAME" then build_user="$LOGNAME" else build_user=`(whoami) 2>/dev/null` || build_user=unknown fi fi echo '#define BUILD_USER "'$build_user'"' >> $file build_host=`(hostname || uname -n) 2>/dev/null` || build_host=unknown echo '#define BUILD_HOST "'$build_host'"' >> $file build_date=`(date) 2>/dev/null` || build_date=unknown_date echo '#define BUILD_DATE "'$build_date'"' >> $file am-utils-6.2+rc20110530/missing000077500000000000000000000262331157065440000157370ustar00rootroot00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2009-04-28.21; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # 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, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; tar*) if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then exit 1 fi ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; tar*) shift # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case $firstarg in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case $firstarg in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: am-utils-6.2+rc20110530/mk-amd-map/000077500000000000000000000000001157065440000162535ustar00rootroot00000000000000am-utils-6.2+rc20110530/mk-amd-map/.cvsignore000066400000000000000000000000141157065440000202460ustar00rootroot00000000000000Makefile.in am-utils-6.2+rc20110530/mk-amd-map/Makefile.am000066400000000000000000000016231157065440000203110ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in # Package: am-utils # Level: Makefile for mk-amd-map/ directory # Author: Erez Zadok sbin_PROGRAMS = mk-amd-map # man pages man_MANS = mk-amd-map.8 # headers this depends on, not to be installed #noinst_HEADERS = mk_amd_map_SOURCES = mk-amd-map.c LDADD = ../libamu/libamu.la INCLUDES = -I$(top_srcdir)/include # allow users to add their own flags via "configure --enable-am-flags=ARG" AMU_CFLAGS = @AMU_CFLAGS@ AM_CFLAGS = @CFLAGS@ $(AMU_CFLAGS) # additional files to distribute and clean EXTRA_DIST = $(man_MANS) # dependencies $(PROGRAMS): $(LDADD) $(mk_amd_map_OBJECTS): \ ../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) am-utils-6.2+rc20110530/mk-amd-map/mk-amd-map.8000066400000000000000000000057241157065440000202750ustar00rootroot00000000000000.\" .\" Copyright (c) 1997-2011 Erez Zadok .\" Copyright (c) 1993 Jan-Simon Pendry .\" Copyright (c) 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" 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. 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 .\" 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/mk-amd-map/mk-amd-map.8 .\" .TH MK-AMD-MAP 8 "June 28, 1993" .SH NAME .B mk-amd-map \- create database maps for Amd .SH SYNOPSIS .B mk-amd-map [ .B \-p ] .I mapname .SH DESCRIPTION .B mk-amd-map creates the database maps used by the keyed map lookups in amd(8). It reads input from the named file and outputs them to a correspondingly named hashed database. .TP .B \-p This option prints the map on standard output instead of generating a database. This is usually used to merge continuation lines into one physical line. .SH SEE ALSO .BR amd (8). .LP ``am-utils'' .BR info (1) entry. .LP .I "Linux NFS and Automounter Administration" by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). .LP .I http://www.am-utils.org .LP .I "Amd \- The 4.4 BSD Automounter" .SH AUTHORS Jan-Simon Pendry , Department of Computing, Imperial College, London, UK. .P Erez Zadok , Computer Science Department, Stony Brook University, New York, USA. .P Other authors and contributors to am-utils are listed in the .B AUTHORS file distributed with am-utils. am-utils-6.2+rc20110530/mk-amd-map/mk-amd-map.c000066400000000000000000000237541157065440000203530ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/mk-amd-map/mk-amd-map.c */ /* * Convert a file map into an ndbm map */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include /* (libdb version 2) uses .db extensions but an old dbm API */ /* check for libgdbm to distinguish it from linux systems */ #if defined(DBM_SUFFIX) && !defined(HAVE_LIBGDBM) # define HAVE_DB_SUFFIX #endif /* not defined(DBM_SUFFIX) && !defined(HAVE_LIBGDBM) */ #ifdef HAVE_MAP_NDBM static int store_data(voidp db, char *k, char *v) { datum key, val; key.dptr = k; val.dptr = v; key.dsize = strlen(k) + 1; val.dsize = strlen(v) + 1; return dbm_store((DBM *) db, key, val, DBM_INSERT); } /* * Read one line from file. */ static int read_line(char *buf, int size, FILE *fp) { int done = 0; do { while (fgets(buf, size, fp)) { int len = strlen(buf); done += len; if (len > 1 && buf[len - 2] == '\\' && buf[len - 1] == '\n') { int ch; buf += len - 2; size -= len - 2; *buf = '\n'; buf[1] = '\0'; /* * Skip leading white space on next line */ while ((ch = getc(fp)) != EOF && isascii((unsigned char)ch) && isspace((unsigned char)ch)) ; (void) ungetc(ch, fp); } else { return done; } } } while (size > 0 && !feof(fp)); return done; } /* * Read through a map. */ static int read_file(FILE *fp, char *map, voidp db) { char key_val[2048]; int chuck = 0; int line_no = 0; int errs = 0; while (read_line(key_val, 2048, fp)) { char *kp; char *cp; char *hash; int len = strlen(key_val); line_no++; /* * Make sure we got the whole line */ if (key_val[len - 1] != '\n') { fprintf(stderr, "line %d in \"%s\" is too long", line_no, map); chuck = 1; } else { key_val[len - 1] = '\0'; } /* * Strip comments */ hash = strchr(key_val, '#'); if (hash) *hash = '\0'; /* * Find start of key */ for (kp = key_val; *kp && isascii((unsigned char)*kp) && isspace((unsigned char)*kp); kp++) ; /* * Ignore blank lines */ if (!*kp) goto again; /* * Find end of key */ for (cp = kp; *cp && (!isascii((unsigned char)*cp) || !isspace((unsigned char)*cp)); cp++) ; /* * Check whether key matches, or whether * the entry is a wildcard entry. */ if (*cp) *cp++ = '\0'; while (*cp && isascii((unsigned char)*cp) && isspace((unsigned char)*cp)) cp++; if (*kp == '+') { fprintf(stderr, "Can't interpolate %s\n", kp); errs++; } else if (*cp) { if (db) { if (store_data(db, kp, cp) < 0) { fprintf(stderr, "Could store %s -> %s\n", kp, cp); errs++; } } else { printf("%s\t%s\n", kp, cp); } } else { fprintf(stderr, "%s: line %d has no value field", map, line_no); errs++; } again: /* * If the last read didn't get a whole line then * throw away the remainder before continuing... */ if (chuck) { while (fgets(key_val, sizeof(key_val), fp) && !strchr(key_val, '\n')) ; chuck = 0; } } return errs; } static int remove_file(char *f) { if (unlink(f) < 0 && errno != ENOENT) return -1; return 0; } int main(int argc, char *argv[]) { FILE *mapf; /* the input file to read from */ int error; char *mapsrc; DBM *db = NULL; static char maptmp[] = "dbmXXXXXX"; #ifdef HAVE_DB_SUFFIX char maptdb[16]; char *map_name_db = (char *) NULL; #else /* not HAVE_DB_SUFFIX */ char maptpag[16], maptdir[16]; char *map_name_pag = (char *) NULL, *map_name_dir = (char *) NULL; #endif /* not HAVE_DB_SUFFIX */ size_t l = 0; char *sl; int printit = 0; int usage = 0; int ch; extern int optind; /* test options */ while ((ch = getopt(argc, argv, "p")) != -1) switch (ch) { case 'p': printit = 1; break; default: usage++; break; } if (usage || optind != (argc - 1)) { fputs("Usage: mk-amd-map [-p] file-map\n", stderr); exit(1); } mapsrc = argv[optind]; /* test if can get to the map directory */ sl = strrchr(mapsrc, '/'); if (sl) { *sl = '\0'; if (chdir(mapsrc) < 0) { fputs("Can't chdir to ", stderr); perror(mapsrc); exit(1); } mapsrc = sl + 1; } /* open source file */ mapf = fopen(mapsrc, "r"); if (!mapf) { fprintf(stderr, "cannot open source file "); perror(mapsrc); exit(1); } #ifndef DEBUG signal(SIGINT, SIG_IGN); #endif /* DEBUG */ if (!printit) { /* enough space for ".db" or ".pag" or ".dir" appended */ l = strlen(mapsrc) + 5; #ifdef HAVE_DB_SUFFIX map_name_db = (char *) malloc(l); error = (map_name_db == NULL); #else /* not HAVE_DB_SUFFIX */ map_name_pag = (char *) malloc(l); map_name_dir = (char *) malloc(l); error = (map_name_pag == NULL || map_name_dir == NULL); #endif /* not HAVE_DB_SUFFIX */ if (error) { perror("mk-amd-map: malloc"); exit(1); } #ifdef HAVE_MKSTEMP { /* * XXX: hack to avoid compiler complaints about mktemp not being * secure, since we have to do a dbm_open on this anyway. So use * mkstemp if you can, and then close the fd, but we get a safe * and unique file name. */ int dummyfd; dummyfd = mkstemp(maptmp); if (dummyfd >= 0) close(dummyfd); } #else /* not HAVE_MKSTEMP */ mktemp(maptmp); #endif /* not HAVE_MKSTEMP */ /* remove existing temps (if any) */ #ifdef HAVE_DB_SUFFIX xsnprintf(maptdb, sizeof(maptdb), "%s.db", maptmp); if (remove_file(maptdb) < 0) { fprintf(stderr, "Can't remove existing temporary file; "); perror(maptdb); exit(1); } #else /* not HAVE_DB_SUFFIX */ xsnprintf(maptpag, sizeof(maptpag), "%s.pag", maptmp); xsnprintf(maptdir, sizeof(maptdir), "%s.dir", maptmp); if (remove_file(maptpag) < 0 || remove_file(maptdir) < 0) { fprintf(stderr, "Can't remove existing temporary files; %s and ", maptpag); perror(maptdir); exit(1); } #endif /* not HAVE_DB_SUFFIX */ db = dbm_open(maptmp, O_RDWR|O_CREAT|O_EXCL, 0444); if (!db) { fprintf(stderr, "cannot initialize temporary database: %s", maptmp); exit(1); } } /* print db to stdout or to temp database */ error = read_file(mapf, mapsrc, db); fclose(mapf); if (error) { if (printit) fprintf(stderr, "Error reading source file %s\n", mapsrc); else fprintf(stderr, "Error creating database map for %s\n", mapsrc); exit(1); } if (printit) exit(0); /* nothing more to do */ /* if gets here, we wrote to a database */ dbm_close(db); /* all went well */ #ifdef HAVE_DB_SUFFIX /* sizeof(map_name_db) is malloc'ed above */ xsnprintf(map_name_db, l, "%s.db", mapsrc); if (rename(maptdb, map_name_db) < 0) { fprintf(stderr, "Couldn't rename %s to ", maptdb); perror(map_name_db); /* Throw away the temporary map */ unlink(maptdb); exit(1); } #else /* not HAVE_DB_SUFFIX */ /* sizeof(map_name_{pag,dir}) are malloc'ed above */ xsnprintf(map_name_pag, l, "%s.pag", mapsrc); xsnprintf(map_name_dir, l, "%s.dir", mapsrc); if (rename(maptpag, map_name_pag) < 0) { fprintf(stderr, "Couldn't rename %s to ", maptpag); perror(map_name_pag); /* Throw away the temporary map */ unlink(maptpag); unlink(maptdir); exit(1); } if (rename(maptdir, map_name_dir) < 0) { fprintf(stderr, "Couldn't rename %s to ", maptdir); perror(map_name_dir); /* remove the (presumably bad) .pag file */ unlink(map_name_pag); /* throw away remaining part of original map */ unlink(map_name_dir); /* throw away the temporary map */ unlink(maptdir); fprintf(stderr, "WARNING: existing map \"%s.{dir,pag}\" destroyed\n", mapsrc); exit(1); } #endif /* not HAVE_DB_SUFFIX */ exit(0); } #else /* not HAVE_MAP_NDBM */ int main() { fputs("mk-amd-map: This system does not support hashed database files\n", stderr); exit(1); } #endif /* not HAVE_MAP_NDBM */ am-utils-6.2+rc20110530/mkinstalldirs000077500000000000000000000067221157065440000171470ustar00rootroot00000000000000#! /bin/sh # mkinstalldirs --- make directory hierarchy scriptversion=2009-04-28.21; # UTC # Original author: Noah Friedman # Created: 1993-05-16 # Public domain. # # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' IFS=" "" $nl" errstatus=0 dirmode= usage="\ Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ... Create each directory DIR (with mode MODE, if specified), including all leading file name components. Report bugs to ." # process command line arguments while test $# -gt 0 ; do case $1 in -h | --help | --h*) # -h for help echo "$usage" exit $? ;; -m) # -m PERM arg shift test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } dirmode=$1 shift ;; --version) echo "$0 $scriptversion" exit $? ;; --) # stop option processing shift break ;; -*) # unknown option echo "$usage" 1>&2 exit 1 ;; *) # first non-opt arg break ;; esac done for file do if test -d "$file"; then shift else break fi done case $# in 0) exit 0 ;; esac # Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and # mkdir -p a/c at the same time, both will detect that a is missing, # one will create a, then the other will try to create a and die with # a "File exists" error. This is a problem when calling mkinstalldirs # from a parallel make. We use --version in the probe to restrict # ourselves to GNU mkdir, which is thread-safe. case $dirmode in '') if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then echo "mkdir -p -- $*" exec mkdir -p -- "$@" else # On NextStep and OpenStep, the `mkdir' command does not # recognize any option. It will interpret all options as # directories to create, and then abort because `.' already # exists. test -d ./-p && rmdir ./-p test -d ./--version && rmdir ./--version fi ;; *) if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 && test ! -d ./--version; then echo "mkdir -m $dirmode -p -- $*" exec mkdir -m "$dirmode" -p -- "$@" else # Clean up after NextStep and OpenStep mkdir. for d in ./-m ./-p ./--version "./$dirmode"; do test -d $d && rmdir $d done fi ;; esac for file do case $file in /*) pathcomp=/ ;; *) pathcomp= ;; esac oIFS=$IFS IFS=/ set fnord $file shift IFS=$oIFS for d do test "x$d" = x && continue pathcomp=$pathcomp$d case $pathcomp in -*) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr else if test ! -z "$dirmode"; then echo "chmod $dirmode $pathcomp" lasterr= chmod "$dirmode" "$pathcomp" || lasterr=$? if test ! -z "$lasterr"; then errstatus=$lasterr fi fi fi fi pathcomp=$pathcomp/ done done exit $errstatus # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: am-utils-6.2+rc20110530/scripts/000077500000000000000000000000001157065440000160215ustar00rootroot00000000000000am-utils-6.2+rc20110530/scripts/.cvsignore000066400000000000000000000000141157065440000200140ustar00rootroot00000000000000Makefile.in am-utils-6.2+rc20110530/scripts/Makefile.am000066400000000000000000000015411157065440000200560ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in # Package: am-utils # Level: Makefile for scripts/ directory # Author: Erez Zadok sbin_SCRIPTS = \ am-eject \ amd2ldif \ amd2sun \ automount2amd \ ctl-amd \ ctl-hlfsd \ fixrmtab \ fix-amd-map \ lostaltmail \ wait4amd \ wait4amd2die noinst_SCRIPTS = \ redhat-ctl-amd \ test-attrcache bin_SCRIPTS = expn sysconf_DATA = amd.conf-sample lostaltmail.conf-sample # man pages man_MANS = amd.conf.5 automount2amd.8 expn.1 EXTRA_DIST = \ am-eject.in \ amd2ldif.in \ amd2sun.in \ automount2amd.in \ ctl-amd.in \ ctl-hlfsd.in \ fixrmtab.in \ fix-amd-map.in \ lostaltmail.in \ redhat-ctl-amd.in \ wait4amd.in \ wait4amd2die.in \ \ expn.in \ \ amd.conf-sample \ lostaltmail.conf-sample \ $(man_MANS) CLEANFILES = $(sbin_SCRIPTS) $(bin_SCRIPTS) $(noinst_SCRIPTS) am-utils-6.2+rc20110530/scripts/am-eject.in000066400000000000000000000021271157065440000200400ustar00rootroot00000000000000#!/bin/sh # auto-unmount floppy/cd directory before ejecting device # script taken from Debian Linux's amd # # Package: am-utils-6.x # (Additional) author: Erez Zadok # set path prefix=@prefix@ exec_prefix=@exec_prefix@ PATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH} export PATH if [ $# -ne 1 ]; then echo "Usage: $0 cd|cdrom|fd|floppy" exit 2 fi # determine toplevel mount point of amd fs=`amq | grep ' toplvl ' | cut -d' ' -f1` if [ "$fs" = "" ]; then echo "Cannot determine amd toplevel directory" exit 2 fi # append name of medium case "$1" in cd|fd) fs=$fs/$1;; *) echo "Usage: $0 cd|cdrom|fd|floppy"; exit 2;; esac # is the medium mounted? if amq | grep -q "^$fs" >/dev/null 2>&1; then # if yes, try to unmount it sync amq -u $fs sleep 2 if amq | grep -q "^$fs" >/dev/null 2>&1; then # failed, bail out echo -n "Cannot unmount $fs; in use by:" fuser -uv -m $fs echo "" exit 1 fi else echo "$fs not mounted" fi case $1 in cd|cdrom) eject cdrom || eject ;; # eject CD-ROM fd|floppy) eject floppy || eject echo "Ok to remove disk" ;; esac am-utils-6.2+rc20110530/scripts/amd.conf-sample000066400000000000000000000137641157065440000207230ustar00rootroot00000000000000# A SAMPLE CONFIGURATION FILE FOR AMD ############################################################################## # GLOBAL OPTIONS SECTION (must be first in amd.conf file) # For most options, the default value is listed first, but see amd.conf(5) [ global ] # (amd -n) normalize_hostnames = no | yes # do we want to strip domain names from hostnames or not? domain_strip = yes | no # (amd -p) print_pid = no | yes pid_file = /dev/stdout | /var/run/amd.pid # (amd -r) restart_mounts = no | yes unmount_on_exit = no | yes forced_unmounts = no | yes # (amd -a) auto_dir = /a # duration in seconds that a looked up name remain cached (amd -c) cache_duration = 300 # (amd -d) local_domain = cs.columbia.edu # (amd -k) karch = sun4m # (amd -A) arch = sun4 # if you don't like autoconf picking up "sunos5" as the os-type, override it # (amd -O) os = sos5 # (amd -o) osver = 2.5.1 # full os name full_os = linux-2.2.5 # OS vendor vendor = redhat # if you print_version after setting up "os", it will show it. (amd -v) print_version = no | yes # (amd -l) log_file = /dev/stderr | /var/log/amd | syslog[:facility] # should we truncate the log file on startup? truncate_log = no | yes # NFS (RPC) retry interval/counter, in tenths of secs (amd -t interval.counter) nfs_retry_interval = 8 nfs_retransmit_counter = 11 (eleven retransmission attempts) # The next four are the same as the above two, but allow you to set global # values for all UDP vs. TCP mounts separately. nfs_retry_interval_udp = 16 nfs_retransmit_counter_udp = 22 nfs_retry_interval_tcp = 4 nfs_retransmit_counter_tcp = 5 # These two are specific to Amd's top-level (NFSv2/udp) mounts # and they can also be set separately. nfs_retry_interval_toplvl = 6 nfs_retransmit_counter_toplvl = 8 # NFS attribute cache value for Amd's automount points # (some OSs use this parameter in units of seconds, and others in 0.1 seconds) # See README.attrcache for important information about this parameter. auto_attrcache = 0 # (amd -w) dismount_interval = 120 # (amd -y) nis_domain = nisDom-CS.columbia.edu # (amd -x) log_options = fatal,error,user,warn,info,map,stats,all # (amd -D) debug_options = all,defaults,test,amq,daemon,fork,\ full,hrtime,info,mem,mtab,str,readdir,trace,xdrtrace # path for mtab file during mtab debug mode debug_mtab_file = /tmp/mnttab # (amd -S) plock = yes | no # should browsable maps show number of entries to df/statfs (default=no) show_statfs_entries = no | yes # (hpux) cluster name (amd -C) cluster = ??? # LDAP (Lightweight Directory Access Protocol) options ldap_base = "ou=Marketing, o=AMD Ltd, c=US" ldap_hostports = ldap.your.domain:389 ldap_cache_seconds = 0 ldap_cache_maxmem = 131072 ldap_proto_version = 2 # default base name for hesiod maps hesiod_base = automount # interval to check if a reload of any maps is needed map_reload_interval = 3600 # alternate RPC program number to register with the port mapper portmap_program = 300019-300029 # Ask for a different Amq RPC port (both UDP and TCP). # If set to 0 (default), Amd will pick a port automatically. preferred_amq_port = 1234 # use fully qualified host names fully_qualified_hosts = no | yes # force NFS version or NFS protocol nfs_vers = 2 | 3 nfs_proto = udp | tcp # perform Amq service checks via tcpwrappers (tcpd/libwrap) use_tcpwrappers = yes | no # allow NFS requests from insecure (>=1024) ports nfs_allow_insecure_port = no | yes # accept local NFS packets from any local interface, not just 127.0.0.1 nfs_allow_any_interface = no | yes # address used for local NFS mount and RPC server (default to localhost) localhost_address = foo.example.com | 192.168.1.2 # number of seconds to timeout before map returns output exec_map_timeout = 10 # normalize multiple/trailing slashes or not? normalize_slashes = yes | no ############################################################################## # these 9 global options can be overridden by each map individually browsable_dirs = no | yes | full map_options = cache:=all map_type = file|hesiod|ndbm|nis|nisplus|passwd|union|ldap # any string that will be used to override to the map /defaults entry map_defaults = opts:=nosuid,rw,intr,bg,noquota;type:=link mount_type = nfs | autofs autofs_use_lofs = yes | no search_path = /etc/local:/etc/amdmaps:/misc/yp # selectors are not recognized by default in the /defaults entry selectors_in_defaults = no | yes # does this map use Sun Automounter map syntax? sun_map_syntax = no | yes ############################################################################## ############################################################################## # DEFINE AN AMD MOUNT POINT [ /home ] # map name must be defined, all else are optional map_name = /etc/amd.home | amd.home map_options = cache:=all # if map type is not defined, will search all map types (default) map_type = file|hesiod|ndbm|nis|nisplus|passwd|union|ldap search_path = /etc/local:/etc/amdmaps:/misc/yp # an amd or autofs mount point mount_type = nfs | autofs browsable_dirs = yes | no # an optional tag to be used with amd -T tag. untagged entries are always # used. Tagged ones get used only if specified with "amd -T" tag = test ############################################################################## # DEFINE ANOTHER AMD MOUNT POINT [ /src ] map_name = /usr/local/lib/amdmaps/amu.src # regular amd (nfs) mount point (default) mount_type = nfs # any string that will be used as prefix to the map /defaults entry # this overrides what's defined in [global] map_defaults = type:=nfs ############################################################################## # DEFINE ANOTHER AMD MOUNT POINT [ /test ] map_name = /etc/lookup-entry.sh # an executable map type map_type = exec ############################################################################## # DEFINE A SUN SYNTAX MOUNT POINT [ /proj ] map_name = /etc/amd.proj # does this map use Sun Automounter map syntax? sun_map_syntax = yes ############################################################################## am-utils-6.2+rc20110530/scripts/amd.conf.5000066400000000000000000000702041157065440000175770ustar00rootroot00000000000000.\" .\" Copyright (c) 1997-2011 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. 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 .\" 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/scripts/amd.conf.5 .\" .TH AMD.CONF 5 "7 August 1997" .SH NAME amd.conf \- Amd configuration file .SH SYNOPSIS .B amd.conf .SH DESCRIPTION The .B amd.conf file is the configuration file for Amd, as part of the am-utils suite. .P .B amd.conf contains runtime configuration information for the .B Amd automounter program. .\" ************************************************************************** .SH FILE FORMAT .P The file consists of sections and parameters. A section begins with the name of the section in square brackets and continues until the next section begins or the end the file is reached. Sections contain parameters of the form 'name = value'. .P The file is line-based - that is, each newline-terminated line represents either a comment, a section name or a parameter. No line-continuation syntax is available. .P Section, parameter names and their values are case sensitive. .P Only the first equals sign in a parameter is significant. Whitespace before or after the first equals sign is discarded. Leading, trailing and internal whitespace in section and parameter names is irrelevant. Leading and trailing whitespace in a parameter value is discarded. Internal whitespace within a parameter value is not allowed, unless the whole parameter value is quoted with double quotes as in 'name = "some value"'. .P Any line beginning with a pound sign (#) is ignored, as are lines containing only whitespace. .P The values following the equals sign in parameters are all either a string (no quotes needed if string does not include spaces) or a boolean, which may be given as yes/no. Case is significant in all values. Some items such as cache timeouts are numeric. .\" ************************************************************************** .SH SECTIONS .SS The [global] section Parameters in this section either apply to Amd as a whole, or to all other regular map sections which follow. There should be only one global section defined in one configuration file. .P It is highly recommended that this section be specified first in the configuration file. If it is not, then regular map sections which precede it will not use global values defined later. .SS Regular [/map] sections Parameters in regular (non-global) sections apply to a single map entry. For example, if the map section .B [/homes] is defined, then all parameters following it will be applied to the .I /homes Amd-managed mount point. .\" ************************************************************************** .SH PARAMETERS .SS Parameters common to all sections These parameters can be specified either in the global or a map specific section. Entries specified in a map-specific section override the default value or one defined in the global section. If such a common parameter is specified only in the global section, it is applicable to all regular map sections that follow. .\" ************************************************************************** .TP .BR browsable_dirs " (string, default=no)" If "yes," then Amd's top-level mount points will be browsable to .BR readdir (3) calls. This means you could run for example .BR ls (1) and see what keys are available to mount in that directory. Not all entries are made visible to readdir(3): the "/default" entry, wildcard entries, and those with a "/" in them are not included. If you specify "full" to this option, all but "/default" will be visible. Note that if you run a command which will attempt to .BR stat (2) the entries, such as often done by "ls -l" or "ls -F," Amd will attempt to mount .I every entry in that map. This is often called a ``mount storm.'' .TP .BR map_defaults " (string, default to empty)" This option sets a string to be used as the map's /defaults entry, overriding any /defaults specified in the map. This allows local users to override map defaults without modifying maps globally. .TP .BR map_options " (string, default no options)" This option is the same as specifying map options on the command line to Amd, such as "cache:=all". .TP .BR map_type " (string, default search all map types)" If specified, Amd will initialize the map only for the type given. This is useful to avoid the default map search type used by Amd which takes longer and can have undesired side-effects such as initializing NIS even if not used. Possible values are .nf \fBexec\fR executable maps \fBfile\fR plain files \fBhesiod\fR Hesiod name service from MIT \fBldap\fR Lightweight Directory Access Protocol \fBndbm\fR (New) dbm style hash files \fBnis\fR Network Information Services (version 2) \fBnisplus\fR Network Information Services Plus (version 3) \fBpasswd\fR local password files \fBunion\fR union maps .fi .TP .BR mount_type " (string, default=nfs)" All Amd mount types default to NFS. That is, Amd is an NFS server on the map mount points, for the local host it is running on. If "autofs" is specified, Amd will be an autofs server for those mount points. .TP .BR autofs_use_lofs " (string, default=yes)" When set to "yes" and using Autofs, Amd will use lofs-type (loopback) mounts for type:=link mounts. This has the advantage of mounting in place, and users get to the see the same pathname that they chdir'ed into. If this option is set to "no," then Amd will use symlinks instead: that code is more tested, but negates autofs's big advantage of in-place mounts. .TP .BR search_path " (string, default no search path)" This provides a (colon-delimited) search path for file maps. Using a search path, sites can allow for local map customizations and overrides, and can distributed maps in several locations as needed. .TP .BR selectors_in_defaults " (boolean, default=no)" If "yes," then the /defaults entry of maps will search for and process any selectors before setting defaults for all other keys in that map. Useful when you want to set different options for a complete map based on some parameters. For example, you may want to better the NFS performance over slow slip-based networks as follows: .nf /defaults \\ wire==slip-net;opts:=intr,rsize=1024,wsize=1024 \\ wire!=slip-net;opts:=intr,rsize=8192,wsize=8192 .fi Deprecated form: selectors_on_default .TP .BR sun_map_syntax " (boolean, default=no)" If "yes," then Amd will parse the map according to the Sun Automount syntax. .\" ************************************************************************** .SS Parameters applicable to the global section only .TP .BR arch " (string, default to compiled in value)" Same as the .B \-A option to Amd. Allows you to override the value of the .I arch Amd variable. .TP .BR auto_attrcache " (numeric, default=0)" Specify in seconds (or units of 0.1 seconds, depending on the OS), what is the (kernel-side) NFS attribute cache timeout for @i{Amd}'s own automount points. A value of 0 is supposed to turn off attribute caching, meaning that @i{Amd} will be consulted via a kernel-RPC each time someone stat()'s the mount point (which could be abused as a denial-of-service attack). Warning: some OSs are incapable of turning off the NFS attribute cache reliably. On such systems, Amd may not work reliably under heavy load. See the README.attrcache document in the Am-utils distribution for more details. .TP .BR auto_dir " (string, default=/a)" Same as the .B \-a option to Amd. This sets the private directory where Amd will create sub-directories for its real mount points. .TP .BR cache_duration " (numeric, default=300)" Same as the .B \-c option to Amd. Sets the duration in seconds that looked-up or mounted map entries remain in the cache. .TP .BR cluster " (string, default no cluster)" Same as the .B \-C option to Amd. Specifies the alternate HP-UX cluster to use. .TP .BR debug_mtab_file " (string, default=/tmp/mnttab)" Path to mtab file that is used by Amd to store a list of mounted file systems during debug-mtab mode. This option only applies to systems that store mtab information on disk. .TP .TP .BR debug_options " (string, default no debug options)" Same as the .B \-D option to Amd. Specify any debugging options for Amd. Works only if am-utils was configured for debugging using the --enable-debug option. The "mem" option, as well as all other options, can be turned on via --enable-debug=mem. Otherwise debugging options are ignored. Options are comma delimited, and can be preceded by the string "no" to negate their meaning. You can get the list of supported debugging options by running Amd \-H. Possible values are: .nf \fBall\fR all options (excludes hrtime and mtab) \fBdefaults\fR "sensible" default options (all--excluding hrtime, mtab, and xdrtrace) \fBtest\fR full debug options plus mtab,nodaemon,nofork,noamq \fBamq\fR register for amq \fBdaemon\fR enter daemon mode \fBfork\fR fork server \fBfull\fR program trace \fBhrtime\fR print high resolution time stamps (only if syslog(3) is not used) \fBinfo\fR info service specific debugging (hesiod, nis, etc.) \fBmem\fR trace memory allocations \fBmtab\fR use local "/tmp/mtab" file \fBreaddir\fR show browsable_dirs progress \fBstr\fR debug string munging \fBtrace\fR trace protocol and NFS mount arguments \fBxdrtrace\fR trace XDR routines .fi .TP .BR dismount_interval " (numeric, default=120)" Same as the .B \-w option to Amd. Specify in seconds, the time between attempts to dismount file systems that have exceeded their cached times. .TP .BR domain_strip " (boolean, default=yes)" If "yes," then the domain name part referred to by ${rhost} is stripped off. This is useful to keep logs and smaller. If "no," then the domain name part is left changed. This is useful when using multiple domains with the same maps (as you may have hosts whose domain-stripped name is identical). .TP .BR exec_map_timeout " (numeric, default=10)" The timeout in seconds that .I Amd will wait for an executable map program before an answer is returned from that program (or script). This value should be set to as small as possible while still allowing normal replies to be returned before the timer expires, because during the time that the executable map program is queried, .I Amd is essentially waiting and is thus not responding to any other queries. .TP .BR forced_unmounts " (boolean, default=no)" If set to "yes," and the client OS supports forced or lazy unmounts, then .I Amd will attempt to use them if it gets any of three serious error conditions when trying to unmount an existing mount point or mount on top of one: EIO, ESTALE, or EBUSY. This could be useful to recover from serious conditions such as hardware failure of mounted disks, or NFS servers which are down permanently, were migrated, or changed their IP address. Only "type:=toplvl" mounts hung with EBUSY are forcibly unmounted using this option, which is useful to recover from a hung .IR Amd ). .TP .BR full_os " (string, default to compiled in value)" The full name of the operating system, along with its version. Allows you to override the compiled-in full name and version of the operating system. Useful when the compiled-in name is not desired. For example, the full operating system name on linux comes up as ``linux'', but you can override it to ``linux-2.2.5.'' .TP .BR fully_qualified_hosts " (string, default=no)" If "yes," .I Amd will perform RPC authentication using fully-qualified host names. This is necessary for some systems, and especially when performing cross-domain mounting. For this function to work, the .I Amd variable ${hostd} is used, requiring that ${domain} not be null. .TP .BR hesiod_base " (string, default=automount)" Specify the base name for hesiod maps. .TP .BR karch " (string, default to karch of the system)" Same as the .B \-k option to Amd. Allows you to override the kernel-architecture of your system. Useful for example on Sun (Sparc) machines, where you can build one Amd binary, and run it on multiple machines, yet you want each one to get the correct .I karch variable set (for example, sun4c, sun4m, sun4u, etc.) Note that if not specified, Amd will use uname(3) to figure out the kernel architecture of the machine. .TP .BR ldap_base " (string, default not set)" Specify the base name for LDAP. This often includes LDAP-specific values such as country and organization. .TP .BR ldap_cache_maxmem " (numeric, default=131072)" Specify the maximum memory Amd should use to cache LDAP entries. .TP .BR ldap_cache_seconds " (numeric, default=0)" Specify the number of seconds to keep entries in the cache. .TP .BR ldap_hostports " (string, default not set)" Specify the LDAP host and port values. .TP .BR ldap_proto_version " (numeric, default=2)" Specify the version of the LDAP protocol to use. .TP .BR local_domain " (string, default no sub-domain)" Same as the .B \-d option to Amd. Specify the local domain name. If this option is not given the domain name is determined from the hostname, by removing the first component of the fully-qualified host name. .TP .BR localhost_address " (string, default to localhost or 127.0.0.1)" Specify the name or IP address for Amd to use when connecting the sockets for the local NFS server and the RPC server. This defaults to 127.0.0.1 or whatever the host reports as its local address. This parameter is useful on hosts with multiple addresses where you want to force Amd to connect to a specific address. .TP .BR log_file " (string, default=/dev/stderr)" Same as the .B \-l option to Amd. Specify a file name to log Amd events to. If the string .B /dev/stderr is specified, Amd will send its events to the standard error file descriptor. If the string .B syslog is given, Amd will record its events with the system logger .BR syslogd (8). The default syslog facility used is LOG_DAEMON. If you wish to change it, append its name to the log file name, delimited by a single colon. For example, if .I logfile is the string .B syslog:local7 then Amd will log messages via .IR syslog (3) using the LOG_LOCAL7 facility (if it exists on the system). .TP .BR log_options " (string, default=defaults)" Same as the .B \-x option to Amd. Specify any logging options for Amd. Options are comma delimited, and can be preceded by the string "no" to negate their meaning. The "debug" logging option is only available if am-utils was configured with --enable-debug. You can get the list of supported debugging and logging options by running .B amd .BR \-H . Possible values are: .nf \fBall\fR all messages \fBdefaults\fR default messages (fatal,error,user,warning,info) \fBdebug\fR debug messages \fBerror\fR non-fatal system errors (cannot be turned off) \fBfatal\fR fatal errors (cannot be turned off) \fBinfo\fR information \fBmap\fR map errors \fBstats\fR additional statistical information \fBuser\fR non-fatal user errors \fBwarn\fR warnings \fBwarning\fR warnings .fi .TP .BR map_reload_interval " (numeric, default=3600)" The number of seconds that Amd will wait before it checks to see if any maps have changed at their source (NIS servers, LDAP servers, files, etc.). Amd will reload only those maps that have changed. .TP .BR nfs_allow_any_interface " (string, default=no)" Normally Amd accepts local NFS packets only from 127.0.0.1. If this parameter is set to "yes" then Amd will accept local NFS packets from any local interface; this is useful on hosts that may have multiple interfaces where the system is forced to send all outgoing packets (even those bound to the same host) via an address other than 127.0.0.1. .TP .BR nfs_allow_insecure_port " (string, default=no)" Normally Amd will refuse requests coming from unprivileged ports (i.e. ports >= 1024 on Unix systems), so that only privileged users and the kernel can send NFS requests to it. However, some kernels (certain versions of Darwin, MacOS X, and Linux) have bugs that cause them to use unprivileged ports in certain situations, which causes Amd to stop dead in its tracks. This parameter allows Amd to operate normally even on such systems, at the expense of a slight decrease in the security of its operations. If you see messages like "ignoring request from foo:1234, port not reserved" in your Amd log, try enabling this parameter and give it another go. .TP .BR nfs_proto " (string, default to trying version tcp then udp)" By default, Amd tries TCP and then UDP. This option forces the overall NFS protocol used to TCP or UDP. It overrides what is in the Amd maps, and is useful when Amd is compiled with NFSv3 support that may not be stable. With this option you can turn off the complete usage of NFSv3 dynamically (without having to recompile Amd) until such time as NFSv3 support is desired again. .TP .BR nfs_retransmit_counter " (numeric, default=11)" Same as the .I retransmit part of the .BI \-t " timeout.retransmit" option to Amd. Specifies the number of NFS retransmissions that the kernel will use to communicate with Amd. .TP .BR nfs_retransmit_counter_udp " (numeric, default=11)" Same as the .B nfs_retransmit_counter option, but for all UDP mounts only. .TP .BR nfs_retransmit_counter_tcp " (numeric, default=11)" Same as the .B nfs_retransmit_counter option, but for all TCP mounts only. .TP .BR nfs_retransmit_counter_toplvl " (numeric, default=11)" Same as the .B nfs_retransmit_counter option, but only for Amd's top-level UDP mounts. .TP .BR nfs_retry_interval " (numeric, default=8)" Same as the .I timeout part of the .BI \-t " timeout.retransmit" option to Amd. Specifies the NFS timeout interval, in .I tenths of seconds, between NFS/RPC retries (for UDP and TCP). This is the value that the kernel will use to communicate with Amd. Amd relies on the kernel RPC retransmit mechanism to trigger mount retries. The values of the .B nfs_retransmit_counter and the .B nfs_retry_interval parameters change the overall retry interval. Too long an interval gives poor interactive response; too short an interval causes excessive retries. .TP .BR nfs_retry_interval_udp " (numeric, default=8)" Same as the .B nfs_retry_interval option, but for all UDP mounts only. .TP .BR nfs_retry_interval_tcp " (numeric, default=8)" Same as the .B nfs_retry_interval option, but for all TCP mounts only. .TP .BR nfs_retry_interval_toplvl " (numeric, default=8)" Same as the .B nfs_retry_interval option, but only for Amd's top-level UDP mounts. .TP .BR nfs_vers " (numeric, default to trying version 3 then 2)" By default, Amd tries version 3 and then version 2. This option forces the overall NFS protocol used to version 3 or 2. It overrides what is in the Amd maps, and is useful when Amd is compiled with NFSv3 support that may not be stable. With this option you can turn off the complete usage of NFSv3 dynamically (without having to recompile Amd) until such time as NFSv3 support is desired again. .TP .BR nis_domain " (string, default to local NIS domain name)" Same as the .B \-y option to Amd. Specify an alternative NIS domain from which to fetch the NIS maps. The default is the system domain name. This option is ignored if NIS support is not available. .TP .BR normalize_hostnames " (boolean, default=no)" Same as the .B \-n option to Amd. If "yes," then the name refereed to by ${rhost} is normalized relative to the host database before being used. The effect is to translate aliases into ``official'' names. .TP .BR normalize_slashes " (boolean, default=yes)" If "yes," then Amd will condense all multiple ``/'' (slash) characters into one and remove all trailing slashes. If "no," then Amd will not touch strings that may contain repeated or trailing slashes. The latter is sometimes useful with SMB mounts, which often require multiple slash characters in pathnames. .TP .BR os " (string, default to compiled in value)" Same as the .B \-O option to Amd. Allows you to override the compiled-in name of the operating system. Useful when the built-in name is not desired for backward compatibility reasons. For example, if the build in name is ``sunos5'', you can override it to ``sos5'', and use older maps which were written with the latter in mind. .TP .BR osver " (string, default to compiled in value)" Same as the .B \-o option to Amd. Overrides the compiled-in version number of the operating system. Useful when the built in version is not desired for backward compatibility reasons. For example, if the build in version is ``2.5.1'', you can override it to ``5.5.1'', and use older maps that were written with the latter in mind. .TP .BR pid_file " (string, default=/dev/stdout)" Specify a file to store the process ID of the running daemon into. If not specified, Amd will print its process id onto the standard output. Useful for killing Amd after it had run. Note that the PID of a running Amd can also be retrieved via .B amq .BR \-p . This file is used only if the print_pid option is on. .TP .BR plock " (boolean, default=yes)" Same as the .B \-S option to Amd. If "yes," lock the running executable pages of Amd into memory. To improve Amd's performance, systems that support the .BR plock (3) or .BR mlockall (2) call can lock the Amd process into memory. This way there is less chance it the operating system will schedule, page out, and swap the Amd process as needed. This improves Amd's performance, at the cost of reserving the memory used by the Amd process (making it unavailable for other processes). .TP .BR portmap_program " (numeric, default=300019)" Specify an alternate Port-mapper RPC program number, other than the official number. This is useful when running multiple Amd processes. For example, you can run another Amd in "test" mode, without affecting the primary Amd process in any way. For safety reasons, the alternate program numbers that can be specified must be in the range 300019-300029, inclusive. Amq has an option .B -P which can be used to specify an alternate program number of an Amd to contact. In this way, amq can fully control any number of Amd processes running on the same host. .TP .BR preferred_amq_port " (numeric, default=0)" Specify an alternate Port-mapper RPC port number for Amd's Amq service. This is used for both UDP and TCP. Setting this value to 0 (or not defining it) will cause Amd to select an arbitrary port number. Setting the Amq RPC service port to a specific number is useful in firewalled or NAT'ed environments, where you need to know which port Amd will listen on. .TP .BR print_pid " (boolean, default=no)" Same as the .B \-p option to Amd. If "yes," Amd will print its process ID upon starting. .TP .BR print_version " (boolean, default=no)" Same as the .B \-v option to Amd, but the version prints and Amd continues to run. If "yes," Amd will print its version information string, which includes some configuration and compilation values. .TP .BR restart_mounts " (boolean, default=no)" Same as the .B \-r option to Amd. If "yes" Amd will scan the mount table to determine which file systems are currently mounted. Whenever one of these would have been auto-mounted, Amd inherits it. .TP .BR show_statfs_entries " (boolean), default=no)" If "yes," then all maps which are browsable will also show the number of entries (keys) they have when "df" runs. (This is accomplished by returning non-zero values to the statfs(2) system call). .TP .BR truncate_log " (boolean), default=no)" If "yes," then the log file (if it is a regular file), will be truncated upon startup. .TP .BR unmount_on_exit " (boolean), default=no)" If "yes," then Amd will attempt to unmount all file systems which it knows about. Normally Amd leaves all (esp. NFS) mounted file systems intact. Note that Amd does not know about file systems mounted before it starts up, unless the restart_mounts option or .B \-r flag are used. .TP .BR use_tcpwrappers " (boolean), default=yes)" If "yes," then Amd will use the tcpd/librwap tcpwrappers library (if available) to control access to Amd via the /etc/hosts.allow and /etc/hosts.deny files. .TP .BR vendor " (string, default to compiled in value)" The name of the vendor of the operating system. Overrides the compiled-in vendor name. Useful when the compiled-in name is not desired. For example, most Intel based systems set the vendor name to ``unknown'', but you can set it to ``redhat.'' .\" ************************************************************************** .SS Parameters applicable to regular map sections .TP .BR map_name " (string, must be specified)" Name of the map where the keys are located. .TP .BR tag " (string, default no tag)" Each map entry in the configuration file can be tagged. If no tag is specified, that map section will always be processed by Amd. If it is specified, then Amd will process the map if the .B -T option was given to Amd, and the value given to that command-line option matches that in the map section. .\" ************************************************************************** .SH EXAMPLES Here is a real Amd configuration file I use daily. .P .nf # GLOBAL OPTIONS SECTION [ global ] normalize_hostnames = no print_pid = no restart_mounts = yes auto_dir = /n log_file = /var/log/amd log_options = all #debug_options = all plock = no selectors_in_defaults = yes # config.guess picks up "sunos5" and I don't want to edit my maps yet os = sos5 # if you print_version after setting up "os," it will show it. print_version = no map_type = file search_path = /etc/amdmaps:/usr/lib/amd:/usr/local/AMD/lib browsable_dirs = yes # DEFINE AN AMD MOUNT POINT [ /u ] map_name = amd.u [ /proj ] map_name = amd.proj [ /src ] map_name = amd.src [ /misc ] map_name = amd.misc [ /import ] map_name = amd.import [ /tftpboot/.amd ] tag = tftpboot map_name = amd.tftpboot .fi .\" ************************************************************************** .SH "SEE ALSO" .BR amd (8), .BR amq (8), .BR ctl-amd (8), .BR automount (8), .BR hosts_access (5). .LP ``am-utils'' .BR info (1) entry. .LP .I "Linux NFS and Automounter Administration" by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). .LP .I http://www.am-utils.org .LP .I "Amd \- The 4.4 BSD Automounter" .SH AUTHORS Erez Zadok , Computer Science Department, Stony Brook University, Stony Brook, New York, USA. .P Other authors and contributors to am-utils are listed in the .B AUTHORS file distributed with am-utils. am-utils-6.2+rc20110530/scripts/amd2ldif.in000077500000000000000000000027151157065440000200430ustar00rootroot00000000000000#!@PERL@ $usage=<mapfile.ldif mapname: name of the amd map beeing converted to ldif base : The LDAP search base. Do not forget the quotes! This script should/could be used in a Makefile together with ldif2ldbm(8C) to automagically update the ldap databases and restart slapd whenever a master copy of the maps have changed. Remember "cd /var/yp; make" ? EOU my $fmt = "%-12s: %s\n"; my $tfmt = "%-15s: %s\n"; my $mapname = $ARGV[0] or die $usage; my $base = $ARGV[1] or die $usage; $time = time(); print "dn: cn=amdmap $mapname timestamp, $base\n"; printf "$tfmt", "cn", "amdmap $mapname timestamp"; printf "$tfmt", "objectClass", "amdmapTimestamp"; printf "$tfmt", "amdmapName", "$mapname"; printf "$tfmt", "amdmapTimestamp", $time; printf "$tfmt", "amdmapName", $mapname; print "\n"; my $line = ""; my $done = 0; while () { chomp; if (/\s*(.+)\\\s*/) { if ($line) { $line .= " ".$1; } else { $line = $1; } $done = 0; } else { s/^\s+//g; $line .= $_; $done = 1; } if ($done) { my @vals = split(/\s+/,$line); my $key = shift @vals; my $entry; print "dn: cn=amdmap $mapname\[$key\], $base\n"; printf "$fmt","cn","amdmap $mapname\[$key\]"; printf "$fmt","objectClass", "amdmap"; printf "$fmt","amdmapName", $mapname; printf "$fmt","amdmapKey", $key; printf "$fmt","amdmapValue", join(' ',@vals); print "\n"; $line = ""; $done = 0; } } am-utils-6.2+rc20110530/scripts/amd2sun.in000077500000000000000000000017441157065440000177330ustar00rootroot00000000000000#!@PERL@ # convert amd maps to Sun automount maps # usage: amd2sun file # # Package: am-utils-6.x # Author: "Mark D. Baushke" print "# file created by amd2sun # # DO NOT EDIT THIS FILE AT ALL # It is automatically generated from the amd mount map - edit that instead # "; while (<>) { print, next if /^#/; chop; $line = $_; while ($line =~ /\\$/) { chop $line; $line2 = <>; $line2 =~ s/^\s*//; $line .= $line2; chop $line; } next unless $line =~ /^([^\s]+)\s+(.*)$/; $fs = $1; $rest=$2; if ($fs =~ /^\/defaults/) { ($defopts = $rest) =~ s/^.*[\s;]opts:=([^;\s]+)[;\s]*.*$/\1/; next; } $opts=$defopts; if ($rest =~ /opts:=([^;\s]+)[;\s]/) { $opts = $1; } $opts =~ s/,ping=[-\d]+//g; ($rhost = $rest) =~ s/^.*[\s;]rhost:=([^;\s]+)[;\s]*.*$/\1/; ($rfs = $rest) =~ s/^.*[\s;]rfs:=([^;\s]+)[;\s]*.*$/\1/; if ($rest =~ /sublink:=([^;\s]+)[;\s]/ ) { $rfs .= "/$1"; } print "$fs -$opts $rhost:$rfs\n"; } am-utils-6.2+rc20110530/scripts/automount2amd.8000066400000000000000000000077441157065440000207250ustar00rootroot00000000000000.\" .\" Copyright (c) 1997-2011 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. 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 .\" 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/scripts/automount2amd.8 .\" .TH AUTOMOUNT2AMD 8L "24 May 1993" .SH NAME automount2amd \- converts old Sun automount maps to Amd maps .SH SYNOPSIS .B automount2amd .I auto.map .SH DESCRIPTION .LP .B automount2amd is used to convert an old Sun automount maps named .I auto.map to an Amd map. This perl script will use the following /default entry .nf type:=nfs;opts:=rw,grpid,nosuid,utimeout=600 .fi If you wish to override that, define the .B $DEFAULTS environment variable, or modify the script. If you wish to generate Amd maps using the .I hostd (host domain) Amd map syntax, then define the environment variable .B $DOMAIN or modify the script. .SH EXAMPLE Say you have the Sun automount file auto.foo, with these two lines: .nf home earth:/home moon -ro,intr server:/proj/images .fi Running .nf automount2amd auto.foo > amd.foo .fi will produce the Amd map .I amd.foo with this content: .nf # generated by automount2amd on Sat Aug 14 17:59:32 US/Eastern 1999 /defaults \\ type:=nfs;opts:=rw,grpid,nosuid,utimeout=600 home \ host==earth;type:=link;fs:=/home \\ rhost:=earth;rfs:=/home moon \ -addopts:=ro,intr \\ host==server;type:=link;fs:=/proj/images \\ rhost:=server;rfs:=/proj/images .fi .SH BUGS .I automount2amd does not understand newer Sun Automount map syntax, those used by autofs. .SH "SEE ALSO" .BR conv2amd (8), amd (8). .LP ``am-utils'' .BR info (1) entry. .LP .I "Linux NFS and Automounter Administration" by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). .LP .I http://www.am-utils.org .LP .I "Amd \- The 4.4 BSD Automounter" .SH AUTHORS Original author Mike Walker . Script modified by Erez Zadok , Computer Science Department, Stony Brook University, Stony Brook, New York, USA. .P Other authors and contributors to am-utils are listed in the .B AUTHORS file distributed with am-utils. am-utils-6.2+rc20110530/scripts/automount2amd.in000077500000000000000000000043121157065440000211530ustar00rootroot00000000000000#!@PERL@ -w # # Convert Sun automount map format to amd format # # Package: am-utils-6.x # Author: Mike Walker # Erez Zadok # # This program expects maps with the format # # dir [ -options ] machine:/path [ # optional comment ] # ... # # and generates an equivalent amd map as follows: # # # generated by automountamd on Fri May 21 9:16:56 1993 # # /defaults \ # type:=nfs;opts:=rw,grpid,nosuid,utimeout=600 # # dir \ # hostd==machine.larc.nasa.gov;type:=link;fs:=/path || \ # domain==larc.nasa.gov;rhost:=machine;rfs:=/path || \ # rhost:=machine.larc.nasa.gov;rfs:=/path # ... # # You should set the DOMAIN and DEFAULT variables to your preferences. # # $Id: automount2amd.in,v 1.2 2002/01/15 18:25:25 ezk Exp $ # require "ctime.pl"; # amd domain name (doesn't have to be the DNS domain; isn't overloading great!) # Should be what you will pass to amd via the -d command-line switch, if any. $DOMAIN=''; # amd default settings; consult the docs for what you can/should do here. # Note, in particular, that if your disk mount points follow a common scheme # you can specify ``rfs:=/common/path/${key}'' and not have to insert that # line (twice) in every entry below! $DEFAULTS='type:=nfs;opts:=rw,grpid,nosuid,utimeout=600'; # print comment header and default string printf "# generated by automount2amd on %s\n", &ctime(time); printf "/defaults \\\n %s\n\n", $DEFAULTS; # loop through map while (<>) { if (m,^(\w\S*)(\s+\-\w\S*\s+|\s+)(\w[^:]*):(\/\S*)\s*(.*),) { ($dir, $options, $machine, $path, $rest) = ($1, $2, $3, $4, $5); print "#$rest\n" if ($rest =~ m/\w/); print "$dir \\\n"; if ($options =~ m/-/) { $options =~ s/\s//g; $options =~ s/^-//g; printf( " -addopts:=$options \\\n"); } if (defined($DOMAIN) && $DOMAIN ne "") { printf(" hostd==%s.%s;type:=link;fs:=%s || \\\n", $machine, $DOMAIN, $path); printf(" domain==%s;rhost:=%s;rfs:=%s || \\\n", $DOMAIN, $machine, $path); printf " rhost:=%s.%s;rfs:=%s\n\n", $machine, $DOMAIN, $path; } else { printf(" host==%s;type:=link;fs:=%s \\\n", $machine, $path); printf " rhost:=%s;rfs:=%s\n\n", $machine, $path; } } } am-utils-6.2+rc20110530/scripts/ctl-amd.in000077500000000000000000000054371157065440000177060ustar00rootroot00000000000000#!/bin/sh # control starting, stopping, or restarting amd. # usage: ctl-amd [start|stop|status|restart|condrestart|reload] # # Package: am-utils-6.x # Author: Erez Zadok # # chkconfig: - 72 28 # description: Runs the automount daemon that mounts devices and NFS hosts \ # on demand. # processname: amd # config: /etc/amd.conf # # set path prefix=@prefix@ exec_prefix=@exec_prefix@ PATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH} export PATH # kill the named process(es) killproc() { # first try to get PID via an amq RPC pid=`amq -p 2>/dev/null` if test "$pid" != "" then kill $pid return 0 fi # try bsd style ps pscmd="ps axc" pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` if test "$pid" != "" then kill $pid return 0 fi # try bsd44 style ps pscmd="ps -x" pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` if test "$pid" != "" then kill $pid return 0 fi # try svr4 style ps pscmd="ps -e" pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` if test "$pid" != "" then kill $pid return 0 fi # failed return 1 } # before running any real programs, chdir to / to avoid possible hangs on # (NFS) mounts which may be restarting. cd / # search for amd.conf file CF_FILE="@sysconfdir@/amd.conf" # any local copy of the conf file overrides the "global" one if [ -f /etc/amd.conf ] then CF_FILE="/etc/amd.conf" fi if [ -f @sysconfdir@/amd.conf ] then CF_FILE="@sysconfdir@/amd.conf" fi if [ -f /etc/local/amd.conf ] then CF_FILE="/etc/local/amd.conf" fi # if have the directory /tftpboot/.amd, then add a tag to include it CF_TAG="" if [ -d /tftpboot/.amd ] then CF_TAG="-T tftpboot" fi case "$1" in 'start') # Start the amd automounter. if [ -x @sbindir@/amd ] then # do not specify full path of amd so killproc() works amd -F $CF_FILE $CF_TAG test -x /var/lock/subsys && touch /var/lock/subsys/amd fi ;; 'stop') # prepend space to program name to ensure only amd process dies echo "killing amd..." killproc " amd" wait4amd2die rm -f /var/lock/subsys/amd ;; 'restart') # kill amd, wait for it to die, then restart ctl-amd stop if [ $? != 0 ] then echo "NOT restarting amd!" else echo "Restarting amd..." sleep 1 ctl-amd start fi ;; 'condrestart') if [ -f /var/lock/subsys/amd ]; then ctl-amd stop ctl-amd start fi ;; 'reload') amq -f ;; 'status') # run amq -v to produce status pid=`amq -p 2>/dev/null` if [ $? = 0 ] then echo "amd (pid $pid) is running..." else echo "amd is stopped" fi ;; # start_msg and stop_msg are for HPUX 'start_msg') echo "Start am-utils 6.1 automounter" ;; 'stop_msg') echo "Stop am-utils 6.1 automounter" ;; *) echo "Usage: $0 [start|stop|status|restart|condrestart|reload]" ;; esac am-utils-6.2+rc20110530/scripts/ctl-hlfsd.in000077500000000000000000000046061157065440000202420ustar00rootroot00000000000000#!/bin/sh # control starting, stopping, or restarting hlfsd. # usage: ctl-hlfsd [start | stop | restart] # # Package: am-utils-6.x # Author: Erez Zadok # # chkconfig: - 72 28 # description: hlfsd is a daemon similar to amd, used to redirect user # mail to home directory of the user # processname: hlfsd # # set path prefix=@prefix@ exec_prefix=@exec_prefix@ PATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH} export PATH # kill the named process(es) killproc() { # try bsd style ps pscmd="ps axc" pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` if test "$pid" != "" then kill $pid return 0 fi # try bsd44 style ps pscmd="ps -x" pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` if test "$pid" != "" then kill $pid return 0 fi # try svr4 style ps pscmd="ps -e" pid=`${pscmd} 2>/dev/null | grep "$1" | sed -e 's/^ *//' -e 's/ .*//'` if test "$pid" != "" then kill $pid return 0 fi # failed return 1 } # before running any real programs, chdir to / to avoid possible hangs on (NFS) # mounts. cd / # locate logs directory if [ -d /var/log ]; then logdir="/var/log" else logdir="/tmp" fi # locate the mail spool directory if [ -d /var/mail/. ]; then maildir="/var/mail" altmaildir="/var/alt_mail" elif [ -d /var/spool/mail/. ]; then maildir="/var/spool/mail" altmaildir="/var/spool/alt_mail" else maildir="/usr/spool/mail" altmaildir="/usr/spool/alt_mail" fi # locate any optional password file if [ -f @sysconfdir@/passwd ]; then PASSWD_FILE="-P @sysconfdir@/passwd" else PASSWD_FILE="" fi case "$1" in 'start') # # Start the hlfsd mail redirector service # if [ -x @sbindir@/hlfsd -a -h $maildir ] then echo @sbindir@/hlfsd ${PASSWD_FILE} -a $altmaildir -x all -l $logdir/hlfsd /mail/home .mailspool @sbindir@/hlfsd ${PASSWD_FILE} -a $altmaildir -x all -l $logdir/hlfsd /mail/home .mailspool & test -x /var/lock/subsys && touch /var/lock/subsys/hlfsd fi ;; 'stop') # prepend space to program name to ensure only amd process dies killproc " hlfsd" test -f /var/lock/subsys/hlfsd && rm -f /var/lock/subsys/hlfsd ;; 'restart') # kill hlfsd, wait for it to die, then restart echo "killing hlfsd..." ctl-hlfsd stop echo "Waiting for 10 seconds..." sleep 10 # hope that would be enough echo "Restarting hlfsd..." ctl-hlfsd start ;; *) echo "Usage: @sbindir@/ctl-hlfsd [ start | stop | restart ]" ;; esac am-utils-6.2+rc20110530/scripts/expn.1000066400000000000000000001106751157065440000170670ustar00rootroot00000000000000#!@PERL@ 'di '; 'ds 00 \\"'; 'ig 00 '; # # THIS PROGRAM IS ITS OWN MANUAL PAGE. INSTALL IN man & bin. # # hardcoded constants, should work fine for BSD-based systems #require 'sys/socket.ph'; # perl 4 use Socket; # perl 5 $AF_INET = &AF_INET; $SOCK_STREAM = &SOCK_STREAM; $sockaddr = 'S n a4 x8'; # system requirements: # must have 'nslookup' and 'hostname' programs. # $Header: /home/ezk/proj/amd/GIT/cvs/am-utils/scripts/expn.1,v 1.4 2003/07/18 15:17:37 ezk Exp $ # TODO: # less magic should apply to command-line addresses # less magic should apply to local addresses # add magic to deal with cross-domain cnames # Checklist: (hard addresses) # 250 Kimmo Suominen <"|/usr/local/mh/lib/slocal -user kim"@grendel.tac.nyc.ny.us> # harry@hofmann.cs.Berkeley.EDU -> harry@tenet (.berkeley.edu) [dead] # bks@cs.berkeley.edu -> shiva.CS (.berkeley.edu) [dead] # dan@tc.cornell.edu -> brown@tiberius (.tc.cornell.edu) ############################################################################# # # Copyright (c) 1993 David Muir Sharnoff # All rights reserved. # # 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. All advertising materials mentioning features or use of this software # must display the following acknowledgment: # This product includes software developed by the David Muir Sharnoff. # 4. The name of David Sharnoff may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE DAVID MUIR SHARNOFF ``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 DAVID MUIR SHARNOFF 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. # # This copyright notice derived from material copyrighted by the Regents # of the University of California. # # Contributions accepted. # ############################################################################# # overall structure: # in an effort to not trace each address individually, but rather # ask each server in turn a whole bunch of questions, addresses to # be expanded are queued up. # # This means that all accounting w.r.t. an address must be stored in # various arrays. Generally these arrays are indexed by the # string "$addr *** $server" where $addr is the address to be # expanded "foo" or maybe "foo@bar" and $server is the hostname # of the SMTP server to contact. # # important global variables: # # @hosts : list of servers still to be contacted # $server : name of the current we are currently looking at # @users = $users{@hosts[0]} : addresses to expand at this server # $u = $users[0] : the current address being expanded # $names{"$users[0] *** $server"} : the 'name' associated with the address # $mxbacktrace{"$users[0] *** $server"} : record of mx expansion # $mx_secondary{$server} : other mx relays at the same priority # $domainify_fallback{"$users[0] *** $server"} : alternative names to try # instead of $server if $server doesn't work # $temporary_redirect{"$users[0] *** $server"} : when trying alternates, # temporarily channel all tries along current path # $giveup{$server} : do not bother expanding addresses at $server # $verbose : -v # $watch : -w # $vw : -v or -w # $debug : -d # $valid : -a # $levels : -1 # S : the socket connection to $server $have_nslookup = 1; # we have the nslookup program $port = 'smtp'; $av0 = $0; $ENV{'PATH'} .= ":/usr/etc" unless $ENV{'PATH'} =~ m,/usr/etc,; $ENV{'PATH'} .= ":/usr/ucb" unless $ENV{'PATH'} =~ m,/usr/ucb,; select(STDERR); $0 = "$av0 - running hostname"; chop($name = `hostname || uname -n`); $0 = "$av0 - lookup host FQDN and IP addr"; ($hostname,$aliases,$type,$len,$thisaddr) = gethostbyname($name); $0 = "$av0 - parsing args"; $usage = "Usage: $av0 [-1avwd] user[\@host] [user2[host2] ...]"; for $a (@ARGV) { die $usage if $a eq "-"; while ($a =~ s/^(-.*)([1avwd])/$1/) { eval '$'."flag_$2 += 1"; } next if $a eq "-"; die $usage if $a =~ /^-/; &expn(&parse($a,$hostname,undef,1)); } $verbose = $flag_v; $watch = $flag_w; $vw = $flag_v + $flag_w; $debug = $flag_d; $valid = $flag_a; $levels = $flag_1; die $usage unless @hosts; if ($valid) { if ($valid == 1) { $validRequirement = 0.8; } elsif ($valid == 2) { $validRequirement = 1.0; } elsif ($valid == 3) { $validRequirement = 0.9; } else { $validRequirement = (1 - (1/($valid-3))); print "validRequirement = $validRequirement\n" if $debug; } } $0 = "$av0 - building local socket"; ($name,$aliases,$proto) = getprotobyname('tcp'); ($name,$aliases,$port) = getservbyname($port,'tcp') unless $port =~ /^\d+/; $this = pack($sockaddr, &AF_INET, 0, $thisaddr); HOST: while (@hosts) { $server = shift(@hosts); @users = split(' ',$users{$server}); delete $users{$server}; # is this server already known to be bad? $0 = "$av0 - looking up $server"; if ($giveup{$server}) { &giveup('mx domainify',$giveup{$server}); next; } # do we already have an mx record for this host? next HOST if &mxredirect($server,*users); # look it up, or try for an mx. $0 = "$av0 - gethostbyname($server)"; ($name,$aliases,$type,$len,$thataddr) = gethostbyname($server); # if we can't get an A record, try for an MX record. unless($thataddr) { &mxlookup(1,$server,"$server: could not resolve name",*users); next HOST; } # get a connection, or look for an mx $0 = "$av0 - socket to $server"; $that = pack($sockaddr, &AF_INET, $port, $thataddr); socket(S, &AF_INET, &SOCK_STREAM, $proto) || die "socket: $!"; $0 = "$av0 - bind to $server"; bind(S, $this) || die "bind $hostname,0: $!"; $0 = "$av0 - connect to $server"; print "debug = $debug server = $server\n" if $debug > 8; if (! connect(S, $that) || ($debug == 10 && $server =~ /relay\d.UU.NET$/i)) { $0 = "$av0 - $server: could not connect: $!\n"; $emsg = $!; unless (&mxlookup(0,$server,"$server: could not connect: $!",*users)) { &giveup('mx',"$server: Could not connect: $emsg"); } next HOST; } select((select(S),$| = 1)[0]); # don't buffer output to S # read the greeting $0 = "$av0 - talking to $server"; &alarm("greeting with $server",''); while() { alarm(0); print if $watch; if (/^(\d+)([- ])/) { if ($1 != 220) { $0 = "$av0 - bad numeric response from $server"; &alarm("giving up after bad response from $server",''); &read_response($2,$watch); alarm(0); print STDERR "$server: NOT 220 greeting: $_" if ($debug || $vw); if (&mxlookup(0,$server,"$server: did not respond with a 220 greeting",*users)) { close(S); next HOST; } } last if ($2 eq " "); } else { $0 = "$av0 - bad response from $server"; print STDERR "$server: NOT 220 greeting: $_" if ($debug || $vw); unless (&mxlookup(0,$server,"$server: did not respond with SMTP codes",*users)) { &giveup('',"$server: did not talk SMTP"); } close(S); next HOST; } &alarm("greeting with $server",''); } alarm(0); # if this causes problems, remove it $0 = "$av0 - sending helo to $server"; &alarm("sending helo to $server",""); &ps("helo $hostname"); while() { print if $watch; last if /^\d+ /; } alarm(0); # try the users, one by one USER: while(@users) { $u = shift(@users); $0 = "$av0 - expanding $u [\@$server]"; # do we already have a name for this user? $oldname = $names{"$u *** $server"}; print &compact($u,$server)." ->\n" if ($verbose && ! $valid); if ($valid) { # # when running with -a, we delay taking any action # on the results of our query until we have looked # at the complete output. @toFinal stores expansions # that will be final if we take them. @toExpn stores # expansions that are not final. @isValid keeps # track of our ability to send mail to each of the # expansions. # @isValid = (); @toFinal = (); @toExpn = (); } # ($ecode,@expansion) = &expn_vrfy($u,$server); (@foo) = &expn_vrfy($u,$server); ($ecode,@expansion) = @foo; if ($ecode) { &giveup('',$ecode,$u); last USER; } for $s (@expansion) { $s =~ s/[\n\r]//g; $0 = "$av0 - parsing $server: $s"; $skipwatch = $watch; if ($s =~ /^[25]51([- ]).*<(.+)>/) { print "$s" if $watch; print "(pretending 250$1<$2>)" if ($debug && $watch); print "\n" if $watch; $s = "250$1<$2>"; $skipwatch = 0; } if ($s =~ /^250([- ])(.+)/) { print "$s\n" if $skipwatch; ($done,$addr) = ($1,$2); ($newhost, $newaddr, $newname) = &parse($addr,$server,$oldname, $#expansion == 0); print "($newhost, $newaddr, $newname) = &parse($addr, $server, $oldname)\n" if $debug; if (! $newhost) { # no expansion is possible w/o a new server to call if ($valid) { push(@isValid, &validAddr($newaddr)); push(@toFinal,$newaddr,$server,$newname); } else { &verbose(&final($newaddr,$server,$newname)); } } else { $newmxhost = &mx($newhost,$newaddr); print "$newmxhost = &mx($newhost)\n" if ($debug && $newhost ne $newmxhost); $0 = "$av0 - parsing $newaddr [@$newmxhost]"; print "levels = $levels, level{$u *** $server} = ".$level{"$u *** $server"}."\n" if ($debug > 1); # If the new server is the current one, # it would have expanded things for us # if it could have. Mx records must be # followed to compare server names. # We are also done if the recursion # count has been exceeded. if (&trhost($newmxhost) eq &trhost($server) || ($levels && $level{"$u *** $server"} >= $levels)) { if ($valid) { push(@isValid, &validAddr($newaddr)); push(@toFinal,$newaddr,$newmxhost,$newname); } else { &verbose(&final($newaddr,$newmxhost,$newname)); } } else { # more work to do... if ($valid) { push(@isValid, &validAddr($newaddr)); push(@toExpn,$newmxhost,$newaddr,$newname,$level{"$u *** $server"}); } else { &verbose(&expn($newmxhost,$newaddr,$newname,$level{"$u *** $server"})); } } } last if ($done eq " "); next; } # 550 is a known code... Should the be # included in -a output? Might be a bug # here. Does it matter? Can assume that # there won't be UNKNOWN USER responses # mixed with valid users? if ($s =~ /^(550)([- ])/) { if ($valid) { print STDERR "\@$server:$u ($oldname) USER UNKNOWN\n"; } else { &verbose(&final($u,$server,$oldname,"USER UNKNOWN")); } last if ($2 eq " "); next; } # 553 is a known code... if ($s =~ /^(553)([- ])/) { if ($valid) { print STDERR "\@$server:$u ($oldname) USER AMBIGUOUS\n"; } else { &verbose(&final($u,$server,$oldname,"USER AMBIGUOUS")); } last if ($2 eq " "); next; } # 252 is a known code... if ($s =~ /^(252)([- ])/) { if ($valid) { print STDERR "\@$server:$u ($oldname) REFUSED TO VRFY\n"; } else { &verbose(&final($u,$server,$oldname,"REFUSED TO VRFY")); } last if ($2 eq " "); next; } &giveup('',"$server: did not grok '$s'",$u); last USER; } if ($valid) { # # now we decide if we are going to take these # expansions or roll them back. # $avgValid = &average(@isValid); print "avgValid = $avgValid\n" if $debug; if ($avgValid >= $validRequirement) { print &compact($u,$server)." ->\n" if $verbose; while (@toExpn) { &verbose(&expn(splice(@toExpn,0,4))); } while (@toFinal) { &verbose(&final(splice(@toFinal,0,3))); } } else { print "Tossing some valid to avoid invalid ".&compact($u,$server)."\n" if ($avgValid > 0.0 && ($vw || $debug)); print &compact($u,$server)." ->\n" if $verbose; &verbose(&final($u,$server,$newname)); } } } &alarm("sending 'quit' to $server",''); $0 = "$av0 - sending 'quit' to $server"; &ps("quit"); while() { print if $watch; last if /^\d+ /; } close(S); alarm(0); } $0 = "$av0 - printing final results"; print "----------\n" if $vw; select(STDOUT); for $f (sort @final) { print "$f\n"; } unlink("/tmp/expn$$"); exit(0); # abandon all attempts deliver to $server # register the current addresses as the final ones sub giveup { local($redirect_okay,$reason,$user) = @_; local($us,@so,$nh,@remaining_users); local($pk,$file,$line); ($pk, $file, $line) = caller; $0 = "$av0 - giving up on $server: $reason"; # # add back a user if we gave up in the middle # push(@users,$user) if $user; # # don't bother with this system anymore # unless ($giveup{$server}) { $giveup{$server} = $reason; print STDERR "$reason\n"; } print "Giveup at $file:$line!!! redirect okay = $redirect_okay; $reason\n" if $debug; # # Wait! # Before giving up, see if there is a chance that # there is another host to redirect to! # (Kids, don't do this at home! Hacking is a dangerous # crime and you could end up behind bars.) # for $u (@users) { if ($redirect_okay =~ /\bmx\b/) { next if &try_fallback('mx',$u,*server, *mx_secondary, *already_mx_fellback); } if ($redirect_okay =~ /\bdomainify\b/) { next if &try_fallback('domainify',$u,*server, *domainify_fallback, *already_domainify_fellback); } push(@remaining_users,$u); } @users = @remaining_users; for $u (@users) { print &compact($u,$server)." ->\n" if ($verbose && $valid && $u); &verbose(&final($u,$server,$names{"$u *** $server"},$reason)); } } # # This routine is used only within &giveup. It checks to # see if we really have to giveup or if there is a second # chance because we did something before that can be # backtracked. # # %fallback{"$user *** $host"} tracks what is able to fallback # %fellback{"$user *** $host"} tracks what has fallen back # # If there is a valid backtrack, then queue up the new possibility # sub try_fallback { local($method,$user,*host,*fall_table,*fellback) = @_; local($us,$fallhost,$oldhost,$ft,$i); if ($debug > 8) { print "Fallback table $method:\n"; for $i (sort keys %fall_table) { print "\t'$i'\t\t'$fall_table{$i}'\n"; } print "Fellback table $method:\n"; for $i (sort keys %fellback) { print "\t'$i'\t\t'$fellback{$i}'\n"; } print "U: $user H: $host\n"; } $us = "$user *** $host"; if (defined $fellback{$us}) { # # Undo a previous fallback so that we can try again # Nested fallbacks are avoided because they could # lead to infinite loops # $fallhost = $fellback{$us}; print "Already $method fell back from $us -> \n" if $debug; $us = "$user *** $fallhost"; $oldhost = $fallhost; } elsif (($method eq 'mx') && (defined $mxbacktrace{$us}) && (defined $mx_secondary{$mxbacktrace{$us}})) { print "Fallback an MX expansion $us -> \n" if $debug; $oldhost = $mxbacktrace{$us}; } else { print "Oldhost($host, $us) = " if $debug; $oldhost = $host; } print "$oldhost\n" if $debug; if (((defined $fall_table{$us}) && ($ft = $us)) || ((defined $fall_table{$oldhost}) && ($ft = $oldhost))) { print "$method Fallback = ".$fall_table{$ft}."\n" if $debug; local(@so,$newhost); @so = split(' ',$fall_table{$ft}); $newhost = shift(@so); print "Falling back ($method) $us -> $newhost (from $oldhost)\n" if $debug; if ($method eq 'mx') { if (! defined ($mxbacktrace{"$user *** $newhost"})) { if (defined $mxbacktrace{"$user *** $oldhost"}) { print "resetting oldhost $oldhost to the original: " if $debug; $oldhost = $mxbacktrace{"$user *** $oldhost"}; print "$oldhost\n" if $debug; } $mxbacktrace{"$user *** $newhost"} = $oldhost; print "mxbacktrace $user *** $newhost -> $oldhost\n" if $debug; } $mx{&trhost($oldhost)} = $newhost; } else { $temporary_redirect{$us} = $newhost; } if (@so) { print "Can still $method $us: @so\n" if $debug; $fall_table{$ft} = join(' ',@so); } else { print "No more fallbacks for $us\n" if $debug; delete $fall_table{$ft}; } if (defined $create_host_backtrack{$us}) { $create_host_backtrack{"$user *** $newhost"} = $create_host_backtrack{$us}; } $fellback{"$user *** $newhost"} = $oldhost; &expn($newhost,$user,$names{$us},$level{$us}); return 1; } delete $temporary_redirect{$us}; $host = $oldhost; return 0; } # return 1 if you could send mail to the address as is. sub validAddr { local($addr) = @_; $res = &do_validAddr($addr); print "validAddr($addr) = $res\n" if $debug; $res; } sub do_validAddr { local($addr) = @_; local($urx) = "[-A-Za-z_.0-9+]+"; # \u return 0 if ($addr =~ /^\\/); # ?@h return 1 if ($addr =~ /.\@$urx$/); # @h:? return 1 if ($addr =~ /^\@$urx\:./); # h!u return 1 if ($addr =~ /^$urx!./); # u return 1 if ($addr =~ /^$urx$/); # ? print "validAddr($addr) = ???\n" if $debug; return 0; } # Some systems use expn and vrfy interchangeably. Some only # implement one or the other. Some check expn against mailing # lists and vrfy against users. It doesn't appear to be # consistent. # # So, what do we do? We try everything! # # # Ranking of result codes: good: 250, 251/551, 252, 550, anything else # # Ranking of inputs: best: user@host.domain, okay: user # # Return value: $error_string, @responses_from_server sub expn_vrfy { local($u,$server) = @_; local(@c) = ('expn', 'vrfy'); local(@try_u) = $u; local(@ret,$code); if (($u =~ /(.+)@(.+)/) && (&trhost($2) eq &trhost($server))) { push(@try_u,$1); } TRY: for $c (@c) { for $try_u (@try_u) { &alarm("${c}'ing $try_u on $server",'',$u); &ps("$c $try_u"); alarm(0); $s = ; if ($s eq '') { return "$server: lost connection"; } if ($s !~ /^(\d+)([- ])/) { return "$server: garbled reply to '$c $try_u'"; } if ($1 == 250) { $code = 250; @ret = ("",$s); push(@ret,&read_response($2,$debug)); return (@ret); } if ($1 == 551 || $1 == 251) { $code = $1; @ret = ("",$s); push(@ret,&read_response($2,$debug)); next; } if ($1 == 252 && ($code == 0 || $code == 550)) { $code = 252; @ret = ("",$s); push(@ret,&read_response($2,$watch)); next; } if ($1 == 550 && $code == 0) { $code = 550; @ret = ("",$s); push(@ret,&read_response($2,$watch)); next; } &read_response($2,$watch); } } return "$server: expn/vrfy not implemented" unless @ret; return @ret; } # sometimes the old parse routine (now parse2) didn't # reject funky addresses. sub parse { local($oldaddr,$server,$oldname,$one_to_one) = @_; local($newhost, $newaddr, $newname, $um) = &parse2($oldaddr,$server,$oldname,$one_to_one); if ($newaddr =~ m,^["/],) { return (undef, $oldaddr, $newname) if $valid; return (undef, $um, $newname); } return ($newhost, $newaddr, $newname); } # returns ($new_smtp_server,$new_address,$new_name) # given a response from a SMTP server ($newaddr), the # current host ($server), the old "name" and a flag that # indicates if it is being called during the initial # command line parsing ($parsing_args) sub parse2 { local($newaddr,$context_host,$old_name,$parsing_args) = @_; local(@names) = $old_name; local($urx) = "[-A-Za-z_.0-9+]+"; local($unmangle); # # first, separate out the address part. # # # [NAME] # [NAME] <[(NAME)] ADDR # ADDR [(NAME)] # (NAME) ADDR # [(NAME)] # if ($newaddr =~ /^\<(.*)\>$/) { print "\n" if $debug; ($newaddr) = &trim($1); print "na = $newaddr\n" if $debug; } if ($newaddr =~ /^([^\<\>]*)\<([^\<\>]*)\>([^\<\>]*)$/) { # address has a < > pair in it. print "N:$1 N:$3\n" if $debug; ($newaddr) = &trim($2); unshift(@names, &trim($3,$1)); print "na = $newaddr\n" if $debug; } if ($newaddr =~ /^([^\(\)]*)\(([^\(\)]*)\)([^\(\)]*)$/) { # address has a ( ) pair in it. print "A:$1 (N:$2) A:$3\n" if $debug; unshift(@names,&trim($2)); local($f,$l) = (&trim($1),&trim($3)); if (($f && $l) || !($f || $l)) { # address looks like: # foo (bar) baz or (bar) # not allowed! print STDERR "Could not parse $newaddr\n" if $vw; return(undef,$newaddr,&firstname(@names)); } $newaddr = $f if $f; $newaddr = $l if $l; print "newaddr now = $newaddr\n" if $debug; } # # @foo:bar # j%k@l # a@b # b!a # a # $unmangle = $newaddr; if ($newaddr =~ /^\@($urx)\:(.+)$/) { print "(\@:)" if $debug; # this is a bit of a cheat, but it seems necessary return (&domainify($1,$context_host,$2),$2,&firstname(@names),$unmangle); } if ($newaddr =~ /^(.+)\@($urx)$/) { print "(\@)" if $debug; return (&domainify($2,$context_host,$newaddr),$newaddr,&firstname(@names),$unmangle); } if ($parsing_args) { if ($newaddr =~ /^($urx)\!(.+)$/) { return (&domainify($1,$context_host,$newaddr),$newaddr,&firstname(@names),$unmangle); } if ($newaddr =~ /^($urx)$/) { return ($context_host,$newaddr,&firstname(@names),$unmangle); } print STDERR "Could not parse $newaddr\n"; } print "(?)" if $debug; return(undef,$newaddr,&firstname(@names),$unmangle); } # return $u (@$server) unless $u includes reference to $server sub compact { local($u, $server) = @_; local($se) = $server; local($sp); $se =~ s/(\W)/\\$1/g; $sp = " (\@$server)"; if ($u !~ /$se/i) { return "$u$sp"; } return $u; } # remove empty (spaces don't count) members from an array sub trim { local(@v) = @_; local($v,@r); for $v (@v) { $v =~ s/^\s+//; $v =~ s/\s+$//; push(@r,$v) if ($v =~ /\S/); } return(@r); } # using the host part of an address, and the server name, add the # servers' domain to the address if it doesn't already have a # domain. Since this sometimes fails, save a back reference so # it can be unrolled. sub domainify { local($host,$domain_host,$u) = @_; local($domain,$newhost); # cut of trailing dots $host =~ s/\.$//; $domain_host =~ s/\.$//; if ($domain_host !~ /\./) { # # domain host isn't, keep $host whatever it is # print "domainify($host,$domain_host) = $host\n" if $debug; return $host; } # # There are several weird situations that need to be # accounted for. They have to do with domain relay hosts. # # Examples: # host server "right answer" # # shiva.cs cs.berkeley.edu shiva.cs.berkeley.edu # shiva cs.berkeley.edu shiva.cs.berekley.edu # cumulus reed.edu @reed.edu:cumulus.uucp # tiberius tc.cornell.edu tiberius.tc.cornell.edu # # The first try must always be to cut the domain part out of # the server and tack it onto the host. # # A reasonable second try is to tack the whole server part onto # the host and for each possible repeated element, eliminate # just that part. # # These extra "guesses" get put into the %domainify_fallback # array. They will be used to give addresses a second chance # in the &giveup routine # local(%fallback); local($long); $long = "$host $domain_host"; $long =~ tr/A-Z/a-z/; print "long = $long\n" if $debug; if ($long =~ s/^([^ ]+\.)([^ ]+) \2(\.[^ ]+\.[^ ]+)/$1$2$3/) { # matches shiva.cs cs.berkeley.edu and returns shiva.cs.berkeley.edu print "condensed fallback $host $domain_host -> $long\n" if $debug; $fallback{$long} = 9; } local($fh); $fh = $domain_host; while ($fh =~ /\./) { print "FALLBACK $host.$fh = 1\n" if $debug > 7; $fallback{"$host.$fh"} = 1; $fh =~ s/^[^\.]+\.//; } $fallback{"$host.$domain_host"} = 2; ($domain = $domain_host) =~ s/^[^\.]+//; $fallback{"$host$domain"} = 6 if ($domain =~ /\./); if ($host =~ /\./) { # # Host is already okay, but let's look for multiple # interpretations # print "domainify($host,$domain_host) = $host\n" if $debug; delete $fallback{$host}; $domainify_fallback{"$u *** $host"} = join(' ',sort {$fallback{$b} <=> $fallback{$a};} keys %fallback) if %fallback; return $host; } $domain = ".$domain_host" if ($domain !~ /\..*\./); $newhost = "$host$domain"; $create_host_backtrack{"$u *** $newhost"} = $domain_host; print "domainify($host,$domain_host) = $newhost\n" if $debug; delete $fallback{$newhost}; $domainify_fallback{"$u *** $newhost"} = join(' ',sort {$fallback{$b} <=> $fallback{$a};} keys %fallback) if %fallback; if ($debug) { print "fallback = "; print $domainify_fallback{"$u *** $newhost"} if defined($domainify_fallback{"$u *** $newhost"}); print "\n"; } return $newhost; } # return the first non-empty element of an array sub firstname { local(@names) = @_; local($n); while(@names) { $n = shift(@names); return $n if $n =~ /\S/; } return undef; } # queue up more addresses to expand sub expn { local($host,$addr,$name,$level) = @_; if ($host) { $host = &trhost($host); if (($debug > 3) || (defined $giveup{$host})) { unshift(@hosts,$host) unless $users{$host}; } else { push(@hosts,$host) unless $users{$host}; } $users{$host} .= " $addr"; $names{"$addr *** $host"} = $name; $level{"$addr *** $host"} = $level + 1; print "expn($host,$addr,$name)\n" if $debug; return "\t$addr\n"; } else { return &final($addr,'NONE',$name); } } # compute the numerical average value of an array sub average { local(@e) = @_; return 0 unless @e; local($e,$sum); for $e (@e) { $sum += $e; } $sum / @e; } # print to the server (also to stdout, if -w) sub ps { local($p) = @_; print ">>> $p\n" if $watch; print S "$p\n"; } # return case-adjusted name for a host (for comparison purposes) sub trhost { # treat foo.bar as an alias for Foo.BAR local($host) = @_; local($trhost) = $host; $trhost =~ tr/A-Z/a-z/; if ($trhost{$trhost}) { $host = $trhost{$trhost}; } else { $trhost{$trhost} = $host; } $trhost{$trhost}; } # re-queue users if an mx record dictates a redirect # don't allow a user to be redirected more than once sub mxredirect { local($server,*users) = @_; local($u,$nserver,@still_there); $nserver = &mx($server); if (&trhost($nserver) ne &trhost($server)) { $0 = "$av0 - mx redirect $server -> $nserver\n"; for $u (@users) { if (defined $mxbacktrace{"$u *** $nserver"}) { push(@still_there,$u); } else { $mxbacktrace{"$u *** $nserver"} = $server; print "mxbacktrace{$u *** $nserver} = $server\n" if ($debug > 1); &expn($nserver,$u,$names{"$u *** $server"}); } } @users = @still_there; if (! @users) { return $nserver; } else { return undef; } } return undef; } # follow mx records, return a hostname # also follow temporary redirections coming from &domainify and # &mxlookup sub mx { local($h,$u) = @_; for (;;) { if (defined $mx{&trhost($h)} && $h ne $mx{&trhost($h)}) { $0 = "$av0 - mx expand $h"; $h = $mx{&trhost($h)}; return $h; } if ($u) { if (defined $temporary_redirect{"$u *** $h"}) { $0 = "$av0 - internal redirect $h"; print "Temporary redirect taken $u *** $h -> " if $debug; $h = $temporary_redirect{"$u *** $h"}; print "$h\n" if $debug; next; } $htr = &trhost($h); if (defined $temporary_redirect{"$u *** $htr"}) { $0 = "$av0 - internal redirect $h"; print "temporary redirect taken $u *** $h -> " if $debug; $h = $temporary_redirect{"$u *** $htr"}; print "$h\n" if $debug; next; } } return $h; } } # look up mx records with the name server. # re-queue expansion requests if possible # optionally give up on this host. sub mxlookup { local($lastchance,$server,$giveup,*users) = @_; local(*T); local(*NSLOOKUP); local($nh, $pref,$cpref); local($o0) = $0; local($nserver); local($name,$aliases,$type,$len,$thataddr); local(%fallback); return 1 if &mxredirect($server,*users); if ((defined $mx{$server}) || (! $have_nslookup)) { return 0 unless $lastchance; &giveup('mx domainify',$giveup); return 0; } $0 = "$av0 - nslookup of $server"; open(T,">/tmp/expn$$") || die "open > /tmp/expn$$: $!\n"; print T "set querytype=MX\n"; print T "$server\n"; close(T); $cpref = 1.0E12; undef $nserver; open(NSLOOKUP,"nslookup < /tmp/expn$$ 2>&1 |") || die "open nslookup: $!"; while() { print if ($debug > 2); if (/mail exchanger = ([-A-Za-z_.0-9+]+)/) { $nh = $1; if (/preference = (\d+)/) { $pref = $1; if ($pref < $cpref) { $nserver = $nh; $cpref = $pref; } elsif ($pref) { $fallback{$pref} .= " $nh"; } } } if (/Non-existent domain/) { # # These addresses are hosed. Kaput! Dead! # However, if we created the address in the # first place then there is a chance of # salvation. # 1 while(); close(NSLOOKUP); return 0 unless $lastchance; &giveup('domainify',"$server: Non-existent domain",undef,1); return 0; } } close(NSLOOKUP); unlink("/tmp/expn$$"); unless ($nserver) { $0 = "$o0 - finished mxlookup"; return 0 unless $lastchance; &giveup('mx domainify',"$server: Could not resolve address"); return 0; } # provide fallbacks in case $nserver doesn't work out if (defined $fallback{$cpref}) { $mx_secondary{$server} = $fallback{$cpref}; } $0 = "$av0 - gethostbyname($nserver)"; ($name,$aliases,$type,$len,$thataddr) = gethostbyname($nserver); unless ($thataddr) { $0 = $o0; return 0 unless $lastchance; &giveup('mx domainify',"$nserver: could not resolve address"); return 0; } print "MX($server) = $nserver\n" if $debug; print "$server -> $nserver\n" if $vw && !$debug; $mx{&trhost($server)} = $nserver; # redeploy the users unless (&mxredirect($server,*users)) { return 0 unless $lastchance; &giveup('mx domainify',"$nserver: only one level of mx redirect allowed"); return 0; } $0 = "$o0 - finished mxlookup"; return 1; } # if mx expansion did not help to resolve an address # (ie: foo@bar became @baz:foo@bar, then undo the # expansion). # this is only used by &final sub mxunroll { local(*host,*addr) = @_; local($r) = 0; print "looking for mxbacktrace{$addr *** $host}\n" if ($debug > 1); while (defined $mxbacktrace{"$addr *** $host"}) { print "Unrolling MX expansion: \@$host:$addr -> " if ($debug || $verbose); $host = $mxbacktrace{"$addr *** $host"}; print "\@$host:$addr\n" if ($debug || $verbose); $r = 1; } return 1 if $r; $addr = "\@$host:$addr" if ($host =~ /\./); return 0; } # register a completed expansion. Make the final address as # simple as possible. sub final { local($addr,$host,$name,$error) = @_; local($he); local($hb,$hr); local($au,$ah); if ($error =~ /Non-existent domain/) { # # If we created the domain, then let's undo the # damage... # if (defined $create_host_backtrack{"$addr *** $host"}) { while (defined $create_host_backtrack{"$addr *** $host"}) { print "Un&domainifying($host) = " if $debug; $host = $create_host_backtrack{"$addr *** $host"}; print "$host\n" if $debug; } $error = "$host: could not locate"; } else { # # If we only want valid addresses, toss out # bad host names. # if ($valid) { print STDERR "\@$host:$addr ($name) Non-existent domain\n"; return ""; } } } MXUNWIND: { $0 = "$av0 - final parsing of \@$host:$addr"; ($he = $host) =~ s/(\W)/\\$1/g; if ($addr !~ /@/) { # addr does not contain any host $addr = "$addr@$host"; } elsif ($addr !~ /$he/i) { # if host part really something else, use the something # else. if ($addr =~ m/(.*)\@([^\@]+)$/) { ($au,$ah) = ($1,$2); print "au = $au ah = $ah\n" if $debug; if (defined $temporary_redirect{"$addr *** $ah"}) { $addr = "$au\@".$temporary_redirect{"$addr *** $ah"}; print "Rewrite! to $addr\n" if $debug; next MXUNWIND; } } # addr does not contain full host if ($valid) { if ($host =~ /^([^\.]+)(\..+)$/) { # host part has a . in it - foo.bar ($hb, $hr) = ($1, $2); if ($addr =~ /\@([^\.\@]+)$/ && ($1 eq $hb)) { # addr part has not . # and matches beginning of # host part -- tack on a # domain name. $addr .= $hr; } else { &mxunroll(*host,*addr) && redo MXUNWIND; } } else { &mxunroll(*host,*addr) && redo MXUNWIND; } } else { $addr = "${addr}[\@$host]" if ($host =~ /\./); } } } $name = "$name " if $name; $error = " $error" if $error; if ($valid) { push(@final,"$name<$addr>"); } else { push(@final,"$name<$addr>$error"); } "\t$name<$addr>$error\n"; } sub alarm { local($alarm_action,$alarm_redirect,$alarm_user) = @_; alarm(3600); $SIG{ALRM} = 'handle_alarm'; } # this involves one great big ugly hack. # the "next HOST" unwinds the stack! sub handle_alarm { &giveup($alarm_redirect,"Timed out during $alarm_action",$alarm_user); next HOST; } # read the rest of the current smtp daemon's response (and toss it away) sub read_response { local($done,$watch) = @_; local(@resp); print $s if $watch; while(($done eq "-") && ($s = ) && ($s =~ /^\d+([- ])/)) { print $s if $watch; $done = $1; push(@resp,$s); } return @resp; } # print args if verbose. Return them in any case sub verbose { local(@tp) = @_; print "@tp" if $verbose; } # to pass perl -w: @tp; $flag_a; $flag_d; $flag_1; %already_domainify_fellback; %already_mx_fellback; &handle_alarm; ################### BEGIN PERL/TROFF TRANSITION .00 ; 'di .nr nl 0-1 .nr % 0 .\\"'; __END__ .\" ############## END PERL/TROFF TRANSITION .TH EXPN 1 "March 11, 1993" .AT 3 .SH NAME expn \- recursively expand mail aliases .SH SYNOPSIS .B expn .RI [ -a ] .RI [ -v ] .RI [ -w ] .RI [ -d ] .RI [ -1 ] .IR user [@ hostname ] .RI [ user [@ hostname ]]... .SH DESCRIPTION .B expn will use the SMTP .B expn and .B vrfy commands to expand mail aliases. It will first look up the addresses you provide on the command line. If those expand into addresses on other systems, it will connect to the other systems and expand again. It will keep doing this until no further expansion is possible. .SH OPTIONS The default output of .B expn can contain many lines which are not valid email addresses. With the .I -aa flag, only expansions that result in legal addresses are used. Since many mailing lists have an illegal address or two, the single .IR -a , address, flag specifies that a few illegal addresses can be mixed into the results. More .I -a flags vary the ratio. Read the source to track down the formula. With the .I -a option, you should be able to construct a new mailing list out of an existing one. .LP If you wish to limit the number of levels deep that .B expn will recurse as it traces addresses, use the .I -1 option. For each .I -1 another level will be traversed. So, .I -111 will traverse no more than three levels deep. .LP The normal mode of operation for .B expn is to do all of its work silently. The following options make it more verbose. It is not necessary to make it verbose to see what it is doing because as it works, it changes its .BR argv [0] variable to reflect its current activity. To see how it is expanding things, the .IR -v , verbose, flag will cause .B expn to show each address before and after translation as it works. The .IR -w , watch, flag will cause .B expn to show you its conversations with the mail daemons. Finally, the .IR -d , debug, flag will expose many of the inner workings so that it is possible to eliminate bugs. .SH ENVIRONMENT No environment variables are used. .SH FILES .B /tmp/expn$$ .B temporary file used as input to .BR nslookup . .SH SEE ALSO .BR aliases (5), .BR sendmail (8), .BR nslookup (8), RFC 823, and RFC 1123. .SH BUGS Not all mail daemons will implement .B expn or .BR vrfy . It is not possible to verify addresses that are served by such daemons. .LP When attempting to connect to a system to verify an address, .B expn only tries one IP address. Most mail daemons will try harder. .LP It is assumed that you are running domain names and that the .BR nslookup (8) program is available. If not, .B expn will not be able to verify many addresses. It will also pause for a long time unless you change the code where it says .I $have_nslookup = 1 to read .I $have_nslookup = .IR 0 . .LP Lastly, .B expn does not handle every valid address. If you have an example, please submit a bug report. .SH CREDITS In 1986 or so, Jon Broome wrote a program of the same name that did about the same thing. It has since suffered bit rot and Jon Broome has dropped off the face of the earth! (Jon, if you are out there, drop me a line) .SH AVAILABILITY The latest version of .B expn is available through anonymous ftp at .IR ftp://ftp.idiom.com/pub/muir-programs/expn . .SH AUTHOR .I David Muir Sharnoff\ \ \ \ am-utils-6.2+rc20110530/scripts/expn.in000077500000000000000000001106221157065440000173300ustar00rootroot00000000000000#!@PERL@ 'di '; 'ds 00 \\"'; 'ig 00 '; # # THIS PROGRAM IS ITS OWN MANUAL PAGE. INSTALL IN man & bin. # # hardcoded constants, should work fine for BSD-based systems #require 'sys/socket.ph'; # perl 4 use Socket; # perl 5 $AF_INET = &AF_INET; $SOCK_STREAM = &SOCK_STREAM; # system requirements: # must have 'nslookup' and 'hostname' programs. # $Header: /home/ezk/proj/amd/GIT/cvs/am-utils/scripts/expn.in,v 1.5 2002/07/11 14:28:20 ezk Exp $ # TODO: # less magic should apply to command-line addresses # less magic should apply to local addresses # add magic to deal with cross-domain cnames # Checklist: (hard addresses) # 250 Kimmo Suominen <"|/usr/local/mh/lib/slocal -user kim"@grendel.tac.nyc.ny.us> # harry@hofmann.cs.Berkeley.EDU -> harry@tenet (.berkeley.edu) [dead] # bks@cs.berkeley.edu -> shiva.CS (.berkeley.edu) [dead] # dan@tc.cornell.edu -> brown@tiberius (.tc.cornell.edu) ############################################################################# # # Copyright (c) 1993 David Muir Sharnoff # All rights reserved. # # 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. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by the David Muir Sharnoff. # 4. The name of David Sharnoff may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE DAVID MUIR SHARNOFF ``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 DAVID MUIR SHARNOFF 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. # # This copyright notice derived from material copyrighted by the Regents # of the University of California. # # Contributions accepted. # ############################################################################# # overall structure: # in an effort to not trace each address individually, but rather # ask each server in turn a whole bunch of questions, addresses to # be expanded are queued up. # # This means that all accounting w.r.t. an address must be stored in # various arrays. Generally these arrays are indexed by the # string "$addr *** $server" where $addr is the address to be # expanded "foo" or maybe "foo@bar" and $server is the hostname # of the SMTP server to contact. # # important global variables: # # @hosts : list of servers still to be contacted # $server : name of the current we are currently looking at # @users = $users{@hosts[0]} : addresses to expand at this server # $u = $users[0] : the current address being expanded # $names{"$users[0] *** $server"} : the 'name' associated with the address # $mxbacktrace{"$users[0] *** $server"} : record of mx expansion # $mx_secondary{$server} : other mx relays at the same priority # $domainify_fallback{"$users[0] *** $server"} : alternative names to try # instead of $server if $server doesn't work # $temporary_redirect{"$users[0] *** $server"} : when trying alternates, # temporarily channel all tries along current path # $giveup{$server} : do not bother expanding addresses at $server # $verbose : -v # $watch : -w # $vw : -v or -w # $debug : -d # $valid : -a # $levels : -1 # S : the socket connection to $server $have_nslookup = 1; # we have the nslookup program $port = 'smtp'; $av0 = $0; $ENV{'PATH'} .= ":/usr/etc" unless $ENV{'PATH'} =~ m,/usr/etc,; $ENV{'PATH'} .= ":/usr/ucb" unless $ENV{'PATH'} =~ m,/usr/ucb,; select(STDERR); $0 = "$av0 - running hostname"; chop($name = `hostname || uname -n`); $0 = "$av0 - lookup host FQDN and IP addr"; ($hostname,$aliases,$type,$len,$thisaddr) = gethostbyname($name); $0 = "$av0 - parsing args"; $usage = "Usage: $av0 [-1avwd] user[\@host] [user2[\@host2] ...]"; for $a (@ARGV) { die $usage if $a eq "-"; while ($a =~ s/^(-.*)([1avwd])/$1/) { eval '$'."flag_$2 += 1"; } next if $a eq "-"; die $usage if $a =~ /^-/; &expn(&parse($a,$hostname,undef,1)); } $verbose = $flag_v; $watch = $flag_w; $vw = $flag_v + $flag_w; $debug = $flag_d; $valid = $flag_a; $levels = $flag_1; die $usage unless @hosts; if ($valid) { if ($valid == 1) { $validRequirement = 0.8; } elsif ($valid == 2) { $validRequirement = 1.0; } elsif ($valid == 3) { $validRequirement = 0.9; } else { $validRequirement = (1 - (1/($valid-3))); print "validRequirement = $validRequirement\n" if $debug; } } $0 = "$av0 - building local socket"; ($name,$aliases,$proto) = getprotobyname('tcp'); ($name,$aliases,$port) = getservbyname($port,'tcp') unless $port =~ /^\d+/; $this = sockaddr_in(0, $thisaddr); HOST: while (@hosts) { $server = shift(@hosts); @users = split(' ',$users{$server}); delete $users{$server}; # is this server already known to be bad? $0 = "$av0 - looking up $server"; if ($giveup{$server}) { &giveup('mx domainify',$giveup{$server}); next; } # do we already have an mx record for this host? next HOST if &mxredirect($server,*users); # look it up, or try for an mx. $0 = "$av0 - gethostbyname($server)"; ($name,$aliases,$type,$len,$thataddr) = gethostbyname($server); # if we can't get an A record, try for an MX record. unless($thataddr) { &mxlookup(1,$server,"$server: could not resolve name",*users); next HOST; } # get a connection, or look for an mx $0 = "$av0 - socket to $server"; $that = sockaddr_in($port, $thataddr); socket(S, &AF_INET, &SOCK_STREAM, $proto) || die "socket: $!"; $0 = "$av0 - bind to $server"; bind(S, $this) || die "bind $hostname,0: $!"; $0 = "$av0 - connect to $server"; print "debug = $debug server = $server\n" if $debug > 8; if (! connect(S, $that) || ($debug == 10 && $server =~ /relay\d.UU.NET$/i)) { $0 = "$av0 - $server: could not connect: $!\n"; $emsg = $!; unless (&mxlookup(0,$server,"$server: could not connect: $!",*users)) { &giveup('mx',"$server: Could not connect: $emsg"); } next HOST; } select((select(S),$| = 1)[0]); # don't buffer output to S # read the greeting $0 = "$av0 - talking to $server"; &alarm("greeting with $server",''); while() { alarm(0); print if $watch; if (/^(\d+)([- ])/) { if ($1 != 220) { $0 = "$av0 - bad numeric response from $server"; &alarm("giving up after bad response from $server",''); &read_response($2,$watch); alarm(0); print STDERR "$server: NOT 220 greeting: $_" if ($debug || $vw); if (&mxlookup(0,$server,"$server: did not respond with a 220 greeting",*users)) { close(S); next HOST; } } last if ($2 eq " "); } else { $0 = "$av0 - bad response from $server"; print STDERR "$server: NOT 220 greeting: $_" if ($debug || $vw); unless (&mxlookup(0,$server,"$server: did not respond with SMTP codes",*users)) { &giveup('',"$server: did not talk SMTP"); } close(S); next HOST; } &alarm("greeting with $server",''); } alarm(0); # if this causes problems, remove it $0 = "$av0 - sending helo to $server"; &alarm("sending helo to $server",""); &ps("helo $hostname"); while() { print if $watch; last if /^\d+ /; } alarm(0); # try the users, one by one USER: while(@users) { $u = shift(@users); $0 = "$av0 - expanding $u [\@$server]"; # do we already have a name for this user? $oldname = $names{"$u *** $server"}; print &compact($u,$server)." ->\n" if ($verbose && ! $valid); if ($valid) { # # when running with -a, we delay taking any action # on the results of our query until we have looked # at the complete output. @toFinal stores expansions # that will be final if we take them. @toExpn stores # expansions that are not final. @isValid keeps # track of our ability to send mail to each of the # expansions. # @isValid = (); @toFinal = (); @toExpn = (); } # ($ecode,@expansion) = &expn_vrfy($u,$server); (@foo) = &expn_vrfy($u,$server); ($ecode,@expansion) = @foo; if ($ecode) { &giveup('',$ecode,$u); last USER; } for $s (@expansion) { $s =~ s/[\n\r]//g; $0 = "$av0 - parsing $server: $s"; $skipwatch = $watch; if ($s =~ /^[25]51([- ]).*<(.+)>/) { print "$s" if $watch; print "(pretending 250$1<$2>)" if ($debug && $watch); print "\n" if $watch; $s = "250$1<$2>"; $skipwatch = 0; } if ($s =~ /^250([- ])(.+)/) { print "$s\n" if $skipwatch; ($done,$addr) = ($1,$2); ($newhost, $newaddr, $newname) = &parse($addr,$server,$oldname, $#expansion == 0); print "($newhost, $newaddr, $newname) = &parse($addr, $server, $oldname)\n" if $debug; if (! $newhost) { # no expansion is possible w/o a new server to call if ($valid) { push(@isValid, &validAddr($newaddr)); push(@toFinal,$newaddr,$server,$newname); } else { &verbose(&final($newaddr,$server,$newname)); } } else { $newmxhost = &mx($newhost,$newaddr); print "$newmxhost = &mx($newhost)\n" if ($debug && $newhost ne $newmxhost); $0 = "$av0 - parsing $newaddr [@$newmxhost]"; print "levels = $levels, level{$u *** $server} = ".$level{"$u *** $server"}."\n" if ($debug > 1); # If the new server is the current one, # it would have expanded things for us # if it could have. Mx records must be # followed to compare server names. # We are also done if the recursion # count has been exceeded. if (&trhost($newmxhost) eq &trhost($server) || ($levels && $level{"$u *** $server"} >= $levels)) { if ($valid) { push(@isValid, &validAddr($newaddr)); push(@toFinal,$newaddr,$newmxhost,$newname); } else { &verbose(&final($newaddr,$newmxhost,$newname)); } } else { # more work to do... if ($valid) { push(@isValid, &validAddr($newaddr)); push(@toExpn,$newmxhost,$newaddr,$newname,$level{"$u *** $server"}); } else { &verbose(&expn($newmxhost,$newaddr,$newname,$level{"$u *** $server"})); } } } last if ($done eq " "); next; } # 550 is a known code... Should the be # included in -a output? Might be a bug # here. Does it matter? Can assume that # there won't be UNKNOWN USER responses # mixed with valid users? if ($s =~ /^(550)([- ])/) { if ($valid) { print STDERR "\@$server:$u ($oldname) USER UNKNOWN\n"; } else { &verbose(&final($u,$server,$oldname,"USER UNKNOWN")); } last if ($2 eq " "); next; } # 553 is a known code... if ($s =~ /^(553)([- ])/) { if ($valid) { print STDERR "\@$server:$u ($oldname) USER AMBIGUOUS\n"; } else { &verbose(&final($u,$server,$oldname,"USER AMBIGUOUS")); } last if ($2 eq " "); next; } # 252 is a known code... if ($s =~ /^(252)([- ])/) { if ($valid) { print STDERR "\@$server:$u ($oldname) REFUSED TO VRFY\n"; } else { &verbose(&final($u,$server,$oldname,"REFUSED TO VRFY")); } last if ($2 eq " "); next; } &giveup('',"$server: did not grok '$s'",$u); last USER; } if ($valid) { # # now we decide if we are going to take these # expansions or roll them back. # $avgValid = &average(@isValid); print "avgValid = $avgValid\n" if $debug; if ($avgValid >= $validRequirement) { print &compact($u,$server)." ->\n" if $verbose; while (@toExpn) { &verbose(&expn(splice(@toExpn,0,4))); } while (@toFinal) { &verbose(&final(splice(@toFinal,0,3))); } } else { print "Tossing some valid to avoid invalid ".&compact($u,$server)."\n" if ($avgValid > 0.0 && ($vw || $debug)); print &compact($u,$server)." ->\n" if $verbose; &verbose(&final($u,$server,$newname)); } } } &alarm("sending 'quit' to $server",''); $0 = "$av0 - sending 'quit' to $server"; &ps("quit"); while() { print if $watch; last if /^\d+ /; } close(S); alarm(0); } $0 = "$av0 - printing final results"; print "----------\n" if $vw; select(STDOUT); for $f (sort @final) { print "$f\n"; } unlink("/tmp/expn$$"); exit(0); # abandon all attempts deliver to $server # register the current addresses as the final ones sub giveup { local($redirect_okay,$reason,$user) = @_; local($us,@so,$nh,@remaining_users); local($pk,$file,$line); ($pk, $file, $line) = caller; $0 = "$av0 - giving up on $server: $reason"; # # add back a user if we gave up in the middle # push(@users,$user) if $user; # # don't bother with this system anymore # unless ($giveup{$server}) { $giveup{$server} = $reason; print STDERR "$reason\n"; } print "Giveup at $file:$line!!! redirect okay = $redirect_okay; $reason\n" if $debug; # # Wait! # Before giving up, see if there is a chance that # there is another host to redirect to! # (Kids, don't do this at home! Hacking is a dangerous # crime and you could end up behind bars.) # for $u (@users) { if ($redirect_okay =~ /\bmx\b/) { next if &try_fallback('mx',$u,*server, *mx_secondary, *already_mx_fellback); } if ($redirect_okay =~ /\bdomainify\b/) { next if &try_fallback('domainify',$u,*server, *domainify_fallback, *already_domainify_fellback); } push(@remaining_users,$u); } @users = @remaining_users; for $u (@users) { print &compact($u,$server)." ->\n" if ($verbose && $valid && $u); &verbose(&final($u,$server,$names{"$u *** $server"},$reason)); } } # # This routine is used only within &giveup. It checks to # see if we really have to giveup or if there is a second # chance because we did something before that can be # backtracked. # # %fallback{"$user *** $host"} tracks what is able to fallback # %fellback{"$user *** $host"} tracks what has fallen back # # If there is a valid backtrack, then queue up the new possibility # sub try_fallback { local($method,$user,*host,*fall_table,*fellback) = @_; local($us,$fallhost,$oldhost,$ft,$i); if ($debug > 8) { print "Fallback table $method:\n"; for $i (sort keys %fall_table) { print "\t'$i'\t\t'$fall_table{$i}'\n"; } print "Fellback table $method:\n"; for $i (sort keys %fellback) { print "\t'$i'\t\t'$fellback{$i}'\n"; } print "U: $user H: $host\n"; } $us = "$user *** $host"; if (defined $fellback{$us}) { # # Undo a previous fallback so that we can try again # Nested fallbacks are avoided because they could # lead to infinite loops # $fallhost = $fellback{$us}; print "Already $method fell back from $us -> \n" if $debug; $us = "$user *** $fallhost"; $oldhost = $fallhost; } elsif (($method eq 'mx') && (defined $mxbacktrace{$us}) && (defined $mx_secondary{$mxbacktrace{$us}})) { print "Fallback an MX expansion $us -> \n" if $debug; $oldhost = $mxbacktrace{$us}; } else { print "Oldhost($host, $us) = " if $debug; $oldhost = $host; } print "$oldhost\n" if $debug; if (((defined $fall_table{$us}) && ($ft = $us)) || ((defined $fall_table{$oldhost}) && ($ft = $oldhost))) { print "$method Fallback = ".$fall_table{$ft}."\n" if $debug; local(@so,$newhost); @so = split(' ',$fall_table{$ft}); $newhost = shift(@so); print "Falling back ($method) $us -> $newhost (from $oldhost)\n" if $debug; if ($method eq 'mx') { if (! defined ($mxbacktrace{"$user *** $newhost"})) { if (defined $mxbacktrace{"$user *** $oldhost"}) { print "resetting oldhost $oldhost to the original: " if $debug; $oldhost = $mxbacktrace{"$user *** $oldhost"}; print "$oldhost\n" if $debug; } $mxbacktrace{"$user *** $newhost"} = $oldhost; print "mxbacktrace $user *** $newhost -> $oldhost\n" if $debug; } $mx{&trhost($oldhost)} = $newhost; } else { $temporary_redirect{$us} = $newhost; } if (@so) { print "Can still $method $us: @so\n" if $debug; $fall_table{$ft} = join(' ',@so); } else { print "No more fallbacks for $us\n" if $debug; delete $fall_table{$ft}; } if (defined $create_host_backtrack{$us}) { $create_host_backtrack{"$user *** $newhost"} = $create_host_backtrack{$us}; } $fellback{"$user *** $newhost"} = $oldhost; &expn($newhost,$user,$names{$us},$level{$us}); return 1; } delete $temporary_redirect{$us}; $host = $oldhost; return 0; } # return 1 if you could send mail to the address as is. sub validAddr { local($addr) = @_; $res = &do_validAddr($addr); print "validAddr($addr) = $res\n" if $debug; $res; } sub do_validAddr { local($addr) = @_; local($urx) = "[-A-Za-z_.0-9+]+"; # \u return 0 if ($addr =~ /^\\/); # ?@h return 1 if ($addr =~ /.\@$urx$/); # @h:? return 1 if ($addr =~ /^\@$urx\:./); # h!u return 1 if ($addr =~ /^$urx!./); # u return 1 if ($addr =~ /^$urx$/); # ? print "validAddr($addr) = ???\n" if $debug; return 0; } # Some systems use expn and vrfy interchangeably. Some only # implement one or the other. Some check expn against mailing # lists and vrfy against users. It doesn't appear to be # consistent. # # So, what do we do? We try everything! # # # Ranking of result codes: good: 250, 251/551, 252, 550, anything else # # Ranking of inputs: best: user@host.domain, okay: user # # Return value: $error_string, @responses_from_server sub expn_vrfy { local($u,$server) = @_; local(@c) = ('expn', 'vrfy'); local(@try_u) = $u; local(@ret,$code); if (($u =~ /(.+)@(.+)/) && (&trhost($2) eq &trhost($server))) { push(@try_u,$1); } TRY: for $c (@c) { for $try_u (@try_u) { &alarm("${c}'ing $try_u on $server",'',$u); &ps("$c $try_u"); alarm(0); $s = ; if ($s eq '') { return "$server: lost connection"; } if ($s !~ /^(\d+)([- ])/) { return "$server: garbled reply to '$c $try_u'"; } if ($1 == 250) { $code = 250; @ret = ("",$s); push(@ret,&read_response($2,$debug)); return (@ret); } if ($1 == 551 || $1 == 251) { $code = $1; @ret = ("",$s); push(@ret,&read_response($2,$debug)); next; } if ($1 == 252 && ($code == 0 || $code == 550)) { $code = 252; @ret = ("",$s); push(@ret,&read_response($2,$watch)); next; } if ($1 == 550 && $code == 0) { $code = 550; @ret = ("",$s); push(@ret,&read_response($2,$watch)); next; } &read_response($2,$watch); } } return "$server: expn/vrfy not implemented" unless @ret; return @ret; } # sometimes the old parse routine (now parse2) didn't # reject funky addresses. sub parse { local($oldaddr,$server,$oldname,$one_to_one) = @_; local($newhost, $newaddr, $newname, $um) = &parse2($oldaddr,$server,$oldname,$one_to_one); if ($newaddr =~ m,^["/],) { return (undef, $oldaddr, $newname) if $valid; return (undef, $um, $newname); } return ($newhost, $newaddr, $newname); } # returns ($new_smtp_server,$new_address,$new_name) # given a response from a SMTP server ($newaddr), the # current host ($server), the old "name" and a flag that # indicates if it is being called during the initial # command line parsing ($parsing_args) sub parse2 { local($newaddr,$context_host,$old_name,$parsing_args) = @_; local(@names) = $old_name; local($urx) = "[-A-Za-z_.0-9+]+"; local($unmangle); # # first, separate out the address part. # # # [NAME] # [NAME] <[(NAME)] ADDR # ADDR [(NAME)] # (NAME) ADDR # [(NAME)] # if ($newaddr =~ /^\<(.*)\>$/) { print "\n" if $debug; ($newaddr) = &trim($1); print "na = $newaddr\n" if $debug; } if ($newaddr =~ /^([^\<\>]*)\<([^\<\>]*)\>([^\<\>]*)$/) { # address has a < > pair in it. print "N:$1 N:$3\n" if $debug; ($newaddr) = &trim($2); unshift(@names, &trim($3,$1)); print "na = $newaddr\n" if $debug; } if ($newaddr =~ /^([^\(\)]*)\(([^\(\)]*)\)([^\(\)]*)$/) { # address has a ( ) pair in it. print "A:$1 (N:$2) A:$3\n" if $debug; unshift(@names,&trim($2)); local($f,$l) = (&trim($1),&trim($3)); if (($f && $l) || !($f || $l)) { # address looks like: # foo (bar) baz or (bar) # not allowed! print STDERR "Could not parse $newaddr\n" if $vw; return(undef,$newaddr,&firstname(@names)); } $newaddr = $f if $f; $newaddr = $l if $l; print "newaddr now = $newaddr\n" if $debug; } # # @foo:bar # j%k@l # a@b # b!a # a # $unmangle = $newaddr; if ($newaddr =~ /^\@($urx)\:(.+)$/) { print "(\@:)" if $debug; # this is a bit of a cheat, but it seems necessary return (&domainify($1,$context_host,$2),$2,&firstname(@names),$unmangle); } if ($newaddr =~ /^(.+)\@($urx)$/) { print "(\@)" if $debug; return (&domainify($2,$context_host,$newaddr),$newaddr,&firstname(@names),$unmangle); } if ($parsing_args) { if ($newaddr =~ /^($urx)\!(.+)$/) { return (&domainify($1,$context_host,$newaddr),$newaddr,&firstname(@names),$unmangle); } if ($newaddr =~ /^($urx)$/) { return ($context_host,$newaddr,&firstname(@names),$unmangle); } print STDERR "Could not parse $newaddr\n"; } print "(?)" if $debug; return(undef,$newaddr,&firstname(@names),$unmangle); } # return $u (@$server) unless $u includes reference to $server sub compact { local($u, $server) = @_; local($se) = $server; local($sp); $se =~ s/(\W)/\\$1/g; $sp = " (\@$server)"; if ($u !~ /$se/i) { return "$u$sp"; } return $u; } # remove empty (spaces don't count) members from an array sub trim { local(@v) = @_; local($v,@r); for $v (@v) { $v =~ s/^\s+//; $v =~ s/\s+$//; push(@r,$v) if ($v =~ /\S/); } return(@r); } # using the host part of an address, and the server name, add the # servers' domain to the address if it doesn't already have a # domain. Since this sometimes fails, save a back reference so # it can be unrolled. sub domainify { local($host,$domain_host,$u) = @_; local($domain,$newhost); # cut of trailing dots $host =~ s/\.$//; $domain_host =~ s/\.$//; if ($domain_host !~ /\./) { # # domain host isn't, keep $host whatever it is # print "domainify($host,$domain_host) = $host\n" if $debug; return $host; } # # There are several weird situations that need to be # accounted for. They have to do with domain relay hosts. # # Examples: # host server "right answer" # # shiva.cs cs.berkeley.edu shiva.cs.berkeley.edu # shiva cs.berkeley.edu shiva.cs.berekley.edu # cumulus reed.edu @reed.edu:cumulus.uucp # tiberius tc.cornell.edu tiberius.tc.cornell.edu # # The first try must always be to cut the domain part out of # the server and tack it onto the host. # # A reasonable second try is to tack the whole server part onto # the host and for each possible repeated element, eliminate # just that part. # # These extra "guesses" get put into the %domainify_fallback # array. They will be used to give addresses a second chance # in the &giveup routine # local(%fallback); local($long); $long = "$host $domain_host"; $long =~ tr/A-Z/a-z/; print "long = $long\n" if $debug; if ($long =~ s/^([^ ]+\.)([^ ]+) \2(\.[^ ]+\.[^ ]+)/$1$2$3/) { # matches shiva.cs cs.berkeley.edu and returns shiva.cs.berkeley.edu print "condensed fallback $host $domain_host -> $long\n" if $debug; $fallback{$long} = 9; } local($fh); $fh = $domain_host; while ($fh =~ /\./) { print "FALLBACK $host.$fh = 1\n" if $debug > 7; $fallback{"$host.$fh"} = 1; $fh =~ s/^[^\.]+\.//; } $fallback{"$host.$domain_host"} = 2; ($domain = $domain_host) =~ s/^[^\.]+//; $fallback{"$host$domain"} = 6 if ($domain =~ /\./); if ($host =~ /\./) { # # Host is already okay, but let's look for multiple # interpretations # print "domainify($host,$domain_host) = $host\n" if $debug; delete $fallback{$host}; $domainify_fallback{"$u *** $host"} = join(' ',sort {$fallback{$b} <=> $fallback{$a};} keys %fallback) if %fallback; return $host; } $domain = ".$domain_host" if ($domain !~ /\..*\./); $newhost = "$host$domain"; $create_host_backtrack{"$u *** $newhost"} = $domain_host; print "domainify($host,$domain_host) = $newhost\n" if $debug; delete $fallback{$newhost}; $domainify_fallback{"$u *** $newhost"} = join(' ',sort {$fallback{$b} <=> $fallback{$a};} keys %fallback) if %fallback; if ($debug) { print "fallback = "; print $domainify_fallback{"$u *** $newhost"} if defined($domainify_fallback{"$u *** $newhost"}); print "\n"; } return $newhost; } # return the first non-empty element of an array sub firstname { local(@names) = @_; local($n); while(@names) { $n = shift(@names); return $n if $n =~ /\S/; } return undef; } # queue up more addresses to expand sub expn { local($host,$addr,$name,$level) = @_; if ($host) { $host = &trhost($host); if (($debug > 3) || (defined $giveup{$host})) { unshift(@hosts,$host) unless $users{$host}; } else { push(@hosts,$host) unless $users{$host}; } $users{$host} .= " $addr"; $names{"$addr *** $host"} = $name; $level{"$addr *** $host"} = $level + 1; print "expn($host,$addr,$name)\n" if $debug; return "\t$addr\n"; } else { return &final($addr,'NONE',$name); } } # compute the numerical average value of an array sub average { local(@e) = @_; return 0 unless @e; local($e,$sum); for $e (@e) { $sum += $e; } $sum / @e; } # print to the server (also to stdout, if -w) sub ps { local($p) = @_; print ">>> $p\n" if $watch; print S "$p\n"; } # return case-adjusted name for a host (for comparison purposes) sub trhost { # treat foo.bar as an alias for Foo.BAR local($host) = @_; local($trhost) = $host; $trhost =~ tr/A-Z/a-z/; if ($trhost{$trhost}) { $host = $trhost{$trhost}; } else { $trhost{$trhost} = $host; } $trhost{$trhost}; } # re-queue users if an mx record dictates a redirect # don't allow a user to be redirected more than once sub mxredirect { local($server,*users) = @_; local($u,$nserver,@still_there); $nserver = &mx($server); if (&trhost($nserver) ne &trhost($server)) { $0 = "$av0 - mx redirect $server -> $nserver\n"; for $u (@users) { if (defined $mxbacktrace{"$u *** $nserver"}) { push(@still_there,$u); } else { $mxbacktrace{"$u *** $nserver"} = $server; print "mxbacktrace{$u *** $nserver} = $server\n" if ($debug > 1); &expn($nserver,$u,$names{"$u *** $server"}); } } @users = @still_there; if (! @users) { return $nserver; } else { return undef; } } return undef; } # follow mx records, return a hostname # also follow temporary redirections coming from &domainify and # &mxlookup sub mx { local($h,$u) = @_; for (;;) { if (defined $mx{&trhost($h)} && $h ne $mx{&trhost($h)}) { $0 = "$av0 - mx expand $h"; $h = $mx{&trhost($h)}; return $h; } if ($u) { if (defined $temporary_redirect{"$u *** $h"}) { $0 = "$av0 - internal redirect $h"; print "Temporary redirect taken $u *** $h -> " if $debug; $h = $temporary_redirect{"$u *** $h"}; print "$h\n" if $debug; next; } $htr = &trhost($h); if (defined $temporary_redirect{"$u *** $htr"}) { $0 = "$av0 - internal redirect $h"; print "temporary redirect taken $u *** $h -> " if $debug; $h = $temporary_redirect{"$u *** $htr"}; print "$h\n" if $debug; next; } } return $h; } } # look up mx records with the name server. # re-queue expansion requests if possible # optionally give up on this host. sub mxlookup { local($lastchance,$server,$giveup,*users) = @_; local(*T); local(*NSLOOKUP); local($nh, $pref,$cpref); local($o0) = $0; local($nserver); local($name,$aliases,$type,$len,$thataddr); local(%fallback); return 1 if &mxredirect($server,*users); if ((defined $mx{$server}) || (! $have_nslookup)) { return 0 unless $lastchance; &giveup('mx domainify',$giveup); return 0; } $0 = "$av0 - nslookup of $server"; open(T,">/tmp/expn$$") || die "open > /tmp/expn$$: $!\n"; print T "set querytype=MX\n"; print T "$server\n"; close(T); $cpref = 1.0E12; undef $nserver; open(NSLOOKUP,"nslookup < /tmp/expn$$ 2>&1 |") || die "open nslookup: $!"; while() { print if ($debug > 2); if (/mail exchanger = ([-A-Za-z_.0-9+]+)/) { $nh = $1; if (/preference = (\d+)/) { $pref = $1; if ($pref < $cpref) { $nserver = $nh; $cpref = $pref; } elsif ($pref) { $fallback{$pref} .= " $nh"; } } } if (/Non-existent domain/) { # # These addresses are hosed. Kaput! Dead! # However, if we created the address in the # first place then there is a chance of # salvation. # 1 while(); close(NSLOOKUP); return 0 unless $lastchance; &giveup('domainify',"$server: Non-existent domain",undef,1); return 0; } } close(NSLOOKUP); unlink("/tmp/expn$$"); unless ($nserver) { $0 = "$o0 - finished mxlookup"; return 0 unless $lastchance; &giveup('mx domainify',"$server: Could not resolve address"); return 0; } # provide fallbacks in case $nserver doesn't work out if (defined $fallback{$cpref}) { $mx_secondary{$server} = $fallback{$cpref}; } $0 = "$av0 - gethostbyname($nserver)"; ($name,$aliases,$type,$len,$thataddr) = gethostbyname($nserver); unless ($thataddr) { $0 = $o0; return 0 unless $lastchance; &giveup('mx domainify',"$nserver: could not resolve address"); return 0; } print "MX($server) = $nserver\n" if $debug; print "$server -> $nserver\n" if $vw && !$debug; $mx{&trhost($server)} = $nserver; # redeploy the users unless (&mxredirect($server,*users)) { return 0 unless $lastchance; &giveup('mx domainify',"$nserver: only one level of mx redirect allowed"); return 0; } $0 = "$o0 - finished mxlookup"; return 1; } # if mx expansion did not help to resolve an address # (ie: foo@bar became @baz:foo@bar, then undo the # expansion). # this is only used by &final sub mxunroll { local(*host,*addr) = @_; local($r) = 0; print "looking for mxbacktrace{$addr *** $host}\n" if ($debug > 1); while (defined $mxbacktrace{"$addr *** $host"}) { print "Unrolling MX expansion: \@$host:$addr -> " if ($debug || $verbose); $host = $mxbacktrace{"$addr *** $host"}; print "\@$host:$addr\n" if ($debug || $verbose); $r = 1; } return 1 if $r; $addr = "\@$host:$addr" if ($host =~ /\./); return 0; } # register a completed expansion. Make the final address as # simple as possible. sub final { local($addr,$host,$name,$error) = @_; local($he); local($hb,$hr); local($au,$ah); if ($error =~ /Non-existent domain/) { # # If we created the domain, then let's undo the # damage... # if (defined $create_host_backtrack{"$addr *** $host"}) { while (defined $create_host_backtrack{"$addr *** $host"}) { print "Un&domainifying($host) = " if $debug; $host = $create_host_backtrack{"$addr *** $host"}; print "$host\n" if $debug; } $error = "$host: could not locate"; } else { # # If we only want valid addresses, toss out # bad host names. # if ($valid) { print STDERR "\@$host:$addr ($name) Non-existent domain\n"; return ""; } } } MXUNWIND: { $0 = "$av0 - final parsing of \@$host:$addr"; ($he = $host) =~ s/(\W)/\\$1/g; if ($addr !~ /@/) { # addr does not contain any host $addr = "$addr@$host"; } elsif ($addr !~ /$he/i) { # if host part really something else, use the something # else. if ($addr =~ m/(.*)\@([^\@]+)$/) { ($au,$ah) = ($1,$2); print "au = $au ah = $ah\n" if $debug; if (defined $temporary_redirect{"$addr *** $ah"}) { $addr = "$au\@".$temporary_redirect{"$addr *** $ah"}; print "Rewrite! to $addr\n" if $debug; next MXUNWIND; } } # addr does not contain full host if ($valid) { if ($host =~ /^([^\.]+)(\..+)$/) { # host part has a . in it - foo.bar ($hb, $hr) = ($1, $2); if ($addr =~ /\@([^\.\@]+)$/ && ($1 eq $hb)) { # addr part has not . # and matches beginning of # host part -- tack on a # domain name. $addr .= $hr; } else { &mxunroll(*host,*addr) && redo MXUNWIND; } } else { &mxunroll(*host,*addr) && redo MXUNWIND; } } else { $addr = "${addr}[\@$host]" if ($host =~ /\./); } } } $name = "$name " if $name; $error = " $error" if $error; if ($valid) { push(@final,"$name<$addr>"); } else { push(@final,"$name<$addr>$error"); } "\t$name<$addr>$error\n"; } sub alarm { local($alarm_action,$alarm_redirect,$alarm_user) = @_; alarm(3600); $SIG{ALRM} = 'handle_alarm'; } # this involves one great big ugly hack. # the "next HOST" unwinds the stack! sub handle_alarm { &giveup($alarm_redirect,"Timed out during $alarm_action",$alarm_user); next HOST; } # read the rest of the current smtp daemon's response (and toss it away) sub read_response { local($done,$watch) = @_; local(@resp); print $s if $watch; while(($done eq "-") && ($s = ) && ($s =~ /^\d+([- ])/)) { print $s if $watch; $done = $1; push(@resp,$s); } return @resp; } # print args if verbose. Return them in any case sub verbose { local(@tp) = @_; print "@tp" if $verbose; } # to pass perl -w: @tp; $flag_a; $flag_d; $flag_1; %already_domainify_fellback; %already_mx_fellback; &handle_alarm; ################### BEGIN PERL/TROFF TRANSITION .00 ; 'di .nr nl 0-1 .nr % 0 .\\"'; __END__ .\" ############## END PERL/TROFF TRANSITION .TH EXPN 1 "March 11, 1993" .AT 3 .SH NAME expn \- recursively expand mail aliases .SH SYNOPSIS .B expn .RI [ -a ] .RI [ -v ] .RI [ -w ] .RI [ -d ] .RI [ -1 ] .IR user [@ hostname ] .RI [ user [@ hostname ]]... .SH DESCRIPTION .B expn will use the SMTP .B expn and .B vrfy commands to expand mail aliases. It will first look up the addresses you provide on the command line. If those expand into addresses on other systems, it will connect to the other systems and expand again. It will keep doing this until no further expansion is possible. .SH OPTIONS The default output of .B expn can contain many lines which are not valid email addresses. With the .I -aa flag, only expansions that result in legal addresses are used. Since many mailing lists have an illegal address or two, the single .IR -a , address, flag specifies that a few illegal addresses can be mixed into the results. More .I -a flags vary the ratio. Read the source to track down the formula. With the .I -a option, you should be able to construct a new mailing list out of an existing one. .LP If you wish to limit the number of levels deep that .B expn will recurse as it traces addresses, use the .I -1 option. For each .I -1 another level will be traversed. So, .I -111 will traverse no more than three levels deep. .LP The normal mode of operation for .B expn is to do all of its work silently. The following options make it more verbose. It is not necessary to make it verbose to see what it is doing because as it works, it changes its .BR argv [0] variable to reflect its current activity. To see how it is expanding things, the .IR -v , verbose, flag will cause .B expn to show each address before and after translation as it works. The .IR -w , watch, flag will cause .B expn to show you its conversations with the mail daemons. Finally, the .IR -d , debug, flag will expose many of the inner workings so that it is possible to eliminate bugs. .SH ENVIRONMENT No environment variables are used. .SH FILES .PD 0 .B /tmp/expn$$ .B temporary file used as input to .BR nslookup . .SH SEE ALSO .BR aliases (5), .BR sendmail (8), .BR nslookup (8), RFC 823, and RFC 1123. .SH BUGS Not all mail daemons will implement .B expn or .BR vrfy . It is not possible to verify addresses that are served by such daemons. .LP When attempting to connect to a system to verify an address, .B expn only tries one IP address. Most mail daemons will try harder. .LP It is assumed that you are running domain names and that the .BR nslookup (8) program is available. If not, .B expn will not be able to verify many addresses. It will also pause for a long time unless you change the code where it says .I $have_nslookup = 1 to read .I $have_nslookup = .IR 0 . .LP Lastly, .B expn does not handle every valid address. If you have an example, please submit a bug report. .SH CREDITS In 1986 or so, Jon Broome wrote a program of the same name that did about the same thing. It has since suffered bit rot and Jon Broome has dropped off the face of the earth! (Jon, if you are out there, drop me a line) .SH AVAILABILITY The latest version of .B expn is available through anonymous ftp at .IR ftp://ftp.idiom.com/pub/muir-programs/expn . .SH AUTHOR .I David Muir Sharnoff\ \ \ \ am-utils-6.2+rc20110530/scripts/fix-amd-map.in000077500000000000000000000027521157065440000204620ustar00rootroot00000000000000#!@PERL@ # # fix an old-syntax amd map to new one # # takes any number of files on the command line, and produces # a fixed map on stdout. # # Package: am-utils-6.x # Author: Erez Zadok # ############################################################################## ### MAINTAINER EDITABLE SECTION # Mappings of old names to new ones: # Update when needed, do not forget commas but not on the last entry! # For your convenience, this is the complete list of all OSs that were # supported by amd-upl102, in their old names: # # 386bsd acis43 aix3 aoi aux bsd43 bsd44 bsdi11 # concentrix dgux fpx4 freebsd hcx hlh42 hpux irix3 irix4 irix5 isc3 # linux mach2 mach3 netbsd news4 next osf1 pyrOSx riscix riscos # rtu6 sos3 sos4 sos5 stellix svr4 u2_2 u3_0 u4_0 u4_2 u4_3 u4_4 # umax43 utek utx32 xinu43 # %mappings = ( "sos4", "sunos4", "sos5", "sunos5", "freebsd", "freebsd2" ); ############################################################################## ### DO NOT EDIT ANYTHING BELOW # This is a trivial parser and works as follows: # (1) read each line # (2) search of regexps that start with '=', continue with a word to replace # and end with a non-value name (whitespace, ';', or newline while (<>) { # skip trivial lines if ($_ =~ /^$/ || $_ =~ /^#/) { print; next; } # modify the line if needed foreach $m (keys %mappings) { $val = $mappings{$m}; $_ =~ s/=$m([^a-zA-Z0-9_])/=$val$1/g; } # print the (possibly) modified line print; } am-utils-6.2+rc20110530/scripts/fixrmtab.in000077500000000000000000000006241157065440000201720ustar00rootroot00000000000000#!/bin/sh # # Invalidate /etc/rmtab entries for hosts named. # Restart mountd for changes to take effect. # # usage: fixrmtab host1 host2 ... # # Package: am-utils-6.x # Author: Andreas Stolcke #set -x RMTAB=/etc/rmtab TMP=/tmp/rmtab.$$ if [ ! -f /etc/rmtab ]; then exit 0 fi for host in $* do sed -e '/^'$host':/s/^./#/' $RMTAB > $TMP && cp $TMP $RMTAB done rm -f $TMP am-utils-6.2+rc20110530/scripts/lostaltmail.conf-sample000066400000000000000000000056761157065440000225120ustar00rootroot00000000000000# -*- perl -*- ############################################################################## # # # CONFIGURABLE VALUES # # # ############################################################################## $MAILGRUNT="postmaster"; # To whom to send log mail if mail is prefered. $TMPDIR="/tmp/"; # Place lostmail can do its dirty work. $LOCAL_LOCK_EXT=".lock"; # Name of file local mailer uses to lock # spool file. This the correct setting for # /bin/mail $SYSTEM_FROM_ADDRESS="Mailer-Daemon"; $MAILDIR="/var/alt_mail"; # What directory should I run out of. $MAILER='/usr/lib/sendmail -t'; # Which mailer should I use. $LOCALMAILJUNK='.*~|\#.*|core'; # Files name patterns that might appear in # alt_mail and should be ignored. This REGEXP # gets or'ed with $MAILJUNK below. $SMTPHOST='localhost'; # The name of a local host which speaks SMTP # and knows *all* your aliases. You probably # don't want to change this. If the machine # running lost_alt mail doesn't run an SMTP, # daemon then something is either wrong or you # should be setting `noverify' to prevent # SMTP verification. $HOSTNAME='localhost'; # Hostname to use for SMTP HELO # Subject of lost log mail message. Must define $MAILGRUNT. # I overwrite this variable in the subroutine Clean_up. Please make sure I # haven't noodle-headdly forgotten to remove that hack in the distribution! # No newline here please. The script will insert it for you. $LOG_SUBJECT="Log of lostmail resends"; ############################################################################## # # # DEFAULTED CONFIGURATIONS # # # ############################################################################## $LOGFILE="$TMPDIR" . "lostlog"; # MAILJUNK is a pattern of ignorable alt_mail files which are either common # to most platforms or actually produced by this script. You should customize # this REGEXP by hacking at $LOCALMAILJUNK above. $MAILJUNK='[a-z]\.[0-9]*|\.\.?|lost\+found'; $LOCKEXT=".lostlock"; # our lock file extension. Should not need to # modify $MESSAGE_DELIM="^From[^:]"; # /bin/mail message delimiter. Your milage # may differ $HEADER_BODY_DELIM="\n"; # RFC 822 header-body delimiter. $RESENT_TO="Resent-To: "; # $RESENT_FROM="Resent-From: "; # Resent headers (RFC 822). $RESENT_DATE="Resent-Date: "; # You probably don't want to muck with these. $RESENT_INFO="X-Resent-Info: "; # (special one to alert folks about mail). ############################################################################## # # # LOSTMAIL DEFINITIONS (DON'T TOUCH) # # # ############################################################################## $FALSE=0; $TRUE=(! $FALSE); $OK=$TRUE; $ABORT_RESEND=2; $LOCK_RETRIES=10; # The number of seconds/retries lost mail # should wait before requeing or aborting a # resend. TRUE; # Ansures true return from include file. am-utils-6.2+rc20110530/scripts/lostaltmail.in000077500000000000000000000444141157065440000207100ustar00rootroot00000000000000#!@PERL@ -sw # # Package: am-utils-6.x # Author: James Tanis # ############################################################################ # # lostaltmail -- remail files files found alt_mail (or -a argument to hlfsd) to # whomever should receive it. This version is for SMTP varient which # support VRFY as a non-expanding verifier!!! (sendmail V8 is a an # example). # # Usage: lostaltmail [-debug] [-nomail] [-noverify] # # GLOBAL VARIABLES (as if you care :-) ) # Probably a very incomplete list. # # Everything in the config file for this program *and* ... # # $debug: set it from the command line with -debug. Does the obvious # $nomail: set it from the command line with -nomail. *Not* implied by # $debug # $currentTO: The addresss we are currently checking on. Actually this is # left over from an earlier version of lostaltmail and will hopefully # go away. # $noverify: set it from the address line. Avoid verification of $currentTO. # This should be relatively safe as long as you are willing to # endure bounces from mail that cannot be redelivered as opposed to # just getting a warning. UNTESTED (but should work). # # $logopen: state variable indicating weather the log file (should there be # one) is in fact open. # # @allentries: Array of all the directory entries in $MAILDIR # @allnames: Array of all *likely* recipients. It is created from @allentries # sans junk files (see $MAILJUNK and $LOCALMAILJUNK) # @wanderers: Array of all the files associated with a *single* address # which might need remailing. Should lostaltmail die unexpectedly, # it might leave a temporary file containing messages it was # currently trying to deliver. These will get picked and resent # later. # # VRFY: Handle onto SMTP verification channel. Not to be confused with mail # delivery; only verification occurs accross this handle. # ############################################################################ ############################################################################## # # # SMTP_SEND # # # ############################################################################## # # Send a message to the smtp channel. Inserts the necessary NEWLINE if it # does not exist; # I stole this from myself. It shouldn nott be printing errors to STDERR, but # this is a quick hack. # sub smtp_send { local ($msg) = @_; local ($length); $length=length($msg); if ( $msg !~ /^.*\n$/ ) { $msg = $msg . "\n"; $length++; } if ( ! syswrite (VRFY, $msg, $length)) { print STDERR "Failing SMTP write: $msg"; return 0; } return 1; } ############################################################################## # # # SMTP_RECV # # # ############################################################################## # # Read in lines from SMTP connection and return the final # Really hideous -- please excuse. # sub smtp_recv { local ($line,$rin, $win, $ein, $readbuf, $ret); $readbuf = ""; $rin = $win = $ein = ''; # Null fd sets, vec ($rin, fileno(VRFY), 1) = 1; # Stolen straight from the example; $ein = $rin | $win; # This is probably useless LINE_OF_INPUT: while (1) { # Read in all the input if ((select ( $rin, $win, $ein, 600.0))[0] == 0 ) { print "select returned -1" if ($debug); return -1; # timeout } sysread (VRFY, $readbuf, 1024); chop ($readbuf); foreach $line ( split('\n', $readbuf)) { # This loop is actually needed since V8 has a multi-line greet. ( $line =~ /^(\d\d\d).*/ && ($SMTP_retval=$1)) || warn "Badly formed reply from SMTP peer: $line\n"; # Space after return code indicates EOT if ($line =~ /^\d\d\d /) { $ret = $line; # Oddly $line is in a different context here; # and thus we need to export it out of the # while loop via $ret. last LINE_OF_INPUT; } } # End of read. } # End of input. return $ret; } ############################################################################## # # # LOG_INFO # # # ############################################################################## # # # Opens appropriate logging file -- STDOUT (cron) or temp file (mail). # sub Log_info { local($message) = @_; if ( !$logopened ) { if ( $MAILGRUNT eq "" || $debug) { open (LOGFILE, ">-") || die "Unable to open stdout"; } else { # Snarf the log into a tmp file for final mailing to MAILGRUNT $logfile = $LOGFILE . ".$$"; open (LOGFILE, (">". "$logfile")) || die "Unable to create log file"; } } $logopened=1; # Note that the log is now open # Heart of the function. print LOGFILE "$message"; print LOGFILE "\n" if ( index($message,"\n") == -1 ); } ############################################################################## # # # LOCK_FILE # # # ############################################################################## # # Tries to grab a lock on the supplied file name. # Spins for a bit if it can't on the assumption that the lock will be released # quickly. If it times out and it's allowed to requeue, it will defer # until later, other wise write a message to loginfo. # If a recurring error or really unexpected situation arrises, return # ABORT_RESEND # # PARAMETERS # mailfile: path to the file to resend. # should_requeue: BOOLEAN - TRUE if the mailfile should be put on the # queue for a later retry if we can not finish # now. sub Lock_file { local($mailfile,$should_requeue,$i,$new_lost_file) = @_; # We need to rename the current mailbox so that mail can loop back into it if # the resent mail just gets looped right back to us. $new_lost_file = $mailfile . ".$$"; # make a tmpfile name based on mailfile; $lostlockfile = "$mailfile" . "$LOCKEXT"; if ( ! open(LOCKFILE, (">" . $lostlockfile)) ) { printf(STDERR "Could not create lostlockfile for %s: %s\n", $mailfile,$!); return $ABORT_RESEND; } close(LOCKFILE); $maillockfile = "$mailfile" . "$LOCAL_LOCK_EXT"; for ($i=0; $i < $LOCK_RETRIES && ! link ($lostlockfile, $maillockfile); $i++) { sleep(1); } unlink($lostlockfile); # No matter what eliminate our cruft if ( $i == $LOCK_RETRIES ) { &Log_info("Could not grab lock on: " . "$mailfile" . " :timed out"); if ( $should_requeue ) { &Log_info("Requeing " . "$mailfile" . " for later retry"); $retry_list .= " $mailfile"; } else { &Log_info("Giving up on: " . "$mailfile"); } return $ABORT_RESEND; } # We created the link and therefore have the lock if (rename ($mailfile, $new_lost_file) == 0 ){ # Failed to rename file -- this is serious. unlink($maillockfile); return $ABORT_RESEND; } unlink($maillockfile); return $new_lost_file; } ############################################################################## # # # PARSE NEXT MAIL MESSAGE # # # ############################################################################## # # Parameters: # mailfile: handle of mailfile to use. # # Parses the next message in the mail file and inserts it in $current_msg # sub Get_next_msg { local($mailfile,$found_body_delimiter) = @_; # If this is the first message in the spool file, read the first line # otherwise use the MESSAGE_DELIM line from the previous message (which we # were forced to overread). $done=$FALSE; $found_body_delimiter=$FALSE; # This if eats the very first "From " line and should never fire again. if ( ! defined $current_msg ) {<$mailfile>}; undef ($current_msg); # Erase the old message. # Read the mailfile and pass through all the lines up until the next # message delimiter. Kill any previous resend headers. while ( <$mailfile> ) { last if (/$MESSAGE_DELIM/); next if ( !$found_body_delimiter && /[Rr][Ee][Ss][Ee][Nn][Tt]-.+:/); if ( !$found_body_delimiter && /^$HEADER_BODY_DELIM/) { &Splice_in_resent_headers(); $found_body_delimiter=$TRUE; } if (defined($current_msg)) { $current_msg .= $_; } else { $current_msg = $_; } } # Return TRUE when we have hit the end of the file. if (!defined($_) || $_ eq "" ) { return $TRUE; } else { return $FALSE; } } ############################################################################## # # # SPLICE IN RESENT_HEADERS # # # ############################################################################## # # Insert the Resent- headers at the *current location* of the message stream # (In Engish, print out a few Resent-X: lines and return :-) ) # In addition splice in the X-resent-info: header. # # Paremters: None. # Return: None # sub Splice_in_resent_headers { local($date,$utctime,$weekday,$time,$month,$hostname); $current_msg .= "$RESENT_TO" . "$currentTO" . "\n"; $current_msg .= "$RESENT_FROM" . "$SYSTEM_FROM_ADDRESS" . "\n"; # Calculate date and time. It is a bit of a shame to do this each time # the time needs to be acurate. @utctime=gmtime(time); $weekday=(Sun,Mon,Tue,Wed,Thu,Fri,Sat)[$utctime[6]]; # If the minutes or second do not take two columns each, patch em up. if ( $utctime[1] < 10 ) { if ( $utctime[0] < 10 ) { $time=sprintf("%d:0%d:0%d",$utctime[2],$utctime[1],$utctime[0]); } else { $time=sprintf("%d:0%d:%d",$utctime[2],$utctime[1],$utctime[0]); } } else { if ( $utctime[0] < 10 ) { $time=sprintf("%d:%d:0%d",$utctime[2],$utctime[1],$utctime[0]); } else { $time=sprintf("%d:%2d:%2d",$utctime[2],$utctime[1],$utctime[0]); } } $month=(Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[$utctime[4]]; # Ensure Y2K format $date=sprintf("%s, %d %s %d %s UTC", $weekday, $utctime[3], $month, $utctime[5]+1900, $time); $current_msg .= "$RESENT_DATE" . $date . "\n"; if ( defined $RESENT_INFO && $RESENT_INFO ne "") { $hostname=`uname -n`; $current_msg .= "$RESENT_INFO" . "Lost mail resent from ". $hostname; } return; } ############################################################################## # # # DO_REMAIL # # # ############################################################################## # # Actually resends the mail. Talks to the process configured as $MAILER # We need better handling. # sub Do_remail { open (MAILER, "| $MAILER $currentTO") || return $ABORT_RESEND; print MAILER $current_msg; close (MAILER); } ############################################################################## # # # CLEAN_UP # # # ############################################################################## # # Clean up my messes. # sub Clean_up { local ($hostname); # Ugly local hack that you should never have seen, but I forgot to # remove. Hopefully it did not kill you (I tried as you see), but you # should eiter remove or update it for yourself. I find the message # subject needs to have the hostname to be useful. # chop ($hostname=`uname -n`); $LOG_SUBJECT="$LOG_SUBJECT from $hostname" if ( $hostname =~ /.*\.cs\.columbia\.edu/ ); # # End of ugly local hack # Mail any log info to MAILGRUNT. if (defined($logfile) && $logfile ne "" ) { close (LOGFILE); # Flush logfile output. if ( -s $logfile ) { open (MAILER, "| $MAILER $MAILGRUNT"); print MAILER "To: $MAILGRUNT\n"; print MAILER "Subject: $LOG_SUBJECT\n"; print MAILER "$HEADER_BODY_DELIM"; open (LOGFILE, "< $logfile"); while () { print MAILER $_; } close (MAILER); close (LOGFILE); } unlink($logfile); } exit(0); } ############################################################################## # # # COLLECT_WANDERERS # # # ############################################################################## # # Collects other files that appear to be mail file for the $currentTO # but were not remailed successfully. # # Parameters: none (but uses $currentTO) # Return: True if a old mail directory is found. False otherwise. # Side effects: $wanderers set. # sub Collect_wanderers { undef (@wanderers); # Slurp in the directory and close. return ($found); } ############################################################################# # # # REMAIL ALL # # # ############################################################################# # # Takes an array of files that all seem to share a common repcipient and # remails them if possible. # # Parameters: None (uses @wanderers). # sub Remail_all { local($file,$i); $i=0; foreach $file (@wanderers) { if ( !open (LOSTFILE, "< $file")) { &Log_info("Could not open " . "$file" . " for remailing"); next; } do { # Power loop! $done = &Get_next_msg(LOSTFILE); # Retrieve the next message... &Do_remail; # and remail it. } until $done; undef ($current_msg); # Erase the final remailed message. close(LOSTFILE); # Tidy up. unlink ($file); # Remove the remailed file $i++; } } ############################################################################# # # # CHECK_USER # # # ############################################################################# # # Checks the password tables for the uid of $currentTO. If the user is # uid 0 (ie *supposed* to get mail in altmail) or unknown the resend is # aborted. # # sub Check_user { local (@passwdinfo); undef (@passwdinfo); if (!$noverify && !&vrfy_user($currentTO) ) { &Log_info("Possible non user mail file: $currentTO"); return $ABORT_RESEND; } @passwdinfo = getpwnam($currentTO); print "Non user mailable mail: Name: $currentTO\n" if ( $debug && ! defined @passwdinfo ); return !$ABORT_RESEND if ( ! defined @passwdinfo ); # A non user but evidently mailable print "Check User(): Name: $currentTO -- UID: $passwdinfo[2]\n" if ($debug); return $ABORT_RESEND if ( $passwdinfo[2] == 0 ); return !$ABORT_RESEND; } ############################################################################# # # # VRFY USER # # # ############################################################################# # # Use SMTP VRFY to insure that argument is in fact a legal mail id. # Boolean: TRUE if mailable account, FALSE if not. sub vrfy_user { local ($mailname,$repl) = @_; if ( !&smtp_send("vrfy $mailname") ) { &Log_info("Failed sending to vrfy smtp command for: $mailname"); return 0; } $repl = &smtp_recv; print "VRFY REPLY: $repl\n" if ($debug); return ( $repl =~ /^2\d\d/ ); } ############################################################################# # # # MAIN PROC # # # ############################################################################# # dummy code to shut up perl -w $debug = 0 if !defined($debug); print $nomail if $debug > 1; print $RESENT_FROM if $debug > 1; print $logopen if $debug > 1; print $LOCAL_LOCK_EXT if $debug > 1; print $RESENT_TO if $debug > 1; print $LOCKEXT if $debug > 1; print $RESENT_DATE if $debug > 1; print $MESSAGE_DELIM if $debug > 1; print $SMTP_retval if $debug > 1; print $found if $debug > 1; print $retry_list if $debug > 1; print $MAILJUNK if $debug > 1; print $noverify if $debug > 1; print $SYSTEM_FROM_ADDRESS if $debug > 1; # BEGIN: stuff $prefix="@prefix@"; $CONFIGDIR="@sysconfdir@"; # Directory where global config lives require "$CONFIGDIR/lostaltmail.conf" if (-f "$CONFIGDIR/lostaltmail.conf"); require "/etc/global/lostaltmail.conf" if (-f "/etc/global/lostaltmail.conf"); require "/etc/os/lostaltmail.conf" if (-f "/etc/os/lostaltmail.conf"); require "/etc/local/lostaltmail.conf" if (-f "/etc/local/lostaltmail.conf"); require "ctime.pl"; use Socket; #require "sys/socket.ph"; # SET some initial state variales $logopen = 0; # # Change to alt_dir # # Important!! This directory should be local. Folks will be responsible # for finding this out for themselves. # if (!defined($MAILDIR) || $MAILDIR eq "") { die "MAILDIR must be defined\n"; } chdir ( $MAILDIR ) || die "Cannot change to $MAILDIR (`x' bit not set?)"; # # slurp in directory # opendir (MAIL, ".") || die "Cannot open $MAILDIR (`r' bit not set?)"; @allentries= readdir (MAIL); closedir (MAIL); @allnames = grep (!/$LOCALMAILJUNK|$MAILJUNK/, @allentries); # Open chanel to SMTP for verification -- unless this option is # configured off. if ( ! $noverify ) { local($addr, $port,$sockaddr); socket (VRFY, &AF_INET, &SOCK_STREAM, 0) || die "Could not create TCP socket (SMTP channel)"; $addr = (gethostbyname($SMTPHOST))[4]; # Just use the first addr die "Could not obtain STMP host ($SMTPHOST) address" if ( $addr eq "" ); $port = (getservbyname('smtp','tcp'))[2]; # Get smtp port. die "Could not obtain SMTP port number" if (!defined($port)); printf("SMTP: address: %s port: $port\n", join ('.',unpack('C4',$addr))) if ($debug); $sockaddr = sockaddr_in($port, $addr); printf("Sockaddr: %s\n", join (' ',unpack('C14',$sockaddr))) if ($debug); connect (VRFY, $sockaddr) || die "Could not connect to SMTP daemon on $SMTPHOST"; print "Establshed SMTP channel\n" if ($debug); &smtp_recv; # Greet wait &smtp_send("helo $SMTPHOST"); # Helo message for picky SMTPs &smtp_recv; # Helo reply # Connection is up and ready to VRFY } # main stuff starts here foreach $currentTO (@allnames) { next if ( &Check_user == $ABORT_RESEND); # just delete the file if too small to be real mail if ((stat($currentTO))[7] < 5) { print "Too small to be real mail, unlinking $currentTO" if $debug; unlink $currentTO; } undef (@wanderers); # Just reset this at each pass. @wanderers=grep (/$currentTO\.\d+/, @allentries); $remail_file = &Lock_file($currentTO,$FALSE); # Need to lock the spool. next if ( $remail_file eq $ABORT_RESEND); # Could not get that lock push (@wanderers, $remail_file); # Try to resend "old" files. print "List to remail: @wanderers\n" if ($debug); # check if there is something to remail &Remail_all if ( defined @wanderers && !$nomail); } # this stuff should run at the end foreach $file (grep (/$LOCALMAILJUNK/,@allentries)) { if ($debug) { print "Would unlink $file\n" if ($debug); } else { unlink $file if (-f $file); } } &Clean_up; # Do a clean exit. am-utils-6.2+rc20110530/scripts/redhat-ctl-amd.in000077500000000000000000000035051157065440000211450ustar00rootroot00000000000000#!/bin/bash # # Version: 1.3 # # chkconfig: - 72 28 # description: Runs the automount daemon that mounts devices and NFS hosts \ # on demand. # processname: amd # config: /etc/amd.conf # # we require the /etc/amd.conf file [ -f /etc/amd.conf ] || exit 0 [ -f /etc/sysconfig/amd ] || exit 0 # Source function library. . /etc/init.d/functions # Recover AMDOPTS from /etc/sysconfig/amd. if [ -f /etc/sysconfig/amd ] ; then . /etc/sysconfig/amd fi RETVAL=0 prog=amd prefix=@prefix@ exec_prefix=@exec_prefix@ amd=@sbindir@/amd start() { echo -n "Starting $prog: " daemon $amd -F /etc/amd.conf $AMDOPTS $OPTIONS $MOUNTPTS RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/amd return $RETVAL } stop() { echo -n "Stopping $prog: " # modeled from /usr/sbin/ctl-amd pid=`/usr/sbin/amq -p 2>/dev/null` if [ "$pid" = "" ] ; then # amq -p did not give pid, so try ps pid=`ps acx 2>/dev/null | grep "amd" | sed -e 's/^ *//' -e 's/ .*//'` fi if [ "$pid" = "" ] ; then failure "amd shutdown pid" echo return 1 fi kill $pid # and this part is from wait4amd2die delay=5 count=6 i=1 maxcount=`expr $count + 1` while [ $i != $maxcount ]; do # run amq /usr/sbin/amq > /dev/null 2>&1 if [ $? != 0 ] then # amq failed to run (because amd is dead) success "amd shutdown" rm -f /var/lock/subsys/amd echo return 0 fi sleep $delay i=`expr $i + 1` done failure "amd shutdown (still up)" echo return 1 } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status $amd ;; restart) stop start ;; condrestart) if [ -f /var/lock/subsys/amd ]; then stop start fi ;; reload) action "Reloading $prog:" killall -HUP $amd ;; *) echo "Usage: $0 {start|stop|restart|reload|condrestart|status}" exit 1 esac exit 0 am-utils-6.2+rc20110530/scripts/test-amd.conf000066400000000000000000000012751157065440000204130ustar00rootroot00000000000000# # a test amd.conf file, for testers. Copy this to /etc/amd.conf # GLOBAL OPTIONS SECTION [ global ] normalize_hostnames = no print_pid = no pid_file = /var/run/amd.pid restart_mounts = yes auto_dir = /n log_file = /var/log/amd #log_file = syslog log_options = all #debug_options = all plock = no selectors_on_default = no print_version = no # set map_type to "nis" for NIS maps, or comment it out to search for all # types map_type = file search_path = /etc browsable_dirs = no show_statfs_entries = no fully_qualified_hosts = no cache_duration = 300 # DEFINE AN AMD MOUNT POINT # [ /net ] # map_name = amd.net # map_type = file [ /misc ] map_name = /etc/amd.misc map_type = file am-utils-6.2+rc20110530/scripts/test-amd.misc000066400000000000000000000001231157065440000204100ustar00rootroot00000000000000# map sample for /etc/amd.misc a type:=link;fs:=/usr b type:=link;fs:=/usr/local am-utils-6.2+rc20110530/scripts/test-attrcache.in000077500000000000000000000050271157065440000212730ustar00rootroot00000000000000#!/bin/sh # Script to test the attribute cache behavior of the local OS client. # If this script fails, it means that Amd cannot turn off the attrcache # reliably on this host, and Amd therefore may not run reliably. See # the README.attrcache file distributed with this am-utils. # -Erez Zadok, September 29, 2005 # set PATH (must install am-utils first) prefix=@prefix@ exec_prefix=@exec_prefix@ PATH=@sbindir@:@bindir@:/usr/ucb:/usr/bin:/bin:${PATH} export PATH # test if amd is running amq -p > /dev/null 2>&1 if test $? = 0 then echo "### Amd already running... please shutdown Amd first" exit 1 fi mapfile="/tmp/amd.testmap.$$" logfile="/var/log/amd" delay=1 a=/a CreateMap1 () { echo "### Creating correct map" cat - >$mapfile <$mapfile < [ [args ...]] # If only hostname is supplied, command defaults to rsh $hostname # # Package: am-utils-6.x # Author: Erez Zadok #set -x if [ "X$1" = "X" ]; then echo "Usage: wait4amd [ [args ...]]" exit 1 else hostname=$1 shift fi # set path prefix=@prefix@ exec_prefix=@exec_prefix@ PATH=@sbindir@:@bindir@:${PATH} export PATH while true do amq -h $hostname > /dev/null 2>&1 if [ $? != 0 ] then # failed echo "Amd not up. Sleeping..." sleep 5; else echo "Amd is active on host $hostname!" cmd=$* if [ -z "${cmd}" ] then cmd="rlogin $hostname" fi echo "Running: $cmd" $cmd echo "Sleep 1 second" sleep 1 fi done am-utils-6.2+rc20110530/scripts/wait4amd2die.in000077500000000000000000000016601157065440000206350ustar00rootroot00000000000000#!/bin/sh # wait for amd to die on local host before returning from program. # Usage: wait4amd2die [delay [count]] # If not specified, delay=5 seconds and count=6 (total 30 seconds) # If at end of total delay amd is till up, return 1; else return 0. # # Package: am-utils-6.x # Author: Erez Zadok #set -x # set path prefix=@prefix@ exec_prefix=@exec_prefix@ PATH=@sbindir@:@bindir@:/usr/bin:/bin:${PATH} export PATH # how long to wait? if test -n "$1" then delay=$1 else delay=3 fi # how many times to delay if test -n "$2" then count=$2 else count=10 fi i=1 maxcount=`expr $count + 1` while [ $i != $maxcount ]; do # run amq @sbindir@/amq > /dev/null 2>&1 if [ $? != 0 ] then # amq failed to run (because amd is dead) echo "wait4amd2die: amd is down!" exit 0 fi echo "wait4amd2die: delay $delay sec ($i of $count)..." sleep $delay i=`expr $i + 1` done echo "wait4amd2die: amd is still up..." exit 1 am-utils-6.2+rc20110530/tasks000066400000000000000000000064771157065440000154200ustar00rootroot00000000000000 AM-UTILS-6.1 TASKS TODO Please volunteer to do any of the following: - autofs support: see README.autofs for details. - deal with everything that has XXX on it in the sources - documentation update ("XXX: FILL IN" sections). - compatibility with Sun's automount maps? should be easier via the amd.conf file to specify type of map - convert to using my own rpcgen .x files for amq/amq/nfs (v2 and v3) - use packaging info for various OSs (such as RPM, Redhat Package Manager) - $mindelay and $maxdelay in milliseconds - multiple nfsl should be matched if one matched and nfs mount failed. fall through. - support multiple "fail-over read-only" NFS mounts in Solaris 2.6+. - random nfs rhost:={srv1, srv2, srv3} - nfslx, same as nfsl, but using linkx - loadable info_*, amfs_*, and ops_* modules (lazy evaluation). - hlfsd should daemonize even if -DDEBUG, then use -D nofork - fixmount should use generic code from transp/transp_{tli,sockets}.c - reverse notion of -F and other cmd-line options, so they override the amd.conf file (right now amd.conf overrides cmd-line options). - add am-utils URL and COPYRIGHT to all distributed scripts and sources and programs etc. also to amq -v output. - ion: browsable_dirs only works for nis if in [global] broken if it is file maps. - browsable 'auto' style maps. - mention signals in amd man page - ALLOWED_MOUNT_TIME of 40 seconds is way too long! - detecting down'ed hosts faster: use default portmap TTL variables? - push get_nfs_version() down into a child process - type:=program should not require umount command. can use default umount(). it works for smbmount/umount. - document var[0-7] variables/selectors - need a way to export a nfs-mount point after it is being mounted (jukebox mounts). can do this with type:=program. - support port=n, for machines that use NFS on a different port - nfsl may be buggy when fs:= is specified explicitly (lockup?) - y2k: amq /home (mounted time uses YY instead of YYYY) - new amd.conf option to disable amq listener altogether (security) Should be available even if DEBUG is off. - new amd.conf option dynamic_system_params to recompute osver, karch, etc. from uname() dynamically. - solaris 8 doesn't pick up hsfs/pcfs/etc *_args structures and mount flags - avoid having to compile ops_nfs3.o - linux support for ext3 - be able to pass generic mount options to systems w/ a mount(2) that supports it (Linux). Perhaps genopt="foo,bar" syntax. - support several different nfs servers inside one nfsx entry - reimplement the "parallel mounting" for multiple matching sub-entries - fix amd.conf parser so it can parse key=value without spaces around the "=" sign. Note this isn't so trivial because 'value' may include "=" signs. - NFSv4 support (such a short "tasks" entry given how much work it is :-) * documentation - document what can and what can't be a top-level mount type (i.e. a map-backed or map-holding type). Currently that's toplvl, auto, and direct. - document how to add a direct map to amd.conf. * autofs stuff Linux: - host mounts broken with autofs v3 - nfsx status unknown - local filesystems (ufs, etc) status unknown Solaris: - host mounts status unknown - nfsx status unknown - local filesystems (ufs, etc) status unknown FreeBSD: - just do it All: - mntfs->mf_fo->opt_fs can contain garbage sometimes?? am-utils-6.2+rc20110530/vers.m4000066400000000000000000000000151157065440000155470ustar00rootroot00000000000000[6.2-rc1]dnl am-utils-6.2+rc20110530/wire-test/000077500000000000000000000000001157065440000162555ustar00rootroot00000000000000am-utils-6.2+rc20110530/wire-test/.cvsignore000066400000000000000000000000141157065440000202500ustar00rootroot00000000000000Makefile.in am-utils-6.2+rc20110530/wire-test/Makefile.am000066400000000000000000000016151157065440000203140ustar00rootroot00000000000000## Process this file with automake to produce Makefile.in # Package: am-utils # Level: Makefile for wire-test/ directory # Author: Erez Zadok sbin_PROGRAMS = wire-test # man pages man_MANS = wire-test.8 # headers this depends on, not to be installed #noinst_HEADERS = wire_test_SOURCES = wire-test.c LDADD = ../libamu/libamu.la INCLUDES = -I$(top_srcdir)/include # allow users to add their own flags via "configure --enable-am-flags=ARG" AMU_CFLAGS = @AMU_CFLAGS@ AM_CFLAGS = @CFLAGS@ $(AMU_CFLAGS) # additional files to distribute and clean EXTRA_DIST = $(man_MANS) # dependencies $(PROGRAMS): $(LDADD) $(wire_test_OBJECTS): \ ../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) am-utils-6.2+rc20110530/wire-test/wire-test.8000066400000000000000000000062061157065440000202750ustar00rootroot00000000000000.\" .\" Copyright (c) 1997-2011 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. 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 .\" 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/wire-test/wire-test.8 .\" .TH WIRE-TEST 8 "26 Feb 1993" .SH NAME wire-test \- test your network interfaces and local IP address .SH SYNOPSIS .B wire-test [ .I host ] .SH DESCRIPTION .LP .B wire-test is used to find out what amd thinks are the first two network interfaces and network names/numbers used, as well as the IP address used for amd to NFS-mount itself. If .I host is specified, then .B wire-test will test for the working combinations of NFS protocol and version from the current client to the NFS server .I host. If not specified, .I host defaults to "localhost". .SH "SEE ALSO" .BR amd (8). .LP ``am-utils'' .BR info (1) entry. .LP .I "Linux NFS and Automounter Administration" by Erez Zadok, ISBN 0-7821-2739-8, (Sybex, 2001). .LP .I http://www.am-utils.org .LP .I "Amd \- The 4.4 BSD Automounter" .SH AUTHORS Erez Zadok , Computer Science Department, Stony Brook University, Stony Brook, New York, USA. .P Other authors and contributors to am-utils are listed in the .B AUTHORS file distributed with am-utils. am-utils-6.2+rc20110530/wire-test/wire-test.c000066400000000000000000000105021157065440000203420ustar00rootroot00000000000000/* * Copyright (c) 1997-2011 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. 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 * 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/wire-test/wire-test.c * */ #ifdef HAVE_CONFIG_H # include #endif /* HAVE_CONFIG_H */ #include #define STRMAX 100 char hostname[MAXHOSTNAMELEN + 1]; int main(int argc, char **argv) { char *networkName1, *networkNumber1; struct in_addr myipaddr; /* (An) IP address of this host */ char *testhost, *proto, *tmp_buf; int nv, ret; struct sockaddr_in *ip; struct hostent *hp = NULL; am_set_progname(argv[0]); if (gethostname(hostname, sizeof(hostname)) < 0) { perror(argv[0]); exit(1); } hostname[sizeof(hostname) - 1] = '\0'; /* get list of networks */ getwire(&networkName1, &networkNumber1); tmp_buf = print_wires(); if (tmp_buf) { fprintf(stderr, "%s", tmp_buf); XFREE(tmp_buf); } /* also print my IP address */ amu_get_myaddress(&myipaddr, NULL); fprintf(stderr, "My IP address is 0x%x.\n", (unsigned int) htonl(myipaddr.s_addr)); /* * NFS VERSION/PROTOCOL TESTS: * If argv[1] is specified perform nfs tests to that host, else use * localhost. */ if (argc > 1) testhost = argv[1]; else testhost = "localhost"; hp = gethostbyname(testhost); if (!hp) { fprintf(stderr, "NFS vers/proto failed: no such hostname \"%s\"\n", testhost); exit(1); } ip = (struct sockaddr_in *) xmalloc(sizeof(struct sockaddr_in)); memset((voidp) ip, 0, sizeof(*ip)); /* as per POSIX, sin_len need not be set (used internally by kernel) */ ip->sin_family = AF_INET; memmove((voidp) &ip->sin_addr, (voidp) hp->h_addr, sizeof(ip->sin_addr)); ip->sin_port = htons(NFS_PORT); fprintf(stderr, "NFS Version and protocol tests to host \"%s\"...\n", testhost); proto = "udp"; for (nv=2; nv<=3; ++nv) { fprintf(stderr, "\ttesting vers=%d, proto=\"%s\" -> ", nv, proto); ret = get_nfs_version(testhost, ip, nv, proto); if (ret == 0) fprintf(stderr, "failed!\n"); else fprintf(stderr, "found version %d.\n", ret); } proto = "tcp"; for (nv=2; nv<=3; ++nv) { fprintf(stderr, "\ttesting vers=%d, proto=\"%s\" -> ", nv, proto); ret = get_nfs_version(testhost, ip, nv, proto); if (ret == 0) fprintf(stderr, "failed!\n"); else fprintf(stderr, "found version %d.\n", ret); } exit(0); return 0; /* should never reach here */ } am-utils-6.2+rc20110530/ylwrap000077500000000000000000000146161157065440000156060ustar00rootroot00000000000000#! /bin/sh # ylwrap - wrapper for lex/yacc invocations. scriptversion=2007-11-22.22 # Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, # 2007 Free Software Foundation, Inc. # # Written by Tom Tromey . # # 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., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . case "$1" in '') echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 exit 1 ;; --basedir) basedir=$2 shift 2 ;; -h|--h*) cat <<\EOF Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... Wrapper for lex/yacc invocations, renaming files as desired. INPUT is the input file OUTPUT is one file PROG generates DESIRED is the file we actually want instead of OUTPUT PROGRAM is program to run ARGS are passed to PROG Any number of OUTPUT,DESIRED pairs may be used. Report bugs to . EOF exit $? ;; -v|--v*) echo "ylwrap $scriptversion" exit $? ;; esac # The input. input="$1" shift case "$input" in [\\/]* | ?:[\\/]*) # Absolute path; do nothing. ;; *) # Relative path. Make it absolute. input="`pwd`/$input" ;; esac pairlist= while test "$#" -ne 0; do if test "$1" = "--"; then shift break fi pairlist="$pairlist $1" shift done # The program to run. prog="$1" shift # Make any relative path in $prog absolute. case "$prog" in [\\/]* | ?:[\\/]*) ;; *[\\/]*) prog="`pwd`/$prog" ;; esac # FIXME: add hostname here for parallel makes that run commands on # other machines. But that might take us over the 14-char limit. dirname=ylwrap$$ trap "cd '`pwd`'; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15 mkdir $dirname || exit 1 cd $dirname case $# in 0) "$prog" "$input" ;; *) "$prog" "$@" "$input" ;; esac ret=$? if test $ret -eq 0; then set X $pairlist shift first=yes # Since DOS filename conventions don't allow two dots, # the DOS version of Bison writes out y_tab.c instead of y.tab.c # and y_tab.h instead of y.tab.h. Test to see if this is the case. y_tab_nodot="no" if test -f y_tab.c || test -f y_tab.h; then y_tab_nodot="yes" fi # The directory holding the input. input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` # Quote $INPUT_DIR so we can use it in a regexp. # FIXME: really we should care about more than `.' and `\'. input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'` while test "$#" -ne 0; do from="$1" # Handle y_tab.c and y_tab.h output by DOS if test $y_tab_nodot = "yes"; then if test $from = "y.tab.c"; then from="y_tab.c" else if test $from = "y.tab.h"; then from="y_tab.h" fi fi fi if test -f "$from"; then # If $2 is an absolute path name, then just use that, # otherwise prepend `../'. case "$2" in [\\/]* | ?:[\\/]*) target="$2";; *) target="../$2";; esac # We do not want to overwrite a header file if it hasn't # changed. This avoid useless recompilations. However the # parser itself (the first file) should always be updated, # because it is the destination of the .y.c rule in the # Makefile. Divert the output of all other files to a temporary # file so we can compare them to existing versions. if test $first = no; then realtarget="$target" target="tmp-`echo $target | sed s/.*[\\/]//g`" fi # Edit out `#line' or `#' directives. # # We don't want the resulting debug information to point at # an absolute srcdir; it is better for it to just mention the # .y file with no path. # # We want to use the real output file name, not yy.lex.c for # instance. # # We want the include guards to be adjusted too. FROM=`echo "$from" | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` TARGET=`echo "$2" | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` prefix=`echo $input | sed \ -e 's,^.*/,,g' \ -e 's/_parse.[yl]$/_/g' \ -e 's/_tok.[yl]$/_/g'` case $prefix in *.y) code_prefix="$(basename $prefix _gram.y)_yy";; *.l) code_prefix="$(basename $prefix _lex.l)_yy";; *) code_prefix="$prefix";; esac sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \ -e "s,$FROM,$TARGET," "$from" | sed "s/yy/$code_prefix/g" > "$target" || ret=$? # Check whether header files must be updated. if test $first = no; then if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then echo "$2" is unchanged rm -f "$target" else echo updating "$2" mv -f "$target" "$realtarget" fi fi else # A missing file is only an error for the first file. This # is a blatant hack to let us support using "yacc -d". If -d # is not specified, we don't want an error when the header # file is "missing". if test $first = yes; then ret=1 fi fi shift shift first=no done else ret=$? fi # Remove the directory. cd .. rm -rf $dirname exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-end: "$" # End: