r57 - in multipath-tools/upstream/current: . devmap_name dmadm
klibc-0.190 klibc-0.190/include klibc-0.190/include/arch
klibc-0.190/include/arch/alpha klibc-0.190/include/arch/alpha/klibc
klibc-0.190/include/arch/alpha/machine klibc-0.190/include/arch/arm
klibc-0.190/include/arch/arm/klibc klibc-0.190/include/arch/cris
klibc-0.190/include/arch/cris/klibc klibc-0.190/include/arch/i386
klibc-0.190/include/arch/i386/klibc
klibc-0.190/include/arch/i386/sys klibc-0.190/include/arch/ia64
klibc-0.190/include/arch/ia64/klibc klibc-0.190/include/arch/m68k
klibc-0.190/include/arch/m68k/klibc klibc-0.190/include/arch/mips
klibc-0.190/include/arch/mips/klibc
klibc-0.190/include/arch/mips/machine
klibc-0.190/include/arch/mips64
klibc-0.190/include/arch/mips64/klibc
klibc-0.190/include/arch/parisc
klibc-0.190/include/arch/parisc/klibc klibc-0.190/include/arch/ppc
klibc-0.190/include/arch/ppc/klibc klibc-0.190/include/arch/ppc64
klibc-0.190/include/arch/ppc64/klibc klibc-0.190/include/arch/s390
klibc-0.190/include/arch/s390/klibc klibc-0.190/include/arch/s390x
klibc-0.190/include/arch/s390x/klibc
klibc-0.190/include/arch/sh klibc-0.190/include/arch/sh/klibc
klibc-0.190/include/arch/sparc klibc-0.190/include/arch/sparc/klibc
klibc-0.190/include/arch/sparc/machine
klibc-0.190/include/arch/sparc64
klibc-0.190/include/arch/sparc64/klibc
klibc-0.190/include/arch/x86_64
klibc-0.190/include/arch/x86_64/klibc
klibc-0.190/include/arch/x86_64/sys klibc-0.190/include/arpa
klibc-0.190/include/bits32 klibc-0.190/include/bits32/bitsize
klibc-0.190/include/bits64 klibc-0.190/include/bits64/bitsize
klibc-0.190/include/klibc klibc-0.190/include/net
klibc-0.190/include/netinet klibc-0.190/include/sys
klibc-0.190/klibc klibc-0.190/klibc/arch
klibc-0.190/klibc/arch/alpha klibc-0.190/klibc/arch/arm
klibc-0.190/klibc/arch/cris klibc-0.190/klibc/arch/i386
klibc-0.190/klibc/arch/i386/libgcc
klibc-0.190/klibc/arch/ia64 klibc-0.190/klibc/arch/m68k
klibc-0.190/klibc/arch/mips klibc-0.190/klibc/arch/mips64
klibc-0.190/klibc/arch/parisc klibc-0.190/klibc/arch/ppc
klibc-0.190/klibc/arch/ppc64 klibc-0.190/klibc/arch/s390
klibc-0.190/klibc/arch/s390x klibc-0.190/klibc/arch/sh
klibc-0.190/klibc/arch/sparc klibc-0.190/klibc/arch/sparc64
klibc-0.190/klibc/arch/x86_64 klibc-0.190/klibc/inet
klibc-0.190/klibc/libgcc klibc-0.190/klibc/tests kpartx
libcheckers libdevmapper libdevmapper/include
libdevmapper/include/linux libdevmapper/ioctl
libdevmapper/kernel libdevmapper/kernel/ioctl libmultipath
libsysfs libsysfs/sysfs multipath multipathd path_priority
Bastian Blank
waldi at costa.debian.org
Thu Jul 21 12:48:12 UTC 2005
Author: waldi
Date: Fri Mar 4 08:05:19 2005
New Revision: 57
Added:
multipath-tools/upstream/current/.indent.pro
multipath-tools/upstream/current/AUTHOR
multipath-tools/upstream/current/COPYING
multipath-tools/upstream/current/ChangeLog
multipath-tools/upstream/current/FAQ
multipath-tools/upstream/current/Makefile
multipath-tools/upstream/current/Makefile.inc
multipath-tools/upstream/current/README
multipath-tools/upstream/current/TODO
multipath-tools/upstream/current/devmap_name/
multipath-tools/upstream/current/devmap_name/Makefile
multipath-tools/upstream/current/devmap_name/devmap_name.8
multipath-tools/upstream/current/devmap_name/devmap_name.c
multipath-tools/upstream/current/dmadm/
multipath-tools/upstream/current/dmadm/Makefile
multipath-tools/upstream/current/dmadm/README
multipath-tools/upstream/current/dmadm/dmadm (contents, props changed)
multipath-tools/upstream/current/dmadm/dmadm.c
multipath-tools/upstream/current/dmadm/md_p.h
multipath-tools/upstream/current/dmadm/md_u.h
multipath-tools/upstream/current/dmadm/mdadm.h
multipath-tools/upstream/current/dmadm/util.c
multipath-tools/upstream/current/klibc (contents, props changed)
multipath-tools/upstream/current/klibc-0.190/
multipath-tools/upstream/current/klibc-0.190/MCONFIG
multipath-tools/upstream/current/klibc-0.190/MRULES
multipath-tools/upstream/current/klibc-0.190/Makefile
multipath-tools/upstream/current/klibc-0.190/README
multipath-tools/upstream/current/klibc-0.190/include/
multipath-tools/upstream/current/klibc-0.190/include/alloca.h
multipath-tools/upstream/current/klibc-0.190/include/arch/
multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/
multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/machine/
multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/machine/asm.h
multipath-tools/upstream/current/klibc-0.190/include/arch/arm/
multipath-tools/upstream/current/klibc-0.190/include/arch/arm/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/arm/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/arm/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/arm/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/arm/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/cris/
multipath-tools/upstream/current/klibc-0.190/include/arch/cris/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/cris/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/cris/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/cris/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/cris/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/i386/
multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/diverr.h
multipath-tools/upstream/current/klibc-0.190/include/arch/i386/sys/
multipath-tools/upstream/current/klibc-0.190/include/arch/i386/sys/io.h
multipath-tools/upstream/current/klibc-0.190/include/arch/i386/sys/vm86.h
multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/
multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/m68k/
multipath-tools/upstream/current/klibc-0.190/include/arch/m68k/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/m68k/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/m68k/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/m68k/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/mips/
multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archfcntl.h
multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/mips/machine/
multipath-tools/upstream/current/klibc-0.190/include/arch/mips/machine/asm.h
multipath-tools/upstream/current/klibc-0.190/include/arch/mips/sgidefs.h
multipath-tools/upstream/current/klibc-0.190/include/arch/mips/spaces.h
multipath-tools/upstream/current/klibc-0.190/include/arch/mips64/
multipath-tools/upstream/current/klibc-0.190/include/arch/mips64/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/mips64/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/mips64/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/mips64/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/parisc/
multipath-tools/upstream/current/klibc-0.190/include/arch/parisc/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/parisc/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/parisc/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/parisc/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/
multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/
multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/s390/
multipath-tools/upstream/current/klibc-0.190/include/arch/s390/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/s390/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/s390/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/s390/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/s390/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/
multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sh/
multipath-tools/upstream/current/klibc-0.190/include/arch/sh/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/sh/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sh/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sh/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sh/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/machine/
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/machine/asm.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/machine/frame.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/machine/trap.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/
multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/klibc/
multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/klibc/archsetjmp.h
multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/klibc/archsignal.h
multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/klibc/archstat.h
multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/klibc/archsys.h
multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/sys/
multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/sys/io.h
multipath-tools/upstream/current/klibc-0.190/include/arpa/
multipath-tools/upstream/current/klibc-0.190/include/arpa/inet.h
multipath-tools/upstream/current/klibc-0.190/include/assert.h
multipath-tools/upstream/current/klibc-0.190/include/bits32/
multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/
multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/limits.h
multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/stddef.h
multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/stdint.h
multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/stdintconst.h
multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/stdintlimits.h
multipath-tools/upstream/current/klibc-0.190/include/bits64/
multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/
multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/limits.h
multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/stddef.h
multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/stdint.h
multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/stdintconst.h
multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/stdintlimits.h
multipath-tools/upstream/current/klibc-0.190/include/ctype.h
multipath-tools/upstream/current/klibc-0.190/include/dirent.h
multipath-tools/upstream/current/klibc-0.190/include/elf.h
multipath-tools/upstream/current/klibc-0.190/include/endian.h
multipath-tools/upstream/current/klibc-0.190/include/errno.h
multipath-tools/upstream/current/klibc-0.190/include/fcntl.h
multipath-tools/upstream/current/klibc-0.190/include/grp.h
multipath-tools/upstream/current/klibc-0.190/include/inttypes.h
multipath-tools/upstream/current/klibc-0.190/include/klibc/
multipath-tools/upstream/current/klibc-0.190/include/klibc/compiler.h
multipath-tools/upstream/current/klibc-0.190/include/klibc/diverr.h
multipath-tools/upstream/current/klibc-0.190/include/klibc/extern.h
multipath-tools/upstream/current/klibc-0.190/include/klibc/sysconfig.h
multipath-tools/upstream/current/klibc-0.190/include/limits.h
multipath-tools/upstream/current/klibc-0.190/include/net/
multipath-tools/upstream/current/klibc-0.190/include/net/if.h
multipath-tools/upstream/current/klibc-0.190/include/net/if_arp.h
multipath-tools/upstream/current/klibc-0.190/include/net/if_ether.h
multipath-tools/upstream/current/klibc-0.190/include/net/if_packet.h
multipath-tools/upstream/current/klibc-0.190/include/netinet/
multipath-tools/upstream/current/klibc-0.190/include/netinet/in.h
multipath-tools/upstream/current/klibc-0.190/include/netinet/in6.h
multipath-tools/upstream/current/klibc-0.190/include/netinet/ip.h
multipath-tools/upstream/current/klibc-0.190/include/netinet/tcp.h
multipath-tools/upstream/current/klibc-0.190/include/netinet/udp.h
multipath-tools/upstream/current/klibc-0.190/include/paths.h
multipath-tools/upstream/current/klibc-0.190/include/poll.h
multipath-tools/upstream/current/klibc-0.190/include/sched.h
multipath-tools/upstream/current/klibc-0.190/include/setjmp.h
multipath-tools/upstream/current/klibc-0.190/include/signal.h
multipath-tools/upstream/current/klibc-0.190/include/stdarg.h
multipath-tools/upstream/current/klibc-0.190/include/stddef.h
multipath-tools/upstream/current/klibc-0.190/include/stdint.h
multipath-tools/upstream/current/klibc-0.190/include/stdio.h
multipath-tools/upstream/current/klibc-0.190/include/stdlib.h
multipath-tools/upstream/current/klibc-0.190/include/string.h
multipath-tools/upstream/current/klibc-0.190/include/sys/
multipath-tools/upstream/current/klibc-0.190/include/sys/dirent.h
multipath-tools/upstream/current/klibc-0.190/include/sys/elf32.h
multipath-tools/upstream/current/klibc-0.190/include/sys/elf64.h
multipath-tools/upstream/current/klibc-0.190/include/sys/elfcommon.h
multipath-tools/upstream/current/klibc-0.190/include/sys/fsuid.h
multipath-tools/upstream/current/klibc-0.190/include/sys/ioctl.h
multipath-tools/upstream/current/klibc-0.190/include/sys/klog.h
multipath-tools/upstream/current/klibc-0.190/include/sys/mman.h
multipath-tools/upstream/current/klibc-0.190/include/sys/mount.h
multipath-tools/upstream/current/klibc-0.190/include/sys/param.h
multipath-tools/upstream/current/klibc-0.190/include/sys/reboot.h
multipath-tools/upstream/current/klibc-0.190/include/sys/resource.h
multipath-tools/upstream/current/klibc-0.190/include/sys/select.h
multipath-tools/upstream/current/klibc-0.190/include/sys/socket.h
multipath-tools/upstream/current/klibc-0.190/include/sys/socketcalls.h
multipath-tools/upstream/current/klibc-0.190/include/sys/stat.h
multipath-tools/upstream/current/klibc-0.190/include/sys/statfs.h
multipath-tools/upstream/current/klibc-0.190/include/sys/syscall.h
multipath-tools/upstream/current/klibc-0.190/include/sys/sysinfo.h
multipath-tools/upstream/current/klibc-0.190/include/sys/sysmacros.h
multipath-tools/upstream/current/klibc-0.190/include/sys/time.h
multipath-tools/upstream/current/klibc-0.190/include/sys/times.h
multipath-tools/upstream/current/klibc-0.190/include/sys/types.h
multipath-tools/upstream/current/klibc-0.190/include/sys/uio.h
multipath-tools/upstream/current/klibc-0.190/include/sys/un.h
multipath-tools/upstream/current/klibc-0.190/include/sys/utime.h
multipath-tools/upstream/current/klibc-0.190/include/sys/utsname.h
multipath-tools/upstream/current/klibc-0.190/include/sys/vfs.h
multipath-tools/upstream/current/klibc-0.190/include/sys/wait.h
multipath-tools/upstream/current/klibc-0.190/include/syslog.h
multipath-tools/upstream/current/klibc-0.190/include/termios.h
multipath-tools/upstream/current/klibc-0.190/include/time.h
multipath-tools/upstream/current/klibc-0.190/include/unistd.h
multipath-tools/upstream/current/klibc-0.190/include/utime.h
multipath-tools/upstream/current/klibc-0.190/klibc/
multipath-tools/upstream/current/klibc-0.190/klibc.spec.in
multipath-tools/upstream/current/klibc-0.190/klibc/CAVEATS
multipath-tools/upstream/current/klibc-0.190/klibc/LICENSE
multipath-tools/upstream/current/klibc-0.190/klibc/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/Makefile
multipath-tools/upstream/current/klibc-0.190/klibc/README
multipath-tools/upstream/current/klibc-0.190/klibc/SOCKETCALLS.def
multipath-tools/upstream/current/klibc-0.190/klibc/SYSCALLS.def
multipath-tools/upstream/current/klibc-0.190/klibc/__put_env.c
multipath-tools/upstream/current/klibc-0.190/klibc/__shared_init.c
multipath-tools/upstream/current/klibc-0.190/klibc/__signal.c
multipath-tools/upstream/current/klibc-0.190/klibc/__static_init.c
multipath-tools/upstream/current/klibc-0.190/klibc/abort.c
multipath-tools/upstream/current/klibc-0.190/klibc/alarm.c
multipath-tools/upstream/current/klibc-0.190/klibc/arch/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/README
multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/README-gcc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/divide.c
multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/pipe.c
multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/syscall.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/sysdual.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/setjmp-arm.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/setjmp-thumb.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/syscall.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/__negdi2.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/divide.c
multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/syscall.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/exits.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__ashldi3.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__ashrdi3.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__lshrdi3.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__muldi3.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__negdi2.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/open.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/socketcall.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/syscall.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/pipe.c
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/syscall.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/vfork.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/m68k/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/m68k/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/m68k/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/klibc.ld
multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/pipe.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/syscall.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/vfork.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips64/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips64/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips64/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/syscall.c
multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/syscall.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/syscall.c
multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/mmap.c
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/syscall.c
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/mmap.c
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/syscall.c
multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/syscall.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/crt0i.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/divrem.m4
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/smul.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/syscall.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/sysfork.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/umul.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/syscall.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/sysfork.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/
multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/MCONFIG
multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/Makefile.inc
multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/crt0.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/exits.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/setjmp.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/syscall.S
multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/sysstub.ph
multipath-tools/upstream/current/klibc-0.190/klibc/asprintf.c
multipath-tools/upstream/current/klibc-0.190/klibc/assert.c
multipath-tools/upstream/current/klibc-0.190/klibc/atexit.c
multipath-tools/upstream/current/klibc-0.190/klibc/atexit.h
multipath-tools/upstream/current/klibc-0.190/klibc/atoi.c
multipath-tools/upstream/current/klibc-0.190/klibc/atol.c
multipath-tools/upstream/current/klibc-0.190/klibc/atoll.c
multipath-tools/upstream/current/klibc-0.190/klibc/atox.c
multipath-tools/upstream/current/klibc-0.190/klibc/brk.c
multipath-tools/upstream/current/klibc-0.190/klibc/bsd_signal.c
multipath-tools/upstream/current/klibc-0.190/klibc/calloc.c
multipath-tools/upstream/current/klibc-0.190/klibc/closelog.c
multipath-tools/upstream/current/klibc-0.190/klibc/creat.c
multipath-tools/upstream/current/klibc-0.190/klibc/ctypes.c
multipath-tools/upstream/current/klibc-0.190/klibc/daemon.c
multipath-tools/upstream/current/klibc-0.190/klibc/exec_l.c
multipath-tools/upstream/current/klibc-0.190/klibc/execl.c
multipath-tools/upstream/current/klibc-0.190/klibc/execle.c
multipath-tools/upstream/current/klibc-0.190/klibc/execlp.c
multipath-tools/upstream/current/klibc-0.190/klibc/execlpe.c
multipath-tools/upstream/current/klibc-0.190/klibc/execv.c
multipath-tools/upstream/current/klibc-0.190/klibc/execvp.c
multipath-tools/upstream/current/klibc-0.190/klibc/execvpe.c
multipath-tools/upstream/current/klibc-0.190/klibc/exitc.c
multipath-tools/upstream/current/klibc-0.190/klibc/fgetc.c
multipath-tools/upstream/current/klibc-0.190/klibc/fgets.c
multipath-tools/upstream/current/klibc-0.190/klibc/fopen.c
multipath-tools/upstream/current/klibc-0.190/klibc/fork.c
multipath-tools/upstream/current/klibc-0.190/klibc/fprintf.c
multipath-tools/upstream/current/klibc-0.190/klibc/fputc.c
multipath-tools/upstream/current/klibc-0.190/klibc/fputs.c
multipath-tools/upstream/current/klibc-0.190/klibc/fread.c
multipath-tools/upstream/current/klibc-0.190/klibc/fread2.c
multipath-tools/upstream/current/klibc-0.190/klibc/fstatfs.c
multipath-tools/upstream/current/klibc-0.190/klibc/fwrite.c
multipath-tools/upstream/current/klibc-0.190/klibc/fwrite2.c
multipath-tools/upstream/current/klibc-0.190/klibc/getcwd.c
multipath-tools/upstream/current/klibc-0.190/klibc/getdomainname.c
multipath-tools/upstream/current/klibc-0.190/klibc/getenv.c
multipath-tools/upstream/current/klibc-0.190/klibc/gethostname.c
multipath-tools/upstream/current/klibc-0.190/klibc/getopt.c
multipath-tools/upstream/current/klibc-0.190/klibc/getpgrp.c
multipath-tools/upstream/current/klibc-0.190/klibc/getpriority.c
multipath-tools/upstream/current/klibc-0.190/klibc/getpt.c
multipath-tools/upstream/current/klibc-0.190/klibc/globals.c
multipath-tools/upstream/current/klibc-0.190/klibc/inet/
multipath-tools/upstream/current/klibc-0.190/klibc/inet/bindresvport.c
multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_addr.c
multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_aton.c
multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_ntoa.c
multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_ntop.c
multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_pton.c
multipath-tools/upstream/current/klibc-0.190/klibc/interp.S
multipath-tools/upstream/current/klibc-0.190/klibc/isatty.c
multipath-tools/upstream/current/klibc-0.190/klibc/jrand48.c
multipath-tools/upstream/current/klibc-0.190/klibc/libc_init.c
multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/
multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__divdi3.c
multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__divsi3.c
multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__moddi3.c
multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__modsi3.c
multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__udivdi3.c
multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__udivmoddi4.c
multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__udivmodsi4.c
multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__udivsi3.c
multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__umoddi3.c
multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__umodsi3.c
multipath-tools/upstream/current/klibc-0.190/klibc/llseek.c
multipath-tools/upstream/current/klibc-0.190/klibc/lrand48.c
multipath-tools/upstream/current/klibc-0.190/klibc/makeerrlist.pl
multipath-tools/upstream/current/klibc-0.190/klibc/malloc.c
multipath-tools/upstream/current/klibc-0.190/klibc/malloc.h
multipath-tools/upstream/current/klibc-0.190/klibc/memccpy.c
multipath-tools/upstream/current/klibc-0.190/klibc/memchr.c
multipath-tools/upstream/current/klibc-0.190/klibc/memcmp.c
multipath-tools/upstream/current/klibc-0.190/klibc/memcpy.c
multipath-tools/upstream/current/klibc-0.190/klibc/memmem.c
multipath-tools/upstream/current/klibc-0.190/klibc/memmove.c
multipath-tools/upstream/current/klibc-0.190/klibc/memset.c
multipath-tools/upstream/current/klibc-0.190/klibc/memswap.c
multipath-tools/upstream/current/klibc-0.190/klibc/mmap.c
multipath-tools/upstream/current/klibc-0.190/klibc/mrand48.c
multipath-tools/upstream/current/klibc-0.190/klibc/nice.c
multipath-tools/upstream/current/klibc-0.190/klibc/nrand48.c
multipath-tools/upstream/current/klibc-0.190/klibc/onexit.c
multipath-tools/upstream/current/klibc-0.190/klibc/open.c
multipath-tools/upstream/current/klibc-0.190/klibc/pause.c
multipath-tools/upstream/current/klibc-0.190/klibc/perror.c
multipath-tools/upstream/current/klibc-0.190/klibc/printf.c
multipath-tools/upstream/current/klibc-0.190/klibc/pty.c
multipath-tools/upstream/current/klibc-0.190/klibc/putchar.c
multipath-tools/upstream/current/klibc-0.190/klibc/putenv.c
multipath-tools/upstream/current/klibc-0.190/klibc/puts.c
multipath-tools/upstream/current/klibc-0.190/klibc/qsort.c
multipath-tools/upstream/current/klibc-0.190/klibc/raise.c
multipath-tools/upstream/current/klibc-0.190/klibc/readdir.c
multipath-tools/upstream/current/klibc-0.190/klibc/realloc.c
multipath-tools/upstream/current/klibc-0.190/klibc/reboot.c
multipath-tools/upstream/current/klibc-0.190/klibc/recv.c
multipath-tools/upstream/current/klibc-0.190/klibc/sbrk.c
multipath-tools/upstream/current/klibc-0.190/klibc/seed48.c
multipath-tools/upstream/current/klibc-0.190/klibc/send.c
multipath-tools/upstream/current/klibc-0.190/klibc/setegid.c
multipath-tools/upstream/current/klibc-0.190/klibc/setenv.c
multipath-tools/upstream/current/klibc-0.190/klibc/seteuid.c
multipath-tools/upstream/current/klibc-0.190/klibc/setpgrp.c
multipath-tools/upstream/current/klibc-0.190/klibc/sha1hash.c
multipath-tools/upstream/current/klibc-0.190/klibc/sigaction.c
multipath-tools/upstream/current/klibc-0.190/klibc/siglist.c
multipath-tools/upstream/current/klibc-0.190/klibc/siglongjmp.c
multipath-tools/upstream/current/klibc-0.190/klibc/sigpending.c
multipath-tools/upstream/current/klibc-0.190/klibc/sigprocmask.c
multipath-tools/upstream/current/klibc-0.190/klibc/sigsuspend.c
multipath-tools/upstream/current/klibc-0.190/klibc/sleep.c
multipath-tools/upstream/current/klibc-0.190/klibc/snprintf.c
multipath-tools/upstream/current/klibc-0.190/klibc/socketcalls.pl
multipath-tools/upstream/current/klibc-0.190/klibc/socketcommon.h
multipath-tools/upstream/current/klibc-0.190/klibc/sprintf.c
multipath-tools/upstream/current/klibc-0.190/klibc/srand48.c
multipath-tools/upstream/current/klibc-0.190/klibc/sscanf.c
multipath-tools/upstream/current/klibc-0.190/klibc/statfs.c
multipath-tools/upstream/current/klibc-0.190/klibc/strcasecmp.c
multipath-tools/upstream/current/klibc-0.190/klibc/strcat.c
multipath-tools/upstream/current/klibc-0.190/klibc/strchr.c
multipath-tools/upstream/current/klibc-0.190/klibc/strcmp.c
multipath-tools/upstream/current/klibc-0.190/klibc/strcpy.c
multipath-tools/upstream/current/klibc-0.190/klibc/strdup.c
multipath-tools/upstream/current/klibc-0.190/klibc/strerror.c
multipath-tools/upstream/current/klibc-0.190/klibc/strlcat.c
multipath-tools/upstream/current/klibc-0.190/klibc/strlcpy.c
multipath-tools/upstream/current/klibc-0.190/klibc/strlen.c
multipath-tools/upstream/current/klibc-0.190/klibc/strncasecmp.c
multipath-tools/upstream/current/klibc-0.190/klibc/strncat.c
multipath-tools/upstream/current/klibc-0.190/klibc/strncmp.c
multipath-tools/upstream/current/klibc-0.190/klibc/strncpy.c
multipath-tools/upstream/current/klibc-0.190/klibc/strndup.c
multipath-tools/upstream/current/klibc-0.190/klibc/strnlen.c
multipath-tools/upstream/current/klibc-0.190/klibc/strntoimax.c
multipath-tools/upstream/current/klibc-0.190/klibc/strntoumax.c
multipath-tools/upstream/current/klibc-0.190/klibc/strrchr.c
multipath-tools/upstream/current/klibc-0.190/klibc/strsep.c
multipath-tools/upstream/current/klibc-0.190/klibc/strspn.c
multipath-tools/upstream/current/klibc-0.190/klibc/strstr.c
multipath-tools/upstream/current/klibc-0.190/klibc/strtoimax.c
multipath-tools/upstream/current/klibc-0.190/klibc/strtok.c
multipath-tools/upstream/current/klibc-0.190/klibc/strtol.c
multipath-tools/upstream/current/klibc-0.190/klibc/strtoll.c
multipath-tools/upstream/current/klibc-0.190/klibc/strtotimespec.c
multipath-tools/upstream/current/klibc-0.190/klibc/strtotimeval.c
multipath-tools/upstream/current/klibc-0.190/klibc/strtotimex.c
multipath-tools/upstream/current/klibc-0.190/klibc/strtoul.c
multipath-tools/upstream/current/klibc-0.190/klibc/strtoull.c
multipath-tools/upstream/current/klibc-0.190/klibc/strtoumax.c
multipath-tools/upstream/current/klibc-0.190/klibc/strtox.c
multipath-tools/upstream/current/klibc-0.190/klibc/syscalls.pl
multipath-tools/upstream/current/klibc-0.190/klibc/syscommon.h
multipath-tools/upstream/current/klibc-0.190/klibc/syslog.c
multipath-tools/upstream/current/klibc-0.190/klibc/system.c
multipath-tools/upstream/current/klibc-0.190/klibc/sysv_signal.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/
multipath-tools/upstream/current/klibc-0.190/klibc/tests/environ.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/fcntl.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/getopttest.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/getpagesize.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/hello.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/idtest.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/malloctest.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/malloctest2.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/memstrtest.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/microhello.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/minihello.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/mmaptest.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/nfs_no_rpc.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/opentest.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/setenvtest.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/setjmptest.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/stat.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/statfs.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/strtoimax.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/strtotime.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/testrand48.c
multipath-tools/upstream/current/klibc-0.190/klibc/tests/testvsnp.c
multipath-tools/upstream/current/klibc-0.190/klibc/time.c
multipath-tools/upstream/current/klibc-0.190/klibc/umount.c
multipath-tools/upstream/current/klibc-0.190/klibc/unsetenv.c
multipath-tools/upstream/current/klibc-0.190/klibc/usleep.c
multipath-tools/upstream/current/klibc-0.190/klibc/utime.c
multipath-tools/upstream/current/klibc-0.190/klibc/vasprintf.c
multipath-tools/upstream/current/klibc-0.190/klibc/vfprintf.c
multipath-tools/upstream/current/klibc-0.190/klibc/vprintf.c
multipath-tools/upstream/current/klibc-0.190/klibc/vsnprintf.c
multipath-tools/upstream/current/klibc-0.190/klibc/vsprintf.c
multipath-tools/upstream/current/klibc-0.190/klibc/vsscanf.c
multipath-tools/upstream/current/klibc-0.190/klibc/wait.c
multipath-tools/upstream/current/klibc-0.190/klibc/wait3.c
multipath-tools/upstream/current/klibc-0.190/klibc/waitpid.c
multipath-tools/upstream/current/kpartx/
multipath-tools/upstream/current/kpartx/ChangeLog
multipath-tools/upstream/current/kpartx/Makefile
multipath-tools/upstream/current/kpartx/README
multipath-tools/upstream/current/kpartx/bsd.c
multipath-tools/upstream/current/kpartx/byteorder.h
multipath-tools/upstream/current/kpartx/crc32.c
multipath-tools/upstream/current/kpartx/crc32.h
multipath-tools/upstream/current/kpartx/dos.c
multipath-tools/upstream/current/kpartx/dos.h
multipath-tools/upstream/current/kpartx/efi.h
multipath-tools/upstream/current/kpartx/gpt.c
multipath-tools/upstream/current/kpartx/gpt.h
multipath-tools/upstream/current/kpartx/kpartx.8
multipath-tools/upstream/current/kpartx/kpartx.c
multipath-tools/upstream/current/kpartx/kpartx.h
multipath-tools/upstream/current/kpartx/loop.h
multipath-tools/upstream/current/kpartx/lopart.c
multipath-tools/upstream/current/kpartx/lopart.h
multipath-tools/upstream/current/kpartx/solaris.c
multipath-tools/upstream/current/kpartx/sysmacros.h
multipath-tools/upstream/current/kpartx/unixware.c
multipath-tools/upstream/current/kpartx/xstrncpy.c
multipath-tools/upstream/current/kpartx/xstrncpy.h
multipath-tools/upstream/current/libcheckers/
multipath-tools/upstream/current/libcheckers/Makefile
multipath-tools/upstream/current/libcheckers/checkers.c
multipath-tools/upstream/current/libcheckers/checkers.h
multipath-tools/upstream/current/libcheckers/emc_clariion.c
multipath-tools/upstream/current/libcheckers/path_state.h
multipath-tools/upstream/current/libcheckers/readsector0.c
multipath-tools/upstream/current/libcheckers/selector.c
multipath-tools/upstream/current/libcheckers/sg_include.h
multipath-tools/upstream/current/libcheckers/tur.c
multipath-tools/upstream/current/libdevmapper/
multipath-tools/upstream/current/libdevmapper/.exported_symbols
multipath-tools/upstream/current/libdevmapper/Makefile
multipath-tools/upstream/current/libdevmapper/include/
multipath-tools/upstream/current/libdevmapper/include/.symlinks
multipath-tools/upstream/current/libdevmapper/include/kdev_t.h
multipath-tools/upstream/current/libdevmapper/include/linux/
multipath-tools/upstream/current/libdevmapper/include/linux/.symlinks
multipath-tools/upstream/current/libdevmapper/include/list.h
multipath-tools/upstream/current/libdevmapper/include/log.h
multipath-tools/upstream/current/libdevmapper/ioctl/
multipath-tools/upstream/current/libdevmapper/ioctl/libdm-compat.h
multipath-tools/upstream/current/libdevmapper/ioctl/libdm-iface.c
multipath-tools/upstream/current/libdevmapper/ioctl/libdm-targets.h
multipath-tools/upstream/current/libdevmapper/kernel/
multipath-tools/upstream/current/libdevmapper/kernel/ioctl/
multipath-tools/upstream/current/libdevmapper/kernel/ioctl/dm-ioctl.h
multipath-tools/upstream/current/libdevmapper/libdevmapper-klibc.a (contents, props changed)
multipath-tools/upstream/current/libdevmapper/libdevmapper.h
multipath-tools/upstream/current/libdevmapper/libdm-common.c
multipath-tools/upstream/current/libdevmapper/libdm-common.h
multipath-tools/upstream/current/libmultipath/
multipath-tools/upstream/current/libmultipath/Makefile
multipath-tools/upstream/current/libmultipath/blacklist.c
multipath-tools/upstream/current/libmultipath/blacklist.h
multipath-tools/upstream/current/libmultipath/callout.c
multipath-tools/upstream/current/libmultipath/callout.h
multipath-tools/upstream/current/libmultipath/defaults.h
multipath-tools/upstream/current/libmultipath/devmapper.c
multipath-tools/upstream/current/libmultipath/devmapper.h
multipath-tools/upstream/current/libmultipath/hwtable.c
multipath-tools/upstream/current/libmultipath/hwtable.h
multipath-tools/upstream/current/libmultipath/memory.c
multipath-tools/upstream/current/libmultipath/memory.h
multipath-tools/upstream/current/libmultipath/parser.c
multipath-tools/upstream/current/libmultipath/parser.h
multipath-tools/upstream/current/libmultipath/safe_printf.h
multipath-tools/upstream/current/libmultipath/structs.h
multipath-tools/upstream/current/libmultipath/sysfs_devinfo.c
multipath-tools/upstream/current/libmultipath/sysfs_devinfo.h
multipath-tools/upstream/current/libmultipath/util.c
multipath-tools/upstream/current/libmultipath/util.h
multipath-tools/upstream/current/libmultipath/vector.c
multipath-tools/upstream/current/libmultipath/vector.h
multipath-tools/upstream/current/libsysfs/
multipath-tools/upstream/current/libsysfs/LGPL
multipath-tools/upstream/current/libsysfs/Makefile
multipath-tools/upstream/current/libsysfs/dlist.c
multipath-tools/upstream/current/libsysfs/libsysfs-klibc.a (contents, props changed)
multipath-tools/upstream/current/libsysfs/sysfs/
multipath-tools/upstream/current/libsysfs/sysfs.h
multipath-tools/upstream/current/libsysfs/sysfs/dlist.h
multipath-tools/upstream/current/libsysfs/sysfs/libsysfs.h
multipath-tools/upstream/current/libsysfs/sysfs_dir.c
multipath-tools/upstream/current/libsysfs/sysfs_utils.c
multipath-tools/upstream/current/multipath/
multipath-tools/upstream/current/multipath-tools.spec.in
multipath-tools/upstream/current/multipath.conf.annotated
multipath-tools/upstream/current/multipath.conf.synthetic
multipath-tools/upstream/current/multipath/.main.c.swo (contents, props changed)
multipath-tools/upstream/current/multipath/.main.c.swp (contents, props changed)
multipath-tools/upstream/current/multipath/01_udev (contents, props changed)
multipath-tools/upstream/current/multipath/02_multipath (contents, props changed)
multipath-tools/upstream/current/multipath/Makefile
multipath-tools/upstream/current/multipath/config.h
multipath-tools/upstream/current/multipath/debug.h
multipath-tools/upstream/current/multipath/dev_t.h
multipath-tools/upstream/current/multipath/devinfo.c
multipath-tools/upstream/current/multipath/devinfo.h
multipath-tools/upstream/current/multipath/dict.c
multipath-tools/upstream/current/multipath/dict.h
multipath-tools/upstream/current/multipath/dmparser.c
multipath-tools/upstream/current/multipath/dmparser.h
multipath-tools/upstream/current/multipath/main.c
multipath-tools/upstream/current/multipath/main.h
multipath-tools/upstream/current/multipath/multipath.8
multipath-tools/upstream/current/multipath/multipath.dev
multipath-tools/upstream/current/multipath/multipath.rules
multipath-tools/upstream/current/multipath/pgpolicies.c
multipath-tools/upstream/current/multipath/pgpolicies.h
multipath-tools/upstream/current/multipath/propsel.c
multipath-tools/upstream/current/multipath/propsel.h
multipath-tools/upstream/current/multipath/sg_include.h
multipath-tools/upstream/current/multipathd/
multipath-tools/upstream/current/multipathd/Makefile
multipath-tools/upstream/current/multipathd/clone_platform.h
multipath-tools/upstream/current/multipathd/copy.c
multipath-tools/upstream/current/multipathd/copy.h
multipath-tools/upstream/current/multipathd/devinfo.c
multipath-tools/upstream/current/multipathd/devinfo.h
multipath-tools/upstream/current/multipathd/dict.c
multipath-tools/upstream/current/multipathd/dict.h
multipath-tools/upstream/current/multipathd/main.c
multipath-tools/upstream/current/multipathd/main.h
multipath-tools/upstream/current/multipathd/multipathd.8
multipath-tools/upstream/current/multipathd/multipathd.init (contents, props changed)
multipath-tools/upstream/current/path_priority/
multipath-tools/upstream/current/path_priority/Makefile
multipath-tools/upstream/current/path_priority/pp_balance_units.c
multipath-tools/upstream/current/path_priority/pp_random (contents, props changed)
Log:
Load multipath-tools-0.4.2 into /multipath-tools/upstream/current.
Added: multipath-tools/upstream/current/.indent.pro
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/.indent.pro Fri Mar 4 08:05:19 2005
@@ -0,0 +1,8 @@
+-kr
+-i8
+-ts8
+-sob
+-l80
+-ss
+-bs
+-psl
Added: multipath-tools/upstream/current/AUTHOR
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/AUTHOR Fri Mar 4 08:05:19 2005
@@ -0,0 +1 @@
+Christophe Varoqui, <christophe.varoqui at free.fr>
Added: multipath-tools/upstream/current/COPYING
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/COPYING Fri Mar 4 08:05:19 2005
@@ -0,0 +1,483 @@
+
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL. It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it. You can use it for
+your libraries, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library. If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software. To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+ Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs. This
+license, the GNU Library General Public License, applies to certain
+designated libraries. This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+ The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it. Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program. However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+ Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries. We
+concluded that weaker conditions might promote sharing better.
+
+ However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves. This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them. (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.) The hope is that this
+will lead to faster development of free libraries.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+ Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License"). Each licensee is
+addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ c) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ d) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library 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
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
Added: multipath-tools/upstream/current/ChangeLog
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/ChangeLog Fri Mar 4 08:05:19 2005
@@ -0,0 +1,854 @@
+2005-01-23 multipath-tools-0.4.2
+
+ * [libmultipath] add symmetrix controler family to the
+ hwtable. Edward Goggin, EMC
+ * [libmultipath] factorize core structs (path, ...)
+ and defaults (pidfile, configfile, ...). Convert
+ callers.
+ * [multipath] fix dmparser to properly fetch non-default
+ hwhandler. Edward Goggin, EMC
+ * [multipath] fix devt2devname matching 8:1 with 8:10
+ for example. Edward Goggin, EMC
+ * [multipath] switch_pg upon devmap create or reload
+ Noticed by Ake.
+ * [libmultipath] move find_hw() the library. Convert
+ users. Now multipathd understand '*' as a product
+ string
+ * [multipath] dissaemble_map() fix to avoid to
+ interpret 'D' as a disable PG (not 'F'). Edward
+ Goggin, EMC
+ * [multipath] find_path() fix to avoid matching 8:1
+ with 8:10 for example. Edward Goggin, EMC
+ * [libmultipath] move some sysfs fetching routines
+ to library, under sysfs_devinfo.[ch]. Convert
+ callers.
+ * [multipath] fix -v0 : avoids the daemon waiting
+ for the initial multipath run to complete, which
+ will never happen because of a flooded pipe
+ * [multipathd] add scsi_id to default binvec
+ * [libmultipath] move hwtable related logic to the
+ library. Convert multipath and multipathd
+ * [multipath] move first blacklist call down after
+ setup_default_blist()
+ * [libmultipath] move basename() to the lib. Convert
+ multipath and multipathd.
+ * [libmultipath] move blacklist related logic to the
+ library. Convert multipath and multipathd
+ * [multipath] fix bug in the default hardware table
+ matching logic (Lars M-B, Suse)
+ * [multipath] allow "*" as scsi model string wildcard
+ (Lars M-B, Suse)
+ * [multipath] provide a macro to fill all hwe fields,
+ use it to declare Clariion models (Lars M-B, Suse)
+ * [multipath] use DEFAULT_GETUID instead of hardcoded
+ *and* incorrect "/bin/scsi_id -g -s" (Lars M-B, Suse)
+ * [multipath] kill superfluous suspend before table
+ reload. The code was unsafe, as spotted by Edward
+ Goggin (EMC)
+ * [multipath] exit early if device parameter is
+ blacklisted
+ * [multipath] don't check for prefix in initrd's
+ multipath.dev : this is the tool responsability to
+ exit early based on its blacklist.
+ * [multipath] don't signal the daemon in initrd
+ (Guido Guenther, Debian tracker)
+ * [multipath] better fail to run kpartx in initrd
+ than crashing the whole system. So don't sleep
+ waiting for udev to create the DM node. Maybe udev
+ has made progress I this regard ... (noticed by
+ Paul Wagland, Debian tracker)
+ * [multipath] don't reinstate when listing, ie list
+ implies dry_run
+ * [checkers] fix the emc checker (Hergen Lange)
+ * [multipath] node_name fetching shouldn't exit on
+ error. FC SAN are not the only multipathed context
+ (noticed by Ramesh Caushik)
+
+2004-12-20 multipath-tools-0.4.1
+
+ * [multipath] bump SERIAL_SIZE to 19
+ * [multipath] add a new group_by_node_name pgpolicy
+ * [multipath] move getopt policy parser to
+ get_policy_id()
+ * [multipath] remove get_evpd_wwid()
+ * [checkers] fix the wwn_set test in emc checker
+ (Hergen Lange)
+ * [checkers] treat the emc checker in the name to
+ index translator function (Hergen Lange)
+ * [multipath] print to stderr DM unmet requirement
+ (Guido Guenther)
+ * [multipath] fix realloc return value store not
+ propagated to caller by merge_word() (Nicola Ranaldo)
+
+2004-12-10 multipath-tools-0.4.0
+
+ * [checkers] forgot to return back to caller the newly
+ allocated context. Lead to fd leak notably.
+ * [checkers] heavy check logic fix
+ * [checkers] really malloc the checker context size,
+ not the pointer size (stupidy may kill)
+ * [multipathd] check more sysfs calls return values
+ * [multipathd] search for sysfs mount point only once,
+ not on each updatepaths() iteration
+ * [multipathd] plug (char *) leak in the daemon
+ * [multipath] change pgcmp logic : we want to reload a
+ map only if a path is in computed map but not in cur
+ map (ie accept to load a map if it brings more paths)
+ * [multipath] undust coalesce_paths()
+ * [multipath] don't print unchanged multipath
+ * [multipath] store the action to take in the multipath
+ struct
+ * [multipath] print mp size with kB, MB, GB or TB units
+ * [multipath] compilation fix for merge_words() (Andy)
+ * [multipath] don't feed the kernel DM maps with paths of
+ different sizes : DM fails and we end up with an empty
+ map ... not fun
+ * [multipath] cover a new corner case : path listed in
+ status string but disappeared from sysfs
+ * [multipath] remove the "-D" command line flag : now
+ we can pass major:minor directly as last argument, like
+ device names or device map names. Update multipathd
+ accordingly.
+ * [multipath] try reinstate again paths after a switchpg
+ * [multipath] reinstate condition change :
+
+2004-12-05 multipath-tools-0.3.9
+
+ * [multipath] add a "-l" flag to list the current
+ multipath maps and their status info
+ * [priority] zalloc controler to avoid random path_count
+ at allocation time
+ * [multipath] add configlet pointers in struct multipath
+ to avoid searching for an entry over and over again
+ * [multipath] new reinstate policy : on multipath exec,
+ reinstate all failed paths the checkers report as ready
+ if they belong to enabled path groups (not disabled, not
+ active path group)
+ * [multipath] fork a print_mp() out of print_all_mp()
+ * [multipath] introduce PG priority, which is the sum of
+ its path priorities. Set first_pg in the map string to
+ the highest prio PG index.
+ * [multipath] assemble maps scaning PG top down now that
+ PG vector is unsorted
+ * [multipath] move select_*() to propsel.c
+ * [multipath] move devinfo() to devinfo.c
+ * [multipath] move h/b/t/l fetching to sysfs_devinfo()
+ * [multipath] move devt2devname() to devinfo.c so we can
+ use it from dmparser.c too
+ * [multipath] introduce select_alias() and clarify a bit
+ of code
+ * [multipath] don't sort PG anymore. We want the map as
+ static as possible.
+ * [multipath] fix a segfault in apply_format() triggered
+ when no config file found.
+ * [multipath] kill unused vars all over the place
+ * [multipath] add a struct pathgroup in struct multipath
+ Store the pathvec in it. We now have a place to store
+ PG status, etc ...
+ * [multipath] new dmparser.c, with disassemble_map(),
+ disassemble_status()
+ * [multipath] suppress *selector_args keywords. Merge
+ in the selector string. Update config file templates.
+
+2004-11-26 multipath-tools-0.3.8
+
+ * [priority] teach multipath to read callout keywords
+ formatted as /sbin/scsi_id -g -u -s /block/%n
+ Apply one substitutions out of :
+ * %n : blockdev basename (ie sdb)
+ * %d : blockdev major:minor string (ie 8:16)
+ update sample config files
+ * [priority] fix find_controler(). Now works, verified
+ on IBM T200 at OSDL (thanks again, Dave). Add to the
+ main build process
+ * [multipath] add a controler specific "prio_callout"
+ keyword. Noticed by Ake
+ * [multipath] normalize the debug ouput
+ * [multipath] add select_getuid(). De-spaghetti
+ devinfo() thanks to that helper.
+ * [libmultipath] add VECTOR_LAST_SLOT macro.
+ multipath/dict.h now use it heavily.
+ * [multipath] policies selectors speedup and cleanup
+ (pgpolicy, features, hwhandler, selector)
+ * [multipath] new "flush" command flag
+ * [libmultipath] add dm_type() and dm_flush_maps()
+ * [multipath] move dm_get_map() to libmultipath
+ * [multipath] rename iopolicy to pgpolicy everywhere.
+ Dual terminology was getting confusing.
+ * [multipath] assemble_map() to always set next_pg to 1
+ for now.
+ * [multipath] update config file to show new keywords.
+ Add an IBM array tested at OSDL.
+ * [multipath] fork select_iopolicy() from setup_map()
+ * [multipath] introduce select_features() and
+ select_hwhandler(). Should merge select_* one day ...
+ * [multipath] add features and hardware_handler keywords
+ and use them in the map setup
+ * [build] make clean really clean. Noticed by Dave Olien,
+ OSDL
+ * [multipath] group_by_serial bugfix
+ * [multipath] dm_addmap() return value fix. Now multipath
+ really creates the maps
+ * [multipath] try dm_log_init_verbose() instead of dup()
+ + close() to silence libdevmapper (Ake at umu)
+ * [libcheckers] remove checkpath() wrapper, obsoleted by
+ the "fd in context" changes
+ * [multipathd] let pathcheckers allocate their context.
+ No more over or unneeded allocation. Suggested by Lars,
+ Suse
+ * [multipathd] store the pathcheckers fd in their context.
+ No more open / close on each check. Suggested by Lars,
+ Suse
+
+2004-11-05 multipath-tools-0.3.7
+
+ * [multipathd] fix off by one memory allocation (Hannes,
+ Suse)
+ * [multipathd] introduce a default callout handler that
+ just remembers to put the callout in ramfs, even if the
+ daemon has no direct use of them. multipath need some
+ that where forgotten, so parse them and use that default
+ handler.
+ * [libcheckers] emc_clariion checker update (Lars, Suse)
+ * [build] exit build process on failure (Lars, Suse)
+ * [kpartx] exit early if DM prereq not met
+ * [multipath] exit early if DM prereq not met
+ * [libmultipath] new dm_prereq() fn to check out if all DM
+ prerequisites are met
+ * [libmultipath] move callout.[ch] function in there.
+ multipath and multipathd impacted
+ * [libmultipath] move dm_* function in there. kpartx,
+ multipath are impacted
+ * [priority] pp_balance_lun should use DM_DEVICE_TABLE ioctl
+ instead of DM_DEVICE_STATUS to find out paths from the
+ primary path groups.
+ * [klibc] drop in "Stable" version 0.190
+ * [build] add manpages for kpartx and multipathd (Patrick
+ Caulfield)
+ * [build] use system's sysfs for multipathd linking
+ * [build] make glibc the default build
+ * [build] "make BUILD=klibc" is enough, deprecate the
+ "make BUILD=klibc klibc" synthax
+
+2004-10-30 multipath-tools-0.3.6
+
+ * Patrick Caulfield took over debian packaging. Showing
+ evident expertise, his first wish is to see debian/
+ disappear. :) So be it.
+ * [libmultipath] add a vector_foreach_slot macro. Still
+ needs an iterator but saves 1 line per loop occurence and
+ tame this UPPERCASE MACROS bad taste.
+ * [multipathd] don't load sg anymore on multipathd startup
+ * [multipathd] change killall for kill `cat $PIDFILE` in
+ init script (Jaime Peñalba & Cesar Solera)
+ * [multipathd] the fork fallback was borked (just exiting)
+ noticed by Jaime Peñalba & Cesar Solera
+ * [multipathd] try without the FLOATING_STACKS flag. Does
+ it matter anyway ?
+ * [multipathd] merge clone_platform.h from LTP and cover
+ the hppa special case.
+ * [multipath] since we will be able to create a devmap with
+ paths too small, don't rely anymore on the first path's
+ size blindly : verify the path is up, before assigning its
+ size to the multipath
+ * [priority] add a path priority fetcher to balance LU accross
+ controlers based on the controler serial detection. Untested
+ but provides a good example of what can be done with the
+ priority framework.
+ * [priority] create subdir and drop a test pp_random
+ * [multipath] add dev_t reporting to print_path() to ease
+ devmap decoding by humans
+ * [multipath] change default path priority to 1
+ * [multipath] add wits to the sort_by_prio policy, so that
+ sort_pathvec_by_prio() is now useless. Remove it.
+ * [multipath] invert sort_pg_by_summed_prio sort order :
+ highest prio leftmost
+ * [libmultipath] add vector_del_slot
+ * revert multipath.rules change : devmap_name still takes
+ "major minor" and not "major:minor" as argument
+ * Makefile refinement : you can now enter any tool directory
+ and build from here, deps are solved
+
+2004-10-26 multipath-tools-0.3.5
+
+ * [multipathd] fix broken test for path going up or shaky
+ that kept executing multipath when it shouldn't
+ * change multipath.dev to exit early when udev' DEVNAME is
+ a devmap (/dev/dm-*). This avoids a recursion case when
+ the kernel devmapper keeps removing a map after multipath
+ configures it.
+ * change multipath.rules to follow the new -D synthax
+ * [multipath] "-D major minor" synthax changed to
+ "-D major:minor" to match the sysfs attribute value.
+ This change removes a few translations in multipath and
+ multipathd.
+ * [multipath] fix segfault in test if conf->dev is a devmap
+ (the one forwarded by MikeAnd)
+ * SG_IO ioctl seem to work in lk 2.6.10+, so remove all sg
+ device knowledge and advertise (here) the new dependency.
+ * [multipath] remove unused do_tur()
+ * [multipath] fix sort_pg_by_summed_prio(), and don't add up
+ failed path priority
+
+2004-10-26 multipath-tools-0.3.4
+
+ * [multipathd] exec multipath precisely : pass in the path
+ or the devmap to update. No more full reconfiguration, and
+ really use the reinstate feature of multipath.
+ * [multipathd] check all paths, not only failed ones. Path
+ checker now trigger on state change (formerly triggred on
+ state == UP condition)
+ * [multipathd] incremental updatepaths() instead of scrap /
+ refresh all logic.
+ * [multipathd] path checkers now take *msg and *context
+ params. consensus w/ lmb at suse. tur.c modified as example
+ * [multipath] assemble maps in PG vector descending order to
+ fit the layered policies design
+ * [multipath] stop playing with strings in pgpolicies, as it
+ uses more memory and looses info for no gain
+ * [multipath] remove lk2.4 scsi ioctl scsi_type remnant
+ * [multipath] layered pgpolicies : (see pgpolicies.c)
+ * group_by_status
+ * group_by_serial | multibus | failover | group_by_prio
+ * sort_pg_by_summed_prio
+ thus remove duplicated failedpath logic in pgpolicies
+ * [libmultipath] add vector_insert_slot
+ * [checkers] framework for arbitrate checkers return values
+ * [multipathd] scrap yet another reinvented wheel in the
+ name of the LOG macro : learn the existance of setloglevel
+ and LOG_UPTO macro
+ * glibc make with "make BUILD=glibc", asked by lmb at suse
+
+2004-10-20 multipath-tools-0.3.3
+
+ * [checkers] add the emc_clariion path checker (lmb at Suse)
+ * [multipath] introduce safe_snprintf macro to complement the
+ safe_sprintf. Needed to cover the sizeof(pointer) cases
+ pointed by Dave Olien at OSDL
+ * [multipath] move to the common libchecker framework and
+ activate the selector
+ * [multipath] fix an iopolicy selector bug (initialized lun
+ iopolicy overrode controler-wide iopolicy)
+ * [multipathd] cleanly separate out the checker selector, as
+ done with iopolicy selector
+ * [multipathd] move out the checkers into a common libcheckers
+ * [multipath] fix the anti-parallel-exec logic : use a write
+ lease for the task. From Dave Olien at osdl.
+ * [multipath] fix reinstate : pass a devt, not a devname
+
+2004-10-16 multipath-tools-0.3.2
+
+ * [multipath] add path reinstate logic :
+ * if a path is given as multipath arg
+ * if the map containing that path already exists
+ * if this map is the same as the that would be
+ created by this multipath run
+ * THEN reinstate the path
+ multipathd is is thus unchanged, while now supporting
+ reinstate
+ * audit and ensafe all sprintf usage
+ * [multipath] fix the annoying \n after each dev_t in
+ params string reporting
+ * [multipath] print out devmaps in "-v2 -d" mode
+ * [kpartx] bump up the params string size (lmb at suse)
+ * [kpartx] replace sprintf by snprintf (lmb at suse)
+ * [kpartx] initialize some more vars (lmb at suse)
+ * [multipath] mp->pg == NULL safety net before calling
+ assemble_map() (for Andy who happen to hit the bug)
+ * [multipath] last rampant bug in map CREATE or UPDATE switch
+ logic due to the device alias feature
+ * [kpartx] zeroe "struct slice all" (lmb at suse)
+
+2004-10-11 multipath-tools-0.3.1
+
+ * [kpartx] move back to getopt, originaly removed from the
+ original partx because of lack of implementation in klibc
+ * [kpartx] don't map extended partitions
+ * [kpartx] add a -p command flag to allow admin to force a
+ delimiting string between disk name and part number. When
+ specified always use it, when unspecified use 'p' as a delim
+ when last char of disk name is a digit, NUL otherwise.
+ * [kpartx] clean up
+ * bump klibc to 0.182
+ * one step further : use klibc MCONFIG for all klibc specific
+ FLAGS definitions, ie massive Makefile.inc cleanup
+ * follow the klibc compilation rules by appending its OPTFLAGS
+ to multipath-tools' CFLAGS. This corrects the segfaults seen
+ on i386 where klibc is built with regparm=3 and tools are not
+ * [multipathd] fall back to fork when clone not available
+ like in Debian Woody
+ * [kpartx] move .start and .size from uint to ulong (Ake)
+ * briefly document system-disk-on-multipath in the FAQ file
+
+2004-10-06 multipath-tools-0.3.0
+
+ * first cut at making scripts to create multipath-aware initrds
+ those scripts are tested on Debian SID, and must be copied into
+ /etc/mkinitrd/scripts. it works here.
+ * [multipath] verify presence of the /sys/block/... node before
+ reading sysfs attributes. Avoids libsysfs and scsi_id stderr
+ garbage
+ * [multipath] move down the stderr close (Ake Sandgren at umu.se)
+ * [multipath] don't care about 0-sized mp (Ake Sandgren at umu.se)
+ * [multipath] bump mp size field to ulong (Ake Sandgren at umu.se)
+ * [multipath] replace quiet/verbose flags by a verbosity one.
+ introduce a new verbosity level : 1 == print only devmap names
+ thus we can feed kpartx with that output
+ * [multipath] update man page to reflect the hotplug.d -> dev.d
+ transition and replace the obsolete group_by_tur policy by the
+ forgotten group_by_prio
+ * [multipath] provide a /etc/udev/rules.d/multipath.rules for
+ multipath devices naming. Cleaner than the previously suggested
+ rule addition in the main udev.rules
+ * [multipath] move out of hotplug.d to dev.d : kill synchronisation
+ problems between device node creation and multipath execution.
+ Incidentally the unfriendly $DEVPATH param become a friendly
+ $DEVNAME (simply /dev/sdb)
+ * [multipath] rework the iopolicies name-to-id & id-to-name
+ translations. kills the last compilation warning here too
+ * [kpartx] kill last compilation warnings
+ * bump klibc to 0.181
+ * add the debian/ packaging dir (make deb)
+ * prototype __clone & __clone2
+
+2004-09-24 multipath-tools-0.2.9
+
+ * [multipathd] finally tame the clone compilation glitch on IA64
+ move from sys_clone to __clone / __clone2
+ * [kpartx] rework from Stephan Bader, IBM :
+ * handle s390x arch
+ * endianness fixes
+ * push the partname string size to handle wwwids
+ * quieten implicit cast warnings
+ * [multipath] add an 'alias' multipath keyword for friendlier device
+ names. This was "asked" by OSDL' CGL board of secret reviewers
+ * [multipath] last pass with JBOD and parallel SCSI support :
+ hard-code scsi_id as a fallback when disk strings doesn't match
+ any hwtable entry
+ * [multipath & multipathd] change the parser to not coalesce
+ consecutive spaces (Patrick Mansfield)
+ * [multipath] remove the [UN]: output prefix, so that stdout can be
+ easily fed to a tool like dmsetup
+ * [multipathd] DEBUG=3 logs more readable/usefull
+ * [multipathd] add a multipath_tool config keyword
+ * [multipathd] move to execute_program() like multipath already did
+ * [multipath] don't print the "no path" msg in quiet mode
+ * [multipathd] include linux/unistd.h for _syscall2
+ definition on RedHat systems. Remove superfluous
+ asm/unistd.h include
+ * [libsysfs] forked : last version uses mntent, which
+ klibc doesn't provide. That, plus the fact we use
+ only 1/3 of the lib, pushed me to freeze the version
+ and strip all unused stuff.
+ * [multipathd] prepare_namespace() cleanup : no more "multipath"
+ special casing since we push it to binvec vector, like the other
+ callouts detected in the config file.
+
+2004-08-13 multipath-tools-0.2.8
+
+ * [multipathd] setsched prio to RT
+ * [multipath] massive include cleanup
+ * [multipath] add a "default_prio_callout" keyword
+ first user will be SPC-3 ALUA priority field fetcher
+ from IBM
+ * [multipath] reenable stdout on some error paths
+ * [build] spilt KERNEL_DIR into KERNEL_SOURCE &
+ KERNEL_BUILD as per 2.6 and SuSe convention
+ * [klibc] kill warnings due to awk parsing wrong locale in
+ arch/i386/MCONFIG
+ * [multipath] implement a generic group_by_prio pgpolicy
+ * [multipath] fix the broken failover pgpolicy
+
+2004-07-24 multipath-tools-0.2.7
+
+ * [multipath] args parser moved to getopt
+ <genanr at emsphone.com>
+ * [multipath] zero conf->hotplugdev at allocation
+ <genanr at emsphone.com>
+ * [multipath] clean up failed devmap creation attempt
+ * [libs] update to libdevmapper 1.00.19
+ * [multipath] framework for claimed device skipping
+ still lacks a reliable way to know if the device is
+ claimed and by who (fs, swap, md, dm, ...). If you
+ think it is valid to let libdevmapper hit the wall,
+ please speak up and tell so.
+ * [multipath] shut down stderr when calling into libdm
+ * [multipath] reformat the verbose output
+ * [multipath] framework for path priority handling (ALUA)
+ * [multipath] kill all reference to group_by_tur
+ * [multipath] integrate path state logic into multibus &
+ failover pgpolicies. This obsoletes the group_by_tur one
+ which is now the same as multibus.
+ * [multipath] zalloc mp structs to avoid garbage in ->size
+ * bump version requisite for scsi_id to 0.6 to support the new
+ '-u' flag (s/ /_/ for proper JBOD device map naming)
+ * [multipath] correct the for(;;) limits to accept 1-slot
+ pathvecs
+ * [multipath] push WWID_SIZE to 64 char (scsi_id w/ JBODs)
+ * [multipath] add a exit_tool() wrapper fn for runfile unlink
+ * [multipath] add a "default_path_grouping_policy" keyword in the
+ "defaults" block.
+ * [multipath] add a "default_getuid_callout" keyword in the
+ "defaults" block. Now multipath is going to work with JBODs
+ * [multipath] fix segfault when pathvec is empty after
+ get_pathvec()
+ * move to template based specfile to avoid regular version skew
+
+2004-07-16 multipath-tools-0.2.6
+
+ * [multipathd] implement the system-disk-on-SAN safety net
+ * [multipathd] add exit_daemon() wrapper function
+ * [multipathd] mlockall() all daemon threads
+ * [multipath] fix a bug in the mp_iopolicy_handler that kept
+ the iopolicy per LUN override from working
+ * [multipath] display the tur bit value in print_path
+ as requested by SUN
+ * try to open /$udev/reverse/$major:$minor before falling back
+ to mknod
+ * add "udev_dir" to the defaults block in the config file
+ * merge "daemon" & "device_maps" config blocks into a new
+ "defaults" block
+ * [multipath] properly comment the config file
+ * [multipath] generalize the dbg() macro usage
+ Makefile now has a DEBUG flag
+ * [multipath] move to callout based WWID fetching. Default to
+ scsi_id callout. I merged execute_program from udev for that
+ (so credit goes to GregKH)
+ * [multipath] get rid of "devnodes in /dev" assumption
+ ie move to "maj:min" device mapper target synthax
+
+2004-07-10 multipath-tools-0.2.5
+
+ * [multipathd] fix misbehaviour noted by <genanr at emsphone.com>
+ improper tar directive in Makefile on some systems
+ * [multipathd] fix bug noted by <genanr at emsphone.com>
+ get_devmaps fills a private vector and forget to pass its
+ address to caller
+ * [multipath] extend EVPD 0x83 id fetching logic.
+ Code borrowed from scsi_id (thanks goes to Patrick
+ Mansfield @IBM) and merged by Hannes Reinecke @SUSE
+ * [multipathd] fix regression noted by <genanr at emsphone.com>
+ (segfault when no config file)
+
+2004-06-20 multipath-tools-0.2.4
+
+ * [multipathd] break free from system's libsysfs for now
+ as it is not that common these days
+ * [multipath] introduce per LUN policies in the config
+ file : path_grouping_policy, path_selector and
+ path_selector_args are supported.
+ See updated sample config file.
+ * [multipath] move ->iopolicy to multipath struct (from
+ path struct)
+ * [multipath] fill the voids left in the config file with
+ defaults
+ * [multipath] group config & flags in a global struct *
+ * [multipath] fix segfault when no config file (was a
+ regression since hwtable vectorisation in 0.2.2)
+ * [multipath] default path selector override in config file
+ * [multipath] don't play with strings in pgpolicies, leave
+ that to a new assemble_map fn. policies now use vector
+ * [multipathd] compilation fix for gentoo (Franck Denis)
+ * [multipath] strcmp fix (Franck Denis)
+
+2004-06-14 multipath-tools-0.2.3
+
+ * [multipath] group_by_serial try to be smart with LUN
+ balancing across controlers (for STK / LSI) :
+ 1st multipath : 1st pg made of path through 1st controler
+ 2nd multipath : 1st pg made of path through 2nd controler
+ 3rd multipath : 1st pg made of path through 1st controler
+ ...
+ * [multipath] drop .pindex[] in struct multipath in favor
+ of a *paths vector : much cleaner
+ * [multipath] fix group_by_serial pgpolicy broken by
+ vectorisation in 0.2.2
+ * add a StorageTek array in the sample multipath.conf
+ * [multipathd] strcmp fix from Franck Denis
+ * [multipathd] convert to vector api
+ * [multipathd] add a configfile option for path checking
+ interval. See sample configfile for synthax.
+
+2004-06-07 multipath-tools-0.2.2
+
+ * [multipath] leave out 2.4 compat code. Is there
+ interest anyway ?
+ * [multipath] convert all_paths table to vector api.
+ Rename to pathvec. Get rid of max_devs
+ * [multipath] convert mp table to vector api
+ * convert blacklist to vector api
+ * 2.6.7-rc? adds _user annotations to scsi/sg.h, causing
+ compilation breakage. Add a "#define _user" in all
+ sg_include.h (and remove cruft)
+ * merge a real parser (from keepalived) courtesy of
+ Alexandre Cassen. Now multipath and multipathd share a
+ config file. This comes with a nice vector lib.
+ * devnode blacklist moved from hardcoded to config file
+ * Guy Coates noted -O2 CFLAGS lead to multipathd crashes
+ on IA64. Remove the needless optimisation for now.
+
+2004-06-05 multipath-tools-0.2.1
+
+ * [multipath] add a flag to inihibit the final SIGHUP to
+ multipathd. Needed to avoid recursion with the correction
+ below
+ * [multipathd] devmap event now triggers a multipath exec
+ in addition to the usual updatepaths()
+ * [multipathd] move checkers from sg_io on BLK onto CHR
+ readsector0 goes from read to sg_read
+ * [multipathd] rely on sysfs for failedpaths enum and no
+ longer on the device mapper
+ * [multipathd] convert get_lun_strings from ioctl to sysfs
+ so we can benefit from strings persistency for failed
+ paths
+ * [multipath] readconfig() to take only 8 char from vendor
+ string (ake)
+ * [multipath] remove unecessery and wrong getuid == NULL
+ check from devinfo() (ake)
+ * [multipathd] make readsector0 open path O_DIRECT
+ * [multipathd] sizeof(path) -> sizeof(struct path) (MikeC)
+ * [Makefile] don't try to install and uninstall libs
+ * [devmap_name] kill the wrong trailing '\n'
+ (Mike Christie)
+ * [kpartx] works with device nodes outside /dev
+ * [kpartx] correctly display the delimiter in partition
+ name outputs
+
+2004-05-17 multipath-tools-0.2.0
+
+ * change the default klibc by greg's :
+ corrects the segfaults reported by Ling Hwa Hing
+
+2004-05-16 multipath-tools-0.1.9
+
+ * break free from udev : package klibc and libsysfs
+ * add a spec file and a "make rpm" rule
+ * pensum on klibc changes needed :
+ * mmap.c & fork.c : invert includes
+ * make clean wipes .*.d
+ * auto create the linux symlink
+ * remove tools and specfiles (files and Makefile
+ targets)
+
+2004-05-15 multipath-tools-0.1.8
+
+ * Makefiles cleanup and factorisation
+ * Compilation fixes for non-ix86 archs, tested on x86_64
+ * strip execs harder for a 10% size reduction
+ * blacklist /dev/fd* and /dev/loop*
+ * dmadm works with sysfs nodes with '!' (cciss for ex)
+
+2004-05-10 multipath-tools-0.1.7
+
+ * bugfixes from Andy <genanr at emsphone.com> :
+ * read the last line of the config file
+ * add an entry for the 3PARData storage ctlrs
+ * read the last char of vendor and model strings
+
+2004-04-25 multipath-tools-0.1.6
+
+ * add the dmadm WIP tool (read MD superblocks and create
+ corresponding devmaps when possible)
+ * plug fd leak in TUR path checker
+
+2004-03-25 multipath-tools-0.1.5
+
+ * kpartx to manage the nested bdevs as /dev/cciss/c0d0.
+ parts are named sysfs style : cciss!c0d0p*
+ * kpartx loop support
+ * kpartx do DM updates if part maps already present
+ * merge kpartx for partitioned multipath support
+ * add get_null_uid to getuid methods. assign it the "0" index
+ devices with this getuid are thus ignored by multipath.
+ warning : change /etc/multipath.conf (get_evpd_wwid == 1)
+ * mv all_scsi_ids out of the 2.6 code path, into the 2.4 one
+ * unlink runfile on malloc exit path
+ * update multipath manpage (MikeC)
+
+2004-03-17 multipath-tools-0.1.4
+
+ * multipath clean up
+ * split default hw table in hwtable.h
+ * split grouping policies in pgpolocies.c
+ * pass *mp to setup_map instead of mp[]+index
+ * ensure defhwtable is used if /etc/multipath.conf is buggy
+ * hwtable is not global anymore
+ * unlink the runfile in various error paths
+
+2004-03-13 multipath-tools-0.1.3
+
+ * multipath config tool now has a config file parser
+ (did I say I make the ugliest parsers ?)
+ * example multipath.conf to put in /etc (manualy)
+
+2004-03-12 multipath-tools-0.1.2
+
+ * detach the per devmap waiter threads
+ * set the thread stack size to lower limits
+ (VSZ down to 4MB from 85 MB here)
+
+2004-03-06 multipath-tools-0.1.1
+
+ * include dlist.h in multipath main.c (PM Hahn)
+ * typo in hotplug script (PM Hahn)
+ * pass -9 opt to gzip for manpages (PM Hahn)
+
+2004-03-05 multipath-tools-0.1.0
+
+ * add the group_by_tur policy
+ * add the multipathd daemon for pathchecking & DM hot-reconfig
+ * multipath doesn't run twice
+ * massive cleanups, and code restructuring
+ * Avoid Kernel Bug when passing too small a buffer in do_inq()
+ * Sync with 2.6.3-udm4 target synthax (no more PG prio)
+
+2004-02-21 multipath-018
+
+ * From the Debian SID inclusion review (Philipp Matthias Hahn)
+ * use DESTDIR install prefix in the Makefile
+ * add man pages for devmap_name & multipath
+ * correct libsysfs.h includes
+ * fork the hotplug script in its own shell
+ * Sync with the kernel device mapper code as of 2.6.3-udm3
+ ie. Remove the test interval parameter and its uses
+ * Remove superfluous scsi parameter passed from hotplug
+ * Add the man pages to the [un]install targets
+
+2004-02-17 multipath-017
+
+ * remove the restrictive -f flag.
+ Introduce a more generic "-m iopolicy" one.
+ * remove useless "int with_sysfs" in env struct
+
+2004-02-04 multipath-016
+
+ * add a GROUP_BY_SERIAL flag. This should be useful for
+ controlers that activate they spare paths on simple IO
+ submition with a penalty. The StorageWorks HW defaults to
+ this mode, even if the MULTIBUS mode is OK.
+ * remove unused sg_err.c
+ * big restructuring : split devinfo.c from main.c. Export :
+ * void basename (char *, char *);
+ * int get_serial (int, char *);
+ * int get_lun_strings (char *, char *, char *, char *);
+ * int get_evpd_wwid(char *, char *);
+ * long get_disk_size (char *);
+ * stop passing struct env as param
+ * add devmap_name proggy for udev to name devmaps as per their
+ internal DM name and not only by their sysfs enum name (dm-*)
+ The corresponding udev.rules line is :
+ KERNEL="dm-[0-9]*", PROGRAM="/sbin/devmap_name %M %m", \
+ NAME="%k", SYMLINK="%c"
+ * remove make_dm_node fn & call. Rely on udev for this.
+ * don't rely on the linux symlink in the udev/klibc dir since
+ udev build doesn't use it anymore. This corrects build breakage
+
+2004-01-19 multipath-013
+
+ * update the DM target synthax to the 2.6.0-udm5 style
+
+2003-12-29 multipath-012
+
+ * check hotplug event refers to a block device; if not exit early
+ * refresh doc
+ * add the uninstall target in Makefile
+
+2003-12-22 multipath-010
+
+ * tweak the install target in Makefile
+ * stop passing fds as argument : this change enable a strict
+ segregation of ugly 2.4 code
+ * sysfs version of get_lun_strings()
+ * be careful about the return of get_unique_id() since errors
+ formerly caught up by if(open()) in the caller fn are now returned
+ by get_unique_id()
+ * send get_serial() in unused.c
+ * introduce dm-simplecmd for RESUME & SUSPEND requests
+ * split add_map() in setup_map() & dm-addmap()
+ * setup_map() correctly submits "SUSPEND-RELOAD-RESUME or CREATE"
+ sequences instead of the bogus "RELOAD or CREATE"
+ * don't print .sg_dev if equal to .dev (2.6) in print_path()
+ * since the kernel code handles defective paths, remove all
+ code to cope with them :
+ * move do_tur() to unused.c
+ * remove .state from path struct
+ * remove .state settings & conditionals
+ * add a cmdline switch to force maps to failover mode,
+ ie 1 path per priority group
+ * add default policies to the whitelist array (spread io ==
+ MULTIBUS / io forced to 1 path == FAILOVER)
+ * move get_disk_size() call out of add_map() to coalesce()
+ * comment tricky coalesce() fn
+ * bogus unsused.c file renamed to unused.c
+
+2003-12-20 multipath-010
+
+ * big ChangeLog update
+ * start to give a little control over target params :
+ introduce cmdline arg -i to control polling interval
+ * cope with hotplug-style calling convention :
+ ie "multipath scsi $DEVPATH" ... to avoid messing with
+ online maps not concerned by an event
+ * example hotplug agent to drop in /etc/hotplug.d/scsi
+ * revert the run & resched patch : unless someone proves me
+ wrong, this was overdesigned
+ * move commented out functions in unused.c
+ * update multipath target params to "udm[23] style"
+ * mp target now supports nr_path == 1, so do we
+ * add gratuitous free()
+ * push version forward
+
+2003-12-15 multipath-009
+
+ * Make the HW-specific get_unique_id switch pretty
+ * Prepare to field-test by whitelisting all known fibre array,
+ try to fetch WWID from the standard EVPD 0x83 off 8 for everyone
+ * configure the multipath target with round-robin path selector and
+ conservative default for a start (udm1 style) :
+ yes it makes this release the firstreally useful one.
+ * temporarily disable map creation for single path device
+ due to current restrictive defaults in the kernel target.
+ Sistina should work it out.
+ * correct the strncmp logic in blacklist function.
+ * update the Makefiles to autodetect libgcc.a & gcc includes
+ "ulibc-style". Factorisation of udevdirs & others niceties
+ * drop a hint about absent /dev/sd? on failed open()
+ * implement a reschedule flag in /var/run.
+ Last thing the prog do before exit is check if a call to multipath
+ was done (but canceled by /var/run/multipath.run check) during its
+ execution. If so restart themain loop.
+ * implement a blacklist of sysfs bdev to not bother with for now
+ (hd,md, dm, sr, scd, ram, raw).
+ This avoid sending SG_IO to unappropiate devices.
+ * Adds a /var/run/multipath.run handling to avoid simultaneous runs.
+ * Remove a commented-out "printf"
+ * drop a libdevmapper copy in extras/multipath;
+ maybe discussions w/Sistina folks will bring a better solution
+ in the future.
+ * drop a putchar usage in libdevmapper to compile cleanly with klibc
+ * drop another such usage of my own in main.c
+ * massage the Makefile to compile libdevmapper against klibc
+ * use "ld" to produce the binary rather than "gcc -static"
+ * stop being stupid w/ uneeded major, minor & dev in main.c:dm_mk_node()
+ * reverse to creating striped target for now because the multipath
+ target is more hairy than expected initialy
+ * push the version code to 009 to be in synch w/ udev
+
+2003-11-27 multipath-007
+
+ * removes sg_err.[ch] deps
+ * makes sure the core code play nice with klibc
+ * port the sysfs calls to dlist helpers
+ * links against udev's sysfs (need libsysfs.a & dlist.a)
+ * finally define DM_TARGET as "multipath" as Joe posted the code today
+ (not tested yet)
+ * push version forward (do you want it in sync with udev version?)
+
+2003-11-19 multipath-006
+
+ * merged in udev-006 tree
+
+2003-09-18 multipath-0.0.1
+
+ * multipath 0.0.1 released.
+ * Initial release.
Added: multipath-tools/upstream/current/FAQ
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/FAQ Fri Mar 4 08:05:19 2005
@@ -0,0 +1,63 @@
+1. How to set up System-on-multipath ?
+======================================
+
+prerequisite : udev and multipath-tools installed
+
+here are the steps on a Debian SID system :
+
+* add dm-mpath and dm-multipath to /etc/mkinitrd/modules
+* copy $tools_dir/multipath/0[12]_* to /etc/mkinitrd/scripts
+* define a friendly alias for your multipathed root disk
+ (in /etc/multipath.conf). Example : "system"
+* enable busybox in /etc/mkinitrd/mkinitrd.conf and set ROOT
+ to any valid block-device (but not a /dev/dm-* one, due to
+ an mkintrd misbelief that all dm-* are managed by LVM2)
+* run mkinitrd
+* in /boot/grub/menu.lst, define the root= kernel parameter
+ Example : root=/dev/system1
+* modify /etc/fstab to reference /dev/system* partitions
+
+At reboot, you should see some info like :
+
+path /dev/sda : multipath system
+...
+gpt: 0 slices
+dos: 5 slices
+reduced size of partition #2 to 63
+Added system1 : 0 70685937 linear /dev/system 63
+Added system2 : 0 63 linear /dev/system 7068600
+Added system5 : 0 995967 linear /dev/system 70686063
+...
+
+2. How does it compare to commercial product XXX ?
+==================================================
+
+Here are a few distinctive features :
+
+* you can mix HBA models, even different vendors, different speed ...
+* you can mix storage controllers on your SAN, and access them all, applying
+ different path grouping policy
+* completely event-driven model : no administration burden if you accept the
+ default behaviours
+* extensible : you can plug your own policies if the available ones don't fill
+ your needs
+* supports root FS on multipathed SAN
+* free, open-source software
+
+3. LVM2 doesn't see my multipathed devices as PV, what's up ?
+=============================================================
+
+By default, lvm2 does not consider device-mapper block devices (such as a
+dm-crypt device) for use as physical volumes.
+
+In order to use a dm-crypt device as an lvm2 pv, add this line to the
+devices block in /etc/lvm/lvm.conf:
+
+types = [ "device-mapper", 16 ]
+
+If /etc/lvm/lvm.conf does not exist, you can create one based on your
+current/default config like so:
+
+lvm dumpconfig > /etc/lvm/lvm.conf
+
+(tip from Christophe Saout)
Added: multipath-tools/upstream/current/Makefile
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/Makefile Fri Mar 4 08:05:19 2005
@@ -0,0 +1,68 @@
+# Makefile
+#
+# Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui at free.fr>
+
+BUILD = glibc
+
+KERNEL_BUILD = /lib/modules/$(shell uname -r)/build
+
+ifeq ($(strip $(BUILD)),klibc)
+ BUILDDIRS = libsysfs libdevmapper libcheckers \
+ libmultipath path_priority \
+ devmap_name multipath multipathd kpartx
+else
+ BUILDDIRS = libmultipath libcheckers path_priority \
+ devmap_name multipath multipathd kpartx
+endif
+
+VERSION = $(shell basename ${PWD} | cut -d'-' -f3)
+INSTALLDIRS = devmap_name multipath multipathd kpartx path_priority
+
+all: recurse
+
+recurse:
+ @if [ "$(BUILD)" = "klibc" ]; then\
+ ln -s ${KERNEL_BUILD} klibc/linux ; \
+ $(MAKE) -C klibc || exit $?; \
+ fi
+ @for dir in $(BUILDDIRS); do\
+ $(MAKE) -C $$dir BUILD=$(BUILD) VERSION=$(VERSION) || \
+ exit $?; \
+ done
+
+recurse_clean:
+ @for dir in $(BUILDDIRS); do\
+ $(MAKE) -C $$dir clean || exit $?; \
+ done
+
+recurse_clean_klibc:
+ @for dir in $(BUILDDIRS); do\
+ $(MAKE) -C $$dir BUILD=klibc clean || exit $?; \
+ done
+ $(MAKE) -C klibc spotless
+
+recurse_install:
+ @for dir in $(INSTALLDIRS); do\
+ $(MAKE) -C $$dir install || exit $?; \
+ done
+
+recurse_uninstall:
+ @for dir in $(INSTALLDIRS); do\
+ $(MAKE) -C $$dir uninstall || exit $?; \
+ done
+
+clean: recurse_clean recurse_clean_klibc
+ rm -f multipath-tools.spec
+ rm -f klibc/linux
+ rm -rf rpms
+
+install: recurse_install
+
+uninstall: recurse_uninstall
+
+release:
+ sed -e "s/__VERSION__/${VERSION}/" \
+ multipath-tools.spec.in > multipath-tools.spec
+
+rpm: release
+ rpmbuild -bb multipath-tools.spec
Added: multipath-tools/upstream/current/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,28 @@
+# Makefile.inc
+#
+# Copyright (C) 2004 Christophe Varoqui, <christophe.varoqui at free.fr>
+
+ifeq ($(strip $(BUILD)),klibc)
+ SRCROOT=../klibc
+ include ${SRCROOT}/MCONFIG
+endif
+
+prefix =
+exec_prefix = $(prefix)
+bindir = $(exec_prefix)/sbin
+klibcdir = $(SRCROOT)
+libdmdir = ../libdevmapper
+sysfsdir = ../libsysfs
+checkersdir = ../libcheckers
+multipathdir = ../libmultipath
+mandir = /usr/share/man/man8
+
+GZIP = /bin/gzip -9 -c
+STRIP = strip --strip-all -R .comment -R .note
+
+DMLIB = $(libdmdir)/libdevmapper
+SYSFSLIB = $(sysfsdir)/libsysfs
+CHECKERSLIB = $(checkersdir)/libcheckers
+MULTIPATHLIB = $(multipathdir)/libmultipath
+
+KERNEL_BUILD = /lib/modules/$(shell uname -r)/build
Added: multipath-tools/upstream/current/README
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/README Fri Mar 4 08:05:19 2005
@@ -0,0 +1,52 @@
+Dependancies :
+==============
+
+These libs have been dropped in the multipath tree :
+
+o libdevmapper : comes with device-mapper-XXXX.tar.gz
+ See www.sistina.com
+o libsysfs : comes with sysutils or udev
+ See ftp.kernel.org/pub/linux/utils/kernel/hotplug/
+o klibc
+ See ftp.kernel.org/pub/linux/libs/klibc/
+
+External :
+
+o Linux kernel 2.6.10-rc with udm2 patchset (or greater)
+ ftp://sources.redhat.com/pub/dm/
+
+How it works :
+==============
+
+Get a path list in sysfs.
+
+For each path, a wwid is retrieved by a callout program.
+Only White Listed HW can retrieve this info.
+
+Coalesce the paths according to pluggable policies and store
+ the result in mp array.
+
+Feed the maps to the kernel device mapper.
+
+The naming of the corresponding block device is handeld
+by udev with the help of the devmap_name proggy. It is
+called by the following rule in /etc/udev/udev.rules :
+
+KERNEL="dm-[0-9]*", PROGRAM="/sbin/devmap_name %M %m", \
+NAME="%k", SYMLINK="%c"
+
+Notes :
+=======
+
+o 2.4.21 version of DM does not like even segment size.
+ if you enconter pbs with this, upgrade DM.
+
+Credits :
+=========
+
+o Heavy cut'n paste from sg_utils. Thanks goes to D.
+ Gilbert.
+o Light cut'n paste from dmsetup. Thanks Joe Thornber.
+o Greg KH for the nice sysfs API.
+o The klibc guys (Starving Linux Artists :), espacially
+ for their nice Makefiles and specfile
Added: multipath-tools/upstream/current/TODO
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/TODO Fri Mar 4 08:05:19 2005
@@ -0,0 +1,3 @@
+Things to do
+
+o activate group dm mesg fn
Added: multipath-tools/upstream/current/devmap_name/Makefile
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/devmap_name/Makefile Fri Mar 4 08:05:19 2005
@@ -0,0 +1,54 @@
+# Makefile
+#
+# Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui at free.fr>
+BUILD = glibc
+
+include ../Makefile.inc
+
+ifeq ($(strip $(BUILD)),klibc)
+ CFLAGS = ${REQFLAGS} ${OPTFLAGS} -I$(libdmdir)
+ OBJS = devmap_name.o $(DMLIB)-$(BUILD).a
+else
+ CFLAGS = -pipe -g -Wall -Wunused -Wstrict-prototypes \
+ -DDEBUG=$(DEBUG)
+ LDFLAGS = -ldevmapper
+ OBJS = devmap_name.o
+endif
+
+EXEC = devmap_name
+
+all: $(BUILD)
+
+prepare:
+ rm -f core *.o *.gz
+
+glibc: prepare $(OBJS)
+ $(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
+ $(STRIP) $(EXEC)
+ $(GZIP) $(EXEC).8 > $(EXEC).8.gz
+
+klibc: prepare $(KLIBC) $(OBJS)
+ $(LD) -o $(EXEC) $(CRT0) $(OBJS) $(KLIBC) $(LIBGCC)
+ $(STRIP) $(EXEC)
+ $(GZIP) $(EXEC).8 > $(EXEC).8.gz
+
+$(DMLIB)-$(BUILD).a:
+ make -C $(libdmdir) BUILD=$(BUILD) $(BUILD)
+
+$(KLIBC):
+ rm -f $(klibcdir)/linux
+ ln -s $(KERNEL_BUILD) $(klibcdir)/linux
+ make -C $(klibcdir)
+
+install:
+ install -d $(DESTDIR)$(bindir)
+ install -m 755 $(EXEC) $(DESTDIR)$(bindir)/
+ install -d $(DESTDIR)$(mandir)
+ install -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
+
+uninstall:
+ rm $(DESTDIR)$(bindir)/$(EXEC)
+ rm $(DESTDIR)$(mandir)/$(EXEC).8.gz
+
+clean:
+ rm -f core *.o $(EXEC) *.gz
Added: multipath-tools/upstream/current/devmap_name/devmap_name.8
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/devmap_name/devmap_name.8 Fri Mar 4 08:05:19 2005
@@ -0,0 +1,30 @@
+.TH DEVMAP_NAME 8 "February 2004" "" "Linux Administrator's Manual"
+.SH NAME
+devmap_name \- Query device-mapper name
+.SH SYNOPSIS
+.BI devmap_name " major minor"
+.SH DESCRIPTION
+.B devmap_name
+queries the device-mapper for the name for the device
+specified by
+.I major
+and
+.I minor
+number.
+.br
+.B devmap_name
+can be called from
+.B udev
+by the following rule in
+.IR /etc/udev/udev.rules :
+.sp
+.nf
+KERNEL="dm-[0-9]*", PROGRAM="/sbin/devmap_name %M %m", \\
+ NAME="%k", SYMLINK="%c"
+.fi
+.SH "SEE ALSO"
+.BR udev (8),
+.BR dmsetup (8)
+.SH AUTHORS
+.B devmap_name
+was developed by Christophe Varoqui, <christophe.varoqui at free.fr> and others.
Added: multipath-tools/upstream/current/devmap_name/devmap_name.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/devmap_name/devmap_name.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <linux/kdev_t.h>
+#include <libdevmapper.h>
+
+static void usage(char * progname) {
+ fprintf(stderr, "usage : %s major minor\n", progname);
+ exit(1);
+}
+
+int main(int argc, char **argv)
+{
+ int r = 0;
+ struct dm_names *names;
+ unsigned next = 0;
+ int major, minor;
+ struct dm_task *dmt;
+
+ /* sanity check */
+ if (argc != 3)
+ usage(argv[0]);
+
+ major = atoi(argv[1]);
+ minor = atoi(argv[2]);
+
+ if (!(dmt = dm_task_create(DM_DEVICE_LIST)))
+ return 0;
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ if (!(names = dm_task_get_names(dmt)))
+ goto out;
+
+ if (!names->dev) {
+ printf("No devices found\n");
+ goto out;
+ }
+
+ do {
+ names = (void *) names + next;
+ if ((int) MAJOR(names->dev) == major &&
+ (int) MINOR(names->dev) == minor) {
+ printf("%s", names->name);
+ goto out;
+ }
+ next = names->next;
+ } while (next);
+
+ /* No correspondance found */
+ r = 1;
+
+ out:
+ dm_task_destroy(dmt);
+ return r;
+}
+
Added: multipath-tools/upstream/current/dmadm/Makefile
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/dmadm/Makefile Fri Mar 4 08:05:19 2005
@@ -0,0 +1,50 @@
+BUILD = glibc
+
+EXEC = dmadm
+
+include ../Makefile.inc
+
+ifeq ($(strip $(BUILD)),klibc)
+ CFLAGS = ${REQFLAGS} ${OPTFLAGS} -I$(sysfsdir) -I$(libdmdir)
+ OBJS = util.o dmadm.o $(SYSFSLIB)-$(BUILD).a $(DMLIB)-$(BUILD).a
+else
+ CFLAGS = -pipe -g -Wall -Wunused -Wstrict-prototypes
+ LDFLAGS = -ldevmapper -lsysfs
+ OBJS = util.o dmadm.o
+endif
+
+all: $(BUILD)
+
+prepare:
+ rm -f core *.o *.gz
+
+glibc: prepare $(OBJS)
+ $(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
+ $(STRIP) $(EXEC)
+
+klibc: prepare $(KLIBC) $(OBJS)
+ $(LD) -o $(EXEC) $(CRT0) $(OBJS) $(KLIBC) $(LIBGCC)
+ $(STRIP) $(EXEC)
+
+$(SYSFSLIB)-$(BUILD).a:
+ make -C $(sysfsdir) BUILD=$(BUILD) $(BUILD)
+
+$(DMLIB)-$(BUILD).a:
+ make -C $(libdmdir) BUILD=$(BUILD) $(BUILD)
+
+$(KLIBC):
+ rm -f $(klibcdir)/linux
+ ln -s $(KERNEL_BUILD) $(klibcdir)/linux
+ make -C $(klibcdir)
+
+clean:
+ rm -f $(OBJS) *.o $(EXEC) *~
+
+install:
+ install -d $(DESTDIR)$(bindir)
+ install -m 755 $(EXEC) $(DESTDIR)$(bindir)/
+
+uninstall:
+ rm $(DESTDIR)$(bindir)/$(EXEC)
+
+$(OBJS): mdadm.h
Added: multipath-tools/upstream/current/dmadm/README
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/dmadm/README Fri Mar 4 08:05:19 2005
@@ -0,0 +1,6 @@
+dmadm is a WIP tool.
+It reads MD superblocks and creates corresponding devmaps when possible
+
+Comments and contributions welcome
+
+christophe.varoqui at free.fr
Added: multipath-tools/upstream/current/dmadm/dmadm
==============================================================================
Binary file. No diff available.
Added: multipath-tools/upstream/current/dmadm/dmadm.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/dmadm/dmadm.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,430 @@
+/*
+ * mdadm - manage Linux "md" devices aka RAID arrays.
+ *
+ * Copyright (C) 2001-2002 Neil Brown <neilb at cse.unsw.edu.au>
+ *
+ *
+ * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Neil Brown
+ * Email: <neilb at cse.unsw.edu.au>
+ * Paper: Neil Brown
+ * School of Computer Science and Engineering
+ * The University of New South Wales
+ * Sydney, 2052
+ * Australia
+ */
+
+#include "mdadm.h"
+#include "../libdevmapper/libdevmapper.h"
+#include <endian.h>
+#include <sysfs/libsysfs.h>
+#include <sysfs/dlist.h>
+
+#if ! defined(__BIG_ENDIAN) && ! defined(__LITTLE_ENDIAN)
+#error no endian defined
+#endif
+#include "md_u.h"
+#include "md_p.h"
+
+#define DEBUG 2
+#define LOG(x, y, z...) if (DEBUG >= x) fprintf (stderr, y, ##z)
+
+#define LINEAR -1
+#define STRIPED 0
+#define RAID1 1
+
+struct device {
+ char devname[FILE_NAME_SIZE];
+ unsigned long long size;
+ mdp_super_t super;
+};
+
+static int
+blacklist (char * dev) {
+ int i;
+ static struct {
+ char * headstr;
+ int lengh;
+ } blist[] = {
+ {"md", 2},
+ {"dm", 2},
+ {"sr", 2},
+ {"scd", 3},
+ {"ram", 3},
+ {"raw", 3},
+ {NULL, 0},
+ };
+
+ for (i = 0; blist[i].lengh; i++) {
+ if (strncmp (dev, blist[i].headstr, blist[i].lengh) == 0)
+ return 1;
+ }
+
+ return 0;
+}
+
+static struct device *
+sort_by_disknum (struct device * a, struct device * b)
+{
+ return (a->super.this_disk.number < b->super.this_disk.number ? a : b);
+}
+
+static void
+format_devname (char * devname)
+{
+ char * p = devname;
+
+ while (*p) {
+ if (*p == '!')
+ *p = '/';
+ p++;
+ }
+}
+
+unsigned long long
+get_disk_size (char * sysfs_path, char * devname) {
+ unsigned long long size;
+ char attr_path[FILE_NAME_SIZE];
+ char buff[FILE_NAME_SIZE];
+
+ sprintf(attr_path, "%s/%s/size", sysfs_path, devname);
+
+ if (0 > sysfs_read_attribute_value(attr_path, buff,
+ FILE_NAME_SIZE * sizeof(char)))
+ return -1;
+
+ size = atoi(buff);
+ return size;
+}
+
+static int
+linear_target (struct dlist * mddevs)
+{
+ char mapname[FILE_NAME_SIZE];
+ char params[DM_PARAMS_SIZE];
+ struct device * dev = NULL;
+ unsigned long long start = 0;
+ struct dm_task *dmt = NULL;
+
+ dlist_for_each_data (mddevs, dev, struct device) {
+ memset (¶ms, 0x0, DM_PARAMS_SIZE);
+
+ if (!start) {
+ /* do only on first iteration */
+ sprintf (mapname, "%x:%x:%x:%x",
+ dev->super.set_uuid0,
+ dev->super.set_uuid1,
+ dev->super.set_uuid2,
+ dev->super.set_uuid3);
+
+ if (!(dmt = dm_task_create (DM_DEVICE_CREATE)))
+ return 1;
+
+ if (!dm_task_set_name (dmt, mapname))
+ goto out;
+ }
+
+ sprintf (params, " %i:%i 0",
+ dev->super.this_disk.major,
+ dev->super.this_disk.minor);
+
+ LOG (1, "%llu %llu linear %s\n", start,
+ MD_NEW_SIZE_SECTORS(dev->size), params);
+
+ if (!dm_task_add_target (dmt, start,
+ MD_NEW_SIZE_SECTORS(dev->size),
+ "linear", params))
+ goto out;
+
+ start += MD_NEW_SIZE_SECTORS(dev->size);
+ }
+
+ if (!dm_task_run (dmt))
+ goto out;
+
+ out:
+ dm_task_destroy (dmt);
+ return 0;
+}
+
+static int
+striped_target (struct dlist * mddevs)
+{
+ char * p;
+ char params[DM_PARAMS_SIZE];
+ char mapname[FILE_NAME_SIZE];
+ struct device * dev = NULL;
+ unsigned long long size = 0;
+ struct dm_task *dmt = NULL;
+
+ p = ¶ms[0];
+
+ dlist_for_each_data (mddevs, dev, struct device) {
+
+ if (!size) {
+ /* do only on first iteration */
+ sprintf (mapname, "%x:%x:%x:%x",
+ dev->super.set_uuid0,
+ dev->super.set_uuid1,
+ dev->super.set_uuid2,
+ dev->super.set_uuid3);
+
+ size = dev->super.size * 2;
+ p += sprintf (p, "%i", dev->super.nr_disks);
+ p += sprintf (p, " %i", dev->super.chunk_size / 1024);
+ }
+
+ p += sprintf (p, " %i:%i 0",
+ dev->super.this_disk.major,
+ dev->super.this_disk.minor);
+ }
+
+ LOG (1, "0 %llu striped %s\n", size, params);
+
+ if (!(dmt = dm_task_create (DM_DEVICE_CREATE)))
+ return 1;
+
+ if (!dm_task_set_name (dmt, mapname))
+ goto out;
+
+ if (!dm_task_add_target (dmt, 0, size, "striped", params))
+ goto out;
+
+ if (!dm_task_run (dmt))
+ goto out;
+
+ out:
+ dm_task_destroy (dmt);
+ return 0;
+}
+
+static int
+raid1_target (struct dlist * mddevs)
+{
+ char * p;
+ char params[DM_PARAMS_SIZE];
+ char mapname[FILE_NAME_SIZE];
+ struct device * dev = NULL;
+ unsigned long long size = 0;
+ struct dm_task *dmt = NULL;
+
+ p = ¶ms[0];
+
+ dlist_for_each_data (mddevs, dev, struct device) {
+
+ if (!size) {
+ /* do only on first iteration */
+ sprintf (mapname, "%x:%x:%x:%x",
+ dev->super.set_uuid0,
+ dev->super.set_uuid1,
+ dev->super.set_uuid2,
+ dev->super.set_uuid3);
+
+ size = dev->super.size * 2;
+ p += sprintf (p, "core 1 1024 %i", dev->super.nr_disks);
+ }
+
+ p += sprintf (p, " %i:%i 0",
+ dev->super.this_disk.major,
+ dev->super.this_disk.minor);
+ }
+
+ LOG (1, "0 %llu mirror %s\n", size, params);
+
+ if (!(dmt = dm_task_create (DM_DEVICE_CREATE)))
+ return 1;
+
+ if (!dm_task_set_name (dmt, mapname))
+ goto out;
+
+ if (!dm_task_add_target (dmt, 0, size, "mirror", params))
+ goto out;
+
+ if (!dm_task_run (dmt))
+ goto out;
+
+ out:
+ dm_task_destroy (dmt);
+ return 0;
+}
+
+int main (int argc, char **argv)
+{
+ struct sysfs_directory * sdir;
+ struct sysfs_directory * devp;
+ char sysfs_path[FILE_NAME_SIZE];
+ char devname[FILE_NAME_SIZE];
+ struct device * dev = NULL;
+ struct device * refdev = NULL;
+ struct dlist * devlist = NULL;
+ struct dlist * mddevs = NULL;
+ int fd, err;
+ int level;
+
+ /*
+ * store every block device listed in sysfs in a dlist
+ * if it has a MD superblock
+ */
+ if (sysfs_get_mnt_path (sysfs_path, FILE_NAME_SIZE)) {
+ LOG (0, "need sysfs\n");
+ exit (1);
+ }
+
+ sprintf (devname, "%s/block", sysfs_path);
+ strncpy (sysfs_path, devname, FILE_NAME_SIZE);
+ sdir = sysfs_open_directory (sysfs_path);
+ sysfs_read_directory (sdir);
+
+ dlist_for_each_data (sdir->subdirs, devp, struct sysfs_directory) {
+ format_devname (devp->name);
+
+ if (blacklist (devp->name))
+ continue;
+
+ LOG (2, "%s\n", devp->name);
+ sprintf (devname, "/dev/%s", devp->name);
+ fd = open(devname, O_RDONLY);
+
+ if (fd < 0) {
+ LOG (0, "Can't open %s\n", devname);
+ close (fd);
+ continue;
+ }
+
+ dev = malloc (sizeof (struct device));
+
+ if (dev == NULL) {
+ LOG (0, "can't allocate memory for device\n");
+ exit (1);
+ }
+
+ err = load_super(fd, &dev->super);
+ close (fd);
+
+ switch(err) {
+ case 1:
+ LOG (2, "cannot find device size for %s: %s\n",
+ devname, strerror(errno));
+ free (dev);
+ continue;
+ case 2:
+ LOG (2, "%s is too small for md\n",
+ devname);
+ free (dev);
+ continue;
+ case 3:
+ LOG (2, "Cannot seek to superblock on %s: %s\n",
+ devname, strerror(errno));
+ free (dev);
+ continue;
+ case 4:
+ LOG (2, "Cannot read superblock on %s\n",
+ devname);
+ free (dev);
+ continue;
+ case 5:
+ LOG (2, "No super block found on %s "
+ "(Expected magic %08x, got %08x)\n",
+ devname, MD_SB_MAGIC, dev->super.md_magic);
+ free (dev);
+ continue;
+ case 6:
+ LOG (2, "Cannot interpret superblock on %s - "
+ "version is %d\n",
+ devname, dev->super.major_version);
+ free (dev);
+ continue;
+ }
+
+ /* here we got a valid raid member, store */
+ LOG (1, "%s is part of a raid array\n", devname);
+
+ if (devlist == NULL) {
+ LOG (2, "First super detected : create dlist\n");
+ devlist = dlist_new (sizeof (struct device));
+ }
+
+ strcpy (dev->devname, devname);
+ dev->size = get_disk_size (sysfs_path, devp->name);
+ dlist_push (devlist, dev);
+ }
+
+ sysfs_close_directory (sdir);
+
+ /*
+ * we need at least one superblock to continue
+ */
+ if (devlist == NULL) {
+ LOG (1, "no superblocks found\n");
+ exit (0);
+ }
+
+ /*
+ * coalesce by MD UUID
+ */
+ LOG (2, "start coalescing\n");
+ dlist_start (devlist);
+
+ while (dlist_next (devlist)) {
+ refdev = dlist_pop (devlist);
+ mddevs = dlist_new (sizeof (struct device));
+ dlist_push (mddevs, refdev);
+ level = refdev->super.level;
+
+ LOG (1, "raid found : %d:%d",
+ refdev->super.this_disk.major,
+ refdev->super.this_disk.minor);
+
+ dlist_for_each_data (devlist, dev, struct device) {
+ if (0 == compare_super (&refdev->super, &dev->super)) {
+ LOG (1, " %d:%d",
+ dev->super.this_disk.major,
+ dev->super.this_disk.minor);
+ dlist_insert_sorted (mddevs, dev,
+ (void *)sort_by_disknum);
+ dlist_pop (devlist);
+ continue;
+ }
+ }
+
+ LOG (1, "\n");
+
+ /*
+ * here we have an array in mddevs.
+ * do sanity checks and create devmap
+ */
+ switch (level) {
+ case LINEAR:
+ linear_target (mddevs);
+ break;
+
+ case STRIPED:
+ striped_target (mddevs);
+ break;
+
+ case RAID1:
+ raid1_target (mddevs);
+ break;
+
+ default:
+ LOG (1, "unsupported raid level : skip\n");
+ }
+
+ dlist_destroy (mddevs);
+ }
+
+ return 0;
+}
Added: multipath-tools/upstream/current/dmadm/md_p.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/dmadm/md_p.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,176 @@
+/*
+ md_p.h : physical layout of Linux RAID devices
+ Copyright (C) 1996-98 Ingo Molnar, Gadi Oxman
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ (for example /usr/src/linux/COPYING); if not, write to the Free
+ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _MD_P_H
+#define _MD_P_H
+
+/*
+ * RAID superblock.
+ *
+ * The RAID superblock maintains some statistics on each RAID configuration.
+ * Each real device in the RAID set contains it near the end of the device.
+ * Some of the ideas are copied from the ext2fs implementation.
+ *
+ * We currently use 4096 bytes as follows:
+ *
+ * word offset function
+ *
+ * 0 - 31 Constant generic RAID device information.
+ * 32 - 63 Generic state information.
+ * 64 - 127 Personality specific information.
+ * 128 - 511 12 32-words descriptors of the disks in the raid set.
+ * 512 - 911 Reserved.
+ * 912 - 1023 Disk specific descriptor.
+ */
+
+/*
+ * If x is the real device size in bytes, we return an apparent size of:
+ *
+ * y = (x & ~(MD_RESERVED_BYTES - 1)) - MD_RESERVED_BYTES
+ *
+ * and place the 4kB superblock at offset y.
+ */
+#define MD_RESERVED_BYTES (64 * 1024)
+#define MD_RESERVED_SECTORS (MD_RESERVED_BYTES / 512)
+#define MD_RESERVED_BLOCKS (MD_RESERVED_BYTES / BLOCK_SIZE)
+
+#define MD_NEW_SIZE_SECTORS(x) ((x & ~(MD_RESERVED_SECTORS - 1)) - MD_RESERVED_SECTORS)
+#define MD_NEW_SIZE_BLOCKS(x) ((x & ~(MD_RESERVED_BLOCKS - 1)) - MD_RESERVED_BLOCKS)
+
+#define MD_SB_BYTES 4096
+#define MD_SB_WORDS (MD_SB_BYTES / 4)
+#define MD_SB_BLOCKS (MD_SB_BYTES / BLOCK_SIZE)
+#define MD_SB_SECTORS (MD_SB_BYTES / 512)
+
+/*
+ * The following are counted in 32-bit words
+ */
+#define MD_SB_GENERIC_OFFSET 0
+#define MD_SB_PERSONALITY_OFFSET 64
+#define MD_SB_DISKS_OFFSET 128
+#define MD_SB_DESCRIPTOR_OFFSET 992
+
+#define MD_SB_GENERIC_CONSTANT_WORDS 32
+#define MD_SB_GENERIC_STATE_WORDS 32
+#define MD_SB_GENERIC_WORDS (MD_SB_GENERIC_CONSTANT_WORDS + MD_SB_GENERIC_STATE_WORDS)
+#define MD_SB_PERSONALITY_WORDS 64
+#define MD_SB_DESCRIPTOR_WORDS 32
+#define MD_SB_DISKS 27
+#define MD_SB_DISKS_WORDS (MD_SB_DISKS*MD_SB_DESCRIPTOR_WORDS)
+#define MD_SB_RESERVED_WORDS (1024 - MD_SB_GENERIC_WORDS - MD_SB_PERSONALITY_WORDS - MD_SB_DISKS_WORDS - MD_SB_DESCRIPTOR_WORDS)
+#define MD_SB_EQUAL_WORDS (MD_SB_GENERIC_WORDS + MD_SB_PERSONALITY_WORDS + MD_SB_DISKS_WORDS)
+
+/*
+ * Device "operational" state bits
+ */
+#define MD_DISK_FAULTY 0 /* disk is faulty / operational */
+#define MD_DISK_ACTIVE 1 /* disk is running or spare disk */
+#define MD_DISK_SYNC 2 /* disk is in sync with the raid set */
+#define MD_DISK_REMOVED 3 /* disk is in sync with the raid set */
+
+typedef struct mdp_device_descriptor_s {
+ __u32 number; /* 0 Device number in the entire set */
+ __u32 major; /* 1 Device major number */
+ __u32 minor; /* 2 Device minor number */
+ __u32 raid_disk; /* 3 The role of the device in the raid set */
+ __u32 state; /* 4 Operational state */
+ __u32 reserved[MD_SB_DESCRIPTOR_WORDS - 5];
+} mdp_disk_t;
+
+#define MD_SB_MAGIC 0xa92b4efc
+
+/*
+ * Superblock state bits
+ */
+#define MD_SB_CLEAN 0
+#define MD_SB_ERRORS 1
+
+typedef struct mdp_superblock_s {
+ /*
+ * Constant generic information
+ */
+ __u32 md_magic; /* 0 MD identifier */
+ __u32 major_version; /* 1 major version to which the set conforms */
+ __u32 minor_version; /* 2 minor version ... */
+ __u32 patch_version; /* 3 patchlevel version ... */
+ __u32 gvalid_words; /* 4 Number of used words in this section */
+ __u32 set_uuid0; /* 5 Raid set identifier */
+ __u32 ctime; /* 6 Creation time */
+ __u32 level; /* 7 Raid personality */
+ __u32 size; /* 8 Apparent size of each individual disk */
+ __u32 nr_disks; /* 9 total disks in the raid set */
+ __u32 raid_disks; /* 10 disks in a fully functional raid set */
+ __u32 md_minor; /* 11 preferred MD minor device number */
+ __u32 not_persistent; /* 12 does it have a persistent superblock */
+ __u32 set_uuid1; /* 13 Raid set identifier #2 */
+ __u32 set_uuid2; /* 14 Raid set identifier #3 */
+ __u32 set_uuid3; /* 15 Raid set identifier #4 */
+ __u32 gstate_creserved[MD_SB_GENERIC_CONSTANT_WORDS - 16];
+
+ /*
+ * Generic state information
+ */
+ __u32 utime; /* 0 Superblock update time */
+ __u32 state; /* 1 State bits (clean, ...) */
+ __u32 active_disks; /* 2 Number of currently active disks */
+ __u32 working_disks; /* 3 Number of working disks */
+ __u32 failed_disks; /* 4 Number of failed disks */
+ __u32 spare_disks; /* 5 Number of spare disks */
+ __u32 sb_csum; /* 6 checksum of the whole superblock */
+#if __BYTE_ORDER == __BIG_ENDIAN
+ __u32 events_hi; /* 7 high-order of superblock update count */
+ __u32 events_lo; /* 8 low-order of superblock update count */
+#else
+ __u32 events_lo; /* 7 low-order of superblock update count */
+ __u32 events_hi; /* 8 high-order of superblock update count */
+#endif
+ __u32 gstate_sreserved[MD_SB_GENERIC_STATE_WORDS - 9];
+
+ /*
+ * Personality information
+ */
+ __u32 layout; /* 0 the array's physical layout */
+ __u32 chunk_size; /* 1 chunk size in bytes */
+ __u32 root_pv; /* 2 LV root PV */
+ __u32 root_block; /* 3 LV root block */
+ __u32 pstate_reserved[MD_SB_PERSONALITY_WORDS - 4];
+
+ /*
+ * Disks information
+ */
+ mdp_disk_t disks[MD_SB_DISKS];
+
+ /*
+ * Reserved
+ */
+ __u32 reserved[MD_SB_RESERVED_WORDS];
+
+ /*
+ * Active descriptor
+ */
+ mdp_disk_t this_disk;
+
+} mdp_super_t;
+
+#ifdef __TINYC__
+typedef unsigned long long __u64;
+#endif
+
+static inline __u64 md_event(mdp_super_t *sb) {
+ __u64 ev = sb->events_hi;
+ return (ev<<32)| sb->events_lo;
+}
+
+#endif
+
Added: multipath-tools/upstream/current/dmadm/md_u.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/dmadm/md_u.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,116 @@
+/*
+ md_u.h : user <=> kernel API between Linux raidtools and RAID drivers
+ Copyright (C) 1998 Ingo Molnar
+
+ 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.
+
+ You should have received a copy of the GNU General Public License
+ (for example /usr/src/linux/COPYING); if not, write to the Free
+ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _MD_U_H
+#define _MD_U_H
+
+/* ioctls */
+
+/* status */
+#define RAID_VERSION _IOR (MD_MAJOR, 0x10, mdu_version_t)
+#define GET_ARRAY_INFO _IOR (MD_MAJOR, 0x11, mdu_array_info_t)
+#define GET_DISK_INFO _IOR (MD_MAJOR, 0x12, mdu_disk_info_t)
+#define PRINT_RAID_DEBUG _IO (MD_MAJOR, 0x13)
+#define RAID_AUTORUN _IO (MD_MAJOR, 0x14)
+
+/* configuration */
+#define CLEAR_ARRAY _IO (MD_MAJOR, 0x20)
+#define ADD_NEW_DISK _IOW (MD_MAJOR, 0x21, mdu_disk_info_t)
+#define HOT_REMOVE_DISK _IO (MD_MAJOR, 0x22)
+#define SET_ARRAY_INFO _IOW (MD_MAJOR, 0x23, mdu_array_info_t)
+#define SET_DISK_INFO _IO (MD_MAJOR, 0x24)
+#define WRITE_RAID_INFO _IO (MD_MAJOR, 0x25)
+#define UNPROTECT_ARRAY _IO (MD_MAJOR, 0x26)
+#define PROTECT_ARRAY _IO (MD_MAJOR, 0x27)
+#define HOT_ADD_DISK _IO (MD_MAJOR, 0x28)
+#define SET_DISK_FAULTY _IO (MD_MAJOR, 0x29)
+
+/* usage */
+#define RUN_ARRAY _IOW (MD_MAJOR, 0x30, mdu_param_t)
+#define START_ARRAY _IO (MD_MAJOR, 0x31)
+#define STOP_ARRAY _IO (MD_MAJOR, 0x32)
+#define STOP_ARRAY_RO _IO (MD_MAJOR, 0x33)
+#define RESTART_ARRAY_RW _IO (MD_MAJOR, 0x34)
+
+typedef struct mdu_version_s {
+ int major;
+ int minor;
+ int patchlevel;
+} mdu_version_t;
+
+typedef struct mdu_array_info_s {
+ /*
+ * Generic constant information
+ */
+ int major_version;
+ int minor_version;
+ int patch_version;
+ int ctime;
+ int level;
+ int size;
+ int nr_disks;
+ int raid_disks;
+ int md_minor;
+ int not_persistent;
+
+ /*
+ * Generic state information
+ */
+ int utime; /* 0 Superblock update time */
+ int state; /* 1 State bits (clean, ...) */
+ int active_disks; /* 2 Number of currently active disks */
+ int working_disks; /* 3 Number of working disks */
+ int failed_disks; /* 4 Number of failed disks */
+ int spare_disks; /* 5 Number of spare disks */
+
+ /*
+ * Personality information
+ */
+ int layout; /* 0 the array's physical layout */
+ int chunk_size; /* 1 chunk size in bytes */
+
+} mdu_array_info_t;
+
+typedef struct mdu_disk_info_s {
+ /*
+ * configuration/status of one particular disk
+ */
+ int number;
+ int major;
+ int minor;
+ int raid_disk;
+ int state;
+
+} mdu_disk_info_t;
+
+typedef struct mdu_start_info_s {
+ /*
+ * configuration/status of one particular disk
+ */
+ int major;
+ int minor;
+ int raid_disk;
+ int state;
+
+} mdu_start_info_t;
+
+typedef struct mdu_param_s
+{
+ int personality; /* 1,2,3,4 */
+ int chunk_size; /* in bytes */
+ int max_fault; /* unused for now */
+} mdu_param_t;
+
+#endif
+
Added: multipath-tools/upstream/current/dmadm/mdadm.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/dmadm/mdadm.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,221 @@
+/*
+ * mdadm - manage Linux "md" devices aka RAID arrays.
+ *
+ * Copyright (C) 2001-2002 Neil Brown <neilb at cse.unsw.edu.au>
+ *
+ *
+ * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Neil Brown
+ * Email: <neilb at cse.unsw.edu.au>
+ * Paper: Neil Brown
+ * School of Computer Science and Engineering
+ * The University of New South Wales
+ * Sydney, 2052
+ * Australia
+ */
+
+#define __USE_LARGEFILE64
+#define MD_MAJOR 9
+#define FILE_NAME_SIZE 255
+#define DM_PARAMS_SIZE 2048
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <time.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <linux/kdev_t.h>
+#include <sys/mount.h>
+#include <asm/types.h>
+#include <sys/ioctl.h>
+
+#ifndef BLKGETSIZE
+#define BLKGETSIZE _IO(0x12,96) /* return device size /512 (long *arg) */
+#endif
+
+#ifndef BLKSSZGET
+#define BLKSSZGET _IO(0x12,104) /* get block device sector size */
+#endif
+
+#ifndef BLKFLSBUF
+#define BLKFLSBUF _IO(0x12,97) /* flush buffer cache */
+#endif
+
+#ifndef BLKGETSIZE64
+#define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size in bytes (u64 *arg) */
+#endif
+
+#include "md_u.h"
+#include "md_p.h"
+
+//extern __off64_t lseek64 __P ((int __fd, __off64_t __offset, int __whence));
+#define lseek64 llseek
+
+#define Name "dmadm"
+
+enum mode {
+ ASSEMBLE=1,
+ BUILD,
+ CREATE,
+ MANAGE,
+ MISC,
+ MONITOR,
+};
+
+extern char short_options[];
+extern struct option long_options[];
+extern char Version[], Usage[], Help[], OptionHelp[],
+ Help_create[], Help_build[], Help_assemble[],
+ Help_manage[], Help_misc[], Help_monitor[], Help_config[];
+
+/* structures read from config file */
+/* List of mddevice names and identifiers
+ * Identifiers can be:
+ * uuid=128-hex-uuid
+ * super-minor=decimal-minor-number-from-superblock
+ * devices=comma,separated,list,of,device,names,with,wildcards
+ *
+ * If multiple fields are present, the intersection of all matching
+ * devices is considered
+ */
+#define UnSet (0xfffe)
+typedef struct mddev_ident_s {
+ char *devname;
+
+ int uuid_set;
+ __u32 uuid[4];
+
+ unsigned int super_minor;
+
+ char *devices; /* comma separated list of device
+ * names with wild cards
+ */
+ int level;
+ unsigned int raid_disks;
+ unsigned int spare_disks;
+ char *spare_group;
+ struct mddev_ident_s *next;
+} *mddev_ident_t;
+
+/* List of device names - wildcards expanded */
+typedef struct mddev_dev_s {
+ char *devname;
+ char disposition; /* 'a' for add, 'r' for remove, 'f' for fail.
+ * Not set for names read from .config
+ */
+ struct mddev_dev_s *next;
+} *mddev_dev_t;
+
+typedef struct mapping {
+ char *name;
+ int num;
+} mapping_t;
+
+
+struct mdstat_ent {
+ char *dev;
+ int devnum;
+ int active;
+ char *level;
+ char *pattern; /* U or up, _ for down */
+ int percent; /* -1 if no resync */
+ struct mdstat_ent *next;
+};
+
+extern struct mdstat_ent *mdstat_read(void);
+extern void free_mdstat(struct mdstat_ent *ms);
+
+#ifndef Sendmail
+#define Sendmail "/usr/lib/sendmail -t"
+#endif
+
+extern char *map_num(mapping_t *map, int num);
+extern int map_name(mapping_t *map, char *name);
+extern mapping_t r5layout[], pers[], modes[];
+
+extern char *map_dev(int major, int minor);
+
+
+extern int Manage_ro(char *devname, int fd, int readonly);
+extern int Manage_runstop(char *devname, int fd, int runstop);
+extern int Manage_subdevs(char *devname, int fd,
+ mddev_dev_t devlist);
+
+
+extern int Assemble(char *mddev, int mdfd,
+ mddev_ident_t ident,
+ char *conffile,
+ mddev_dev_t devlist,
+ int readonly, int runstop,
+ char *update,
+ int verbose, int force);
+
+extern int Build(char *mddev, int mdfd, int chunk, int level,
+ int raiddisks,
+ mddev_dev_t devlist);
+
+
+extern int Create(char *mddev, int mdfd,
+ int chunk, int level, int layout, unsigned long size, int raiddisks, int sparedisks,
+ int subdevs, mddev_dev_t devlist,
+ int runstop, int verbose, int force);
+
+extern int Detail(char *dev, int brief, int test);
+extern int Query(char *dev);
+extern int Examine(mddev_dev_t devlist, int brief, int scan, int SparcAdjust);
+extern int Monitor(mddev_dev_t devlist,
+ char *mailaddr, char *alert_cmd,
+ int period, int daemonise, int scan, int oneshot,
+ char *config, int test);
+
+extern int Kill(char *dev, int force);
+
+extern int md_get_version(int fd);
+extern int get_linux_version(void);
+extern int parse_uuid(char *str, int uuid[4]);
+extern int check_ext2(int fd, char *name);
+extern int check_reiser(int fd, char *name);
+extern int check_raid(int fd, char *name);
+
+extern mddev_ident_t conf_get_ident(char *conffile, char *dev);
+extern mddev_dev_t conf_get_devs(char *conffile);
+extern char *conf_get_mailaddr(char *conffile);
+extern char *conf_get_program(char *conffile);
+extern char *conf_line(FILE *file);
+extern char *conf_word(FILE *file, int allow_key);
+extern void free_line(char *line);
+extern int match_oneof(char *devices, char *devname);
+extern int load_super(int fd, mdp_super_t *super);
+extern void uuid_from_super(int uuid[4], mdp_super_t *super);
+extern int same_uuid(int a[4], int b[4]);
+extern int compare_super(mdp_super_t *first, mdp_super_t *second);
+extern unsigned long calc_sb_csum(mdp_super_t *super);
+extern int store_super(int fd, mdp_super_t *super);
+extern int enough(int level, int raid_disks, int avail_disks);
+extern int ask(char *mesg);
+
+
+extern char *human_size(long long bytes);
+char *human_size_brief(long long bytes);
+
+extern void put_md_name(char *name);
+extern char *get_md_name(int dev);
+
+extern char DefaultConfFile[];
Added: multipath-tools/upstream/current/dmadm/util.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/dmadm/util.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,437 @@
+/*
+ * mdadm - manage Linux "md" devices aka RAID arrays.
+ *
+ * Copyright (C) 2001-2002 Neil Brown <neilb at cse.unsw.edu.au>
+ *
+ *
+ * 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Neil Brown
+ * Email: <neilb at cse.unsw.edu.au>
+ * Paper: Neil Brown
+ * School of Computer Science and Engineering
+ * The University of New South Wales
+ * Sydney, 2052
+ * Australia
+ */
+
+#include "mdadm.h"
+#include "md_p.h"
+#include <sys/utsname.h>
+#include <ctype.h>
+
+/*
+ * Parse a 128 bit uuid in 4 integers
+ * format is 32 hexx nibbles with options :.<space> separator
+ * If not exactly 32 hex digits are found, return 0
+ * else return 1
+ */
+int parse_uuid(char *str, int uuid[4])
+{
+ int hit = 0; /* number of Hex digIT */
+ int i;
+ char c;
+ for (i=0; i<4; i++) uuid[i]=0;
+
+ while ((c= *str++)) {
+ int n;
+ if (c>='0' && c<='9')
+ n = c-'0';
+ else if (c>='a' && c <= 'f')
+ n = 10 + c - 'a';
+ else if (c>='A' && c <= 'F')
+ n = 10 + c - 'A';
+ else if (strchr(":. -", c))
+ continue;
+ else return 0;
+
+ if (hit<32) {
+ uuid[hit/8] <<= 4;
+ uuid[hit/8] += n;
+ }
+ hit++;
+ }
+ if (hit == 32)
+ return 1;
+ return 0;
+
+}
+
+
+/*
+ * Get the md version number.
+ * We use the RAID_VERSION ioctl if it is supported
+ * If not, but we have a block device with major '9', we assume
+ * 0.36.0
+ *
+ * Return version number as 24 but number - assume version parts
+ * always < 255
+ */
+
+int md_get_version(int fd)
+{
+ struct stat stb;
+ mdu_version_t vers;
+
+ if (fstat(fd, &stb)<0)
+ return -1;
+ if ((S_IFMT&stb.st_mode) != S_IFBLK)
+ return -1;
+
+ if (ioctl(fd, RAID_VERSION, &vers) == 0)
+ return (vers.major*10000) + (vers.minor*100) + vers.patchlevel;
+ if (errno == EACCES)
+ return -1;
+ if (MAJOR(stb.st_rdev) == MD_MAJOR)
+ return (3600);
+ return -1;
+}
+
+
+int get_linux_version()
+{
+ struct utsname name;
+ char *cp;
+ int a,b,c;
+ if (uname(&name) <0)
+ return -1;
+
+ cp = name.release;
+ a = strtoul(cp, &cp, 10);
+ if (*cp != '.') return -1;
+ b = strtoul(cp+1, &cp, 10);
+ if (*cp != '.') return -1;
+ c = strtoul(cp+1, NULL, 10);
+
+ return (a*1000000)+(b*1000)+c;
+}
+
+int enough(int level, int raid_disks, int avail_disks)
+{
+ switch (level) {
+ case -4:
+ return avail_disks>= 1;
+ case -1:
+ case 0:
+ return avail_disks == raid_disks;
+ case 1:
+ return avail_disks >= 1;
+ case 4:
+ case 5:
+ return avail_disks >= raid_disks-1;
+ case 6:
+ return avail_disks >= raid_disks-2;
+ default:
+ return 0;
+ }
+}
+
+int same_uuid(int a[4], int b[4])
+{
+ if (a[0]==b[0] &&
+ a[1]==b[1] &&
+ a[2]==b[2] &&
+ a[3]==b[3])
+ return 1;
+ return 0;
+}
+
+void uuid_from_super(int uuid[4], mdp_super_t *super)
+{
+ uuid[0] = super->set_uuid0;
+ if (super->minor_version >= 90) {
+ uuid[1] = super->set_uuid1;
+ uuid[2] = super->set_uuid2;
+ uuid[3] = super->set_uuid3;
+ } else {
+ uuid[1] = 0;
+ uuid[2] = 0;
+ uuid[3] = 0;
+ }
+}
+
+int compare_super(mdp_super_t *first, mdp_super_t *second)
+{
+ /*
+ * return:
+ * 0 same, or first was empty, and second was copied
+ * 1 second had wrong number
+ * 2 wrong uuid
+ * 3 wrong other info
+ */
+ int uuid1[4], uuid2[4];
+ if (second->md_magic != MD_SB_MAGIC)
+ return 1;
+ if (first-> md_magic != MD_SB_MAGIC) {
+ memcpy(first, second, sizeof(*first));
+ return 0;
+ }
+
+ uuid_from_super(uuid1, first);
+ uuid_from_super(uuid2, second);
+ if (!same_uuid(uuid1, uuid2))
+ return 2;
+ if (first->major_version != second->major_version ||
+ first->minor_version != second->minor_version ||
+ first->patch_version != second->patch_version ||
+ first->gvalid_words != second->gvalid_words ||
+ first->ctime != second->ctime ||
+ first->level != second->level ||
+ first->size != second->size ||
+ first->raid_disks != second->raid_disks )
+ return 3;
+
+ return 0;
+}
+
+int load_super(int fd, mdp_super_t *super)
+{
+ /* try to read in the superblock
+ *
+ * return
+ * 0 - success
+ * 1 - no block size
+ * 2 - too small
+ * 3 - no seek
+ * 4 - no read
+ * 5 - no magic
+ * 6 - wrong major version
+ */
+ unsigned long size;
+ unsigned long long offset;
+
+ if (ioctl(fd, BLKGETSIZE, &size))
+ return 1;
+
+ if (size < MD_RESERVED_SECTORS*2)
+ return 2;
+
+ offset = MD_NEW_SIZE_SECTORS(size);
+
+ offset *= 512;
+
+ ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
+
+ if (lseek64(fd, offset, 0)< 0LL)
+ return 3;
+
+ if (read(fd, super, sizeof(*super)) != sizeof(*super))
+ return 4;
+
+ if (super->md_magic != MD_SB_MAGIC)
+ return 5;
+
+ if (super->major_version != 0)
+ return 6;
+ return 0;
+}
+
+int store_super(int fd, mdp_super_t *super)
+{
+ long size;
+ long long offset;
+
+ if (ioctl(fd, BLKGETSIZE, &size))
+ return 1;
+
+ if (size < MD_RESERVED_SECTORS*2)
+ return 2;
+
+ offset = MD_NEW_SIZE_SECTORS(size);
+
+ offset *= 512;
+
+ if (lseek64(fd, offset, 0)< 0LL)
+ return 3;
+
+ if (write(fd, super, sizeof(*super)) != sizeof(*super))
+ return 4;
+
+ return 0;
+}
+
+
+
+int check_raid(int fd, char *name)
+{
+ mdp_super_t super;
+ time_t crtime;
+ if (load_super(fd, &super))
+ return 0;
+ /* Looks like a raid array .. */
+ fprintf(stderr, Name ": %s appears to be part of a raid array:\n",
+ name);
+ crtime = super.ctime;
+ return 1;
+}
+
+char *map_num(mapping_t *map, int num)
+{
+ while (map->name) {
+ if (map->num == num)
+ return map->name;
+ map++;
+ }
+ return NULL;
+}
+
+int map_name(mapping_t *map, char *name)
+{
+ while (map->name) {
+ if (strcmp(map->name, name)==0)
+ return map->num;
+ map++;
+ }
+ return UnSet;
+}
+
+unsigned long calc_sb_csum(mdp_super_t *super)
+{
+ unsigned int oldcsum = super->sb_csum;
+ unsigned long long newcsum = 0;
+ unsigned long csum;
+ int i;
+ unsigned int *superc = (int*) super;
+ super->sb_csum = 0;
+
+ for(i=0; i<MD_SB_BYTES/4; i++)
+ newcsum+= superc[i];
+ csum = (newcsum& 0xffffffff) + (newcsum>>32);
+ super->sb_csum = oldcsum;
+ return csum;
+}
+
+char *human_size(long long bytes)
+{
+ static char buf[30];
+
+
+ if (bytes < 5000*1024)
+ buf[0]=0;
+ else if (bytes < 2*1024LL*1024LL*1024LL)
+ sprintf(buf, " (%ld.%02ld MiB %ld.%02ld MB)",
+ (long)(bytes>>20),
+ (long)((bytes&0xfffff)+0x100000/200)/(0x100000/100),
+ (long)(bytes/1000/1000),
+ (long)(((bytes%1000000)+5000)/10000)
+ );
+ else
+ sprintf(buf, " (%ld.%02ld GiB %ld.%02ld GB)",
+ (long)(bytes>>30),
+ (long)(((bytes>>10)&0xfffff)+0x100000/200)/(0x100000/100),
+ (long)(bytes/1000LL/1000LL/1000LL),
+ (long)((((bytes/1000)%1000000)+5000)/10000)
+ );
+ return buf;
+}
+
+char *human_size_brief(long long bytes)
+{
+ static char buf[30];
+
+
+ if (bytes < 5000*1024)
+ sprintf(buf, "%ld.%02ldKiB",
+ (long)(bytes>>10), (long)(((bytes&1023)*100+512)/1024)
+ );
+ else if (bytes < 2*1024LL*1024LL*1024LL)
+ sprintf(buf, "%ld.%02ldMiB",
+ (long)(bytes>>20),
+ (long)((bytes&0xfffff)+0x100000/200)/(0x100000/100)
+ );
+ else
+ sprintf(buf, "%ld.%02ldGiB",
+ (long)(bytes>>30),
+ (long)(((bytes>>10)&0xfffff)+0x100000/200)/(0x100000/100)
+ );
+ return buf;
+}
+
+static int mdp_major = -1;
+/*
+void get_mdp_major(void)
+{
+ FILE *fl = fopen("/proc/devices", "r");
+ char *w;
+ int have_block = 0;
+ int have_devices = 0;
+ int last_num = -1;
+ if (!fl)
+ return;
+ while ((w = conf_word(fl, 1))) {
+ if (have_block && strcmp(w, "devices:")==0)
+ have_devices = 1;
+ have_block = (strcmp(w, "Block")==0);
+ if (isdigit(w[0]))
+ last_num = atoi(w);
+ if (have_devices && strcmp(w, "mdp")==0)
+ mdp_major = last_num;
+ free(w);
+ }
+ fclose(fl);
+}
+
+char *get_md_name(int dev)
+{
+*/
+ /* find /dev/md%d or /dev/md/%d or make a device /dev/.tmp.md%d */
+ /* if dev < 0, want /dev/md/d%d or find mdp in /proc/devices ... */
+/*
+ static char devname[50];
+ struct stat stb;
+ dev_t rdev;
+
+ if (dev < 0) {
+
+ if (mdp_major < 0) get_mdp_major();
+ if (mdp_major < 0) return NULL;
+ rdev = MKDEV(mdp_major, (-1-dev)<<6);
+ sprintf(devname, "/dev/md/d%d", -1-dev);
+ if (stat(devname, &stb) == 0
+ && (S_IFMT&stb.st_mode) == S_IFBLK
+ && (stb.st_rdev == rdev))
+ return devname;
+ } else {
+ rdev = MKDEV(MD_MAJOR, dev);
+ sprintf(devname, "/dev/md%d", dev);
+ if (stat(devname, &stb) == 0
+ && (S_IFMT&stb.st_mode) == S_IFBLK
+ && (stb.st_rdev == rdev))
+ return devname;
+
+ sprintf(devname, "/dev/md/%d", dev);
+ if (stat(devname, &stb) == 0
+ && (S_IFMT&stb.st_mode) == S_IFBLK
+ && (stb.st_rdev == rdev))
+ return devname;
+ }
+ sprintf(devname, "/dev/.tmp.md%d", dev);
+ if (mknod(devname, S_IFBLK | 0600, rdev) == -1)
+ return NULL;
+
+ if (stat(devname, &stb) == 0
+ && (S_IFMT&stb.st_mode) == S_IFBLK
+ && (stb.st_rdev == rdev))
+ return devname;
+ unlink(devname);
+ return NULL;
+}
+
+void put_md_name(char *name)
+{
+ if (strncmp(name, "/dev/.tmp.md", 12)==0)
+ unlink(name);
+}
+*/
Added: multipath-tools/upstream/current/klibc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc Fri Mar 4 08:05:19 2005
@@ -0,0 +1 @@
+link klibc-0.190
\ No newline at end of file
Added: multipath-tools/upstream/current/klibc-0.190/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,66 @@
+# -*- makefile -*-
+#
+# Makefile configuration, without explicit rules
+#
+
+# Eventually support separate compilation, but we don't have it yet...
+OBJROOT = $(SRCROOT)
+
+# Kernel trees (source and obj) - can potentially be different
+KRNLSRC = $(SRCROOT)/linux
+KRNLOBJ = $(SRCROOT)/linux
+
+ARCH = $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
+CROSS =
+CC = $(CROSS)gcc
+LD = $(CROSS)ld
+KLIBSRC = $(SRCROOT)/klibc
+KLIBOBJ = $(OBJROOT)/klibc
+INCLUDE = -I$(SRCROOT)/include/arch/$(ARCH) \
+ -I$(SRCROOT)/include/bits$(BITSIZE) \
+ -I$(SRCROOT)/include \
+ -I$(KRNLOBJ)/include -I$(KRNLOBJ)/include2 -I$(KRNLSRC)/include
+REQFLAGS = $(ARCHREQFLAGS) -nostdinc -iwithprefix include \
+ -D__KLIBC__ -DBITSIZE=$(BITSIZE) \
+ $(INCLUDE)
+LDFLAGS =
+AR = $(CROSS)ar
+RANLIB = $(CROSS)ranlib
+NM = $(CROSS)nm
+PERL = perl
+STRIP = $(CROSS)strip --strip-all -R .comment -R .note
+OBJCOPY = $(CROSS)objcopy
+
+HOST_CC = gcc
+HOST_CFLAGS = -g -O
+HOST_LDFLAGS =
+HOST_LIBS =
+
+# Static library paths
+CRT0 = $(KLIBOBJ)/crt0.o
+KLIBC = $(KLIBOBJ)/libc.a
+LIBGCC = $(shell $(CC) --print-libgcc)
+
+# Shared library paths
+CRTSHARED = $(KLIBOBJ)/interp.o
+LIBSHARED = $(KLIBOBJ)/libc.so
+
+#
+# This indicates the location of the final version of the shared library.
+# THIS MUST BE AN ABSOLUTE PATH WITH NO FINAL SLASH.
+# Leave this empty to make it the root.
+#
+SHLIBDIR = /lib
+
+# Enable this to make perror/strerror return real error messages
+# This makes klibc.so and any static binary which uses these functions
+# about 4K bigger.
+ERRLIST = 1
+
+#
+# Include arch-specific rule fragments
+#
+include $(KLIBSRC)/arch/$(ARCH)/MCONFIG
+
+# How to tell the linker main() is the entrypoint
+EMAIN ?= -e main
Added: multipath-tools/upstream/current/klibc-0.190/MRULES
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/MRULES Fri Mar 4 08:05:19 2005
@@ -0,0 +1,45 @@
+# -*- makefile -*-
+#
+# Standard pattern rules
+#
+
+.SUFFIXES: .c .o .a .so .lo .i .S .s .ls .ss .lss
+
+% : %.c # Cancel default rule
+
+% : %.S
+
+.c.o:
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+.c.i:
+ $(CC) $(CFLAGS) -E -o $@ $<
+
+.c.s:
+ $(CC) $(CFLAGS) -S -o $@ $<
+
+.S.o:
+ $(CC) $(CFLAGS) -D__ASSEMBLY__ -c -o $@ $<
+
+.S.s:
+ $(CC) $(CFLAGS) -D__ASSEMBLY__ -E -o $@ $<
+
+.S.lo:
+ $(CC) $(CFLAGS) $(SOFLAGS) -D__ASSEMBLY__ -c -o $@ $<
+
+.S.ls:
+ $(CC) $(CFLAGS) $(SOFLAGS) -D__ASSEMBLY__ -E -o $@ $<
+
+.s.o:
+ $(CC) $(CFLAGS) -x assembler -c -o $@ $<
+
+.ls.lo:
+ $(CC) $(CFLAGS) $(SOFLAGS) -x assembler -c -o $@ $<
+
+.c.lo:
+ $(CC) $(CFLAGS) $(SOFLAGS) -c -o $@ $<
+
+.c.ls:
+ $(CC) $(CFLAGS) $(SOFLAGS) -S -o $@ $<
+
+
Added: multipath-tools/upstream/current/klibc-0.190/Makefile
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/Makefile Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+VERSION := $(shell cat version)
+SUBDIRS = klibc
+
+all:
+
+rpmbuild = $(shell which rpmbuild 2>/dev/null || which rpm)
+
+klibc.spec: klibc.spec.in version
+ sed -e 's/@@VERSION@@/$(VERSION)/g' < $< > $@
+
+.PHONY: rpm
+rpm: klibc.spec
+ +$(rpmbuild) -bb klibc.spec --target=$(ARCH)
+
+%:
+ @set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
+
+clean:
+ @set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
+
+spotless:
+ @set -e; for d in $(SUBDIRS); do $(MAKE) -C $$d $@; done
+ rm -f klibc.spec *~ tags
Added: multipath-tools/upstream/current/klibc-0.190/README
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/README Fri Mar 4 08:05:19 2005
@@ -0,0 +1,21 @@
+Please see klibc/README for build instructions and for the status of
+various platforms.
+
+
+
+klibc is archived at:
+
+ ftp://ftp.kernel.org/pub/linux/libs/klibc/
+
+There is a mailing list for klibc and early-userspace issues at:
+
+ http://www.zytor.com/mailman/listinfo/klibc/
+
+There is also a cvsweb repository at:
+
+ http://www.zytor.com/cvsweb.cgi/klibc/
+
+There is no direct public CVS access yet, however, the CVS repository
+is available for rsync from:
+
+ rsync://rsync.kernel.org/pub/linux/libs/klibc/cvsroot/
Added: multipath-tools/upstream/current/klibc-0.190/include/alloca.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/alloca.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * alloca.h
+ *
+ * Just call the builtin alloca() function
+ */
+
+#ifndef _ALLOCA_H
+#define _ALLOCA_H
+
+#define alloca(size) __builtin_alloca(size)
+
+#endif /* _ALLOCA_H */
+
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,33 @@
+/*
+ * arch/alpha/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __s0;
+ unsigned long __s1;
+ unsigned long __s2;
+ unsigned long __s3;
+ unsigned long __s4;
+ unsigned long __s5;
+ unsigned long __fp;
+ unsigned long __ra;
+ unsigned long __gp;
+ unsigned long __sp;
+
+ unsigned long __f2;
+ unsigned long __f3;
+ unsigned long __f4;
+ unsigned long __f5;
+ unsigned long __f6;
+ unsigned long __f7;
+ unsigned long __f8;
+ unsigned long __f9;
+};
+
+/* Must be an array so it will decay to a pointer when a function is called */
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _KLIBC_ARCHSETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/alpha/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,26 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned long st_rdev;
+ long st_size;
+ unsigned long st_blocks;
+
+ unsigned int st_mode;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int st_blksize;
+ unsigned int st_nlink;
+ unsigned int __pad0;
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ long __unused[3];
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,53 @@
+/*
+ * arch/alpha/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* Alpha has some bizarre Tru64-derived system calls which return two
+ different values in $0 and $20(!), respectively. The standard
+ macros can't deal with these; even the ones that give the right
+ return value have the wrong clobbers. */
+
+#define _syscall0_dual0(type, name) \
+type name(void) \
+{ \
+ long _sc_ret, _sc_err; \
+ { \
+ register long _sc_0 __asm__("$0"); \
+ register long _sc_19 __asm__("$19"); \
+ register long _sc_20 __asm__("$20"); \
+ \
+ _sc_0 = __NR_##name; \
+ __asm__("callsys" \
+ : "=r"(_sc_0), "=r"(_sc_19), "=r" (_sc_20) \
+ : "0"(_sc_0) \
+ : _syscall_clobbers); \
+ _sc_ret = _sc_0, _sc_err = _sc_19; (void)(_sc_20); \
+ } \
+ _syscall_return(type); \
+}
+
+#define _syscall0_dual1(type, name) \
+type name(void) \
+{ \
+ long _sc_ret, _sc_err; \
+ { \
+ register long _sc_0 __asm__("$0"); \
+ register long _sc_19 __asm__("$19"); \
+ register long _sc_20 __asm__("$20"); \
+ \
+ _sc_0 = __NR_##name; \
+ __asm__("callsys" \
+ : "=r"(_sc_0), "=r"(_sc_19), "=r" (_sc_20) \
+ : "0"(_sc_0) \
+ : _syscall_clobbers); \
+ _sc_ret = _sc_20, _sc_err = _sc_19; (void)(_sc_0); \
+ } \
+ _syscall_return(type); \
+}
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/machine/asm.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/alpha/machine/asm.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,44 @@
+/*
+ * machine/asm.h
+ */
+
+#ifndef _MACHINE_ASM_H
+#define _MACHINE_ASM_H
+
+/* Standard aliases for Alpha register names */
+
+#define v0 $0
+#define t0 $1
+#define t1 $2
+#define t2 $3
+#define t3 $4
+#define t4 $5
+#define t5 $6
+#define t6 $7
+#define t7 $8
+#define s0 $9
+#define s1 $10
+#define s2 $11
+#define s3 $12
+#define s4 $13
+#define s5 $14
+#define fp $15
+#define a0 $16
+#define a1 $17
+#define a2 $18
+#define a3 $19
+#define a4 $20
+#define a5 $21
+#define t8 $22
+#define t9 $23
+#define t10 $24
+#define t11 $25
+#define ra $26
+#define t12 $27 /* t12 and pv are both used for $27 */
+#define pv $27 /* t12 and pv are both used for $27 */
+#define at $28
+#define gp $29
+#define sp $30
+#define zero $31
+
+#endif /* _MACHINE_ASM_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/arm/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/arm/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * arch/i386/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned int regs[10];
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/arm/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/arm/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/arm/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/arm/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/arm/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,45 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#include <endian.h>
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ * Note: The kernel zero's the padded region because glibc might read them
+ * in the hope that the kernel has stretched to using larger sizes.
+ */
+struct stat {
+ unsigned long long st_dev;
+ unsigned char __pad0[4];
+
+ unsigned long __st_ino;
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned long st_uid;
+ unsigned long st_gid;
+
+ unsigned long long st_rdev;
+ unsigned char __pad3[4];
+
+ long long st_size;
+ unsigned long st_blksize;
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned long __pad4; /* Future possible st_blocks hi bits */
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+#else /* Must be little */
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+ unsigned long __pad4; /* Future possible st_blocks hi bits */
+#endif
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned long long st_ino;
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/arm/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/arm/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * arch/cris/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/cris/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/cris/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+/*
+ * arch/cris/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __r0;
+ unsigned long __r1;
+ unsigned long __r2;
+ unsigned long __r3;
+ unsigned long __r4;
+ unsigned long __r5;
+ unsigned long __r6;
+ unsigned long __r7;
+ unsigned long __r8;
+ unsigned long __sp;
+ unsigned long __srp;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _KLIBC_ARCHSETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/cris/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/cris/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/cris/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/cris/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/cris/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,37 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ */
+struct stat {
+ unsigned long long st_dev;
+ unsigned char __pad0[4];
+
+ unsigned long __st_ino;
+
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned long st_uid;
+ unsigned long st_gid;
+
+ unsigned long long st_rdev;
+ unsigned char __pad3[4];
+
+ long long st_size;
+ unsigned long st_blksize;
+
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+ unsigned long __pad4; /* future possible st_blocks high bits */
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned long long st_ino;
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/cris/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/cris/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * arch/cris/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * arch/i386/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned int __ebx;
+ unsigned int __esp;
+ unsigned int __ebp;
+ unsigned int __esi;
+ unsigned int __edi;
+ unsigned int __eip;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/i386/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,37 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ */
+struct stat {
+ unsigned long long st_dev;
+ unsigned char __pad0[4];
+
+ unsigned long __st_ino;
+
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned long st_uid;
+ unsigned long st_gid;
+
+ unsigned long long st_rdev;
+ unsigned char __pad3[4];
+
+ long long st_size;
+ unsigned long st_blksize;
+
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+ unsigned long __pad4; /* future possible st_blocks high bits */
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned long long st_ino;
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * arch/cris/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/diverr.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/i386/klibc/diverr.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * arch/i386/include/klibc/diverr.h
+ */
+
+#ifndef _KLIBC_DIVERR_H
+#define _KLIBC_DIVERR_H
+
+#include <signal.h>
+
+static __inline__ void
+__divide_error(void)
+{
+ asm volatile("divl %0" :: "rm" (0) : "eax", "edx");
+}
+
+#endif /* _KLIBC_DIVERR_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/i386/sys/io.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/i386/sys/io.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,126 @@
+#ident "$Id: io.h,v 1.2 2004/01/25 07:49:39 hpa Exp $"
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2004 H. Peter Anvin - All Rights Reserved
+ *
+ * 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 AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * sys/io.h for the i386 architecture
+ *
+ * Basic I/O macros
+ */
+
+#ifndef _SYS_IO_H
+#define _SYS_IO_H 1
+
+/* I/O-related system calls */
+
+int iopl(int);
+int ioperm(unsigned long, unsigned long, int);
+
+/* Basic I/O macros */
+
+static __inline__ void
+outb(unsigned char __v, unsigned short __p)
+{
+ asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ void
+outw(unsigned short __v, unsigned short __p)
+{
+ asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ void
+outl(unsigned int __v, unsigned short __p)
+{
+ asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ unsigned char
+inb(unsigned short __p)
+{
+ unsigned char __v;
+ asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p));
+ return __v;
+}
+
+static __inline__ unsigned short
+inw(unsigned short __p)
+{
+ unsigned short __v;
+ asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p));
+ return __v;
+}
+
+static __inline__ unsigned int
+inl(unsigned short __p)
+{
+ unsigned int __v;
+ asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p));
+ return __v;
+}
+
+/* String I/O macros */
+
+static __inline__ void
+outsb (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+outsw (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+outsl (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+
+static __inline__ void
+insb (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+insw (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+insl (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+#endif /* _SYS_IO_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/i386/sys/vm86.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/i386/sys/vm86.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,41 @@
+#ident "$Id: vm86.h,v 1.1 2004/01/25 01:34:28 hpa Exp $"
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2004 H. Peter Anvin - All Rights Reserved
+ *
+ * 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 AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * sys/vm86.h for i386
+ */
+
+#ifndef _SYS_VM86_H
+#define _SYS_VM86_H 1
+
+#include <asm/vm86.h>
+
+/* Actual system call */
+int vm86(struct vm86_struct *);
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,17 @@
+/*
+ * arch/ia64/include/klibc/archsetjmp.h
+ *
+ * Code borrowed from the FreeBSD kernel.
+ *
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+/* User code must not depend on the internal representation of jmp_buf. */
+#define _JBLEN 0x200
+
+/* guaranteed 128-bit alignment! */
+typedef char jmp_buf[_JBLEN] __attribute__ ((aligned (16)));
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,31 @@
+/*
+ * arch/ia64/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions.
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+#define _NSIG 64
+#define _NSIG_BPW 64
+#define _NSIG_WORDS (_NSIG / _NSIG_BPW)
+
+typedef struct {
+ unsigned long sig[_NSIG_WORDS];
+} sigset_t;
+
+struct sigaction {
+ union {
+ __sighandler_t _sa_handler;
+ void (*_sa_sigaction)(int, struct siginfo *, void *);
+ } _u;
+ sigset_t sa_mask;
+ int sa_flags;
+};
+
+#define sa_handler _u._sa_handler
+#define sa_sigaction _u._sa_sigaction
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned long st_nlink;
+ unsigned int st_mode;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int __pad0;
+ unsigned long st_rdev;
+ unsigned long st_size;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned long st_blksize;
+ long st_blocks;
+ unsigned long __unused[3];
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/ia64/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,218 @@
+/*
+ * arch/ia64/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+#define __IA64_BREAK "break 0x100000;;\n\t"
+
+#define _syscall0(type,name) \
+type \
+name (void) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15) \
+ : "2" (_r15) ASM_ARGS_0 \
+ : "memory" ASM_CLOBBERS_0); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+#define _syscall1(type,name,type1,arg1) \
+type \
+name (type1 arg1) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ LOAD_ARGS_1(arg1); \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
+ ASM_OUTARGS_1 \
+ : "2" (_r15) ASM_ARGS_1 \
+ : "memory" ASM_CLOBBERS_1); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type \
+name (type1 arg1, type2 arg2) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ LOAD_ARGS_2(arg1, arg2); \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
+ ASM_OUTARGS_2 \
+ : "2" (_r15) ASM_ARGS_2 \
+ : "memory" ASM_CLOBBERS_2); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type \
+name (type1 arg1, type2 arg2, type3 arg3) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ LOAD_ARGS_3(arg1, arg2, arg3); \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
+ ASM_OUTARGS_3 \
+ : "2" (_r15) ASM_ARGS_3 \
+ : "memory" ASM_CLOBBERS_3); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type \
+name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ LOAD_ARGS_4(arg1, arg2, arg3, arg4); \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
+ ASM_OUTARGS_4 \
+ : "2" (_r15) ASM_ARGS_4 \
+ : "memory" ASM_CLOBBERS_4); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
+type \
+name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ LOAD_ARGS_5(arg1, arg2, arg3, arg4, arg5); \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
+ ASM_OUTARGS_5 \
+ : "2" (_r15) ASM_ARGS_5 \
+ : "memory" ASM_CLOBBERS_5); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
+type \
+name (type1 arg1, type2 arg2, type3 arg3, type4 arg4, type5 arg5, type6 arg6) \
+{ \
+ register long _r8 asm ("r8"); \
+ register long _r10 asm ("r10"); \
+ register long _r15 asm ("r15") = __NR_##name; \
+ long _retval; \
+ LOAD_ARGS_6(arg1, arg2, arg3, arg4, arg5, arg6); \
+ __asm __volatile (__IA64_BREAK \
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15), \
+ ASM_OUTARGS_6 \
+ : "2" (_r15) ASM_ARGS_6 \
+ : "memory" ASM_CLOBBERS_6); \
+ _retval = _r8; \
+ if (_r10 == -1) { \
+ errno = (_retval); \
+ _retval = -1; \
+ } \
+ return (type)_retval; \
+}
+
+
+#define LOAD_ARGS_0() do { } while (0)
+#define LOAD_ARGS_1(out0) \
+ register long _out0 asm ("out0") = (long) (out0); \
+ LOAD_ARGS_0 ()
+#define LOAD_ARGS_2(out0, out1) \
+ register long _out1 asm ("out1") = (long) (out1); \
+ LOAD_ARGS_1 (out0)
+#define LOAD_ARGS_3(out0, out1, out2) \
+ register long _out2 asm ("out2") = (long) (out2); \
+ LOAD_ARGS_2 (out0, out1)
+#define LOAD_ARGS_4(out0, out1, out2, out3) \
+ register long _out3 asm ("out3") = (long) (out3); \
+ LOAD_ARGS_3 (out0, out1, out2)
+#define LOAD_ARGS_5(out0, out1, out2, out3, out4) \
+ register long _out4 asm ("out4") = (long) (out4); \
+ LOAD_ARGS_4 (out0, out1, out2, out3)
+#define LOAD_ARGS_6(out0, out1, out2, out3, out4, out5) \
+ register long _out5 asm ("out5") = (long) (out5); \
+ LOAD_ARGS_5 (out0, out1, out2, out3, out4)
+
+#define ASM_OUTARGS_1 "=r" (_out0)
+#define ASM_OUTARGS_2 ASM_OUTARGS_1, "=r" (_out1)
+#define ASM_OUTARGS_3 ASM_OUTARGS_2, "=r" (_out2)
+#define ASM_OUTARGS_4 ASM_OUTARGS_3, "=r" (_out3)
+#define ASM_OUTARGS_5 ASM_OUTARGS_4, "=r" (_out4)
+#define ASM_OUTARGS_6 ASM_OUTARGS_5, "=r" (_out5)
+
+#define ASM_ARGS_0
+#define ASM_ARGS_1 ASM_ARGS_0, "3" (_out0)
+#define ASM_ARGS_2 ASM_ARGS_1, "4" (_out1)
+#define ASM_ARGS_3 ASM_ARGS_2, "5" (_out2)
+#define ASM_ARGS_4 ASM_ARGS_3, "6" (_out3)
+#define ASM_ARGS_5 ASM_ARGS_4, "7" (_out4)
+#define ASM_ARGS_6 ASM_ARGS_5, "8" (_out5)
+
+#define ASM_CLOBBERS_0 ASM_CLOBBERS_1, "out0"
+#define ASM_CLOBBERS_1 ASM_CLOBBERS_2, "out1"
+#define ASM_CLOBBERS_2 ASM_CLOBBERS_3, "out2"
+#define ASM_CLOBBERS_3 ASM_CLOBBERS_4, "out3"
+#define ASM_CLOBBERS_4 ASM_CLOBBERS_5, "out4"
+#define ASM_CLOBBERS_5 ASM_CLOBBERS_6, "out5"
+#define ASM_CLOBBERS_6 , "out6", "out7", \
+ /* Non-stacked integer registers, minus r8, r10, r15. */ \
+ "r2", "r3", "r9", "r11", "r12", "r13", "r14", "r16", "r17", "r18", \
+ "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", \
+ "r28", "r29", "r30", "r31", \
+ /* Predicate registers. */ \
+ "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
+ /* Non-rotating fp registers. */ \
+ "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
+ /* Branch registers. */ \
+ "b6", "b7"
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/m68k/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/m68k/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/m68k/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/m68k/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/m68k/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,37 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ */
+struct stat {
+ unsigned long long st_dev;
+ unsigned char __pad1[2];
+
+ unsigned long __st_ino;
+
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned long st_uid;
+ unsigned long st_gid;
+
+ unsigned long long st_rdev;
+ unsigned char __pad3[2];
+
+ long long st_size;
+ unsigned long st_blksize;
+
+ unsigned long __pad4; /* future possible st_blocks high bits */
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned long long st_ino;
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/m68k/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/m68k/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * arch/m68k/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archfcntl.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archfcntl.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,87 @@
+/*
+ * arch/mips/include/klibc/archfcntl.h
+ *
+ * On MIPS, <asm/fcntl.h> isn't usable (compiling struct stat with
+ * the correct definitions doesn't "just work"), so we need to provide
+ * our own definitions.
+ */
+
+#ifndef _KLIBC_ARCHFCNTL_H
+#define _KLIBC_ARCHFCNTL_H
+
+#ifdef _ASM_FCNTL_H /* We were too late! */
+# error "<asm/fcntl.h> included before <klibc/archfcntl.h>"
+#endif
+#define _ASM_FCNTL_H /* Keep <asm/fcntl.h> from getting included */
+
+#define O_ACCMODE 0x0003
+#define O_RDONLY 0x0000
+#define O_WRONLY 0x0001
+#define O_RDWR 0x0002
+#define O_APPEND 0x0008
+#define O_SYNC 0x0010
+#define O_NONBLOCK 0x0080
+#define O_CREAT 0x0100
+#define O_TRUNC 0x0200
+#define O_EXCL 0x0400
+#define O_NOCTTY 0x0800
+#define FASYNC 0x1000
+#define O_LARGEFILE 0x2000
+#define O_DIRECT 0x8000
+#define O_DIRECTORY 0x10000
+#define O_NOFOLLOW 0x20000
+#define O_NOATIME 0x40000
+
+#define O_NDELAY O_NONBLOCK
+
+#define F_DUPFD 0
+#define F_GETFD 1
+#define F_SETFD 2
+#define F_GETFL 3
+#define F_SETFL 4
+#define F_GETLK 14
+#define F_SETLK 6
+#define F_SETLKW 7
+
+#define F_SETOWN 24
+#define F_GETOWN 23
+#define F_SETSIG 10
+#define F_GETSIG 11
+
+#define F_GETLK64 33
+#define F_SETLK64 34
+#define F_SETLKW64 35
+
+#define FD_CLOEXEC 1
+
+#define F_RDLCK 0
+#define F_WRLCK 1
+#define F_UNLCK 2
+
+#define F_EXLCK 4
+#define F_SHLCK 8
+
+#define F_INPROGRESS 16
+
+#define LOCK_SH 1
+#define LOCK_EX 2
+#define LOCK_NB 4
+#define LOCK_UN 8
+
+#define LOCK_MAND 32
+#define LOCK_READ 64
+#define LOCK_WRITE 128
+#define LOCK_RW 192
+
+typedef struct flock {
+ short l_type;
+ short l_whence;
+ loff_t l_start;
+ loff_t l_len;
+ pid_t l_pid;
+} flock_t;
+
+#define F_LINUX_SPECIFIC_BASE 1024
+
+#endif /* _KLIBC_ARCHFCNTL_H */
+
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,39 @@
+/*
+ * arch/mips/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __s0;
+ unsigned long __s1;
+ unsigned long __s2;
+ unsigned long __s3;
+ unsigned long __s4;
+ unsigned long __s5;
+ unsigned long __s6;
+ unsigned long __s7;
+ unsigned long __gp;
+ unsigned long __sp;
+ unsigned long __s8;
+ unsigned long __ra;
+ unsigned long __f20;
+ unsigned long __f21;
+ unsigned long __f22;
+ unsigned long __f23;
+ unsigned long __f24;
+ unsigned long __f25;
+ unsigned long __f26;
+ unsigned long __f27;
+ unsigned long __f28;
+ unsigned long __f29;
+ unsigned long __f30;
+ unsigned long __f31;
+ unsigned long __fcr31;
+ unsigned long __unused;
+} __attribute__((aligned(8)));
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _KLIBC_ARCHSETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/mips/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,39 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+/*
+ * This matches struct stat64 in glibc2.1, hence the absolutely insane
+ * amounts of padding around dev_t's. The memory layout is the same as of
+ * struct stat of the 64-bit kernel.
+ */
+
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_pad0[3]; /* Reserved for st_dev expansion */
+
+ unsigned long long st_ino;
+
+ mode_t st_mode;
+ nlink_t st_nlink;
+
+ uid_t st_uid;
+ gid_t st_gid;
+
+ unsigned long st_rdev;
+ unsigned long st_pad1[3]; /* Reserved for st_rdev expansion */
+
+ long long st_size;
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned long st_blksize;
+ unsigned long st_pad2;
+
+ long long st_blocks;
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/mips/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * arch/mips/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/mips/machine/asm.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/mips/machine/asm.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+/*
+ * arch/mips/include/machine/asm.h
+ */
+
+#ifndef _MACHINE_ASM_H
+#define _MACHINE_ASM_H
+
+#include <asm/regdef.h>
+#include <asm/asm.h>
+
+#endif /* _MACHINE_ASM_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/mips/sgidefs.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/mips/sgidefs.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,20 @@
+/*
+ * arch/mips/include/sgidefs.h
+ */
+
+/* Some ABI constants */
+
+#ifndef _SGIDEFS_H
+#define _SGIDEFS_H
+
+#define _MIPS_ISA_MIPS1 1
+#define _MIPS_ISA_MIPS2 2
+#define _MIPS_ISA_MIPS3 3
+#define _MIPS_ISA_MIPS4 4
+#define _MIPS_ISA_MIPS5 5
+
+#define _MIPS_SIM_ABI32 1
+#define _MIPS_SIM_NABI32 2
+#define _MIPS_SIM_ABI64 3
+
+#endif /* _SGIDEFS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/mips/spaces.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/mips/spaces.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1 @@
+/* Included by <asm/page.h> but not actually needed */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/mips64/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/mips64/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/mips64/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/mips64/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/mips64/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,33 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned int st_dev;
+ unsigned int st_pad0[3]; /* Reserved for st_dev expansion */
+
+ unsigned long st_ino;
+
+ mode_t st_mode;
+ nlink_t st_nlink;
+
+ uid_t st_uid;
+ gid_t st_gid;
+
+ unsigned int st_rdev;
+ unsigned int st_pad1[3]; /* Reserved for st_rdev expansion */
+
+ off_t st_size;
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned int st_blksize;
+ unsigned int st_pad2;
+
+ unsigned long st_blocks;
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/mips64/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/mips64/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * arch/mips64/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/parisc/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/parisc/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+/*
+ * arch/parisc/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+#define _NSIG 64
+#define _NSIG_SZ (_NSIG / LONG_BIT)
+
+typedef struct {
+ unsigned long sig[_NSIG_SZ];
+} sigset_t;
+
+struct sigaction {
+ __sighandler_t sa_handler;
+ unsigned long sa_flags;
+ sigset_t sa_mask;
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/parisc/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/parisc/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,27 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long long st_dev;
+ unsigned int __pad1;
+
+ unsigned int __st_ino; /* Not actually filled in */
+ unsigned int st_mode;
+ unsigned int st_nlink;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned long long st_rdev;
+ unsigned int __pad2;
+ signed long long st_size;
+ signed int st_blksize;
+
+ signed long long st_blocks;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned long long st_ino;
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/parisc/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/parisc/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * arch/parisc/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,36 @@
+/*
+ * arch/ppc/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __r2;
+ unsigned long __sp;
+ unsigned long __lr;
+ unsigned long __cr;
+ unsigned long __r13;
+ unsigned long __r14;
+ unsigned long __r15;
+ unsigned long __r16;
+ unsigned long __r17;
+ unsigned long __r18;
+ unsigned long __r19;
+ unsigned long __r20;
+ unsigned long __r21;
+ unsigned long __r22;
+ unsigned long __r23;
+ unsigned long __r24;
+ unsigned long __r25;
+ unsigned long __r26;
+ unsigned long __r27;
+ unsigned long __r28;
+ unsigned long __r29;
+ unsigned long __r30;
+ unsigned long __r31;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/ppc/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,28 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1.
+ */
+struct stat {
+ unsigned long long st_dev; /* Device. */
+ unsigned long long st_ino; /* File serial number. */
+ unsigned int st_mode; /* File mode. */
+ unsigned int st_nlink; /* Link count. */
+ unsigned int st_uid; /* User ID of the file's owner. */
+ unsigned int st_gid; /* Group ID of the file's group. */
+ unsigned long long st_rdev; /* Device number, if device. */
+ unsigned short int __pad2;
+ long long st_size; /* Size of file, in bytes. */
+ long st_blksize; /* Optimal block size for I/O. */
+
+ long long st_blocks; /* Number 512-byte blocks allocated. */
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+ unsigned long int __unused4;
+ unsigned long int __unused5;
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/ppc/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,61 @@
+/*
+ * arch/ppc/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* PowerPC seems to lack _syscall6() in its headers */
+/* This seems to work on both 32- and 64-bit ppc */
+
+#ifndef _syscall6
+
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5,type6,arg6) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
+{ \
+ unsigned long __sc_ret, __sc_err; \
+ { \
+ register unsigned long __sc_0 __asm__ ("r0"); \
+ register unsigned long __sc_3 __asm__ ("r3"); \
+ register unsigned long __sc_4 __asm__ ("r4"); \
+ register unsigned long __sc_5 __asm__ ("r5"); \
+ register unsigned long __sc_6 __asm__ ("r6"); \
+ register unsigned long __sc_7 __asm__ ("r7"); \
+ register unsigned long __sc_8 __asm__ ("r8"); \
+ \
+ __sc_3 = (unsigned long) (arg1); \
+ __sc_4 = (unsigned long) (arg2); \
+ __sc_5 = (unsigned long) (arg3); \
+ __sc_6 = (unsigned long) (arg4); \
+ __sc_7 = (unsigned long) (arg5); \
+ __sc_8 = (unsigned long) (arg6); \
+ __sc_0 = __NR_##name; \
+ __asm__ __volatile__ \
+ ("sc \n\t" \
+ "mfcr %1 " \
+ : "+r" (__sc_3), \
+ "+r" (__sc_0), \
+ "+r" (__sc_4), \
+ "+r" (__sc_5), \
+ "+r" (__sc_6), \
+ "+r" (__sc_7), \
+ "+r" (__sc_8) \
+ : : "cr0", "ctr", "memory", \
+ "r9", "r10", "r11", "r12"); \
+ __sc_ret = __sc_3; \
+ __sc_err = __sc_0; \
+ } \
+ if (__sc_err & 0x10000000) \
+ { \
+ errno = (int)__sc_ret; \
+ __sc_ret = -1; \
+ } \
+ return (type)__sc_ret; \
+}
+
+#endif /* _syscall6() missing */
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,36 @@
+/*
+ * arch/ppc64/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __r2;
+ unsigned long __sp;
+ unsigned long __lr;
+ unsigned long __cr;
+ unsigned long __r13;
+ unsigned long __r14;
+ unsigned long __r15;
+ unsigned long __r16;
+ unsigned long __r17;
+ unsigned long __r18;
+ unsigned long __r19;
+ unsigned long __r20;
+ unsigned long __r21;
+ unsigned long __r22;
+ unsigned long __r23;
+ unsigned long __r24;
+ unsigned long __r25;
+ unsigned long __r26;
+ unsigned long __r27;
+ unsigned long __r28;
+ unsigned long __r29;
+ unsigned long __r30;
+ unsigned long __r31;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/ppc64/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long st_dev;
+ ino_t st_ino;
+ nlink_t st_nlink;
+ mode_t st_mode;
+ uid_t st_uid;
+ gid_t st_gid;
+ unsigned long st_rdev;
+ off_t st_size;
+ unsigned long st_blksize;
+ unsigned long st_blocks;
+ struct timespec st_atim; /* Time of last access. */
+ struct timespec st_mtim; /* Time of last modification. */
+ struct timespec st_ctim; /* Time of last status change. */
+ unsigned long __unused4;
+ unsigned long __unused5;
+ unsigned long __unused6;
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/ppc64/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,52 @@
+/*
+ * arch/ppc64/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+#ifndef _syscall6
+
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5,type6,arg6) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
+{ \
+ unsigned long __sc_ret, __sc_err; \
+ { \
+ register unsigned long __sc_0 __asm__ ("r0"); \
+ register unsigned long __sc_3 __asm__ ("r3"); \
+ register unsigned long __sc_4 __asm__ ("r4"); \
+ register unsigned long __sc_5 __asm__ ("r5"); \
+ register unsigned long __sc_6 __asm__ ("r6"); \
+ register unsigned long __sc_7 __asm__ ("r7"); \
+ register unsigned long __sc_8 __asm__ ("r8"); \
+ \
+ __sc_3 = (unsigned long) (arg1); \
+ __sc_4 = (unsigned long) (arg2); \
+ __sc_5 = (unsigned long) (arg3); \
+ __sc_6 = (unsigned long) (arg4); \
+ __sc_7 = (unsigned long) (arg5); \
+ __sc_8 = (unsigned long) (arg6); \
+ __sc_0 = __NR_##name; \
+ __asm__ __volatile__ \
+ ("sc \n\t" \
+ "mfcr %1 " \
+ : "=&r" (__sc_3), "=&r" (__sc_0) \
+ : "0" (__sc_3), "1" (__sc_0), \
+ "r" (__sc_4), \
+ "r" (__sc_5), \
+ "r" (__sc_6), \
+ "r" (__sc_7), \
+ "r" (__sc_8) \
+ : __syscall_clobbers); \
+ __sc_ret = __sc_3; \
+ __sc_err = __sc_0; \
+ } \
+ __syscall_return (type); \
+}
+
+#endif /* _syscall6() missing */
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/s390/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/s390/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * arch/s390/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ uint32_t __gregs[10]; /* general registers r6-r15 */
+ uint64_t __fpregs[2]; /* fp registers f4 and f6 */
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/s390/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/s390/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/s390/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/s390/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/s390/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,31 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ */
+struct stat {
+ unsigned long long st_dev;
+ unsigned int __pad1;
+#define STAT64_HAS_BROKEN_ST_INO 1
+ unsigned long __st_ino;
+ unsigned int st_mode;
+ unsigned int st_nlink;
+ unsigned long st_uid;
+ unsigned long st_gid;
+ unsigned long long st_rdev;
+ unsigned int __pad3;
+ long long st_size;
+ unsigned long st_blksize;
+ unsigned char __pad4[4];
+ unsigned long __pad5; /* future possible st_blocks high bits */
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned long long st_ino;
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/s390/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/s390/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,41 @@
+/*
+ * arch/s390/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* S/390 only has five syscall parameters, and uses a structure for
+ 6-argument syscalls. */
+
+#ifndef _syscall6
+
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,\
+ type4,arg4,type5,arg5,type6,arg6) \
+type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
+ type5 arg5, type6 arg6) { \
+ unsigned long __arg[6] = { \
+ (unsigned long) arg1, \
+ (unsigned long) arg2, \
+ (unsigned long) arg3, \
+ (unsigned long) arg4, \
+ (unsigned long) arg5, \
+ (unsigned long) arg6 \
+ }; \
+ register void *__argp asm("2") = &__arg; \
+ long __res; \
+ __asm__ __volatile__ ( \
+ " svc %b1\n" \
+ " lr %0,2" \
+ : "=d" (__res) \
+ : "i" (__NR_##name), \
+ "d" (__argp) \
+ : _svc_clobber); \
+ __syscall_return(type, __res); \
+}
+
+#endif /* _syscall6() missing */
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * arch/s390x/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ uint64_t __gregs[10]; /* general registers r6-r15 */
+ uint64_t __fpregs[4]; /* fp registers f1, f3, f5, f7 */
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/s390x/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned long st_nlink;
+ unsigned int st_mode;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int __pad1;
+ unsigned long st_rdev;
+ unsigned long st_size;
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ unsigned long st_blksize;
+ long st_blocks;
+ unsigned long __unused[3];
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/s390x/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,41 @@
+/*
+ * arch/s390x/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* S/390X only has five syscall parameters, and uses a structure for
+ 6-argument syscalls. */
+
+#ifndef _syscall6
+
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,\
+ type4,arg4,type5,arg5,type6,arg6) \
+type name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
+ type5 arg5, type6 arg6) { \
+ unsigned long __arg[6] = { \
+ (unsigned long) arg1, \
+ (unsigned long) arg2, \
+ (unsigned long) arg3, \
+ (unsigned long) arg4, \
+ (unsigned long) arg5, \
+ (unsigned long) arg6 \
+ }; \
+ register void *__argp asm("2") = &__arg; \
+ long __res; \
+ __asm__ __volatile__ ( \
+ " svc %b1\n" \
+ " lgr %0,2" \
+ : "=d" (__res) \
+ : "i" (__NR_##name), \
+ "d" (__argp) \
+ : _svc_clobber); \
+ __syscall_return(type, __res); \
+}
+
+#endif /* _syscall6() missing */
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sh/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sh/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,22 @@
+/*
+ * arch/sh/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long r8;
+ unsigned long r9;
+ unsigned long r10;
+ unsigned long r11;
+ unsigned long r12;
+ unsigned long r13;
+ unsigned long r14;
+ unsigned long r15;
+ unsigned long pr;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _KLIBC_ARCHSETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sh/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sh/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/sh/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sh/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sh/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,45 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#include <endian.h>
+
+#define _STATBUF_ST_NSEC
+
+/* This matches struct stat64 in glibc2.1, hence the absolutely
+ * insane amounts of padding around dev_t's.
+ */
+struct stat64 {
+ unsigned long long st_dev;
+ unsigned char __pad0[4];
+
+ unsigned long st_ino;
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned long st_uid;
+ unsigned long st_gid;
+
+ unsigned long long st_rdev;
+ unsigned char __pad3[4];
+
+ long long st_size;
+ unsigned long st_blksize;
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+ unsigned long __pad4; /* Future possible st_blocks hi bits */
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+#else /* Must be little */
+ unsigned long st_blocks; /* Number 512-byte blocks allocated. */
+ unsigned long __pad4; /* Future possible st_blocks hi bits */
+#endif
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned long __unused1;
+ unsigned long __unused2;
+};
+
+#endif
+
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sh/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sh/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * arch/sh/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* No special syscall definitions for this architecture */
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * arch/sparc/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __sp;
+ unsigned long __fp;
+ unsigned long __pc;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/sparc/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,35 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long long st_dev;
+
+ unsigned long long st_ino;
+
+ unsigned int st_mode;
+ unsigned int st_nlink;
+
+ unsigned int st_uid;
+ unsigned int st_gid;
+
+ unsigned long long st_rdev;
+
+ unsigned char __pad3[8];
+
+ long long st_size;
+ unsigned int st_blksize;
+
+ unsigned char __pad4[8];
+ unsigned int st_blocks;
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+
+ unsigned int __unused4;
+ unsigned int __unused5;
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+/*
+ * arch/sparc/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/machine/asm.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/machine/asm.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,192 @@
+/* $NetBSD: asm.h,v 1.14 2002/07/20 08:37:30 mrg Exp $ */
+
+/*
+ * Copyright (c) 1994 Allen Briggs
+ * All rights reserved.
+ *
+ * Gleaned from locore.s and sun3 asm.h which had the following copyrights:
+ * locore.s:
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1982, 1990 The Regents of the University of California.
+ * sun3/include/asm.h:
+ * Copyright (c) 1993 Adam Glass
+ * Copyright (c) 1990 The Regents of the University of California.
+ *
+ * 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 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.
+ */
+
+#ifndef _ASM_H_
+#define _ASM_H_
+
+/* Pull in CCFSZ, CC64FSZ, and BIAS from frame.h */
+#ifndef _LOCORE
+#define _LOCORE
+#endif
+#include <machine/frame.h>
+
+#ifdef __ELF__
+#define _C_LABEL(name) name
+#else
+#ifdef __STDC__
+#define _C_LABEL(name) _ ## name
+#else
+#define _C_LABEL(name) _/**/name
+#endif
+#endif
+#define _ASM_LABEL(name) name
+
+#ifdef PIC
+/*
+ * PIC_PROLOGUE() is akin to the compiler generated function prologue for
+ * PIC code. It leaves the address of the Global Offset Table in DEST,
+ * clobbering register TMP in the process.
+ *
+ * We can use two code sequences. We can read the %pc or use the call
+ * instruction that saves the pc in %o7. Call requires the branch unit and
+ * IEU1, and clobbers %o7 which needs to be restored. This instruction
+ * sequence takes about 4 cycles due to instruction interdependence. Reading
+ * the pc takes 4 cycles to dispatch and is always dispatched alone. That
+ * sequence takes 7 cycles.
+ */
+#ifdef __arch64__
+#define PIC_PROLOGUE(dest,tmp) \
+ mov %o7, tmp; \
+ sethi %hi(_GLOBAL_OFFSET_TABLE_-4),dest; \
+ call 0f; \
+ or dest,%lo(_GLOBAL_OFFSET_TABLE_+4),dest; \
+0: \
+ add dest,%o7,dest; \
+ mov tmp, %o7
+#else
+#define PIC_PROLOGUE(dest,tmp) \
+ mov %o7,tmp; 3: call 4f; nop; 4: \
+ sethi %hi(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
+ or dest,%lo(_C_LABEL(_GLOBAL_OFFSET_TABLE_)-(3b-.)),dest; \
+ add dest,%o7,dest; mov tmp,%o7
+#endif
+
+/*
+ * PICCY_SET() does the equivalent of a `set var, %dest' instruction in
+ * a PIC-like way, but without involving the Global Offset Table. This
+ * only works for VARs defined in the same file *and* in the text segment.
+ */
+#ifdef __arch64__
+#define PICCY_SET(var,dest,tmp) \
+ 3: rd %pc, tmp; add tmp,(var-3b),dest
+#else
+#define PICCY_SET(var,dest,tmp) \
+ mov %o7,tmp; 3: call 4f; nop; 4: \
+ add %o7,(var-3b),dest; mov tmp,%o7
+#endif
+#else
+#define PIC_PROLOGUE(dest,tmp)
+#define PICCY_OFFSET(var,dest,tmp)
+#endif
+
+#define FTYPE(x) .type x, at function
+#define OTYPE(x) .type x, at object
+
+#define _ENTRY(name) \
+ .align 4; .globl name; .proc 1; FTYPE(name); name:
+
+#ifdef GPROF
+/* see _MCOUNT_ENTRY in profile.h */
+#ifdef __ELF__
+#ifdef __arch64__
+#define _PROF_PROLOGUE \
+ .data; .align 8; 1: .uaword 0; .uaword 0; \
+ .text; save %sp,-CC64FSZ,%sp; sethi %hi(1b),%o0; call _mcount; \
+ or %o0,%lo(1b),%o0; restore
+#else
+#define _PROF_PROLOGUE \
+ .data; .align 4; 1: .long 0; \
+ .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call _mcount; \
+ or %o0,%lo(1b),%o0; restore
+#endif
+#else
+#ifdef __arch64__
+#define _PROF_PROLOGUE \
+ .data; .align 8; 1: .uaword 0; .uaword 0; \
+ .text; save %sp,-CC64FSZ,%sp; sethi %hi(1b),%o0; call mcount; \
+ or %o0,%lo(1b),%o0; restore
+#else
+#define _PROF_PROLOGUE \
+ .data; .align 4; 1: .long 0; \
+ .text; save %sp,-96,%sp; sethi %hi(1b),%o0; call mcount; \
+ or %o0,%lo(1b),%o0; restore
+#endif
+#endif
+#else
+#define _PROF_PROLOGUE
+#endif
+
+#define ENTRY(name) _ENTRY(_C_LABEL(name)); _PROF_PROLOGUE
+#define ENTRY_NOPROFILE(name) _ENTRY(_C_LABEL(name))
+#define ASENTRY(name) _ENTRY(_ASM_LABEL(name)); _PROF_PROLOGUE
+#define FUNC(name) ASENTRY(name)
+#define RODATA(name) .align 4; .text; .globl _C_LABEL(name); \
+ OTYPE(_C_LABEL(name)); _C_LABEL(name):
+
+
+#define ASMSTR .asciz
+
+#define RCSID(name) .asciz name
+
+#ifdef __ELF__
+#define WEAK_ALIAS(alias,sym) \
+ .weak alias; \
+ alias = sym
+#endif
+
+/*
+ * WARN_REFERENCES: create a warning if the specified symbol is referenced.
+ */
+#ifdef __ELF__
+#ifdef __STDC__
+#define WARN_REFERENCES(_sym,_msg) \
+ .section .gnu.warning. ## _sym ; .ascii _msg ; .text
+#else
+#define WARN_REFERENCES(_sym,_msg) \
+ .section .gnu.warning./**/_sym ; .ascii _msg ; .text
+#endif /* __STDC__ */
+#else
+#ifdef __STDC__
+#define __STRING(x) #x
+#define WARN_REFERENCES(sym,msg) \
+ .stabs msg ## ,30,0,0,0 ; \
+ .stabs __STRING(_ ## sym) ## ,1,0,0,0
+#else
+#define __STRING(x) "x"
+#define WARN_REFERENCES(sym,msg) \
+ .stabs msg,30,0,0,0 ; \
+ .stabs __STRING(_/**/sym),1,0,0,0
+#endif /* __STDC__ */
+#endif /* __ELF__ */
+
+#endif /* _ASM_H_ */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/machine/frame.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/machine/frame.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,138 @@
+/* $NetBSD: frame.h,v 1.4 2001/12/04 00:05:05 darrenr Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * 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 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.
+ *
+ * @(#)frame.h 8.1 (Berkeley) 6/11/93
+ */
+
+#if defined(_KERNEL_OPT)
+#include "opt_sparc_arch.h"
+#endif
+
+/*
+ * Sparc stack frame format.
+ *
+ * Note that the contents of each stack frame may be held only in
+ * machine register windows. In order to get an accurate picture
+ * of the frame, you must first force the kernel to write any such
+ * windows to the stack.
+ */
+#ifndef _LOCORE
+#ifndef SUN4U
+struct frame {
+ int32_t fr_local[8]; /* space to save locals (%l0..%l7) */
+ int32_t fr_arg[6]; /* space to save arguments (%i0..%i5) */
+ struct frame *fr_fp; /* space to save frame pointer (%i6) */
+ int32_t fr_pc; /* space to save return pc (%i7) */
+ /*
+ * SunOS reserves another 8 words here; this is pointless
+ * but we do it for compatibility.
+ */
+ int32_t fr_xxx; /* `structure return pointer' (unused) */
+ int32_t fr_argd[6]; /* `arg dump area' (lunacy) */
+ int32_t fr_argx[1]; /* arg extension (args 7..n; variable size) */
+};
+#else
+struct frame32 {
+ int32_t fr_local[8]; /* space to save locals (%l0..%l7) */
+ int32_t fr_arg[6]; /* space to save arguments (%i0..%i5) */
+ u_int32_t fr_fp; /* space to save frame pointer (%i6) */
+ u_int32_t fr_pc; /* space to save return pc (%i7) */
+ /*
+ * SunOS reserves another 8 words here; this is pointless
+ * but we do it for compatibility.
+ */
+ int32_t fr_xxx; /* `structure return pointer' (unused) */
+ int32_t fr_argd[6]; /* `arg dump area' (lunacy) */
+ int32_t fr_argx[1]; /* arg extension (args 7..n; variable size) */
+};
+#endif
+#endif
+
+/*
+ * CCFSZ (C Compiler Frame SiZe) is the size of a stack frame required if
+ * a function is to call C code. It should be just 64, but Sun defined
+ * their frame with space to hold arguments 0 through 5 (plus some junk),
+ * and varargs routines (such as kprintf) demand this, and gcc uses this
+ * area at times anyway.
+ */
+#define CCFSZ 96
+
+/*
+ * Sparc v9 stack frame format.
+ *
+ * Note that the contents of each stack frame may be held only in
+ * machine register windows. In order to get an accurate picture
+ * of the frame, you must first force the kernel to write any such
+ * windows to the stack.
+ *
+ * V9 frames have an odd bias, so you can tall a v9 frame from
+ * a v8 frame by testing the stack pointer's lsb.
+ */
+#if !defined(_LOCORE) && !defined(_LIBC)
+struct frame64 {
+ int64_t fr_local[8]; /* space to save locals (%l0..%l7) */
+ int64_t fr_arg[6]; /* space to save arguments (%i0..%i5) */
+ u_int64_t fr_fp; /* space to save frame pointer (%i6) */
+ u_int64_t fr_pc; /* space to save return pc (%i7) */
+ /*
+ * SVR4 reserves a bunch of extra stuff.
+ */
+ int64_t fr_argd[6]; /* `register save area' (lunacy) */
+ int64_t fr_argx[0]; /* arg extension (args 7..n; variable size) */
+};
+
+#define v9next_frame(f) ((struct frame64*)(f->fr_fp+BIAS))
+#endif
+
+/*
+ * CC64FSZ (C Compiler 64-bit Frame SiZe) is the size of a stack frame used
+ * by the compiler in 64-bit mode. It is (16)*8; space for 8 ins, 8 outs.
+ */
+#define CC64FSZ 176
+
+/*
+ * v9 stacks all have a bias of 2047 added to the %sp and %fp, so you can easily
+ * detect it by testing the register for an odd value. Why 2K-1 I don't know.
+ */
+#define BIAS (2048-1)
+
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/machine/trap.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sparc/machine/trap.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,141 @@
+/* $NetBSD: trap.h,v 1.11 1999/01/20 00:15:08 pk Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * 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 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.
+ *
+ * @(#)trap.h 8.1 (Berkeley) 6/11/93
+ */
+/*
+ * Sun4m support by Aaron Brown, Harvard University.
+ * Changes Copyright (c) 1995 The President and Fellows of Harvard College.
+ * All rights reserved.
+ */
+
+#ifndef _MACHINE_TRAP_H
+#define _MACHINE_TRAP_H
+
+/* trap vec (pri) description */
+#define T_RESET 0x00 /* (1) not actually vectored; jumps to 0 */
+#define T_TEXTFAULT 0x01 /* (2) address fault during instr fetch */
+#define T_ILLINST 0x02 /* (3) illegal instruction */
+#define T_PRIVINST 0x03 /* (4) privileged instruction */
+#define T_FPDISABLED 0x04 /* (5) fp instr while fp disabled */
+#define T_WINOF 0x05 /* (6) register window overflow */
+#define T_WINUF 0x06 /* (7) register window underflow */
+#define T_ALIGN 0x07 /* (8) address not properly aligned */
+#define T_FPE 0x08 /* (9) floating point exception */
+#define T_DATAFAULT 0x09 /* (10) address fault during data fetch */
+#define T_TAGOF 0x0a /* (11) tag overflow */
+/* 0x0b unused */
+/* 0x0c unused */
+/* 0x0d unused */
+/* 0x0e unused */
+/* 0x0f unused */
+/* 0x10 unused */
+#define T_L1INT 0x11 /* (27) level 1 interrupt */
+#define T_L2INT 0x12 /* (26) level 2 interrupt */
+#define T_L3INT 0x13 /* (25) level 3 interrupt */
+#define T_L4INT 0x14 /* (24) level 4 interrupt */
+#define T_L5INT 0x15 /* (23) level 5 interrupt */
+#define T_L6INT 0x16 /* (22) level 6 interrupt */
+#define T_L7INT 0x17 /* (21) level 7 interrupt */
+#define T_L8INT 0x18 /* (20) level 8 interrupt */
+#define T_L9INT 0x19 /* (19) level 9 interrupt */
+#define T_L10INT 0x1a /* (18) level 10 interrupt */
+#define T_L11INT 0x1b /* (17) level 11 interrupt */
+#define T_L12INT 0x1c /* (16) level 12 interrupt */
+#define T_L13INT 0x1d /* (15) level 13 interrupt */
+#define T_L14INT 0x1e /* (14) level 14 interrupt */
+#define T_L15INT 0x1f /* (13) level 15 interrupt */
+/* 0x20 unused */
+/* through 0x23 unused */
+#define T_CPDISABLED 0x24 /* (5) coprocessor instr while disabled */
+#define T_UNIMPLFLUSH 0x25 /* Unimplemented FLUSH */
+/* through 0x27 unused */
+#define T_CPEXCEPTION 0x28 /* (9) coprocessor exception */
+/* 0x29 unused */
+#define T_IDIV0 0x2a /* divide by zero (from hw [su]div instr) */
+#define T_STOREBUFFAULT 0x2b /* SuperSPARC: Store buffer copy-back fault */
+/* 0x2c unused */
+/* through 0x7f unused */
+
+/* beginning of `user' vectors (from trap instructions) - all priority 12 */
+#define T_SUN_SYSCALL 0x80 /* system call */
+#define T_BREAKPOINT 0x81 /* breakpoint `instruction' */
+#define T_DIV0 0x82 /* division routine was handed 0 */
+#define T_FLUSHWIN 0x83 /* flush windows */
+#define T_CLEANWIN 0x84 /* provide clean windows */
+#define T_RANGECHECK 0x85 /* ? */
+#define T_FIXALIGN 0x86 /* fix up unaligned accesses */
+#define T_INTOF 0x87 /* integer overflow ? */
+#define T_SVR4_SYSCALL 0x88 /* SVR4 system call */
+#define T_BSD_SYSCALL 0x89 /* BSD system call */
+#define T_KGDB_EXEC 0x8a /* for kernel gdb */
+
+/* 0x8b..0xff are currently unallocated, except the following */
+#define T_SVR4_GETCC 0xa0
+#define T_SVR4_SETCC 0xa1
+#define T_SVR4_GETPSR 0xa2
+#define T_SVR4_SETPSR 0xa3
+#define T_SVR4_GETHRTIME 0xa4
+#define T_SVR4_GETHRVTIME 0xa5
+#define T_SVR4_GETHRESTIME 0xa7
+
+
+#ifdef _KERNEL /* pseudo traps for locore.s */
+#define T_RWRET -1 /* need first user window for trap return */
+#define T_AST -2 /* no-op, just needed reschedule or profile */
+#endif
+
+/* flags to system call (flags in %g1 along with syscall number) */
+#define SYSCALL_G2RFLAG 0x400 /* on success, return to %g2 rather than npc */
+#define SYSCALL_G7RFLAG 0x800 /* use %g7 as above (deprecated) */
+
+/*
+ * `software trap' macros to keep people happy (sparc v8 manual says not
+ * to set the upper bits).
+ */
+#define ST_BREAKPOINT (T_BREAKPOINT & 0x7f)
+#define ST_DIV0 (T_DIV0 & 0x7f)
+#define ST_FLUSHWIN (T_FLUSHWIN & 0x7f)
+#define ST_SYSCALL (T_SUN_SYSCALL & 0x7f)
+
+#endif /* _MACHINE_TRAP_H_ */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * arch/sparc64/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __sp;
+ unsigned long __fp;
+ unsigned long __pc;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/sparc64/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,22 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+/* No nsec fields?! */
+struct stat {
+ unsigned st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ short st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ unsigned st_rdev;
+ off_t st_size;
+ time_t st_atime;
+ time_t st_mtime;
+ time_t st_ctime;
+ off_t st_blksize;
+ off_t st_blocks;
+ unsigned long __unused4[2];
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/sparc64/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+/*
+ * arch/sparc64/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/klibc/archsetjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/klibc/archsetjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,21 @@
+/*
+ * arch/x86_64/include/klibc/archsetjmp.h
+ */
+
+#ifndef _KLIBC_ARCHSETJMP_H
+#define _KLIBC_ARCHSETJMP_H
+
+struct __jmp_buf {
+ unsigned long __rbx;
+ unsigned long __rsp;
+ unsigned long __rbp;
+ unsigned long __r12;
+ unsigned long __r13;
+ unsigned long __r14;
+ unsigned long __r15;
+ unsigned long __rip;
+};
+
+typedef struct __jmp_buf jmp_buf[1];
+
+#endif /* _SETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/klibc/archsignal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/klibc/archsignal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/x86_64/include/klibc/archsignal.h
+ *
+ * Architecture-specific signal definitions
+ *
+ */
+
+#ifndef _KLIBC_ARCHSIGNAL_H
+#define _KLIBC_ARCHSIGNAL_H
+
+/* No special stuff for this architecture */
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/klibc/archstat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/klibc/archstat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,26 @@
+#ifndef _KLIBC_ARCHSTAT_H
+#define _KLIBC_ARCHSTAT_H
+
+#define _STATBUF_ST_NSEC
+
+struct stat {
+ unsigned long st_dev;
+ unsigned long st_ino;
+ unsigned long st_nlink;
+
+ unsigned int st_mode;
+ unsigned int st_uid;
+ unsigned int st_gid;
+ unsigned int __pad0;
+ unsigned long st_rdev;
+ long st_size;
+ long st_blksize;
+ long st_blocks; /* Number 512-byte blocks allocated. */
+
+ struct timespec st_atim;
+ struct timespec st_mtim;
+ struct timespec st_ctim;
+ long __unused[3];
+};
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/klibc/archsys.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/klibc/archsys.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,109 @@
+/*
+ * arch/x86_64/include/klibc/archsys.h
+ *
+ * Architecture-specific syscall definitions
+ */
+
+#ifndef _KLIBC_ARCHSYS_H
+#define _KLIBC_ARCHSYS_H
+
+/* The x86-64 syscall headers are needlessly inefficient */
+
+#undef _syscall0
+#undef _syscall1
+#undef _syscall2
+#undef _syscall3
+#undef _syscall4
+#undef _syscall5
+#undef _syscall6
+
+#define _syscall0(type,name) \
+type name (void) \
+{ \
+long __res; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall1(type,name,type1,arg1) \
+type name (type1 arg1) \
+{ \
+long __res; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"D" (arg1) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall2(type,name,type1,arg1,type2,arg2) \
+type name (type1 arg1,type2 arg2) \
+{ \
+long __res; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"D" (arg1),"S" (arg2) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
+type name (type1 arg1,type2 arg2,type3 arg3) \
+{ \
+long __res; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
+ "d" (arg3) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4) \
+{ \
+long __res; \
+register type4 __r10 asm("%r10") = arg4; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
+ "d" (arg3),"r" (__r10) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
+{ \
+long __res; \
+register type4 __r10 asm("%r10") = arg4; \
+register type5 __r8 asm("%r8") = arg5; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
+ "d" (arg3),"r" (__r10),"r" (__r8) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
+ type5,arg5,type6,arg6) \
+type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
+{ \
+long __res; \
+register type4 __r10 asm("%r10") = arg4; \
+register type5 __r8 asm("%r8") = arg5; \
+register type6 __r9 asm("%r9") = arg6; \
+__asm__ volatile (__syscall \
+ : "=a" (__res) \
+ : "0" (__NR_##name),"D" (arg1),"S" (arg2), \
+ "d" (arg3),"r" (__r10),"r" (__r8), "r" (__r9) \
+ : __syscall_clobber); \
+__syscall_return(type,__res); \
+}
+
+#endif /* _KLIBC_ARCHSYS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/sys/io.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arch/x86_64/sys/io.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,126 @@
+#ident "$Id: io.h,v 1.1 2004/01/25 01:34:29 hpa Exp $"
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2004 H. Peter Anvin - All Rights Reserved
+ *
+ * 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 AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * sys/io.h for the i386 architecture
+ *
+ * Basic I/O macros
+ */
+
+#ifndef _SYS_IO_H
+#define _SYS_IO_H 1
+
+/* I/O-related system calls */
+
+int iopl(int);
+int ioperm(unsigned long, unsigned long, int);
+
+/* Basic I/O macros */
+
+static __inline__ void
+outb(unsigned char __v, unsigned short __p)
+{
+ asm volatile("outb %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ void
+outw(unsigned short __v, unsigned short __p)
+{
+ asm volatile("outw %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ void
+outl(unsigned int __v, unsigned short __p)
+{
+ asm volatile("outl %0,%1" : : "a" (__v), "dN" (__p));
+}
+
+static __inline__ unsigned char
+inb(unsigned short __p)
+{
+ unsigned char __v;
+ asm volatile("inb %1,%0" : "=a" (__v) : "dN" (__p));
+ return v;
+}
+
+static __inline__ unsigned short
+inw(unsigned short __p)
+{
+ unsigned short __v;
+ asm volatile("inw %1,%0" : "=a" (__v) : "dN" (__p));
+ return v;
+}
+
+static __inline__ unsigned int
+inl(unsigned short __p)
+{
+ unsigned int __v;
+ asm volatile("inl %1,%0" : "=a" (__v) : "dN" (__p));
+ return v;
+}
+
+/* String I/O macros */
+
+static __inline__ void
+outsb (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsb" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+outsw (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsw" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+outsl (unsigned short __p, const void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; outsl" : "+S" (__d), "+c" (__n) : "d" (__p));
+}
+
+
+static __inline__ void
+insb (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insb" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+insw (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insw" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+static __inline__ void
+insl (unsigned short __p, void *__d, unsigned long __n)
+{
+ asm volatile("cld; rep; insl" : "+D" (__d), "+c" (__n) : "d" (__p));
+}
+
+#endif /* _SYS_IO_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/arpa/inet.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/arpa/inet.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+/*
+ * arpa/inet.h
+ */
+
+#ifndef _ARPA_INET_H
+#define _ARPA_INET_H
+
+#include <klibc/extern.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <netinet/in6.h>
+
+__extern uint32_t inet_addr(const char *);
+__extern int inet_aton(const char *, struct in_addr *);
+__extern char *inet_ntoa(struct in_addr);
+__extern int inet_pton(int, const char *, void *);
+__extern const char *inet_ntop(int, const void *, char *, size_t);
+__extern unsigned int inet_nsap_addr(const char *, unsigned char *, int);
+__extern char *inet_nsap_ntoa(int, const unsigned char *, char *);
+
+#endif /* _ARPA_INET_H */
+
+
Added: multipath-tools/upstream/current/klibc-0.190/include/assert.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/assert.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,22 @@
+/*
+ * assert.h
+ */
+
+#ifndef _ASSERT_H
+#define _ASSERT_H
+
+#ifdef NDEBUG
+
+#define assert(x) ((void)(x))
+
+#else
+
+extern void __assert_fail(const char *, const char *,
+ unsigned int);
+
+#define assert(x) ((x) ? (void)0 : __assert_fail(#x, __FILE__, __LINE__))
+
+#endif
+
+#endif /* _ASSERT_H */
+
Added: multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/limits.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/limits.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * bits32/limits.h
+ */
+
+#ifndef _BITSIZE_LIMITS_H
+#define _BITSIZE_LIMITS_H
+
+#define LONG_BIT 32
+
+#define LONG_MIN (-2147483647L-1)
+#define LONG_MAX 2147483647L
+#define ULONG_MAX 4294967295UL
+
+#endif /* _BITSIZE_LIMITS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/stddef.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/stddef.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+/*
+ * bits32/stddef.h
+ */
+
+#ifndef _BITSIZE_STDDEF_H
+#define _BITSIZE_STDDEF_H
+
+#define _SIZE_T
+#if defined(__s390__) || defined(__hppa__) || defined(__cris__)
+typedef unsigned long size_t;
+#else
+typedef unsigned int size_t;
+#endif
+
+#define _PTRDIFF_T
+typedef signed int ptrdiff_t;
+
+#endif /* _BITSIZE_STDDEF_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/stdint.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/stdint.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,34 @@
+/*
+ * bits32/stdint.h
+ */
+
+#ifndef _BITSIZE_STDINT_H
+#define _BITSIZE_STDINT_H
+
+typedef signed char int8_t;
+typedef short int int16_t;
+typedef int int32_t;
+typedef long long int int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short int uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long long int uint64_t;
+
+typedef int int_fast16_t;
+typedef int int_fast32_t;
+
+typedef unsigned int uint_fast16_t;
+typedef unsigned int uint_fast32_t;
+
+typedef int intptr_t;
+typedef unsigned int uintptr_t;
+
+#define __INT64_C(c) c ## LL
+#define __UINT64_C(c) c ## ULL
+
+#define __PRI64_RANK "ll"
+#define __PRIFAST_RANK ""
+#define __PRIPTR_RANK ""
+
+#endif /* _BITSIZE_STDINT_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/stdintconst.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/stdintconst.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+/*
+ * bits32/stdintconst.h
+ */
+
+#ifndef _BITSIZE_STDINTCONST_H
+#define _BITSIZE_STDINTCONST_H
+
+#define INT_FAST16_C(c) INT32_C(c)
+#define INT_FAST32_C(c) INT32_C(c)
+
+#define UINT_FAST16_C(c) UINT32_C(c)
+#define UINT_FAST32_C(c) UINT32_C(c)
+
+#define INTPTR_C(c) INT32_C(c)
+#define UINTPTR_C(c) UINT32_C(c)
+#define PTRDIFF_C(c) INT32_C(c)
+
+#endif /* _BITSIZE_STDINTCONST_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/stdintlimits.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/bits32/bitsize/stdintlimits.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,22 @@
+/*
+ * bits32/stdintlimits.h
+ */
+
+#ifndef _BITSIZE_STDINTLIMITS_H
+#define _BITSIZE_STDINTLIMITS_H
+
+#define INT_FAST16_MIN INT32_MIN
+#define INT_FAST32_MIN INT32_MIN
+#define INT_FAST16_MAX INT32_MAX
+#define INT_FAST32_MAX INT32_MAX
+#define UINT_FAST16_MAX UINT32_MAX
+#define UINT_FAST32_MAX UINT32_MAX
+
+#define INTPTR_MIN INT32_MIN
+#define INTPTR_MAX INT32_MAX
+#define UINTPTR_MAX UINT32_MAX
+
+#define PTRDIFF_MIN INT32_MIN
+#define PTRDIFF_MAX INT32_MAX
+
+#endif /* _BITSIZE_STDINTLIMITS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/limits.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/limits.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * bits64/limits.h
+ */
+
+#ifndef _BITSIZE_LIMITS_H
+#define _BITSIZE_LIMITS_H
+
+#define LONG_BIT 64
+
+#define LONG_MIN (-9223372036854775807L-1)
+#define LONG_MAX 9223372036854775807L
+#define ULONG_MAX 18446744073709551615UL
+
+#endif /* _BITSIZE_LIMITS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/stddef.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/stddef.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * bits64/stddef.h
+ */
+
+#ifndef _BITSIZE_STDDEF_H
+#define _BITSIZE_STDDEF_H
+
+#define _SIZE_T
+typedef unsigned long size_t;
+#define _PTRDIFF_T
+typedef signed long ptrdiff_t;
+
+#endif /* _BITSIZE_STDDEF_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/stdint.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/stdint.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,36 @@
+/*
+ * bits64/stdint.h
+ */
+
+#ifndef _BITSIZE_STDINT_H
+#define _BITSIZE_STDINT_H
+
+typedef signed char int8_t;
+typedef short int int16_t;
+typedef int int32_t;
+typedef long int int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short int uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long int uint64_t;
+
+typedef long int int_fast16_t;
+typedef long int int_fast32_t;
+
+typedef unsigned long int uint_fast16_t;
+typedef unsigned long int uint_fast32_t;
+
+typedef long int intptr_t;
+typedef unsigned long int uintptr_t;
+
+#define __INT64_C(c) c ## L
+#define __UINT64_C(c) c ## UL
+
+#define __PRI64_RANK "l"
+#define __PRIFAST_RANK "l"
+#define __PRIPTR_RANK "l"
+
+#endif /* _BITSIZE_STDINT_H */
+
+
Added: multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/stdintconst.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/stdintconst.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+/*
+ * bits64/stdintconst.h
+ */
+
+#ifndef _BITSIZE_STDINTCONST_H
+#define _BITSIZE_STDINTCONST_H
+
+#define INT_FAST16_C(c) INT64_C(c)
+#define INT_FAST32_C(c) INT64_C(c)
+
+#define UINT_FAST16_C(c) UINT64_C(c)
+#define UINT_FAST32_C(c) UINT64_C(c)
+
+#define INTPTR_C(c) INT64_C(c)
+#define UINTPTR_C(c) UINT64_C(c)
+#define PTRDIFF_C(c) INT64_C(c)
+
+#endif /* _BITSIZE_STDINTCONST_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/stdintlimits.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/bits64/bitsize/stdintlimits.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,22 @@
+/*
+ * bits64/stdintlimits.h
+ */
+
+#ifndef _BITSIZE_STDINTLIMITS_H
+#define _BITSIZE_STDINTLIMITS_H
+
+#define INT_FAST16_MIN INT64_MIN
+#define INT_FAST32_MIN INT64_MIN
+#define INT_FAST16_MAX INT64_MAX
+#define INT_FAST32_MAX INT64_MAX
+#define UINT_FAST16_MAX UINT64_MAX
+#define UINT_FAST32_MAX UINT64_MAX
+
+#define INTPTR_MIN INT64_MIN
+#define INTPTR_MAX INT64_MAX
+#define UINTPTR_MAX UINT64_MAX
+
+#define PTRDIFF_MIN INT64_MIN
+#define PTRDIFF_MAX INT64_MAX
+
+#endif /* _BITSIZE_STDINTLIMITS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/ctype.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/ctype.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,119 @@
+/*
+ * ctype.h
+ *
+ * This assumes ISO 8859-1, being a reasonable superset of ASCII.
+ */
+
+#ifndef _CTYPE_H
+#define _CTYPE_H
+
+#ifndef __CTYPE_NO_INLINE
+# define __ctype_inline extern __inline__
+#else
+# define __ctype_inline
+#endif
+
+/*
+ * This relies on the following definitions:
+ *
+ * cntrl = !print
+ * alpha = upper|lower
+ * graph = punct|alpha|digit
+ * blank = '\t' || ' ' (per POSIX requirement)
+ */
+enum {
+ __ctype_upper = (1 << 0),
+ __ctype_lower = (1 << 1),
+ __ctype_digit = (1 << 2),
+ __ctype_xdigit = (1 << 3),
+ __ctype_space = (1 << 4),
+ __ctype_print = (1 << 5),
+ __ctype_punct = (1 << 6),
+ __ctype_cntrl = (1 << 7),
+};
+
+extern const unsigned char __ctypes[];
+
+__ctype_inline int isalnum(int __c)
+{
+ return __ctypes[__c+1] &
+ (__ctype_upper|__ctype_lower|__ctype_digit);
+}
+
+__ctype_inline int isalpha(int __c)
+{
+ return __ctypes[__c+1] &
+ (__ctype_upper|__ctype_lower);
+}
+
+__ctype_inline int isascii(int __c)
+{
+ return !(__c & ~0x7f);
+}
+
+__ctype_inline int isblank(int __c)
+{
+ return (__c == '\t') || (__c == ' ');
+}
+
+__ctype_inline int iscntrl(int __c)
+{
+ return __ctypes[__c+1] & __ctype_cntrl;
+}
+
+__ctype_inline int isdigit(int __c)
+{
+ return ((unsigned)__c - '0') <= 9;
+}
+
+__ctype_inline int isgraph(int __c)
+{
+ return __ctypes[__c+1] &
+ (__ctype_upper|__ctype_lower|__ctype_digit|__ctype_punct);
+}
+
+__ctype_inline int islower(int __c)
+{
+ return __ctypes[__c+1] & __ctype_lower;
+}
+
+__ctype_inline int isprint(int __c)
+{
+ return __ctypes[__c+1] & __ctype_print;
+}
+
+__ctype_inline int ispunct(int __c)
+{
+ return __ctypes[__c+1] & __ctype_punct;
+}
+
+__ctype_inline int isspace(int __c)
+{
+ return __ctypes[__c+1] & __ctype_space;
+}
+
+__ctype_inline int isupper(int __c)
+{
+ return __ctypes[__c+1] & __ctype_upper;
+}
+
+__ctype_inline int isxdigit(int __c)
+{
+ return __ctypes[__c+1] & __ctype_xdigit;
+}
+
+/* Note: this is decimal, not hex, to avoid accidental promotion to unsigned */
+#define _toupper(__c) ((__c) & ~32)
+#define _tolower(__c) ((__c) | 32)
+
+__ctype_inline int toupper(int __c)
+{
+ return islower(__c) ? _toupper(__c) : __c;
+}
+
+__ctype_inline int tolower(int __c)
+{
+ return isupper(__c) ? _tolower(__c) : __c;
+}
+
+#endif /* _CTYPE_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/dirent.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/dirent.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,32 @@
+/*
+ * dirent.h
+ */
+
+#ifndef _DIRENT_H
+#define _DIRENT_H
+
+#include <klibc/extern.h>
+#include <sys/dirent.h>
+
+struct _IO_dir {
+ int __fd;
+
+#ifdef __KLIBC_DIRENT_INTERNALS
+ /* These fields for internal use only */
+
+ size_t bytes_left;
+ struct dirent *next;
+ /* Declaring this as an array of struct enforces correct alignment */
+ struct dirent buffer[15]; /* 15 times max dirent size =~ 4K */
+#endif
+};
+typedef struct _IO_dir DIR;
+
+__extern DIR *opendir(const char *);
+__extern struct dirent *readdir(DIR *);
+__extern int closedir(DIR *);
+static __inline__ int dirfd (DIR *__d) {
+ return __d->__fd;
+}
+
+#endif /* _DIRENT_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/elf.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/elf.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * elf.h
+ */
+
+#ifndef _ELF_H
+#define _ELF_H
+
+#include <sys/elf32.h>
+#include <sys/elf64.h>
+
+#endif /* _ELF_H */
+
Added: multipath-tools/upstream/current/klibc-0.190/include/endian.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/endian.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,42 @@
+/*
+ * endian.h
+ */
+
+#ifndef _ENDIAN_H
+#define _ENDIAN_H
+
+#include <klibc/compiler.h>
+#include <asm/byteorder.h>
+
+/* Linux' asm/byteorder.h defines either __LITTLE_ENDIAN or
+ __BIG_ENDIAN, but the glibc/BSD-ish macros expect both to be
+ defined with __BYTE_ORDER defining which is actually used... */
+
+#if defined(__LITTLE_ENDIAN)
+# undef __LITTLE_ENDIAN
+# define __LITTLE_ENDIAN 1234
+# define __BIG_ENDIAN 4321
+# define __PDP_ENDIAN 3412
+# define __BYTE_ORDER __LITTLE_ENDIAN
+#elif defined(__BIG_ENDIAN)
+# undef __BIG_ENDIAN
+# define __LITTLE_ENDIAN 1234
+# define __BIG_ENDIAN 4321
+# define __PDP_ENDIAN 3412
+# define __BYTE_ORDER __BIG_ENDIAN
+#elif defined(__PDP_ENDIAN)
+# undef __PDP_ENDIAN
+# define __LITTLE_ENDIAN 1234
+# define __BIG_ENDIAN 4321
+# define __PDP_ENDIAN 3412
+# define __BYTE_ORDER __PDP_ENDIAN
+#else
+# error "Unknown byte order!"
+#endif
+
+#define LITTLE_ENDIAN __LITTLE_ENDIAN
+#define BIG_ENDIAN __BIG_ENDIAN
+#define PDP_ENDIAN __PDP_ENDIAN
+#define BYTE_ORDER __BYTE_ORDER
+
+#endif /* _ENDIAN_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/errno.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/errno.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,8 @@
+/*
+ * errno.h
+ */
+
+#include <klibc/extern.h>
+#include <asm/errno.h>
+
+__extern int errno;
Added: multipath-tools/upstream/current/klibc-0.190/include/fcntl.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/fcntl.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,46 @@
+/*
+ * fcntl.h
+ */
+
+#ifndef _FCNTL_H
+#define _FCNTL_H
+
+#include <klibc/extern.h>
+#include <klibc/compiler.h>
+#include <sys/types.h>
+#if defined(__mips__) && !defined(__mips64__)
+# include <klibc/archfcntl.h>
+#endif
+#include <linux/fcntl.h>
+
+/* This is ugly, but "struct flock" has actually been defined with
+ a long off_t, so it's really "struct flock64". It just happens
+ to work. Gag. Barf.
+
+ This happens to work on all 32-bit architectures except MIPS. */
+
+#ifdef F_GETLK64
+# undef F_GETLK
+# define F_GETLK F_GETLK64
+#endif
+
+#ifdef F_SETLK64
+# undef F_SETLK
+# define F_SETLK F_SETLK64
+#endif
+
+#ifdef F_SETLKW64
+# undef F_SETLKW
+# define F_SETLKW F_SETLKW64
+#endif
+
+/* This is defined here as well as in <unistd.h> since old-style code
+ would still include <fcntl.h> when using open(), and open() being
+ a varadic function changes its calling convention on some architectures. */
+#ifndef _KLIBC_IN_OPEN_C
+__extern int open(const char *, int, ...);
+#endif
+
+__extern int fcntl(int, int, ...);
+
+#endif /* _FCNTL_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/grp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/grp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * grp.h
+ */
+
+#ifndef _GRP_H
+#define _GRP_H
+
+#include <klibc/extern.h>
+#include <sys/types.h>
+
+__extern int setgroups(size_t, const gid_t *);
+
+#endif /* _GRP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/inttypes.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/inttypes.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,226 @@
+/*
+ * inttypes.h
+ */
+
+#ifndef _INTTYPES_H
+#define _INTTYPES_H
+
+#include <klibc/extern.h>
+#include <stdint.h>
+#include <stddef.h>
+
+static __inline__ intmax_t imaxabs(intmax_t __n)
+{
+ return (__n < (intmax_t)0) ? -__n : __n;
+}
+
+__extern intmax_t strtoimax(const char *, char **, int);
+__extern uintmax_t strtoumax(const char *, char **, int);
+
+/* extensions */
+__extern intmax_t strntoimax(const char *, char **, int, size_t);
+__extern uintmax_t strntoumax(const char *, char **, int, size_t);
+
+#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS)
+
+#define PRId8 "d"
+#define PRId16 "d"
+#define PRId32 "d"
+#define PRId64 __PRI64_RANK "d"
+
+#define PRIdLEAST8 "d"
+#define PRIdLEAST16 "d"
+#define PRIdLEAST32 "d"
+#define PRIdLEAST64 __PRI64_RANK "d"
+
+#define PRIdFAST8 "d"
+#define PRIdFAST16 __PRIFAST_RANK "d"
+#define PRIdFAST32 __PRIFAST_RANK "d"
+#define PRIdFAST64 __PRI64_RANK "d"
+
+#define PRIdMAX __PRI64_RANK "d"
+#define PRIdPTR __PRIPTR_RANK "d"
+
+#define PRIi8 "i"
+#define PRIi16 "i"
+#define PRIi32 "i"
+#define PRIi64 __PRI64_RANK "i"
+
+#define PRIiLEAST8 "i"
+#define PRIiLEAST16 "i"
+#define PRIiLEAST32 "i"
+#define PRIiLEAST64 __PRI64_RANK "i"
+
+#define PRIiFAST8 "i"
+#define PRIiFAST16 __PRIFAST_RANK "i"
+#define PRIiFAST32 __PRIFAST_RANK "i"
+#define PRIiFAST64 __PRI64_RANK "i"
+
+#define PRIiMAX __PRI64_RANK "i"
+#define PRIiPTR __PRIPTR_RANK "i"
+
+#define PRIo8 "o"
+#define PRIo16 "o"
+#define PRIo32 "o"
+#define PRIo64 __PRI64_RANK "o"
+
+#define PRIoLEAST8 "o"
+#define PRIoLEAST16 "o"
+#define PRIoLEAST32 "o"
+#define PRIoLEAST64 __PRI64_RANK "o"
+
+#define PRIoFAST8 "o"
+#define PRIoFAST16 __PRIFAST_RANK "o"
+#define PRIoFAST32 __PRIFAST_RANK "o"
+#define PRIoFAST64 __PRI64_RANK "o"
+
+#define PRIoMAX __PRI64_RANK "o"
+#define PRIoPTR __PRIPTR_RANK "o"
+
+#define PRIu8 "u"
+#define PRIu16 "u"
+#define PRIu32 "u"
+#define PRIu64 __PRI64_RANK "u"
+
+#define PRIuLEAST8 "u"
+#define PRIuLEAST16 "u"
+#define PRIuLEAST32 "u"
+#define PRIuLEAST64 __PRI64_RANK "u"
+
+#define PRIuFAST8 "u"
+#define PRIuFAST16 __PRIFAST_RANK "u"
+#define PRIuFAST32 __PRIFAST_RANK "u"
+#define PRIuFAST64 __PRI64_RANK "u"
+
+#define PRIuMAX __PRI64_RANK "u"
+#define PRIuPTR __PRIPTR_RANK "u"
+
+#define PRIx8 "x"
+#define PRIx16 "x"
+#define PRIx32 "x"
+#define PRIx64 __PRI64_RANK "x"
+
+#define PRIxLEAST8 "x"
+#define PRIxLEAST16 "x"
+#define PRIxLEAST32 "x"
+#define PRIxLEAST64 __PRI64_RANK "x"
+
+#define PRIxFAST8 "x"
+#define PRIxFAST16 __PRIFAST_RANK "x"
+#define PRIxFAST32 __PRIFAST_RANK "x"
+#define PRIxFAST64 __PRI64_RANK "x"
+
+#define PRIxMAX __PRI64_RANK "x"
+#define PRIxPTR __PRIPTR_RANK "x"
+
+#define PRIX8 "X"
+#define PRIX16 "X"
+#define PRIX32 "X"
+#define PRIX64 __PRI64_RANK "X"
+
+#define PRIXLEAST8 "X"
+#define PRIXLEAST16 "X"
+#define PRIXLEAST32 "X"
+#define PRIXLEAST64 __PRI64_RANK "X"
+
+#define PRIXFAST8 "X"
+#define PRIXFAST16 __PRIFAST_RANK "X"
+#define PRIXFAST32 __PRIFAST_RANK "X"
+#define PRIXFAST64 __PRI64_RANK "X"
+
+#define PRIXMAX __PRI64_RANK "X"
+#define PRIXPTR __PRIPTR_RANK "X"
+
+#define SCNd8 "hhd"
+#define SCNd16 "hd"
+#define SCNd32 "d"
+#define SCNd64 __PRI64_RANK "d"
+
+#define SCNdLEAST8 "hhd"
+#define SCNdLEAST16 "hd"
+#define SCNdLEAST32 "d"
+#define SCNdLEAST64 __PRI64_RANK "d"
+
+#define SCNdFAST8 "hhd"
+#define SCNdFAST16 __PRIFAST_RANK "d"
+#define SCNdFAST32 __PRIFAST_RANK "d"
+#define SCNdFAST64 __PRI64_RANK "d"
+
+#define SCNdMAX __PRI64_RANK "d"
+#define SCNdPTR __PRIPTR_RANK "d"
+
+#define SCNi8 "hhi"
+#define SCNi16 "hi"
+#define SCNi32 "i"
+#define SCNi64 __PRI64_RANK "i"
+
+#define SCNiLEAST8 "hhi"
+#define SCNiLEAST16 "hi"
+#define SCNiLEAST32 "i"
+#define SCNiLEAST64 __PRI64_RANK "i"
+
+#define SCNiFAST8 "hhi"
+#define SCNiFAST16 __PRIFAST_RANK "i"
+#define SCNiFAST32 __PRIFAST_RANK "i"
+#define SCNiFAST64 __PRI64_RANK "i"
+
+#define SCNiMAX __PRI64_RANK "i"
+#define SCNiPTR __PRIPTR_RANK "i"
+
+#define SCNo8 "hho"
+#define SCNo16 "ho"
+#define SCNo32 "o"
+#define SCNo64 __PRI64_RANK "o"
+
+#define SCNoLEAST8 "hho"
+#define SCNoLEAST16 "ho"
+#define SCNoLEAST32 "o"
+#define SCNoLEAST64 __PRI64_RANK "o"
+
+#define SCNoFAST8 "hho"
+#define SCNoFAST16 __PRIFAST_RANK "o"
+#define SCNoFAST32 __PRIFAST_RANK "o"
+#define SCNoFAST64 __PRI64_RANK "o"
+
+#define SCNoMAX __PRI64_RANK "o"
+#define SCNoPTR __PRIPTR_RANK "o"
+
+#define SCNu8 "hhu"
+#define SCNu16 "hu"
+#define SCNu32 "u"
+#define SCNu64 __PRI64_RANK "u"
+
+#define SCNuLEAST8 "hhu"
+#define SCNuLEAST16 "hu"
+#define SCNuLEAST32 "u"
+#define SCNuLEAST64 __PRI64_RANK "u"
+
+#define SCNuFAST8 "hhu"
+#define SCNuFAST16 __PRIFAST_RANK "u"
+#define SCNuFAST32 __PRIFAST_RANK "u"
+#define SCNuFAST64 __PRI64_RANK "u"
+
+#define SCNuMAX __PRI64_RANK "u"
+#define SCNuPTR __PRIPTR_RANK "u"
+
+#define SCNx8 "hhx"
+#define SCNx16 "hx"
+#define SCNx32 "x"
+#define SCNx64 __PRI64_RANK "x"
+
+#define SCNxLEAST8 "hhx"
+#define SCNxLEAST16 "hx"
+#define SCNxLEAST32 "x"
+#define SCNxLEAST64 __PRI64_RANK "x"
+
+#define SCNxFAST8 "hhx"
+#define SCNxFAST16 __PRIFAST_RANK "x"
+#define SCNxFAST32 __PRIFAST_RANK "x"
+#define SCNxFAST64 __PRI64_RANK "x"
+
+#define SCNxMAX __PRI64_RANK "x"
+#define SCNxPTR __PRIPTR_RANK "x"
+
+#endif
+
+#endif /* _INTTYPES_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/klibc/compiler.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/klibc/compiler.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,119 @@
+/*
+ * klibc/compiler.h
+ *
+ * Various compiler features
+ */
+
+#ifndef _KLIBC_COMPILER_H
+#define _KLIBC_COMPILER_H
+
+/* Specific calling conventions */
+/* __cdecl is used when we want varadic and non-varadic functions to have
+ the same binary calling convention. */
+#ifdef __i386__
+# ifdef __GNUC__
+# define __cdecl __attribute__((cdecl,regparm(0)))
+# else
+ /* Most other C compilers have __cdecl as a keyword */
+# endif
+#else
+# define __cdecl /* Meaningless on non-i386 */
+#endif
+
+/* How to declare a function that *must* be inlined */
+#ifdef __GNUC__
+# if __GNUC_MAJOR__ >= 3
+# define __must_inline static __inline__ __attribute__((always_inline))
+# else
+# define __must_inline extern __inline__
+# endif
+#else
+# define __must_inline inline /* Just hope this works... */
+#endif
+
+/* How to declare a function that does not return */
+#ifdef __GNUC__
+# define __noreturn void __attribute__((noreturn))
+#else
+# define __noreturn void
+#endif
+
+/* "const" function:
+
+ Many functions do not examine any values except their arguments,
+ and have no effects except the return value. Basically this is
+ just slightly more strict class than the `pure' attribute above,
+ since function is not allowed to read global memory.
+
+ Note that a function that has pointer arguments and examines the
+ data pointed to must _not_ be declared `const'. Likewise, a
+ function that calls a non-`const' function usually must not be
+ `const'. It does not make sense for a `const' function to return
+ `void'.
+*/
+#ifdef __GNUC__
+# define __constfunc __attribute__((const))
+#else
+# define __constfunc
+#endif
+#undef __attribute_const__
+#define __attribute_const__ __constfunc
+
+/* "pure" function:
+
+ Many functions have no effects except the return value and their
+ return value depends only on the parameters and/or global
+ variables. Such a function can be subject to common subexpression
+ elimination and loop optimization just as an arithmetic operator
+ would be. These functions should be declared with the attribute
+ `pure'.
+*/
+#ifdef __GNUC__
+# define __purefunc __attribute__((pure))
+#else
+# define __purefunc
+#endif
+#undef __attribute_pure__
+#define __attribute_pure__ __purefunc
+
+/* Format attribute */
+#ifdef __GNUC__
+# define __formatfunc(t,f,a) __attribute__((format(t,f,a)))
+#else
+# define __formatfunc(t,f,a)
+#endif
+
+/* malloc() function (returns unaliased pointer) */
+#if defined(__GNUC__) && (__GNUC_MAJOR__ >= 3)
+# define __mallocfunc __attribute__((malloc))
+#else
+# define __mallocfunc
+#endif
+
+/* likely/unlikely */
+#if defined(__GNUC__) && (__GNUC_MAJOR__ > 2 || (__GNUC_MAJOR__ == 2 && __GNUC_MINOR__ >= 95))
+# define __likely(x) __builtin_expect((x), 1)
+# define __unlikely(x) __builtin_expect((x), 0)
+#else
+# define __likely(x) (x)
+# define __unlikely(x) (x)
+#endif
+
+/* Possibly unused function */
+#ifdef __GNUC__
+# define __unusedfunc __attribute__((unused))
+#else
+# define __unusedfunc
+#endif
+
+/* It's all user space... */
+#define __user
+
+/* The bitwise attribute: disallow arithmetric operations */
+#ifdef __CHECKER__ /* sparse only */
+# define __bitwise __attribute__((bitwise))
+#else
+# define __bitwise
+#endif
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/klibc/diverr.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/klibc/diverr.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * klibc/diverr.h
+ */
+
+#ifndef _KLIBC_DIVERR_H
+#define _KLIBC_DIVERR_H
+
+#include <signal.h>
+
+static __inline__ void
+__divide_error(void)
+{
+ raise(SIGFPE);
+}
+
+#endif /* _KLIBC_DIVERR_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/klibc/extern.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/klibc/extern.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * klibc/extern.h
+ */
+
+#ifndef _KLIBC_EXTERN_H
+#define _KLIBC_EXTERN_H
+
+#ifdef __cplusplus
+#define __extern extern "C"
+#else
+#define __extern extern
+#endif
+
+#endif /* _KLIBC_EXTERN_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/klibc/sysconfig.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/klibc/sysconfig.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,34 @@
+/*
+ * klibc/sysconfig.h
+ *
+ * Allows for definitions of some things which may be system-dependent
+ */
+
+#ifndef _KLIBC_SYSCONFIG_H
+#define _KLIBC_SYSCONFIG_H
+
+/*
+ * Define this to obtain memory using sbrk() instead
+ * of mmap(). This should make it friendlier on
+ * non-MMU architectures. This should become a
+ * per-architecture configurable.
+ */
+#undef MALLOC_USING_SBRK
+
+/*
+ * This is the minimum chunk size we will ask the kernel for using
+ * malloc(); this should be a multiple of the page size on all
+ * architectures.
+ */
+#define MALLOC_CHUNK_SIZE 65536
+#define MALLOC_CHUNK_MASK (MALLOC_CHUNK_SIZE-1)
+
+/*
+ * This is the minimum alignment for the memory returned by sbrk().
+ * It must be a power of 2. If MALLOC_USING_SBRK is defined it should
+ * be no smaller than the size of struct arena_header in malloc.h (4
+ * pointers.)
+ */
+#define SBRK_ALIGNMENT 32
+
+#endif /* _KLIBC_SYSCONFIG_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/limits.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/limits.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,40 @@
+/*
+ * limits.h
+ */
+
+#ifndef _LIMITS_H
+#define _LIMITS_H
+
+#define CHAR_BIT 8
+#define SHRT_BIT 16
+#define INT_BIT 32
+#define LONGLONG_BIT 64
+
+#define SCHAR_MIN (-128)
+#define SCHAR_MAX 127
+#define UCHAR_MAX 255
+
+#ifdef __CHAR_UNSIGNED__
+# define CHAR_MIN 0
+# define CHAR_MAX UCHAR_MAX
+#else
+# define CHAR_MIN SCHAR_MIN
+# define CHAR_MAX SCHAR_MAX
+#endif
+
+#define SHRT_MIN (-32768)
+#define SHRT_MAX 32767
+#define USHRT_MAX 65535
+
+#define INT_MIN (-2147483647-1)
+#define INT_MAX 2147483647
+#define UINT_MAX 4294967295U
+
+#define LONGLONG_MIN (-9223372036854775807LL-1)
+#define LONGLONG_MAX 9223372036854775807LL
+#define ULONGLONG_MAX 18446744073709551615ULL
+
+#include <bitsize/limits.h>
+#include <linux/limits.h>
+
+#endif /* _LIMITS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/net/if.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/net/if.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1 @@
+#include <linux/if.h>
Added: multipath-tools/upstream/current/klibc-0.190/include/net/if_arp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/net/if_arp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1 @@
+#include <linux/if_arp.h>
Added: multipath-tools/upstream/current/klibc-0.190/include/net/if_ether.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/net/if_ether.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1 @@
+#include <linux/if_ether.h>
Added: multipath-tools/upstream/current/klibc-0.190/include/net/if_packet.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/net/if_packet.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1 @@
+#include <linux/if_packet.h>
Added: multipath-tools/upstream/current/klibc-0.190/include/netinet/in.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/netinet/in.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,39 @@
+/*
+ * netinet/in.h
+ */
+
+#ifndef _NETINET_IN_H
+#define _NETINET_IN_H
+
+/* added this include by Mats Petersson */
+#include <linux/socket.h>
+
+#include <klibc/extern.h>
+#include <stdint.h>
+#include <endian.h> /* Must be included *before* <linux/in.h> */
+#include <linux/in.h>
+
+#ifndef htons
+# define htons(x) __cpu_to_be16(x)
+#endif
+#ifndef ntohs
+# define ntohs(x) __be16_to_cpu(x)
+#endif
+#ifndef htonl
+# define htonl(x) __cpu_to_be32(x)
+#endif
+#ifndef ntohl
+# define ntohl(x) __be32_to_cpu(x)
+#endif
+#ifndef htonq
+# define htonq(x) __cpu_to_be64(x)
+#endif
+#ifndef ntohq
+# define ntohq(x) __be64_to_cpu(x)
+#endif
+
+#define IPPORT_RESERVED 1024
+
+__extern int bindresvport (int sd, struct sockaddr_in *sin);
+
+#endif /* _NETINET_IN_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/netinet/in6.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/netinet/in6.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+/*
+ * netinet/in6.h
+ */
+
+#ifndef _NETINET_IN6_H
+#define _NETINET_IN6_H
+
+#include <linux/in6.h>
+
+#endif /* _NETINET_IN6_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/netinet/ip.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/netinet/ip.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * netinet/ip.h
+ */
+
+#ifndef _NETINET_IP_H
+#define _NETINET_IP_H
+
+#include <endian.h>
+#include <linux/ip.h>
+
+#define IP_DF 0x4000 /* Flag: "Don't Fragment" */
+
+#endif /* _NETINET_IP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/netinet/tcp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/netinet/tcp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+/*
+ * netinet/tcp.h
+ */
+
+#ifndef _NETINET_TCP_H
+#define _NETINET_TCP_H
+
+#include <endian.h> /* Include *before* linux/tcp.h */
+#include <linux/tcp.h>
+
+#endif /* _NETINET_TCP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/netinet/udp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/netinet/udp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * netinet/udp.h
+ */
+
+#ifndef _NETINET_UDP_H
+#define _NETINET_UDP_H
+
+/*
+ * We would include linux/udp.h, but it brings in too much other stuff
+ */
+
+struct udphdr {
+ __u16 source;
+ __u16 dest;
+ __u16 len;
+ __u16 check;
+};
+
+#endif /* _NETINET_UDP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/paths.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/paths.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1989, 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.
+ * 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.
+ *
+ * @(#)paths.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _PATHS_H_
+#define _PATHS_H_
+
+/* Default search path. */
+#define _PATH_DEFPATH "/usr/bin:/bin"
+/* All standard utilities path. */
+#define _PATH_STDPATH \
+ "/usr/bin:/bin:/usr/sbin:/sbin"
+
+#define _PATH_BSHELL "/bin/sh"
+#define _PATH_CONSOLE "/dev/console"
+#define _PATH_CSHELL "/bin/csh"
+#define _PATH_DEVDB "/var/run/dev.db"
+#define _PATH_DEVNULL "/dev/null"
+#define _PATH_DRUM "/dev/drum"
+#define _PATH_KLOG "/proc/kmsg"
+#define _PATH_KMEM "/dev/kmem"
+#define _PATH_LASTLOG "/var/log/lastlog"
+#define _PATH_MAILDIR "/var/mail"
+#define _PATH_MAN "/usr/share/man"
+#define _PATH_MEM "/dev/mem"
+#define _PATH_MNTTAB "/etc/fstab"
+#define _PATH_MOUNTED "/etc/mtab"
+#define _PATH_NOLOGIN "/etc/nologin"
+#define _PATH_PRESERVE "/var/lib"
+#define _PATH_RWHODIR "/var/spool/rwho"
+#define _PATH_SENDMAIL "/usr/sbin/sendmail"
+#define _PATH_SHADOW "/etc/shadow"
+#define _PATH_SHELLS "/etc/shells"
+#define _PATH_TTY "/dev/tty"
+#define _PATH_UNIX "/boot/vmlinux"
+#define _PATH_UTMP "/var/run/utmp"
+#define _PATH_VI "/bin/vi"
+#define _PATH_WTMP "/var/log/wtmp"
+
+/* Provide trailing slash, since mostly used for building pathnames. */
+#define _PATH_DEV "/dev/"
+#define _PATH_TMP "/tmp/"
+#define _PATH_VARDB "/var/db/"
+#define _PATH_VARRUN "/var/run/"
+#define _PATH_VARTMP "/var/tmp/"
+
+#endif /* !_PATHS_H_ */
Added: multipath-tools/upstream/current/klibc-0.190/include/poll.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/poll.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * poll.h
+ */
+
+#ifndef _POLL_H
+#define _POLL_H
+
+#include <klibc/extern.h>
+#include <linux/poll.h>
+
+/* POSIX specifies "int" for the timeout, Linux seems to use long... */
+
+typedef unsigned int nfds_t;
+__extern int poll(struct pollfd *, nfds_t, long);
+
+#endif /* _POLL_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sched.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sched.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,36 @@
+/*
+ * sched.h
+ */
+
+#ifndef _SCHED_H
+#define _SCHED_H
+
+#include <klibc/extern.h>
+
+/* linux/sched.h is unusable; put the declarations we need here... */
+
+#define SCHED_NORMAL 0
+#define SCHED_FIFO 1
+#define SCHED_RR 2
+
+struct sched_param {
+ int sched_priority;
+};
+
+__extern int sched_setscheduler(pid_t, int, const struct sched_param *);
+__extern int sched_yield(void);
+
+/* Raw interfaces to clone(2); only actually usable for non-VM-cloning */
+#ifdef __ia64__
+__extern pid_t __clone2(int, void *, void *);
+static __inline__ pid_t __clone(int _f, void *_sp)
+{
+ /* If this is used with _sp != 0 it will have the effect of the sp
+ and rsp growing away from a single point in opposite directions. */
+ return __clone2(_f, _sp, _sp);
+}
+#else
+__extern pid_t __clone(int, void *);
+#endif
+
+#endif /* _SCHED_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/setjmp.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/setjmp.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,43 @@
+/*
+ * setjmp.h
+ */
+
+#ifndef _SETJMP_H
+#define _SETJMP_H
+
+#include <klibc/extern.h>
+#include <klibc/compiler.h>
+#include <stddef.h>
+#include <signal.h>
+
+#include <klibc/archsetjmp.h>
+
+__extern int setjmp(jmp_buf);
+__extern __noreturn longjmp(jmp_buf, int);
+
+/*
+ Whose bright idea was it to add unrelated functionality to just about
+ the only function in the standard C library (setjmp) which cannot be
+ wrapped by an ordinary function wrapper? Anyway, the damage is done,
+ and therefore, this wrapper *must* be inline. However, gcc will
+ complain if this is an inline function for unknown reason, and
+ therefore sigsetjmp() needs to be a macro.
+*/
+
+struct __sigjmp_buf {
+ jmp_buf __jmpbuf;
+ sigset_t __sigs;
+};
+
+typedef struct __sigjmp_buf sigjmp_buf[1];
+
+#define sigsetjmp(__env, __save) \
+({ \
+ struct __sigjmp_buf *__e = (__env); \
+ sigprocmask(0, NULL, &__e->__sigs); \
+ setjmp(__e->__jmpbuf); \
+})
+
+__extern __noreturn siglongjmp(sigjmp_buf, int);
+
+#endif /* _SETJMP_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/signal.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/signal.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,81 @@
+/*
+ * signal.h
+ */
+
+#ifndef _SIGNAL_H
+#define _SIGNAL_H
+
+#include <klibc/compiler.h>
+#include <klibc/extern.h>
+#include <string.h> /* For memset() */
+#include <limits.h> /* For LONG_BIT */
+#include <sys/types.h>
+#include <asm/signal.h>
+
+#include <klibc/archsignal.h>
+
+/* glibc seems to use sig_atomic_t as "int" pretty much on all architectures.
+ Do the same, but allow the architecture to override. */
+#ifdef _KLIBC_HAS_ARCH_SIG_ATOMIC_T
+typedef int sig_atomic_t;
+#endif
+
+/* Some architectures don't define these */
+#ifndef SA_RESETHAND
+# define SA_RESETHAND SA_ONESHOT
+#endif
+#ifndef SA_NODEFER
+# define SA_NODEFER SA_NOMASK
+#endif
+#ifndef NSIG
+# define NSIG _NSIG
+#endif
+
+__extern const char * const sys_siglist[];
+
+/* This assumes sigset_t is either an unsigned long or an array of such,
+ and that _NSIG_BPW in the kernel is always LONG_BIT */
+
+static __inline__ int sigemptyset(sigset_t *__set)
+{
+ memset(__set, 0, sizeof *__set);
+ return 0;
+}
+static __inline__ int sigfillset(sigset_t *__set)
+{
+ memset(__set, ~0, sizeof *__set);
+ return 0;
+}
+static __inline__ int sigaddset(sigset_t *__set, int __signum)
+{
+ unsigned long *__lset = (unsigned long *)__set;
+ __lset[__signum/LONG_BIT] |= 1UL << (__signum%LONG_BIT);
+ return 0;
+}
+static __inline__ int sigdelset(sigset_t *__set, int __signum)
+{
+ unsigned long *__lset = (unsigned long *)__set;
+ __lset[__signum/LONG_BIT] &= ~(1UL << (__signum%LONG_BIT));
+ return 0;
+}
+static __inline__ int sigismember(sigset_t *__set, int __signum)
+{
+ unsigned long *__lset = (unsigned long *)__set;
+ return (int)((__lset[__signum/LONG_BIT] >> (__signum%LONG_BIT)) & 1);
+}
+
+__extern __sighandler_t __signal(int, __sighandler_t, int);
+__extern __sighandler_t sysv_signal(int, __sighandler_t);
+__extern __sighandler_t bsd_signal(int, __sighandler_t);
+__extern int sigaction(int, const struct sigaction *, struct sigaction *);
+__extern int sigprocmask(int, const sigset_t *, sigset_t *);
+__extern int sigpending(sigset_t *);
+__extern int sigsuspend(const sigset_t *);
+__extern int rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t);
+__extern int rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t);
+__extern int rt_sigpending(sigset_t *, size_t);
+__extern int rt_sigsuspend(const sigset_t *, size_t);
+__extern int raise(int);
+__extern int kill(pid_t, int);
+
+#endif /* _SIGNAL_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/stdarg.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/stdarg.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * stdarg.h
+ *
+ * This is just a wrapper for the gcc one, but defines va_copy()
+ * even if gcc doesn't.
+ */
+
+/* Note: the _STDARG_H macro belongs to the gcc header... */
+#include_next <stdarg.h>
+
+/* Older gcc considers this an extension, so it's double underbar only */
+#ifndef va_copy
+#define va_copy(d,s) __va_copy(d,s)
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/stddef.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/stddef.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+/*
+ * stddef.h
+ */
+
+#ifndef _STDDEF_H
+#define _STDDEF_H
+
+#ifndef __KLIBC__
+# define __KLIBC__ 1
+#endif
+
+#include <bitsize/stddef.h>
+
+#undef NULL
+#ifdef __cplusplus
+# define NULL 0
+#else
+# define NULL ((void *)0)
+#endif
+
+#undef offsetof
+#define offsetof(t,m) ((size_t)&((t *)0)->m)
+
+#endif /* _STDDEF_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/stdint.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/stdint.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,116 @@
+/*
+ * stdint.h
+ */
+
+#ifndef _STDINT_H
+#define _STDINT_H
+
+#include <bitsize/stdint.h>
+
+typedef int8_t int_least8_t;
+typedef int16_t int_least16_t;
+typedef int32_t int_least32_t;
+typedef int64_t int_least64_t;
+
+typedef uint8_t uint_least8_t;
+typedef uint16_t uint_least16_t;
+typedef uint32_t uint_least32_t;
+typedef uint64_t uint_least64_t;
+
+typedef int8_t int_fast8_t;
+typedef int64_t int_fast64_t;
+
+typedef uint8_t uint_fast8_t;
+typedef uint64_t uint_fast64_t;
+
+typedef int64_t intmax_t;
+typedef uint64_t uintmax_t;
+
+#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
+
+#define INT8_MIN (-128)
+#define INT16_MIN (-32768)
+#define INT32_MIN (-2147483647-1)
+#define INT64_MIN (__INT64_C(-9223372036854775807)-1)
+
+#define INT8_MAX (127)
+#define INT16_MAX (32767)
+#define INT32_MAX (2147483647)
+#define INT64_MAX (__INT64_C(9223372036854775807))
+
+#define UINT8_MAX (255U)
+#define UINT16_MAX (65535U)
+#define UINT32_MAX (4294967295U)
+#define UINT64_MAX (__UINT64_C(18446744073709551615))
+
+#define INT_LEAST8_MIN INT8_MIN
+#define INT_LEAST16_MIN INT16_MIN
+#define INT_LEAST32_MIN INT32_MIN
+#define INT_LEAST64_MIN INT64_MIN
+
+#define INT_LEAST8_MAX INT8_MAX
+#define INT_LEAST16_MAX INT16_MAX
+#define INT_LEAST32_MAX INT32_MAX
+#define INT_LEAST64_MAX INT64_MAX
+
+#define UINT_LEAST8_MAX UINT8_MAX
+#define UINT_LEAST16_MAX UINT16_MAX
+#define UINT_LEAST32_MAX UINT32_MAX
+#define UINT_LEAST64_MAX UINT64_MAX
+
+#define INT_FAST8_MIN INT8_MIN
+#define INT_FAST64_MIN INT64_MIN
+
+#define INT_FAST8_MAX INT8_MAX
+#define INT_FAST64_MAX INT64_MAX
+
+#define UINT_FAST8_MAX UINT8_MAX
+#define UINT_FAST64_MAX UINT64_MAX
+
+#define INTMAX_MIN INT64_MIN
+#define INTMAX_MAX INT64_MAX
+#define UINTMAX_MAX UINT64_MAX
+
+#include <bitsize/stdintlimits.h>
+
+#endif
+
+#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
+
+#define INT8_C(c) c
+#define INT16_C(c) c
+#define INT32_C(c) c
+#define INT64_C(c) __INT64_C(c)
+
+#define UINT8_C(c) c ## U
+#define UINT16_C(c) c ## U
+#define UINT32_C(c) c ## U
+#define UINT64_C(c) __UINT64_C(c)
+
+#define INT_LEAST8_C(c) INT8_C(c)
+#define INT_LEAST16_C(c) INT16_C(c)
+#define INT_LEAST32_C(c) INT32_C(c)
+#define INT_LEAST64_C(c) INT64_C(c)
+
+#define UINT_LEAST8_C(c) UINT8_C(c)
+#define UINT_LEAST16_C(c) UINT16_C(c)
+#define UINT_LEAST32_C(c) UINT32_C(c)
+#define UINT_LEAST64_C(c) UINT64_C(c)
+
+#define INT_FAST8_C(c) INT8_C(c)
+#define INT_FAST64_C(c) INT64_C(c)
+
+#define UINT_FAST8_C(c) UINT8_C(c)
+#define UINT_FAST64_C(c) UINT64_C(c)
+
+#define INTMAX_C(c) INT64_C(c)
+#define UINTMAX_C(c) UINT64_C(c)
+
+#include <bitsize/stdintconst.h>
+
+#endif
+
+/* Keep the kernel from trying to define these types... */
+#define __BIT_TYPES_DEFINED__
+
+#endif /* _STDINT_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/stdio.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/stdio.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,125 @@
+/*
+ * stdio.h
+ */
+
+#ifndef _STDIO_H
+#define _STDIO_H
+
+#include <klibc/extern.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <unistd.h>
+
+/* This structure doesn't really exist, but it gives us something
+ to define FILE * with */
+struct _IO_file;
+typedef struct _IO_file FILE;
+
+#ifndef EOF
+# define EOF (-1)
+#endif
+
+#ifndef BUFSIZ
+# define BUFSIZ 4096
+#endif
+
+#define SEEK_SET 0
+#define SEEK_CUR 1
+#define SEEK_END 2
+
+/*
+ * Convert between a FILE * and a file descriptor. We don't actually
+ * have any in-memory data, so we just abuse the pointer itself to
+ * hold the data. Note, however, that for file descriptors, -1 is
+ * error and 0 is a valid value; for FILE *, NULL (0) is error and
+ * non-NULL are valid.
+ */
+static __inline__ int fileno(FILE *__f)
+{
+ /* This should really be intptr_t, but size_t should be the same size */
+ return (int)(size_t)__f - 1;
+}
+
+/* This is a macro so it can be used as initializer */
+#define __create_file(__fd) ((FILE *)(size_t)((__fd) + 1))
+
+#define stdin __create_file(0)
+#define stdout __create_file(1)
+#define stderr __create_file(2)
+
+__extern FILE *fopen(const char *, const char *);
+
+static __inline__ FILE *fdopen(int __fd, const char *__m)
+{
+ (void)__m; return __create_file(__fd);
+}
+static __inline__ int fclose(FILE *__f)
+{
+ extern int close(int);
+ return close(fileno(__f));
+}
+static __inline__ int fseek(FILE *__f, off_t __o, int __w)
+{
+ extern off_t lseek(int, off_t, int);
+ return (lseek(fileno(__f), __o, __w) == (off_t)-1) ? -1 : 0;
+}
+static __inline__ off_t ftell(FILE *__f)
+{
+ extern off_t lseek(int, off_t, int);
+ return lseek(fileno(__f), 0, SEEK_CUR);
+}
+
+__extern int fputs(const char *, FILE *);
+__extern int puts(const char *);
+__extern int fputc(int, FILE *);
+#define putc(c,f) fputc((c),(f))
+#define putchar(c) fputc((c),stdout)
+
+__extern int fgetc(FILE *);
+__extern char * fgets(char *, int, FILE *);
+#define getc(f) fgetc(f)
+
+__extern size_t _fread(void *, size_t, FILE *);
+__extern size_t _fwrite(const void *, size_t, FILE *);
+
+#ifndef __NO_FREAD_FWRITE_INLINES
+extern __inline__ size_t
+fread(void *__p, size_t __s, size_t __n, FILE *__f)
+{
+ return _fread(__p, __s*__n, __f)/__s;
+}
+
+extern __inline__ size_t
+fwrite(const void *__p, size_t __s, size_t __n, FILE *__f)
+{
+ return _fwrite(__p, __s*__n, __f)/__s;
+}
+#endif
+
+__extern int printf(const char *, ...);
+__extern int vprintf(const char *, va_list);
+__extern int fprintf(FILE *, const char *, ...);
+__extern int vfprintf(FILE *, const char *, va_list);
+__extern int sprintf(char *, const char *, ...);
+__extern int vsprintf(char *, const char *, va_list);
+__extern int snprintf(char *, size_t n, const char *, ...);
+__extern int vsnprintf(char *, size_t n, const char *, va_list);
+__extern int asprintf(char **, const char *, ...);
+__extern int vasprintf(char **, const char *, va_list);
+
+/* No buffering, so no flushing needed */
+extern __inline__ int
+fflush(FILE *__f)
+{
+ (void)__f;
+ return 0;
+}
+
+__extern int sscanf(const char *, const char *, ...);
+__extern int vsscanf(const char *, const char *, va_list);
+
+__extern void perror(const char *);
+
+__extern int rename(const char *, const char *);
+
+#endif /* _STDIO_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/stdlib.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/stdlib.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,91 @@
+/*
+ * stdlib.h
+ */
+
+#ifndef _STDLIB_H
+#define _STDLIB_H
+
+#include <klibc/extern.h>
+#include <klibc/compiler.h>
+#include <stddef.h>
+
+#define EXIT_FAILURE 1
+#define EXIT_SUCCESS 0
+
+static __inline__ __noreturn _Exit(int __n) {
+ __extern __noreturn _exit(int);
+ _exit(__n);
+ for(;;); /* Some gcc versions are stupid */
+}
+__extern __noreturn abort(void);
+static __inline__ int abs(int __n) {
+ return (__n < 0) ? -__n : __n;
+}
+__extern int system(const char * string);
+__extern int atexit(void (*)(void));
+__extern int on_exit(void (*)(int, void *), void *);
+__extern int atoi(const char *);
+__extern long atol(const char *);
+__extern long long atoll(const char *);
+__extern __noreturn exit(int);
+__extern void free(void *);
+static __inline__ long labs(long __n) {
+ return (__n < 0L) ? -__n : __n;
+}
+
+static __inline__ long long llabs(long long __n) {
+ return (__n < 0LL) ? -__n : __n;
+}
+
+__extern __mallocfunc void *malloc(size_t);
+__extern __mallocfunc void *calloc(size_t, size_t);
+__extern __mallocfunc void *realloc(void *, size_t);
+__extern long strtol(const char *, char **, int);
+__extern long long strtoll(const char *, char **, int);
+__extern unsigned long strtoul(const char *, char **, int);
+__extern unsigned long long strtoull(const char *, char **, int);
+
+__extern char *getenv(const char *);
+__extern int putenv(const char *);
+__extern int setenv(const char *, const char *, int);
+__extern int unsetenv(const char *);
+
+__extern void qsort(void *, size_t, size_t, int (*)(const void *, const void *));
+
+
+__extern long jrand48(unsigned short *);
+__extern long mrand48(void);
+__extern long nrand48(unsigned short *);
+__extern long lrand48(void);
+__extern unsigned short *seed48(const unsigned short *);
+__extern void srand48(long);
+
+#define RAND_MAX 0x7fffffff
+static __inline__ int rand(void) {
+ return (int)lrand48();
+}
+static __inline__ void srand(unsigned int __s) {
+ srand48(__s);
+}
+static __inline__ long random(void)
+{
+ return lrand48();
+}
+static __inline__ void srandom(unsigned int __s)
+{
+ srand48(__s);
+}
+
+/* Basic PTY functions. These only work if devpts is mounted! */
+
+__extern int unlockpt(int);
+__extern char *ptsname(int);
+__extern int getpt(void);
+
+static __inline__ int grantpt(int __fd)
+{
+ (void)__fd;
+ return 0; /* devpts does this all for us! */
+}
+
+#endif /* _STDLIB_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/string.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/string.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,43 @@
+/*
+ * string.h
+ */
+
+#ifndef _STRING_H
+#define _STRING_H
+
+#include <klibc/extern.h>
+#include <stddef.h>
+
+__extern void *memccpy(void *, const void *, int, size_t);
+__extern void *memchr(const void *, int, size_t);
+__extern int memcmp(const void *, const void *, size_t);
+__extern void *memcpy(void *, const void *, size_t);
+__extern void *memmove(void *, const void *, size_t);
+__extern void *memset(void *, int, size_t);
+__extern void *memmem(const void *, size_t, const void *, size_t);
+__extern void memswap(void *, void *, size_t);
+__extern int strcasecmp(const char *, const char *);
+__extern int strncasecmp(const char *, const char *, size_t);
+__extern char *strcat(char *, const char *);
+__extern char *strchr(const char *, int);
+__extern int strcmp(const char *, const char *);
+__extern char *strcpy(char *, const char *);
+__extern size_t strcspn(const char *, const char *);
+__extern char *strdup(const char *);
+__extern char *strndup(const char *, size_t);
+__extern char *strerror(int);
+__extern size_t strlen(const char *);
+__extern size_t strnlen(const char *, size_t);
+__extern char *strncat(char *, const char *, size_t);
+__extern size_t strlcat(char *, const char *, size_t);
+__extern int strncmp(const char *, const char *, size_t);
+__extern char *strncpy(char *, const char *, size_t);
+__extern size_t strlcpy(char *, const char *, size_t);
+__extern char *strpbrk(const char *, const char *);
+__extern char *strrchr(const char *, int);
+__extern char *strsep(char **, const char *);
+__extern size_t strspn(const char *, const char *);
+__extern char *strstr(const char *, const char *);
+__extern char *strtok(char *, const char *);
+
+#endif /* _STRING_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/dirent.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/dirent.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,21 @@
+/*
+ * sys/dirent.h
+ */
+
+#ifndef _SYS_DIRENT_H
+#define _SYS_DIRENT_H
+
+#include <stdint.h>
+
+/* The kernel calls this struct dirent64 */
+struct dirent {
+ uint64_t d_ino;
+ int64_t d_off;
+ unsigned short d_reclen;
+ unsigned char d_type;
+ char d_name[256];
+};
+
+__extern int getdents(unsigned int, struct dirent *, unsigned int);
+
+#endif /* _SYS_DIRENT_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/elf32.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/elf32.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,115 @@
+/*
+ * sys/elf32.h
+ */
+
+#ifndef _SYS_ELF32_H
+#define _SYS_ELF32_H
+
+#include <sys/elfcommon.h>
+
+/* ELF standard typedefs (yet more proof that <stdint.h> was way overdue) */
+typedef uint16_t Elf32_Half;
+typedef int16_t Elf32_SHalf;
+typedef uint32_t Elf32_Word;
+typedef int32_t Elf32_Sword;
+typedef uint64_t Elf32_Xword;
+typedef int64_t Elf32_Sxword;
+
+typedef uint32_t Elf32_Off;
+typedef uint32_t Elf32_Addr;
+typedef uint16_t Elf32_Section;
+
+/* Dynamic header */
+
+typedef struct elf32_dyn {
+ Elf32_Sword d_tag;
+ union{
+ Elf32_Sword d_val;
+ Elf32_Addr d_ptr;
+ } d_un;
+} Elf32_Dyn;
+
+/* Relocations */
+
+#define ELF32_R_SYM(x) ((x) >> 8)
+#define ELF32_R_TYPE(x) ((x) & 0xff)
+
+typedef struct elf32_rel {
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+} Elf32_Rel;
+
+typedef struct elf32_rela {
+ Elf32_Addr r_offset;
+ Elf32_Word r_info;
+ Elf32_Sword r_addend;
+} Elf32_Rela;
+
+/* Symbol */
+
+typedef struct elf32_sym {
+ Elf32_Word st_name;
+ Elf32_Addr st_value;
+ Elf32_Word st_size;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf32_Half st_shndx;
+} Elf32_Sym;
+
+/* Main file header */
+
+typedef struct elf32_hdr {
+ unsigned char e_ident[EI_NIDENT];
+ Elf32_Half e_type;
+ Elf32_Half e_machine;
+ Elf32_Word e_version;
+ Elf32_Addr e_entry;
+ Elf32_Off e_phoff;
+ Elf32_Off e_shoff;
+ Elf32_Word e_flags;
+ Elf32_Half e_ehsize;
+ Elf32_Half e_phentsize;
+ Elf32_Half e_phnum;
+ Elf32_Half e_shentsize;
+ Elf32_Half e_shnum;
+ Elf32_Half e_shstrndx;
+} Elf32_Ehdr;
+
+/* Program header */
+
+typedef struct elf32_phdr {
+ Elf32_Word p_type;
+ Elf32_Off p_offset;
+ Elf32_Addr p_vaddr;
+ Elf32_Addr p_paddr;
+ Elf32_Word p_filesz;
+ Elf32_Word p_memsz;
+ Elf32_Word p_flags;
+ Elf32_Word p_align;
+} Elf32_Phdr;
+
+
+/* Section header */
+
+typedef struct elf32_shdr {
+ Elf32_Word sh_name;
+ Elf32_Word sh_type;
+ Elf32_Word sh_flags;
+ Elf32_Addr sh_addr;
+ Elf32_Off sh_offset;
+ Elf32_Word sh_size;
+ Elf32_Word sh_link;
+ Elf32_Word sh_info;
+ Elf32_Word sh_addralign;
+ Elf32_Word sh_entsize;
+} Elf32_Shdr;
+
+/* Note header */
+typedef struct elf32_note {
+ Elf32_Word n_namesz; /* Name size */
+ Elf32_Word n_descsz; /* Content size */
+ Elf32_Word n_type; /* Content type */
+} Elf32_Nhdr;
+
+#endif /* _SYS_ELF32_H */
+
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/elf64.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/elf64.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,115 @@
+/*
+ * sys/elf64.h
+ */
+
+#ifndef _SYS_ELF64_H
+#define _SYS_ELF64_H
+
+#include <sys/elfcommon.h>
+
+/* ELF standard typedefs (yet more proof that <stdint.h> was way overdue) */
+typedef uint16_t Elf64_Half;
+typedef int16_t Elf64_SHalf;
+typedef uint32_t Elf64_Word;
+typedef int32_t Elf64_Sword;
+typedef uint64_t Elf64_Xword;
+typedef int64_t Elf64_Sxword;
+
+typedef uint64_t Elf64_Off;
+typedef uint64_t Elf64_Addr;
+typedef uint16_t Elf64_Section;
+
+/* Dynamic header */
+
+typedef struct elf64_dyn {
+ Elf64_Sxword d_tag;
+ union{
+ Elf64_Xword d_val;
+ Elf64_Addr d_ptr;
+ } d_un;
+} Elf64_Dyn;
+
+/* Relocations */
+
+#define ELF64_R_SYM(x) ((x) >> 32)
+#define ELF64_R_TYPE(x) ((x) & 0xffffffff)
+
+typedef struct elf64_rel {
+ Elf64_Addr r_offset;
+ Elf64_Xword r_info;
+} Elf64_Rel;
+
+typedef struct elf64_rela {
+ Elf64_Addr r_offset;
+ Elf64_Xword r_info;
+ Elf64_Sxword r_addend;
+} Elf64_Rela;
+
+/* Symbol */
+
+typedef struct elf64_sym {
+ Elf64_Word st_name;
+ unsigned char st_info;
+ unsigned char st_other;
+ Elf64_Half st_shndx;
+ Elf64_Addr st_value;
+ Elf64_Xword st_size;
+} Elf64_Sym;
+
+/* Main file header */
+
+typedef struct elf64_hdr {
+ unsigned char e_ident[EI_NIDENT];
+ Elf64_Half e_type;
+ Elf64_Half e_machine;
+ Elf64_Word e_version;
+ Elf64_Addr e_entry;
+ Elf64_Off e_phoff;
+ Elf64_Off e_shoff;
+ Elf64_Word e_flags;
+ Elf64_Half e_ehsize;
+ Elf64_Half e_phentsize;
+ Elf64_Half e_phnum;
+ Elf64_Half e_shentsize;
+ Elf64_Half e_shnum;
+ Elf64_Half e_shstrndx;
+} Elf64_Ehdr;
+
+/* Program header */
+
+typedef struct elf64_phdr {
+ Elf64_Word p_type;
+ Elf64_Word p_flags;
+ Elf64_Off p_offset;
+ Elf64_Addr p_vaddr;
+ Elf64_Addr p_paddr;
+ Elf64_Xword p_filesz;
+ Elf64_Xword p_memsz;
+ Elf64_Xword p_align;
+} Elf64_Phdr;
+
+
+/* Section header */
+
+typedef struct elf64_shdr {
+ Elf64_Word sh_name;
+ Elf64_Word sh_type;
+ Elf64_Xword sh_flags;
+ Elf64_Addr sh_addr;
+ Elf64_Off sh_offset;
+ Elf64_Xword sh_size;
+ Elf64_Word sh_link;
+ Elf64_Word sh_info;
+ Elf64_Xword sh_addralign;
+ Elf64_Xword sh_entsize;
+} Elf64_Shdr;
+
+/* Note header */
+typedef struct elf64_note {
+ Elf64_Word n_namesz; /* Name size */
+ Elf64_Word n_descsz; /* Content size */
+ Elf64_Word n_type; /* Content type */
+} Elf64_Nhdr;
+
+#endif /* _SYS_ELF64_H */
+
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/elfcommon.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/elfcommon.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,188 @@
+/*
+ * sys/elfcommon.h
+ */
+
+#ifndef _SYS_ELFCOMMON_H
+#define _SYS_ELFCOMMON_H
+
+#include <stdint.h>
+
+/* Segment types */
+#define PT_NULL 0
+#define PT_LOAD 1
+#define PT_DYNAMIC 2
+#define PT_INTERP 3
+#define PT_NOTE 4
+#define PT_SHLIB 5
+#define PT_PHDR 6
+#define PT_LOOS 0x60000000
+#define PT_HIOS 0x6fffffff
+#define PT_LOPROC 0x70000000
+#define PT_HIPROC 0x7fffffff
+#define PT_GNU_EH_FRAME 0x6474e550 /* Extension, eh? */
+
+/* ELF file types */
+#define ET_NONE 0
+#define ET_REL 1
+#define ET_EXEC 2
+#define ET_DYN 3
+#define ET_CORE 4
+#define ET_LOPROC 0xff00
+#define ET_HIPROC 0xffff
+
+/* ELF machine types */
+#define EM_NONE 0
+#define EM_M32 1
+#define EM_SPARC 2
+#define EM_386 3
+#define EM_68K 4
+#define EM_88K 5
+#define EM_486 6 /* Not used in Linux at least */
+#define EM_860 7
+#define EM_MIPS 8 /* R3k, bigendian(?) */
+#define EM_MIPS_RS4_BE 10 /* R4k BE */
+#define EM_PARISC 15
+#define EM_SPARC32PLUS 18
+#define EM_PPC 20
+#define EM_PPC64 21
+#define EM_S390 22
+#define EM_SH 42
+#define EM_SPARCV9 43 /* v9 = SPARC64 */
+#define EM_H8_300H 47
+#define EM_H8S 48
+#define EM_IA_64 50 /* Itanic */
+#define EM_X86_64 62
+#define EM_CRIS 76
+#define EM_V850 87
+#define EM_ALPHA 0x9026 /* Interrim Alpha that stuck around */
+#define EM_CYGNUS_V850 0x9080 /* Old v850 ID used by Cygnus */
+#define EM_S390_OLD 0xA390 /* Obsolete interrim value for S/390 */
+
+/* Dynamic type values */
+#define DT_NULL 0
+#define DT_NEEDED 1
+#define DT_PLTRELSZ 2
+#define DT_PLTGOT 3
+#define DT_HASH 4
+#define DT_STRTAB 5
+#define DT_SYMTAB 6
+#define DT_RELA 7
+#define DT_RELASZ 8
+#define DT_RELAENT 9
+#define DT_STRSZ 10
+#define DT_SYMENT 11
+#define DT_INIT 12
+#define DT_FINI 13
+#define DT_SONAME 14
+#define DT_RPATH 15
+#define DT_SYMBOLIC 16
+#define DT_REL 17
+#define DT_RELSZ 18
+#define DT_RELENT 19
+#define DT_PLTREL 20
+#define DT_DEBUG 21
+#define DT_TEXTREL 22
+#define DT_JMPREL 23
+#define DT_LOPROC 0x70000000
+#define DT_HIPROC 0x7fffffff
+
+/* Auxilliary table entries */
+#define AT_NULL 0 /* end of vector */
+#define AT_IGNORE 1 /* entry should be ignored */
+#define AT_EXECFD 2 /* file descriptor of program */
+#define AT_PHDR 3 /* program headers for program */
+#define AT_PHENT 4 /* size of program header entry */
+#define AT_PHNUM 5 /* number of program headers */
+#define AT_PAGESZ 6 /* system page size */
+#define AT_BASE 7 /* base address of interpreter */
+#define AT_FLAGS 8 /* flags */
+#define AT_ENTRY 9 /* entry point of program */
+#define AT_NOTELF 10 /* program is not ELF */
+#define AT_UID 11 /* real uid */
+#define AT_EUID 12 /* effective uid */
+#define AT_GID 13 /* real gid */
+#define AT_EGID 14 /* effective gid */
+#define AT_PLATFORM 15 /* string identifying CPU for optimizations */
+#define AT_HWCAP 16 /* arch dependent hints at CPU capabilities */
+#define AT_CLKTCK 17 /* frequency at which times() increments */
+/* 18..22 = ? */
+#define AT_SECURE 23 /* secure mode boolean */
+
+/* Program header permission flags */
+#define PF_X 0x1
+#define PF_W 0x2
+#define PF_R 0x4
+
+/* Section header types */
+#define SHT_NULL 0
+#define SHT_PROGBITS 1
+#define SHT_SYMTAB 2
+#define SHT_STRTAB 3
+#define SHT_RELA 4
+#define SHT_HASH 5
+#define SHT_DYNAMIC 6
+#define SHT_NOTE 7
+#define SHT_NOBITS 8
+#define SHT_REL 9
+#define SHT_SHLIB 10
+#define SHT_DYNSYM 11
+#define SHT_NUM 12
+#define SHT_LOPROC 0x70000000
+#define SHT_HIPROC 0x7fffffff
+#define SHT_LOUSER 0x80000000
+#define SHT_HIUSER 0xffffffff
+
+/* Section header flags */
+#define SHF_WRITE 0x1
+#define SHF_ALLOC 0x2
+#define SHF_EXECINSTR 0x4
+#define SHF_MASKPROC 0xf0000000
+
+/* Special section numbers */
+#define SHN_UNDEF 0
+#define SHN_LORESERVE 0xff00
+#define SHN_LOPROC 0xff00
+#define SHN_HIPROC 0xff1f
+#define SHN_ABS 0xfff1
+#define SHN_COMMON 0xfff2
+#define SHN_HIRESERVE 0xffff
+
+/* Lenght of magic at the start of a file */
+#define EI_NIDENT 16
+
+/* Magic number constants... */
+#define EI_MAG0 0 /* e_ident[] indexes */
+#define EI_MAG1 1
+#define EI_MAG2 2
+#define EI_MAG3 3
+#define EI_CLASS 4
+#define EI_DATA 5
+#define EI_VERSION 6
+#define EI_OSABI 7
+#define EI_PAD 8
+
+#define ELFMAG0 0x7f /* EI_MAG */
+#define ELFMAG1 'E'
+#define ELFMAG2 'L'
+#define ELFMAG3 'F'
+#define ELFMAG "\177ELF"
+#define SELFMAG 4
+
+#define ELFCLASSNONE 0 /* EI_CLASS */
+#define ELFCLASS32 1
+#define ELFCLASS64 2
+#define ELFCLASSNUM 3
+
+#define ELFDATANONE 0 /* e_ident[EI_DATA] */
+#define ELFDATA2LSB 1
+#define ELFDATA2MSB 2
+
+#define EV_NONE 0 /* e_version, EI_VERSION */
+#define EV_CURRENT 1
+#define EV_NUM 2
+
+#define ELFOSABI_NONE 0
+#define ELFOSABI_LINUX 3
+
+#endif /* _SYS_ELFCOMMON_H */
+
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/fsuid.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/fsuid.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * sys/fsuid.h
+ */
+
+#ifndef _SYS_FSUID_H
+#define _SYS_FSUID_H
+
+#include <klibc/extern.h>
+#include <sys/types.h>
+
+__extern int setfsuid(uid_t);
+__extern int setfsgid(gid_t);
+
+#endif /* _SYS_FSUID_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/ioctl.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/ioctl.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * sys/ioctl.h
+ */
+
+#ifndef _SYS_IOCTL_H
+#define _SYS_IOCTL_H
+
+#include <klibc/extern.h>
+#include <linux/ioctl.h>
+#include <asm/ioctls.h>
+
+__extern int ioctl(int, int, void *);
+
+#endif /* _SYS_IOCTL_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/klog.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/klog.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+/*
+ * sys/klog.h
+ */
+
+#ifndef _SYS_KLOG_H
+#define _SYS_KLOG_H
+
+#include <klibc/extern.h>
+
+#define KLOG_CLOSE 0
+#define KLOG_OPEN 1
+#define KLOG_READ 2
+#define KLOG_READ_ALL 3
+#define KLOG_READ_CLEAR 4
+#define KLOG_CLEAR 5
+#define KLOG_DISABLE 6
+#define KLOG_ENABLE 7
+#define KLOG_SETLEVEL 8
+#define KLOG_UNREADSIZE 9
+#define KLOG_WRITE 10
+
+__extern int klogctl(int, char *, int);
+
+#endif /* _SYS_KLOG_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/mman.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/mman.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+/*
+ * sys/mman.h
+ */
+
+#ifndef _SYS_MMAN_H
+#define _SYS_MMAN_H
+
+#include <klibc/extern.h>
+#include <sys/types.h>
+#include <asm/mman.h>
+#include <asm/page.h> /* For PAGE_SIZE */
+
+#define MAP_FAILED ((void *)-1)
+
+__extern void *mmap(void *, size_t, int, int, int, off_t);
+__extern int munmap(void *, size_t);
+__extern void *mremap(void *, size_t, size_t, unsigned long);
+__extern int msync(const void *, size_t, int);
+__extern int mprotect(const void *, size_t, int);
+__extern int mlockall(int);
+__extern int munlockall(void);
+__extern int mlock(const void *, size_t);
+__extern int munlock(const void *, size_t);
+
+#endif /* _SYS_MMAN_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/mount.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/mount.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,55 @@
+/*
+ * sys/mount.h
+ */
+
+#ifndef _SYS_MOUNT_H
+#define _SYS_MOUNT_H
+
+#include <klibc/extern.h>
+
+/*
+ * These are the fs-independent mount-flags: up to 32 flags are supported
+ */
+#define MS_RDONLY 1 /* Mount read-only */
+#define MS_NOSUID 2 /* Ignore suid and sgid bits */
+#define MS_NODEV 4 /* Disallow access to device special files */
+#define MS_NOEXEC 8 /* Disallow program execution */
+#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
+#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
+#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
+#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
+#define MS_NOATIME 1024 /* Do not update access times. */
+#define MS_NODIRATIME 2048 /* Do not update directory access times */
+#define MS_BIND 4096
+#define MS_MOVE 8192
+#define MS_REC 16384
+#define MS_VERBOSE 32768
+#define MS_NOUSER (1<<31)
+
+/*
+ * Superblock flags that can be altered by MS_REMOUNT
+ */
+#define MS_RMT_MASK (MS_RDONLY|MS_SYNCHRONOUS|MS_MANDLOCK|MS_NOATIME|MS_NODIRATIME)
+
+/*
+ * Old magic mount flag and mask
+ */
+#define MS_MGC_VAL 0xC0ED0000
+#define MS_MGC_MSK 0xffff0000
+
+/*
+ * umount2() flags
+ */
+#define MNT_FORCE 1
+
+/*
+ * Prototypes
+ */
+__extern int mount(const char *, const char *,
+ const char *, unsigned long,
+ const void *);
+__extern int umount(const char *);
+__extern int umount2(const char *, int);
+__extern int pivot_root(const char *, const char *);
+
+#endif /* _SYS_MOUNT_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/param.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/param.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+/*
+ * sys/param.h
+ */
+
+#ifndef _SYS_PARAM_H
+#define _SYS_PARAM_H
+
+#include <limits.h>
+#include <linux/param.h>
+
+#endif /* _SYS_PARAM_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/reboot.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/reboot.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+/*
+ * sys/reboot.h
+ */
+
+#ifndef _SYS_REBOOT_H
+#define _SYS_REBOOT_H
+
+#include <klibc/extern.h>
+#include <linux/reboot.h>
+
+/* glibc names these constants differently; allow both versions */
+
+#define RB_AUTOBOOT LINUX_REBOOT_CMD_RESTART
+#define RB_HALT_SYSTEM LINUX_REBOOT_CMD_HALT
+#define RB_ENABLE_CAD LINUX_REBOOT_CMD_CAD_ON
+#define RB_DISABLE_CAD LINUX_REBOOT_CMD_CAD_OFF
+#define RB_POWER_OFF LINUX_REBOOT_CMD_POWER_OFF
+
+/* glibc-ish one-argument version */
+__extern int reboot(int);
+
+/* Native four-argument system call */
+__extern int __reboot(int, int, int, void *);
+
+#endif /* _SYS_REBOOT_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/resource.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/resource.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * sys/resource.h
+ */
+
+#ifndef _SYS_RESOURCE_H
+#define _SYS_RESOURCE_H
+
+#include <klibc/extern.h>
+#include <sys/types.h> /* MUST be included before linux/resource.h */
+#include <linux/resource.h>
+
+__extern int getpriority(int, int);
+__extern int setpriority(int, int, int);
+
+#endif /* _SYS_RESOURCE_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/select.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/select.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * sys/select.h
+ */
+
+#ifndef _SYS_SELECT_H
+#define _SYS_SELECT_H
+
+#include <sys/time.h>
+#include <sys/types.h>
+
+__extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
+
+#endif /* _SYS_SELECT_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/socket.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/socket.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,50 @@
+/*
+ * sys/socket.h
+ */
+
+#ifndef _SYS_SOCKET_H
+#define _SYS_SOCKET_H
+
+#include <klibc/extern.h>
+#include <klibc/compiler.h>
+#include <linux/socket.h>
+
+/* For some reason these may be protected by __KERNEL__ in asm/socket.h */
+#ifndef SOCK_STREAM
+# define SOCK_STREAM 1
+# define SOCK_DGRAM 2
+# define SOCK_RAW 3
+# define SOCK_RDM 4
+# define SOCK_SEQPACKET 5
+# define SOCK_PACKET 10
+#endif
+
+#ifdef __i386__
+# define __socketcall __extern __cdecl
+#else
+# define __socketcall __extern
+#endif
+
+typedef int socklen_t;
+
+__socketcall int socket(int, int, int);
+__socketcall int bind(int, struct sockaddr *, int);
+__socketcall int connect(int, struct sockaddr *, socklen_t);
+__socketcall int listen(int, int);
+__socketcall int accept(int, struct sockaddr *, socklen_t *);
+__socketcall int getsockname(int, struct sockaddr *, socklen_t *);
+__socketcall int getpeername(int, struct sockaddr *, socklen_t *);
+__socketcall int socketpair(int, int, int, int *);
+__extern int send(int, const void *, size_t, unsigned int);
+__socketcall int sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t);
+__extern int recv(int, void *, size_t, unsigned int);
+__socketcall int recvfrom(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *);
+__socketcall int shutdown(int, int);
+__socketcall int setsockopt(int, int, int, const void *, socklen_t);
+__socketcall int getsockopt(int, int, int, void *, socklen_t *);
+__socketcall int sendmsg(int, const struct msghdr *, unsigned int);
+__socketcall int recvmsg(int, struct msghdr *, unsigned int);
+
+#undef __socketcall
+
+#endif /* _SYS_SOCKET_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/socketcalls.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/socketcalls.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,28 @@
+/*
+ * sys/socketcalls.h
+ */
+
+#ifndef _SYS_SOCKETCALLS_H
+#define _SYS_SOCKETCALLS_H
+
+/* socketcalls by number, since <linux/net.h> isn't usable for assembly */
+
+#define SYS_SOCKET 1 /* sys_socket(2) */
+#define SYS_BIND 2 /* sys_bind(2) */
+#define SYS_CONNECT 3 /* sys_connect(2) */
+#define SYS_LISTEN 4 /* sys_listen(2) */
+#define SYS_ACCEPT 5 /* sys_accept(2) */
+#define SYS_GETSOCKNAME 6 /* sys_getsockname(2) */
+#define SYS_GETPEERNAME 7 /* sys_getpeername(2) */
+#define SYS_SOCKETPAIR 8 /* sys_socketpair(2) */
+#define SYS_SEND 9 /* sys_send(2) */
+#define SYS_RECV 10 /* sys_recv(2) */
+#define SYS_SENDTO 11 /* sys_sendto(2) */
+#define SYS_RECVFROM 12 /* sys_recvfrom(2) */
+#define SYS_SHUTDOWN 13 /* sys_shutdown(2) */
+#define SYS_SETSOCKOPT 14 /* sys_setsockopt(2) */
+#define SYS_GETSOCKOPT 15 /* sys_getsockopt(2) */
+#define SYS_SENDMSG 16 /* sys_sendmsg(2) */
+#define SYS_RECVMSG 17 /* sys_recvmsg(2) */
+
+#endif /* _SYS_SOCKETCALLS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/stat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/stat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,31 @@
+/*
+ * sys/stat.h
+ */
+
+#ifndef _SYS_STAT_H
+#define _SYS_STAT_H
+
+#include <klibc/extern.h>
+#include <sys/types.h>
+#include <sys/time.h> /* For struct timespec */
+#include <klibc/archstat.h>
+#include <linux/stat.h>
+
+#ifdef _STATBUF_ST_NSEC
+ /* struct stat has struct timespec instead of time_t */
+# define st_atime st_atim.tv_sec
+# define st_mtime st_mtim.tv_sec
+# define st_ctime st_ctim.tv_sec
+#endif
+
+__extern int stat(const char *, struct stat *);
+__extern int fstat(int, struct stat *);
+__extern int lstat(const char *, struct stat *);
+__extern mode_t umask(mode_t);
+__extern int mknod(const char *, mode_t, dev_t);
+static __inline__ int mkfifo(const char *__p, mode_t __m)
+{
+ return mknod(__p, (__m & ~S_IFMT) | S_IFIFO, (dev_t)0);
+}
+
+#endif /* _SYS_STAT_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/statfs.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/statfs.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1 @@
+#include <sys/vfs.h>
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/syscall.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/syscall.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,17 @@
+/*
+ * sys/syscall.h
+ *
+ * Generic system call interface macros
+ */
+#ifndef _SYS_SYSCALL_H
+#define _SYS_SYSCALL_H
+
+#include <errno.h>
+#include <sys/types.h>
+#include <asm/unistd.h>
+
+/* Many architectures have incomplete, defective or non-applicable
+ syscall macros */
+#include <klibc/archsys.h>
+
+#endif /* _SYS_SYSCALL_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/sysinfo.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/sysinfo.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * sys/sysinfo.h
+ */
+
+#ifndef _SYS_SYSINFO_H
+#define _SYS_SYSINFO_H
+
+#include <linux/kernel.h>
+
+extern int sysinfo (struct sysinfo *info);
+
+#endif /* _SYS_SYSINFO_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/sysmacros.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/sysmacros.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,31 @@
+/*
+ * sys/sysmacros.h
+ *
+ * Constructs to create and pick apart dev_t. This applies to the Linux 2.6
+ * 32-bit dev_t format.
+ */
+
+#ifndef _SYS_SYSMACROS_H
+#define _SYS_SYSMACROS_H
+
+#ifndef _SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+static __inline__ int major(dev_t __d)
+{
+ return (__d >> 8) & 0xfff;
+}
+
+static __inline__ int minor(dev_t __d)
+{
+ return (__d & 0xff) | ((__d >> 12) & 0xfff00);
+}
+
+static __inline__ dev_t makedev(int __ma, int __mi)
+{
+ return ((__ma & 0xfff) << 8) | (__mi & 0xff) | ((__mi & 0xfff00) << 12);
+}
+
+#endif /* _SYS_SYSMACROS_H */
+
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/time.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/time.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+/*
+ * sys/time.h
+ */
+
+#ifndef _SYS_TIME_H
+#define _SYS_TIME_H
+
+#include <klibc/extern.h>
+#include <sys/types.h>
+#include <linux/time.h>
+
+__extern int gettimeofday(struct timeval *, struct timezone *);
+__extern int settimeofday(const struct timeval *, const struct timezone *);
+__extern int getitimer(int, struct itimerval *);
+__extern int setitimer(int, const struct itimerval *, struct itimerval *);
+__extern int utimes(const char *, const struct timeval *);
+
+#endif /* _SYS_TIME_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/times.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/times.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * sys/times.h
+ */
+
+#ifndef _SYS_TIMES_H
+#define _SYS_TIMES_H
+
+#include <linux/times.h>
+
+__extern clock_t times(struct tms *);
+__extern int gettimeofday(struct timeval *, struct timezone *);
+__extern int settimeofday(const struct timeval *, const struct timezone *);
+
+#endif /* _SYS_TIMES_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/types.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/types.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,104 @@
+/*
+ * sys/types.h
+ */
+
+#ifndef _SYS_TYPES_H
+#define _SYS_TYPES_H
+
+#include <klibc/compiler.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#define _SSIZE_T
+typedef ptrdiff_t ssize_t;
+
+#include <linux/posix_types.h>
+#include <asm/types.h>
+
+/* Keeps linux/types.h from getting included elsewhere */
+#define _LINUX_TYPES_H
+
+typedef __kernel_fd_set fd_set;
+typedef uint32_t dev_t;
+typedef __kernel_ino_t ino_t;
+typedef __kernel_mode_t mode_t;
+typedef __kernel_nlink_t nlink_t;
+typedef __kernel_loff_t off_t;
+typedef __kernel_loff_t loff_t;
+typedef __kernel_pid_t pid_t;
+typedef __kernel_daddr_t daddr_t;
+typedef __kernel_key_t key_t;
+typedef __kernel_suseconds_t suseconds_t;
+/* typedef __kernel_timer_t timer_t; */
+typedef int timer_t;
+
+typedef __kernel_uid32_t uid_t;
+typedef __kernel_gid32_t gid_t;
+
+typedef __kernel_fsid_t fsid_t;
+
+/*
+ * The following typedefs are also protected by individual ifdefs for
+ * historical reasons:
+ */
+#ifndef _SIZE_T
+#define _SIZE_T
+typedef __kernel_size_t size_t;
+#endif
+
+#ifndef _SSIZE_T
+#define _SSIZE_T
+typedef __kernel_ssize_t ssize_t;
+#endif
+
+#ifndef _PTRDIFF_T
+#define _PTRDIFF_T
+typedef __kernel_ptrdiff_t ptrdiff_t;
+#endif
+
+#ifndef _TIME_T
+#define _TIME_T
+typedef __kernel_time_t time_t;
+#endif
+
+#ifndef _CLOCK_T
+#define _CLOCK_T
+typedef __kernel_clock_t clock_t;
+#endif
+
+#ifndef _CADDR_T
+#define _CADDR_T
+typedef __kernel_caddr_t caddr_t;
+#endif
+
+/* bsd */
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+typedef unsigned int u_int;
+typedef unsigned long u_long;
+
+/* sysv */
+typedef unsigned char unchar;
+typedef unsigned short ushort;
+typedef unsigned int uint;
+typedef unsigned long ulong;
+
+/* Linux-specific? */
+typedef uint8_t u_int8_t;
+typedef uint16_t u_int16_t;
+typedef uint32_t u_int32_t;
+typedef uint64_t u_int64_t;
+
+typedef uint16_t __bitwise __le16;
+typedef uint16_t __bitwise __be16;
+typedef uint32_t __bitwise __le32;
+typedef uint32_t __bitwise __be32;
+typedef uint64_t __bitwise __le64;
+typedef uint64_t __bitwise __be64;
+
+/*
+ * Some apps want this in <sys/types.h>
+ */
+#include <sys/sysmacros.h>
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/uio.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/uio.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * sys/uio.h
+ */
+
+#ifndef _SYS_UIO_H
+#define _SYS_UIO_H
+
+#include <klibc/extern.h>
+#include <sys/types.h>
+#include <linux/uio.h>
+
+__extern int readv(int, const struct iovec *, int);
+__extern int writev(int, const struct iovec *, int);
+
+#endif /* _SYS_UIO_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/un.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/un.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+/*
+ * <sys/un.h>
+ */
+
+#ifndef _SYS_UN_H
+#define _SYS_UN_H
+
+#include <linux/un.h>
+
+#endif /* _SYS_UN_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/utime.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/utime.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+/*
+ * sys/utime.h
+ */
+
+#ifndef _SYS_UTIME_H
+#define _SYS_UTIME_H
+
+#include <linux/utime.h>
+
+#endif /* _SYS_UTIME_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/utsname.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/utsname.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+/*
+ * sys/utsname.h
+ */
+
+#ifndef _SYS_UTSNAME_H
+#define _SYS_UTSNAME_H
+
+#include <klibc/extern.h>
+
+#define SYS_NMLN 65
+
+struct utsname {
+ char sysname[SYS_NMLN];
+ char nodename[SYS_NMLN];
+ char release[SYS_NMLN];
+ char version[SYS_NMLN];
+ char machine[SYS_NMLN];
+ char domainname[SYS_NMLN];
+};
+
+__extern int uname(struct utsname *);
+
+#endif /* _SYS_UTSNAME_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/vfs.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/vfs.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,111 @@
+/*
+ * sys/vfs.h
+ */
+
+#ifndef _SYS_VFS_H
+#define _SYS_VFS_H
+
+#include <stdint.h>
+#include <klibc/extern.h>
+#include <sys/types.h>
+
+/* struct statfs64 -- there seems to be two standards -
+ one for 32 and one for 64 bits, and they're incompatible... */
+
+#if BITSIZE == 32 || defined(__s390__)
+
+struct statfs {
+ uint32_t f_type;
+ uint32_t f_bsize;
+ uint64_t f_blocks;
+ uint64_t f_bfree;
+ uint64_t f_bavail;
+ uint64_t f_files;
+ uint64_t f_ffree;
+ __kernel_fsid_t f_fsid;
+ uint32_t f_namelen;
+ uint32_t f_frsize;
+ uint32_t f_spare[5];
+};
+
+#else /* BITSIZE == 64 */
+
+struct statfs {
+ uint64_t f_type;
+ uint64_t f_bsize;
+ uint64_t f_blocks;
+ uint64_t f_bfree;
+ uint64_t f_bavail;
+ uint64_t f_files;
+ uint64_t f_ffree;
+ __kernel_fsid_t f_fsid;
+ uint64_t f_namelen;
+ uint64_t f_frsize;
+ uint64_t f_spare[5];
+};
+
+#endif /* BITSIZE */
+
+__extern int statfs(const char *, struct statfs *);
+__extern int fstatfs(int, struct statfs *);
+
+/* Various filesystem types */
+#define ADFS_SUPER_MAGIC 0xadf5
+#define AFFS_SUPER_MAGIC 0xadff
+#define AFS_FS_MAGIC 0x6B414653 /* 'kAFS' */
+#define AUTOFS_SUPER_MAGIC 0x0187
+#define BFS_MAGIC 0x1BADFACE
+#define CAPIFS_SUPER_MAGIC 0x434e
+#define CIFS_MAGIC_NUMBER 0xFF534D42
+#define CODA_SUPER_MAGIC 0x73757245
+#define CRAMFS_MAGIC 0x28cd3d45
+#define DEVFS_SUPER_MAGIC 0x1373
+#define DEVPTS_SUPER_MAGIC 0x1cd1
+#define EFS_SUPER_MAGIC 0x414A53
+#define EVENTPOLLFS_MAGIC 0x03111965
+#define EXT2_SUPER_MAGIC 0xEF53
+#define EXT3_SUPER_MAGIC 0xEF53
+#define GADGETFS_MAGIC 0xaee71ee7
+#define HFSPLUS_SUPER_MAGIC 0x482b
+#define HFS_MFS_SUPER_MAGIC 0xD2D7 /* MFS MDB (super block) */
+#define HFS_SUPER_MAGIC 0x4244 /* "BD": HFS MDB (super block) */
+#define HPFS_SUPER_MAGIC 0xf995e849
+#define HUGETLBFS_MAGIC 0x958458f6
+#define HWGFS_MAGIC 0x12061983
+#define IBMASMFS_MAGIC 0x66726f67
+#define ISOFS_SUPER_MAGIC 0x9660
+#define JFFS2_SUPER_MAGIC 0x72b6
+#define JFFS_MAGIC_BITMASK 0x34383931 /* "1984" */
+#define JFFS_MAGIC_SB_BITMASK 0x07c0 /* 1984 */
+#define JFS_SUPER_MAGIC 0x3153464a /* "JFS1" */
+#define MINIX2_SUPER_MAGIC 0x2468 /* minix V2 fs */
+#define MINIX2_SUPER_MAGIC2 0x2478 /* minix V2 fs, 30 char names */
+#define MINIX_SUPER_MAGIC 0x137F /* original minix fs */
+#define MINIX_SUPER_MAGIC2 0x138F /* minix fs, 30 char names */
+#define MSDOS_SUPER_MAGIC 0x4d44 /* MD */
+#define NCP_SUPER_MAGIC 0x564c
+#define NFS_SUPER_MAGIC 0x6969
+#define NFS_SUPER_MAGIC 0x6969
+#define OPENPROM_SUPER_MAGIC 0x9fa1
+#define OPROFILEFS_MAGIC 0x6f70726f
+#define PFMFS_MAGIC 0xa0b4d889
+#define PIPEFS_MAGIC 0x50495045
+#define PROC_SUPER_MAGIC 0x9fa0
+#define QNX4_SUPER_MAGIC 0x002f /* qnx4 fs detection */
+#define RAMFS_MAGIC 0x858458f6
+#define REISERFS_SUPER_MAGIC 0x52654973
+#define ROMFS_MAGIC 0x7275
+#define SMB_SUPER_MAGIC 0x517B
+#define SOCKFS_MAGIC 0x534F434B
+#define SYSFS_MAGIC 0x62656572
+#define TMPFS_MAGIC 0x01021994
+#define UDF_SUPER_MAGIC 0x15013346
+#define UFS_MAGIC 0x00011954
+#define UFS_MAGIC_4GB 0x05231994 /* fs > 4 GB && fs_featurebits */
+#define UFS_MAGIC_FEA 0x00195612 /* fs_featurebits supported */
+#define UFS_MAGIC_LFN 0x00095014 /* fs supports filenames > 14 chars */
+#define UFS_MAGIC_SEC 0x00612195 /* B1 security fs */
+#define USBDEVICE_SUPER_MAGIC 0x9fa2
+#define VXFS_SUPER_MAGIC 0xa501FCF5
+
+#endif /* _SYS_VFS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/sys/wait.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/sys/wait.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,28 @@
+/*
+ * sys/wait.h
+ */
+
+#ifndef _SYS_WAIT_H
+#define _SYS_WAIT_H
+
+#include <klibc/extern.h>
+#include <sys/types.h>
+#include <sys/resource.h>
+
+#include <linux/wait.h>
+
+#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
+#define WTERMSIG(s) ((s) & 0x7f)
+#define WIFEXITED(s) (WTERMSIG(s) == 0)
+#define WIFSTOPPED(s) (WTERMSIG(s) == 0x7f)
+/* Ugly hack to avoid multiple evaluation of "s" */
+#define WIFSIGNALED(s) (WTERMSIG((s)+1) >= 2)
+#define WCOREDUMP(s) ((s) & 0x80)
+#define WSTOPSIG(s) WEXITSTATUS(s)
+
+__extern pid_t wait(int *);
+__extern pid_t waitpid(pid_t, int *, int);
+__extern pid_t wait3(int *, int, struct rusage *);
+__extern pid_t wait4(pid_t, int *, int, struct rusage *);
+
+#endif /* _SYS_WAIT_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/syslog.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/syslog.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,64 @@
+/*
+ * syslog.h
+ */
+
+#ifndef _SYSLOG_H
+#define _SYSLOG_H
+
+#include <stdio.h>
+#include <klibc/extern.h>
+
+/* Alert levels */
+#define LOG_EMERG 0
+#define LOG_ALERT 1
+#define LOG_CRIT 2
+#define LOG_ERR 3
+#define LOG_WARNING 4
+#define LOG_NOTICE 5
+#define LOG_INFO 6
+#define LOG_DEBUG 7
+
+#define LOG_PRIMASK 7
+#define LOG_PRI(x) ((x) & LOG_PRIMASK)
+
+
+/* Facilities; not actually used */
+#define LOG_KERN 0000
+#define LOG_USER 0010
+#define LOG_MAIL 0020
+#define LOG_DAEMON 0030
+#define LOG_AUTH 0040
+#define LOG_SYSLOG 0050
+#define LOG_LPR 0060
+#define LOG_NEWS 0070
+#define LOG_UUCP 0100
+#define LOG_CRON 0110
+#define LOG_AUTHPRIV 0120
+#define LOG_FTP 0130
+#define LOG_LOCAL0 0200
+#define LOG_LOCAL1 0210
+#define LOG_LOCAL2 0220
+#define LOG_LOCAL3 0230
+#define LOG_LOCAL4 0240
+#define LOG_LOCAL5 0250
+#define LOG_LOCAL6 0260
+#define LOG_LOCAL7 0270
+
+#define LOG_FACMASK 01770
+#define LOG_FAC(x) (((x) >> 3) & (LOG_FACMASK >> 3))
+
+/* openlog() flags - not used */
+#define LOG_PID 0x01 /* include pid with message */
+#define LOG_CONS 0x02 /* write to console on logger error */
+#define LOG_ODELAY 0x04 /* delay connection until syslog() */
+#define LOG_NDELAY 0x08 /* open connection immediately */
+#define LOG_NOWAIT 0x10 /* wait for child processes (unused on linux) */
+#define LOG_PERROR 0x20 /* additional logging to stderr */
+
+
+__extern void openlog(const char *, int, int);
+__extern void syslog(int, const char *, ...);
+__extern void vsyslog(int, const char *, va_list);
+__extern void closelog(void);
+
+#endif /* _SYSLOG_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/termios.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/termios.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,86 @@
+/*
+ * termios.h
+ */
+
+#ifndef _TERMIOS_H
+#define _TERMIOS_H
+
+#include <klibc/extern.h>
+#include <stdint.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <linux/termios.h>
+
+/* Redefine these so the magic constants == the ioctl number to use. */
+#undef TCSANOW
+#undef TCSADRAIN
+#undef TCSAFLUSH
+#define TCSANOW TCSETS
+#define TCSADRAIN TCSETSW
+#define TCSAFLUSH TCSETSF
+
+static __inline__ int tcgetattr(int __fd, struct termios *__s)
+{
+ return ioctl(__fd, TCGETS, __s);
+}
+
+static __inline__ int tcsetattr(int __fd, int __opt, const struct termios *__s)
+{
+ return ioctl(__fd, __opt, (void *)__s);
+}
+
+static __inline__ int tcflow(int __fd, int __action)
+{
+ return ioctl(__fd, TCXONC, (void *)(intptr_t)__action);
+}
+
+static __inline__ int tcflush(int __fd, int __queue)
+{
+ return ioctl(__fd, TCFLSH, (void *)(intptr_t)__queue);
+}
+
+static __inline__ pid_t tcgetpgrp(int __fd)
+{
+ pid_t __p;
+ return ioctl(__fd, TIOCGPGRP, &__p) ? (pid_t)-1 : __p;
+}
+
+static __inline__ pid_t tcgetsid(int __fd)
+{
+ pid_t __p;
+ return ioctl(__fd, TIOCGSID, &__p) ? (pid_t)-1 : __p;
+}
+
+static __inline__ int tcsendbreak(int __fd, int __duration)
+{
+ return ioctl(__fd, TCSBRKP, (void *)(uintptr_t)__duration);
+}
+
+static __inline__ int tcsetpgrp(int __fd, pid_t __p)
+{
+ return ioctl(__fd, TIOCSPGRP, &__p);
+}
+
+static __inline__ speed_t cfgetospeed(const struct termios *__s)
+{
+ return (speed_t)(__s->c_cflag & CBAUD);
+}
+
+static __inline__ speed_t cfgetispeed(const struct termios *__s)
+{
+ return (speed_t)(__s->c_cflag & CBAUD);
+}
+
+static __inline__ int cfsetospeed(struct termios *__s, speed_t __v)
+{
+ __s->c_cflag = (__s->c_cflag & ~CBAUD) | (__v & CBAUD);
+ return 0;
+}
+
+static __inline__ int cfsetispeed(struct termios *__s, speed_t __v)
+{
+ __s->c_cflag = (__s->c_cflag & ~CBAUD) | (__v & CBAUD);
+ return 0;
+}
+
+#endif /* _TERMIOS_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/time.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/time.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+/*
+ * time.h
+ */
+
+#ifndef _TIME_H
+#define _TIME_H
+
+#include <klibc/extern.h>
+#include <sys/time.h>
+
+__extern time_t time(time_t *);
+__extern int nanosleep(const struct timespec *, struct timespec *);
+
+/* klibc-specific but useful since we don't have floating point */
+__extern char *strtotimeval(const char *str, struct timeval *tv);
+__extern char *strtotimespec(const char *str, struct timespec *tv);
+
+#endif /* _TIME_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/unistd.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/unistd.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,140 @@
+/*
+ * unistd.h
+ */
+
+#ifndef _UNISTD_H
+#define _UNISTD_H
+
+#include <klibc/extern.h>
+#include <klibc/compiler.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/select.h>
+
+__extern char **environ;
+__extern __noreturn _exit(int);
+
+__extern pid_t fork(void);
+__extern pid_t vfork(void);
+__extern pid_t getpid(void);
+__extern pid_t getpgid(pid_t);
+__extern int setpgid(pid_t, pid_t);
+__extern pid_t getppid(void);
+__extern pid_t getpgrp(void);
+__extern int setpgrp(void);
+__extern pid_t setsid(void);
+__extern pid_t getsid(pid_t);
+__extern int execv(const char *, char * const *);
+__extern int execvp(const char *, char * const *);
+__extern int execve(const char *, char * const *, char * const *);
+__extern int execvpe(const char *, char * const *, char * const *);
+__extern int execl(const char *, const char *, ...);
+__extern int execlp(const char *, const char *, ...);
+__extern int execle(const char *, const char *, ...);
+__extern int execlpe(const char *, const char *, ...);
+
+__extern int setuid(uid_t);
+__extern uid_t getuid(void);
+__extern int seteuid(uid_t);
+__extern uid_t geteuid(void);
+__extern int setgid(gid_t);
+__extern gid_t getgid(void);
+__extern int setegid(gid_t);
+__extern gid_t getegid(void);
+__extern int getgroups(int, gid_t *);
+__extern int setgroups(size_t, const gid_t *);
+__extern int setreuid(uid_t, uid_t);
+__extern int setregid(gid_t, gid_t);
+__extern int setresuid(uid_t, uid_t, uid_t);
+__extern int setresgid(gid_t, gid_t, gid_t);
+__extern int getfsuid(uid_t);
+__extern int setfsuid(uid_t);
+
+/* Macros for access() */
+#define R_OK 4 /* Read */
+#define W_OK 2 /* Write */
+#define X_OK 1 /* Execute */
+#define F_OK 0 /* Existence */
+
+__extern int access(const char *, int);
+__extern int link(const char *, const char *);
+__extern int unlink(const char *);
+__extern int chdir(const char *);
+__extern int fchdir(int);
+__extern int chmod(const char *, mode_t);
+__extern int fchmod(int, mode_t);
+__extern int mkdir(const char *, mode_t);
+__extern int rmdir(const char *);
+__extern int pipe(int *);
+__extern int chroot(const char *);
+__extern int symlink(const char *, const char *);
+__extern int readlink(const char *, char *, size_t);
+__extern int chown(const char *, uid_t, gid_t);
+__extern int fchown(int, uid_t, gid_t);
+__extern int lchown(const char *, uid_t, gid_t);
+__extern char *getcwd(char *, size_t);
+
+__extern int sync(void);
+
+/* Also in <fcntl.h> */
+#ifndef _KLIBC_IN_OPEN_C
+__extern int open(const char *, int, ...);
+#endif
+__extern int close(int);
+__extern off_t lseek(int, off_t, int);
+/* off_t is 64 bits now even on 32-bit platforms; see llseek.c */
+static __inline__ off_t llseek(int __f, off_t __o, int __w) {
+ return lseek(__f, __o, __w);
+}
+
+__extern ssize_t read(int, void *, size_t);
+__extern ssize_t write(int, const void *, size_t);
+__extern ssize_t pread(int, void *, size_t, off_t);
+__extern ssize_t pwrite(int, void *, size_t, off_t);
+
+__extern int dup(int);
+__extern int dup2(int, int);
+__extern int fcntl(int, int, ...);
+__extern int ioctl(int, int, void *);
+__extern int flock(int, int);
+__extern int fsync(int);
+__extern int fdatasync(int);
+__extern int ftruncate(int, off_t);
+
+__extern int pause(void);
+__extern unsigned int alarm(unsigned int);
+__extern unsigned int sleep(unsigned int);
+__extern void usleep(unsigned long);
+
+__extern int gethostname(char *, size_t);
+__extern int sethostname(const char *, size_t);
+__extern int getdomainname(char *, size_t);
+__extern int setdomainname(const char *, size_t);
+
+__extern void *__brk(void *);
+__extern int brk(void *);
+__extern void *sbrk(ptrdiff_t);
+
+__extern int getopt(int, char * const *, const char *);
+__extern char *optarg;
+__extern int optind, opterr, optopt;
+
+__extern int isatty(int);
+
+static __inline__ int getpagesize(void) {
+ extern unsigned int __page_size;
+ return __page_size;
+}
+static __inline__ int __getpageshift(void) {
+ extern unsigned int __page_shift;
+ return __page_shift;
+}
+
+__extern int daemon(int, int);
+
+/* Standard file descriptor numbers. */
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+
+#endif /* _UNISTD_H */
Added: multipath-tools/upstream/current/klibc-0.190/include/utime.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/include/utime.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * utime.h
+ */
+
+#ifndef _UTIME_H
+#define _UTIME_H
+
+#include <klibc/extern.h>
+#include <sys/types.h>
+#include <linux/utime.h>
+
+__extern int utime(const char *, const struct utimbuf *);
+
+#endif /* _UTIME_H */
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc.spec.in
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc.spec.in Fri Mar 4 08:05:19 2005
@@ -0,0 +1,157 @@
+Summary: A minimal libc subset for use with initramfs.
+Name: klibc
+Version: @@VERSION@@
+Release: 1
+License: BSD/GPL
+Group: Development/Libraries
+URL: http://www.zytor.com/mailman/listinfo/klibc
+Source: http://www.kernel.org/pub/linux/libs/klibc-%{version}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
+BuildRequires: kernel-source >= 2.6.0
+Packager: H. Peter Anvin <hpa at zytor.com>
+Prefix: /usr
+Vendor: Starving Linux Artists
+
+%description
+%{name} is intended to be a minimalistic libc subset for use with
+initramfs. It is deliberately written for small size, minimal
+entanglement, and portability, not speed. It is definitely a work in
+progress, and a lot of things are still missing.
+
+%package kernheaders
+Summary: Kernel headers used during the build of klibc.
+Group: Development/Libraries
+
+%description kernheaders
+This package contains the set of kernel headers that were required to
+build %{name} and the utilities that ship with it. This may or may
+not be a complete enough set to build other programs that link against
+%{name}. If in doubt, use real kernel headers instead.
+
+%package utils
+Summary: Small statically-linked utilities built with klibc.
+Group: Utilities/System
+
+%description utils
+
+This package contains a collection of programs that are statically
+linked against klibc. These duplicate some of the functionality of a
+regular Linux toolset, but are typically much smaller than their
+full-function counterparts. They are intended for inclusion in
+initramfs images and embedded systems.
+
+%prep
+%setup -q
+cp -as /usr/src/linux-`rpm -q kernel-source | tail -1 | cut -d- -f3-` ./linux
+make -C linux defconfig ARCH=%{_target_cpu}
+make -C linux prepare ARCH=%{_target_cpu}
+# Deal with braindamage in RedHat's kernel-source RPM
+rm -f linux/include/linux/config.h
+cat <<EOF > linux/include/linux/config.h
+#ifndef _LINUX_CONFIG_H
+#define _LINUX_CONFIG_H
+
+#include <linux/autoconf.h>
+
+#endif
+EOF
+mkdir -p %{buildroot}
+
+%build
+make ARCH=%{_target_cpu}
+
+%install
+rm -rf %{buildroot}
+
+dest=%{buildroot}/%{prefix}
+lib=$dest/%{_lib}/klibc
+inc=$dest/include/klibc
+exe=$dest/libexec/klibc
+doc=$dest/share/doc/%{name}-%{version}
+udoc=$dest/share/doc/%{name}-utils-%{version}
+
+# First, the library.
+
+install -dD -m 755 $lib $inc/kernel $exe $doc $udoc
+install -m 755 klibc/klibc.so $lib
+install -m 644 klibc/libc.a $lib
+install -m 644 klibc/crt0.o $lib
+install -m 644 klibc/libc.so.hash $lib
+ln $lib/klibc.so $lib/libc.so
+ln $lib/klibc.so $lib/klibc-$(cat $lib/libc.so.hash).so
+
+# Next, the generated binaries.
+# These are currently static binaries, should we go for shared?
+
+install -m 755 ash/sh $exe
+install -m 755 gzip/gzip $exe
+ln $exe/gzip $exe/gunzip
+ln $exe/gzip $exe/zcat
+install -m 755 ipconfig/ipconfig $exe
+install -m 755 kinit/kinit $exe
+install -m 755 nfsmount/nfsmount $exe
+install -m 755 utils/static/* $exe
+
+# The docs.
+
+install -m 444 README $doc
+install -m 444 klibc/README $doc/README.klibc
+install -m 444 klibc/arch/README $doc/README.klibc.arch
+
+install -m 444 gzip/COPYING $udoc/COPYING.gzip
+install -m 444 gzip/README $udoc/README.gzip
+install -m 444 ipconfig/README $udoc/README.ipconfig
+install -m 444 kinit/README $udoc/README.kinit
+
+# Finally, the include files.
+
+bitsize=$(make --no-print-directory -C klibc bitsize ARCH=%{_target_cpu})
+cp --parents $(find klibc/include \( -name CVS -o -name SCCS \) -prune \
+ -o -name '*.h' -print) $inc
+mv $inc/klibc $inc/klibc.$$
+mv $inc/klibc.$$/include/* $inc
+mv $inc/bits$bitsize/bitsize $inc
+rm -rf $inc/klibc.$$ $inc/bits[0-9]*
+pushd klibc/arch/%{_arch}/include
+cp --parents -f $(find . \( -name CVS -o -name SCCS \) -prune \
+ -o -name '*.h' -print) $inc
+popd
+
+# Yeugh. Find the transitive closure over all kernel headers included
+# by klibc, and copy them into place.
+
+find . -name '.*.d' | xargs -r sed -e 's,[ \t][ \t]*,\n,g' | sed -n -e 's,^\.\./linux/include/,,p' | sort | uniq | (cd linux/include && xargs -ri cp --parents '{}' $inc/kernel)
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root,-)
+%docdir %{prefix}/share/doc/%{name}-%{version}
+%{prefix}/%{_lib}/klibc
+%dir %{prefix}/include/klibc
+%{prefix}/include/klibc/*.h
+%{prefix}/include/klibc/arpa
+%{prefix}/include/klibc/bitsize
+%{prefix}/include/klibc/klibc
+%{prefix}/include/klibc/net
+%{prefix}/include/klibc/netinet
+%{prefix}/include/klibc/sys
+%{prefix}/share/doc/%{name}-%{version}
+
+%files kernheaders
+%defattr(-,root,root,-)
+%{prefix}/include/klibc/kernel
+
+%files utils
+%defattr(-,root,root,-)
+%{prefix}/libexec/klibc
+%docdir %{prefix}/share/doc/%{name}-utils-%{version}
+%{prefix}/share/doc/%{name}-utils-%{version}
+
+%changelog
+* Tue Jul 6 2004 H. Peter Anvin <hpa at zytor.com>
+- Update to use kernel-source RPM for the kernel symlink.
+
+* Sat Nov 29 2003 Bryan O'Sullivan <bos at serpentine.com> -
+- Initial build.
Added: multipath-tools/upstream/current/klibc-0.190/klibc/CAVEATS
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/CAVEATS Fri Mar 4 08:05:19 2005
@@ -0,0 +1,61 @@
+ -------------------------------------------------
+ Please note the following caveats to using klibc:
+ -------------------------------------------------
+
+optimization:
+-------------
+
+Compiling with -O0 is not supported. It may or may not work; please
+use -O1 if you want to do maximize debuggability.
+
+Compiling with -O0 is more likely to work on gcc 3.
+
+
+setjmp()/longjmp():
+-------------------
+
+setjmp() and longjmp() *do not* save signal state. sigsetjmp() and
+siglongjmp() *do* save the signal mask -- regardless of the value of
+the extra argument.
+
+The standards actually state that if you pass longjmp() a final value
+of zero the library should change that to a 1! Presumably the reason
+is so people who write broken code can get away with writing
+longjmp(buf); or something equally bad. If you pass longjmp() a final
+value of 0 you get what you deserve -- setjmp() will happily return 0.
+
+
+stdio:
+------
+
+Only a small subset of the stdio functions are implemented. Those
+that are implemented do not buffer, although they *do* trap EINTR or
+short read/writes and iterate.
+
+_fread() and _fwrite(), which take only one size argument (like
+read/write), but do handle EINTR/short return are also available.
+
+
+namespaces:
+-----------
+
+klibc frequently includes headers in other headers in a way that
+exposes more symbols than POSIX says they should. "Live with it."
+
+
+theading:
+---------
+
+klibc is not thread-safe. Consequently, clone() or any of the
+pthreads functions are not included.
+
+
+bsd_signal vs sysv_signal:
+--------------------------
+
+There is no signal() call, because you never know if you want
+Linux/SysV semantics (SA_RESETHAND) or GNU/BSD semantics (SA_RESTART).
+The best, in *any* circumstances, is to never use signal() and instead
+use sigaction(), but in order to simplify porting you can use either
+sysv_signal() or bsd_signal(), depending on what you actually want.
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/LICENSE
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/LICENSE Fri Mar 4 08:05:19 2005
@@ -0,0 +1,73 @@
+This license applies to all files in directory and its subdirectories,
+unless otherwise noted in individual files.
+
+
+Some files are derived from files derived from the include/ directory
+of the Linux kernel, and are licensed under the terms of the GNU
+General Public License, version 2, as released by the Free Software
+Foundation, Inc.; incorporated herein by reference.
+
+ -----
+
+Some files are derived from files copyrighted by the Regents of The
+University of California, and are available under the following
+license:
+
+Note: The advertising clause in the license appearing on BSD Unix
+files was officially rescinded by the Director of the Office of
+Technology Licensing of the University of California on July 22
+1999. He states that clause 3 is "hereby deleted in its entirety."
+
+ * Copyright (c)
+ * 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 acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * 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.
+
+ -----
+
+For all remaining files, the following license applies:
+
+ * 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:
+ *
+ * Any copyright notice(s) 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 AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Added: multipath-tools/upstream/current/klibc-0.190/klibc/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+# -*- makefile -*-
+#
+# Makefile configuration, without explicit rules
+#
+
+SRCROOT = ..
+include ../MCONFIG
+include ../MRULES
+
+WARNFLAGS = -W -Wall -Wpointer-arith -Wwrite-strings -Wstrict-prototypes -Winline
+
+ifeq ($(ERRLIST),1)
+REQFLAGS += -DWITH_ERRLIST
+endif
+
+CFLAGS = -Wp,-MT,$@,-MD,$(dir $@).$(notdir $@).d $(OPTFLAGS) $(REQFLAGS) $(WARNFLAGS)
+
+SOFLAGS = -fPIC
Added: multipath-tools/upstream/current/klibc-0.190/klibc/Makefile
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/Makefile Fri Mar 4 08:05:19 2005
@@ -0,0 +1,173 @@
+#
+# Makefile
+#
+# Main makefile
+#
+
+# Include configuration rules
+include MCONFIG
+
+TESTS = $(patsubst %.c,%,$(wildcard tests/*.c)) \
+ $(patsubst %.c,%.shared,$(wildcard tests/*.c))
+LIBOBJS = vsnprintf.o snprintf.o vsprintf.o sprintf.o \
+ asprintf.o vasprintf.o \
+ vsscanf.o sscanf.o ctypes.o \
+ strntoumax.o strntoimax.o \
+ atoi.o atol.o atoll.o \
+ strtol.o strtoll.o strtoul.o strtoull.o \
+ strtoimax.o strtoumax.o \
+ globals.o exitc.o atexit.o onexit.o \
+ execl.o execle.o execv.o execvpe.o execvp.o execlp.o execlpe.o \
+ fork.o wait.o wait3.o waitpid.o system.o setpgrp.o getpgrp.o \
+ daemon.o \
+ printf.o vprintf.o fprintf.o vfprintf.o perror.o \
+ statfs.o fstatfs.o umount.o \
+ open.o fopen.o fread.o fread2.o fgetc.o fgets.o \
+ fwrite.o fwrite2.o fputc.o fputs.o puts.o putchar.o \
+ sleep.o usleep.o strtotimespec.o strtotimeval.o \
+ raise.o abort.o assert.o alarm.o pause.o \
+ __signal.o sysv_signal.o bsd_signal.o siglist.o siglongjmp.o \
+ sigaction.o sigpending.o sigprocmask.o sigsuspend.o \
+ brk.o sbrk.o malloc.o realloc.o calloc.o mmap.o \
+ memcpy.o memcmp.o memset.o memccpy.o memmem.o memswap.o \
+ memmove.o memchr.o \
+ strcasecmp.o strncasecmp.o strndup.o strerror.o \
+ strcat.o strchr.o strcmp.o strcpy.o strdup.o strlen.o strnlen.o \
+ strncat.o strlcpy.o strlcat.o \
+ strstr.o strncmp.o strncpy.o strrchr.o strspn.o \
+ strsep.o strtok.o \
+ gethostname.o getdomainname.o getcwd.o \
+ seteuid.o setegid.o \
+ getenv.o setenv.o putenv.o __put_env.o unsetenv.o \
+ getopt.o readdir.o \
+ syslog.o closelog.o pty.o getpt.o isatty.o reboot.o \
+ time.o utime.o llseek.o nice.o getpriority.o \
+ qsort.o \
+ lrand48.o jrand48.o mrand48.o nrand48.o srand48.o seed48.o \
+ inet/inet_ntoa.o inet/inet_aton.o inet/inet_addr.o \
+ inet/inet_ntop.o inet/inet_pton.o inet/bindresvport.o \
+ send.o recv.o
+ifeq ($(ERRLIST),1)
+LIBOBJS += errlist.o
+endif
+
+SOLIB = libc.so
+SOHASH = klibc.so
+
+CRT0 = crt0.o
+LIB = libc.a
+
+INTERP_O = interp.o
+
+all: tests $(CRT0) $(LIB) $(SOLIB) klibc.so
+
+# Add any architecture-specific rules
+include arch/$(ARCH)/Makefile.inc
+EMAIN ?= -e main
+
+tests: $(TESTS)
+
+tests/%.o : tests/%.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+# This particular file uses a bunch of formats gcc don't know of, in order
+# to test the full range of our vsnprintf() function. This outputs a bunch
+# of useless warnings unless we tell it not to.
+tests/testvsnp.o : tests/testvsnp.c
+ $(CC) $(CFLAGS) -Wno-format -c -o $@ $<
+
+tests/% : tests/%.o $(LIB) $(CRT0)
+ $(LD) $(LDFLAGS) -o $@ $(CRT0) $< $(LIB) $(LIBGCC)
+ cp $@ $@.stripped
+ $(STRIP) $@.stripped
+
+tests/%.shared : tests/%.o interp.o $(SOLIB)
+ $(LD) $(LDFLAGS) -o $@ $(EMAIN) interp.o tests/$*.o -R $(SOLIB) $(LIBGCC)
+ cp $@ $@.stripped
+ $(STRIP) $@.stripped
+
+$(LIB): __static_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj
+ rm -f $(LIB)
+ $(AR) cq $(LIB) __static_init.o $(LIBOBJS) $(ARCHOBJS) \
+ $(wildcard syscalls/*.o) $(wildcard socketcalls/*.o)
+ $(RANLIB) $(LIB)
+
+$(SOLIB): $(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) syscalls/static.obj socketcalls/static.obj
+ $(LD) $(LDFLAGS) $(SHAREDFLAGS) -o $@ \
+ $(CRT0) __shared_init.o $(LIBOBJS) $(ARCHOBJS) \
+ $(wildcard syscalls/*.o) $(wildcard socketcalls/*.o) \
+ $(LIBGCC)
+
+sha1hash: sha1hash.c
+ $(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ $<
+
+$(SOLIB).hash: $(SOLIB) sha1hash
+ $(NM) $(SOLIB) | \
+ egrep '^[0-9a-fA-F]+ [ADRTW] ' | sort | ./sha1hash > $@
+
+$(SOHASH): $(SOLIB) $(SOLIB).hash
+ cp -f $(SOLIB) $@
+ $(STRIP) $@
+ rm -f klibc-??????????????????????.so
+ ln -f $@ klibc-`cat $(SOLIB).hash`.so
+
+$(INTERP_O): interp.S $(SOLIB).hash
+ $(CC) $(CFLAGS) -D__ASSEMBLY__ -DLIBDIR=\"$(SHLIBDIR)\" \
+ -DSOHASH=\"`cat $(SOLIB).hash`\" \
+ -c -o $@ $<
+
+crt0.o: arch/$(ARCH)/crt0.o
+ cp arch/$(ARCH)/crt0.o .
+
+errlist.c:
+ $(PERL) makeerrlist.pl $(INCLUDE) -errlist > $@ || rm -f $@
+
+# We pass -ansi to keep cpp from define e.g. "i386" as well as "__i386__"
+SYSCALLS.i: SYSCALLS.def
+ $(CC) $(CFLAGS) -D__ASSEMBLY__ -ansi -x assembler-with-cpp -E -o $@ $<
+
+syscalls.nrs: ../include/sys/syscall.h
+ $(CC) $(CFLAGS) -Wp,-dM -x c -E -o $@ $<
+
+syscalls.dir: SYSCALLS.i syscalls.pl arch/$(ARCH)/sysstub.ph syscommon.h syscalls.nrs
+ rm -rf syscalls
+ mkdir syscalls
+ $(PERL) syscalls.pl SYSCALLS.i $(ARCH) $(BITSIZE) syscalls.nrs ../include/klibc/havesyscall.h
+ touch $@
+
+../include/klibc/havesyscall.h: syscalls.dir
+ : Generated by side effect
+
+socketcalls.dir: SOCKETCALLS.def socketcalls.pl socketcommon.h
+ rm -rf socketcalls
+ mkdir socketcalls
+ $(PERL) socketcalls.pl SOCKETCALLS.def $(ARCH)
+ touch $@
+
+%/static.obj: %.dir
+ $(MAKE) objects-$(basename $(notdir $@)) DIR=$*/
+
+STATIC = $(addsuffix .o,$(basename $(wildcard $(DIR)*.[cS])))
+
+objects-static: $(STATIC)
+ touch $(DIR)static.obj
+
+clean: archclean
+ find . -type f -a \( -name \*.[isoa] -o -name \*.l[iso] \) -print0 | xargs -0rt rm -f
+ rm -f *.a *.so *.hash *.syms *.stripped
+ rm -f $(TESTS) tests/*.stripped
+ rm -rf syscalls syscalls.dir
+ rm -rf socketcalls socketcalls.dir
+ rm -f sha1hash errlist.c
+
+spotless: clean
+ rm -f ../include/klibc/havesyscall.h syscalls.nrs
+ find . \( -name \*~ -o -name '.*.d' \) -not -type d -print0 | \
+ xargs -0rt rm -f
+
+bitsize:
+ @echo $(BITSIZE)
+
+ifneq ($(wildcard $(DIR).*.d),)
+include $(wildcard $(DIR).*.d)
+endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/README
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/README Fri Mar 4 08:05:19 2005
@@ -0,0 +1,80 @@
+This is klibc, what is intended to be a minimalistic libc subset for
+use with initramfs. It is deliberately written for small size,
+minimal entaglement, and portability, not speed. It is definitely a
+work in progress, and a lot of things are still missing.
+
+
+The build procedure is not very polished yet, but it should work like
+this:
+
+a) In the source root directory (the directory above the one in which
+ this file is found) create a symlink called "linux" pointing to a
+ reasonably recent Linux kernel tree (2.4 or 2.6 should be OK.)
+ This tree must have the include/asm symlink set up for the
+ architecture you're compiling for, and include/linux/autoconf.h
+ must exist. The easiest way to make sure of all of these is to do
+ a "make config" or any of its variants on the kernel tree is
+ question, followed by a "make dep" (2.4) or "make prepare" (2.6).
+
+b) If you're cross-compiling, change ARCH in the main MCONFIG file to
+ the appropriate architecture, and set CROSS to your toolchain
+ prefix.
+
+ IMPORTANT: if you're on a 64-bit machine with a 32-bit userland
+ (ia64, mips64, ppc64 sparc64, s390x or x86_64), and you want to
+ build the 32-bit version: you need to set ARCH to the 32-bit
+ architecture as well as set up the linux/include/asm symlink to
+ point to the 32-bit architecture. Building the 32-bit architecture
+ usually (but not always) produces smaller binaries, and is likely
+ to be better tested.
+
+ If you are on ARM, and want to build a thumb version of the library
+ (this is supported), change OPTFLAGS in arch/arm/MCONFIG to build
+ thumb code.
+
+ The following is the last known status of various architectures:
+
+ alpha: Working static, shared untested
+ arm-thumb: Untested
+ arm26: Not yet ported
+ arm: Working
+ cris: Working
+ h8300: Not yet ported
+ i386: Working
+ ia64: Working
+ m68k: Not yet ported
+ mips64: Not yet ported
+ mips: Working
+ parisc: Untested
+ ppc64: Working
+ ppc: Working
+ s390: Working static, shared untested
+ s390x: Working
+ sh: Untested
+ sparc64: Untested
+ sparc: Working
+ v850: Not yet ported
+ x86-64: Working
+
+ Shared library support requires recent binutils on many
+ architectures.
+
+ "Need sysstub.ph" means the architectural changes first implemented
+ in klibc-0.117 has not yet been implemented; klibc-0.116 did,
+ however, work. "Not yet ported" means no porting work has been
+ done on this architecture.
+
+ Note that even the "working" ones likely have bugs. Please report
+ them if you run into them.
+
+c) Type "make" and pray...
+
+d) Try the test programs in the tests/ directory. They should run...
+
+Contact the klibc mailing list:
+
+ http://www.zytor.com/mailman/listinfo/klibc
+
+... for more info.
+
+ -hpa
Added: multipath-tools/upstream/current/klibc-0.190/klibc/SOCKETCALLS.def
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/SOCKETCALLS.def Fri Mar 4 08:05:19 2005
@@ -0,0 +1,21 @@
+; -*- fundamental -*-
+;
+; These are calls that are invoked via the socketcall mechanism
+; Note that on most architectures this is simply #included into
+; SYSCALLS.def.
+;
+<?> int socket(int, int, int)
+<?> int bind(int, struct sockaddr *, int)
+<?> int connect(int, struct sockaddr *, socklen_t)
+<?> int listen(int, int)
+<?> int accept(int, struct sockaddr *, socklen_t *)
+<?> int getsockname(int, struct sockaddr *, socklen_t *)
+<?> int getpeername(int, struct sockaddr *, socklen_t *)
+<?> int socketpair(int, int, int, int *)
+<?> int sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t)
+<?> int recvfrom(int, void *, size_t, unsigned int, struct sockaddr *, socklen_t *)
+<?> int shutdown(int, int)
+<?> int setsockopt(int, int, int, const void *, socklen_t)
+<?> int getsockopt(int, int, int, void *, socklen_t *)
+<?> int sendmsg(int, const struct msghdr *, unsigned int)
+<?> int recvmsg(int, struct msghdr *, unsigned int)
Added: multipath-tools/upstream/current/klibc-0.190/klibc/SYSCALLS.def
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/SYSCALLS.def Fri Mar 4 08:05:19 2005
@@ -0,0 +1,212 @@
+; -*- fundamental -*-
+;
+; This is a list of system calls we invoke "directly". These
+; are generated into syscall stubs in their own files, so the
+; linker can do its job properly.
+;
+; The full description of a line is:
+; [<[?][!]arch,...>] type [sysname,...][@systype][::funcname](args)
+;
+; ? means only instantiate this system call if present in asm/unistd.h
+;
+
+#include <asm/unistd.h>
+
+;
+; Process-related syscalls
+;
+<!i386,x86_64> void _exit,exit::_exit(int)
+<?!ia64> pid_t clone::__clone(unsigned long, void *)
+<?ia64> pid_t clone::__clone2(unsigned long, void *, void *)
+<?!sparc> pid_t fork()
+<sparc> pid_t fork at forkish()
+<!mips,mips64,sparc,ia64> pid_t vfork()
+<sparc> pid_t vfork at forkish()
+<!alpha> pid_t getpid()
+<alpha> pid_t getxpid at dual0::getpid()
+int setpgid(pid_t, pid_t)
+pid_t getpgid(pid_t)
+<!alpha> pid_t getppid()
+<alpha> pid_t getxpid at dual1::getppid()
+pid_t setsid()
+pid_t getsid(pid_t)
+pid_t wait4(pid_t, int *, int, struct rusage *)
+int execve(const char *, char * const *, char * const *)
+<?> int nice(int)
+<alpha,ia64> int getpriority(int, int)
+<!alpha,ia64> int getpriority::__getpriority(int, int)
+int setpriority(int, int, int)
+int sched_setscheduler(pid_t, int, const struct sched_param *)
+int sched_yield()
+
+;
+; User and group IDs
+;
+int setuid32,setuid::setuid(uid_t)
+int setgid32,setgid::setgid(gid_t)
+<!alpha> uid_t getuid32,getuid::getuid()
+<alpha> uid_t getxuid at dual0::getuid()
+<!alpha> gid_t getgid32,getgid::getgid()
+<alpha> gid_t getxgid at dual0::getgid()
+<!alpha> uid_t geteuid32,geteuid::geteuid()
+<alpha> uid_t getxuid at dual1::geteuid()
+<!alpha> gid_t getegid32,getegid::getegid()
+<alpha> gid_t getxgid at dual1::getegid()
+int getgroups32,getgroups::getgroups(int, gid_t *)
+int setgroups32,setgroups::setgroups(size_t, const gid_t *)
+int setreuid32,setreuid::setreuid(uid_t, uid_t)
+int setregid32,setregid::setregid(gid_t, gid_t)
+int setfsuid32,setfsuid::setfsuid(uid_t)
+int setfsgid32,setfsgid::setfsgid(gid_t)
+int setresuid32,setresuid::setresuid(int, uid_t, uid, uid_t)
+
+;
+; Filesystem-related system calls
+;
+int mount(const char *, const char *, const char *, unsigned long, const void *)
+<!alpha,ia64> int umount2(const char *, int)
+<alpha,ia64> int umount::umount2(const char *, int)
+<?> int pivot_root(const char *, const char *)
+int sync()
+#ifdef __NR_statfs64
+int statfs64::__statfs64(const char *, size_t, struct statfs *)
+#else
+int statfs(const char *, struct statfs *)
+#endif
+#ifdef __NR_fstatfs64
+int fstatfs64::__fstatfs64(int, size_t, struct statfs *)
+#else
+int fstatfs(int, struct statfs *)
+#endif
+int swapon(const char *, int)
+int swapoff(const char *)
+
+;
+; Inode-related system calls
+;
+int access(const char *, int)
+int link(const char *, const char *)
+int unlink(const char *)
+int chdir(const char *)
+int fchdir(int)
+int rename(const char *, const char *)
+int mknod(const char *, mode_t, dev_t)
+int chmod(const char *, mode_t)
+int fchmod(int, mode_t)
+int mkdir(const char *, mode_t)
+int rmdir(const char *)
+<!alpha,ia64,mips,mips64> int pipe(int *)
+mode_t umask(mode_t)
+int chroot(const char *)
+int symlink(const char *, const char *)
+int readlink(const char *, char *, size_t)
+<!ppc64> int stat64,stat::stat(const char *, struct stat *)
+<!ppc64> int lstat64,lstat::lstat(const char *, struct stat *)
+<!ppc64> int fstat64,fstat::fstat(int, struct stat *)
+<ppc64> int stat::stat(const char *, struct stat *)
+<ppc64> int lstat::lstat(const char *, struct stat *)
+<ppc64> int fstat::fstat(int, struct stat *)
+int getdents64,getdents::getdents(unsigned int, struct dirent *, unsigned int)
+int chown32,chown::chown(const char *, uid_t, gid_t)
+int fchown32,fchown::fchown(int, uid_t, gid_t)
+int lchown32,lchown::lchown(const char *, uid_t, gid_t)
+int getcwd::__getcwd(char *, size_t)
+<?> int utime(const char *, const struct utimbuf *)
+<?> int utimes(const char *, const struct timeval *)
+
+;
+; I/O operations
+;
+<!i386,64> int open::__open(const char *, int, mode_t)
+<64> int open(const char *, int, mode_t)
+ssize_t read(int, void *, size_t)
+ssize_t write(int, const void *, size_t)
+int close(int)
+<64> off_t lseek(int, off_t, int)
+<32> int _llseek::__llseek(int, unsigned long, unsigned long, off_t *, int)
+int dup(int)
+int dup2(int, int)
+<i386> int fcntl64 at varadic::fcntl(int, int, unsigned long)
+<ppc64> int fcntl(int, int, unsigned long)
+<!i386,ppc64> int fcntl64,fcntl::fcntl(int, int, unsigned long)
+int ioctl(int, int, void *)
+int flock(int, int)
+int _newselect,select::select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
+int poll(struct pollfd *, nfds_t, long)
+int fsync(int)
+int fdatasync,fsync::fdatasync(int)
+int readv(int, const struct iovec *, int)
+int writev(int, const struct iovec *, int)
+int ftruncate64,ftruncate::ftruncate(int, off_t)
+ssize_t pread64,pread::pread(int, void *, size_t, off_t)
+ssize_t pwrite64,pwrite::pwrite(int, void *, size_t, off_t)
+
+;
+; Signal operations
+;
+int kill(pid_t, int)
+<?> int sigaction(int, const struct sigaction *, struct sigaction *)
+int rt_sigaction(int, const struct sigaction *, struct sigaction *, size_t)
+<?> int sigsuspend(const sigset_t *)
+int rt_sigsuspend(const sigset_t *, size_t)
+<?> int sigpending(sigset_t)
+int rt_sigpending(sigset_t *, size_t)
+<?> int sigprocmask(int, const sigset_t *, sigset_t *)
+int rt_sigprocmask(int, const sigset_t *, sigset_t *, size_t)
+<?> unsigned int alarm(unsigned int)
+int getitimer(int, struct itimerval *)
+int setitimer(int, const struct itimerval *, struct itimerval *)
+
+;
+; Time-related system calls
+;
+<?> time_t time(time_t *)
+clock_t times(struct tms *)
+int gettimeofday(struct timeval *, struct timezone *)
+int settimeofday(const struct timeval *, const struct timezone *)
+int nanosleep(const struct timespec *, struct timespec *)
+<?> int pause()
+
+;
+; Memory
+;
+void * brk::__brk(void *)
+int munmap(void *, size_t)
+void * mremap(void *, size_t, size_t, unsigned long)
+int msync(const void *, size_t, int)
+int mprotect(const void *, size_t, int)
+#if (BITSIZE == 32 && defined(__NR_mmap2)) || (BITSIZE == 64 && !defined(__NR_mmap))
+<!s390> void * mmap2::__mmap2(void *, size_t, int, int, int, long)
+#else
+<!s390x> void * mmap(void *, size_t, int, int, int, long)
+#endif
+int mlockall(int)
+int munlockall()
+int mlock(const void *, size_t)
+int munlock(const void *, size_t)
+
+;
+; System stuff
+;
+int uname(struct utsname *)
+int setdomainname(const char *, size_t)
+int sethostname(const char *, size_t)
+long init_module(void *, unsigned long, const char *)
+long delete_module(const char *, unsigned int)
+int reboot::__reboot(int, int, int, void *)
+int syslog::klogctl(int, char *, int)
+int sysinfo(struct sysinfo *)
+
+;
+; Low-level I/O (generally architecture-specific)
+;
+<i386,x86_64> int iopl(int)
+<i386,x86_64> int ioperm(unsigned long, unsigned long, int)
+<i386> int vm86(struct vm86_struct *)
+
+;
+; Most architectures have the socket interfaces using regular
+; system calls.
+;
+<?!i386> long socketcall::__socketcall(int, const unsigned long *)
+#include "SOCKETCALLS.def"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/__put_env.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/__put_env.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,60 @@
+/*
+ * __put_env.c - common code for putenv() and setenv()
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* Initialized to zero, meaning "not malloc'd" */
+static size_t __environ_size;
+
+/* str should be a duplicated version of the input string;
+ len is the length of the key including the = sign */
+int __put_env(char *str, size_t len, int overwrite)
+{
+ char **p, *q;
+ char **newenv;
+ size_t n;
+
+ n = 1; /* Include space for final NULL */
+ for ( p = environ ; (q = *p) ; p++ ) {
+ n++;
+ if ( !strncmp(q,str,len) ) {
+ if ( !overwrite )
+ free(str);
+ else
+ *p = str; /* Possible memory leak... */
+ return 0;
+ }
+ }
+
+ /* Need to extend the environment */
+ if ( n < __environ_size ) {
+ p[1] = NULL;
+ *p = str;
+ return 0;
+ } else {
+ if ( __environ_size ) {
+ newenv = realloc(environ, (__environ_size << 1)*sizeof(char *));
+ if ( !newenv )
+ return -1;
+
+ __environ_size <<= 1;
+ } else {
+ /* Make a reasonable guess how much more space we need */
+ size_t newsize = n+32;
+ newenv = malloc(newsize*sizeof(char *));
+ if ( !newenv )
+ return -1;
+
+ memcpy(newenv, environ, n*sizeof(char *));
+ __environ_size = newsize;
+ }
+ newenv[n-1] = str; /* Old NULL position */
+ newenv[n] = NULL;
+ environ = newenv;
+ }
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/__shared_init.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/__shared_init.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,2 @@
+#define SHARED 1
+#include "libc_init.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/__signal.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/__signal.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,22 @@
+/*
+ * __signal.c
+ */
+
+#include <signal.h>
+
+__sighandler_t __signal(int signum, __sighandler_t handler, int flags)
+{
+ struct sigaction sa;
+
+ sa.sa_handler = handler;
+ sa.sa_flags = flags;
+ sigemptyset(&sa.sa_mask);
+
+ if ( sigaction(signum, &sa, &sa) ) {
+ return (__sighandler_t)SIG_ERR;
+ } else {
+ return (__sighandler_t)sa.sa_handler;
+ }
+}
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/__static_init.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/__static_init.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,2 @@
+#define SHARED 0
+#include "libc_init.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/abort.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/abort.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * abort.c
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+
+void abort(void)
+{
+ sigset_t set;
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGABRT);
+ sigprocmask(SIG_UNBLOCK, &set, NULL);
+ raise(SIGABRT);
+ _exit(255); /* raise() should have killed us */
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/alarm.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/alarm.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+/*
+ * alarm.c
+ */
+
+#include <sys/time.h>
+#include <sys/syscall.h>
+
+#ifndef __NR_alarm
+
+/* Emulate alarm() via setitimer() */
+
+unsigned int alarm(unsigned int seconds)
+{
+ struct itimerval iv;
+
+ iv.it_interval.tv_sec = iv.it_interval.tv_usec = 0;
+ iv.it_value.tv_sec = seconds;
+ iv.it_value.tv_usec = 0;
+
+ setitimer(ITIMER_REAL, &iv, &iv);
+
+ return iv.it_value.tv_sec + (iv.it_value.tv_usec ? 1 : 0);
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/README
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/README Fri Mar 4 08:05:19 2005
@@ -0,0 +1,67 @@
+To port klibc to a new architecture, you need:
+
+a) A directory structure
+
+Each archtecture has an arch/ directory, which should include an
+MCONFIG and a Makefile.inc file.
+
+b) Startup code (arch/*/crt0.S)
+
+The crt0.S assembly routine typically corresponds to the following
+pseudo-C code. In addition, each architecture needs any support
+routines that gcc-generated code expects to find in the system library
+-- Alpha, for example, needs divide subroutines.
+
+The "getenvtest" test program is a very good test for proper crt0.S
+functionality.
+
+
+extern __noreturn __libc_init(void *, void *);
+
+__noreturn _start(void)
+{
+ void *elf_data = get_elf_data_address(); /* Usually the stack address */
+ void *atexit_ptr = get_atexit_ptr(); /* Usually in a register */
+
+ /* Some architectures need this for debugging to work */
+ setup_null_stack_frame_if_necessary();
+
+ __libc_init(elf_data, atexit_ptr);
+}
+
+
+c) A setenv implementation (arch/*/setjmp.S, arch/*/include/klibc/archsetjmp.h)
+
+On most (but not all!) architectures, this entails creating a setjmp
+buffer big enough to hold all callee-saved registers, plus the stack
+pointer and the return address. In setjmp.S you have:
+
+* A "setjmp" function that writes out the callee-saved registers, the
+ stack pointer and the return address to the buffer pointed to by the
+ first argument, and then returns zero normally.
+
+ On some architectures you need to take some kind of action to make
+ sure the contents of the stack is actually manifest in memory and
+ not cached in the CPU. In some cases (e.g. on SPARC) this will
+ automatically spill the registers onto the stack; then they don't
+ need to be spilled into the jmp_buf.
+
+* A "longjmp" function that read back these same registers from the
+ jmp_buf pointed to by the first argument, and returns the second
+ argument *to the address specified in the jmp_buf*.
+
+ On some architectures you need to take some kind of action to flush
+ any cached stack data or return stack.
+
+
+d) Any support functions needed by gcc, *unless* they are in libgcc
+ *and* libgcc is usable for klibc on your particular platform. If
+ libgcc isn't usable for klibc (on MIPS, for example, libgcc is
+ compiled in a way that is not compatible with klibc) there are
+ reasonably good clones of most of the libgcc functions in the libgcc
+ directory. To use them, add them to ARCHOBJS in
+ arch/*/Makefile.inc.
+
+
+e) A link location for the shared klibc. This should be specified in
+ SHAREDFLAGS in arch/*/MCONFIG.
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,17 @@
+# -*- makefile -*-
+#
+# arch/alpha/MCONFIG
+#
+# Build configuration for this architecture
+#
+
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 64
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# 7 GB - normal binaries start at 4.5 GB, and the stack is below
+# the binary.
+SHAREDFLAGS = -Ttext 0x1c0000200
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,95 @@
+# -*- makefile -*-
+#
+# arch/alpha/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+# Special CFLAGS for the divide code
+DIVCFLAGS = $(REQFLAGS) \
+ -O3 -fomit-frame-pointer -fcall-saved-1 -fcall-saved-2 \
+ -fcall-saved-3 -fcall-saved-4 -fcall-saved-5 -fcall-saved-6 \
+ -fcall-saved-7 -fcall-saved-8 -ffixed-15 -fcall-saved-16 \
+ -fcall-saved-17 -fcall-saved-18 -fcall-saved-19 -fcall-saved-20 \
+ -fcall-saved-21 -fcall-saved-22 -ffixed-23 -fcall-saved-24 \
+ -ffixed-25 -ffixed-27
+
+ARCHOBJS = \
+ arch/$(ARCH)/__divqu.o \
+ arch/$(ARCH)/__remqu.o \
+ arch/$(ARCH)/__divq.o \
+ arch/$(ARCH)/__remq.o \
+ arch/$(ARCH)/__divlu.o \
+ arch/$(ARCH)/__remlu.o \
+ arch/$(ARCH)/__divl.o \
+ arch/$(ARCH)/__reml.o \
+ arch/$(ARCH)/pipe.o \
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/syscall.o \
+ arch/$(ARCH)/sysdual.o
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
+arch/$(ARCH)/%.s: arch/$(ARCH)/%.ss
+ sed -e 's/\$$0\b/$$27/g' -e 's/\$$24\b/$$99/g' \
+ -e 's/\$$16\b/$$24/g' -e 's/\$$17\b/$$25/g' \
+ -e 's/\$$26\b/$$23/g' -e 's/\$$99\b/$$16/g' < $< > $@
+
+arch/$(ARCH)/%.ls: arch/$(ARCH)/%.lss
+ sed -e 's/\$$0\b/$$27/g' -e 's/\$$24\b/$$99/g' \
+ -e 's/\$$16\b/$$24/g' -e 's/\$$17\b/$$25/g' \
+ -e 's/\$$26\b/$$23/g' -e 's/\$$99\b/$$16/g' < $< > $@
+
+arch/$(ARCH)/__divqu.ss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -DSIGNED=0 -DREM=0 -DBITS=64 -DNAME=__divqu -S -o $@ $<
+
+arch/$(ARCH)/__remqu.ss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -DSIGNED=0 -DREM=1 -DBITS=64 -DNAME=__remqu -S -o $@ $<
+
+arch/$(ARCH)/__divq.ss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -DSIGNED=1 -DREM=0 -DBITS=64 -DNAME=__divq -S -o $@ $<
+
+arch/$(ARCH)/__remq.ss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -DSIGNED=1 -DREM=1 -DBITS=64 -DNAME=__remq -S -o $@ $<
+
+arch/$(ARCH)/__divlu.ss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -DSIGNED=0 -DREM=0 -DBITS=32 -DNAME=__divlu -S -o $@ $<
+
+arch/$(ARCH)/__remlu.ss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -DSIGNED=0 -DREM=1 -DBITS=32 -DNAME=__remlu -S -o $@ $<
+
+arch/$(ARCH)/__divl.ss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -DSIGNED=1 -DREM=0 -DBITS=32 -DNAME=__divl -S -o $@ $<
+
+arch/$(ARCH)/__reml.ss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -DSIGNED=1 -DREM=1 -DBITS=32 -DNAME=__reml -S -o $@ $<
+
+arch/$(ARCH)/__divqu.lss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=0 -DREM=0 -DBITS=64 -DNAME=__divqu -S -o $@ $<
+
+arch/$(ARCH)/__remqu.lss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=0 -DREM=1 -DBITS=64 -DNAME=__remqu -S -o $@ $<
+
+arch/$(ARCH)/__divq.lss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=1 -DREM=0 -DBITS=64 -DNAME=__divq -S -o $@ $<
+
+arch/$(ARCH)/__remq.lss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=1 -DREM=1 -DBITS=64 -DNAME=__remq -S -o $@ $<
+
+arch/$(ARCH)/__divlu.lss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=0 -DREM=0 -DBITS=32 -DNAME=__divlu -S -o $@ $<
+
+arch/$(ARCH)/__remlu.lss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=0 -DREM=1 -DBITS=32 -DNAME=__remlu -S -o $@ $<
+
+arch/$(ARCH)/__divl.lss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=1 -DREM=0 -DBITS=32 -DNAME=__divl -S -o $@ $<
+
+arch/$(ARCH)/__reml.lss: arch/$(ARCH)/divide.c
+ $(CC) $(DIVCFLAGS) -fPIC -DSIGNED=1 -DREM=1 -DBITS=32 -DNAME=__reml -S -o $@ $<
+
+archclean:
+ rm -f arch/$(ARCH)/*.ss arch/$(ARCH)/*.lss
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/README-gcc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/README-gcc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+ The current Alpha chips don't provide hardware for integer
+ division. The C compiler expects the functions
+
+ __divqu: 64-bit unsigned long divide
+ __remqu: 64-bit unsigned long remainder
+ __divq/__remq: signed 64-bit
+ __divlu/__remlu: unsigned 32-bit
+ __divl/__reml: signed 32-bit
+
+ These are not normal C functions: instead of the normal calling
+ sequence, these expect their arguments in registers t10 and t11, and
+ return the result in t12 (aka pv). Register AT may be clobbered
+ (assembly temporary), anything else must be saved.
+
+ Furthermore, the return address is in t9 instead of ra.
+
+ Normal function Divide functions
+ --------------- ----------------
+ v0 ($0) t12/pv ($27)
+ a0 ($16) t10 ($24)
+ a1 ($17) t11 ($25)
+ ra ($26) t9 ($23)
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,22 @@
+#
+# arch/alpha/crt0.S
+#
+
+ .text
+ .type _start, at function
+ .ent _start, 0
+ .globl _start
+_start:
+ .frame $30, 0, $26, 0
+ mov $31, $15
+ br $29, 1f
+1: ldgp $29, 0($29)
+ .prologue 0
+
+ lda $16, 0($30) # ELF data structure
+ lda $17, 0($0) # atexit pointer
+
+ jsr $26, __libc_init
+
+ .size _start,.-_start
+ .end _start
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/divide.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/divide.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,57 @@
+#include <stdint.h>
+#include <asm/gentrap.h>
+#include <asm/pal.h>
+
+#if BITS == 64
+typedef uint64_t uint;
+typedef int64_t sint;
+#else
+typedef uint32_t uint;
+typedef int32_t sint;
+#endif
+
+#ifdef SIGNED
+typedef sint xint;
+#else
+typedef uint xint;
+#endif
+
+xint NAME (uint num, uint den)
+{
+ uint quot = 0, qbit = 1;
+ int minus = 0;
+ xint v;
+
+ if ( den == 0 ) {
+ /* This is really $16, but $16 and $24 are exchanged by a script */
+ register unsigned long cause asm("$24") = GEN_INTDIV;
+ asm volatile("call_pal %0" :: "i" (PAL_gentrap), "r" (cause));
+ return 0; /* If trap returns... */
+ }
+
+#if SIGNED
+ if ( (sint)(num^den) < 0 )
+ minus = 1;
+ if ( (sint)num < 0 ) num = -num;
+ if ( (sint)den < 0 ) den = -den;
+#endif
+
+ /* Left-justify denominator and count shift */
+ while ( (sint)den >= 0 ) {
+ den <<= 1;
+ qbit <<= 1;
+ }
+
+ while ( qbit ) {
+ if ( den <= num ) {
+ num -= den;
+ quot += qbit;
+ }
+ den >>= 1;
+ qbit >>= 1;
+ }
+
+ v = (xint)(REM ? num : quot);
+ if ( minus ) v = -v;
+ return v;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/pipe.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/pipe.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,28 @@
+#include <unistd.h>
+#include <sys/syscall.h>
+
+/* pipe() on alpha returns both file descriptors in registers --
+ $0 and $20 respectively. This is unlike any other system call,
+ as far as I can tell. */
+
+int pipe(int *fds)
+{
+ register long sc_0 __asm__("$0");
+ register long sc_19 __asm__("$19");
+ register long sc_20 __asm__("$20");
+
+ sc_0 = __NR_pipe;
+ asm volatile("callsys" : "=r" (sc_0), "=r" (sc_19), "=r" (sc_20)
+ : "0" (sc_0)
+ : _syscall_clobbers);
+
+ if ( sc_19 ) {
+ errno = sc_19;
+ return -1;
+ }
+
+ fds[0] = sc_0;
+ fds[1] = sc_20;
+
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,77 @@
+#
+# setjmp.S
+#
+
+#
+# The jmp_buf looks like:
+#
+# s0..5
+# fp
+# ra
+# gp
+# sp
+#
+
+#include <machine/asm.h>
+
+ .text
+ .align 3
+ .type setjmp, at function
+ .ent setjmp, 0
+ .globl setjmp
+setjmp:
+ lda v0, 0(zero)
+ stq s0, 0(a0)
+ stq s1, 8(a0)
+ stq s2, 16(a0)
+ stq s3, 24(a0)
+ stq s4, 32(a0)
+ stq s5, 40(a0)
+ stq fp, 48(a0)
+ stq ra, 56(a0)
+ stq gp, 64(a0)
+ stq sp, 72(a0)
+ stt $f2, 80(a0)
+ stt $f3, 88(a0)
+ stt $f4, 96(a0)
+ stt $f5, 104(a0)
+ stt $f6, 112(a0)
+ stt $f7, 120(a0)
+ stt $f8, 128(a0)
+ stt $f9, 136(a0)
+ ret zero,(ra),1
+
+ .size setjmp,.-setjmp
+ .end setjmp
+
+ .type longjmp, at function
+ .ent longjmp, 0
+ .globl longjmp
+longjmp:
+ mov a1, v0
+ ldq s0, 0(a0)
+ ldq s1, 8(a0)
+ ldq s2, 16(a0)
+ ldq s3, 24(a0)
+ ldq s4, 32(a0)
+ ldq s5, 40(a0)
+ ldq fp, 48(a0)
+ ldq ra, 56(a0)
+ ldq gp, 64(a0)
+ ldq sp, 72(a0)
+ ldt $f2, 80(a0)
+ ldt $f3, 88(a0)
+ ldt $f4, 96(a0)
+ ldt $f5, 104(a0)
+ ldt $f6, 112(a0)
+ ldt $f7, 120(a0)
+ ldt $f8, 128(a0)
+ ldt $f9, 136(a0)
+ /* We're bound to get a mispredict here, but at least give us
+ a chance to get the return stack back in sync... */
+ ret zero,(ra),1
+
+ .size longjmp,.-longjmp
+ .end longjmp
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/syscall.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/syscall.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,26 @@
+#
+# arch/alpha/syscall.S
+#
+
+#include <machine/asm.h>
+
+ .text
+ .align 3
+ .type __syscall_common, at function
+ .ent __syscall_common, 0
+ .globl __syscall_common
+__syscall_common:
+ .frame sp,0,ra,0
+ callsys
+ beq a3, 1f
+ br pv, 2f # pv <- pc
+2:
+ ldgp gp, 0(pv)
+ lda a1, errno
+ lda v0, -1(zero)
+ stl a3, 0(a1)
+1:
+ ret zero,(ra),1
+
+ .size __syscall_common,.-__syscall_common
+ .end __syscall_common
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/sysdual.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/sysdual.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,33 @@
+#
+# arch/alpha/sysdual.S
+#
+
+#
+# Some system calls have an alternate return value in r20 (a4).
+# This system call stub is for system calls where that is
+# the "real" return value.
+#
+
+#include <machine/asm.h>
+
+ .text
+ .align 3
+ .type __syscall_dual1, at function
+ .ent __syscall_dual1, 0
+ .globl __syscall_dual1
+__syscall_dual1:
+ .frame sp,0,ra,0
+ callsys
+ mov v0, a4
+ beq a3, 1f
+ br pv, 2f # pv <- pc
+2:
+ ldgp gp, 0(pv)
+ lda a1, errno
+ lda v0, -1(zero)
+ stl a3, 0(a1)
+1:
+ ret zero,(ra),1
+
+ .size __syscall_dual1,.-__syscall_dual1
+ .end __syscall_dual1
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/alpha/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,37 @@
+# -*- perl -*-
+#
+# arch/alpha/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+# On Alpha, most system calls follow the standard convention, with the
+# system call number in r0 (v0), return an error value in r19 (a3) as
+# well as the return value in r0 (v0).
+#
+# A few system calls are dual-return with the second return value in
+# r20 (a4).
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ $stype = $stype || 'common';
+ $stype = 'common' if ( $stype eq 'dual0' );
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "#include <machine/asm.h>\n";
+ print OUT "\n";
+ print OUT "\t.text\n";
+ print OUT "\t.type ${fname},\@function\n";
+ print OUT "\t.ent\t${fname}, 0\n"; # What is this?
+ print OUT "\t.globl ${fname}\n";
+ print OUT "${fname}:\n";
+ print OUT "\tlda\tv0, __NR_${sname}(zero)\n";
+ print OUT "\tbr __syscall_${stype}\n";
+ print OUT "\t.size\t${fname},.-${fname}\n";
+ print OUT "\t.end\t${fname}\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,26 @@
+# -*- makefile -*-
+#
+# arch/arm/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+THUMB = n
+CPU_ARCH := armv4
+CPU_TUNE := strongarm
+
+OPTFLAGS = -Os -fomit-frame-pointer -march=$(CPU_ARCH) -mtune=$(CPU_TUNE)
+BITSIZE = 32
+
+ifeq ($(THUMB),y)
+CPU_ARCH := $(CPU_ARCH)t
+OPTFLAGS += -mthumb
+LDFLAGS += --thumb-entry _start
+endif
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+SHAREDFLAGS = -Ttext 0x01000200
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,43 @@
+# -*- makefile -*-
+#
+# arch/arm/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = \
+ libgcc/__divsi3.o \
+ libgcc/__modsi3.o \
+ libgcc/__udivsi3.o \
+ libgcc/__umodsi3.o \
+ libgcc/__udivmodsi4.o \
+ libgcc/__divdi3.o \
+ libgcc/__moddi3.o \
+ libgcc/__udivdi3.o \
+ libgcc/__umoddi3.o \
+ libgcc/__udivmoddi4.o \
+ arch/arm/syscall.o
+
+ifeq ($(THUMB),y)
+ARCHOBJS += arch/arm/setjmp-thumb.o
+LIBGCC =
+else
+ARCHOBJS += arch/arm/setjmp-arm.o
+endif
+
+arch/arm/sysstubs.a: arch/arm/sysstubs.pl
+ mkdir -p arch/arm/sysstubs
+ $(PERL) $< arch/arm/sysstubs
+ $(MAKE) $(patsubst %.S,%.o,$(wildcard arch/arm/sysstubs/*.S))
+ -rm -f $@
+ $(AR) cq $@ arch/arm/sysstubs/*.o
+ $(RANLIB) $@
+
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
+archclean:
+ -rm -rf arch/arm/sysstubs
+ -rm -f arch/arm/sysstubs.a
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+#
+# arch/arm/crt0.S
+#
+# void _start(void)
+# {
+# __libc_init(elf_structure, atexit_ptr);
+# }
+#
+
+ .text
+ .align 4
+ .type _start,#function
+ .globl _start
+
+#ifdef __thumb__
+ .thumb_func
+#endif
+
+_start: mov r0, sp
+ mov r1, #0
+ bl __libc_init
+
+ .size _start,.-_start
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/setjmp-arm.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/setjmp-arm.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,39 @@
+#
+# arch/arm/setjmp.S
+#
+# setjmp/longjmp for the ARM architecture
+#
+
+#
+# The jmp_buf is assumed to contain the following, in order:
+# r4
+# r5
+# r6
+# r7
+# r8
+# r9
+# r10
+# fp
+# sp
+# lr
+#
+
+ .text
+ .align 4
+ .globl setjmp
+ .type setjmp, #function
+setjmp:
+ stmia r0, {r4, r5, r6, r7, r8, r9, r10, fp, sp, lr}
+ mov r0, #0
+ mov pc, lr
+ .size setjmp,.-setjmp
+
+ .text
+ .align 4
+ .globl longjmp
+ .type longjmp, #function
+longjmp:
+ ldmia r0, {r4, r5, r6, r7, r8, r9, r10, fp, sp, lr}
+ mov r0, r1
+ mov pc, lr
+ .size longjmp,.-longjmp
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/setjmp-thumb.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/setjmp-thumb.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,58 @@
+#
+# arch/arm/setjmp-thumb.S
+#
+# setjmp/longjmp for the ARM/thumb architecture
+#
+
+#
+# The jmp_buf is assumed to contain the following, in order:
+# lr
+# r4
+# r5
+# r6
+# r7
+# r8
+# r9
+# r10
+# fp
+# sp
+#
+
+ .text
+ .align 4
+ .globl setjmp
+ .type setjmp, #function
+ .thumb_func
+setjmp:
+ mov r3, lr
+ stmia r0!, {r3, r4, r5, r6, r7}
+ mov r3, r8
+ mov r4, r9
+ mov r5, r10
+ mov r6, fp
+ mov r7, sp
+ stmia r0!, {r3, r4, r5, r6, r7}
+ mov r0, #0
+ mov pc, lr
+ .size setjmp,.-setjmp
+
+ .text
+ .align 4
+ .globl longjmp
+ .type longjmp, #function
+ .thumb_func
+longjmp:
+ mov r2, r0
+ add r0, #5*4
+ ldmia r0!, {r3, r4, r5, r6, r7}
+ mov r8, r3
+ mov r9, r4
+ mov r10, r5
+ mov fp, r6
+ mov sp, r7
+ ldmia r2!, {r3, r4, r5, r6, r7}
+ mov r0, r1
+ bne 1f
+ mov r0, #1
+1: mov pc, r3
+ .size longjmp,.-longjmp
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/syscall.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/syscall.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,50 @@
+/*
+ * arch/arm/syscall.S
+ *
+ * System call common handling
+ */
+
+ .type __syscall_common,#function
+ .globl __syscall_common
+#ifndef __thumb__
+ /* ARM version - this is executed after the swi */
+
+ .align 4
+__syscall_common:
+ cmn r0, #4096
+ rsbcs r2, r0, #0
+ ldrcs r3, 1f
+ mvncs r0, #0
+ strcs r2, [r3]
+ ldmfd sp!,{r4,r5,pc}
+
+ .align 4
+1:
+ .word errno
+
+#else
+ /* Thumb version - must still load r4 and r5 and run swi */
+
+ .thumb_func
+ .align 2
+__syscall_common:
+ ldr r4, [sp #12]
+ ldr r5, [sp #16]
+ swi 0
+ ldr r1, 2f
+ cmp r0, r1
+ bcc 1f
+ ldr r1, 3f
+ neg r2, r0
+ mvn r0, #0
+ str r2, [r1]
+1:
+ pop {r4,r5,r7,pc}
+
+ .align 4
+2:
+ .word #-4095
+3:
+ .word errno
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/arm/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,44 @@
+# -*- perl -*-
+#
+# arch/arm/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+
+ print OUT "\t.text\n";
+ print OUT "\t.type\t${fname}, #function\n";
+ print OUT "\t.globl ${fname}\n";
+ print OUT "\t.align\t4\n";
+
+ print OUT "#ifndef __thumb__\n";
+
+ # ARM version first
+ print OUT "${fname}:\n";
+ print OUT "\tstmfd\tsp!,{r4,r5,lr}\n";
+ print OUT "\tldr\tr4,[sp,#12]\n";
+ print OUT "\tldr\tr5,[sp,#16]\n";
+ print OUT "\tswi\t# __NR_${sname}\n";
+ print OUT "\tb\t__syscall_common\n";
+
+ print OUT "#else\n";
+
+ # Thumb version
+ print OUT "\t.thumb_func\n";
+ print OUT "${fname}:\n";
+ print OUT "\tpush\t{r4,r5,r7,pc}\n";
+ print OUT "\tmov\tr7, # __NR_${sname}\n";
+ print OUT "\tb\t__syscall_common\n";
+
+ print OUT "#endif\n";
+
+ print OUT "\t.size\t__syscall${i},.-__syscall${i}\n";
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,26 @@
+# -*- makefile -*-
+#
+# arch/cris/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 32
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# 224 MB - normal binaries start at 0
+# (lib?)gcc on cris seems to insist on producing .init and .fini sections
+SHAREDFLAGS = --section-start .init=0x0e000100
+
+# The CRIS compiler needs an -iprefix to find libgcc includes when
+# nostdinc is used. It also needs -mlinux to compile linux applications.
+INCLUDE_PREFIX = $(shell $(CC) -print-libgcc-file-name | sed -e s/libgcc.a//)
+ARCHREQFLAGS = -iprefix $(INCLUDE_PREFIX) -mlinux
+
+# Special flags needed for linking
+LDFLAGS += -mcrislinux
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,33 @@
+# -*- makefile -*-
+#
+# arch/cris/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = \
+ arch/$(ARCH)/__Umod.o \
+ arch/$(ARCH)/__Udiv.o \
+ arch/$(ARCH)/__Mod.o \
+ arch/$(ARCH)/__Div.o \
+ arch/$(ARCH)/__negdi2.o \
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/syscall.o \
+ libgcc/__divdi3.o \
+ libgcc/__moddi3.o \
+ libgcc/__udivdi3.o \
+ libgcc/__umoddi3.o \
+ libgcc/__udivmoddi4.o
+
+arch/$(ARCH)/__Umod.o: arch/$(ARCH)/divide.c
+ $(CC) $(CFLAGS) -DSIGNED=0 -DREM=1 -DBITS=32 -DNAME=__Umod -c -o $@ $<
+arch/$(ARCH)/__Udiv.o: arch/$(ARCH)/divide.c
+ $(CC) $(CFLAGS) -DSIGNED=0 -DREM=0 -DBITS=32 -DNAME=__Udiv -c -o $@ $<
+arch/$(ARCH)/__Mod.o: arch/$(ARCH)/divide.c
+ $(CC) $(CFLAGS) -DSIGNED=1 -DREM=1 -DBITS=32 -DNAME=__Mod -c -o $@ $<
+arch/$(ARCH)/__Div.o: arch/$(ARCH)/divide.c
+ $(CC) $(CFLAGS) -DSIGNED=1 -DREM=0 -DBITS=32 -DNAME=__Div -c -o $@ $<
+
+archclean:
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/__negdi2.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/__negdi2.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+/*
+ * arch/cris/__negdi2.c
+ */
+
+/*
+ * In 2's complement arithmetric, -x == (~x + 1), so
+ * -{h,l} = (~{h,l} + {0,1)
+ * -{h,l} = {~h,~l} + {0,1}
+ * -{h,l} = {~h + cy, ~l + 1}
+ * ... where cy = (l == 0)
+ * -{h,l} = {~h + cy, -l}
+ */
+
+ .text
+ .balign 4
+ .type __negdi2, at function
+ .globl __negdi2
+__negdi2:
+ neg.d $r10,$r10
+ seq $r12
+ not $r11
+ ret
+ add.d $r12,$r11
+
+ .size __negdi2, .-__negdi2
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,28 @@
+#
+# arch/cris/crt0.S
+#
+# Does arch-specific initialization and invokes __libc_init
+# with the appropriate arguments.
+#
+# See __static_init.c or __shared_init.c for the expected
+# arguments.
+#
+
+ .text
+ .balign 4
+ .type _start, at function
+ .globl _start
+_start:
+ /* Save the address of the ELF argument array */
+ move.d $sp,$r10 /* Address of ELF arguments */
+
+ /* atexit() function (assume null) */
+ moveq 0,$r11
+
+ /* Set up a dummy stack frame to keep gcc from getting confused */
+ push $r11
+ push $r11
+ jump __libc_init
+
+ .size _start, .-_start
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/divide.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/divide.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,92 @@
+#include <stdint.h>
+#include <signal.h>
+
+#if BITS == 64
+typedef uint64_t unum;
+typedef int64_t snum;
+#else
+typedef uint32_t unum;
+typedef int32_t snum;
+#endif
+
+#ifdef SIGNED
+typedef snum xnum;
+#else
+typedef unum xnum;
+#endif
+
+#ifdef __cris__
+static inline unum __attribute__((const)) dstep(unum rs, unum rd) {
+ asm("dstep %1,%0" : "+r" (rd) : "r" (rs));
+ return rd;
+}
+
+static inline unum __attribute__((const)) lz(unum rs) {
+ unum rd;
+ asm("lz %1,%0" : "=r" (rd) : "r" (rs));
+ return rd;
+}
+
+#else
+/* For testing */
+static inline unum __attribute__ ((const)) dstep(unum rs, unum rd) {
+ rd <<= 1;
+ if ( rd >= rs )
+ rd -= rs;
+
+ return rd;
+}
+
+static inline unum __attribute__((const)) lz(unum rs) {
+ unum rd = 0;
+ while ( rs >= 0x7fffffff ) {
+ rd++;
+ rs <<= 1;
+ }
+ return rd;
+}
+
+#endif
+
+xnum NAME (unum num, unum den)
+{
+ unum quot = 0, qbit = 1;
+ int minus = 0;
+ xnum v;
+
+ if ( den == 0 ) {
+ raise(SIGFPE);
+ return 0; /* If signal ignored... */
+ }
+
+ if (den == 1) return (xnum)(REM ? 0 : num);
+
+#if SIGNED
+ if ( (snum)(num^den) < 0 )
+ minus = 1;
+ if ( (snum)num < 0 ) num = -num;
+ if ( (snum)den < 0 ) den = -den;
+#endif
+
+ den--;
+
+
+ /* Left-justify denominator and count shift */
+ while ( (snum)den >= 0 ) {
+ den <<= 1;
+ qbit <<= 1;
+ }
+
+ while ( qbit ) {
+ if ( den <= num ) {
+ num -= den;
+ quot += qbit;
+ }
+ den >>= 1;
+ qbit >>= 1;
+ }
+
+ v = (xnum)(REM ? num : quot);
+ if ( minus ) v = -v;
+ return v;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,37 @@
+#
+# arch/cris/setjmp.S
+#
+# setjmp/longjmp for the cris architecture
+#
+
+#
+# The jmp_buf is assumed to contain the following, in order:
+# $r8..$r0 (in that order)
+# $sp ($r14)
+# return address
+#
+
+ .text
+ .balign 4
+ .globl setjmp
+ .type setjmp, @function
+setjmp:
+ movem $r8,[$r10+] /* Save $r8..$r0 at $r10... */
+ move.d $sp,[$r10+]
+ move $srp,[$r10]
+ ret
+ moveq 0,$r10
+
+ .size setjmp,.-setjmp
+
+ .text
+ .balign 4
+ .globl longjmp
+ .type longjmp, @function
+longjmp:
+ movem [$r10+],$r8 /* Load $r8..$r0 from $r10... */
+ move.d [$r10+],$sp
+ jump [$r10]
+ move.d $r11,$r10
+
+ .size longjmp,.-longjmp
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/syscall.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/syscall.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,30 @@
+/*
+ * arch/cris/syscall.S
+ *
+ * On cris, r9 contains the syscall number (set by generated stub);
+ * r10..r13 contain arguments 0-3 per the standard calling convention,
+ * and arguments 4-5 are passed in $mof and $srp; however, we have
+ * to save $srp around the system call.
+ */
+
+ .section ".text","ax"
+ .balign 4
+ .globl __syscall_common
+ .type __syscall_common, at function
+__syscall_common:
+ push $srp
+ move [$sp+4],$mof
+ move [$sp+8],$srp
+ break 13
+
+ cmps.w -4096,$r10
+ blo 1f
+ neg.d $r10,$r11
+ move.d $r11,[errno]
+ moveq -1,$r10
+1:
+ pop $srp
+ ret
+ nop
+
+ .size __syscall_common,.-__syscall_common
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/cris/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+# -*- perl -*-
+#
+# arch/cris/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "\n";
+ print OUT "\t.text\n";
+ print OUT "\t.type\t${fname},\@function\n";
+ print OUT "\t.globl\t${fname}\n";
+ print OUT "\t.balign\t4\n";
+ print OUT "${fname}:\n";
+ print OUT "#if __NR_${sname} <= 31\n";
+ print OUT "\t moveq\t__NR_${sname}, \$r9\n";
+ print OUT "#else\n";
+ print OUT "\t move.d\t__NR_${sname}, \$r9\n";
+ print OUT "#endif\n";
+ print OUT "\tjump\t__syscall_common\n";
+ print OUT "\t.size ${fname},.-${fname}\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,31 @@
+# -*- makefile -*-
+#
+# arch/i386/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+# Enable this to compile with register parameters; only safe for
+# gcc > 3
+REGPARM_OPT := -mregparm=3 -DREGPARM=3
+
+gcc_major := $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1)
+
+OPTFLAGS = $(REGPARM) -march=i386 -Os -g
+
+ifeq ($(gcc_major),3)
+REGPARM := $(REGPARM_OPT)
+OPTFLAGS += -falign-functions=0 -falign-jumps=0 -falign-loops=0
+else
+OPTFLAGS += -malign-functions=0 -malign-jumps=0 -malign-loops=0
+endif
+
+BITSIZE = 32
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# 96 MB - normal binaries start at 128 MB
+SHAREDFLAGS = -Ttext 0x06000200
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,27 @@
+# -*- makefile -*-
+#
+# arch/i386/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = \
+ arch/$(ARCH)/exits.o \
+ arch/$(ARCH)/socketcall.o \
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/syscall.o \
+ arch/$(ARCH)/open.o \
+ arch/$(ARCH)/libgcc/__ashldi3.o \
+ arch/$(ARCH)/libgcc/__ashrdi3.o \
+ arch/$(ARCH)/libgcc/__lshrdi3.o \
+ arch/$(ARCH)/libgcc/__muldi3.o \
+ arch/$(ARCH)/libgcc/__negdi2.o \
+ libgcc/__divdi3.o \
+ libgcc/__moddi3.o \
+ libgcc/__udivdi3.o \
+ libgcc/__umoddi3.o \
+ libgcc/__udivmoddi4.o
+
+archclean:
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,32 @@
+#
+# arch/i386/crt0.S
+#
+# Does arch-specific initialization and invokes __libc_init
+# with the appropriate arguments.
+#
+# See __static_init.c or __shared_init.c for the expected
+# arguments.
+#
+
+ .text
+ .align 4
+ .type _start, at function
+ .globl _start
+_start:
+ # Save the address of the ELF argument array
+ movl %esp,%eax # Address of ELF arguments
+ # Set up a faux stack frame for the benefit of gdb
+ xorl %ebp,%ebp
+ push %ebp # Keep gdb from getting confused
+ push %ebp # Keep gdb from getting confused
+ # Push the arguments and called __libc_init()
+#ifndef REGPARM
+ push %edx # atexit() function
+ push %eax # ELF array
+#endif
+ call __libc_init
+ # If __libc_init returns, problem...
+ hlt
+
+ .size _start, .-_start
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/exits.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/exits.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,45 @@
+#
+# exit and _exit get included in *every* program, and gcc generates
+# horrible code for them. Yes, this only saves a few bytes, but
+# it does it in every program.
+#
+
+#include <asm/unistd.h>
+
+ .data
+ .align 4
+ .globl __exit_handler
+ .type __exit_handler, at object
+__exit_handler:
+ .long _exit
+ .size __exit_handler,4
+
+ .text
+ .align 4
+ .globl exit
+ .type exit, at function
+exit:
+ jmp *(__exit_handler)
+ .size exit,.-exit
+
+ /* No need to save any registers... we're exiting! */
+ .text
+ .align 4
+ .globl _exit
+ .type _exit, at function
+_exit:
+#ifdef REGPARM
+ movl %eax,%ebx
+#else
+ popl %ebx
+ popl %ebx
+#endif
+#if __NR_exit == 1
+ xorl %eax,%eax
+ incl %eax
+#else
+ movl $__NR_exit,%eax
+#endif
+ int $0x80
+ hlt
+ .size _exit,.-exit
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__ashldi3.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__ashldi3.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+/*
+ * arch/i386/libgcc/__ashldi3.S
+ *
+ * 64-bit shl
+ */
+ .text
+ .align 4
+ .globl __ashldi3
+ .type __ashldi3, at function
+__ashldi3:
+#ifndef REGPARM
+ movl 4(%esp),%eax
+ movl 8(%esp),%edx
+ movb 12(%esp),%cl
+#endif
+ cmpb $32,%cl
+ jae 1f
+
+ shldl %cl,%eax,%edx
+ shl %cl,%eax
+ ret
+
+1:
+ xorl %edx,%edx
+ shl %cl,%eax
+ xchgl %edx,%eax
+ ret
+
+ .size __ashldi3,.-__ashldi3
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__ashrdi3.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__ashrdi3.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+/*
+ * arch/i386/libgcc/__ashrdi3.S
+ *
+ * 64-bit sar
+ */
+ .text
+ .align 4
+ .globl __ashrdi3
+ .type __ashrdi3, at function
+__ashrdi3:
+#ifndef REGPARM
+ movl 4(%esp),%eax
+ movl 8(%esp),%edx
+ movb 12(%esp),%cl
+#endif
+ cmpb $32,%cl
+ jae 1f
+
+ shrdl %cl,%edx,%eax
+ sarl %cl,%edx
+ ret
+
+1:
+ sarl %cl,%edx
+ movl %edx,%eax
+ cdq
+ ret
+
+ .size __ashrdi3,.-__ashrdi3
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__lshrdi3.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__lshrdi3.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+/*
+ * arch/i386/libgcc/__lshrdi3.S
+ *
+ * 64-bit shr
+ */
+ .text
+ .align 4
+ .globl __lshrdi3
+ .type __lshrdi3, at function
+__lshrdi3:
+#ifndef REGPARM
+ movl 4(%esp),%eax
+ movl 8(%esp),%edx
+ movb 12(%esp),%cl
+#endif
+ cmpb $32,%cl
+ jae 1f
+
+ shrdl %cl,%edx,%eax
+ shrl %cl,%edx
+ ret
+
+1:
+ shrl %cl,%edx
+ xorl %eax,%eax
+ xchgl %edx,%eax
+ ret
+
+ .size __lshrdi3,.-__lshrdi3
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__muldi3.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__muldi3.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,34 @@
+/*
+ * arch/i386/libgcc/__muldi3.S
+ *
+ * 64*64 = 64 bit unsigned multiplication
+ */
+
+ .text
+ .align 4
+ .globl __muldi3
+ .type __muldi3, at function
+__muldi3:
+ push %esi
+#ifndef REGPARM
+ movl 8(%esp),%eax
+ movl %eax,%esi
+ movl 16(%esp),%ecx
+ mull %ecx
+ imull 12(%esp),%ecx
+ imull 20(%esp),%esi
+ addl %ecx,%edx
+ addl %esi,%edx
+#else
+ movl %eax,%esi
+ push %edx
+ mull %ecx
+ imull 8(%esp),%esi
+ addl %esi,%edx
+ pop %esi
+ imull %esi,%ecx
+ addl %ecx,%edx
+#endif
+ pop %esi
+ ret
+ .size __muldi3,.-__muldi3
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__negdi2.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/libgcc/__negdi2.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,21 @@
+/*
+ * arch/i386/libgcc/__negdi2.S
+ *
+ * 64-bit negation
+ */
+
+ .text
+ .align 4
+ .globl __negdi2
+ .type __negdi2, at function
+__negdi2:
+#ifndef REGPARM
+ movl 4(%esp),%eax
+ movl 8(%esp),%edx
+#endif
+ negl %edx
+ negl %eax
+ sbbl $0,%edx
+ ret
+
+ .size __negdi2,.-__negdi2
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/open.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/open.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+/*
+ * arch/i386/open.S
+ *
+ * Handle the open() system call - oddball due to the varadic
+ * prototype, which forces the use of the cdecl calling convention,
+ * and the need for O_LARGEFILE.
+ */
+
+#include <asm/unistd.h>
+
+/* <asm/fcntl.h>, despite the name, isn't assembly-safe */
+#define O_LARGEFILE 0100000
+
+ .globl open
+ .type open, at function
+
+open:
+#ifdef REGPARM
+ movl 4(%esp),%eax
+ movl 8(%esp),%edx
+ movl 12(%esp),%ecx
+ orl $O_LARGEFILE,%edx
+#else
+ orl $O_LARGEFILE,8(%esp)
+#endif
+ pushl $__NR_open
+ jmp __syscall_common
+
+ .size open,.-open
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,58 @@
+#
+# arch/i386/setjmp.S
+#
+# setjmp/longjmp for the i386 architecture
+#
+
+#
+# The jmp_buf is assumed to contain the following, in order:
+# %ebx
+# %esp
+# %ebp
+# %esi
+# %edi
+# <return address>
+#
+
+ .text
+ .align 4
+ .globl setjmp
+ .type setjmp, @function
+setjmp:
+#ifdef REGPARM
+ movl %eax,%edx
+#else
+ movl 4(%esp),%edx
+#endif
+ popl %ecx # Return address, and adjust the stack
+ xorl %eax,%eax # Return value
+ movl %ebx,(%edx)
+ movl %esp,4(%edx) # Post-return %esp!
+ pushl %ecx # Make the call/return stack happy
+ movl %ebp,8(%edx)
+ movl %esi,12(%edx)
+ movl %edi,16(%edx)
+ movl %ecx,20(%edx) # Return address
+ ret
+
+ .size setjmp,.-setjmp
+
+ .text
+ .align 4
+ .globl longjmp
+ .type longjmp, @function
+longjmp:
+#ifdef REGPARM
+ xchgl %eax,%edx
+#else
+ movl 4(%esp),%edx # jmp_ptr address
+ movl 8(%esp),%eax # Return value
+#endif
+ movl (%edx),%ebx
+ movl 4(%edx),%esp
+ movl 8(%edx),%ebp
+ movl 12(%edx),%esi
+ movl 16(%edx),%edi
+ jmp *20(%edx)
+
+ .size longjmp,.-longjmp
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/socketcall.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/socketcall.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,42 @@
+#
+# socketcall.S
+#
+# On i386, the main (only?) user of socketcall(2), the memory array
+# socketcall(2) needs is conveniently already assembled for us on
+# the stack. Capitalize on that to make a common socketcall stub.
+#
+
+#include <asm/unistd.h>
+
+#ifdef __i386__
+
+ .text
+ .align 4
+ .globl __socketcall_common
+ .type __socketcall_common, @function
+
+__socketcall_common:
+ pushl %ebx
+
+ movzbl %al,%ebx # The socketcall number is passed in in %al
+ leal 8(%esp),%ecx # Argument pointer
+ movl $__NR_socketcall,%eax
+ int $0x80
+
+ cmpl $-4096,%eax # Error return?
+
+ popl %ebx
+
+ jb 1f
+
+ negl %eax
+ movl %eax,errno
+ orl $-1,%eax # Return -1
+1:
+ ret
+
+ .size __socketcall_common,.-__socketcall_common
+
+#endif
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/syscall.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/syscall.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,60 @@
+/*
+ * arch/i386/syscall.S
+ *
+ * Common tail-handling code for system calls. Because of __syscalldecl
+ * we are using the stack even on if we are compiling with regparm.
+ *
+ * The arguments are on the stack; the system call number in %eax.
+ */
+
+#define ARG(n) (4*n+20)(%esp)
+
+ .text
+ .align 4
+ .globl __syscall_common
+ .type __syscall_common, at function
+__syscall_common:
+#ifdef REGPARM
+ xchgl %ebx,(%esp)
+#else
+ popl %eax
+ pushl %ebx
+#endif
+ pushl %esi
+ pushl %edi
+ pushl %ebp
+
+#ifdef REGPARM
+ xchgl %eax,%ebx
+ xchgl %ecx,%edx
+ movl ARG(0),%esi
+ movl ARG(1),%edi
+ movl ARG(2),%ebp
+#else
+ movl ARG(0),%ebx # Syscall arguments
+ movl ARG(1),%ecx
+ movl ARG(2),%edx
+ movl ARG(3),%esi
+ movl ARG(4),%edi
+ movl ARG(5),%ebp
+#endif
+ int $0x80
+
+ cmpl $-4096,%eax
+
+ popl %ebp
+ popl %edi
+ popl %esi
+ popl %ebx
+
+ jb 1f
+
+ # Error return, must set errno
+ negl %eax
+ movl %eax,errno
+ orl $-1,%eax # Return -1
+
+1:
+ ret
+
+ .size __syscall_common,.-__syscall_common
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/i386/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,32 @@
+# -*- perl -*-
+#
+# arch/i386/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "\n";
+ print OUT "\t.type ${fname},\@function\n";
+ print OUT "\t.globl ${fname}\n";
+ print OUT "${fname}:\n";
+
+ if ( $stype eq 'varadic' ) {
+ print OUT "#ifdef REGPARM\n";
+ print OUT "\tmovl 4(%esp),%eax\n";
+ print OUT "\tmovl 8(%esp),%edx\n";
+ print OUT "\tmovl 12(%esp),%ecx\n";
+ print OUT "#endif\n";
+ }
+
+ print OUT "\tpushl \$__NR_${sname}\n";
+ print OUT "\tjmp __syscall_common\n";
+ print OUT "\t.size ${fname},.-${fname}\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+# -*- makefile -*-
+#
+# arch/ia64/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 64
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,26 @@
+# -*- makefile -*-
+#
+# arch/ia64/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = \
+ arch/$(ARCH)/vfork.o \
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/pipe.o \
+ arch/$(ARCH)/syscall.o \
+ libgcc/__divdi3.o \
+ libgcc/__divsi3.o \
+ libgcc/__udivdi3.o \
+ libgcc/__udivsi3.o \
+ libgcc/__umodsi3.o \
+ libgcc/__umoddi3.o \
+ libgcc/__udivmodsi4.o \
+ libgcc/__udivmoddi4.o
+
+ARCHSOOBJS = $(patsubst %o,%.lo,%(ARCHOBJS))
+
+archclean:
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,27 @@
+
+#include <asm/fpu.h>
+
+ .align 32
+ .global _start
+
+ .proc _start
+ .type _start, at function
+_start:
+ .prologue
+ .save rp, r0
+
+ alloc r2 = ar.pfs,0,0,2,0
+ movl r3 = FPSR_DEFAULT
+ ;;
+ adds out0= 16,sp /* argc pointer */
+ movl gp = @gprel(0f)
+0: mov r9 = ip
+ ;;
+ sub gp = r9, gp /* back-compute gp value */
+
+ .body
+ br.call.sptk.few rp = __libc_init
+ ;;
+ break 0 /* break miserably if we ever return */
+
+ .endp _start
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/pipe.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/pipe.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,42 @@
+/*
+ * pipe.c
+ */
+
+#include <sys/syscall.h>
+#include <klibc/archsys.h>
+
+#define ASM_CLOBBERS ,"out2", "out3", "out4", "out5", "out6", "out7", \
+ /* Non-stacked integer registers, minus r8, r9, r10, r15. */ \
+ "r2", "r3", "r11", "r12", "r13", "r14", "r16", "r17", "r18", \
+ "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26", "r27", \
+ "r28", "r29", "r30", "r31", \
+ /* Predicate registers. */ \
+ "p6", "p7", "p8", "p9", "p10", "p11", "p12", "p13", "p14", "p15", \
+ /* Non-rotating fp registers. */ \
+ "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \
+ /* Branch registers. */ \
+ "b6", "b7"
+
+int pipe(int *filedes)
+{
+ register long _r8 asm("r8");
+ register long _r9 asm("r9");
+ register long _r10 asm("r10");
+ register long _r15 asm("r15") = __NR_pipe;
+ register long _out0 asm ("out0") = (long)filedes;
+ long _retval;
+ __asm __volatile (__IA64_BREAK
+ : "=r" (_r8), "=r" (_r10), "=r" (_r15),
+ "=r" (_out0), "=r" (_r9)
+ : "2" (_r15), "3" (_out0)
+ : "memory" ASM_CLOBBERS);
+ if (_r10 == -1) {
+ errno = _r8;
+ _retval = -1;
+ } else {
+ filedes[0] = _r8;
+ filedes[1] = _r9;
+ _retval = 0;
+ }
+ return _retval;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,341 @@
+/*
+ * IA-64 specific setjmp/longjmp routines
+ *
+ * Inspired by setjmp.s from the FreeBSD kernel.
+ */
+
+#define J_UNAT 0
+#define J_NATS 0x8
+#define J_PFS 0x10
+#define J_BSP 0x18
+#define J_RNAT 0x20
+#define J_PREDS 0x28
+#define J_LC 0x30
+#define J_R4 0x38
+#define J_R5 0x40
+#define J_R6 0x48
+#define J_R7 0x50
+#define J_SP 0x58
+#define J_F2 0x60
+#define J_F3 0x70
+#define J_F4 0x80
+#define J_F5 0x90
+#define J_F16 0xa0
+#define J_F17 0xb0
+#define J_F18 0xc0
+#define J_F19 0xd0
+#define J_F20 0xe0
+#define J_F21 0xf0
+#define J_F22 0x100
+#define J_F23 0x110
+#define J_F24 0x120
+#define J_F25 0x130
+#define J_F26 0x140
+#define J_F27 0x150
+#define J_F28 0x160
+#define J_F29 0x170
+#define J_F30 0x180
+#define J_F31 0x190
+#define J_FPSR 0x1a0
+#define J_B0 0x1a8
+#define J_B1 0x1b0
+#define J_B2 0x1b8
+#define J_B3 0x1c0
+#define J_B4 0x1c8
+#define J_B5 0x1d0
+#define J_SIGMASK 0x1d8
+#define J_SIGSET 0x1e0
+#define J_GP 0x1f0
+
+// int setjmp(struct jmp_buffer *)
+//
+// Setup a non-local goto.
+//
+// Description:
+//
+// SetJump stores the current register set in the area pointed to
+// by "save". It returns zero. Subsequent calls to "LongJump" will
+// restore the registers and return non-zero to the same location.
+//
+// On entry, r32 contains the pointer to the jmp_buffer
+//
+ .align 32
+ .global setjmp
+setjmp:
+ //
+ // Make sure buffer is aligned at 16byte boundary
+ //
+ add r10 = -0x10,r0 ;; // mask the lower 4 bits
+ and r32 = r32, r10;;
+ add r32 = 0x10, r32;; // move to next 16 byte boundary
+
+ add r10 = J_PREDS, r32 // skip Unats & pfs save area
+ add r11 = J_BSP, r32
+ //
+ // save immediate context
+ //
+ mov r2 = ar.bsp // save backing store pointer
+ mov r3 = pr // save predicates
+ flushrs
+ ;;
+ //
+ // save user Unat register
+ //
+ mov r16 = ar.lc // save loop count register
+ mov r14 = ar.unat // save user Unat register
+
+ st8 [r10] = r3, J_LC-J_PREDS
+ st8 [r11] = r2, J_R4-J_BSP
+ ;;
+ st8 [r10] = r16, J_R5-J_LC
+ st8 [r32] = r14, J_NATS // Note: Unat at the
+ // beginning of the save area
+ mov r15 = ar.pfs
+ ;;
+ //
+ // save preserved general registers & NaT's
+ //
+ st8.spill [r11] = r4, J_R6-J_R4
+ ;;
+ st8.spill [r10] = r5, J_R7-J_R5
+ ;;
+ st8.spill [r11] = r6, J_SP-J_R6
+ ;;
+ st8.spill [r10] = r7, J_F3-J_R7
+ ;;
+ st8.spill [r11] = sp, J_F2-J_SP
+ ;;
+ //
+ // save spilled Unat and pfs registers
+ //
+ mov r2 = ar.unat // save Unat register after spill
+ ;;
+ st8 [r32] = r2, J_PFS-J_NATS // save unat for spilled regs
+ ;;
+ st8 [r32] = r15 // save pfs
+ //
+ // save floating registers
+ //
+ stf.spill [r11] = f2, J_F4-J_F2
+ stf.spill [r10] = f3, J_F5-J_F3
+ ;;
+ stf.spill [r11] = f4, J_F16-J_F4
+ stf.spill [r10] = f5, J_F17-J_F5
+ ;;
+ stf.spill [r11] = f16, J_F18-J_F16
+ stf.spill [r10] = f17, J_F19-J_F17
+ ;;
+ stf.spill [r11] = f18, J_F20-J_F18
+ stf.spill [r10] = f19, J_F21-J_F19
+ ;;
+ stf.spill [r11] = f20, J_F22-J_F20
+ stf.spill [r10] = f21, J_F23-J_F21
+ ;;
+ stf.spill [r11] = f22, J_F24-J_F22
+ stf.spill [r10] = f23, J_F25-J_F23
+ ;;
+ stf.spill [r11] = f24, J_F26-J_F24
+ stf.spill [r10] = f25, J_F27-J_F25
+ ;;
+ stf.spill [r11] = f26, J_F28-J_F26
+ stf.spill [r10] = f27, J_F29-J_F27
+ ;;
+ stf.spill [r11] = f28, J_F30-J_F28
+ stf.spill [r10] = f29, J_F31-J_F29
+ ;;
+ stf.spill [r11] = f30, J_FPSR-J_F30
+ stf.spill [r10] = f31, J_B0-J_F31 // size of f31 + fpsr
+ //
+ // save FPSR register & branch registers
+ //
+ mov r2 = ar.fpsr // save fpsr register
+ mov r3 = b0
+ ;;
+ st8 [r11] = r2, J_B1-J_FPSR
+ st8 [r10] = r3, J_B2-J_B0
+ mov r2 = b1
+ mov r3 = b2
+ ;;
+ st8 [r11] = r2, J_B3-J_B1
+ st8 [r10] = r3, J_B4-J_B2
+ mov r2 = b3
+ mov r3 = b4
+ ;;
+ st8 [r11] = r2, J_B5-J_B3
+ st8 [r10] = r3
+ mov r2 = b5
+ ;;
+ st8 [r11] = r2
+ ;;
+ //
+ // return
+ //
+ mov r8 = r0 // return 0 from setjmp
+ mov ar.unat = r14 // restore unat
+ br.ret.sptk b0
+ .endp setjmp
+
+//
+// void longjmp(struct jmp_buffer *, int val)
+//
+// Perform a non-local goto.
+//
+// Description:
+//
+// LongJump initializes the register set to the values saved by a
+// previous 'SetJump' and jumps to the return location saved by that
+// 'SetJump'. This has the effect of unwinding the stack and returning
+// for a second time to the 'SetJump'.
+//
+
+ .align 32
+ .global longjmp
+longjmp:
+ //
+ // Make sure buffer is aligned at 16byte boundary
+ //
+ add r10 = -0x10,r0 ;; // mask the lower 4 bits
+ and r32 = r32, r10;;
+ add r32 = 0x10, r32;; // move to next 16 byte boundary
+
+ //
+ // caching the return value as we do invala in the end
+ //
+ mov r8 = r33 // return value
+
+ //
+ // get immediate context
+ //
+ mov r14 = ar.rsc // get user RSC conf
+ add r10 = J_PFS, r32 // get address of pfs
+ add r11 = J_NATS, r32
+ ;;
+ ld8 r15 = [r10], J_BSP-J_PFS // get pfs
+ ld8 r2 = [r11], J_LC-J_NATS // get unat for spilled regs
+ ;;
+ mov ar.unat = r2
+ ;;
+ ld8 r16 = [r10], J_PREDS-J_BSP // get backing store pointer
+ mov ar.rsc = r0 // put RSE in enforced lazy
+ mov ar.pfs = r15
+ ;;
+
+ //
+ // while returning from longjmp the BSPSTORE and BSP needs to be
+ // same and discard all the registers allocated after we did
+ // setjmp. Also, we need to generate the RNAT register since we
+ // did not flushed the RSE on setjmp.
+ //
+ mov r17 = ar.bspstore // get current BSPSTORE
+ ;;
+ cmp.ltu p6,p7 = r17, r16 // is it less than BSP of
+(p6) br.spnt.few .flush_rse
+ mov r19 = ar.rnat // get current RNAT
+ ;;
+ loadrs // invalidate dirty regs
+ br.sptk.many .restore_rnat // restore RNAT
+
+.flush_rse:
+ flushrs
+ ;;
+ mov r19 = ar.rnat // get current RNAT
+ mov r17 = r16 // current BSPSTORE
+ ;;
+.restore_rnat:
+ //
+ // check if RNAT is saved between saved BSP and curr BSPSTORE
+ //
+ mov r18 = 0x3f
+ ;;
+ dep r18 = r18,r16,3,6 // get RNAT address
+ ;;
+ cmp.ltu p8,p9 = r18, r17 // RNAT saved on RSE
+ ;;
+(p8) ld8 r19 = [r18] // get RNAT from RSE
+ ;;
+ mov ar.bspstore = r16 // set new BSPSTORE
+ ;;
+ mov ar.rnat = r19 // restore RNAT
+ mov ar.rsc = r14 // restore RSC conf
+
+
+ ld8 r3 = [r11], J_R4-J_LC // get lc register
+ ld8 r2 = [r10], J_R5-J_PREDS // get predicates
+ ;;
+ mov pr = r2, -1
+ mov ar.lc = r3
+ //
+ // restore preserved general registers & NaT's
+ //
+ ld8.fill r4 = [r11], J_R6-J_R4
+ ;;
+ ld8.fill r5 = [r10], J_R7-J_R5
+ ld8.fill r6 = [r11], J_SP-J_R6
+ ;;
+ ld8.fill r7 = [r10], J_F2-J_R7
+ ld8.fill sp = [r11], J_F3-J_SP
+ ;;
+ //
+ // restore floating registers
+ //
+ ldf.fill f2 = [r10], J_F4-J_F2
+ ldf.fill f3 = [r11], J_F5-J_F3
+ ;;
+ ldf.fill f4 = [r10], J_F16-J_F4
+ ldf.fill f5 = [r11], J_F17-J_F5
+ ;;
+ ldf.fill f16 = [r10], J_F18-J_F16
+ ldf.fill f17 = [r11], J_F19-J_F17
+ ;;
+ ldf.fill f18 = [r10], J_F20-J_F18
+ ldf.fill f19 = [r11], J_F21-J_F19
+ ;;
+ ldf.fill f20 = [r10], J_F22-J_F20
+ ldf.fill f21 = [r11], J_F23-J_F21
+ ;;
+ ldf.fill f22 = [r10], J_F24-J_F22
+ ldf.fill f23 = [r11], J_F25-J_F23
+ ;;
+ ldf.fill f24 = [r10], J_F26-J_F24
+ ldf.fill f25 = [r11], J_F27-J_F25
+ ;;
+ ldf.fill f26 = [r10], J_F28-J_F26
+ ldf.fill f27 = [r11], J_F29-J_F27
+ ;;
+ ldf.fill f28 = [r10], J_F30-J_F28
+ ldf.fill f29 = [r11], J_F31-J_F29
+ ;;
+ ldf.fill f30 = [r10], J_FPSR-J_F30
+ ldf.fill f31 = [r11], J_B0-J_F31 ;;
+
+ //
+ // restore branch registers and fpsr
+ //
+ ld8 r16 = [r10], J_B1-J_FPSR // get fpsr
+ ld8 r17 = [r11], J_B2-J_B0 // get return pointer
+ ;;
+ mov ar.fpsr = r16
+ mov b0 = r17
+ ld8 r2 = [r10], J_B3-J_B1
+ ld8 r3 = [r11], J_B4-J_B2
+ ;;
+ mov b1 = r2
+ mov b2 = r3
+ ld8 r2 = [r10], J_B5-J_B3
+ ld8 r3 = [r11]
+ ;;
+ mov b3 = r2
+ mov b4 = r3
+ ld8 r2 = [r10]
+ ld8 r21 = [r32] // get user unat
+ ;;
+ mov b5 = r2
+ mov ar.unat = r21
+
+ //
+ // invalidate ALAT
+ //
+ invala ;;
+
+ br.ret.sptk b0
+ .endp longjmp
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/syscall.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/syscall.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,20 @@
+#
+# arch/ia64/syscall.S
+#
+
+#include <asm/unistd.h>
+
+ .text
+ .align 32
+ .proc __syscall_error
+ .globl __syscall_error
+__syscall_error:
+ addl r2 = @ltoffx(errno),gp
+ ;;
+ ld8.mov r3 = [r2],errno
+ ;;
+ st4 [r3] = r8
+ mov r8 = -1
+ br.ret.sptk.many b0
+ .size __syscall_error, .-__syscall_error
+ .endp __syscall_error
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+# -*- perl -*-
+#
+# arch/ia64/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "\n";
+ print OUT "\t.text\n";
+ print OUT "\t.align 32\n";
+ print OUT "\t.proc ${fname}\n";
+ print OUT "\t.globl ${fname}\n";
+ print OUT "${fname}:\n";
+ print OUT "\tmov\tr15 = __NR_${sname}\n";
+ print OUT "\tbreak __BREAK_SYSCALL\n";
+ print OUT "\tcmp.eq p6,p0 = -1,r10\n";
+ print OUT "(p6)\tbr.few __syscall_error\n";
+ print OUT "\tbr.ret.sptk.many b0\n";
+ print OUT "\t.size\t${fname},.-${fname}\n";
+ print OUT "\t.endp\t${fname}\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/vfork.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ia64/vfork.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,41 @@
+/*
+ * ia64 specific vfork syscall
+ *
+ * Written By: Martin Hicks <mort at wildopensource.com>
+ *
+ */
+
+/* This syscall is a special case of the clone syscall */
+#include <asm/unistd.h>
+#include <asm/signal.h>
+#include <klibc/archsys.h>
+
+/* These are redefined here because linux/sched.h isn't safe for
+ * inclusion in asm.
+ */
+#define CLONE_VM 0x00000100 /* set if VM shared between processes */
+#define CLONE_VFORK 0x00004000 /* set if parent wants the child to wake it up on exit */
+
+/* pid_t vfork(void) */
+/* Implemented as clone(CLONE_VFORK | CLONE_VM | SIGCHLD, 0) */
+
+ .proc vfork
+ .global vfork
+vfork:
+ alloc r2=ar.pfs,0,0,2,0
+ mov r15=__NR_clone
+ mov out0=CLONE_VM|CLONE_VFORK|SIGCHLD
+ mov out1=0
+ ;;
+ break 0x100000 // Do the syscall
+ ;;
+ addl r15=0,r1
+ cmp.eq p7,p6 = -1,r10
+ ;;
+ ld8 r14=[r15]
+ ;;
+(p7) st4 [r14]=r8
+ ;;
+(p7) mov r8=-1
+ br.ret.sptk.many b0
+ .endp
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/m68k/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/m68k/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+# -*- makefile -*-
+#
+# arch/m68k/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 32
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/m68k/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/m68k/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+# -*- makefile -*-
+#
+# arch/m68k/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+archclean:
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+# -*- makefile -*-
+#
+# arch/mips/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHREQFLAGS = -fno-pic -mno-abicalls -G 0
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 32
+
+# Extra linkflags when building the shared version of the library
+SHAREDFLAGS = -T arch/$(ARCH)/klibc.ld
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+# -*- makefile -*-
+#
+# arch/mips/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = \
+ arch/$(ARCH)/pipe.o \
+ arch/$(ARCH)/vfork.o \
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/syscall.o \
+ libgcc/__divdi3.o \
+ libgcc/__moddi3.o \
+ libgcc/__udivdi3.o \
+ libgcc/__umoddi3.o \
+ libgcc/__udivmoddi4.o
+
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
+
+archclean:
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+#
+# arch/mips/crt0.S
+#
+# Does arch-specific initialization and invokes __libc_init
+# with the appropriate arguments.
+#
+# See __static_init.c or __shared_init.c for the expected
+# arguments.
+#
+
+#include <machine/asm.h>
+
+NESTED(__start, 32, sp)
+ subu sp, 32
+ sw zero, 16(sp)
+
+ lui gp, %hi(_gp) # Initialize gp
+ addiu gp, gp, _gp
+
+ addiu a0, sp, 32 # Pointer to ELF entry structure
+ move a1, v0 # Kernel-provided atexit() pointer
+
+ jal __libc_init
+
+ END(__start)
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/klibc.ld
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/klibc.ld Fri Mar 4 08:05:19 2005
@@ -0,0 +1,217 @@
+/* Linker script for klibc.so, needed because of the the damned
+ GNU ld script headers problem */
+
+OUTPUT_FORMAT("elf32-tradbigmips", "elf32-tradbigmips",
+ "elf32-tradlittlemips")
+OUTPUT_ARCH(mips)
+ENTRY(__start)
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ /* This address needs to be reachable using normal inter-module
+ calls, and work on the memory models for this architecture */
+ /* 2 MB -- the normal starting point for text is 4 MB */
+ . = 0x00200400;
+ .interp : { *(.interp) }
+ .reginfo : { *(.reginfo) }
+ .dynamic : { *(.dynamic) }
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_d : { *(.gnu.version_d) }
+ .gnu.version_r : { *(.gnu.version_r) }
+ .rel.dyn :
+ {
+ *(.rel.init)
+ *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
+ *(.rel.fini)
+ *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
+ *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
+ *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
+ *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
+ *(.rel.ctors)
+ *(.rel.dtors)
+ *(.rel.got)
+ *(.rel.sdata .rel.sdata.* .rel.gnu.linkonce.s.*)
+ *(.rel.sbss .rel.sbss.* .rel.gnu.linkonce.sb.*)
+ *(.rel.sdata2 .rel.sdata2.* .rel.gnu.linkonce.s2.*)
+ *(.rel.sbss2 .rel.sbss2.* .rel.gnu.linkonce.sb2.*)
+ *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
+ }
+ .rela.dyn :
+ {
+ *(.rela.init)
+ *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
+ *(.rela.fini)
+ *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
+ *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
+ *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
+ *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
+ *(.rela.ctors)
+ *(.rela.dtors)
+ *(.rela.got)
+ *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
+ *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
+ *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
+ *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
+ *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
+ }
+ .rel.plt : { *(.rel.plt) }
+ .rela.plt : { *(.rela.plt) }
+ .init :
+ {
+ KEEP (*(.init))
+ } =0
+ .plt : { *(.plt) }
+ .text :
+ {
+ _ftext = . ;
+ *(.text .stub .text.* .gnu.linkonce.t.*)
+ /* .gnu.warning sections are handled specially by elf32.em. */
+ *(.gnu.warning)
+ *(.mips16.fn.*) *(.mips16.call.*)
+ } =0
+ .fini :
+ {
+ KEEP (*(.fini))
+ } =0
+ PROVIDE (__etext = .);
+ PROVIDE (_etext = .);
+ PROVIDE (etext = .);
+ .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
+ .rodata1 : { *(.rodata1) }
+ .sdata2 : { *(.sdata2 .sdata2.* .gnu.linkonce.s2.*) }
+ .sbss2 : { *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*) }
+ .eh_frame_hdr : { *(.eh_frame_hdr) }
+ /* Adjust the address for the data segment. We want to adjust up to
+ the same address within the page on the next page up. */
+ . = ALIGN(8192);
+ /* Ensure the __preinit_array_start label is properly aligned. We
+ could instead move the label definition inside the section, but
+ the linker would then create the section even if it turns out to
+ be empty, which isn't pretty. */
+ . = ALIGN(32 / 8);
+ PROVIDE (__preinit_array_start = .);
+ .preinit_array : { *(.preinit_array) }
+ PROVIDE (__preinit_array_end = .);
+ PROVIDE (__init_array_start = .);
+ .init_array : { *(.init_array) }
+ PROVIDE (__init_array_end = .);
+ PROVIDE (__fini_array_start = .);
+ .fini_array : { *(.fini_array) }
+ PROVIDE (__fini_array_end = .);
+ .data :
+ {
+ _fdata = . ;
+ *(.data .data.* .gnu.linkonce.d.*)
+ SORT(CONSTRUCTORS)
+ }
+ .data1 : { *(.data1) }
+ .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
+ .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
+ .eh_frame : { KEEP (*(.eh_frame)) }
+ .gcc_except_table : { *(.gcc_except_table) }
+ .ctors :
+ {
+ /* gcc uses crtbegin.o to find the start of
+ the constructors, so we make sure it is
+ first. Because this is a wildcard, it
+ doesn't matter if the user does not
+ actually link against crtbegin.o; the
+ linker won't look for a file to match a
+ wildcard. The wildcard also means that it
+ doesn't matter which directory crtbegin.o
+ is in. */
+ KEEP (*crtbegin*.o(.ctors))
+ /* We don't want to include the .ctor section from
+ from the crtend.o file until after the sorted ctors.
+ The .ctor section from the crtend file contains the
+ end of ctors marker and it must be last */
+ KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
+ KEEP (*(SORT(.ctors.*)))
+ KEEP (*(.ctors))
+ }
+ .dtors :
+ {
+ KEEP (*crtbegin*.o(.dtors))
+ KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
+ KEEP (*(SORT(.dtors.*)))
+ KEEP (*(.dtors))
+ }
+ .jcr : { KEEP (*(.jcr)) }
+ _gp = ALIGN(16) + 0x7ff0;
+ .got : { *(.got.plt) *(.got) }
+ /* We want the small data sections together, so single-instruction offsets
+ can access them all, and initialized data all before uninitialized, so
+ we can shorten the on-disk segment size. */
+ .sdata :
+ {
+ *(.sdata .sdata.* .gnu.linkonce.s.*)
+ }
+ .lit8 : { *(.lit8) }
+ .lit4 : { *(.lit4) }
+ _edata = .;
+ PROVIDE (edata = .);
+ __bss_start = .;
+ _fbss = .;
+ .sbss :
+ {
+ PROVIDE (__sbss_start = .);
+ PROVIDE (___sbss_start = .);
+ *(.dynsbss)
+ *(.sbss .sbss.* .gnu.linkonce.sb.*)
+ *(.scommon)
+ PROVIDE (__sbss_end = .);
+ PROVIDE (___sbss_end = .);
+ }
+ .bss :
+ {
+ *(.dynbss)
+ *(.bss .bss.* .gnu.linkonce.b.*)
+ *(COMMON)
+ /* Align here to ensure that the .bss section occupies space up to
+ _end. Align after .bss to ensure correct alignment even if the
+ .bss section disappears because there are no input sections. */
+ . = ALIGN(32 / 8);
+ }
+ . = ALIGN(32 / 8);
+ _end = .;
+ PROVIDE (end = .);
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+ /* DWARF debug sections.
+ Symbols in the DWARF debugging sections are relative to the beginning
+ of the section so we begin them at 0. */
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+ /* SGI/MIPS DWARF 2 extensions */
+ .debug_weaknames 0 : { *(.debug_weaknames) }
+ .debug_funcnames 0 : { *(.debug_funcnames) }
+ .debug_typenames 0 : { *(.debug_typenames) }
+ .debug_varnames 0 : { *(.debug_varnames) }
+ .gptab.sdata : { *(.gptab.data) *(.gptab.sdata) }
+ .gptab.sbss : { *(.gptab.bss) *(.gptab.sbss) }
+ /DISCARD/ : { *(.note.GNU-stack) }
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/pipe.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/pipe.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+#include <asm/asm.h>
+#include <asm/regdef.h>
+#include <asm/unistd.h>
+
+LEAF(pipe)
+ li v0, __NR_pipe
+ syscall
+ bnez a3, 1f
+ sw v0, (a0)
+ sw v1, (a1)
+ li v0, 0
+ b 2f
+1: sw v0, errno
+ li v0, -1
+2: jr ra
+ END(pipe)
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,82 @@
+#
+# arch/mips/setjmp.S
+#
+# setjmp/longjmp for the MIPS architecture
+#
+# The jmp_buf is assumed to contain the following, in order:
+# s0..s7
+# gp
+# sp
+# s8
+# ra
+# f20..f31
+# fcr31
+#
+
+#include <machine/asm.h>
+
+LEAF(setjmp)
+ sw s0, 0(a0)
+ sw s1, 4(a0)
+ sw s2, 8(a0)
+ sw s3, 12(a0)
+ sw s4, 16(a0)
+ sw s5, 20(a0)
+ sw s6, 24(a0)
+ sw s7, 28(a0)
+ sw gp, 32(a0)
+ sw sp, 36(a0)
+ sw s8, 40(a0)
+ sw ra, 44(a0)
+ cfc1 t0,$31
+ swc1 $f20,48(a0)
+ swc1 $f21,52(a0)
+ swc1 $f22,56(a0)
+ swc1 $f23,60(a0)
+ swc1 $f24,64(a0)
+ swc1 $f25,68(a0)
+ swc1 $f26,72(a0)
+ swc1 $f27,76(a0)
+ swc1 $f28,80(a0)
+ swc1 $f29,84(a0)
+ swc1 $f30,88(a0)
+ swc1 $f31,92(a0)
+ sw t0,96(a0)
+ move v0,zero
+ jr ra
+
+ END(setjmp)
+
+LEAF(longjmp)
+ lw s0, 0(a0)
+ lw s1, 4(a0)
+ lw s2, 8(a0)
+ lw s3, 12(a0)
+ lw s4, 16(a0)
+ lw s5, 20(a0)
+ lw s6, 24(a0)
+ lw s7, 28(a0)
+ lw gp, 32(a0)
+ lw sp, 36(a0)
+ lw s8, 40(a0)
+ lw ra, 44(a0)
+ lw t0, 96(a0)
+ lwc1 $f20,48(a0)
+ lwc1 $f21,52(a0)
+ lwc1 $f22,56(a0)
+ lwc1 $f23,60(a0)
+ lwc1 $f24,64(a0)
+ lwc1 $f25,68(a0)
+ lwc1 $f26,72(a0)
+ lwc1 $f27,76(a0)
+ lwc1 $f28,80(a0)
+ lwc1 $f29,84(a0)
+ lwc1 $f30,88(a0)
+ lwc1 $f31,92(a0)
+ ctc1 t0,$31
+ move v0,a1
+ jr ra
+
+ END(longjmp)
+
+
\ No newline at end of file
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/syscall.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/syscall.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+#include <asm/asm.h>
+#include <asm/regdef.h>
+#include <asm/unistd.h>
+
+ .set noreorder
+
+LEAF(__syscall_common)
+ syscall
+ beqz a3, 1f
+ # sw is actually two instructions; the first one goes
+ # in the branch delay slot
+ sw v0, errno
+ li v0, -1
+1: jr ra
+ END(__syscall_common)
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,30 @@
+# -*- perl -*-
+#
+# arch/mips/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+# On MIPS, most system calls follow the standard convention, with the
+# system call number in r0 (v0), return an error value in r19 (a3) as
+# well as the return value in r0 (v0).
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ $stype = $stype || 'common';
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/asm.h>\n";
+ print OUT "#include <asm/regdef.h>\n";
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "\n";
+ print OUT "\t.set noreorder\n";
+ print OUT "\n";
+ print OUT "LEAF(${fname})\n";
+ print OUT "\tj\t__syscall_${stype}\n";
+ print OUT "\t li\tv0, __NR_${sname}\n";
+ print OUT "\tEND(${fname})\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/vfork.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips/vfork.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+#include <asm/asm.h>
+#include <asm/regdef.h>
+#include <asm/unistd.h>
+
+#define CLONE_VM 0x00000100
+#define CLONE_VFORK 0x00004000
+#define SIGCHLD 18
+
+ .set noreorder
+
+LEAF(vfork)
+ li a0, CLONE_VFORK | CLONE_VM | SIGCHLD
+ li a1, 0
+ j __syscall_common
+ li v0, __NR_clone
+ END(vfork)
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips64/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips64/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+# -*- makefile -*-
+#
+# arch/mips64/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 64
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips64/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/mips64/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+# -*- makefile -*-
+#
+# arch/mips64/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+archclean:
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+# -*- makefile -*-
+#
+# arch/parisc/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 32
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+# -*- makefile -*-
+#
+# arch/parisc/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = \
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/syscall.o
+
+ARCHOOBJS = $(patsubst %o,%.lo,%(ARCHOBJS))
+
+archclean:
+
+arch/$(ARCH)/syscall.o: arch/$(ARCH)/syscall.c
+ $(CC) $(CFLAGS) -ffixed-r20 -c -o $@ $<
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,34 @@
+ .align 4
+
+ .import $global$, data
+ .import __libc_init, code
+
+ .global _start
+ .export _start, ENTRY
+ .type _start, at function
+
+ .proc
+ .callinfo
+
+_start:
+/* extend the stack by 64-bytes */
+ ldo 64(%sp), %sp
+
+/* %r25 = argc
+ * %r24 = argv
+ * envp = argv + (argc + 1)
+ * elfdata = (argv - 4)
+ */
+ ldo -4(%r24), %r26
+
+/* load global data */
+ ldil L%$global$, %dp
+ ldo R%$global$(%dp), %dp
+
+/* branch to __libc_init */
+ bl __libc_init,%r2
+ nop
+/* break miserably if we ever return */
+ iitlbp %r0,(%r0) /* illegal instruction */
+ nop
+ .procend
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,88 @@
+/*
+ * parisc specific setjmp/longjmp routines
+ *
+ */
+
+ .text
+ .align 4
+ .global setjmp
+ .export setjmp, code
+ .proc
+ .callinfo
+setjmp:
+ stw %r3,0(%r26)
+ stw %r4,8(%r26)
+ stw %r5,12(%r26)
+ stw %r6,16(%r26)
+ stw %r7,20(%r26)
+ stw %r8,24(%r26)
+ stw %r9,28(%r26)
+ stw %r10,32(%r26)
+ stw %r11,36(%r26)
+ stw %r12,40(%r26)
+ stw %r13,44(%r26)
+ stw %r14,48(%r26)
+ stw %r15,52(%r26)
+ stw %r16,56(%r26)
+ stw %r17,60(%r26)
+ stw %r18,64(%r26)
+ stw %r19,68(%r26)
+ stw %dp,72(%r26)
+ stw %r30,76(%r26)
+ stw %rp,80(%r26)
+ ldo 88(%r26),%r19
+ fstd,ma %fr12,8(%r19)
+ fstd,ma %fr13,8(%r19)
+ fstd,ma %fr14,8(%r19)
+ fstd,ma %fr15,8(%r19)
+ fstd,ma %fr16,8(%r19)
+ fstd,ma %fr17,8(%r19)
+ fstd,ma %fr18,8(%r19)
+ fstd,ma %fr19,8(%r19)
+ fstd,ma %fr20,8(%r19)
+ fstd %fr21,0(%r19)
+ bv %r0(%rp)
+ copy %r0,%r28
+ .procend
+
+ .text
+ .align 4
+ .global longjmp
+ .export longjmp, code
+ .proc
+ .callinfo
+longjmp:
+ ldw 0(%r26),%r3
+ ldw 8(%r26),%r4
+ ldw 12(%r26),%r5
+ ldw 16(%r26),%r6
+ ldw 20(%r26),%r7
+ ldw 24(%r26),%r8
+ ldw 28(%r26),%r9
+ ldw 32(%r26),%r10
+ ldw 36(%r26),%r11
+ ldw 40(%r26),%r12
+ ldw 44(%r26),%r13
+ ldw 48(%r26),%r14
+ ldw 52(%r26),%r15
+ ldw 56(%r26),%r16
+ ldw 60(%r26),%r17
+ ldw 64(%r26),%r18
+ ldw 68(%r26),%r19
+ ldw 72(%r26),%r27
+ ldw 76(%r26),%r30
+ ldw 80(%r26),%rp
+ ldo 88(%r26),%r20
+ fldd,ma 8(%r20),%fr12
+ fldd,ma 8(%r20),%fr13
+ fldd,ma 8(%r20),%fr14
+ fldd,ma 8(%r20),%fr15
+ fldd,ma 8(%r20),%fr16
+ fldd,ma 8(%r20),%fr17
+ fldd,ma 8(%r20),%fr18
+ fldd,ma 8(%r20),%fr19
+ fldd,ma 8(%r20),%fr20
+ fldd 0(%r20),%fr21
+ bv %r0(%rp)
+ copy %r25,%r28
+ .procend
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/syscall.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/syscall.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+/*
+ * arch/parisc/syscall.c
+ *
+ * This function is called from a stub with %r20 already set up.
+ * Compile this function with -ffixed-r20 so that it doesn't clobber
+ * this register by mistake.
+ */
+
+#include <klibc/compiler.h>
+#include <errno.h>
+
+long __syscall_common(long a0, long a1, long a2, long a3, long a4, long a5)
+{
+ register unsigned long rv asm ("r28");
+
+ asm volatile("\tble 0x100(%%sr2, %%r0)\n"
+ : "=r" (rv)
+ : "r" (a0), "r" (a1), "r" (a2), "r" (a3), "r" (a4), "r" (a5)
+ : "%r1", "%r2", "%r29", "%r31");
+
+ if ( __unlikely(rv >= -4095UL) ) {
+ errno = -rv;
+ return -1L;
+ } else {
+ return (long)rv;
+ }
+}
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/parisc/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+# -*- perl -*-
+#
+# arch/parisc/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "\n";
+ print OUT "\t.text\n";
+ print OUT "\t.align 4\n";
+ print OUT "\t.import __syscall_common, code\n";
+ print OUT "\t.global ${fname}\n";
+ print OUT "\t.export ${fname}, code\n";
+ print OUT "\t.type ${fname}, @function\n";
+ print OUT "\t.proc\n";
+ print OUT "\.callinfo\n";
+ print OUT "${fname}:\n";
+ print OUT "\tb\t__syscall_common\n";
+ print OUT "\t ldo\t__NR_${sname}(%r0),%r20\n";
+ print OUT "\t.procend\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+# -*- makefile -*-
+#
+# arch/ppc/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 32
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# 256-16 MB - normal binaries start at 256 MB, and jumps are limited
+# to +/- 16 MB
+SHAREDFLAGS = -Ttext 0x0f000200
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,22 @@
+# -*- makefile -*-
+#
+# arch/ppc/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = \
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/syscall.o \
+ libgcc/__divdi3.o \
+ libgcc/__moddi3.o \
+ libgcc/__udivdi3.o \
+ libgcc/__umoddi3.o \
+ libgcc/__udivmoddi4.o
+
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
+archclean:
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,20 @@
+#
+# arch/ppc/crt0.S
+#
+
+ .text
+ .align 4
+ .type _start, at function
+ .globl _start
+_start:
+ stwu 1,-16(1)
+ addi 3,1,16
+ /*
+ * the SVR4abippc.pdf specifies r7 as a pointer to
+ * a termination function pointer.
+ * It is unused on Linux.
+ */
+ mr 4,7
+ bl __libc_init
+
+ .size _start,.-_start
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,35 @@
+#
+# arch/ppc/setjmp.S
+#
+# Basic setjmp/longjmp implementation
+# This file was derived from the equivalent file in NetBSD
+#
+
+ .text
+ .align 4
+ .type setjmp, at function
+ .globl setjmp
+setjmp:
+ mflr %r11 /* save return address */
+ mfcr %r12 /* save condition register */
+ mr %r10,%r1 /* save stack pointer */
+ mr %r9,%r2 /* save GPR2 (not needed) */
+ stmw %r9,0(%r3) /* save r9..r31 */
+ li %r3,0 /* indicate success */
+ blr /* return */
+
+ .size setjmp,.-setjmp
+
+ .type longjmp, at function
+ .globl longjmp
+longjmp:
+ lmw %r9,0(%r3) /* save r9..r31 */
+ mtlr %r11 /* restore LR */
+ mtcr %r12 /* restore CR */
+ mr %r2,%r9 /* restore GPR2 (not needed) */
+ mr %r1,%r10 /* restore stack */
+ mr %r3,%r4 /* get return value */
+ blr /* return */
+
+ .size longjmp,.-longjmp
+
\ No newline at end of file
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/syscall.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/syscall.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * arch/ppc/syscall.S
+ *
+ * Common error-handling path for system calls.
+ */
+
+ .text
+ .align 2
+ .globl __syscall_error
+ .type __syscall_error, at function
+__syscall_error:
+ lis 9,errno at ha
+ stw 3,errno at l(9)
+ li 3,-1
+ blr
+ .size __syscall_error,.-__syscall_error
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+# -*- perl -*-
+#
+# arch/ppc/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "\n";
+ print OUT "\t.type ${fname},\@function\n";
+ print OUT "\t.globl ${fname}\n";
+ print OUT "${fname}:\n";
+ print OUT "\tli 0,__NR_${sname}\n";
+ print OUT "\tsc\n";
+ print OUT "\tbnslr\n";
+ print OUT "\tb __syscall_error\n";
+ print OUT "\t.size ${fname},.-${fname}\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,20 @@
+# -*- makefile -*-
+#
+# arch/ppc64/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHREQFLAGS = -m64 -mcall-aixdesc
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 64
+LDFLAGS = -m elf64ppc
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# 256-16 MB - normal binaries start at 256 MB, and jumps are limited
+# to +/- 16 MB
+SHAREDFLAGS = -Ttext 0x0f000200
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+# -*- makefile -*-
+#
+# arch/ppc64/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = \
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/syscall.o
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
+INTERP_O = interp1.o
+
+interp.o: interp1.o klibc.got
+ $(LD) $(LDFLAGS) -r -o $@ interp1.o klibc.got
+
+klibc.got: $(SOHASH)
+ $(OBJCOPY) -j .got $< $@
+
+archclean:
+ rm -f klibc.got
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,32 @@
+#
+# arch/ppc64/crt0.S
+#
+# void _start(void)
+# {
+# /* Divine up argc, argv, and envp */
+# environ = envp;
+# exit(main(argc, argv, envp));
+# }
+#
+
+ .section ".toc","aw"
+.LC0: .tc environ[TC],environ
+
+ .section ".opd","aw"
+ .align 3
+ .globl _start
+_start:
+ .quad ._start
+ .quad .TOC. at tocbase, 0
+
+ .text
+ .globl ._start
+ .type ._start, at function
+._start:
+ stdu %r1,-32(%r1)
+ addi %r3,%r1,32
+ mr %r4,%r7 /* fini */
+ b .__libc_init
+ nop
+
+ .size _start,.-_start
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,85 @@
+#
+# arch/ppc64/setjmp.S
+#
+# Basic setjmp/longjmp implementation
+#
+
+ .text
+ .align 4
+
+ .section ".opd","aw"
+setjmp:
+ .quad .setjmp,.TOC. at tocbase,0
+ .previous
+ .size setjmp,24
+ .type .setjmp, at function
+ .globl setjmp
+ .globl .setjmp
+.setjmp:
+ mflr %r11 /* save return address */
+ mfcr %r12 /* save condition register */
+ std %r2,0(%r3) /* save TOC pointer (not needed) */
+ stdu %r1,8(%r3) /* save stack pointer */
+ stdu %r11,8(%r3)
+ stdu %r12,8(%r3)
+ stdu %r13,8(%r3) /* save caller saved regs */
+ stdu %r14,8(%r3)
+ stdu %r15,8(%r3)
+ stdu %r16,8(%r3)
+ stdu %r17,8(%r3)
+ stdu %r18,8(%r3)
+ stdu %r19,8(%r3)
+ stdu %r20,8(%r3)
+ stdu %r21,8(%r3)
+ stdu %r22,8(%r3)
+ stdu %r23,8(%r3)
+ stdu %r24,8(%r3)
+ stdu %r25,8(%r3)
+ stdu %r26,8(%r3)
+ stdu %r27,8(%r3)
+ stdu %r28,8(%r3)
+ stdu %r29,8(%r3)
+ stdu %r30,8(%r3)
+ std %r31,8(%r3)
+ li %r3,0 /* indicate success */
+ blr /* return */
+
+ .size .setjmp,.-.setjmp
+ .section ".opd","aw"
+longjmp:
+ .quad .longjmp,.TOC. at tocbase,0
+ .previous
+ .size longjmp,24
+ .type .longjmp, at function
+ .globl longjmp
+ .globl .longjmp
+.longjmp:
+ ld %r2,0(%r3) /* restore TOC pointer (not needed) */
+ ldu %r1,8(%r3) /* restore stack */
+ ldu %r11,8(%r3)
+ ldu %r12,8(%r3)
+ ldu %r13,8(%r3) /* restore caller saved regs */
+ ldu %r14,8(%r3)
+ ldu %r15,8(%r3)
+ ldu %r16,8(%r3)
+ ldu %r17,8(%r3)
+ ldu %r18,8(%r3)
+ ldu %r19,8(%r3)
+ ldu %r20,8(%r3)
+ ldu %r21,8(%r3)
+ ldu %r22,8(%r3)
+ ldu %r23,8(%r3)
+ ldu %r24,8(%r3)
+ ldu %r25,8(%r3)
+ ldu %r26,8(%r3)
+ ldu %r27,8(%r3)
+ ldu %r28,8(%r3)
+ ldu %r29,8(%r3)
+ ldu %r30,8(%r3)
+ ld %r31,8(%r3)
+ mtlr %r11 /* restore LR */
+ mtcr %r12 /* restore CR */
+ mr %r3,%r4 /* get return value */
+ blr /* return */
+
+ .size .longjmp,.-.longjmp
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/syscall.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/syscall.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * arch/ppc64/syscall.c
+ *
+ * Common error-handling path for system calls.
+ * The return value from __syscall_error becomes the
+ * return value from the system call.
+ */
+#include <errno.h>
+
+long int __syscall_error(long int err)
+{
+ errno = err;
+ return -1;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/ppc64/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,31 @@
+# -*- perl -*-
+#
+# arch/ppc64/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "\n";
+ print OUT "\t.globl ${fname}\n";
+ print OUT "\t.section \".opd\",\"aw\"\n";
+ print OUT "\t.align 3\n";
+ print OUT "${fname}:\n";
+ print OUT "\t.quad .${fname},.TOC.\@tocbase,0\n";
+ print OUT "\t.text\n";
+ print OUT "\t.type .${fname},\@function\n";
+ print OUT "\t.globl .${fname}\n";
+ print OUT ".${fname}:\n";
+ print OUT "\tli 0,__NR_${sname}\n";
+ print OUT "\tsc\n";
+ print OUT "\tbnslr\n";
+ print OUT "\tb .__syscall_error\n";
+ print OUT "\t.size .${fname},.-.${fname}\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+# -*- makefile -*-
+#
+# arch/s390/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 32
+
+SHAREDFLAGS = -Ttext 0x40000200
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+# -*- makefile -*-
+#
+# arch/s390/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = \
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/mmap.o \
+ arch/$(ARCH)/syscall.o \
+ libgcc/__divdi3.o \
+ libgcc/__moddi3.o \
+ libgcc/__udivdi3.o \
+ libgcc/__umoddi3.o \
+ libgcc/__udivmoddi4.o
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
+
+archclean:
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+#
+# arch/s390/crt0.S
+#
+# Does arch-specific initialization and invokes __libc_init
+# with the appropriate arguments.
+#
+# See __static_init.c or __shared_init.c for the expected
+# arguments.
+#
+ .text
+ .align 4
+ .type _start, at function
+ .globl _start
+_start:
+ lr %r2,%r15
+ lhi %r3,0
+ ahi %r15,-96
+ bras %r1,.L0
+.L0:
+ l %r1,.L1-.L0(%r1)
+ br %r1
+.L1:
+ .long __libc_init
+
+ .size _start,.-_start
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/mmap.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/mmap.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,41 @@
+#include <sys/types.h>
+#include <linux/unistd.h>
+
+struct mmap_arg_struct {
+ unsigned long addr;
+ unsigned long len;
+ unsigned long prot;
+ unsigned long flags;
+ unsigned long fd;
+ unsigned long offset;
+};
+
+void * __mmap2(void * addr, size_t len, int prot, int flags,
+ int fd, long offset)
+{
+ struct mmap_arg_struct args = {
+ (unsigned long) addr,
+ (unsigned long) len,
+ (unsigned long) prot,
+ (unsigned long) flags,
+ (unsigned long) fd,
+ (unsigned long) offset,
+ };
+
+ register struct mmap_arg_struct *__arg1 asm("2") = &args;
+ register long __svcres asm("2");
+ unsigned long __res;
+
+ __asm__ __volatile__ (
+ " svc %b1\n"
+ : "=d" (__svcres)
+ : "i" (__NR_mmap2),
+ "0" (__arg1)
+ : "1", "cc", "memory");
+ __res = __svcres;
+ if (__res >= (unsigned long)-125) {
+ errno = -__res;
+ __res = -1;
+ }
+ return (void *)__res;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,32 @@
+#
+# arch/s390/setjmp.S
+#
+# setjmp/longjmp for the s390 architecture
+#
+
+ .text
+ .align 4
+ .globl setjmp
+ .type setjmp, @function
+setjmp:
+ stm %r6,%r15,0(%r2) # save all general registers
+ std %f4,40(%r2) # save fp registers f4 and f6
+ std %f6,48(%r2)
+ lhi %r2,0 # return 0
+ br %r14
+
+ .size setjmp,.-setjmp
+
+ .text
+ .align 4
+ .globl longjmp
+ .type longjmp, @function
+longjmp:
+ lr %r1,%r2 # jmp_buf
+ lr %r2,%r3 # return value
+ ld %f6,48(%r1) # restore all saved registers
+ ld %f4,40(%r1)
+ lm %r6,%r15,0(%r1)
+ br %r14 # return to restored address
+
+ .size longjmp,.-longjmp
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/syscall.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/syscall.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * arch/s390/syscall.c
+ *
+ * Common error-handling path for system calls.
+ * The return value from __syscall_common becomes the
+ * return value from the system call.
+ */
+#include <errno.h>
+
+long int __syscall_common(long int err)
+{
+ if ((unsigned long)(err) < (unsigned long)(-125))
+ return err;
+ errno = err;
+ return -1;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,31 @@
+# -*- perl -*-
+#
+# arch/s390/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "\n";
+ print OUT "\t.type ${fname},\@function\n";
+ print OUT "\t.globl ${fname}\n";
+ print OUT "${fname}:\n";
+ print OUT ".if __NR_${sname} < 256\n";
+ print OUT "\tsvc __NR_${sname}\n";
+ print OUT ".else\n";
+ print OUT "\tlhi %r1,__NR_${sname}\n";
+ print OUT "\tsvc 0\n";
+ print OUT ".endif\n";
+ print OUT "\tbras %r3,1f\n";
+ print OUT "\t.long __syscall_common\n";
+ print OUT "1:\tl %r3,0(%r3)\n";
+ print OUT "\tbr %r3\n";
+ print OUT "\t.size ${fname},.-${fname}\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+# -*- makefile -*-
+#
+# arch/s390x/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 64
+
+SHAREDFLAGS = -Ttext 0x40000200
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+# -*- makefile -*-
+#
+# arch/s390x/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = \
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/mmap.o \
+ arch/$(ARCH)/syscall.o
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
+
+archclean:
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,21 @@
+#
+# arch/s390/crt0.S
+#
+# Does arch-specific initialization and invokes __libc_init
+# with the appropriate arguments.
+#
+# See __static_init.c or __shared_init.c for the expected
+# arguments.
+#
+
+ .text
+ .align 4
+ .type _start, at function
+ .globl _start
+_start:
+ lgr %r2,%r15
+ lghi %r3,0
+ aghi %r15,-160
+ jg __libc_init
+
+ .size _start,.-_start
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/mmap.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/mmap.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,41 @@
+#include <sys/types.h>
+#include <linux/unistd.h>
+
+struct mmap_arg_struct {
+ unsigned long addr;
+ unsigned long len;
+ unsigned long prot;
+ unsigned long flags;
+ unsigned long fd;
+ unsigned long offset;
+};
+
+void * mmap(void * addr, size_t len, int prot, int flags,
+ int fd, off_t offset)
+{
+ struct mmap_arg_struct args = {
+ (unsigned long) addr,
+ (unsigned long) len,
+ (unsigned long) prot,
+ (unsigned long) flags,
+ (unsigned long) fd,
+ (unsigned long) offset,
+ };
+
+ register struct mmap_arg_struct *__arg1 asm("2") = &args;
+ register long __svcres asm("2");
+ unsigned long __res;
+
+ __asm__ __volatile__ (
+ " svc %b1\n"
+ : "=d" (__svcres)
+ : "i" (__NR_mmap),
+ "0" (__arg1)
+ : "1", "cc", "memory");
+ __res = __svcres;
+ if (__res >= (unsigned long)-125) {
+ errno = -__res;
+ __res = -1;
+ }
+ return (void *)__res;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,36 @@
+#
+# arch/s390x/setjmp.S
+#
+# setjmp/longjmp for the s390x architecture
+#
+
+ .text
+ .align 4
+ .globl setjmp
+ .type setjmp, @function
+setjmp:
+ stmg %r6,%r15,0(%r2) # save all general registers
+ std %f1,80(%r2) # save fp registers f4 and f6
+ std %f3,88(%r2)
+ std %f5,96(%r2)
+ std %f7,104(%r2)
+ lghi %r2,0 # return 0
+ br %r14
+
+ .size setjmp,.-setjmp
+
+ .text
+ .align 4
+ .globl longjmp
+ .type longjmp, @function
+longjmp:
+ lgr %r1,%r2 # jmp_buf
+ lgr %r2,%r3 # return value
+ ld %f7,104(%r1) # restore all saved registers
+ ld %f5,96(%r1)
+ ld %f3,88(%r1)
+ ld %f1,80(%r1)
+ lmg %r6,%r15,0(%r1)
+ br %r14 # return to restored address
+
+ .size longjmp,.-longjmp
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/syscall.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/syscall.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * arch/s390/syscall.c
+ *
+ * Common error-handling path for system calls.
+ * The return value from __syscall_common becomes the
+ * return value from the system call.
+ */
+#include <errno.h>
+
+long int __syscall_common(long int err)
+{
+ if ((unsigned long)(err) < (unsigned long)(-125))
+ return err;
+ errno = err;
+ return -1;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/s390x/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,28 @@
+# -*- perl -*-
+#
+# arch/s390x/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "\n";
+ print OUT "\t.type ${fname},\@function\n";
+ print OUT "\t.globl ${fname}\n";
+ print OUT "${fname}:\n";
+ print OUT ".if __NR_${sname} < 256\n";
+ print OUT "\tsvc __NR_${sname}\n";
+ print OUT ".else\n";
+ print OUT "\tlghi %r1,__NR_${sname}\n";
+ print OUT "\tsvc 0\n";
+ print OUT ".endif\n";
+ print OUT "\tbrasl %r3,__syscall_common\n";
+ print OUT "\t.size ${fname},.-${fname}\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+# -*- makefile -*-
+#
+# arch/sh/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHREGFLAGS = -m4 -mno-implicit-fp
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 32
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# 2 MB -- the normal starting point for text is 4 MB.
+SHAREDFLAGS = -Ttext 0x00200200
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+# -*- makefile -*-
+#
+# arch/sh/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = arch/sh/setjmp.o \
+ arch/sh/syscall.o
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
+archclean:
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,27 @@
+#
+# arch/sh/crt0.S
+#
+# Does arch-specific initialization and invokes __libc_init
+# with the appropriate arguments.
+#
+# See __static_init.c or __shared_init.c for the expected
+# arguments.
+#
+
+ .text
+ .align 2
+ .type _start,#function
+ .globl _start
+
+_start:
+ mov r15, r4
+ mov #0, r5
+ mov.l 1f, r0
+
+ jsr @r0
+ nop
+
+ .align 2
+1: .long __libc_init
+
+ .size _start,.-_start
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,65 @@
+#
+# arch/sh/setjmp.S
+#
+# setjmp/longjmp for the SuperH architecture
+#
+
+#
+# The jmp_buf is assumed to contain the following, in order:
+#
+# r8
+# r9
+# r10
+# r11
+# r12
+# r13
+# r14
+# r15
+# pr
+#
+
+ .text
+ .align 2
+
+ .globl setjmp
+ .type setjmp, #function
+
+setjmp:
+ add #(9*4), r4
+ sts.l pr, @-r4
+ mov.l r15, @-r4
+ mov.l r14, @-r4
+ mov.l r13, @-r4
+ mov.l r12, @-r4
+ mov.l r11, @-r4
+ mov.l r10, @-r4
+ mov.l r9, @-r4
+ mov.l r8, @-r4
+ rts
+ mov #0, r0
+
+ .size setjmp,.-setjmp
+
+ .align 2
+ .globl longjmp
+ .type setjmp, #function
+
+longjmp:
+ mov.l @r4+, r8
+ mov.l @r4+, r9
+ mov.l @r4+, r10
+ mov.l @r4+, r11
+ mov.l @r4+, r12
+ mov.l @r4+, r13
+ mov.l @r4+, r14
+ mov.l @r4+, r15
+ lds.l @r4+, pr
+ mov r5, r0
+ tst r0, r0
+ bf 1f
+ mov #1, r0 ! in case val==0
+1: rts
+ nop
+
+ .size longjmp,.-longjmp
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/syscall.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/syscall.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,35 @@
+/*
+ * arch/sh/syscall.S
+ *
+ * On sh, r3 contains the syscall number (set by generated stub);
+ * r4..r7 contain arguments 0-3 per the standard calling convention,
+ * and arguments 4-5 are passed in r0 and r1.
+ *
+ * The return value is in r3 rather than standard r0.
+ */
+
+ .section ".text.syscall","ax"
+ .align 2
+ .globl ___syscall_common
+ .type ___syscall_common, at function
+___syscall_common:
+ mov.l @(sp),r0
+ mov.l @(4,sp),r1
+ trapa #0x15
+ mov.l 1f,r0
+ cmp/hs r0,r3
+ bt/s 3f
+ neg r3,r4
+ mov.l 2f,r5
+ mov.l r4, at r5
+ rts
+ mov #-1,r0
+3:
+ rts
+ mov r3,r0
+
+ .align 2
+1: .long -4096 /* Errno limit */
+2: .long errno
+
+ .size ___syscall_common,.-___syscall_common
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sh/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,34 @@
+# -*- perl -*-
+#
+# arch/sh/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "\n";
+ print OUT "\t.section\t\".text.syscall\",\"ax\"\n";
+ print OUT "\t.type\t${fname},\#function\n";
+ print OUT "\t.globl\t${fname}\n";
+ print OUT "\t.align\t2\n";
+ print OUT "${fname}:\n";
+ print OUT "\tbra\t__syscall_common\n";
+ print OUT "#if __NR_${sname} >= 128\n";
+ print OUT "\t mov.l\t1f, r3\n";
+ print OUT "#else\n";
+ print OUT "\t mov\t# __NR_${sname}, r3\n";
+ print OUT "#endif\n";
+ print OUT "\t.size ${fname},.-${fname}\n";
+ print OUT "\n";
+ print OUT "#if __NR_${sname} >= 128\n";
+ print OUT "\t.align\t2\n";
+ print OUT "1:\t.long\t__NR_${sname}\n";
+ print OUT "#endif\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+# -*- makefile -*-
+#
+# arch/sparc/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 32
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# Normal binaries start at 64K; the linker wants 64K alignment,
+# and call instructions have a 30-bit signed offset, << 2.
+SHAREDFLAGS = -Ttext 0x40000100
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,46 @@
+# -*- makefile -*-
+#
+# arch/sparc/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = \
+ arch/$(ARCH)/sdiv.o \
+ arch/$(ARCH)/udiv.o \
+ arch/$(ARCH)/srem.o \
+ arch/$(ARCH)/urem.o \
+ arch/$(ARCH)/smul.o \
+ arch/$(ARCH)/umul.o \
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/syscall.o \
+ arch/$(ARCH)/sysfork.o
+
+arch/$(ARCH)/sdiv.S: arch/$(ARCH)/divrem.m4
+ @echo 'building $@ from $^'
+ @(echo "define(NAME,\`.div')define(OP,\`div')define(S,\`true')"; \
+ cat $^) | m4 > $@
+ @chmod 444 $@
+
+arch/$(ARCH)/udiv.S: arch/$(ARCH)/divrem.m4
+ @echo 'building $@ from $^'
+ @(echo "define(NAME,\`.udiv')define(OP,\`div')define(S,\`false')"; \
+ cat $^) | m4 > $@
+ @chmod 444 $@
+
+arch/$(ARCH)/srem.S: arch/$(ARCH)/divrem.m4
+ @echo 'building $@ from $^'
+ @(echo "define(NAME,\`.rem')define(OP,\`rem')define(S,\`true')"; \
+ cat $^) | m4 > $@
+ @chmod 444 $@
+
+arch/$(ARCH)/urem.S: arch/$(ARCH)/divrem.m4
+ @echo 'building $@ from $^'
+ @(echo "define(NAME,\`.urem')define(OP,\`rem')define(S,\`false')"; \
+ cat $^) | m4 > $@
+ @chmod 444 $@
+
+archclean:
+ rm -f arch/$(ARCH)/?div.S arch/$(ARCH)/?rem.S
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,2 @@
+#define TARGET_PTR_SIZE 32
+#include "arch/sparc/crt0i.S"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/crt0i.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/crt0i.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,100 @@
+! This file derived from the equivalent in newlib
+!
+! C run time start off
+
+! This file supports:
+!
+! - both 32bit pointer and 64bit pointer environments (at compile time)
+! - an imposed stack bias (of 2047) (at run time)
+! - medium/low and medium/anywhere code models (at run time)
+
+! Initial stack setup:
+!
+! bottom of stack (higher memory address)
+! ...
+! text of environment strings
+! text of argument strings
+! envp[envc] = 0 (4/8 bytes)
+! ...
+! env[0] (4/8 bytes)
+! argv[argc] = 0 (4/8 bytes)
+! ...
+! argv[0] (4/8 bytes)
+! argc (4/8 bytes)
+! register save area (64 bits by 16 registers = 128 bytes)
+! top of stack (%sp)
+
+! Stack Bias:
+!
+! It is the responsibility of the o/s to set this up.
+! We handle both a 0 and 2047 value for the stack bias.
+
+! Medium/Anywhere code model support:
+!
+! In this model %g4 points to the start of the data segment.
+! The text segment can go anywhere, but %g4 points to the *data* segment.
+! It is up to the compiler/linker to get this right.
+!
+! Since this model is statically linked the start of the data segment
+! is known at link time. Eg:
+!
+! sethi %hh(data_start), %g1
+! sethi %lm(data_start), %g4
+! or %g1, %hm(data_start), %g1
+! or %g4, %lo(data_start), %g4
+! sllx %g1, 32, %g1
+! or %g4, %g1, %g4
+!
+! FIXME: For now we just assume 0.
+
+! FIXME: if %g1 contains a non-zero value, atexit() should be invoked
+! with this value.
+
+
+ .text
+ .align 4
+ .globl _start
+ .type _start, @function
+_start:
+ clr %fp
+
+! We use %g4 even if the code model is Medium/Low (simplifies the code).
+
+ clr %g4 ! Medium/Anywhere base reg
+
+! If there is a stack bias in effect, account for it in %g5. Then always
+! add %g5 to stack references below. This way the code can be used with
+! or without an imposed bias.
+
+ andcc %sp, 1, %g5
+ bz,a .LNoBias
+ nop
+ mov 2047, %g5
+.LNoBias:
+ add %sp, %g5, %g5
+
+! On entry, the kernel leaves room for one register frame, but
+! the C API wants more free space. Thus, we need to drop the stack
+! pointer additionally.
+
+#if TARGET_PTR_SIZE == 32
+ sub %sp, 32, %sp ! make room for incoming arguments
+#else /* TARGET_PTR_SIZE == 64 */
+ sub %sp, 64, %sp ! make room for incoming arguments
+#endif
+
+! Set up pointers to the ELF data structure (argc, argv, ...)
+! Pass as the first argument to __libc_init
+#if TARGET_PTR_SIZE == 32
+ add %g5, 0x40, %o0
+#else /* TARGET_PTR_SIZE == 64 */
+ add %g5, 0x80, %o0
+#endif
+
+ call __libc_init
+ mov %g1, %o1 ! This is the "atexit" pointer;
+ ! pass as the second argument to __libc_init
+
+! If __libc_init returns, something is hosed. Try an illegal insn.
+! If that does not work, the o/s is hosed more than we are.
+ .long 0
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/divrem.m4
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/divrem.m4 Fri Mar 4 08:05:19 2005
@@ -0,0 +1,276 @@
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * 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 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.
+ *
+ * from: Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp
+ * $NetBSD: divrem.m4,v 1.4 1997/10/09 10:07:54 lukem Exp $
+ */
+
+/*
+ * Division and remainder, from Appendix E of the Sparc Version 8
+ * Architecture Manual, with fixes from Gordon Irlam.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)divrem.m4 8.1 (Berkeley) 6/4/93"
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Input: dividend and divisor in %o0 and %o1 respectively.
+ *
+ * m4 parameters:
+ * NAME name of function to generate
+ * OP OP=div => %o0 / %o1; OP=rem => %o0 % %o1
+ * S S=true => signed; S=false => unsigned
+ *
+ * Algorithm parameters:
+ * N how many bits per iteration we try to get (4)
+ * WORDSIZE total number of bits (32)
+ *
+ * Derived constants:
+ * TWOSUPN 2^N, for label generation (m4 exponentiation currently broken)
+ * TOPBITS number of bits in the top `decade' of a number
+ *
+ * Important variables:
+ * Q the partial quotient under development (initially 0)
+ * R the remainder so far, initially the dividend
+ * ITER number of main division loop iterations required;
+ * equal to ceil(log2(quotient) / N). Note that this
+ * is the log base (2^N) of the quotient.
+ * V the current comparand, initially divisor*2^(ITER*N-1)
+ *
+ * Cost:
+ * Current estimate for non-large dividend is
+ * ceil(log2(quotient) / N) * (10 + 7N/2) + C
+ * A large dividend is one greater than 2^(31-TOPBITS) and takes a
+ * different path, as the upper bits of the quotient must be developed
+ * one bit at a time.
+ */
+
+define(N, `4')
+define(TWOSUPN, `16')
+define(WORDSIZE, `32')
+define(TOPBITS, eval(WORDSIZE - N*((WORDSIZE-1)/N)))
+
+define(dividend, `%o0')
+define(divisor, `%o1')
+define(Q, `%o2')
+define(R, `%o3')
+define(ITER, `%o4')
+define(V, `%o5')
+
+/* m4 reminder: ifelse(a,b,c,d) => if a is b, then c, else d */
+define(T, `%g1')
+define(SC, `%g7')
+ifelse(S, `true', `define(SIGN, `%g6')')
+
+/*
+ * This is the recursive definition for developing quotient digits.
+ *
+ * Parameters:
+ * $1 the current depth, 1 <= $1 <= N
+ * $2 the current accumulation of quotient bits
+ * N max depth
+ *
+ * We add a new bit to $2 and either recurse or insert the bits in
+ * the quotient. R, Q, and V are inputs and outputs as defined above;
+ * the condition codes are expected to reflect the input R, and are
+ * modified to reflect the output R.
+ */
+define(DEVELOP_QUOTIENT_BITS,
+` ! depth $1, accumulated bits $2
+ bl L.$1.eval(TWOSUPN+$2)
+ srl V,1,V
+ ! remainder is positive
+ subcc R,V,R
+ ifelse($1, N,
+ ` b 9f
+ add Q, ($2*2+1), Q
+ ', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2+1)')')
+L.$1.eval(TWOSUPN+$2):
+ ! remainder is negative
+ addcc R,V,R
+ ifelse($1, N,
+ ` b 9f
+ add Q, ($2*2-1), Q
+ ', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2-1)')')
+ ifelse($1, 1, `9:')')
+
+#include <machine/asm.h>
+#include <machine/trap.h>
+
+FUNC(NAME)
+ifelse(S, `true',
+` ! compute sign of result; if neither is negative, no problem
+ orcc divisor, dividend, %g0 ! either negative?
+ bge 2f ! no, go do the divide
+ ifelse(OP, `div',
+ `xor divisor, dividend, SIGN',
+ `mov dividend, SIGN') ! compute sign in any case
+ tst divisor
+ bge 1f
+ tst dividend
+ ! divisor is definitely negative; dividend might also be negative
+ bge 2f ! if dividend not negative...
+ neg divisor ! in any case, make divisor nonneg
+1: ! dividend is negative, divisor is nonnegative
+ neg dividend ! make dividend nonnegative
+2:
+')
+ ! Ready to divide. Compute size of quotient; scale comparand.
+ orcc divisor, %g0, V
+ bnz 1f
+ mov dividend, R
+
+ ! Divide by zero trap. If it returns, return 0 (about as
+ ! wrong as possible, but that is what SunOS does...).
+ t ST_DIV0
+ retl
+ clr %o0
+
+1:
+ cmp R, V ! if divisor exceeds dividend, done
+ blu Lgot_result ! (and algorithm fails otherwise)
+ clr Q
+ sethi %hi(1 << (WORDSIZE - TOPBITS - 1)), T
+ cmp R, T
+ blu Lnot_really_big
+ clr ITER
+
+ ! `Here the dividend is >= 2^(31-N) or so. We must be careful here,
+ ! as our usual N-at-a-shot divide step will cause overflow and havoc.
+ ! The number of bits in the result here is N*ITER+SC, where SC <= N.
+ ! Compute ITER in an unorthodox manner: know we need to shift V into
+ ! the top decade: so do not even bother to compare to R.'
+ 1:
+ cmp V, T
+ bgeu 3f
+ mov 1, SC
+ sll V, N, V
+ b 1b
+ inc ITER
+
+ ! Now compute SC.
+ 2: addcc V, V, V
+ bcc Lnot_too_big
+ inc SC
+
+ ! We get here if the divisor overflowed while shifting.
+ ! This means that R has the high-order bit set.
+ ! Restore V and subtract from R.
+ sll T, TOPBITS, T ! high order bit
+ srl V, 1, V ! rest of V
+ add V, T, V
+ b Ldo_single_div
+ dec SC
+
+ Lnot_too_big:
+ 3: cmp V, R
+ blu 2b
+ nop
+ be Ldo_single_div
+ nop
+ /* NB: these are commented out in the V8-Sparc manual as well */
+ /* (I do not understand this) */
+ ! V > R: went too far: back up 1 step
+ ! srl V, 1, V
+ ! dec SC
+ ! do single-bit divide steps
+ !
+ ! We have to be careful here. We know that R >= V, so we can do the
+ ! first divide step without thinking. BUT, the others are conditional,
+ ! and are only done if R >= 0. Because both R and V may have the high-
+ ! order bit set in the first step, just falling into the regular
+ ! division loop will mess up the first time around.
+ ! So we unroll slightly...
+ Ldo_single_div:
+ deccc SC
+ bl Lend_regular_divide
+ nop
+ sub R, V, R
+ mov 1, Q
+ b Lend_single_divloop
+ nop
+ Lsingle_divloop:
+ sll Q, 1, Q
+ bl 1f
+ srl V, 1, V
+ ! R >= 0
+ sub R, V, R
+ b 2f
+ inc Q
+ 1: ! R < 0
+ add R, V, R
+ dec Q
+ 2:
+ Lend_single_divloop:
+ deccc SC
+ bge Lsingle_divloop
+ tst R
+ b,a Lend_regular_divide
+
+Lnot_really_big:
+1:
+ sll V, N, V
+ cmp V, R
+ bleu 1b
+ inccc ITER
+ be Lgot_result
+ dec ITER
+
+ tst R ! set up for initial iteration
+Ldivloop:
+ sll Q, N, Q
+ DEVELOP_QUOTIENT_BITS(1, 0)
+Lend_regular_divide:
+ deccc ITER
+ bge Ldivloop
+ tst R
+ bl,a Lgot_result
+ ! non-restoring fixup here (one instruction only!)
+ifelse(OP, `div',
+` dec Q
+', ` add R, divisor, R
+')
+
+Lgot_result:
+ifelse(S, `true',
+` ! check to see if answer should be < 0
+ tst SIGN
+ bl,a 1f
+ ifelse(OP, `div', `neg Q', `neg R')
+1:')
+ retl
+ ifelse(OP, `div', `mov Q, %o0', `mov R, %o0')
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,38 @@
+!
+! setjmp.S
+!
+! Basic setjmp/longjmp
+!
+! This code was based on the equivalent code in NetBSD
+!
+
+#include <machine/asm.h>
+#include <machine/trap.h>
+
+!
+! The jmp_buf contains the following entries:
+! sp
+! fp
+! pc
+!
+ENTRY(setjmp)
+ st %sp,[%o0+0] ! Callers stack pointer
+ st %o7,[%o0+4] ! Return pc
+ st %fp,[%o0+8] ! Frame pointer
+ retl ! Return
+ clr %o0 ! ...0
+
+ENTRY(longjmp)
+ sub %sp, 64, %sp ! set up a local stack frame
+0:
+ t ST_FLUSHWIN ! flush register windows out to memory
+ !
+ ! We restore the saved stack pointer to %fp, then issue
+ ! a restore instruction which will reload the register
+ ! window from the stack.
+ !
+ ld [%o0+4], %o7 /* restore return pc */
+ ld [%o0+0], %fp /* and stack pointer */
+
+ retl ! success, return %g6
+ restore %o1, 0, %o0
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/smul.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/smul.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,160 @@
+/* $NetBSD: mul.S,v 1.3 1997/07/16 14:37:42 christos Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * 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 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.
+ *
+ * from: Header: mul.s,v 1.5 92/06/25 13:24:03 torek Exp
+ */
+
+#include <machine/asm.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+ .asciz "@(#)mul.s 8.1 (Berkeley) 6/4/93"
+#else
+ RCSID("$NetBSD: mul.S,v 1.3 1997/07/16 14:37:42 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Signed multiply, from Appendix E of the Sparc Version 8
+ * Architecture Manual.
+ *
+ * Returns %o0 * %o1 in %o1%o0 (i.e., %o1 holds the upper 32 bits of
+ * the 64-bit product).
+ *
+ * This code optimizes short (less than 13-bit) multiplies.
+ */
+
+FUNC(.mul)
+ mov %o0, %y ! multiplier -> Y
+ andncc %o0, 0xfff, %g0 ! test bits 12..31
+ be Lmul_shortway ! if zero, can do it the short way
+ andcc %g0, %g0, %o4 ! zero the partial product and clear N and V
+
+ /*
+ * Long multiply. 32 steps, followed by a final shift step.
+ */
+ mulscc %o4, %o1, %o4 ! 1
+ mulscc %o4, %o1, %o4 ! 2
+ mulscc %o4, %o1, %o4 ! 3
+ mulscc %o4, %o1, %o4 ! 4
+ mulscc %o4, %o1, %o4 ! 5
+ mulscc %o4, %o1, %o4 ! 6
+ mulscc %o4, %o1, %o4 ! 7
+ mulscc %o4, %o1, %o4 ! 8
+ mulscc %o4, %o1, %o4 ! 9
+ mulscc %o4, %o1, %o4 ! 10
+ mulscc %o4, %o1, %o4 ! 11
+ mulscc %o4, %o1, %o4 ! 12
+ mulscc %o4, %o1, %o4 ! 13
+ mulscc %o4, %o1, %o4 ! 14
+ mulscc %o4, %o1, %o4 ! 15
+ mulscc %o4, %o1, %o4 ! 16
+ mulscc %o4, %o1, %o4 ! 17
+ mulscc %o4, %o1, %o4 ! 18
+ mulscc %o4, %o1, %o4 ! 19
+ mulscc %o4, %o1, %o4 ! 20
+ mulscc %o4, %o1, %o4 ! 21
+ mulscc %o4, %o1, %o4 ! 22
+ mulscc %o4, %o1, %o4 ! 23
+ mulscc %o4, %o1, %o4 ! 24
+ mulscc %o4, %o1, %o4 ! 25
+ mulscc %o4, %o1, %o4 ! 26
+ mulscc %o4, %o1, %o4 ! 27
+ mulscc %o4, %o1, %o4 ! 28
+ mulscc %o4, %o1, %o4 ! 29
+ mulscc %o4, %o1, %o4 ! 30
+ mulscc %o4, %o1, %o4 ! 31
+ mulscc %o4, %o1, %o4 ! 32
+ mulscc %o4, %g0, %o4 ! final shift
+
+ ! If %o0 was negative, the result is
+ ! (%o0 * %o1) + (%o1 << 32))
+ ! We fix that here.
+
+ tst %o0
+ bge 1f
+ rd %y, %o0
+
+ ! %o0 was indeed negative; fix upper 32 bits of result by subtracting
+ ! %o1 (i.e., return %o4 - %o1 in %o1).
+ retl
+ sub %o4, %o1, %o1
+
+1:
+ retl
+ mov %o4, %o1
+
+Lmul_shortway:
+ /*
+ * Short multiply. 12 steps, followed by a final shift step.
+ * The resulting bits are off by 12 and (32-12) = 20 bit positions,
+ * but there is no problem with %o0 being negative (unlike above).
+ */
+ mulscc %o4, %o1, %o4 ! 1
+ mulscc %o4, %o1, %o4 ! 2
+ mulscc %o4, %o1, %o4 ! 3
+ mulscc %o4, %o1, %o4 ! 4
+ mulscc %o4, %o1, %o4 ! 5
+ mulscc %o4, %o1, %o4 ! 6
+ mulscc %o4, %o1, %o4 ! 7
+ mulscc %o4, %o1, %o4 ! 8
+ mulscc %o4, %o1, %o4 ! 9
+ mulscc %o4, %o1, %o4 ! 10
+ mulscc %o4, %o1, %o4 ! 11
+ mulscc %o4, %o1, %o4 ! 12
+ mulscc %o4, %g0, %o4 ! final shift
+
+ /*
+ * %o4 has 20 of the bits that should be in the low part of the
+ * result; %y has the bottom 12 (as %y's top 12). That is:
+ *
+ * %o4 %y
+ * +----------------+----------------+
+ * | -12- | -20- | -12- | -20- |
+ * +------(---------+------)---------+
+ * --hi-- ----low-part----
+ *
+ * The upper 12 bits of %o4 should be sign-extended to form the
+ * high part of the product (i.e., highpart = %o4 >> 20).
+ */
+
+ rd %y, %o5
+ sll %o4, 12, %o0 ! shift middle bits left 12
+ srl %o5, 20, %o5 ! shift low bits right 20, zero fill at left
+ or %o5, %o0, %o0 ! construct low part of result
+ retl
+ sra %o4, 20, %o1 ! ... and extract high part of result
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/syscall.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/syscall.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * arch/sparc/syscall.S
+ *
+ * Common system-call stub; %g1 already set to syscall number
+ */
+
+ .globl __syscall_common
+ .type __syscall_common,#function
+ .align 4
+__syscall_common:
+ t 0x10
+ bcc 1f
+ sethi %hi(errno), %g4
+ or %g4, %lo(errno), %g4
+ st %o0,[%g4]
+ mov -1, %o0
+1:
+ retl
+ nop
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/sysfork.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/sysfork.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+/*
+ * arch/sparc/sysfork.S
+ *
+ * The fork and vfork system calls are special on sparc[64]:
+ * they return the "other process" pid in %o0 and the
+ * "is child" flag in %o1
+ *
+ * Common system-call stub; %g1 already set to syscall number
+ */
+
+ .globl __syscall_forkish
+ .type __syscall_forkish,#function
+ .align 4
+__syscall_forkish:
+ t 0x10
+ sub %o1, 1, %o1
+ bcc,a 1f
+ and %o0, %o1, %o0
+ sethi %hi(errno), %g4
+ or %g4, %lo(errno), %g4
+ st %o0,[%g4]
+ mov -1, %o0
+1:
+ retl
+ nop
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+# -*- perl -*-
+#
+# arch/sparc32/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ $stype = $stype || 'common';
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "\n";
+ print OUT "\t.type ${fname},\@function\n";
+ print OUT "\t.globl ${fname}\n";
+ print OUT "${fname}:\n";
+ print OUT "\tb __syscall_${stype}\n";
+ print OUT "\t mov\t__NR_${sname}, %g1\n";
+ print OUT "\t.size ${fname},.-${fname}\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/umul.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc/umul.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,193 @@
+/* $NetBSD: umul.S,v 1.3 1997/07/16 14:37:44 christos Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * 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 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.
+ *
+ * from: Header: umul.s,v 1.4 92/06/25 13:24:05 torek Exp
+ */
+
+#include <machine/asm.h>
+#if defined(LIBC_SCCS) && !defined(lint)
+#if 0
+ .asciz "@(#)umul.s 8.1 (Berkeley) 6/4/93"
+#else
+ RCSID("$NetBSD: umul.S,v 1.3 1997/07/16 14:37:44 christos Exp $")
+#endif
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * Unsigned multiply. Returns %o0 * %o1 in %o1%o0 (i.e., %o1 holds the
+ * upper 32 bits of the 64-bit product).
+ *
+ * This code optimizes short (less than 13-bit) multiplies. Short
+ * multiplies require 25 instruction cycles, and long ones require
+ * 45 instruction cycles.
+ *
+ * On return, overflow has occurred (%o1 is not zero) if and only if
+ * the Z condition code is clear, allowing, e.g., the following:
+ *
+ * call .umul
+ * nop
+ * bnz overflow (or tnz)
+ */
+
+FUNC(.umul)
+ or %o0, %o1, %o4
+ mov %o0, %y ! multiplier -> Y
+ andncc %o4, 0xfff, %g0 ! test bits 12..31 of *both* args
+ be Lmul_shortway ! if zero, can do it the short way
+ andcc %g0, %g0, %o4 ! zero the partial product and clear N and V
+
+ /*
+ * Long multiply. 32 steps, followed by a final shift step.
+ */
+ mulscc %o4, %o1, %o4 ! 1
+ mulscc %o4, %o1, %o4 ! 2
+ mulscc %o4, %o1, %o4 ! 3
+ mulscc %o4, %o1, %o4 ! 4
+ mulscc %o4, %o1, %o4 ! 5
+ mulscc %o4, %o1, %o4 ! 6
+ mulscc %o4, %o1, %o4 ! 7
+ mulscc %o4, %o1, %o4 ! 8
+ mulscc %o4, %o1, %o4 ! 9
+ mulscc %o4, %o1, %o4 ! 10
+ mulscc %o4, %o1, %o4 ! 11
+ mulscc %o4, %o1, %o4 ! 12
+ mulscc %o4, %o1, %o4 ! 13
+ mulscc %o4, %o1, %o4 ! 14
+ mulscc %o4, %o1, %o4 ! 15
+ mulscc %o4, %o1, %o4 ! 16
+ mulscc %o4, %o1, %o4 ! 17
+ mulscc %o4, %o1, %o4 ! 18
+ mulscc %o4, %o1, %o4 ! 19
+ mulscc %o4, %o1, %o4 ! 20
+ mulscc %o4, %o1, %o4 ! 21
+ mulscc %o4, %o1, %o4 ! 22
+ mulscc %o4, %o1, %o4 ! 23
+ mulscc %o4, %o1, %o4 ! 24
+ mulscc %o4, %o1, %o4 ! 25
+ mulscc %o4, %o1, %o4 ! 26
+ mulscc %o4, %o1, %o4 ! 27
+ mulscc %o4, %o1, %o4 ! 28
+ mulscc %o4, %o1, %o4 ! 29
+ mulscc %o4, %o1, %o4 ! 30
+ mulscc %o4, %o1, %o4 ! 31
+ mulscc %o4, %o1, %o4 ! 32
+ mulscc %o4, %g0, %o4 ! final shift
+
+
+ /*
+ * Normally, with the shift-and-add approach, if both numbers are
+ * positive you get the correct result. WIth 32-bit two's-complement
+ * numbers, -x is represented as
+ *
+ * x 32
+ * ( 2 - ------ ) mod 2 * 2
+ * 32
+ * 2
+ *
+ * (the `mod 2' subtracts 1 from 1.bbbb). To avoid lots of 2^32s,
+ * we can treat this as if the radix point were just to the left
+ * of the sign bit (multiply by 2^32), and get
+ *
+ * -x = (2 - x) mod 2
+ *
+ * Then, ignoring the `mod 2's for convenience:
+ *
+ * x * y = xy
+ * -x * y = 2y - xy
+ * x * -y = 2x - xy
+ * -x * -y = 4 - 2x - 2y + xy
+ *
+ * For signed multiplies, we subtract (x << 32) from the partial
+ * product to fix this problem for negative multipliers (see mul.s).
+ * Because of the way the shift into the partial product is calculated
+ * (N xor V), this term is automatically removed for the multiplicand,
+ * so we don't have to adjust.
+ *
+ * But for unsigned multiplies, the high order bit wasn't a sign bit,
+ * and the correction is wrong. So for unsigned multiplies where the
+ * high order bit is one, we end up with xy - (y << 32). To fix it
+ * we add y << 32.
+ */
+ tst %o1
+ bl,a 1f ! if %o1 < 0 (high order bit = 1),
+ add %o4, %o0, %o4 ! %o4 += %o0 (add y to upper half)
+1: rd %y, %o0 ! get lower half of product
+ retl
+ addcc %o4, %g0, %o1 ! put upper half in place and set Z for %o1==0
+
+Lmul_shortway:
+ /*
+ * Short multiply. 12 steps, followed by a final shift step.
+ * The resulting bits are off by 12 and (32-12) = 20 bit positions,
+ * but there is no problem with %o0 being negative (unlike above),
+ * and overflow is impossible (the answer is at most 24 bits long).
+ */
+ mulscc %o4, %o1, %o4 ! 1
+ mulscc %o4, %o1, %o4 ! 2
+ mulscc %o4, %o1, %o4 ! 3
+ mulscc %o4, %o1, %o4 ! 4
+ mulscc %o4, %o1, %o4 ! 5
+ mulscc %o4, %o1, %o4 ! 6
+ mulscc %o4, %o1, %o4 ! 7
+ mulscc %o4, %o1, %o4 ! 8
+ mulscc %o4, %o1, %o4 ! 9
+ mulscc %o4, %o1, %o4 ! 10
+ mulscc %o4, %o1, %o4 ! 11
+ mulscc %o4, %o1, %o4 ! 12
+ mulscc %o4, %g0, %o4 ! final shift
+
+ /*
+ * %o4 has 20 of the bits that should be in the result; %y has
+ * the bottom 12 (as %y's top 12). That is:
+ *
+ * %o4 %y
+ * +----------------+----------------+
+ * | -12- | -20- | -12- | -20- |
+ * +------(---------+------)---------+
+ * -----result-----
+ *
+ * The 12 bits of %o4 left of the `result' area are all zero;
+ * in fact, all top 20 bits of %o4 are zero.
+ */
+
+ rd %y, %o5
+ sll %o4, 12, %o0 ! shift middle bits left 12
+ srl %o5, 20, %o5 ! shift low bits right 20
+ or %o5, %o0, %o0
+ retl
+ addcc %g0, %g0, %o1 ! %o1 = zero, and set Z
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,21 @@
+# -*- makefile -*-
+#
+# arch/sparc64/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHREQFLAGS = -m64 -mptr64
+OPTFLAGS = -Os -fomit-frame-pointer
+BITSIZE = 64
+
+LDFLAGS = -m elf64_sparc
+
+# Extra linkflags when building the shared version of the library
+# This address needs to be reachable using normal inter-module
+# calls, and work on the memory models for this architecture
+# Normal binaries start at 1 MB; the linker wants 1 MB alignment,
+# and call instructions have a 30-bit signed offset, << 2.
+SHAREDFLAGS = -Ttext 0x80000200
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+# -*- makefile -*-
+#
+# arch/sparc64/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = \
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/syscall.o \
+ arch/$(ARCH)/sysfork.o
+
+archclean:
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,2 @@
+#define TARGET_PTR_SIZE 64
+#include "arch/sparc/crt0i.S"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,55 @@
+!
+! setjmp.S
+!
+! Basic setjmp/longjmp
+!
+! This code was based on the equivalent code in NetBSD
+!
+
+!
+! The jmp_buf contains the following entries:
+! sp
+! fp
+! pc
+!
+ .text
+ .align 4
+ .global setjmp
+ .type setjmp, @function
+setjmp:
+ stx %sp,[%o0+0] ! Callers stack pointer
+ stx %o7,[%o0+8] ! Return pc
+ stx %fp,[%o0+16] ! Frame pointer
+ retl ! Return
+ clr %o0 ! ...0
+
+ .size setjmp,.-setjmp
+
+
+ .globl longjmp
+ .type longjmp, @function
+longjmp:
+ mov %o1, %g4 ! save return value
+ mov %o0, %g1 ! save target
+ ldx [%g1+16],%g5 ! get callers frame
+1:
+ cmp %fp, %g5 ! compare against desired frame
+ bl,a 1b ! if below...
+ restore ! pop frame and loop
+ be,a 2f ! if there...
+ ldx [%g1+0],%o2 ! fetch return %sp
+
+.Lbotch:
+ unimp 0 ! ... error ...
+
+2:
+ cmp %o2, %sp ! %sp must not decrease
+ bl .Lbotch
+ nop
+ mov %o2, %sp ! it is OK, put it in place
+
+ ldx [%g1+8],%o3 ! fetch %pc
+ jmp %o3 + 8 ! if sucess...
+ mov %g4,%o0 ! return %g4
+
+ .size longjmp,.-longjmp
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/syscall.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/syscall.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+/*
+ * arch/sparc64/syscall.S
+ *
+ * Common system-call stub; %g1 already set to syscall number
+ */
+
+ .globl __syscall_common
+ .type __syscall_common,#function
+ .align 4
+__syscall_common:
+ t 0x6d
+ bcc %xcc, 1f
+ sethi %hi(errno), %g4
+ or %g4, %lo(errno), %g4
+ st %o0,[%g4]
+1:
+ retl
+ movcs %xcc, -1, %o0
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/sysfork.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/sysfork.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,26 @@
+/*
+ * arch/sparc64/sysfork.S
+ *
+ * The fork and vfork system calls are special on sparc[64]:
+ * they return the "other process" pid in %o0 and the
+ * "is child" flag in %o1
+ *
+ * Common system-call stub; %g1 already set to syscall number
+ *
+ * IS THIS CORRECT FOR SPARC64?
+ */
+
+ .globl __syscall_forkish
+ .type __syscall_forkish,#function
+ .align 4
+__syscall_forkish:
+ t 0x6d
+ sub %o1, 1, %o1
+ bcc,a %xcc, 1f
+ and %o0, %o1, %o0
+ sethi %hi(errno), %g4
+ or %g4, %lo(errno), %g4
+ st %o0,[%g4]
+1:
+ retl
+ movcs %xcc, -1, %o0
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/sparc64/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+# -*- perl -*-
+#
+# arch/sparc64/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ $stype = $stype || 'common';
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "\n";
+ print OUT "\t.type ${fname},\@function\n";
+ print OUT "\t.globl ${fname}\n";
+ print OUT "${fname}:\n";
+ print OUT "\tb __syscall_${stype}\n";
+ print OUT "\t mov\t__NR_${sname}, %g1\n";
+ print OUT "\t.size ${fname},.-${fname}\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/MCONFIG
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/MCONFIG Fri Mar 4 08:05:19 2005
@@ -0,0 +1,22 @@
+# -*- makefile -*-
+#
+# arch/x86-64/MCONFIG
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+# Blatantly copied and modified from i386 version by Mats Petersson, AMD.
+#
+
+#
+# NOTE: -fno-asynchronous-unwind-tables produce significantly smaller
+# binaries (20% smaller), but makes the code completely useless for
+# debugging using gdb.
+#
+ARCHREQFLAGS = -m64
+OPTFLAGS = -Os -fno-asynchronous-unwind-tables -fomit-frame-pointer \
+ -falign-functions=0 -falign-jumps=0 -falign-loops=0
+BITSIZE = 64
+LDFLAGS = -m elf_x86_64
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/Makefile.inc
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/Makefile.inc Fri Mar 4 08:05:19 2005
@@ -0,0 +1,17 @@
+# -*- makefile -*-
+#
+# arch/x86_64/Makefile.inc
+#
+# Special rules for this architecture. Note that this is actually
+# included from the main Makefile, and that pathnames should be
+# accordingly.
+#
+
+ARCHOBJS = \
+ arch/$(ARCH)/exits.o \
+ arch/$(ARCH)/setjmp.o \
+ arch/$(ARCH)/syscall.o
+
+ARCHSOOBJS = $(patsubst %.o,%.lo,$(ARCHOBJS))
+
+archclean:
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/crt0.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/crt0.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,22 @@
+#
+# arch/x86_64/crt0.S
+#
+# Does arch-specific initialization and invokes __libc_init
+# with the appropriate arguments.
+#
+# See __static_init.c or __shared_init.c for the expected
+# arguments.
+#
+
+ .text
+ .align 4
+ .type _start, at function
+ .globl _start
+_start:
+ movq %rsp,%rdi # Offset of the ELF data structure
+ movq %rdx,%rsi # The atexit() pointer (if any)
+ call __libc_init
+ # We should never get here...
+ hlt
+
+ .size _start,.-_start
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/exits.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/exits.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,35 @@
+#
+# exit and _exit get included in *every* program, and gcc generates
+# horrible code for them. Yes, this only saves a few bytes, but
+# it does it in every program.
+#
+
+#include <asm/unistd.h>
+
+ .data
+ .align 8
+ .globl __exit_handler
+ .type __exit_handler, at object
+__exit_handler:
+ .quad _exit
+ .size __exit_handler,8
+
+ .text
+ .align 8
+ .globl exit
+ .type exit, at function
+exit:
+ jmp *(__exit_handler)
+ .size exit,.-exit
+
+ /* No need to save any registers... we're exiting! */
+ .text
+ .align 4
+ .globl _exit
+ .type _exit, at function
+_exit:
+ movl $__NR_exit,%eax
+ /* The argument is already in %rdi */
+ syscall
+ .size _exit,.-exit
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/setjmp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/setjmp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,54 @@
+#
+# arch/x86_64/setjmp.S
+#
+# setjmp/longjmp for the x86-64 architecture
+#
+
+#
+# The jmp_buf is assumed to contain the following, in order:
+# %rbx
+# %rsp (post-return)
+# %rbp
+# %r12
+# %r13
+# %r14
+# %r15
+# <return address>
+#
+
+ .text
+ .align 4
+ .globl setjmp
+ .type setjmp, @function
+setjmp:
+ pop %rsi # Return address, and adjust the stack
+ xorl %eax,%eax # Return value
+ movq %rbx,(%rdi)
+ movq %rsp,8(%rdi) # Post-return %rsp!
+ push %rsi # Make the call/return stack happy
+ movq %rbp,16(%rdi)
+ movq %r12,24(%rdi)
+ movq %r13,32(%rdi)
+ movq %r14,40(%rdi)
+ movq %r15,48(%rdi)
+ movq %rsi,56(%rdi) # Return address
+ ret
+
+ .size setjmp,.-setjmp
+
+ .text
+ .align 4
+ .globl longjmp
+ .type longjmp, @function
+longjmp:
+ movl %esi,%eax # Return value (int)
+ movq (%rdi),%rbx
+ movq 8(%rdi),%rsp
+ movq 16(%rdi),%rbp
+ movq 24(%rdi),%r12
+ movq 32(%rdi),%r13
+ movq 40(%rdi),%r14
+ movq 48(%rdi),%r15
+ jmp *56(%rdi)
+
+ .size longjmp,.-longjmp
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/syscall.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/syscall.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,28 @@
+/*
+ * arch/x86-64/syscall.S
+ *
+ * Common tail-handling code for system calls.
+ *
+ * The arguments are in the standard argument registers; the system
+ * call number in %eax.
+ */
+ .text
+ .align 4
+ .globl __syscall_common
+ .type __syscall_common, at function
+__syscall_common:
+ movq %rcx,%r10 # The kernel uses %r10 istf %rcx
+ syscall
+
+ cmpq $-4095,%rax
+ jb 1f
+
+ # Error return, must set errno
+ negl %eax
+ movl %eax,errno(%rip) # errno is type int, so 32 bits
+ orq $-1,%rax # orq $-1 smaller than movq $-1
+
+1:
+ ret
+
+ .size __syscall_common,.-__syscall_common
Added: multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/sysstub.ph
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/arch/x86_64/sysstub.ph Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+# -*- perl -*-
+#
+# arch/x86_64/sysstub.ph
+#
+# Script to generate system call stubs
+#
+
+sub make_sysstub($$$$@) {
+ my($fname, $type, $sname, $stype, @args) = @_;
+
+ open(OUT, '>', "syscalls/${fname}.S");
+ print OUT "#include <asm/unistd.h>\n";
+ print OUT "\n";
+ print OUT "\t.type ${fname},\@function\n";
+ print OUT "\t.globl ${fname}\n";
+ print OUT "${fname}:\n";
+ print OUT "\tmovl \$__NR_${sname},%eax\n"; # Zero-extends to 64 bits
+ print OUT "\tjmp __syscall_common\n";
+ print OUT "\t.size ${fname},.-${fname}\n";
+ close(OUT);
+}
+
+1;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/asprintf.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/asprintf.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,30 @@
+/*
+ * asprintf.c
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+int asprintf(char **bufp, const char *format, ...)
+{
+ va_list ap, ap1;
+ int rv;
+ int bytes;
+ char *p;
+
+ va_start(ap, format);
+ va_copy(ap1, ap);
+
+ bytes = vsnprintf(NULL, 0, format, ap1) + 1;
+ va_end(ap1);
+
+ *bufp = p = malloc(bytes);
+ if ( !p )
+ return -1;
+
+ rv = vsnprintf(p, bytes, format, ap);
+ va_end(ap);
+
+ return rv;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/assert.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/assert.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * assert.c
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+
+void __assert_fail(const char *expr, const char *file, unsigned int line)
+{
+ printf("Assertion %s failed, file %s, line %u\n", expr, file, line);
+ abort();
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/atexit.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/atexit.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+/*
+ * atexit.c
+ */
+
+#include <stdlib.h>
+
+int atexit(void (*fctn)(void))
+{
+ return on_exit((void (*)(int, void *))fctn, NULL);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/atexit.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/atexit.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * atexit.h
+ *
+ * atexit()/on_exit() internal definitions
+ */
+
+#ifndef ATEXIT_H
+#define ATEXIT_H
+
+struct atexit {
+ void (*fctn)(int, void *);
+ void *arg; /* on_exit() parameter */
+ struct atexit *next;
+};
+
+extern struct atexit *__atexit_list;
+
+#endif /* ATEXIT_H */
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/atoi.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/atoi.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,3 @@
+#define TYPE int
+#define NAME atoi
+#include "atox.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/atol.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/atol.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,3 @@
+#define TYPE long
+#define NAME atol
+#include "atox.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/atoll.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/atoll.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,3 @@
+#define TYPE long long
+#define NAME atoll
+#include "atox.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/atox.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/atox.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * atox.c
+ *
+ * atoi(), atol(), atoll()
+ */
+
+#include <inttypes.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+TYPE NAME (const char *nptr)
+{
+ return (TYPE) strntoumax(nptr, (char **)NULL, 10, ~(size_t)0);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/brk.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/brk.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+/* brk.c - Change data segment size */
+
+/* Written 2000 by Werner Almesberger */
+
+
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+char *__current_brk; /* Common with sbrk.c */
+
+/*
+ * The Linux brk() isn't what most people expect, so we call the
+ * system call __brk() and provide a wrapper.
+ */
+int brk(void *end_data_segment)
+{
+ char *new_brk;
+
+ new_brk = __brk(end_data_segment);
+ if (new_brk != end_data_segment) return -1;
+ __current_brk = new_brk;
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/bsd_signal.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/bsd_signal.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+/*
+ * bsd_signal.c
+ */
+
+#include <signal.h>
+
+__sighandler_t bsd_signal(int signum, __sighandler_t handler)
+{
+ /* BSD signal() semantics */
+ return __signal(signum, handler, SA_RESTART);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/calloc.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/calloc.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,21 @@
+/*
+ * calloc.c
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+/* FIXME: This should look for multiplication overflow */
+
+void *calloc(size_t nmemb, size_t size)
+{
+ void *ptr;
+
+ size *= nmemb;
+ ptr = malloc(size);
+ if ( ptr )
+ memset(ptr, 0, size);
+
+ return ptr;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/closelog.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/closelog.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+/*
+ * closelog.c
+ */
+
+#include <syslog.h>
+#include <unistd.h>
+
+extern int __syslog_fd;
+
+void closelog(void)
+{
+ int logfd = __syslog_fd;
+
+ if ( logfd != -1 ) {
+ close(logfd);
+ __syslog_fd = -1;
+ }
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/creat.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/creat.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * creat.c
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+int creat(const char *pathname, mode_t mode)
+{
+ return open(pathname, O_CREAT|O_WRONLY|O_TRUNC, mode);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/ctypes.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/ctypes.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,284 @@
+/*
+ * ctypes.c
+ *
+ * This is the array that defines <ctype.h> classes.
+ * This assumes ISO 8859-1.
+ */
+
+#include <ctype.h>
+
+const unsigned char __ctypes[257] = {
+ 0, /* EOF */
+
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl|__ctype_space, /* BS */
+ __ctype_cntrl|__ctype_space, /* TAB */
+ __ctype_cntrl|__ctype_space, /* LF */
+ __ctype_cntrl|__ctype_space, /* VT */
+ __ctype_cntrl|__ctype_space, /* FF */
+ __ctype_cntrl|__ctype_space, /* CR */
+ __ctype_cntrl, /* control character */
+
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+
+ __ctype_print|__ctype_space, /* space */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+
+ __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+ __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+ __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+ __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+ __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+ __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+ __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+ __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+ __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+ __ctype_print|__ctype_digit|__ctype_xdigit, /* digit */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
+ __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
+ __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
+ __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
+ __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
+ __ctype_print|__ctype_upper|__ctype_xdigit, /* A-F */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_upper, /* G-Z */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
+ __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
+ __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
+ __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
+ __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
+ __ctype_print|__ctype_lower|__ctype_xdigit, /* a-f */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_lower, /* g-z */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_cntrl, /* control character */
+
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+ __ctype_cntrl, /* control character */
+
+ __ctype_print|__ctype_space, /* NBSP */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_punct, /* punctuation */
+
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_upper, /* upper accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_punct, /* punctuation */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+ __ctype_print|__ctype_lower, /* lower accented */
+};
Added: multipath-tools/upstream/current/klibc-0.190/klibc/daemon.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/daemon.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,38 @@
+/*
+ * daemon.c - "daemonize" a process
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+int daemon(int nochdir, int noclose)
+{
+ int nullfd;
+ pid_t f;
+
+ if ( !nochdir ) {
+ if ( chdir("/") )
+ return -1;
+ }
+
+ if ( !noclose ) {
+ if ( (nullfd = open("/dev/null", O_RDWR)) < 0 ||
+ dup2(nullfd, 0) < 0 ||
+ dup2(nullfd, 1) < 0 ||
+ dup2(nullfd, 2) < 0 )
+ return -1;
+ close(nullfd);
+ }
+
+ f = fork();
+ if ( f < 0 )
+ return -1;
+ else if ( f > 0 )
+ _exit(0);
+
+
+ return setsid();
+}
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/exec_l.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/exec_l.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,57 @@
+/*
+ * exec_l.c
+ *
+ * Common implementation of execl() execle() execlp()
+ */
+
+#include <stdarg.h>
+#include <alloca.h>
+#include <unistd.h>
+
+int NAME (const char *path, const char *arg0, ...)
+{
+ va_list ap, cap;
+ int argc = 1, rv;
+ const char **argv, **argp;
+ const char *arg;
+#if EXEC_E
+ char * const * envp;
+#else
+#define envp environ
+#endif
+
+ va_start(ap, arg0);
+ va_copy(cap, ap);
+
+ /* Count the number of arguments */
+ do {
+ arg = va_arg(cap, const char *);
+ argc++;
+ } while ( arg );
+
+ va_end(cap);
+
+ /* Allocate memory for the pointer array */
+ argp = argv = alloca(argc*sizeof(const char *));
+ if ( !argv ) {
+ va_end(ap);
+ return -1;
+ }
+
+ /* Copy the list into an array */
+ *argp++ = arg0;
+ do {
+ *argp++ = arg = va_arg(ap, const char *);
+ } while ( arg );
+
+#if EXEC_E
+ /* execle() takes one more argument for the environment pointer */
+ envp = va_arg(ap, char * const *);
+#endif
+
+ rv = (EXEC_P ? execvpe : execve)(path, (char * const *)argv, envp);
+
+ va_end(ap);
+
+ return rv;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/execl.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/execl.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,8 @@
+/*
+ * execl.c
+ */
+
+#define NAME execl
+#define EXEC_P 0
+#define EXEC_E 0
+#include "exec_l.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/execle.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/execle.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,8 @@
+/*
+ * execle.c
+ */
+
+#define NAME execle
+#define EXEC_P 0
+#define EXEC_E 1
+#include "exec_l.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/execlp.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/execlp.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,8 @@
+/*
+ * execlp.c
+ */
+
+#define NAME execlp
+#define EXEC_P 1
+#define EXEC_E 0
+#include "exec_l.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/execlpe.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/execlpe.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,8 @@
+/*
+ * execlpe.c
+ */
+
+#define NAME execlpe
+#define EXEC_P 1
+#define EXEC_E 1
+#include "exec_l.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/execv.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/execv.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * execv.c
+ */
+
+#include <stdarg.h>
+#include <unistd.h>
+
+int execv(const char *path, char * const * argv)
+{
+ return execve(path, argv, environ);
+}
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/execvp.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/execvp.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * execvp.c
+ */
+
+#include <stdarg.h>
+#include <unistd.h>
+
+int execvp(const char *path, char * const * argv)
+{
+ return execvpe(path, argv, environ);
+}
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/execvpe.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/execvpe.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,73 @@
+/*
+ * execvpe.c
+ *
+ * execvpe() function (from which we build execlp, execlpe, execvp).
+ *
+ * This version of execvpe() will *not* spawn /bin/sh if the command
+ * return ENOEXEC. That's what #! is for, folks!
+ *
+ * Since execlpe() and execvpe() aren't in POSIX, nor in glibc,
+ * I have followed QNX precedent in the implementation of the PATH:
+ * the PATH that is used is the one in the current environment, not
+ * in the new environment.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+
+#define DEFAULT_PATH "/bin:/usr/bin:."
+
+int execvpe(const char *file, char * const *argv, char * const *envp)
+{
+ char path[PATH_MAX];
+ const char *searchpath, *esp;
+ size_t prefixlen, filelen, totallen;
+
+ if ( strchr(file, '/') ) /* Specific path */
+ return execve(file, argv, envp);
+
+ filelen = strlen(file);
+
+ searchpath = getenv("PATH");
+ if ( !searchpath )
+ searchpath = DEFAULT_PATH;
+
+ errno = ENOENT; /* Default errno, if execve() doesn't change it */
+
+ do {
+ esp = strchr(searchpath, ':');
+ if ( esp )
+ prefixlen = esp-searchpath;
+ else
+ prefixlen = strlen(searchpath);
+
+ if ( prefixlen == 0 || searchpath[prefixlen-1] == '/' ) {
+ totallen = prefixlen+filelen;
+ if ( totallen >= PATH_MAX )
+ continue;
+ memcpy(path, searchpath, prefixlen);
+ memcpy(path+prefixlen, file, filelen);
+ } else {
+ totallen = prefixlen+filelen+1;
+ if ( totallen >= PATH_MAX )
+ continue;
+ memcpy(path, searchpath, prefixlen);
+ path[prefixlen] = '/';
+ memcpy(path+prefixlen+1, file, filelen);
+ }
+ path[totallen] = '\0';
+
+ execve(path, argv, envp);
+ if ( errno == E2BIG || errno == ENOEXEC ||
+ errno == ENOMEM || errno == ETXTBSY )
+ break; /* Report this as an error, no more search */
+
+ searchpath = esp+1;
+ } while ( esp );
+
+ return -1;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/exitc.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/exitc.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+/*
+ * exit.c
+ *
+ * Implement exit()
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+
+/* We have an assembly version for i386 and x86-64 */
+
+#if !defined(__i386__) && !defined(__x86_64__)
+
+/* This allows atexit/on_exit to install a hook */
+__noreturn (*__exit_handler)(int) = _exit;
+
+__noreturn exit(int rv)
+{
+ __exit_handler(rv);
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/fgetc.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/fgetc.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,20 @@
+/*
+ * fgetc.c
+ *
+ * Extremely slow fgetc implementation, using _fread(). If people
+ * actually need character-oriented input to be fast, we may actually
+ * have to implement buffering. Sigh.
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+
+int fgetc(FILE *f)
+{
+ unsigned char ch;
+
+ return (_fread(&ch, 1, f) == 1) ? (int)ch : EOF;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/fgets.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/fgets.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,33 @@
+/*
+ * fgets.c
+ *
+ * This will be very slow due to the implementation of getc(),
+ * but we can't afford to drain characters we don't need from
+ * the input.
+ */
+
+#include <stdio.h>
+
+char *fgets(char *s, int n, FILE *f)
+{
+ int ch;
+ char *p = s;
+
+ while ( n > 1 ) {
+ ch = getc(f);
+ if ( ch == EOF ) {
+ *p = '\0';
+ return NULL;
+ }
+ *p++ = ch;
+ if ( ch == '\n' )
+ break;
+ }
+ if ( n )
+ *p = '\0';
+
+ return s;
+}
+
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/fopen.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/fopen.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,40 @@
+/*
+ * fopen.c
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+/* This depends on O_RDONLY == 0, O_WRONLY == 1, O_RDWR == 2 */
+
+
+FILE *fopen(const char *file, const char *mode)
+{
+ int flags = O_RDONLY;
+ int plus = 0;
+
+ while ( *mode ) {
+ switch ( *mode++ ) {
+ case 'r':
+ flags = O_RDONLY;
+ break;
+ case 'w':
+ flags = O_WRONLY|O_CREAT|O_TRUNC;
+ break;
+ case 'a':
+ flags = O_WRONLY|O_CREAT|O_APPEND;
+ break;
+ case '+':
+ plus = 1;
+ break;
+ }
+ }
+
+ if ( plus ) {
+ flags = (flags & ~(O_RDONLY|O_WRONLY)) | O_RDWR;
+ }
+
+ /* Note: __create_file(-1) == NULL, so this is safe */
+ return __create_file(open(file, flags, 0666));
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/fork.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/fork.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,20 @@
+/*
+ * fork.c
+ *
+ * This is normally just a syscall stub, but at least one system
+ * doesn't have sys_fork, only sys_clone...
+ */
+
+#include <sys/syscall.h>
+#include <signal.h>
+#include <unistd.h>
+#include <sched.h>
+
+#ifndef __NR_fork
+
+pid_t fork(void)
+{
+ return __clone(SIGCHLD, 0);
+}
+
+#endif /* __NR_fork */
Added: multipath-tools/upstream/current/klibc-0.190/klibc/fprintf.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/fprintf.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * fprintf.c
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#define BUFFER_SIZE 16384
+
+int fprintf(FILE *file, const char *format, ...)
+{
+ va_list ap;
+ int rv;
+
+ va_start(ap, format);
+ rv = vfprintf(file, format, ap);
+ va_end(ap);
+ return rv;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/fputc.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/fputc.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * fputc.c
+ *
+ * gcc "printf decompilation" expects this to exist...
+ */
+
+#include <stdio.h>
+
+int fputc(int c, FILE *f)
+{
+ unsigned char ch = c;
+
+ return _fwrite(&ch, 1, f) == 1 ? ch : EOF;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/fputs.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/fputs.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * fputs.c
+ *
+ * This isn't quite fputs() in the stdio sense, since we don't
+ * have stdio, but it takes a file descriptor argument instead
+ * of the FILE *.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+int fputs(const char *s, FILE *file)
+{
+ return _fwrite(s, strlen(s), file);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/fread.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/fread.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,35 @@
+/*
+ * fread.c
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+
+size_t _fread(void *buf, size_t count, FILE *f)
+{
+ size_t bytes = 0;
+ ssize_t rv;
+ char *p = buf;
+
+ while ( count ) {
+ rv = read(fileno(f), p, count);
+ if ( rv == -1 ) {
+ if ( errno == EINTR )
+ continue;
+ else
+ break;
+ } else if ( rv == 0 ) {
+ break;
+ }
+
+ p += rv;
+ bytes += rv;
+ count -= rv;
+ }
+
+ return bytes;
+}
+
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/fread2.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/fread2.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * fread2.c
+ *
+ * The actual fread() function as a non-inline
+ */
+
+#define __NO_FREAD_FWRITE_INLINES
+#include <stdio.h>
+
+size_t fread(void *ptr, size_t size, size_t nmemb, FILE *f)
+{
+ return _fread(ptr, size*nmemb, f)/size;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/fstatfs.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/fstatfs.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * fstatfs.c
+ *
+ * On architectures which do fstatfs64, wrap the system call
+ */
+
+#include <sys/syscall.h>
+#include <sys/vfs.h>
+
+#ifdef __NR_fstatfs64
+
+extern int __fstatfs64(int, size_t, struct statfs *);
+
+int fstatfs(int fd, struct statfs *buf)
+{
+ return __fstatfs64(fd, sizeof *buf, buf);
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/fwrite.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/fwrite.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,35 @@
+/*
+ * fwrite.c
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+
+size_t _fwrite(const void *buf, size_t count, FILE *f)
+{
+ size_t bytes = 0;
+ ssize_t rv;
+ const char *p = buf;
+
+ while ( count ) {
+ rv = write(fileno(f), p, count);
+ if ( rv == -1 ) {
+ if ( errno == EINTR )
+ continue;
+ else
+ break;
+ } else if ( rv == 0 ) {
+ break;
+ }
+
+ p += rv;
+ bytes += rv;
+ count -= rv;
+ }
+
+ return bytes;
+}
+
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/fwrite2.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/fwrite2.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * fwrite2.c
+ *
+ * The actual fwrite() function as a non-inline
+ */
+
+#define __NO_FREAD_FWRITE_INLINES
+#include <stdio.h>
+
+size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *f)
+{
+ return _fwrite(ptr, size*nmemb, f)/size;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/getcwd.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/getcwd.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * getcwd.c
+ *
+ * The system call behaves differently than the library function.
+ */
+
+#include <unistd.h>
+#include <sys/syscall.h>
+
+extern int __getcwd(char * buf, size_t size);
+
+char *getcwd(char *buf, size_t size)
+{
+ return ( __getcwd(buf, size) < 0 ) ? NULL : buf;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/getdomainname.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/getdomainname.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+/*
+ * getdomainname.c
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/utsname.h>
+
+int getdomainname(char *name, size_t len)
+{
+ struct utsname un;
+
+ if ( !uname(&un) )
+ return -1;
+
+ if ( len < strlen(un.domainname)+1 ) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ strcpy(name, un.domainname);
+
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/getenv.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/getenv.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,22 @@
+/*
+ * getenv.c
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+char *getenv(const char *name)
+{
+ char **p, *q;
+ int len = strlen(name);
+
+ for ( p = environ ; (q = *p) ; p++ ) {
+ if ( !strncmp(name, q, len) && q[len] == '=' ) {
+ return q+(len+1);
+ }
+ }
+
+ return NULL;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/gethostname.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/gethostname.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+/*
+ * gethostname.c
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/utsname.h>
+
+int gethostname(char *name, size_t len)
+{
+ struct utsname un;
+
+ if ( !uname(&un) )
+ return -1;
+
+ if ( len < strlen(un.nodename)+1 ) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ strcpy(name, un.nodename);
+
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/getopt.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/getopt.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,74 @@
+/*
+ * getopt.c
+ *
+ * Simple POSIX getopt(), no GNU extensions...
+ */
+
+#include <stdint.h>
+#include <unistd.h>
+#include <string.h>
+
+char *optarg;
+int optind = 1;
+int opterr, optopt;
+static const char *__optptr;
+
+int getopt(int argc, char * const *argv, const char *optstring)
+{
+ const char *carg = argv[optind];
+ const char *osptr;
+ int opt;
+
+ /* We don't actually need argc */
+ (void)argc;
+
+ /* First, eliminate all non-option cases */
+
+ if ( !carg || carg[0] != '-' || !carg[1] ) {
+ return -1;
+ }
+
+ if ( carg[1] == '-' && !carg[2] ) {
+ optind++;
+ return -1;
+ }
+
+ if ( (uintptr_t)(__optptr-carg) > (uintptr_t)strlen(carg) )
+ __optptr = carg+1; /* Someone frobbed optind, change to new opt. */
+
+ opt = *__optptr++;
+
+ if ( opt != ':' && (osptr = strchr(optstring, opt)) ) {
+ if ( osptr[1] == ':' ) {
+ if ( *__optptr ) {
+ /* Argument-taking option with attached argument */
+ optarg = (char *)__optptr;
+ optind++;
+ } else {
+ /* Argument-taking option with non-attached argument */
+ if ( argv[optind+1] ) {
+ optarg = (char *)argv[optind+1];
+ optind += 2;
+ } else {
+ /* Missing argument */
+ return (optstring[0] == ':') ? ':' : '?';
+ }
+ }
+ return opt;
+ } else {
+ /* Non-argument-taking option */
+ /* __optptr will remember the exact position to resume at */
+ if ( ! *__optptr )
+ optind++;
+ return opt;
+ }
+ } else {
+ /* Unknown option */
+ optopt = opt;
+ if ( ! *__optptr )
+ optind++;
+ return '?';
+ }
+}
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/getpgrp.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/getpgrp.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,9 @@
+/*
+ * getpgrp.c
+ */
+
+#include <unistd.h>
+
+pid_t getpgrp(void) {
+ return getpgid(0);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/getpriority.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/getpriority.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+/*
+ * getpriority.c
+ *
+ * Needs to do some post-syscall mangling to distinguish error returns...
+ * but only on some platforms. Sigh.
+ */
+
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/syscall.h>
+
+#if !defined(__alpha__) && !defined(__ia64__)
+
+extern int __getpriority(int, int);
+
+int getpriority(int which, int who)
+{
+ int rv = __getpriority(which, who);
+ return ( rv < 0 ) ? rv : 20-rv;
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/getpt.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/getpt.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,17 @@
+/*
+ * getpt.c
+ *
+ * GNU extension to the standard Unix98 pty suite
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <termios.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+
+int getpt(void)
+{
+ return open("/dev/ptmx", O_RDWR|O_NOCTTY);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/globals.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/globals.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+/*
+ * globals.c
+ *
+ * These have to be defined somewhere...
+ */
+#include <errno.h>
+#include <unistd.h>
+
+int errno;
+char **environ;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/inet/bindresvport.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/inet/bindresvport.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,45 @@
+/*
+ * inet/bindresvport.c
+ */
+
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <string.h>
+#include <unistd.h>
+
+#define START_PORT 768
+#define END_PORT IPPORT_RESERVED
+#define NUM_PORTS (END_PORT - START_PORT)
+
+int bindresvport(int sd, struct sockaddr_in *sin)
+{
+ struct sockaddr_in me;
+ static short port;
+ int ret = 0;
+ int i;
+
+ if (sin == NULL) {
+ memset(&me, 0, sizeof(me));
+ sin = &me;
+ sin->sin_family = AF_INET;
+ } else if (sin->sin_family != AF_INET) {
+ errno = EPFNOSUPPORT;
+ return -1;
+ }
+
+ if (port == 0) {
+ port = START_PORT + (getpid() % NUM_PORTS);
+ }
+
+ for (i = 0; i < NUM_PORTS; i++, port++) {
+ if (port == END_PORT)
+ port = START_PORT;
+ sin->sin_port = htons(port);
+ if ((ret = bind(sd, (struct sockaddr *)sin, sizeof(*sin))) != -1)
+ break;
+ }
+
+ return ret;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_addr.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_addr.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * inet/inet_addr.c
+ */
+
+#include <arpa/inet.h>
+#include <stdio.h>
+
+uint32_t inet_addr(const char *str)
+{
+ struct in_addr a;
+ int rv = inet_aton(str, &a);
+
+ return rv ? INADDR_NONE : a.s_addr;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_aton.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_aton.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+/*
+ * inet/inet_aton.c
+ */
+
+#include <arpa/inet.h>
+#include <stdio.h>
+
+int inet_aton(const char *str, struct in_addr *addr)
+{
+ union {
+ uint8_t b[4];
+ uint32_t l;
+ } a;
+
+ if ( sscanf(str, "%hhu.%hhu.%hhu.%hhu", &a.b[0], &a.b[1], &a.b[2], &a.b[3]) == 4 ) {
+ addr->s_addr = a.l; /* Always in network byte order */
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_ntoa.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_ntoa.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * inet/inet_ntoa.c
+ */
+
+#include <arpa/inet.h>
+#include <stdio.h>
+
+char *inet_ntoa(struct in_addr addr)
+{
+ static char name[16];
+ union {
+ uint8_t b[4];
+ uint32_t l;
+ } a;
+ a.l = addr.s_addr;
+
+ sprintf(name, "%u.%u.%u.%u", a.b[0], a.b[1], a.b[2], a.b[3]);
+ return name;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_ntop.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_ntop.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,52 @@
+/*
+ * inet/inet_ntop.c
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <netinet/in6.h>
+
+const char *inet_ntop(int af, const void *cp, char *buf, size_t len)
+{
+ size_t xlen;
+
+ switch ( af ) {
+ case AF_INET:
+ {
+ union {
+ uint8_t b[4];
+ uint32_t l;
+ } a;
+ a.l = ((const struct in_addr *)cp)->s_addr;
+
+ xlen = snprintf(buf, len, "%u.%u.%u.%u", a.b[0], a.b[1], a.b[2], a.b[3]);
+ }
+ break;
+
+ case AF_INET6:
+ {
+ const struct in6_addr *s = (const struct in6_addr *)cp;
+
+ xlen = snprintf(buf, len, "%x:%x:%x:%x:%x:%x:%x:%x",
+ ntohs(s->s6_addr16[0]), ntohs(s->s6_addr16[1]),
+ ntohs(s->s6_addr16[2]), ntohs(s->s6_addr16[3]),
+ ntohs(s->s6_addr16[4]), ntohs(s->s6_addr16[5]),
+ ntohs(s->s6_addr16[6]), ntohs(s->s6_addr16[7]));
+ }
+ break;
+
+ default:
+ errno = EAFNOSUPPORT;
+ return NULL;
+ }
+
+ if ( xlen > len ) {
+ errno = ENOSPC;
+ return NULL;
+ }
+
+ return buf;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_pton.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/inet/inet_pton.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,74 @@
+/*
+ * inet/inet_pton.c
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <errno.h>
+#include <ctype.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <netinet/in6.h>
+
+static inline int hexval(int ch)
+{
+ if ( ch >= '0' && ch <= '9' ) {
+ return ch-'0';
+ } else if ( ch >= 'A' && ch <= 'F' ) {
+ return ch-'A'+10;
+ } else if ( ch >= 'a' && ch <= 'f' ) {
+ return ch-'a'+10;
+ } else {
+ return -1;
+ }
+}
+
+int inet_pton(int af, const char *src, void *dst)
+{
+ switch ( af ) {
+ case AF_INET:
+ return inet_aton(src, (struct in_addr *)dst);
+
+ case AF_INET6:
+ {
+ struct in6_addr *d = (struct in6_addr *)dst;
+ int colons = 0, dcolons = 0;
+ int i;
+ const char *p;
+
+ /* A double colon will increment colons by 2, dcolons by 1 */
+ for ( p = dst ; *p ; p++ ) {
+ if ( p[0] == ':' ) {
+ colons++;
+ if ( p[1] == ':' )
+ dcolons++;
+ } else if ( !isxdigit(*p) )
+ return 0; /* Not a valid address */
+ }
+
+ if ( colons > 7 || dcolons > 1 || (!dcolons && colons != 7) )
+ return 0; /* Not a valid address */
+
+ memset(d, 0, sizeof(struct in6_addr));
+
+ i = 0;
+ for ( p = dst ; *p ; p++ ) {
+ if ( *p == ':' ) {
+ if ( p[1] == ':' ) {
+ i += (8-colons);
+ } else {
+ i++;
+ }
+ } else {
+ d->s6_addr16[i] = htons((ntohs(d->s6_addr16[i]) << 4) + hexval(*p));
+ }
+ }
+
+ return 1;
+ }
+
+ default:
+ errno = EAFNOSUPPORT;
+ return -1;
+ }
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/interp.S
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/interp.S Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+#
+# This is a hack to generate the .intrp section, which then
+# ld turns into an PT_INTERP header.
+#
+# NOTE: The .interp section needs to be "a", or it doesnt work...
+#
+
+ .section ".interp","a"
+ .ascii LIBDIR
+ .ascii "/klibc-"
+ .ascii SOHASH
+ .ascii ".so"
+ .byte 0
Added: multipath-tools/upstream/current/klibc-0.190/klibc/isatty.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/isatty.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,21 @@
+/*
+ * isatty.c
+ */
+
+#include <unistd.h>
+#include <termios.h>
+#include <errno.h>
+
+int isatty(int fd)
+{
+ int old_errno = errno;
+ int istty;
+ pid_t dummy;
+
+ /* All ttys support TIOCGPGRP */
+ istty = !ioctl(fd, TIOCGPGRP, &dummy);
+ errno = old_errno;
+
+ return istty;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/jrand48.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/jrand48.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+/*
+ * jrand48.c
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+
+long jrand48(unsigned short xsubi[3])
+{
+ uint64_t x;
+
+ /* The xsubi[] array is littleendian by spec */
+ x = (uint64_t)(uint16_t)xsubi[0] +
+ ((uint64_t)(uint16_t)xsubi[1] << 16) +
+ ((uint64_t)(uint16_t)xsubi[2] << 32);
+
+ x = (0x5deece66dULL * x) + 0xb;
+
+ xsubi[0] = (unsigned short)(uint16_t)x;
+ xsubi[1] = (unsigned short)(uint16_t)(x >> 16);
+ xsubi[2] = (unsigned short)(uint16_t)(x >> 32);
+
+ return (long)(int32_t)(x >> 16);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/libc_init.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/libc_init.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,86 @@
+/*
+ * libc_init.c
+ *
+ * This function takes the raw data block set up by the ELF loader
+ * in the kernel and parses it. It is invoked by crt0.S which makes
+ * any necessary adjustments and passes calls this function using
+ * the standard C calling convention.
+ *
+ * The arguments are:
+ * uintptr_t *elfdata -- The ELF loader data block; usually from the stack.
+ * Basically a pointer to argc.
+ * void (*onexit)(void) -- Function to install into onexit
+ */
+
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <klibc/compiler.h>
+#include <elf.h>
+
+/* This file is included from __static_init.c or __shared_init.c */
+#ifndef SHARED
+# error "SHARED should be defined to 0 or 1"
+#endif
+
+char **environ;
+unsigned int __page_size, __page_shift;
+
+struct auxentry {
+ uintptr_t type;
+ uintptr_t v;
+};
+
+__noreturn __libc_init(uintptr_t *elfdata, void (*onexit)(void))
+{
+ int argc;
+ char **argv, **envp, **envend;
+ struct auxentry *auxentry;
+#if SHARED
+ typedef int (*main_t)(int, char **, char **);
+ main_t MAIN = NULL;
+#else
+ extern int main(int, char **, char **);
+#define MAIN main
+#endif
+ unsigned int page_size = 0, page_shift = 0;
+
+ (void)onexit; /* For now, we ignore this... */
+
+ argc = (int)*elfdata++;
+ argv = (char **)elfdata;
+ envp = argv+(argc+1);
+
+ /* The auxillary entry vector is after all the environment vars */
+ for ( envend = envp ; *envend ; envend++ );
+ auxentry = (struct auxentry *)(envend+1);
+
+ while ( auxentry->type ) {
+ switch ( auxentry->type ) {
+#if SHARED
+ case AT_ENTRY:
+ MAIN = (main_t)(auxentry->v);
+ break;
+#endif
+ case AT_PAGESZ:
+ page_size = (int)(auxentry->v);
+ break;
+ }
+ auxentry++;
+ }
+
+ __page_size = page_size;
+
+#if defined(__i386__) || defined(__x86_64__)
+ asm("bsrl %1,%0" : "=r" (page_shift) : "rm" (page_size));
+#else
+ while ( page_size > 1 ) {
+ page_shift++;
+ page_size >>= 1;
+ }
+#endif
+ __page_shift = page_shift;
+
+ environ = envp;
+ exit(MAIN(argc, argv, envp));
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__divdi3.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__divdi3.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+/*
+ * arch/i386/libgcc/__divdi3.c
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem);
+
+int64_t __divdi3(int64_t num, int64_t den)
+{
+ int minus = 0;
+ int64_t v;
+
+ if ( num < 0 ) {
+ num = -num;
+ minus = 1;
+ }
+ if ( den < 0 ) {
+ den = -den;
+ minus ^= 1;
+ }
+
+ v = __udivmoddi4(num, den, NULL);
+ if ( minus )
+ v = -v;
+
+ return v;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__divsi3.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__divsi3.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+/*
+ * libgcc/__divsi3.c
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t *rem);
+
+int32_t __divsi3(int32_t num, int32_t den)
+{
+ int minus = 0;
+ int32_t v;
+
+ if ( num < 0 ) {
+ num = -num;
+ minus = 1;
+ }
+ if ( den < 0 ) {
+ den = -den;
+ minus ^= 1;
+ }
+
+ v = __udivmodsi4(num, den, NULL);
+ if ( minus )
+ v = -v;
+
+ return v;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__moddi3.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__moddi3.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+/*
+ * arch/i386/libgcc/__moddi3.c
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem);
+
+int64_t __moddi3(int64_t num, int64_t den)
+{
+ int minus = 0;
+ int64_t v;
+
+ if ( num < 0 ) {
+ num = -num;
+ minus = 1;
+ }
+ if ( den < 0 ) {
+ den = -den;
+ minus ^= 1;
+ }
+
+ (void) __udivmoddi4(num, den, &v);
+ if ( minus )
+ v = -v;
+
+ return v;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__modsi3.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__modsi3.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+/*
+ * libgcc/__modsi3.c
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t *rem);
+
+int32_t __modsi3(int32_t num, int32_t den)
+{
+ int minus = 0;
+ int32_t v;
+
+ if ( num < 0 ) {
+ num = -num;
+ minus = 1;
+ }
+ if ( den < 0 ) {
+ den = -den;
+ minus ^= 1;
+ }
+
+ (void) __udivmodsi4(num, den, &v);
+ if ( minus )
+ v = -v;
+
+ return v;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__udivdi3.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__udivdi3.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * arch/i386/libgcc/__divdi3.c
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem);
+
+uint64_t __udivdi3(uint64_t num, uint64_t den)
+{
+ return __udivmoddi4(num, den, NULL);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__udivmoddi4.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__udivmoddi4.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,32 @@
+#include <klibc/diverr.h>
+#include <stdint.h>
+
+uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem_p)
+{
+ uint64_t quot = 0, qbit = 1;
+
+ if ( den == 0 ) {
+ __divide_error();
+ return 0; /* If trap returns... */
+ }
+
+ /* Left-justify denominator and count shift */
+ while ( (int64_t)den >= 0 ) {
+ den <<= 1;
+ qbit <<= 1;
+ }
+
+ while ( qbit ) {
+ if ( den <= num ) {
+ num -= den;
+ quot += qbit;
+ }
+ den >>= 1;
+ qbit >>= 1;
+ }
+
+ if ( rem_p )
+ *rem_p = num;
+
+ return quot;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__udivmodsi4.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__udivmodsi4.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,32 @@
+#include <klibc/diverr.h>
+#include <stdint.h>
+
+uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t *rem_p)
+{
+ uint32_t quot = 0, qbit = 1;
+
+ if ( den == 0 ) {
+ __divide_error();
+ return 0; /* If trap returns... */
+ }
+
+ /* Left-justify denominator and count shift */
+ while ( (int32_t)den >= 0 ) {
+ den <<= 1;
+ qbit <<= 1;
+ }
+
+ while ( qbit ) {
+ if ( den <= num ) {
+ num -= den;
+ quot += qbit;
+ }
+ den >>= 1;
+ qbit >>= 1;
+ }
+
+ if ( rem_p )
+ *rem_p = num;
+
+ return quot;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__udivsi3.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__udivsi3.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * libgcc/__divsi3.c
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t *rem);
+
+uint32_t __udivsi3(uint32_t num, uint32_t den)
+{
+ return __udivmodsi4(num, den, NULL);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__umoddi3.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__umoddi3.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * arch/i386/libgcc/__umoddi3.c
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t *rem);
+
+uint64_t __umoddi3(uint64_t num, uint64_t den)
+{
+ uint64_t v;
+
+ (void) __udivmoddi4(num, den, &v);
+ return v;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__umodsi3.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/libgcc/__umodsi3.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * libgcc/__umodsi3.c
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+
+extern uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t *rem);
+
+uint32_t __umodsi3(uint32_t num, uint32_t den)
+{
+ uint32_t v;
+
+ (void) __udivmodsi4(num, den, &v);
+ return v;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/llseek.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/llseek.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+/*
+ * llseek.c
+ *
+ * On 32-bit platforms, we need to use the _llseek() system call
+ * rather than lseek(), to be able to handle large disks. _llseek()
+ * isn't just a normal syscall which takes a 64-bit argument; it needs
+ * to return a 64-bit value and so takes an extra pointer.
+ */
+
+#include <unistd.h>
+#include <sys/syscall.h>
+
+#if BITSIZE == 32
+
+extern int __llseek(int fd, unsigned long hi, unsigned long lo, off_t *res, int whence);
+
+off_t lseek(int fd, off_t offset, int whence)
+{
+ off_t result;
+ int rv;
+
+ rv = __llseek(fd, (unsigned long)(offset >> 32), (unsigned long)offset,
+ &result, whence);
+
+ return rv ? (off_t)-1 : result;
+}
+
+#endif
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/lrand48.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/lrand48.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * lrand48.c
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+
+unsigned short __rand48_seed[3]; /* Common with mrand48.c, srand48.c */
+
+long lrand48(void)
+{
+ return (uint32_t)jrand48(__rand48_seed) >> 1;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/makeerrlist.pl
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/makeerrlist.pl Fri Mar 4 08:05:19 2005
@@ -0,0 +1,100 @@
+#!/usr/bin/perl
+#
+# This creates sys_errlist from <asm/errno.h> through somewhat
+# heuristic matching. It presumes the relevant entries are of the form
+# #define Exxxx <integer> /* comment */
+#
+
+use FileHandle;
+
+%errors = ();
+%errmsg = ();
+$maxerr = -1;
+ at includelist = (); # Include directories
+
+sub parse_file($) {
+ my($file) = @_;
+ my($fh) = new FileHandle;
+ my($line, $error, $msg);
+ my($kernelonly) = 0;
+ my($root);
+
+ print STDERR "opening $file\n" unless ( $quiet );
+
+ $ok = 0;
+ foreach $root ( @includelist ) {
+ if ( $fh->open($root.'//'.$file, '<') ) {
+ $ok = 1;
+ last;
+ }
+ }
+
+ if ( ! $ok ) {
+ die "$0: Cannot find file $file\n";
+ }
+
+ while ( defined($line = <$fh>) ) {
+ if ( $kernelonly ) {
+ if ( $line =~ /^\#\s*endif/ ) {
+ $kernelonly--;
+ } elsif ( $line =~ /^\#\sif/ ) {
+ $kernelonly++;
+ }
+ } else {
+ if ( $line =~ /^\#\s*define\s+([A-Z0-9_]+)\s+([0-9]+)\s*\/\*\s*(.*\S)\s*\*\// ) {
+ $error = $1;
+ $errno = $2+0;
+ $msg = $3;
+ print STDERR "$error ($errno) => \"$msg\"\n" unless ( $quiet );
+ $errors{$errno} = $error;
+ $errmsg{$errno} = $msg;
+ $maxerr = $errno if ( $errno > $maxerr );
+ } elsif ( $line =~ /^\#\s*include\s+[\<\"](.*)[\>\"]/ ) {
+ parse_file($1);
+ } elsif ( $line =~ /^\#\s*ifdef\s+__KERNEL__/ ) {
+ $kernelonly++;
+ }
+ }
+ }
+ close($fh);
+ print STDERR "closing $file\n" unless ( $quiet );
+}
+
+$v = $ENV{'KBUILD_VERBOSE'};
+$quiet = defined($v) ? !$v : 0;
+
+foreach $arg ( @ARGV ) {
+ if ( $arg eq '-q' ) {
+ $quiet = 1;
+ } elsif ( $arg =~ /^-(errlist|errnos|maxerr)$/ ) {
+ $type = $arg;
+ } elsif ( $arg =~ '^\-I' ) {
+ push(@includelist, "$'");
+ } else {
+ die "$0: Unknown option: $arg\n";
+ }
+}
+
+parse_file('linux/errno.h');
+
+if ( $type eq '-errlist' ) {
+ print "#include <errno.h>\n";
+ printf "const int sys_nerr = %d;\n", $maxerr+1;
+ printf "const char * const sys_errlist[%d] = {\n", $maxerr+1;
+ foreach $e ( sort(keys(%errors)) ) {
+ printf " [%s] = \"%s\",\n", $errors{$e}, $errmsg{$e};
+ }
+ print "};\n";
+} elsif ( $type eq '-errnos' ) {
+ print "#include <errno.h>\n";
+ printf "const int sys_nerr = %d;\n", $maxerr+1;
+ printf "const char * const sys_errlist[%d] = {\n", $maxerr+1;
+ foreach $e ( sort(keys(%errors)) ) {
+ printf " [%s] = \"%s\",\n", $errors{$e}, $errors{$e};
+ }
+ print "};\n";
+} elsif ( $type eq '-maxerr' ) {
+ print $maxerr, "\n";
+}
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/malloc.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/malloc.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,197 @@
+/*
+ * malloc.c
+ *
+ * Very simple linked-list based malloc()/free().
+ */
+
+#include <stdlib.h>
+#include <sys/mman.h>
+#include "malloc.h"
+
+struct free_arena_header __malloc_head =
+{
+ {
+ ARENA_TYPE_HEAD,
+ 0,
+ &__malloc_head,
+ &__malloc_head,
+ },
+ &__malloc_head,
+ &__malloc_head
+};
+
+static void *__malloc_from_block(struct free_arena_header *fp, size_t size)
+{
+ size_t fsize;
+ struct free_arena_header *nfp, *na;
+
+ fsize = fp->a.size;
+
+ /* We need the 2* to account for the larger requirements of a free block */
+ if ( fsize >= size+2*sizeof(struct arena_header) ) {
+ /* Bigger block than required -- split block */
+ nfp = (struct free_arena_header *)((char *)fp + size);
+ na = fp->a.next;
+
+ nfp->a.type = ARENA_TYPE_FREE;
+ nfp->a.size = fsize-size;
+ fp->a.type = ARENA_TYPE_USED;
+ fp->a.size = size;
+
+ /* Insert into all-block chain */
+ nfp->a.prev = fp;
+ nfp->a.next = na;
+ na->a.prev = nfp;
+ fp->a.next = nfp;
+
+ /* Replace current block on free chain */
+ nfp->next_free = fp->next_free;
+ nfp->prev_free = fp->prev_free;
+ fp->next_free->prev_free = nfp;
+ fp->prev_free->next_free = nfp;
+ } else {
+ /* Allocate the whole block */
+ fp->a.type = ARENA_TYPE_USED;
+
+ /* Remove from free chain */
+ fp->next_free->prev_free = fp->prev_free;
+ fp->prev_free->next_free = fp->next_free;
+ }
+
+ return (void *)(&fp->a + 1);
+}
+
+static struct free_arena_header *
+__free_block(struct free_arena_header *ah)
+{
+ struct free_arena_header *pah, *nah;
+
+ pah = ah->a.prev;
+ nah = ah->a.next;
+ if ( pah->a.type == ARENA_TYPE_FREE &&
+ (char *)pah+pah->a.size == (char *)ah ) {
+ /* Coalesce into the previous block */
+ pah->a.size += ah->a.size;
+ pah->a.next = nah;
+ nah->a.prev = pah;
+
+#ifdef DEBUG_MALLOC
+ ah->a.type = ARENA_TYPE_DEAD;
+#endif
+
+ ah = pah;
+ pah = ah->a.prev;
+ } else {
+ /* Need to add this block to the free chain */
+ ah->a.type = ARENA_TYPE_FREE;
+
+ ah->next_free = __malloc_head.next_free;
+ ah->prev_free = &__malloc_head;
+ __malloc_head.next_free = ah;
+ ah->next_free->prev_free = ah;
+ }
+
+ /* In either of the previous cases, we might be able to merge
+ with the subsequent block... */
+ if ( nah->a.type == ARENA_TYPE_FREE &&
+ (char *)ah+ah->a.size == (char *)nah ) {
+ ah->a.size += nah->a.size;
+
+ /* Remove the old block from the chains */
+ nah->next_free->prev_free = nah->prev_free;
+ nah->prev_free->next_free = nah->next_free;
+ ah->a.next = nah->a.next;
+ nah->a.next->a.prev = ah;
+
+#ifdef DEBUG_MALLOC
+ nah->a.type = ARENA_TYPE_DEAD;
+#endif
+ }
+
+ /* Return the block that contains the called block */
+ return ah;
+}
+
+void *malloc(size_t size)
+{
+ struct free_arena_header *fp;
+ struct free_arena_header *pah;
+ size_t fsize;
+
+ if ( size == 0 )
+ return NULL;
+
+ /* Add the obligatory arena header, and round up */
+ size = (size+2*sizeof(struct arena_header)-1) & ARENA_SIZE_MASK;
+
+ for ( fp = __malloc_head.next_free ; fp->a.type != ARENA_TYPE_HEAD ;
+ fp = fp->next_free ) {
+ if ( fp->a.size >= size ) {
+ /* Found fit -- allocate out of this block */
+ return __malloc_from_block(fp, size);
+ }
+ }
+
+ /* Nothing found... need to request a block from the kernel */
+ fsize = (size+MALLOC_CHUNK_MASK) & ~MALLOC_CHUNK_MASK;
+
+#ifdef MALLOC_USING_SBRK
+ fp = (struct free_arena_header *) sbrk(fsize);
+#else
+ fp = (struct free_arena_header *)
+ mmap(NULL, fsize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+#endif
+
+ if ( fp == (struct free_arena_header *)MAP_FAILED ) {
+ return NULL; /* Failed to get a block */
+ }
+
+ /* Insert the block into the management chains. We need to set
+ up the size and the main block list pointer, the rest of
+ the work is logically identical to free(). */
+ fp->a.type = ARENA_TYPE_FREE;
+ fp->a.size = fsize;
+
+ /* We need to insert this into the main block list in the proper
+ place -- this list is required to be sorted. Since we most likely
+ get memory assignments in ascending order, search backwards for
+ the proper place. */
+ for ( pah = __malloc_head.a.prev ; pah->a.type != ARENA_TYPE_HEAD ;
+ pah = pah->a.prev ) {
+ if ( pah < fp )
+ break;
+ }
+
+ /* Now pah points to the node that should be the predecessor of
+ the new node */
+ fp->a.next = pah->a.next;
+ fp->a.prev = pah;
+ pah->a.next = fp;
+ fp->a.next->a.prev = fp;
+
+
+ /* Insert into the free chain and coalesce with adjacent blocks */
+ fp = __free_block(fp);
+
+ /* Now we can allocate from this block */
+ return __malloc_from_block(fp, size);
+}
+
+void free(void *ptr)
+{
+ struct free_arena_header *ah;
+
+ if ( !ptr )
+ return;
+
+ ah = (struct free_arena_header *)
+ ((struct arena_header *)ptr - 1);
+
+#ifdef DEBUG_MALLOC
+ assert( ah->a.type == ARENA_TYPE_USED );
+#endif
+
+ __free_block(ah);
+
+ /* Here we could insert code to return memory to the system. */
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/malloc.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/malloc.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,45 @@
+/*
+ * malloc.h
+ *
+ * Internals for the memory allocator
+ */
+
+#include <stdint.h>
+#include <stddef.h>
+#include <klibc/sysconfig.h>
+
+/*
+ * This structure should be a power of two. This becomes the
+ * alignment unit.
+ */
+struct free_arena_header;
+
+struct arena_header {
+ size_t type;
+ size_t size; /* Also gives the location of the next entry */
+ struct free_arena_header *next, *prev;
+};
+
+#ifdef DEBUG_MALLOC
+#define ARENA_TYPE_USED 0x64e69c70
+#define ARENA_TYPE_FREE 0x012d610a
+#define ARENA_TYPE_HEAD 0x971676b5
+#define ARENA_TYPE_DEAD 0xeeeeeeee
+#else
+#define ARENA_TYPE_USED 0
+#define ARENA_TYPE_FREE 1
+#define ARENA_TYPE_HEAD 2
+#endif
+
+#define ARENA_SIZE_MASK (~(sizeof(struct arena_header)-1))
+
+/*
+ * This structure should be no more than twice the size of the
+ * previous structure.
+ */
+struct free_arena_header {
+ struct arena_header a;
+ struct free_arena_header *next_free, *prev_free;
+};
+
+extern struct free_arena_header __malloc_head;
Added: multipath-tools/upstream/current/klibc-0.190/klibc/memccpy.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/memccpy.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+/*
+ * memccpy.c
+ *
+ * memccpy()
+ */
+
+#include <stddef.h>
+#include <string.h>
+
+void *memccpy(void *dst, const void *src, int c, size_t n)
+{
+ char *q = dst;
+ const char *p = src;
+ char ch;
+
+ while ( n-- ) {
+ *q++ = ch = *p++;
+ if ( ch == (char)c )
+ return q;
+ }
+
+ return NULL; /* No instance of "c" found */
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/memchr.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/memchr.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+/*
+ * memchr.c
+ */
+
+#include <stddef.h>
+#include <string.h>
+
+void *memchr(const void *s, int c, size_t n)
+{
+ const unsigned char *sp = s;
+
+ while ( n-- ) {
+ if ( *sp == (unsigned char)c )
+ return (void *)sp;
+ }
+
+ return NULL;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/memcmp.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/memcmp.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * memcmp.c
+ */
+
+#include <string.h>
+
+int memcmp(const void *s1, const void *s2, size_t n)
+{
+ const unsigned char *c1 = s1, *c2 = s2;
+ int d = 0;
+
+ while ( n-- ) {
+ d = (int)*c1++ - (int)*c2++;
+ if ( d )
+ break;
+ }
+
+ return d;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/memcpy.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/memcpy.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+/*
+ * memcpy.c
+ */
+
+#include <string.h>
+#include <stdint.h>
+
+void *memcpy(void *dst, const void *src, size_t n)
+{
+ const char *p = src;
+ char *q = dst;
+#if defined(__i386__)
+ size_t nl = n >> 2;
+ asm volatile("cld ; rep ; movsl ; movl %3,%0 ; rep ; movsb"
+ : "+c" (nl), "+S" (p), "+D" (q)
+ : "r" (n & 3));
+#elif defined(__x86_64__)
+ size_t nq = n >> 3;
+ asm volatile("cld ; rep ; movsq ; movl %3,%%ecx ; rep ; movsb"
+ : "+c" (nq), "+S" (p), "+D" (q)
+ : "r" ((uint32_t)(n & 7)));
+#else
+ while ( n-- ) {
+ *q++ = *p++;
+ }
+#endif
+
+ return dst;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/memmem.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/memmem.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,44 @@
+/*
+ * memmem.c
+ *
+ * Find a byte string inside a longer byte string
+ *
+ * This uses the "Not So Naive" algorithm, a very simple but
+ * usually effective algorithm, see:
+ *
+ * http://www-igm.univ-mlv.fr/~lecroq/string/
+ */
+
+#include <string.h>
+
+void *memmem(const void *haystack, size_t n, const void *needle, size_t m)
+{
+ const unsigned char *y = (const unsigned char *)haystack;
+ const unsigned char *x = (const unsigned char *)needle;
+
+ size_t j, k, l;
+
+ if ( m > n )
+ return NULL;
+
+ if ( x[0] == x[1] ) {
+ k = 2;
+ l = 1;
+ } else {
+ k = 1;
+ l = 2;
+ }
+
+ j = 0;
+ while ( j <= n-m ) {
+ if (x[1] != y[j+1]) {
+ j += k;
+ } else {
+ if ( !memcmp(x+2, y+j+2, m-2) && x[0] == y[j] )
+ return (void *)&y[j];
+ j += l;
+ }
+ }
+
+ return NULL;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/memmove.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/memmove.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,34 @@
+/*
+ * memmove.c
+ */
+
+#include <string.h>
+
+void *memmove(void *dst, const void *src, size_t n)
+{
+ const char *p = src;
+ char *q = dst;
+#if defined(__i386__) || defined(__x86_64__)
+ if ( q < p ) {
+ asm volatile("cld ; rep ; movsb" : "+c" (n), "+S" (p), "+D" (q));
+ } else {
+ p += (n-1);
+ q += (n-1);
+ asm volatile("std ; rep ; movsb" : "+c" (n), "+S" (p), "+D" (q));
+ }
+#else
+ if ( q < p ) {
+ while ( n-- ) {
+ *q++ = *p++;
+ }
+ } else {
+ p += n;
+ q += n;
+ while ( n-- ) {
+ *--q = *--p;
+ }
+ }
+#endif
+
+ return dst;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/memset.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/memset.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,30 @@
+/*
+ * memset.c
+ */
+
+#include <string.h>
+#include <stdint.h>
+
+void *memset(void *dst, int c, size_t n)
+{
+ char *q = dst;
+
+#if defined(__i386__)
+ size_t nl = n >> 2;
+ asm volatile("cld ; rep ; stosl ; movl %3,%0 ; rep ; stosb"
+ : "+c" (nl), "+D" (q)
+ : "a" ((unsigned char)c * 0x01010101U), "r" (n & 3));
+#elif defined(__x86_64__)
+ size_t nq = n >> 3;
+ asm volatile("cld ; rep ; stosq ; movl %3,%%ecx ; rep ; stosb"
+ : "+c" (nq), "+D" (q)
+ : "a" ((unsigned char)c * 0x0101010101010101U),
+ "r" ((uint32_t)n & 7));
+#else
+ while ( n-- ) {
+ *q++ = c;
+ }
+#endif
+
+ return dst;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/memswap.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/memswap.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+/*
+ * memswap()
+ *
+ * Swaps the contents of two nonoverlapping memory areas.
+ * This really could be done faster...
+ */
+
+#include <string.h>
+
+void memswap(void *m1, void *m2, size_t n)
+{
+ char *p = m1;
+ char *q = m2;
+ char tmp;
+
+ while ( n-- ) {
+ tmp = *p;
+ *p = *q;
+ *q = tmp;
+
+ p++; q++;
+ }
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/mmap.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/mmap.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,49 @@
+/*
+ * mmap.c
+ */
+
+#include <stdint.h>
+#include <errno.h>
+#include <sys/syscall.h>
+#include <sys/mman.h>
+#include <unistd.h>
+#include <asm/page.h> /* For PAGE_SHIFT */
+
+#if defined(__sparc__)
+# define MMAP2_SHIFT 12 /* Fixed by syscall definition */
+#elif defined(__mips__) || defined(__powerpc__)
+# define MMAP2_SHIFT __getpageshift() /* Variable */
+#else
+# define MMAP2_SHIFT PAGE_SHIFT
+#endif
+
+/*
+ * Set in SYSCALLS whether or not we should use an unadorned mmap() system
+ * call (typical on 64-bit architectures).
+ */
+#if (BITSIZE == 32 && defined(__NR_mmap2)) || (BITSIZE == 64 && !defined(__NR_mmap))
+
+/* This architecture uses mmap2(). The Linux mmap2() system call takes
+ a page offset as the offset argument. We need to make sure we have
+ the proper conversion in place. */
+
+extern void *__mmap2(void *, size_t, int, int, int, size_t);
+
+void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
+{
+ const int mmap2_shift = MMAP2_SHIFT;
+ const unsigned long mmap2_mask = (1UL << mmap2_shift) - 1;
+
+ if ( offset & mmap2_mask ) {
+ errno = EINVAL;
+ return MAP_FAILED;
+ }
+
+ return __mmap2(start, length, prot, flags, fd, (size_t)offset >> mmap2_shift);
+}
+
+#endif
+
+
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/mrand48.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/mrand48.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * mrand48.c
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+
+unsigned short __rand48_seed[3]; /* Common with lrand48.c, srand48.c */
+
+long mrand48(void)
+{
+ return jrand48(__rand48_seed);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/nice.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/nice.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+/*
+ * nice.c
+ */
+
+#include <unistd.h>
+#include <sched.h>
+#include <sys/resource.h>
+#include <sys/syscall.h>
+
+#ifndef __NR_nice
+
+int nice(int inc)
+{
+ pid_t me = getpid();
+ return setpriority(me, PRIO_PROCESS, getpriority(me, PRIO_PROCESS)+inc);
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/nrand48.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/nrand48.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+/*
+ * nrand48.c
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+
+long nrand48(unsigned short xsubi[3])
+{
+ return (long)((uint32_t)jrand48(xsubi) >> 1);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/onexit.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/onexit.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,39 @@
+/*
+ * onexit.c
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include "atexit.h"
+
+extern __noreturn (*__exit_handler)(int);
+static struct atexit *__atexit_list;
+
+static __noreturn on_exit_exit(int rv)
+{
+ struct atexit *ap;
+
+ for ( ap = __atexit_list ; ap ; ap = ap->next ) {
+ ap->fctn(rv, ap->arg); /* This assumes extra args are harmless */
+ }
+
+ _exit(rv);
+}
+
+int on_exit(void (*fctn)(int, void *), void *arg)
+{
+ struct atexit *as = malloc(sizeof(struct atexit));
+
+ if ( !as )
+ return -1;
+
+ as->fctn = fctn;
+ as->arg = arg;
+
+ as->next = __atexit_list;
+ __atexit_list = as;
+
+ __exit_handler = on_exit_exit;
+
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/open.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/open.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,21 @@
+/*
+ * open.c
+ *
+ * On 32-bit platforms we need to pass O_LARGEFILE to the open()
+ * system call, to indicate that we're 64-bit safe.
+ */
+
+#define _KLIBC_IN_OPEN_C
+#include <unistd.h>
+#include <fcntl.h>
+
+#if BITSIZE == 32 && !defined(__i386__)
+
+extern int __open(const char *, int, mode_t);
+
+int open(const char *pathname, int flags, mode_t mode)
+{
+ return __open(pathname, flags|O_LARGEFILE, mode);
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/pause.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/pause.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,17 @@
+/*
+ * pause.c
+ */
+
+#include <stddef.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/syscall.h>
+
+#ifndef __NR_pause
+
+int pause(void)
+{
+ return select(0,NULL,NULL,NULL,NULL);
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/perror.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/perror.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * perror.c
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+void perror(const char *s)
+{
+ int e = errno;
+ fprintf(stderr, "%s: %s\n", s, strerror(e));
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/printf.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/printf.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * printf.c
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#define BUFFER_SIZE 16384
+
+int printf(const char *format, ...)
+{
+ va_list ap;
+ int rv;
+
+ va_start(ap, format);
+ rv = vfprintf(stdout, format, ap);
+ va_end(ap);
+ return rv;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/pty.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/pty.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,31 @@
+/*
+ * pty.c
+ *
+ * Basic Unix98 PTY functionality; assumes devpts mounted on /dev/pts
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+char *ptsname(int fd)
+{
+ static char buffer[32]; /* Big enough to hold even a 64-bit pts no */
+ unsigned int ptyno;
+
+ if ( ioctl(fd, TIOCGPTN, &ptyno) )
+ return NULL;
+
+ snprintf(buffer, sizeof buffer, "/dev/pts/%u", ptyno);
+
+ return buffer;
+}
+
+int unlockpt(int fd)
+{
+ int unlock = 0;
+
+ return ioctl(fd, TIOCSPTLCK, &unlock);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/putchar.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/putchar.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * putchar.c
+ *
+ * - gcc wants this
+ */
+
+#include <stdio.h>
+
+#undef putchar /* Defined as a macro */
+int putchar(int);
+
+int putchar(int c)
+{
+ return fputc(c, stdout);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/putenv.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/putenv.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,40 @@
+/*
+ * putenv.c
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* str should be a duplicated version of the input string;
+ len is the length of the key including the = sign */
+int __put_env(char *str, size_t len, int overwrite);
+
+int putenv(const char *str)
+{
+ char *s;
+ const char *e, *z;
+
+ if ( !str ) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ e = NULL;
+ for ( z = str ; *z ; z++ ) {
+ if ( *z == '=' )
+ e = z;
+ }
+
+ if ( !e ) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ s = strdup(str);
+ if ( !s )
+ return -1;
+
+ return __put_env(s, e-str, 1);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/puts.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/puts.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * puts.c
+ */
+
+#include <stdio.h>
+
+int puts(const char *s)
+{
+ if ( fputs(s, stdout) < 0 )
+ return -1;
+
+ return _fwrite("\n", 1, stdout);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/qsort.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/qsort.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,42 @@
+/*
+ * qsort.c
+ *
+ * This is actually combsort. It's an O(n log n) algorithm with
+ * simplicity/small code size being its main virtue.
+ */
+
+#include <stddef.h>
+#include <string.h>
+
+static inline size_t newgap(size_t gap)
+{
+ gap = (gap*10)/13;
+ if ( gap == 9 || gap == 10 )
+ gap = 11;
+
+ if ( gap < 1 )
+ gap = 1;
+ return gap;
+}
+
+void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *))
+{
+ size_t gap = nmemb;
+ size_t i, j;
+ char *p1, *p2;
+ int swapped;
+
+ do {
+ gap = newgap(gap);
+ swapped = 0;
+
+ for ( i = 0, p1 = base ; i < nmemb-gap ; i++, p1 += size ) {
+ j = i+gap;
+ if ( compar(p1, p2 = (char *)base+j*size) > 0 ) {
+ memswap(p1, p2, size);
+ swapped = 1;
+ }
+ }
+ } while ( gap > 1 || swapped );
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/raise.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/raise.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+/*
+ * raise.c
+ */
+
+#include <unistd.h>
+#include <signal.h>
+
+int raise(int signal)
+{
+ return kill(getpid(), signal);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/readdir.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/readdir.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,57 @@
+/*
+ * readdir.c: opendir/readdir/closedir
+ */
+
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+
+#define __KLIBC_DIRENT_INTERNALS
+#include <dirent.h>
+
+DIR *opendir(const char *name)
+{
+ DIR *dp = malloc(sizeof(DIR));
+
+ if ( !dp )
+ return NULL;
+
+ dp->__fd = open(name, O_DIRECTORY|O_RDONLY);
+
+ if ( dp->__fd < 0 ) {
+ free(dp);
+ return NULL;
+ }
+
+ dp->bytes_left = 0;
+
+ return dp;
+}
+
+struct dirent *readdir(DIR *dir)
+{
+ struct dirent *dent;
+ int rv;
+
+ if ( !dir->bytes_left ) {
+ rv = getdents(dir->__fd, dir->buffer, sizeof(dir->buffer));
+ if ( rv <= 0 )
+ return NULL;
+ dir->bytes_left = rv;
+ dir->next = dir->buffer;
+ }
+
+ dent = dir->next;
+ dir->next = (struct dirent *)((char *)dir->next + dent->d_reclen);
+ dir->bytes_left -= dent->d_reclen;
+
+ return dent;
+}
+
+int closedir(DIR *dir)
+{
+ int rv;
+ rv = close(dir->__fd);
+ free(dir);
+ return rv;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/realloc.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/realloc.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,49 @@
+/*
+ * realloc.c
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "malloc.h"
+
+/* FIXME: This is cheesy, it should be fixed later */
+
+void *realloc(void *ptr, size_t size)
+{
+ struct free_arena_header *ah;
+ void *newptr;
+ size_t oldsize;
+
+ if ( !ptr )
+ return malloc(size);
+
+ if ( size == 0 ) {
+ free(ptr);
+ return NULL;
+ }
+
+ /* Add the obligatory arena header, and round up */
+ size = (size+2*sizeof(struct arena_header)-1) & ARENA_SIZE_MASK;
+
+ ah = (struct free_arena_header *)
+ ((struct arena_header *)ptr - 1);
+
+ if ( ah->a.size >= size && size >= (ah->a.size >> 2) ) {
+ /* This field is a good size already. */
+ return ptr;
+ } else {
+ /* Make me a new block. This is kind of bogus; we should
+ be checking the adjacent blocks to see if we can do an
+ in-place adjustment... fix that later. */
+
+ oldsize = ah->a.size - sizeof(struct arena_header);
+
+ newptr = malloc(size);
+ memcpy(newptr, ptr, (size < oldsize) ? size : oldsize);
+ free(ptr);
+
+ return newptr;
+ }
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/reboot.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/reboot.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * reboot.c
+ */
+
+#include <unistd.h>
+#include <sys/reboot.h>
+#include <sys/syscall.h>
+
+/* This provides the one-argument glibc-ish version of reboot.
+ The full four-argument system call is available as __reboot(). */
+
+int reboot(int flag)
+{
+ return __reboot(LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, flag, NULL);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/recv.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/recv.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+/*
+ * recv.c
+ */
+
+#include <stddef.h>
+#include <sys/socket.h>
+
+int recv(int s, void *buf, size_t len, unsigned int flags)
+{
+ return recvfrom(s, buf, len, flags, NULL, 0);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/sbrk.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/sbrk.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,41 @@
+/* sbrk.c - Change data segment size */
+
+/* Written 2000 by Werner Almesberger */
+/* Modified 2003-2004 for klibc by H. Peter Anvin */
+
+#include <stddef.h>
+#include <unistd.h>
+#include <inttypes.h>
+#include <errno.h>
+#include "malloc.h"
+
+char *__current_brk; /* Common with brk.c */
+
+/* p is an address, a is alignment; must be a power of 2 */
+static inline void *align_up(void *p, uintptr_t a)
+{
+ return (void *) (((uintptr_t)p + a-1) & ~(a-1));
+}
+
+void *sbrk(ptrdiff_t increment)
+{
+ char *start, *end, *new_brk;
+
+ if (!__current_brk)
+ __current_brk = __brk(NULL);
+
+ start = align_up(__current_brk, SBRK_ALIGNMENT);
+ end = start + increment;
+
+ new_brk = __brk(end);
+
+ if (new_brk == (void *)-1)
+ return (void *)-1;
+ else if (new_brk < end) {
+ errno = ENOMEM;
+ return (void *) -1;
+ }
+
+ __current_brk = new_brk;
+ return start;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/seed48.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/seed48.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * seed48.c
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+unsigned short __rand48_seed[3];
+
+unsigned short *seed48(const unsigned short xsubi[3])
+{
+ static unsigned short oldseed[3];
+ memcpy(oldseed, __rand48_seed, sizeof __rand48_seed);
+ memcpy(__rand48_seed, xsubi, sizeof __rand48_seed);
+
+ return oldseed;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/send.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/send.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+/*
+ * send.c
+ */
+
+#include <stddef.h>
+#include <sys/socket.h>
+
+int send(int s, const void *buf, size_t len, unsigned int flags)
+{
+ return sendto(s, buf, len, flags, NULL, 0);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/setegid.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/setegid.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+/*
+ * setegid.c
+ */
+
+#include <unistd.h>
+
+int setegid(gid_t egid)
+{
+ return setregid(-1, egid);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/setenv.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/setenv.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,45 @@
+/*
+ * setenv.c
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* str should be a duplicated version of the input string;
+ len is the length of the key including the = sign */
+int __put_env(char *str, size_t len, int overwrite);
+
+int setenv(const char *name, const char *val, int overwrite)
+{
+ const char *z;
+ char *s;
+ size_t l1, l2;
+
+ if ( !name || !name[0] ) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ l1 = 0;
+ for ( z = name ; *z ; z++ ) {
+ l1++;
+ if ( *z == '=' ) {
+ errno = EINVAL;
+ return -1;
+ }
+ }
+
+ l2 = strlen(val);
+
+ s = malloc(l1+l2+2);
+ if ( !s )
+ return -1;
+
+ memcpy(s, name, l1);
+ s[l1] = '=';
+ memcpy(s+l1+1, val, l2+1);
+
+ return __put_env(s, l1+1, overwrite);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/seteuid.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/seteuid.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+/*
+ * seteuid.c
+ */
+
+#include <unistd.h>
+
+int seteuid(uid_t euid)
+{
+ return setreuid(-1, euid);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/setpgrp.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/setpgrp.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+/*
+ * setpgrp.c
+ */
+
+#include <unistd.h>
+
+int setpgrp(void)
+{
+ return setpgid(0,0);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/sha1hash.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/sha1hash.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,317 @@
+/*
+SHA-1 in C
+By Steve Reid <sreid at sea-to-sky.net>
+100% Public Domain
+
+-----------------
+Modified 7/98
+By James H. Brown <jbrown at burgoyne.com>
+Still 100% Public Domain
+
+Corrected a problem which generated improper hash values on 16 bit machines
+Routine SHA1Update changed from
+ void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int
+len)
+to
+ void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned
+long len)
+
+The 'len' parameter was declared an int which works fine on 32 bit machines.
+However, on 16 bit machines an int is too small for the shifts being done
+against
+it. This caused the hash function to generate incorrect values if len was
+greater than 8191 (8K - 1) due to the 'len << 3' on line 3 of SHA1Update().
+
+Since the file IO in main() reads 16K at a time, any file 8K or larger would
+be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million
+"a"s).
+
+I also changed the declaration of variables i & j in SHA1Update to
+unsigned long from unsigned int for the same reason.
+
+These changes should make no difference to any 32 bit implementations since
+an
+int and a long are the same size in those environments.
+
+--
+I also corrected a few compiler warnings generated by Borland C.
+1. Added #include <process.h> for exit() prototype
+2. Removed unused variable 'j' in SHA1Final
+3. Changed exit(0) to return(0) at end of main.
+
+ALL changes I made can be located by searching for comments containing 'JHB'
+-----------------
+Modified 8/98
+By Steve Reid <sreid at sea-to-sky.net>
+Still 100% public domain
+
+1- Removed #include <process.h> and used return() instead of exit()
+2- Fixed overwriting of finalcount in SHA1Final() (discovered by Chris Hall)
+3- Changed email address from steve at edmweb.com to sreid at sea-to-sky.net
+
+-----------------
+Modified 4/01
+By Saul Kravitz <Saul.Kravitz at celera.com>
+Still 100% PD
+Modified to run on Compaq Alpha hardware.
+
+-----------------
+Modified 2/03
+By H. Peter Anvin <hpa at zytor.com>
+Still 100% PD
+Modified to run on any hardware with <inttypes.h> and <netinet/in.h>
+Changed the driver program
+
+*/
+
+/*
+Test Vectors (from FIPS PUB 180-1)
+"abc"
+ A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
+"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
+ 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
+A million repetitions of "a"
+ 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
+*/
+
+/* #define SHA1HANDSOFF */
+
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+#include <netinet/in.h> /* For htonl/ntohl/htons/ntohs */
+
+/* #include <process.h> */ /* prototype for exit() - JHB */
+/* Using return() instead of exit() - SWR */
+
+typedef struct {
+ uint32_t state[5];
+ uint32_t count[2];
+ unsigned char buffer[64];
+} SHA1_CTX;
+
+void SHA1Transform(uint32_t state[5], unsigned char buffer[64]);
+void SHA1Init(SHA1_CTX* context);
+void SHA1Update(SHA1_CTX* context, unsigned char* data, uint32_t len); /*
+JHB */
+void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
+
+#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
+
+/* blk0() and blk() perform the initial expand. */
+/* I got the idea of expanding during the round function from SSLeay */
+#define blk0(i) (block->l[i] = ntohl(block->l[i]))
+#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
+ ^block->l[(i+2)&15]^block->l[i&15],1))
+
+/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
+#define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
+#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
+#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
+#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+
+
+#ifdef VERBOSE /* SAK */
+void SHAPrintContext(SHA1_CTX *context, char *msg){
+ printf("%s (%d,%d) %x %x %x %x %x\n",
+ msg,
+ context->count[0], context->count[1],
+ context->state[0],
+ context->state[1],
+ context->state[2],
+ context->state[3],
+ context->state[4]);
+}
+#endif
+
+/* Hash a single 512-bit block. This is the core of the algorithm. */
+
+void SHA1Transform(uint32_t state[5], unsigned char buffer[64])
+{
+uint32_t a, b, c, d, e;
+typedef union {
+ unsigned char c[64];
+ uint32_t l[16];
+} CHAR64LONG16;
+CHAR64LONG16* block;
+#ifdef SHA1HANDSOFF
+static unsigned char workspace[64];
+ block = (CHAR64LONG16*)workspace;
+ memcpy(block, buffer, 64);
+#else
+ block = (CHAR64LONG16*)buffer;
+#endif
+ /* Copy context->state[] to working vars */
+ a = state[0];
+ b = state[1];
+ c = state[2];
+ d = state[3];
+ e = state[4];
+ /* 4 rounds of 20 operations each. Loop unrolled. */
+ R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
+ R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
+ R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
+ R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
+ R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
+ R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
+ R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
+ R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
+ R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
+ R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
+ R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
+ R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
+ R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
+ R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
+ R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
+ R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
+ R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
+ R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
+ R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
+ R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+ /* Add the working vars back into context.state[] */
+ state[0] += a;
+ state[1] += b;
+ state[2] += c;
+ state[3] += d;
+ state[4] += e;
+ /* Wipe variables */
+ a = b = c = d = e = 0;
+}
+
+
+/* SHA1Init - Initialize new context */
+
+void SHA1Init(SHA1_CTX* context)
+{
+ /* SHA1 initialization constants */
+ context->state[0] = 0x67452301;
+ context->state[1] = 0xEFCDAB89;
+ context->state[2] = 0x98BADCFE;
+ context->state[3] = 0x10325476;
+ context->state[4] = 0xC3D2E1F0;
+ context->count[0] = context->count[1] = 0;
+}
+
+
+/* Run your data through this. */
+
+void SHA1Update(SHA1_CTX* context, unsigned char* data, uint32_t len) /*
+JHB */
+{
+uint32_t i, j; /* JHB */
+
+#ifdef VERBOSE
+ SHAPrintContext(context, "before");
+#endif
+ j = (context->count[0] >> 3) & 63;
+ if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++;
+ context->count[1] += (len >> 29);
+ if ((j + len) > 63) {
+ memcpy(&context->buffer[j], data, (i = 64-j));
+ SHA1Transform(context->state, context->buffer);
+ for ( ; i + 63 < len; i += 64) {
+ SHA1Transform(context->state, &data[i]);
+ }
+ j = 0;
+ }
+ else i = 0;
+ memcpy(&context->buffer[j], &data[i], len - i);
+#ifdef VERBOSE
+ SHAPrintContext(context, "after ");
+#endif
+}
+
+
+/* Add padding and return the message digest. */
+
+void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
+{
+uint32_t i; /* JHB */
+unsigned char finalcount[8];
+
+ for (i = 0; i < 8; i++) {
+ finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
+ >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
+ }
+ SHA1Update(context, (unsigned char *)"\200", 1);
+ while ((context->count[0] & 504) != 448) {
+ SHA1Update(context, (unsigned char *)"\0", 1);
+ }
+ SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform()
+*/
+ for (i = 0; i < 20; i++) {
+ digest[i] = (unsigned char)
+ ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
+ }
+ /* Wipe variables */
+ i = 0; /* JHB */
+ memset(context->buffer, 0, 64);
+ memset(context->state, 0, 20);
+ memset(context->count, 0, 8);
+ memset(finalcount, 0, 8); /* SWR */
+#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite it's own static vars */
+ SHA1Transform(context->state, context->buffer);
+#endif
+}
+
+/*************************************************************/
+
+/* This is not quite the MIME base64 algorithm: it uses _ instead of /,
+ and instead of padding the output with = characters we just make the
+ output shorter. */
+char *mybase64(uint8_t digest[20])
+{
+ static const char charz[] =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+_";
+ uint8_t input[21];
+ static char output[28];
+ int i, j;
+ uint8_t *p;
+ char *q;
+ uint32_t bv;
+
+ memcpy(input, digest, 20);
+ input[20] = 0; /* Pad to multiple of 3 bytes */
+
+ p = input; q = output;
+ for ( i = 0 ; i < 7 ; i++ ) {
+ bv = (p[0] << 16) | (p[1] << 8) | p[2];
+ p += 3;
+ for ( j = 0 ; j < 4 ; j++ ) {
+ *q++ = charz[(bv >> 18) & 0x3f];
+ bv <<= 6;
+ }
+ }
+ *--q = '\0'; /* The last character is not significant */
+ return output;
+}
+
+int main(int argc, char** argv)
+{
+ int i;
+ SHA1_CTX context;
+ uint8_t digest[20], buffer[16384];
+ FILE* file;
+
+ if (argc < 2) {
+ file = stdin;
+ }
+ else {
+ if (!(file = fopen(argv[1], "rb"))) {
+ fputs("Unable to open file.", stderr);
+ return(-1);
+ }
+ }
+ SHA1Init(&context);
+ while (!feof(file)) { /* note: what if ferror(file) */
+ i = fread(buffer, 1, 16384, file);
+ SHA1Update(&context, buffer, i);
+ }
+ SHA1Final(digest, &context);
+ fclose(file);
+
+ puts(mybase64(digest));
+
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/sigaction.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/sigaction.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * sigaction.c
+ */
+
+#include <signal.h>
+#include <sys/syscall.h>
+
+#if !defined(__NR_sigaction)
+
+int sigaction(int sig, const struct sigaction *act, struct sigaction *oact)
+{
+ return rt_sigaction(sig, act, oact, sizeof(sigset_t));
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/siglist.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/siglist.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,115 @@
+/*
+ * siglist.h
+ *
+ * Construct the signal list
+ */
+
+#include <signal.h>
+#include <unistd.h>
+
+const char * const sys_siglist[NSIG] = {
+#ifdef SIGABRT
+ [SIGABRT] = "Aborted",
+#endif
+#ifdef SIGALRM
+ [SIGALRM] = "Alarm clock",
+#endif
+#ifdef SIGBUS
+ [SIGBUS] = "Bus error",
+#endif
+#ifdef SIGCHLD
+ [SIGCHLD] = "Child exited",
+#endif
+#if defined(SIGCLD) && (SIGCHLD != SIGCLD)
+ [SIGCLD] = "Child exited",
+#endif
+#ifdef SIGEMT
+ [SIGEMT] = "Emulation trap",
+#endif
+#ifdef SIGFPE
+ [SIGFPE] = "Floating point exception",
+#endif
+#ifdef SIGHUP
+ [SIGHUP] = "Hangup",
+#endif
+#ifdef SIGILL
+ [SIGILL] = "Illegal instruction",
+#endif
+ /* SIGINFO == SIGPWR */
+#ifdef SIGINT
+ [SIGINT] = "Interrupt",
+#endif
+#ifdef SIGIO
+ [SIGIO] = "I/O possible",
+#endif
+#if defined(SIGIOT) && (SIGIOT != SIGABRT)
+ [SIGIOT] = "I/O trap",
+#endif
+#ifdef SIGKILL
+ [SIGKILL] = "Killed",
+#endif
+#if defined(SIGLOST) && (SIGLOST != SIGIO) && (SIGLOST != SIGPWR)
+ [SIGLOST] = "Lock lost",
+#endif
+#ifdef SIGPIPE
+ [SIGPIPE] = "Broken pipe",
+#endif
+#if defined(SIGPOLL) && (SIGPOLL != SIGIO)
+ [SIGPOLL] = "Pollable event",
+#endif
+#ifdef SIGPROF
+ [SIGPROF] = "Profiling timer expired",
+#endif
+#ifdef SIGPWR
+ [SIGPWR] = "Power failure",
+#endif
+#ifdef SIGQUIT
+ [SIGQUIT] = "Quit",
+#endif
+ /* SIGRESERVE == SIGUNUSED */
+#ifdef SIGSEGV
+ [SIGSEGV] = "Segment violation",
+#endif
+#ifdef SIGSTKFLT
+ [SIGSTKFLT] = "Stack fault",
+#endif
+#ifdef SIGSTOP
+ [SIGSTOP] = "Stopped (signal)",
+#endif
+#ifdef SIGSYS
+ [SIGSYS] = "Bad system call",
+#endif
+#ifdef SIGTERM
+ [SIGTERM] = "Terminated",
+#endif
+#ifdef SIGTSTP
+ [SIGTSTP] = "Stopped",
+#endif
+#ifdef SIGTTIN
+ [SIGTTIN] = "Stopped (tty input)",
+#endif
+#ifdef SIGTTOU
+ [SIGTTOU] = "Stopped (tty output)",
+#endif
+#ifdef SIGURG
+ [SIGURG] = "Urgent I/O condition",
+#endif
+#ifdef SIGUSR1
+ [SIGUSR1] = "User signal 1",
+#endif
+#ifdef SIGUSR2
+ [SIGUSR2] = "User signal 2",
+#endif
+#ifdef SIGVTALRM
+ [SIGVTALRM] = "Virtual timer expired",
+#endif
+#ifdef SIGWINCH
+ [SIGWINCH] = "Window size changed",
+#endif
+#ifdef SIGXCPU
+ [SIGXCPU] = "CPU time limit exceeded",
+#endif
+#ifdef SIGXFSZ
+ [SIGXFSZ] = "File size limit exceeded",
+#endif
+};
Added: multipath-tools/upstream/current/klibc-0.190/klibc/siglongjmp.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/siglongjmp.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * siglongjmp.c
+ *
+ * sigsetjmp() is a macro, by necessity (it's either that or write
+ * it in assembly), but siglongjmp() is a normal function.
+ */
+
+#include <setjmp.h>
+#include <signal.h>
+
+__noreturn siglongjmp(sigjmp_buf buf, int retval)
+{
+ sigprocmask(SIG_SETMASK, &buf->__sigs, NULL);
+ longjmp(buf->__jmpbuf, retval);
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/sigpending.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/sigpending.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * sigpending.c
+ */
+
+#include <signal.h>
+#include <sys/syscall.h>
+
+#ifndef __NR_sigpending
+
+int sigpending(sigset_t *set)
+{
+ return rt_sigpending(set, sizeof(sigset_t));
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/sigprocmask.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/sigprocmask.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * sigprocmask.c
+ */
+
+#include <signal.h>
+#include <sys/syscall.h>
+
+#ifndef __NR_sigprocmask
+
+int sigprocmask(int how, const sigset_t *set, sigset_t *oset)
+{
+ return rt_sigprocmask(how, set, oset, sizeof(sigset_t));
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/sigsuspend.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/sigsuspend.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * sigsuspend.c
+ */
+
+#include <signal.h>
+#include <sys/syscall.h>
+
+#ifndef __NR_sigsuspend
+
+int sigsuspend(const sigset_t *mask)
+{
+ return rt_sigsuspend(mask, sizeof *mask);
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/sleep.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/sleep.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,20 @@
+/*
+ * sleep.c
+ */
+
+#include <errno.h>
+#include <time.h>
+
+unsigned int sleep(unsigned int seconds)
+{
+ struct timespec ts;
+
+ ts.tv_sec = seconds;
+ ts.tv_nsec = 0;
+ if ( !nanosleep(&ts,&ts) )
+ return 0;
+ else if ( errno == EINTR )
+ return ts.tv_sec;
+ else
+ return -1;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/snprintf.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/snprintf.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * snprintf.c
+ */
+
+#include <stdio.h>
+
+int snprintf(char *buffer, size_t n, const char *format, ...)
+{
+ va_list ap;
+ int rv;
+
+ va_start(ap, format);
+ rv = vsnprintf(buffer, n, format, ap);
+ va_end(ap);
+ return rv;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/socketcalls.pl
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/socketcalls.pl Fri Mar 4 08:05:19 2005
@@ -0,0 +1,84 @@
+#!/usr/bin/perl
+
+$v = $ENV{'KBUILD_VERBOSE'};
+$quiet = defined($v) ? !$v : 0;
+
+ at args = ();
+for $arg ( @ARGV ) {
+ if ( $arg =~ /^-/ ) {
+ if ( $arg eq '-q' ) {
+ $quiet = 1;
+ } else {
+ die "$0: Unknown option: $arg\n";
+ }
+ } else {
+ push(@args, $arg);
+ }
+}
+($file, $arch) = @args;
+
+if (!open(FILE, "< $file")) {
+ die "$file: $!\n";
+}
+
+while ( defined($line = <FILE>) ) {
+ chomp $line;
+ $line =~ s/\s*[\#\;].*$//; # Strip comments and trailing blanks
+ next unless $line;
+
+ if ( $line =~ /^\s*\<\?\>\s*(.*)\s+([_a-zA-Z][_a-zA-Z0-9]+)\s*\((.*)\)$/ ) {
+ $type = $1;
+ $name = $2;
+ $argv = $3;
+
+ @args = split(/\s*\,\s*/, $argv);
+ @cargs = ();
+
+ $i = 0;
+ for $arg ( @args ) {
+ push(@cargs, "$arg a".$i++);
+ }
+ $nargs = $i;
+
+ if ( $arch eq 'i386' ) {
+ open(OUT, '>', "socketcalls/${name}.S")
+ or die "$0: Cannot open socketcalls/${name}.S\n";
+
+ print OUT "#include <sys/socketcalls.h>\n";
+ print OUT "\n";
+ print OUT "\t.text\n";
+ print OUT "\t.align 4\n";
+ print OUT "\t.globl ${name}\n";
+ print OUT "\t.type ${name},\@function\n";
+ print OUT "${name}:\n";
+ print OUT "\tmovb \$SYS_\U${name}\E,%al\n";
+ print OUT "\tjmp __socketcall_common\n";
+ print OUT "\t.size ${name},.-${name}\n";
+ close(OUT);
+ } else {
+ open(OUT, '>', "socketcalls/${name}.c")
+ or die "$0: Cannot open socketcalls/${name}.c\n";
+
+ print OUT "#include \"../socketcommon.h\"\n";
+ print OUT "\n";
+ print OUT "#ifndef __NR_${name}\n\n";
+
+ print OUT "extern long __socketcall(int, const unsigned long *);\n\n";
+
+ print OUT "$type $name (", join(', ', @cargs), ")\n";
+ print OUT "{\n";
+ print OUT " unsigned long args[$nargs];\n";
+ for ( $i = 0 ; $i < $nargs ; $i++ ) {
+ print OUT " args[$i] = (unsigned long)a$i;\n";
+ }
+ print OUT " return ($type) __socketcall(SYS_\U${name}\E, args);\n";
+ print OUT "}\n\n";
+
+ print OUT "#endif\n";
+
+ close(OUT);
+ }
+ } else {
+ die "$file:$.: Could not parse input\n";
+ }
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/socketcommon.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/socketcommon.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * socketcommon.h
+ *
+ * Common header file for socketcall stubs
+ */
+
+#define __IN_SYS_COMMON
+#include <errno.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <linux/net.h>
+#include <sys/socketcalls.h>
Added: multipath-tools/upstream/current/klibc-0.190/klibc/sprintf.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/sprintf.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+/*
+ * sprintf.c
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+
+int sprintf(char *buffer, const char *format, ...)
+{
+ va_list ap;
+ int rv;
+
+ va_start(ap, format);
+ rv = vsnprintf(buffer, ~(size_t)0, format, ap);
+ va_end(ap);
+
+ return rv;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/srand48.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/srand48.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * srand48.c
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+
+unsigned short __rand48_seed[3]; /* Common with mrand48.c, lrand48.c */
+
+void srand48(long seedval)
+{
+ __rand48_seed[0] = 0x330e;
+ __rand48_seed[1] = (unsigned short)seedval;
+ __rand48_seed[2] = (unsigned short)((uint32_t)seedval >> 16);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/sscanf.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/sscanf.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,17 @@
+/*
+ * sscanf()
+ */
+
+#include <stdio.h>
+
+int sscanf(const char *str, const char *format, ...)
+{
+ va_list ap;
+ int rv;
+
+ va_start(ap, format);
+ rv = vsscanf(str, format, ap);
+ va_end(ap);
+
+ return rv;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/statfs.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/statfs.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * statfs.c
+ *
+ * On architectures which do statfs64, wrap the system call
+ */
+
+#include <sys/syscall.h>
+#include <sys/vfs.h>
+
+#ifdef __NR_statfs64
+
+extern int __statfs64(const char *, size_t, struct statfs *);
+
+int statfs(const char *path, struct statfs *buf)
+{
+ return __statfs64(path, sizeof *buf, buf);
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strcasecmp.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strcasecmp.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+/*
+ * strcasecmp.c
+ */
+
+#include <string.h>
+#include <ctype.h>
+
+int strcasecmp(const char *s1, const char *s2)
+{
+ const unsigned char *c1 = s1, *c2 = s2;
+ unsigned char ch;
+ int d = 0;
+
+ while ( 1 ) {
+ /* toupper() expects an unsigned char (implicitly cast to int)
+ as input, and returns an int, which is exactly what we want. */
+ d = toupper(ch = *c1++) - toupper(*c2++);
+ if ( d || !ch )
+ break;
+ }
+
+ return d;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strcat.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strcat.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+/*
+ * strcat.c
+ */
+
+#include <string.h>
+
+char *strcat(char *dst, const char *src)
+{
+ strcpy(strchr(dst, '\0'), src);
+ return dst;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strchr.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strchr.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * strchr.c
+ */
+
+#include <string.h>
+
+char *strchr(const char *s, int c)
+{
+ while ( *s != (char)c ) {
+ if ( ! *s )
+ return NULL;
+ s++;
+ }
+
+ return (char *)s;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strcmp.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strcmp.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,20 @@
+/*
+ * strcmp.c
+ */
+
+#include <string.h>
+
+int strcmp(const char *s1, const char *s2)
+{
+ const unsigned char *c1 = s1, *c2 = s2;
+ unsigned char ch;
+ int d = 0;
+
+ while ( 1 ) {
+ d = (int)(ch = *c1++) - (int)*c2++;
+ if ( d || !ch )
+ break;
+ }
+
+ return d;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strcpy.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strcpy.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,20 @@
+/*
+ * strcpy.c
+ *
+ * strcpy()
+ */
+
+#include <string.h>
+
+char *strcpy(char *dst, const char *src)
+{
+ char *q = dst;
+ const char *p = src;
+ char ch;
+
+ do {
+ *q++ = ch = *p++;
+ } while ( ch );
+
+ return dst;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strdup.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strdup.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,17 @@
+/*
+ * strdup.c
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+char *strdup(const char *s)
+{
+ int l = strlen(s)+1;
+ char *d = malloc(l);
+
+ if ( d )
+ memcpy(d, s, l);
+
+ return d;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strerror.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strerror.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,34 @@
+/*
+ * strerror.c
+ */
+
+#include <string.h>
+
+char *strerror(int errnum)
+{
+ static char message[32] = "error "; /* enough for error 2^63-1 */
+ char numbuf[32];
+ char *p;
+ unsigned int e = (unsigned int)errnum;
+
+#ifdef WITH_ERRLIST
+ extern const int sys_nerr;
+ extern const char * const sys_errlist[];
+
+ if ( e < (unsigned int)sys_nerr && sys_errlist[e] )
+ return (char *)sys_errlist[e];
+#endif
+
+ p = numbuf+sizeof numbuf;
+ *--p = '\0';
+
+ do {
+ *--p = (e % 10) + '0';
+ e /= 10;
+ } while ( e );
+
+ memcpy(message+6, p, (numbuf+sizeof numbuf)-p);
+
+ return message;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strlcat.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strlcat.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,31 @@
+/*
+ * strlcat.c
+ */
+
+#include <string.h>
+#include <klibc/compiler.h>
+
+size_t strlcat(char *dst, const char *src, size_t size)
+{
+ size_t bytes = 0;
+ char *q = dst;
+ const char *p = src;
+ char ch;
+
+ while ( bytes < size && *q ) {
+ q++;
+ bytes++;
+ }
+
+ while ( (ch = *p++) ) {
+ if ( bytes < size )
+ *q++ = ch;
+
+ bytes++;
+ }
+
+ *q = '\0';
+ return bytes;
+}
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strlcpy.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strlcpy.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,26 @@
+/*
+ * strlcpy.c
+ */
+
+#include <string.h>
+#include <klibc/compiler.h>
+
+size_t strlcpy(char *dst, const char *src, size_t size)
+{
+ size_t bytes = 0;
+ char *q = dst;
+ const char *p = src;
+ char ch;
+
+ while ( (ch = *p++) ) {
+ if ( bytes < size )
+ *q++ = ch;
+
+ bytes++;
+ }
+
+ *q = '\0';
+ return bytes;
+}
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strlen.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strlen.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+/*
+ * strlen()
+ */
+
+#include <string.h>
+
+size_t strlen(const char *s)
+{
+ const char *ss = s;
+ while ( *ss )
+ ss++;
+ return ss-s;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strncasecmp.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strncasecmp.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+/*
+ * strncasecmp.c
+ */
+
+#include <string.h>
+#include <ctype.h>
+
+int strncasecmp(const char *s1, const char *s2, size_t n)
+{
+ const unsigned char *c1 = s1, *c2 = s2;
+ unsigned char ch;
+ int d = 0;
+
+ while ( n-- ) {
+ /* toupper() expects an unsigned char (implicitly cast to int)
+ as input, and returns an int, which is exactly what we want. */
+ d = toupper(ch = *c1++) - toupper(*c2++);
+ if ( d || !ch )
+ break;
+ }
+
+ return d;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strncat.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strncat.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+/*
+ * strncat.c
+ */
+
+#include <string.h>
+#include <klibc/compiler.h>
+
+char *strncat(char *dst, const char *src, size_t n)
+{
+ char *q = strchr(dst, '\0');
+ const char *p = src;
+ char ch;
+ size_t nn = q-dst;
+
+ if ( __likely(nn <= n) )
+ n -= nn;
+
+ while (n--) {
+ *q++ = ch = *p++;
+ if ( !ch )
+ break;
+ }
+
+ return dst;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strncmp.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strncmp.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,20 @@
+/*
+ * strncmp.c
+ */
+
+#include <string.h>
+
+int strncmp(const char *s1, const char *s2, size_t n)
+{
+ const unsigned char *c1 = s1, *c2 = s2;
+ unsigned char ch;
+ int d = 0;
+
+ while ( n-- ) {
+ d = (int)(ch = *c1++) - (int)*c2++;
+ if ( d || !ch )
+ break;
+ }
+
+ return d;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strncpy.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strncpy.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+/*
+ * strncpy.c
+ */
+
+#include <string.h>
+
+char *strncpy(char *dst, const char *src, size_t n)
+{
+ char *q = dst;
+ const char *p = src;
+ char ch;
+
+ while (n) {
+ n--;
+ *q++ = ch = *p++;
+ if ( !ch )
+ break;
+ }
+
+ /* The specs say strncpy() fills the entire buffer with NUL. Sigh. */
+ memset(q, 0, n);
+
+ return dst;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strndup.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strndup.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,17 @@
+/*
+ * strndup.c
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+char *strndup(const char *s, size_t n)
+{
+ int l = n > strlen(s) ? strlen(s)+1 : n+1;
+ char *d = malloc(l);
+
+ if (d)
+ memcpy(d, s, l);
+ d[n] = '\0';
+ return d;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strnlen.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strnlen.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * strnlen()
+ */
+
+#include <string.h>
+
+size_t strnlen(const char *s, size_t maxlen)
+{
+ const char *ss = s;
+
+ /* Important: the maxlen test must precede the reference through ss;
+ since the byte beyond the maximum may segfault */
+ while ((maxlen > 0) && *ss) {
+ ss++;
+ maxlen--;
+ }
+ return ss-s;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strntoimax.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strntoimax.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * strntoimax.c
+ *
+ * strntoimax()
+ */
+
+#include <stddef.h>
+#include <inttypes.h>
+
+intmax_t strntoimax(const char *nptr, char **endptr, int base, size_t n)
+{
+ return (intmax_t) strntoumax(nptr, endptr, base, n);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strntoumax.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strntoumax.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,75 @@
+/*
+ * strntoumax.c
+ *
+ * The strntoumax() function and associated
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+#include <ctype.h>
+
+static inline int digitval(int ch)
+{
+ if ( ch >= '0' && ch <= '9' ) {
+ return ch-'0';
+ } else if ( ch >= 'A' && ch <= 'Z' ) {
+ return ch-'A'+10;
+ } else if ( ch >= 'a' && ch <= 'z' ) {
+ return ch-'a'+10;
+ } else {
+ return -1;
+ }
+}
+
+uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n)
+{
+ int minus = 0;
+ uintmax_t v = 0;
+ int d;
+
+ while ( n && isspace((unsigned char)*nptr) ) {
+ nptr++;
+ n--;
+ }
+
+ /* Single optional + or - */
+ if ( n && *nptr == '-' ) {
+ minus = 1;
+ nptr++;
+ n--;
+ } else if ( n && *nptr == '+' ) {
+ nptr++;
+ }
+
+ if ( base == 0 ) {
+ if ( n >= 2 && nptr[0] == '0' &&
+ (nptr[1] == 'x' || nptr[1] == 'X') ) {
+ n -= 2;
+ nptr += 2;
+ base = 16;
+ } else if ( n >= 1 && nptr[0] == '0' ) {
+ n--;
+ nptr++;
+ base = 8;
+ } else {
+ base = 10;
+ }
+ } else if ( base == 16 ) {
+ if ( n >= 2 && nptr[0] == '0' &&
+ (nptr[1] == 'x' || nptr[1] == 'X') ) {
+ n -= 2;
+ nptr += 2;
+ }
+ }
+
+ while ( n && (d = digitval(*nptr)) >= 0 && d < base ) {
+ v = v*base + d;
+ n--;
+ nptr++;
+ }
+
+ if ( endptr )
+ *endptr = (char *)nptr;
+
+ return minus ? -v : v;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strrchr.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strrchr.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,18 @@
+/*
+ * strrchr.c
+ */
+
+#include <string.h>
+
+char *strrchr(const char *s, int c)
+{
+ const char *found = NULL;
+
+ while ( *s ) {
+ if ( *s == (char) c )
+ found = s;
+ s++;
+ }
+
+ return (char *)found;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strsep.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strsep.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,21 @@
+/*
+ * strsep.c
+ */
+
+#include <string.h>
+
+char *strsep(char **stringp, const char *delim)
+{
+ char *s = *stringp;
+ char *e;
+
+ if ( !s )
+ return NULL;
+
+ e = strpbrk(s, delim);
+ if (e)
+ *e++ = '\0';
+
+ *stringp = e;
+ return s;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strspn.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strspn.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,67 @@
+/*
+ * strspn, strcspn
+ */
+
+#include <string.h>
+#include <stddef.h>
+#include <inttypes.h>
+#include <limits.h>
+
+#ifndef LONG_BIT
+#define LONG_BIT (CHAR_BIT*sizeof(long))
+#endif
+
+static inline void
+set_bit(unsigned long *bitmap, unsigned int bit)
+{
+ bitmap[bit/LONG_BIT] |= 1UL << (bit%LONG_BIT);
+}
+
+static inline int
+test_bit(unsigned long *bitmap, unsigned int bit)
+{
+ return (int)(bitmap[bit/LONG_BIT] >> (bit%LONG_BIT)) & 1;
+}
+
+static size_t
+strxspn(const char *s, const char *map, int parity)
+{
+ unsigned long matchmap[((1 << CHAR_BIT)+LONG_BIT-1)/LONG_BIT];
+ size_t n = 0;
+
+ /* Create bitmap */
+ memset(matchmap, 0, sizeof matchmap);
+ while ( *map )
+ set_bit(matchmap, (unsigned char) *map++);
+
+ /* Make sure the null character never matches */
+ if ( parity )
+ set_bit(matchmap, 0);
+
+ /* Calculate span length */
+ while ( test_bit(matchmap, (unsigned char) *s++)^parity )
+ n++;
+
+ return n;
+}
+
+size_t
+strspn(const char *s, const char *accept)
+{
+ return strxspn(s, accept, 0);
+}
+
+size_t
+strcspn(const char *s, const char *reject)
+{
+ return strxspn(s, reject, 1);
+}
+
+char *
+strpbrk(const char *s, const char *accept)
+{
+ const char *ss = s+strxspn(s, accept, 1);
+
+ return *ss ? (char *)ss : NULL;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strstr.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strstr.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+/*
+ * strstr.c
+ */
+
+#include <string.h>
+
+char *strstr(const char *haystack, const char *needle)
+{
+ return (char *)memmem(haystack, strlen(haystack), needle, strlen(needle));
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strtoimax.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strtoimax.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,3 @@
+#define TYPE intmax_t
+#define NAME strtoimax
+#include "strtox.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strtok.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strtok.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+/*
+ * strtok.c
+ */
+
+#include <string.h>
+
+char *strtok(char *s, const char *delim)
+{
+ static char *holder;
+
+ if ( s )
+ holder = s;
+
+ return strsep(&holder, delim);
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strtol.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strtol.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,3 @@
+#define TYPE signed long
+#define NAME strtol
+#include "strtox.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strtoll.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strtoll.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,3 @@
+#define TYPE signed long long
+#define NAME strtoll
+#include "strtox.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strtotimespec.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strtotimespec.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,5 @@
+#define NAME strtotimespec
+#define TIMEX struct timespec
+#define FSEC tv_nsec
+#define DECIMALS 9
+#include "strtotimex.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strtotimeval.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strtotimeval.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,5 @@
+#define NAME strtotimeval
+#define TIMEX struct timeval
+#define FSEC tv_usec
+#define DECIMALS 6
+#include "strtotimex.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strtotimex.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strtotimex.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,39 @@
+/*
+ * strtotimex.c
+ *
+ * Nonstandard function which takes a string and converts it to a
+ * struct timespec/timeval. Returns a pointer to the first non-numeric
+ * character in the string.
+ *
+ */
+
+#include <ctype.h>
+#include <inttypes.h>
+#include <stdlib.h>
+#include <sys/time.h>
+
+char * NAME (const char *str, TIMEX *ts)
+{
+ int n;
+ char *s, *s0;
+ __typeof__(ts->FSEC) fs; /* Fractional seconds */
+
+ ts->tv_sec = strntoumax(str, &s, 10, ~(size_t)0);
+ fs = 0;
+
+ if ( *s == '.' ) {
+ s0 = s+1;
+
+ fs = strntoumax(s0, &s, 10, DECIMALS);
+ n = s-s0;
+
+ while ( isdigit(*s) )
+ s++;
+
+ for ( ; n < DECIMALS ; n++ )
+ fs *= 10;
+ }
+
+ ts->FSEC = fs;
+ return s;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strtoul.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strtoul.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,3 @@
+#define TYPE unsigned long
+#define NAME strtoul
+#include "strtox.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strtoull.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strtoull.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,3 @@
+#define TYPE unsigned long long
+#define NAME strtoull
+#include "strtox.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strtoumax.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strtoumax.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,3 @@
+#define TYPE uintmax_t
+#define NAME strtoumax
+#include "strtox.c"
Added: multipath-tools/upstream/current/klibc-0.190/klibc/strtox.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/strtox.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+/*
+ * strtox.c
+ *
+ * strto...() functions, by macro definition
+ */
+
+#include <stddef.h>
+#include <inttypes.h>
+
+TYPE NAME (const char *nptr, char **endptr, int base)
+{
+ return (TYPE) strntoumax(nptr, endptr, base, ~(size_t)0);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/syscalls.pl
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/syscalls.pl Fri Mar 4 08:05:19 2005
@@ -0,0 +1,114 @@
+#!/usr/bin/perl
+#
+# Script to parse the SYSCALLS file and generate appropriate
+# stubs.
+
+$v = $ENV{'KBUILD_VERBOSE'};
+$quiet = defined($v) ? !$v : 0;
+
+ at args = ();
+for $arg ( @ARGV ) {
+ if ( $arg =~ /^-/ ) {
+ if ( $arg eq '-q' ) {
+ $quiet = 1;
+ } else {
+ die "$0: Unknown option: $arg\n";
+ }
+ } else {
+ push(@args, $arg);
+ }
+}
+($file, $arch, $bits, $unistd, $havesyscall) = @args;
+
+require "arch/$arch/sysstub.ph";
+
+if (!open(UNISTD, '<', $unistd)) {
+ die "$0: $unistd: $!\n";
+}
+while ( defined($line = <UNISTD>) ) {
+ chomp $line;
+
+ if ( $line =~ /^\#\s*define\s+__NR_([A-Za-z0-9_]+)\s+(.*\S)\s*$/ ) {
+ $syscalls{$1} = $2;
+ print STDERR "SYSCALL FOUND: $1\n" unless ( $quiet );
+ }
+}
+close(UNISTD);
+
+if (!open(HAVESYS, '>', $havesyscall)) {
+ die "$0: $havesyscall: $!\n";
+}
+
+print HAVESYS "#ifndef _KLIBC_HAVESYSCALL_H\n";
+print HAVESYS "#define _KLIBC_HAVESYSCALL_H 1\n\n";
+
+if (!open(FILE, '<', $file)) {
+ die "$0: $file: $!\n";
+}
+
+while ( defined($line = <FILE>) ) {
+ chomp $line;
+ $line =~ s/\s*(|[\#;].*)$//; # Strip comments and trailing blanks
+ next unless $line;
+
+ if ( $line =~ /^\s*(\<[^\>]+\>\s+|)([A-Za-z0-9_\*\s]+)\s+([A-Za-z0-9_,]+)(|\@[A-Za-z0-9_]+)(|\:\:[A-Za-z0-9_]+)\s*\(([^\:\)]*)\)\s*$/ ) {
+ $archs = $1;
+ $type = $2;
+ $snames = $3;
+ $stype = $4;
+ $fname = $5;
+ $argv = $6;
+
+ $doit = 1;
+ $maybe = 0;
+ if ( $archs ne '' ) {
+ die "$file:$.: Invalid architecture spec: <$archs>\n"
+ unless ( $archs =~ /^\<(|\?)(|\!)([^\>\!\?]*)\>/ );
+ $maybe = $1 ne '';
+ $not = $2 ne '';
+ $list = $3;
+
+ $doit = $not || ($list eq '');
+
+ @list = split(/,/, $list);
+ foreach $a ( @list ) {
+ if ( $a eq $arch || $a eq $bits ) {
+ $doit = !$not;
+ last;
+ }
+ }
+ }
+ next if ( ! $doit );
+
+ undef $sname;
+ foreach $sn ( split(/,/, $snames) ) {
+ if ( defined $syscalls{$sn} ) {
+ $sname = $sn;
+ last;
+ }
+ }
+ if ( !defined($sname) ) {
+ next if ( $maybe );
+ die "$file:$.: Undefined system call: $snames\n";
+ }
+
+ $type =~ s/\s*$//;
+ $stype =~ s/^\@//;
+
+ if ( $fname eq '' ) {
+ $fname = $sname;
+ } else {
+ $fname =~ s/^\:\://;
+ }
+
+ @args = split(/\s*\,\s*/, $argv);
+
+ print HAVESYS "#define _KLIBC_HAVE_SYSCALL_${fname} ${sname}\n";
+ make_sysstub($fname, $type, $sname, $stype, @args);
+ } else {
+ die "$file:$.: Could not parse input: \"$line\"\n";
+ }
+}
+
+print HAVESYS "\n#endif\n";
+close(HAVESYS);
Added: multipath-tools/upstream/current/klibc-0.190/klibc/syscommon.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/syscommon.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,32 @@
+/*
+ * syscommon.h
+ *
+ * Common header file for system call stubs
+ */
+
+#define __IN_SYS_COMMON
+#include <errno.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+#include <poll.h>
+#include <sched.h>
+#include <sys/dirent.h>
+#include <sys/klog.h>
+#include <sys/mman.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/times.h>
+#include <sys/uio.h>
+#include <sys/utime.h>
+#include <sys/utsname.h>
+#include <sys/vfs.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#ifdef __i386__
+# include <sys/vm86.h>
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/syslog.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/syslog.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,79 @@
+/*
+ * syslog.c
+ *
+ * Issue syslog messages via the kernel printk queue.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+/* Maximum size for a kernel message */
+#define BUFLEN 1024
+
+/* Logging node */
+#define LOGDEV "/dev/kmsg"
+
+/* Max length of ID string */
+#define MAXID 31 /* MAXID+6 must be < BUFLEN */
+
+int __syslog_fd = -1;
+static char id[MAXID+1];
+
+void openlog(const char *ident, int option, int facility)
+{
+ int fd;
+
+ (void)option; (void)facility; /* Unused */
+
+ if ( __syslog_fd == -1 ) {
+ __syslog_fd = fd = open(LOGDEV, O_WRONLY);
+ if ( fd == -1 )
+ return;
+ fcntl(fd, F_SETFD, (long)FD_CLOEXEC);
+ }
+
+ strncpy(id, ident?ident:"", MAXID);
+ id[MAXID] = '\0'; /* Make sure it's null-terminated */
+}
+
+void vsyslog(int prio, const char *format, va_list ap)
+{
+ char buf[BUFLEN];
+ int len;
+ int fd;
+
+ if ( __syslog_fd == -1 )
+ openlog(NULL, 0, 0);
+
+ buf[0] = '<';
+ buf[1] = LOG_PRI(prio)+'0';
+ buf[2] = '>';
+ len = 3;
+
+ if ( *id )
+ len += sprintf(buf+3, "%s: ", id);
+
+ len += vsnprintf(buf+len, BUFLEN-len, format, ap);
+
+ if ( len > BUFLEN-1 ) len = BUFLEN-1;
+ buf[len++] = '\n';
+
+ fd = __syslog_fd;
+ if ( fd == -1 )
+ fd = 2; /* Failed to open log, write to stderr */
+
+ write(fd, buf, len);
+}
+
+void syslog(int prio, const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ vsyslog(prio, format, ap);
+ va_end(ap);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/system.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/system.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,61 @@
+/*
+ * system.c
+ *
+ * The system() function. If this turns out to actually be *used*,
+ * we may want to try to detect the very simple cases (no shell magic)
+ * and handle them internally, instead of requiring that /bin/sh be
+ * present.
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <sys/wait.h>
+
+int system(const char *string)
+{
+ pid_t pid;
+ struct sigaction ignore, old_int, old_quit;
+ sigset_t masked, oldmask;
+ static const char *argv[] = { "/bin/sh", "-c", NULL, NULL };
+ int status;
+
+ /* Block SIGCHLD and ignore SIGINT and SIGQUIT */
+ /* Do this before the fork() to avoid races */
+
+ ignore.sa_handler = SIG_IGN;
+ sigemptyset(&ignore.sa_mask);
+ ignore.sa_flags = 0;
+ sigaction(SIGINT, &ignore, &old_int);
+ sigaction(SIGQUIT, &ignore, &old_quit);
+
+ sigemptyset(&masked);
+ sigaddset(&masked, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &masked, &oldmask);
+
+ pid = fork();
+
+ if ( pid < 0 )
+ return -1;
+ else if ( pid == 0 ) {
+ sigaction(SIGINT, &old_int, NULL);
+ sigaction(SIGQUIT, &old_quit, NULL);
+ sigprocmask(SIG_SETMASK, &oldmask, NULL);
+
+ argv[2] = string;
+
+ execve(argv[0], (char * const *)argv, (char * const *)environ);
+ _exit(127);
+ }
+
+ /* else... */
+
+ waitpid(pid, &status, 0);
+
+ sigaction(SIGINT, &old_int, NULL);
+ sigaction(SIGQUIT, &old_quit, NULL);
+ sigprocmask(SIG_SETMASK, &oldmask, NULL);
+
+ return status;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/sysv_signal.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/sysv_signal.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+/*
+ * sysv_signal.c
+ */
+
+#include <signal.h>
+
+__sighandler_t sysv_signal(int signum, __sighandler_t handler)
+{
+ /* Linux/SysV signal() semantics */
+ return __signal(signum, handler, SA_RESETHAND);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/environ.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/environ.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int main(int argc, char *argv[], char *envp[])
+{
+ int i;
+
+ /* Verify envp == environ */
+ printf("Verifying envp == environ... %s\n",
+ (envp == environ) ? "ok" : "ERROR");
+
+ /* Test argc/argv */
+ printf("argc = %d, argv = %p\n", argc, argv);
+ for ( i = 0 ; i < argc ; i++ ) {
+ printf("argv[%2d] = %s\n", i, argv[i]);
+ }
+
+ /* Test environ */
+ for ( i = 0 ; envp[i] ; i++ )
+ printf("%s\n", envp[i]);
+
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/fcntl.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/fcntl.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,53 @@
+/*
+ * Simple test of fcntl
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main(int argc, char *argv[])
+{
+ int fd = open(argv[0], O_RDONLY);
+ struct flock l;
+ long flags;
+
+ (void)argc;
+
+ if ( fd < 0 ) {
+ perror("open");
+ exit(1);
+ }
+
+ /* Get the flags on this FD */
+
+ if ( (flags = fcntl(fd, F_GETFL)) == -1 ) {
+ perror("F_GETFL");
+ exit(1);
+ }
+
+ if ( flags != (O_RDONLY|O_LARGEFILE) )
+ fprintf(stderr, "flags = %#lx\n", flags);
+
+ /* Set a lock on this FD */
+ memset(&l, 0, sizeof l);
+ l.l_type = F_RDLCK;
+ l.l_whence = SEEK_SET;
+ l.l_start = 123;
+ l.l_len = 456;
+
+ if ( fcntl(fd, F_SETLK, &l) == -1 ) {
+ perror("F_SETLK");
+ exit(1);
+ }
+
+ /* Eventually, fork and try to conflict with this lock... */
+
+ return 0;
+}
+
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/getopttest.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/getopttest.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,31 @@
+/*
+ * getopttest.c
+ *
+ * Simple test for getopt, set the environment variable GETOPTTEST
+ * to give the argument string to getopt()
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+
+int main(int argc, char * const *argv)
+{
+ const char *parser;
+ char showchar[] = "\'?\'";
+ int c;
+
+ parser = getenv("GETOPTTEST");
+ if ( !parser ) parser = "abzf:o:";
+
+ do {
+ c = getopt(argc, argv, parser);
+ showchar[1] = c;
+ printf("c = %s, optind = %d (%s), optarg = \"%s\", optopt = \'%c\'\n",
+ (c == EOF) ? "EOF" : showchar,
+ optind, argv[optind], optarg, optopt);
+ } while ( c != -1 );
+
+ return 0;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/getpagesize.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/getpagesize.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+#include <unistd.h>
+#include <stdio.h>
+
+int main(void)
+{
+ printf("getpagesize() = %d\n"
+ "__getpageshift() = %d\n",
+ getpagesize(), __getpageshift());
+
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/hello.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/hello.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(void)
+{
+ printf("Hello, World!\n");
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/idtest.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/idtest.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <unistd.h>
+
+int main(void)
+{
+ printf("pid = %u\n", getpid());
+ printf("ppid = %u\n", getppid());
+ printf("uid = %u\n", getuid());
+ printf("euid = %u\n", geteuid());
+ printf("gid = %u\n", getgid());
+ printf("egid = %u\n", getegid());
+ sleep(10);
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/malloctest.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/malloctest.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,4145 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define NCYCLES 4096
+
+int sizes[NCYCLES] = {
+ 11986,
+ 277806,
+ 2659,
+ 46,
+ 0,
+ 775553,
+ 1991,
+ 21,
+ 7638,
+ 250197,
+ 155828,
+ 5777,
+ 9,
+ 315006,
+ 900788,
+ 0,
+ 24893,
+ 119996,
+ 72299,
+ 171266,
+ 357,
+ 560,
+ 368,
+ 22952,
+ 54058,
+ 12638,
+ 39155,
+ 2738,
+ 217563,
+ 26853,
+ 47,
+ 75,
+ 1167,
+ 16917,
+ 1899,
+ 2905,
+ 9337,
+ 62243,
+ 14214,
+ 270523,
+ 4024,
+ 21,
+ 32,
+ 14892,
+ 625144,
+ 13,
+ 21700,
+ 8804,
+ 254147,
+ 0,
+ 6,
+ 836004,
+ 1718,
+ 2289,
+ 15554,
+ 412857,
+ 185097,
+ 806709,
+ 64,
+ 18602,
+ 17064,
+ 1779,
+ 78153,
+ 170600,
+ 199100,
+ 546528,
+ 0,
+ 21,
+ 20609,
+ 16514,
+ 548196,
+ 311446,
+ 53484,
+ 0,
+ 551,
+ 22225,
+ 24,
+ 153989,
+ 457309,
+ 526833,
+ 227979,
+ 757167,
+ 429560,
+ 0,
+ 835,
+ 1702,
+ 475275,
+ 798416,
+ 753,
+ 0,
+ 11126,
+ 145779,
+ 2006,
+ 0,
+ 8182,
+ 0,
+ 569432,
+ 9671,
+ 36,
+ 5523,
+ 407325,
+ 0,
+ 65,
+ 9293,
+ 0,
+ 6793,
+ 468701,
+ 73,
+ 0,
+ 186236,
+ 0,
+ 328405,
+ 125616,
+ 508013,
+ 380519,
+ 599518,
+ 83,
+ 151973,
+ 466906,
+ 9029,
+ 159725,
+ 1316,
+ 1,
+ 911532,
+ 1508,
+ 19050,
+ 972850,
+ 126,
+ 439377,
+ 29,
+ 37928,
+ 149628,
+ 54,
+ 130248,
+ 2,
+ 143,
+ 0,
+ 716873,
+ 3327,
+ 5,
+ 116131,
+ 5124,
+ 559621,
+ 2886,
+ 534,
+ 186432,
+ 441,
+ 7348,
+ 10331,
+ 1,
+ 260935,
+ 7,
+ 4370,
+ 405415,
+ 2,
+ 84518,
+ 1970,
+ 1,
+ 281910,
+ 46,
+ 274,
+ 2273,
+ 370565,
+ 4190,
+ 820641,
+ 577970,
+ 32809,
+ 974893,
+ 398067,
+ 380698,
+ 4,
+ 25978,
+ 153,
+ 882668,
+ 312365,
+ 9523,
+ 156421,
+ 0,
+ 268143,
+ 6,
+ 2,
+ 42987,
+ 212,
+ 12303,
+ 6723,
+ 1179,
+ 0,
+ 120924,
+ 3877,
+ 330421,
+ 310445,
+ 39264,
+ 8,
+ 85380,
+ 464716,
+ 0,
+ 33657,
+ 6285,
+ 0,
+ 4491,
+ 229,
+ 50,
+ 373197,
+ 6029,
+ 19,
+ 86884,
+ 243745,
+ 335656,
+ 90945,
+ 38973,
+ 572950,
+ 164129,
+ 0,
+ 3,
+ 17,
+ 13579,
+ 4448,
+ 47,
+ 3,
+ 132966,
+ 726249,
+ 498503,
+ 256,
+ 0,
+ 25841,
+ 0,
+ 7,
+ 945380,
+ 11872,
+ 69,
+ 3799,
+ 77223,
+ 1914,
+ 73,
+ 810968,
+ 10223,
+ 257918,
+ 184252,
+ 350,
+ 8101,
+ 725,
+ 9,
+ 2,
+ 2089,
+ 175,
+ 247,
+ 185964,
+ 36517,
+ 3723,
+ 313465,
+ 209,
+ 1300,
+ 128071,
+ 7425,
+ 2436,
+ 62,
+ 13753,
+ 9514,
+ 41,
+ 409141,
+ 46643,
+ 20866,
+ 15664,
+ 388548,
+ 84692,
+ 9549,
+ 610,
+ 7213,
+ 14,
+ 14930,
+ 244719,
+ 4748,
+ 41682,
+ 401098,
+ 102506,
+ 176535,
+ 0,
+ 5133,
+ 548,
+ 5234,
+ 56,
+ 11101,
+ 87638,
+ 336579,
+ 291705,
+ 640250,
+ 768165,
+ 370,
+ 2809,
+ 3,
+ 0,
+ 445122,
+ 47190,
+ 24885,
+ 143556,
+ 84,
+ 504726,
+ 610020,
+ 40355,
+ 902230,
+ 4360,
+ 1747,
+ 3496,
+ 489501,
+ 19,
+ 801601,
+ 62189,
+ 48,
+ 2645,
+ 320601,
+ 27304,
+ 17740,
+ 344,
+ 10,
+ 991,
+ 925503,
+ 0,
+ 315,
+ 251,
+ 3611,
+ 1756,
+ 683,
+ 165,
+ 380132,
+ 181101,
+ 453041,
+ 892056,
+ 67191,
+ 252592,
+ 32407,
+ 56242,
+ 8,
+ 297173,
+ 542903,
+ 830334,
+ 585236,
+ 422555,
+ 44769,
+ 0,
+ 68,
+ 4143,
+ 38754,
+ 73539,
+ 44579,
+ 94001,
+ 428537,
+ 38554,
+ 106612,
+ 0,
+ 182987,
+ 831731,
+ 3605,
+ 752851,
+ 52,
+ 72,
+ 120872,
+ 963754,
+ 31,
+ 764,
+ 240592,
+ 99101,
+ 328538,
+ 440325,
+ 12211,
+ 151282,
+ 353436,
+ 2991,
+ 40710,
+ 5212,
+ 5106,
+ 139122,
+ 148915,
+ 498505,
+ 1366,
+ 516,
+ 29190,
+ 17,
+ 224208,
+ 40,
+ 89,
+ 19190,
+ 8,
+ 25377,
+ 10029,
+ 720,
+ 97963,
+ 0,
+ 614,
+ 244567,
+ 2113,
+ 903675,
+ 8388,
+ 6,
+ 390705,
+ 325006,
+ 284272,
+ 108086,
+ 17,
+ 2628,
+ 952530,
+ 20474,
+ 898276,
+ 138661,
+ 3883,
+ 903,
+ 569993,
+ 376918,
+ 5849,
+ 103404,
+ 794499,
+ 35388,
+ 5,
+ 0,
+ 961626,
+ 27415,
+ 1927,
+ 92036,
+ 46241,
+ 35978,
+ 7426,
+ 399884,
+ 29490,
+ 252655,
+ 675971,
+ 3509,
+ 54170,
+ 170790,
+ 831341,
+ 134579,
+ 0,
+ 790422,
+ 35,
+ 930830,
+ 97394,
+ 20265,
+ 670,
+ 38497,
+ 1759,
+ 71209,
+ 93,
+ 736,
+ 11,
+ 886,
+ 1961,
+ 7,
+ 210607,
+ 62226,
+ 186736,
+ 1518,
+ 5,
+ 5,
+ 13,
+ 66989,
+ 442321,
+ 0,
+ 607939,
+ 11253,
+ 210875,
+ 495530,
+ 2,
+ 221136,
+ 377663,
+ 372,
+ 200658,
+ 18591,
+ 129783,
+ 803411,
+ 867506,
+ 757446,
+ 48836,
+ 34,
+ 200,
+ 114983,
+ 7287,
+ 22849,
+ 226669,
+ 13,
+ 0,
+ 20164,
+ 7828,
+ 39,
+ 49448,
+ 26740,
+ 185566,
+ 9927,
+ 36192,
+ 91068,
+ 338368,
+ 926,
+ 27746,
+ 534794,
+ 936132,
+ 2922,
+ 5,
+ 183162,
+ 256846,
+ 242551,
+ 134318,
+ 212959,
+ 167162,
+ 470,
+ 477045,
+ 532116,
+ 483794,
+ 733,
+ 5335,
+ 83074,
+ 4686,
+ 9567,
+ 1,
+ 195100,
+ 40354,
+ 87338,
+ 369,
+ 800,
+ 0,
+ 194504,
+ 469051,
+ 363532,
+ 850574,
+ 5085,
+ 167027,
+ 794511,
+ 124320,
+ 303231,
+ 132195,
+ 13225,
+ 46333,
+ 4313,
+ 89,
+ 799,
+ 51482,
+ 0,
+ 26,
+ 12659,
+ 1045,
+ 23621,
+ 0,
+ 74926,
+ 490979,
+ 6,
+ 3188,
+ 9448,
+ 174730,
+ 38982,
+ 102317,
+ 189621,
+ 853,
+ 29227,
+ 43374,
+ 423,
+ 420951,
+ 686,
+ 128,
+ 31291,
+ 0,
+ 402819,
+ 663143,
+ 55903,
+ 142,
+ 2,
+ 331584,
+ 197164,
+ 7,
+ 671983,
+ 53,
+ 5020,
+ 9782,
+ 123,
+ 743407,
+ 1276,
+ 1115,
+ 1169,
+ 122752,
+ 824690,
+ 292030,
+ 2094,
+ 144626,
+ 0,
+ 297278,
+ 440,
+ 742,
+ 95879,
+ 17682,
+ 10654,
+ 31,
+ 22183,
+ 746,
+ 0,
+ 0,
+ 11185,
+ 28,
+ 394987,
+ 36,
+ 474,
+ 243749,
+ 1431,
+ 56702,
+ 76,
+ 15619,
+ 33071,
+ 12181,
+ 158647,
+ 261786,
+ 1,
+ 119783,
+ 48816,
+ 6278,
+ 4121,
+ 61122,
+ 69,
+ 48790,
+ 345335,
+ 275917,
+ 964393,
+ 424,
+ 586433,
+ 20519,
+ 18156,
+ 756400,
+ 27736,
+ 458706,
+ 1,
+ 3286,
+ 929624,
+ 1883,
+ 2,
+ 1086,
+ 439501,
+ 552,
+ 157132,
+ 5565,
+ 105061,
+ 8199,
+ 23,
+ 178797,
+ 0,
+ 130644,
+ 1,
+ 6952,
+ 754,
+ 500,
+ 647683,
+ 0,
+ 959079,
+ 622561,
+ 1131,
+ 559783,
+ 6862,
+ 175420,
+ 408671,
+ 463461,
+ 55908,
+ 606496,
+ 169,
+ 49060,
+ 247,
+ 953,
+ 333030,
+ 0,
+ 23399,
+ 29193,
+ 9303,
+ 15,
+ 515402,
+ 34961,
+ 365856,
+ 633043,
+ 173,
+ 556089,
+ 1809,
+ 12215,
+ 14,
+ 316,
+ 20642,
+ 9,
+ 15,
+ 190391,
+ 951463,
+ 25059,
+ 13654,
+ 385040,
+ 4272,
+ 929033,
+ 208813,
+ 35166,
+ 42849,
+ 662648,
+ 254811,
+ 4230,
+ 812459,
+ 681,
+ 390168,
+ 5381,
+ 4662,
+ 173257,
+ 478863,
+ 103,
+ 89332,
+ 0,
+ 0,
+ 589484,
+ 19369,
+ 94,
+ 9,
+ 639917,
+ 1110,
+ 393,
+ 101040,
+ 911,
+ 152899,
+ 0,
+ 2,
+ 0,
+ 0,
+ 335691,
+ 43694,
+ 62273,
+ 200121,
+ 2250,
+ 621004,
+ 149918,
+ 41063,
+ 218229,
+ 0,
+ 497924,
+ 16832,
+ 587071,
+ 0,
+ 0,
+ 729918,
+ 2,
+ 808513,
+ 9417,
+ 718,
+ 0,
+ 2769,
+ 28704,
+ 1335,
+ 734726,
+ 219157,
+ 786230,
+ 981004,
+ 350788,
+ 884529,
+ 0,
+ 87872,
+ 34647,
+ 85469,
+ 4524,
+ 339838,
+ 38228,
+ 0,
+ 4151,
+ 1145,
+ 0,
+ 351,
+ 167956,
+ 810075,
+ 689,
+ 251212,
+ 583068,
+ 2929,
+ 189456,
+ 2089,
+ 48749,
+ 278952,
+ 77134,
+ 0,
+ 0,
+ 45595,
+ 281829,
+ 969602,
+ 43999,
+ 69824,
+ 856982,
+ 61732,
+ 336,
+ 25488,
+ 213,
+ 46683,
+ 1909,
+ 174097,
+ 57930,
+ 91466,
+ 828418,
+ 95740,
+ 378828,
+ 128065,
+ 68068,
+ 0,
+ 13312,
+ 26006,
+ 6760,
+ 51,
+ 276081,
+ 640068,
+ 634985,
+ 7131,
+ 784882,
+ 790126,
+ 628585,
+ 205824,
+ 764965,
+ 17793,
+ 3159,
+ 649924,
+ 0,
+ 37383,
+ 9919,
+ 353,
+ 0,
+ 149003,
+ 620629,
+ 95928,
+ 2560,
+ 504343,
+ 1000,
+ 32,
+ 43836,
+ 407031,
+ 207,
+ 800894,
+ 3222,
+ 51028,
+ 7,
+ 6,
+ 22010,
+ 0,
+ 21174,
+ 12893,
+ 824932,
+ 7305,
+ 70,
+ 624258,
+ 372139,
+ 21504,
+ 387996,
+ 418931,
+ 914268,
+ 576,
+ 0,
+ 0,
+ 618224,
+ 787516,
+ 133014,
+ 422,
+ 383124,
+ 656318,
+ 4420,
+ 6082,
+ 244813,
+ 38585,
+ 3200,
+ 1,
+ 2,
+ 11882,
+ 113,
+ 45581,
+ 13121,
+ 95475,
+ 807219,
+ 8195,
+ 995116,
+ 13,
+ 2146,
+ 369925,
+ 60103,
+ 25,
+ 125165,
+ 51300,
+ 4894,
+ 173261,
+ 74186,
+ 1044,
+ 122992,
+ 1243,
+ 21703,
+ 26294,
+ 197,
+ 333825,
+ 426872,
+ 719580,
+ 3598,
+ 106,
+ 0,
+ 9932,
+ 61509,
+ 146,
+ 721428,
+ 964781,
+ 319850,
+ 573802,
+ 7458,
+ 317889,
+ 0,
+ 133086,
+ 87836,
+ 60496,
+ 304249,
+ 1565,
+ 27,
+ 42,
+ 899324,
+ 189637,
+ 8648,
+ 104570,
+ 901598,
+ 447765,
+ 24,
+ 108,
+ 120127,
+ 828626,
+ 8,
+ 899514,
+ 28,
+ 13,
+ 7576,
+ 163390,
+ 1625,
+ 3023,
+ 155175,
+ 2,
+ 391,
+ 1,
+ 493073,
+ 398,
+ 210771,
+ 26266,
+ 287999,
+ 38255,
+ 249666,
+ 598202,
+ 119601,
+ 216933,
+ 91205,
+ 0,
+ 7247,
+ 77077,
+ 565383,
+ 29102,
+ 253641,
+ 48855,
+ 19722,
+ 463536,
+ 40182,
+ 65393,
+ 829444,
+ 598402,
+ 1590,
+ 798,
+ 467,
+ 834847,
+ 3007,
+ 13711,
+ 0,
+ 195,
+ 101662,
+ 255749,
+ 129201,
+ 11965,
+ 1781,
+ 13349,
+ 3100,
+ 718066,
+ 99,
+ 712450,
+ 888215,
+ 42503,
+ 43171,
+ 494946,
+ 0,
+ 2175,
+ 12387,
+ 25662,
+ 78,
+ 739030,
+ 0,
+ 19,
+ 427526,
+ 4275,
+ 5583,
+ 0,
+ 2447,
+ 132398,
+ 26437,
+ 3873,
+ 440035,
+ 21,
+ 6,
+ 35432,
+ 41523,
+ 7179,
+ 712703,
+ 428868,
+ 2793,
+ 6,
+ 286277,
+ 1882,
+ 95116,
+ 2959,
+ 86,
+ 115425,
+ 81386,
+ 59836,
+ 37,
+ 247598,
+ 34732,
+ 249,
+ 500110,
+ 5589,
+ 40319,
+ 575,
+ 12145,
+ 385829,
+ 565600,
+ 582150,
+ 92,
+ 223209,
+ 0,
+ 910,
+ 1048,
+ 47329,
+ 90944,
+ 235,
+ 8739,
+ 686685,
+ 1753,
+ 126,
+ 434,
+ 609477,
+ 25021,
+ 6610,
+ 52675,
+ 4,
+ 717846,
+ 150864,
+ 418583,
+ 17751,
+ 513794,
+ 181362,
+ 329556,
+ 10426,
+ 717019,
+ 457,
+ 616,
+ 388984,
+ 17,
+ 8338,
+ 59531,
+ 32,
+ 99565,
+ 376146,
+ 134578,
+ 966,
+ 0,
+ 0,
+ 174,
+ 2105,
+ 555,
+ 8990,
+ 298,
+ 169932,
+ 247281,
+ 240918,
+ 298655,
+ 158743,
+ 15994,
+ 95708,
+ 51,
+ 2985,
+ 4294,
+ 731934,
+ 185640,
+ 1483,
+ 87,
+ 742033,
+ 9,
+ 1345,
+ 3680,
+ 133530,
+ 9355,
+ 800111,
+ 28508,
+ 0,
+ 369,
+ 31681,
+ 24,
+ 8237,
+ 313380,
+ 4732,
+ 275423,
+ 951592,
+ 0,
+ 41381,
+ 225515,
+ 393004,
+ 526,
+ 187,
+ 19515,
+ 6006,
+ 28923,
+ 310151,
+ 2390,
+ 374,
+ 0,
+ 19142,
+ 72,
+ 114,
+ 193305,
+ 24035,
+ 397067,
+ 18,
+ 14839,
+ 3473,
+ 164,
+ 104622,
+ 378958,
+ 2218,
+ 0,
+ 89053,
+ 105183,
+ 312265,
+ 82146,
+ 147210,
+ 3419,
+ 5178,
+ 34948,
+ 46836,
+ 41319,
+ 842825,
+ 595972,
+ 0,
+ 249625,
+ 325,
+ 608,
+ 372328,
+ 119634,
+ 7504,
+ 920214,
+ 7302,
+ 444532,
+ 359213,
+ 27265,
+ 1755,
+ 48,
+ 126799,
+ 651270,
+ 818220,
+ 799493,
+ 724024,
+ 64047,
+ 73699,
+ 206999,
+ 209,
+ 1581,
+ 0,
+ 42937,
+ 301144,
+ 73416,
+ 0,
+ 242058,
+ 29660,
+ 3,
+ 34709,
+ 162719,
+ 2863,
+ 3992,
+ 5212,
+ 151814,
+ 3092,
+ 198001,
+ 44331,
+ 36,
+ 407,
+ 364771,
+ 1349,
+ 502772,
+ 214726,
+ 607,
+ 388583,
+ 137660,
+ 337124,
+ 13279,
+ 10549,
+ 943075,
+ 164068,
+ 19157,
+ 38443,
+ 26351,
+ 0,
+ 67167,
+ 735,
+ 46486,
+ 130305,
+ 232330,
+ 744,
+ 882337,
+ 2,
+ 69275,
+ 126354,
+ 9370,
+ 2845,
+ 299,
+ 38988,
+ 37834,
+ 0,
+ 306433,
+ 9139,
+ 237132,
+ 0,
+ 500,
+ 13462,
+ 373684,
+ 107453,
+ 381924,
+ 347915,
+ 4329,
+ 1668,
+ 3960,
+ 370661,
+ 3614,
+ 636048,
+ 0,
+ 487449,
+ 64925,
+ 333894,
+ 11,
+ 52192,
+ 531200,
+ 155554,
+ 461,
+ 1547,
+ 994361,
+ 11955,
+ 321056,
+ 37425,
+ 14249,
+ 69151,
+ 621862,
+ 174,
+ 79607,
+ 34,
+ 77577,
+ 13723,
+ 267550,
+ 13801,
+ 698,
+ 12,
+ 171556,
+ 57354,
+ 676845,
+ 0,
+ 24965,
+ 908955,
+ 570483,
+ 0,
+ 296387,
+ 983966,
+ 85012,
+ 130298,
+ 151946,
+ 384474,
+ 731455,
+ 150699,
+ 772,
+ 216131,
+ 346,
+ 130935,
+ 3472,
+ 18,
+ 426045,
+ 677262,
+ 808,
+ 17030,
+ 5188,
+ 0,
+ 491153,
+ 67299,
+ 19,
+ 60342,
+ 69,
+ 0,
+ 76478,
+ 95763,
+ 0,
+ 28778,
+ 147869,
+ 335927,
+ 27846,
+ 2163,
+ 22750,
+ 162,
+ 23,
+ 11391,
+ 469099,
+ 5852,
+ 63,
+ 0,
+ 0,
+ 22193,
+ 165,
+ 489007,
+ 9249,
+ 12477,
+ 2841,
+ 223532,
+ 13877,
+ 173,
+ 3570,
+ 45477,
+ 233073,
+ 23296,
+ 64377,
+ 4910,
+ 8,
+ 76246,
+ 411147,
+ 287411,
+ 10450,
+ 3667,
+ 1,
+ 500933,
+ 31363,
+ 257,
+ 1705,
+ 6036,
+ 49934,
+ 13738,
+ 13485,
+ 61608,
+ 561978,
+ 76493,
+ 16377,
+ 1817,
+ 0,
+ 235600,
+ 0,
+ 16347,
+ 680478,
+ 5115,
+ 895607,
+ 138270,
+ 369912,
+ 53110,
+ 0,
+ 647083,
+ 85,
+ 458681,
+ 163227,
+ 52767,
+ 196,
+ 267719,
+ 14047,
+ 147293,
+ 814457,
+ 174896,
+ 0,
+ 34138,
+ 36,
+ 21575,
+ 3,
+ 0,
+ 0,
+ 38391,
+ 2597,
+ 2,
+ 1433,
+ 3807,
+ 36476,
+ 287,
+ 141530,
+ 29389,
+ 495655,
+ 30014,
+ 0,
+ 550766,
+ 11958,
+ 348,
+ 226760,
+ 15,
+ 251353,
+ 675788,
+ 518308,
+ 215,
+ 81987,
+ 409862,
+ 559596,
+ 114283,
+ 4925,
+ 0,
+ 17,
+ 14221,
+ 0,
+ 162,
+ 766370,
+ 4898,
+ 998,
+ 493,
+ 138418,
+ 265159,
+ 12152,
+ 5229,
+ 1204,
+ 1814,
+ 432530,
+ 2889,
+ 144,
+ 1149,
+ 35886,
+ 636931,
+ 6640,
+ 1508,
+ 414118,
+ 858,
+ 20039,
+ 17398,
+ 3,
+ 5094,
+ 6,
+ 13996,
+ 6754,
+ 362,
+ 451487,
+ 11471,
+ 7896,
+ 330009,
+ 244269,
+ 99928,
+ 0,
+ 14311,
+ 9949,
+ 15251,
+ 283923,
+ 123754,
+ 188360,
+ 93902,
+ 854384,
+ 548001,
+ 531788,
+ 26298,
+ 328479,
+ 941,
+ 246535,
+ 106320,
+ 28769,
+ 440,
+ 4,
+ 61262,
+ 55615,
+ 170,
+ 989327,
+ 692534,
+ 8063,
+ 445842,
+ 4434,
+ 255349,
+ 117781,
+ 6,
+ 9249,
+ 136216,
+ 38165,
+ 307012,
+ 12,
+ 2341,
+ 18062,
+ 371882,
+ 662154,
+ 12623,
+ 176847,
+ 332220,
+ 590935,
+ 33682,
+ 0,
+ 121374,
+ 67,
+ 46841,
+ 495890,
+ 640,
+ 19,
+ 14737,
+ 11032,
+ 17,
+ 5993,
+ 302562,
+ 827710,
+ 165346,
+ 49607,
+ 87863,
+ 308513,
+ 735300,
+ 1914,
+ 2900,
+ 207308,
+ 9068,
+ 83494,
+ 179,
+ 417,
+ 41605,
+ 74681,
+ 652171,
+ 4013,
+ 29811,
+ 13966,
+ 8136,
+ 78,
+ 61182,
+ 674187,
+ 0,
+ 331121,
+ 0,
+ 18559,
+ 386,
+ 77,
+ 348439,
+ 975358,
+ 18,
+ 33700,
+ 47396,
+ 204751,
+ 2350,
+ 26503,
+ 0,
+ 83653,
+ 446,
+ 10844,
+ 485,
+ 9241,
+ 88347,
+ 232419,
+ 936900,
+ 43250,
+ 2,
+ 26112,
+ 811955,
+ 20723,
+ 102069,
+ 42255,
+ 8431,
+ 119508,
+ 4080,
+ 13565,
+ 12,
+ 46110,
+ 62096,
+ 638777,
+ 44025,
+ 152985,
+ 13362,
+ 3,
+ 12331,
+ 193337,
+ 56419,
+ 14593,
+ 3837,
+ 282314,
+ 403454,
+ 48589,
+ 135,
+ 18350,
+ 2160,
+ 90,
+ 918216,
+ 7083,
+ 105534,
+ 742826,
+ 399028,
+ 1470,
+ 23770,
+ 480,
+ 677884,
+ 340472,
+ 107406,
+ 0,
+ 5002,
+ 445,
+ 748948,
+ 534012,
+ 592464,
+ 6539,
+ 819632,
+ 3138,
+ 4,
+ 39397,
+ 229683,
+ 12204,
+ 2439,
+ 65131,
+ 817226,
+ 22596,
+ 0,
+ 1046,
+ 94638,
+ 0,
+ 95403,
+ 1230,
+ 790056,
+ 19976,
+ 43085,
+ 14251,
+ 139187,
+ 20232,
+ 693,
+ 3058,
+ 27654,
+ 65690,
+ 40948,
+ 15001,
+ 21089,
+ 14425,
+ 322459,
+ 13571,
+ 228154,
+ 536814,
+ 761221,
+ 28030,
+ 2322,
+ 921,
+ 1,
+ 1137,
+ 187815,
+ 8,
+ 34911,
+ 4527,
+ 15,
+ 46,
+ 78801,
+ 0,
+ 73605,
+ 44,
+ 28233,
+ 1370,
+ 73409,
+ 198159,
+ 66586,
+ 3,
+ 2576,
+ 15,
+ 35460,
+ 263237,
+ 44997,
+ 2873,
+ 240,
+ 1781,
+ 269,
+ 46,
+ 272778,
+ 28404,
+ 8232,
+ 417073,
+ 234591,
+ 9,
+ 720349,
+ 1176,
+ 16195,
+ 0,
+ 9705,
+ 0,
+ 14,
+ 947048,
+ 163,
+ 76288,
+ 1115,
+ 267020,
+ 3416,
+ 414217,
+ 441004,
+ 95131,
+ 765002,
+ 6196,
+ 9069,
+ 27017,
+ 137039,
+ 65247,
+ 266489,
+ 484945,
+ 187008,
+ 45405,
+ 5700,
+ 9,
+ 7751,
+ 12,
+ 294,
+ 3093,
+ 6350,
+ 103303,
+ 6045,
+ 252345,
+ 140207,
+ 22390,
+ 234867,
+ 443326,
+ 1,
+ 0,
+ 89972,
+ 8637,
+ 427150,
+ 22146,
+ 0,
+ 310432,
+ 390333,
+ 10461,
+ 1632,
+ 31403,
+ 908653,
+ 0,
+ 6543,
+ 163479,
+ 67608,
+ 195543,
+ 315889,
+ 822964,
+ 383536,
+ 954954,
+ 1619,
+ 241,
+ 96053,
+ 104556,
+ 767302,
+ 2469,
+ 12,
+ 164330,
+ 78,
+ 141,
+ 170519,
+ 268214,
+ 53338,
+ 48342,
+ 721,
+ 58980,
+ 4345,
+ 1,
+ 856265,
+ 87289,
+ 57219,
+ 775679,
+ 123992,
+ 695804,
+ 113025,
+ 832,
+ 117420,
+ 16634,
+ 352,
+ 24729,
+ 14973,
+ 25622,
+ 131290,
+ 0,
+ 22,
+ 87740,
+ 5917,
+ 533,
+ 2934,
+ 34261,
+ 9174,
+ 0,
+ 1656,
+ 764587,
+ 54652,
+ 35597,
+ 36389,
+ 577889,
+ 63957,
+ 26808,
+ 34556,
+ 56,
+ 15641,
+ 137,
+ 1,
+ 3,
+ 11724,
+ 197397,
+ 39027,
+ 87902,
+ 320,
+ 791479,
+ 7,
+ 487864,
+ 0,
+ 433,
+ 25733,
+ 6956,
+ 15407,
+ 312557,
+ 526302,
+ 383019,
+ 340215,
+ 96,
+ 276158,
+ 6493,
+ 135613,
+ 2000,
+ 1218,
+ 930,
+ 276808,
+ 273249,
+ 8896,
+ 397,
+ 735095,
+ 20648,
+ 2079,
+ 5349,
+ 205,
+ 356313,
+ 841954,
+ 8255,
+ 266874,
+ 0,
+ 965,
+ 287993,
+ 1549,
+ 207833,
+ 75,
+ 178180,
+ 39072,
+ 0,
+ 43254,
+ 3847,
+ 227,
+ 2712,
+ 161043,
+ 463264,
+ 74720,
+ 795789,
+ 12,
+ 6812,
+ 202804,
+ 29379,
+ 64241,
+ 132121,
+ 790622,
+ 493588,
+ 0,
+ 48,
+ 147352,
+ 925197,
+ 38149,
+ 18380,
+ 0,
+ 270280,
+ 633,
+ 3373,
+ 31294,
+ 7830,
+ 0,
+ 0,
+ 11371,
+ 56143,
+ 5393,
+ 74724,
+ 495109,
+ 0,
+ 18993,
+ 21524,
+ 0,
+ 53889,
+ 400509,
+ 204563,
+ 0,
+ 11625,
+ 9635,
+ 0,
+ 1678,
+ 12096,
+ 59,
+ 817112,
+ 10002,
+ 128209,
+ 11593,
+ 17313,
+ 15200,
+ 106796,
+ 261401,
+ 707077,
+ 0,
+ 314030,
+ 798591,
+ 14175,
+ 5668,
+ 2766,
+ 0,
+ 566,
+ 5543,
+ 24112,
+ 154482,
+ 5642,
+ 0,
+ 38410,
+ 3,
+ 4,
+ 700724,
+ 25024,
+ 5,
+ 407,
+ 564150,
+ 672,
+ 143,
+ 2049,
+ 574708,
+ 65858,
+ 213412,
+ 3797,
+ 511,
+ 30907,
+ 1212,
+ 765,
+ 2127,
+ 481,
+ 130048,
+ 113816,
+ 39861,
+ 153169,
+ 503378,
+ 523944,
+ 111,
+ 55083,
+ 698,
+ 275,
+ 3,
+ 3195,
+ 1657,
+ 0,
+ 317881,
+ 6672,
+ 543,
+ 153011,
+ 77240,
+ 9338,
+ 889850,
+ 29518,
+ 872485,
+ 181927,
+ 376086,
+ 266,
+ 409,
+ 4,
+ 14856,
+ 31943,
+ 2448,
+ 8,
+ 75,
+ 383097,
+ 294366,
+ 0,
+ 173084,
+ 753160,
+ 66457,
+ 725783,
+ 51,
+ 127651,
+ 1073,
+ 12598,
+ 140080,
+ 0,
+ 296375,
+ 581720,
+ 217346,
+ 8272,
+ 2051,
+ 185390,
+ 520645,
+ 1260,
+ 13873,
+ 168040,
+ 19690,
+ 103347,
+ 295011,
+ 548404,
+ 48,
+ 4,
+ 916417,
+ 1948,
+ 621365,
+ 263245,
+ 2792,
+ 86803,
+ 181193,
+ 558081,
+ 50907,
+ 442770,
+ 51448,
+ 340276,
+ 1346,
+ 607,
+ 459627,
+ 0,
+ 30,
+ 73298,
+ 15389,
+ 12264,
+ 2719,
+ 2936,
+ 143043,
+ 209970,
+ 0,
+ 42,
+ 6657,
+ 317419,
+ 0,
+ 32622,
+ 524000,
+ 0,
+ 310331,
+ 303778,
+ 268710,
+ 9,
+ 10410,
+ 25343,
+ 949506,
+ 784353,
+ 3861,
+ 46823,
+ 251292,
+ 75008,
+ 269798,
+ 87731,
+ 112813,
+ 571679,
+ 385,
+ 3,
+ 2811,
+ 36025,
+ 9243,
+ 935128,
+ 906,
+ 10688,
+ 25,
+ 86757,
+ 307,
+ 55,
+ 22,
+ 2,
+ 61,
+ 620426,
+ 484530,
+ 633806,
+ 0,
+ 1342,
+ 9293,
+ 992181,
+ 503,
+ 195433,
+ 46150,
+ 893091,
+ 3207,
+ 2865,
+ 72894,
+ 830299,
+ 355,
+ 327479,
+ 0,
+ 35573,
+ 3068,
+ 15699,
+ 31187,
+ 55378,
+ 416067,
+ 91721,
+ 159,
+ 0,
+ 255139,
+ 2104,
+ 19,
+ 606757,
+ 323,
+ 902659,
+ 365655,
+ 400,
+ 903,
+ 408,
+ 385,
+ 21774,
+ 701290,
+ 234426,
+ 17020,
+ 950,
+ 0,
+ 0,
+ 429,
+ 1245,
+ 405871,
+ 1097,
+ 280634,
+ 74,
+ 158233,
+ 1583,
+ 180333,
+ 42114,
+ 575973,
+ 539327,
+ 59252,
+ 121928,
+ 165,
+ 148501,
+ 55757,
+ 7494,
+ 127728,
+ 7832,
+ 68504,
+ 619770,
+ 70995,
+ 312816,
+ 7307,
+ 38265,
+ 46248,
+ 363304,
+ 269442,
+ 77112,
+ 448331,
+ 910442,
+ 474418,
+ 152752,
+ 752,
+ 104912,
+ 408492,
+ 691709,
+ 632381,
+ 48519,
+ 20524,
+ 344294,
+ 14670,
+ 0,
+ 21607,
+ 81162,
+ 181458,
+ 0,
+ 908322,
+ 7261,
+ 10888,
+ 58054,
+ 1788,
+ 970933,
+ 5925,
+ 121553,
+ 36152,
+ 588267,
+ 23615,
+ 1850,
+ 30728,
+ 3599,
+ 1319,
+ 6027,
+ 0,
+ 32141,
+ 984156,
+ 436781,
+ 15003,
+ 621407,
+ 9412,
+ 562911,
+ 189740,
+ 377895,
+ 656800,
+ 197,
+ 14413,
+ 99382,
+ 384,
+ 11480,
+ 0,
+ 86118,
+ 881961,
+ 1905,
+ 82061,
+ 4140,
+ 741153,
+ 26,
+ 687,
+ 12251,
+ 10945,
+ 209267,
+ 220602,
+ 135881,
+ 6,
+ 237945,
+ 158,
+ 5,
+ 76303,
+ 81344,
+ 986042,
+ 956063,
+ 30282,
+ 186055,
+ 357802,
+ 12492,
+ 577476,
+ 838,
+ 0,
+ 11,
+ 117602,
+ 0,
+ 187928,
+ 96860,
+ 4268,
+ 3478,
+ 818264,
+ 1649,
+ 17175,
+ 272,
+ 158951,
+ 440987,
+ 677594,
+ 14935,
+ 37953,
+ 0,
+ 198,
+ 160404,
+ 12,
+ 287803,
+ 2386,
+ 10,
+ 271663,
+ 319152,
+ 361322,
+ 68370,
+ 428,
+ 182707,
+ 387429,
+ 1152,
+ 360065,
+ 25218,
+ 2790,
+ 42228,
+ 13,
+ 110942,
+ 452491,
+ 1,
+ 665638,
+ 2308,
+ 1196,
+ 87306,
+ 66,
+ 219,
+ 0,
+ 130736,
+ 334,
+ 605,
+ 5979,
+ 2681,
+ 0,
+ 123463,
+ 11219,
+ 283681,
+ 19269,
+ 553,
+ 6217,
+ 130965,
+ 714409,
+ 242,
+ 674833,
+ 237581,
+ 133284,
+ 683,
+ 1758,
+ 278193,
+ 518726,
+ 44,
+ 420361,
+ 325228,
+ 14955,
+ 10,
+ 11994,
+ 64157,
+ 1937,
+ 20214,
+ 848,
+ 27804,
+ 151341,
+ 79236,
+ 316393,
+ 158883,
+ 1196,
+ 334,
+ 22797,
+ 185955,
+ 13857,
+ 397357,
+ 7948,
+ 6038,
+ 0,
+ 2621,
+ 16,
+ 155267,
+ 44809,
+ 9171,
+ 21328,
+ 12212,
+ 40200,
+ 2600,
+ 439,
+ 804014,
+ 10938,
+ 96135,
+ 43696,
+ 158715,
+ 4,
+ 284558,
+ 191,
+ 270254,
+ 7923,
+ 880603,
+ 21032,
+ 107700,
+ 172,
+ 700823,
+ 5613,
+ 78816,
+ 258290,
+ 214398,
+ 821856,
+ 295325,
+ 0,
+ 1,
+ 23559,
+ 63895,
+ 21249,
+ 717490,
+ 956952,
+ 944819,
+ 793,
+ 356,
+ 757716,
+ 111773,
+ 394826,
+ 25665,
+ 4358,
+ 640216,
+ 1152,
+ 37175,
+ 150192,
+ 106071,
+ 28992,
+ 67,
+ 1685,
+ 134242,
+ 2,
+ 102045,
+ 1457,
+ 419589,
+ 6789,
+ 677,
+ 94675,
+ 11300,
+ 2595,
+ 8,
+ 926535,
+ 265194,
+ 0,
+ 886048,
+ 246242,
+ 1494,
+ 191,
+ 169985,
+ 649765,
+ 0,
+ 201,
+ 1069,
+ 679163,
+ 16627,
+ 274639,
+ 84438,
+ 3,
+ 1301,
+ 247496,
+ 5879,
+ 710904,
+ 403652,
+ 958241,
+ 361,
+ 139732,
+ 6042,
+ 15985,
+ 2378,
+ 267031,
+ 223767,
+ 9656,
+ 241717,
+ 33863,
+ 14314,
+ 205697,
+ 1274,
+ 168000,
+ 621777,
+ 837913,
+ 89654,
+ 659829,
+ 69,
+ 503884,
+ 432717,
+ 70443,
+ 110891,
+ 19655,
+ 132432,
+ 620401,
+ 428,
+ 0,
+ 425662,
+ 0,
+ 0,
+ 0,
+ 194489,
+ 7601,
+ 26870,
+ 0,
+ 63,
+ 594,
+ 12278,
+ 582479,
+ 213723,
+ 424489,
+ 96446,
+ 990664,
+ 46966,
+ 44137,
+ 829810,
+ 104,
+ 19707,
+ 16,
+ 0,
+ 2499,
+ 167075,
+ 140972,
+ 249283,
+ 6620,
+ 68368,
+ 856414,
+ 9255,
+ 14315,
+ 0,
+ 11432,
+ 24329,
+ 216463,
+ 299556,
+ 818401,
+ 246607,
+ 697733,
+ 229,
+ 144,
+ 389394,
+ 664634,
+ 0,
+ 19393,
+ 657903,
+ 52912,
+ 952177,
+ 536931,
+ 187271,
+ 17687,
+ 970155,
+ 232571,
+ 234016,
+ 159980,
+ 13510,
+ 32952,
+ 0,
+ 0,
+ 24132,
+ 18806,
+ 15624,
+ 28364,
+ 472126,
+ 626978,
+ 599,
+ 112843,
+ 502933,
+ 915660,
+ 63920,
+ 0,
+ 84,
+ 10899,
+ 904823,
+ 126,
+ 469132,
+ 590052,
+ 195831,
+ 443113,
+ 294149,
+ 15944,
+ 2271,
+ 282974,
+ 211,
+ 0,
+ 22934,
+ 82283,
+ 49973,
+ 41707,
+ 87530,
+ 0,
+ 910528,
+ 0,
+ 36029,
+ 423337,
+ 817512,
+ 223671,
+ 27800,
+ 398847,
+ 198528,
+ 1,
+ 560679,
+ 518270,
+ 23033,
+ 501059,
+ 0,
+ 3909,
+ 272062,
+ 261581,
+ 187,
+ 52043,
+ 334,
+ 24354,
+ 3947,
+ 8549,
+ 37863,
+ 328851,
+ 963771,
+ 1,
+ 3930,
+ 82416,
+ 6,
+ 2943,
+ 122101,
+ 82577,
+ 85,
+ 89540,
+ 5135,
+ 109236,
+ 18297,
+ 1,
+ 177371,
+ 4541,
+ 769577,
+ 178,
+ 417,
+ 960566,
+ 33803,
+ 911651,
+ 248160,
+ 153725,
+ 43981,
+ 809174,
+ 116,
+ 486900,
+ 4842,
+ 148490,
+ 131534,
+ 4347,
+ 239949,
+ 984096,
+ 749756,
+ 429499,
+ 2794,
+ 78209,
+ 18812,
+ 21111,
+ 490,
+ 328042,
+ 12,
+ 132119,
+ 505103,
+ 353148,
+ 0,
+ 373656,
+ 951244,
+ 491,
+ 355778,
+ 30620,
+ 317,
+ 60175,
+ 220,
+ 214496,
+ 41249,
+ 5169,
+ 78367,
+ 506804,
+ 0,
+ 1368,
+ 407,
+ 295126,
+ 1288,
+ 86,
+ 97614,
+ 61640,
+ 244723,
+ 3,
+ 0,
+ 869827,
+ 527246,
+ 52,
+ 107036,
+ 240739,
+ 780281,
+ 113084,
+ 62009,
+ 740343,
+ 483201,
+ 8649,
+ 16419,
+ 1,
+ 801574,
+ 95524,
+ 326126,
+ 26912,
+ 877040,
+ 10262,
+ 5895,
+ 0,
+ 132633,
+ 59171,
+ 306347,
+ 702701,
+ 196245,
+ 12642,
+ 32723,
+ 24608,
+ 30287,
+ 45775,
+ 18281,
+ 7587,
+ 144532,
+ 5,
+ 35,
+ 99862,
+ 215127,
+ 170875,
+ 61461,
+ 77790,
+ 5,
+ 0,
+ 129358,
+ 0,
+ 105084,
+ 21399,
+ 42233,
+ 85397,
+ 480654,
+ 555988,
+ 89575,
+ 42346,
+ 20004,
+ 11102,
+ 21321,
+ 185,
+ 379267,
+ 849147,
+ 121514,
+ 3388,
+ 33662,
+ 12,
+ 164898,
+ 226,
+ 274,
+ 385003,
+ 365052,
+ 693376,
+ 41245,
+ 9010,
+ 41594,
+ 89835,
+ 10490,
+ 272,
+ 128437,
+ 0,
+ 122648,
+ 277,
+ 116505,
+ 38372,
+ 4,
+ 1376,
+ 0,
+ 46317,
+ 139368,
+ 36398,
+ 193899,
+ 30632,
+ 26371,
+ 7548,
+ 367643,
+ 954849,
+ 25889,
+ 36567,
+ 176,
+ 140631,
+ 4690,
+ 975031,
+ 80965,
+ 500471,
+ 8442,
+ 43,
+ 27758,
+ 301501,
+ 3797,
+ 80,
+ 384440,
+ 928477,
+ 4960,
+ 24566,
+ 33245,
+ 14638,
+ 228354,
+ 54347,
+ 861285,
+ 12841,
+ 2,
+ 157402,
+ 646747,
+ 53763,
+ 1,
+ 214732,
+ 49471,
+ 49757,
+ 998,
+ 201135,
+ 566,
+ 73512,
+ 194240,
+ 391773,
+ 21510,
+ 13,
+ 829894,
+ 783200,
+ 565329,
+ 2101,
+ 12,
+ 191043,
+ 1621,
+ 18443,
+ 279,
+ 294135,
+ 526503,
+ 729735,
+ 4639,
+ 444138,
+ 5835,
+ 12372,
+ 46362,
+ 1543,
+ 870907,
+ 83262,
+ 0,
+ 38331,
+ 95,
+ 1194,
+ 909,
+ 8053,
+ 453066,
+ 845561,
+ 411,
+ 3229,
+ 1,
+ 158,
+ 1431,
+ 835137,
+ 21774,
+ 7298,
+ 148388,
+ 224649,
+ 379318,
+ 520138,
+ 39781,
+ 172130,
+ 362634,
+ 487495,
+ 51957,
+ 158,
+ 1770,
+ 7,
+ 18010,
+ 1063,
+ 171484,
+ 19924,
+ 279867,
+ 469956,
+ 189785,
+ 0,
+ 814,
+ 60580,
+ 944349,
+ 18743,
+ 553235,
+ 0,
+ 95475,
+ 99,
+ 0,
+ 5,
+ 42623,
+ 178418,
+ 398940,
+ 5700,
+ 69023,
+ 5786,
+ 0,
+ 10531,
+ 551,
+ 86308,
+ 63451,
+ 32704,
+ 176903,
+ 0,
+ 251689,
+ 11589,
+ 25711,
+ 43437,
+ 1431,
+ 304,
+ 52965,
+ 34816,
+ 268688,
+ 47756,
+ 825323,
+ 122608,
+ 81246,
+ 69974,
+ 360515,
+ 99973,
+ 143015,
+ 5063,
+ 4499,
+ 34459,
+ 171982,
+ 677943,
+ 489082,
+ 257515,
+ 3765,
+ 5,
+ 7416,
+ 602206,
+ 74122,
+ 3,
+ 686204,
+ 5493,
+ 28901,
+ 11349,
+ 549668,
+ 257082,
+ 82000,
+ 17031,
+ 1517,
+ 7442,
+ 937160,
+ 722,
+ 0,
+ 72952,
+ 377192,
+ 438266,
+ 555,
+ 31436,
+ 284,
+ 56390,
+ 0,
+ 585856,
+ 27635,
+ 519344,
+ 126131,
+ 360273,
+ 845073,
+ 0,
+ 191965,
+ 55652,
+ 23,
+ 112773,
+ 639025,
+ 84749,
+ 0,
+ 330822,
+ 7173,
+ 126217,
+ 871,
+ 112112,
+ 0,
+ 664,
+ 530474,
+ 1,
+ 379564,
+ 172617,
+ 647308,
+ 0,
+ 356,
+ 17,
+ 84345,
+ 457,
+ 0,
+ 8,
+ 6,
+ 136602,
+ 634424,
+ 0,
+ 177298,
+ 100726,
+ 91661,
+ 383792,
+ 1665,
+ 43583,
+ 15775,
+ 4083,
+ 4277,
+ 345749,
+ 969599,
+ 65804,
+ 19327,
+ 0,
+ 352514,
+ 4225,
+ 9,
+ 103767,
+ 0,
+ 0,
+ 148436,
+ 850,
+ 33,
+ 2146,
+ 20153,
+ 50,
+ 9063,
+ 50329,
+ 348379,
+ 2569,
+ 83697,
+ 37073,
+ 715486,
+ 629,
+ 4753,
+ 442,
+ 259203,
+ 287223,
+ 48625,
+ 9,
+ 70184,
+ 45946,
+ 144947,
+ 0,
+ 60285,
+ 28640,
+ 7626,
+ 134159,
+ 33,
+ 12452,
+ 150566,
+ 348293,
+ 124426,
+ 353952,
+ 11,
+ 22,
+ 776742,
+ 29072,
+ 132168,
+ 254533,
+ 319957,
+ 1602,
+ 1659,
+ 209341,
+ 32847,
+ 92392,
+ 753005,
+ 1392,
+ 10271,
+ 28557,
+ 6717,
+ 941745,
+ 0,
+ 0,
+ 0,
+ 78645,
+ 45320,
+ 11193,
+ 1448,
+ 130626,
+ 377907,
+ 795535,
+ 24285,
+ 26094,
+ 266691,
+ 64449,
+ 77400,
+ 191410,
+ 1,
+ 1346,
+ 25224,
+ 489637,
+ 47052,
+ 248592,
+ 76689,
+ 0,
+ 7722,
+ 47285,
+ 3152,
+ 285577,
+ 0,
+ 149366,
+ 264346,
+ 1,
+ 208602,
+ 320459,
+ 131771,
+ 1421,
+ 350,
+ 723283,
+ 714934,
+ 0,
+ 566439,
+ 11656,
+ 34189,
+ 125484,
+ 943273,
+ 15,
+ 7789,
+ 0,
+ 7427,
+ 464278,
+ 680924,
+ 651102,
+ 87794,
+ 39640,
+ 838644,
+ 964500,
+ 1,
+ 1765,
+ 272604,
+ 10,
+ 837347,
+ 44845,
+ 130,
+ 163357,
+ 4150,
+ 403331,
+ 839132,
+ 44876,
+ 272792,
+ 592527,
+ 57225,
+ 128826,
+ 2915,
+ 2,
+ 3570,
+ 2410,
+ 199,
+ 171358,
+ 5931,
+ 53620,
+ 55299,
+ 1868,
+ 24123,
+ 165,
+ 346513,
+ 16527,
+ 133,
+ 517412,
+ 195700,
+ 730365,
+ 896209,
+ 152760,
+ 24577,
+ 65,
+ 8218,
+ 349642,
+ 901345,
+ 5127,
+ 5102,
+ 238318,
+ 955,
+ 631921,
+ 12218,
+ 55101,
+ 930381,
+ 219503,
+ 469237,
+ 132,
+ 16701,
+ 494,
+ 199729,
+ 0,
+ 32139,
+ 314,
+ 172,
+ 2947,
+ 106997,
+ 4871,
+ 236,
+ 6146,
+ 1843,
+ 128,
+ 0,
+ 254240,
+ 2964,
+ 14825,
+ 60624,
+ 2108,
+ 286953,
+ 654931,
+ 0,
+ 0,
+ 396587,
+ 19852,
+ 70311,
+ 363561,
+ 282,
+ 17966,
+ 924254,
+ 104173,
+ 130816,
+ 179096,
+ 105466,
+ 136,
+ 618261,
+ 358433,
+ 25587,
+ 49357,
+ 102,
+ 133746,
+ 620776,
+ 17084,
+ 406881,
+ 802675,
+ 349,
+ 69,
+ 8761,
+ 278482,
+ 16336,
+ 128,
+ 160096,
+ 25857,
+ 280,
+ 39639,
+ 726299,
+ 293905,
+ 4621,
+ 41,
+ 649,
+ 3655,
+ 269286,
+ 578026,
+ 0,
+ 11156,
+ 1,
+ 744858,
+ 531,
+ 48155,
+ 28435,
+ 7991,
+ 447,
+ 10201,
+ 379341,
+ 0,
+ 5773,
+ 0,
+ 295,
+ 228592,
+ 331155,
+ 104089,
+ 628069,
+ 29693,
+ 22,
+ 13,
+ 0,
+ 0,
+ 554349,
+ 6082,
+ 238,
+ 23,
+ 151873,
+ 805937,
+ 0,
+ 194076,
+ 6450,
+ 3,
+ 128322,
+ 69149,
+ 95511,
+ 86,
+ 844368,
+ 415964,
+ 51985,
+ 308686,
+ 553403,
+ 624943,
+ 365800,
+ 4,
+ 120263,
+ 91239,
+ 195248,
+ 58010,
+ 19,
+ 415112,
+ 136806,
+ 42,
+ 571848,
+ 55306,
+ 29454,
+ 3,
+ 144926,
+ 189,
+ 0,
+ 161943,
+ 592155,
+ 10930,
+ 279297,
+ 56932,
+ 957430,
+ 10244,
+ 190296,
+ 807209,
+ 781,
+ 1466,
+ 235055,
+ 33,
+ 196,
+ 58280,
+ 436,
+ 408649,
+ 221,
+ 711143,
+ 10495,
+ 2441,
+ 275720,
+ 2,
+ 15391,
+ 132107,
+ 102610,
+ 688549,
+ 237142,
+ 3041,
+ 14,
+ 308623,
+ 0,
+ 0,
+ 287,
+ 295147,
+ 61443,
+ 229,
+ 207,
+ 2051,
+ 64,
+ 13479,
+ 55656,
+ 570134,
+ 50387,
+ 225869,
+ 20615,
+ 258465,
+ 64932,
+ 112461,
+ 164521,
+ 907269,
+ 758563,
+ 22901,
+ 0,
+ 7944,
+ 48,
+ 154921,
+ 2784,
+ 548608,
+ 0,
+ 12524,
+ 142556,
+ 0,
+ 13882,
+ 507227,
+ 316598,
+ 987551,
+ 0,
+ 894687,
+ 1964,
+ 364,
+ 10316,
+ 440269,
+ 9,
+ 776723,
+ 72288,
+ 54604,
+ 185101,
+ 142,
+ 362,
+ 11679,
+ 77,
+ 79,
+ 529321,
+ 364,
+ 42387,
+ 0,
+ 570879,
+ 417503,
+ 604871,
+ 578806,
+ 1102,
+ 66584,
+ 615440,
+ 146744,
+ 19441,
+ 170478,
+ 144069,
+ 36170,
+ 145376,
+ 842283,
+ 193612,
+ 3,
+ 359429,
+ 368596,
+ 0,
+ 11064,
+ 7726,
+ 229410,
+ 63569,
+ 67402,
+ 91,
+ 203201,
+ 213513,
+ 0,
+ 704479,
+ 1325,
+ 0,
+ 385154,
+ 13,
+ 806763,
+ 197132,
+ 6183,
+ 45760,
+ 99377,
+ 0,
+ 972077,
+ 4043,
+ 195700,
+ 34229,
+ 0,
+ 154027,
+ 633,
+ 6,
+ 32142,
+ 0,
+ 29,
+ 620842,
+ 14099,
+ 495465,
+ 26937,
+ 0,
+ 0,
+ 432,
+ 227704,
+ 0,
+ 63,
+ 0,
+ 19,
+ 863491,
+ 20,
+ 1,
+ 160713,
+ 24607,
+ 85800,
+ 3566,
+ 37854,
+ 81913,
+ 121573,
+ 816,
+ 20,
+ 133253,
+ 692231,
+ 4869,
+ 255175,
+ 15028,
+ 9383,
+ 542877,
+ 4608,
+ 369610,
+ 243635,
+ 385285,
+ 391565,
+ 286009,
+ 0,
+ 61685,
+ 416318,
+ 208,
+ 67019,
+ 788416,
+ 88,
+ 165056,
+ 0,
+ 439589,
+ 160,
+ 105528,
+ 152,
+ 160624,
+ 865,
+ 390229,
+ 714086,
+ 6007,
+ 30229,
+ 481306,
+ 173266,
+ 1135,
+ 2266,
+ 8,
+ 59,
+ 104722,
+ 647885,
+ 579471,
+ 21309,
+ 230834,
+ 140278,
+ 31858,
+ 3288,
+ 36011,
+ 151387,
+ 594217,
+ 22439,
+ 418638,
+ 76859,
+ 29363,
+ 154809,
+ 275533,
+ 39,
+ 472996,
+ 22076,
+ 7481,
+ 155705,
+ 10406,
+ 214779,
+ 223,
+ 1312,
+ 16391,
+ 17203,
+ 55605,
+ 44579,
+ 69332,
+ 303,
+ 19217,
+ 26288,
+ 126212,
+ 316,
+ 98,
+ 114,
+ 37382,
+ 137591,
+ 439749,
+ 12972,
+ 54,
+ 154879,
+ 0,
+ 102680,
+ 7639,
+ 309119,
+ 263550,
+ 766,
+ 1124,
+ 56,
+ 686608,
+ 123767,
+ 518054,
+ 18,
+ 672385,
+ 3161,
+ 53791,
+ 26769,
+ 451670,
+ 61,
+ 148245,
+ 2713,
+ 96725,
+ 4794,
+ 33247,
+ 297946,
+ 33380,
+ 0,
+ 20034,
+ 5647,
+ 17227,
+ 76444,
+ 0,
+ 21011,
+ 675,
+ 13226,
+ 1027,
+ 990842,
+ 124459,
+ 34406,
+ 53,
+ 69540,
+ 134,
+ 0,
+ 168521,
+ 6,
+ 4075,
+ 1137,
+ 63740,
+ 220,
+ 10434,
+ 1171,
+ 28950,
+ 0,
+ 79680,
+ 993269,
+ 355622,
+ 15,
+ 0,
+ 1452,
+ 21667,
+ 22208,
+ 494484,
+ 33984,
+ 691308,
+ 10,
+ 693686,
+ 196,
+ 9,
+ 70676,
+ 157660,
+ 775,
+ 165,
+ 468432,
+ 1083,
+ 515154,
+ 778344,
+ 70241,
+ 42,
+ 40931,
+ 277125,
+ 43837,
+ 301881,
+ 1332,
+ 56712,
+ 9013,
+ 1299,
+ 7564,
+ 31092,
+ 1975,
+ 113517,
+ 833295,
+ 245021,
+ 36503,
+ 23586,
+ 149327,
+ 89175,
+ 10512,
+ 484348,
+ 187793,
+ 954609,
+ 53199,
+ 792175,
+ 126,
+ 12369,
+ 405,
+ 0,
+ 6614,
+ 322857,
+ 166,
+ 571874,
+ 60839,
+ 180975,
+ 146722,
+ 411565,
+ 1536,
+ 1,
+ 11,
+ 116230,
+ 60514,
+ 9003,
+ 2325,
+ 43763,
+ 63,
+ 355553,
+ 0,
+ 389876,
+ 14672,
+ 11526,
+ 160209,
+ 65,
+ 10283,
+ 966,
+ 10,
+ 58333,
+ 129920,
+ 2850,
+ 83346,
+ 0,
+ 14,
+ 295819,
+ 679550,
+ 143928,
+ 29489,
+ 82324,
+ 36558,
+ 267118,
+ 143313,
+ 90107,
+ 12789,
+ 951,
+ 0,
+ 187619,
+ 295317,
+ 82,
+ 41326,
+ 309682,
+ 907327,
+ 809358,
+ 324,
+ 139157,
+ 12,
+ 78366,
+ 671811,
+ 354,
+ 131,
+ 70525,
+ 35830,
+ 281018,
+ 91456,
+ 92523,
+ 54874,
+ 48273,
+ 2423,
+ 0,
+ 81,
+ 361314,
+ 374811,
+ 394758,
+ 15350,
+ 795,
+ 3,
+ 16779,
+ 796684,
+ 477556,
+ 73927,
+ 26643,
+ 119281,
+ 62692,
+ 17039,
+ 454778,
+ 952,
+ 48973,
+ 19529,
+ 151,
+ 239121,
+ 93509,
+ 254702,
+ 1307,
+ 10029,
+ 7973,
+ 546706,
+ 806644,
+ 680517,
+ 223,
+ 0,
+ 2,
+ 0,
+ 402421,
+ 619193,
+ 15685,
+ 2,
+ 939715,
+ 519198,
+ 0,
+ 444312,
+ 23204,
+ 35669,
+ 32467,
+ 0,
+ 799725,
+ 5883,
+ 2217,
+ 32292,
+ 355557,
+ 22179,
+ 1066,
+ 15704,
+ 610,
+ 37819,
+ 403626,
+ 83101,
+ 10989,
+ 311607,
+ 43394,
+ 72576,
+ 335450,
+ 85964,
+ 73734,
+ 105142,
+ 38292,
+ 0,
+ 181516,
+ 33959,
+ 611797,
+ 221838,
+ 5931,
+ 7666,
+ 1044,
+ 477173,
+ 13591,
+ 405,
+ 521,
+ 190653,
+ 184191,
+ 0,
+ 215,
+ 847195,
+ 22782,
+ 11912,
+ 27345,
+ 2572,
+ 0,
+ 566350,
+ 7,
+ 52302,
+ 26641,
+ 587826,
+ 127,
+ 2,
+ 44449,
+ 153198,
+ 14,
+ 926,
+ 285,
+ 0,
+ 938196,
+ 52255,
+ 9153,
+ 807,
+ 12548,
+ 358324,
+ 18521,
+ 104956,
+ 42738,
+ 116,
+ 135772,
+ 189554,
+ 38,
+ 54,
+ 36,
+ 89768,
+ 17170,
+ 75,
+ 34502,
+ 45489,
+ 172796,
+ 971810,
+ 16153,
+ 499280,
+ 1,
+ 879663,
+ 53830,
+ 186,
+ 539,
+ 242059,
+ 268,
+ 402,
+ 2732,
+ 68057,
+ 18463,
+ 198560,
+ 10068,
+ 591753,
+ 6116,
+ 699280,
+ 1,
+ 0,
+ 114258,
+ 277,
+ 149,
+ 283821,
+ 352561,
+ 88172,
+ 684476,
+ 3450,
+ 87,
+ 99936,
+ 3155,
+ 72983,
+ 31619,
+ 8832,
+ 58666,
+ 0,
+ 59023,
+ 306091,
+ 352150,
+ 255063,
+ 992708,
+ 23,
+ 4896,
+ 18165,
+ 424401,
+ 227613,
+ 5175,
+ 347,
+ 139846,
+ 11962,
+ 714,
+ 3501,
+ 82367,
+ 11110,
+ 10,
+ 12874,
+ 0,
+ 0,
+ 222712,
+ 169,
+ 123281,
+ 0,
+ 268149,
+ 101,
+ 17446,
+ 4262,
+ 489,
+ 0,
+ 30,
+ 0,
+ 277235,
+ 28,
+ 71,
+ 23,
+ 61219,
+ 953631,
+ 477548,
+ 662491,
+ 273,
+ 44787,
+ 4130,
+ 14483,
+ 470571,
+ 735977,
+ 406648,
+ 815898,
+ 5985,
+ 462696,
+ 937510,
+ 9,
+ 0,
+ 111727,
+ 93,
+ 331435,
+ 336402,
+ 78690,
+ 49,
+ 0,
+ 87422,
+ 1242,
+ 0,
+ 8783,
+ 8540,
+ 314,
+ 33411,
+ 805718,
+ 247,
+ 6870,
+ 523743,
+ 8323,
+ 612593,
+ 430,
+ 354048,
+ 264913,
+ 83,
+ 114063,
+ 202825,
+ 35202,
+ 32823,
+ 185554,
+ 85760,
+ 45159,
+ 5971,
+ 267733,
+ 4545,
+ 116,
+ 6910,
+ 24833,
+ 218,
+ 922362,
+ 221735,
+ 740,
+ 7112,
+ 31,
+ 15739,
+ 523589,
+ 4,
+ 95996,
+ 936,
+ 823951,
+ 0,
+ 88,
+ 160,
+ 375419,
+ 663627,
+ 3741,
+ 22896,
+ 114326,
+ 415962,
+ 880100,
+ 6222,
+ 18650,
+ 35524,
+ 195076,
+ 506,
+ 451640,
+ 541336,
+ 70903,
+ 3946,
+ 1,
+ 61765,
+ 1,
+ 2696,
+ 753129,
+ 289,
+ 225234,
+ 378692,
+ 1703,
+ 6751,
+ 1,
+ 820,
+ 7677,
+ 589,
+ 12412,
+ 317,
+ 69,
+ 226031,
+ 134523,
+ 318253,
+ 66677,
+ 111025,
+ 96,
+ 0,
+ 96,
+ 523528,
+ 1017,
+ 0,
+ 258740,
+ 420947,
+ 4600,
+ 400684,
+ 12174,
+ 11770,
+ 52,
+ 5959,
+ 82658,
+ 531787,
+ 202,
+ 548430,
+ 964,
+ 1054,
+ 34,
+ 96897,
+ 25445,
+ 47609,
+ 386052,
+ 97004,
+ 1935,
+ 30074,
+ 13458,
+ 494105,
+ 54,
+ 65575,
+ 594698,
+ 2340,
+ 20259,
+ 84,
+ 2774,
+ 534,
+ 972534,
+ 115057,
+ 0,
+ 11379,
+ 0,
+ 271,
+ 266305,
+ 132595,
+ 2,
+ 773561,
+ 52365,
+ 3585,
+ 351,
+ 148206,
+ 778964,
+ 149379,
+ 596,
+ 284914,
+ 2900,
+ 35596,
+ 1547,
+ 212027,
+ 8100,
+ 12248,
+ 3013,
+ 1814,
+ 183415,
+ 273633,
+ 15812,
+ 0,
+ 966680,
+ 14830,
+ 134309,
+ 0,
+ 416450,
+ 206611,
+ 816,
+ 82258,
+ 9873,
+ 3155,
+ 53485,
+ 779805,
+ 107690,
+ 254475,
+ 102504,
+ 72495,
+ 17301,
+ 472130,
+ 6895,
+ 245420,
+ 7299,
+ 110508,
+ 27776,
+ 246134,
+ 0,
+ 330853,
+ 0,
+ 271767,
+ 61886,
+ 24123,
+ 309681,
+ 58325,
+ 608865,
+ 20666,
+ 87349,
+ 229228,
+ 246,
+ 457768,
+ 5374,
+ 69643,
+ 148,
+ 618375,
+ 45236,
+ 352565,
+ 133904,
+ 152,
+ 10688,
+ 18,
+ 0,
+ 276036,
+ 493281,
+ 11156,
+ 12566,
+ 5762,
+ 113,
+ 24179,
+ 98,
+ 327,
+ 893,
+ 209180,
+ 140805,
+ 0,
+ 2341,
+ 66309,
+ 30305,
+ 630559,
+ 3682,
+ 152767,
+ 265822,
+ 142868,
+ 1535,
+ 728603,
+ 69081,
+ 353151,
+ 237995,
+ 1075,
+ 925071,
+ 86,
+ 6748,
+ 0,
+ 684186,
+ 735,
+ 13793,
+ 4790,
+ 73175,
+ 69677,
+ 367627,
+ 238650,
+ 303543,
+ 1,
+ 26059,
+ 21392,
+ 10,
+ 288609,
+ 0,
+ 76345,
+ 158496,
+ 7000,
+ 1865,
+ 20385,
+ 0,
+ 54213,
+ 9948,
+ 102667,
+ 6963,
+ 71,
+ 555744,
+ 5626,
+ 2512,
+ 1124,
+ 7171,
+ 628,
+ 29225,
+ 321687,
+ 61519,
+ 4,
+ 8352,
+ 9156,
+};
+
+char *pointers[NCYCLES];
+
+int main(void)
+{
+ int r, i, j, sp, sq;
+ char *p, *q, *ep, *eq;
+ int ok;
+ int err = 0;
+
+ for ( r = 0 ; r < 4 ; r++ ) {
+ for ( i = 0 ; i < NCYCLES ; i++ ) {
+ pointers[i] = p = malloc(sp = sizes[i]);
+ ep = p+sp;
+ ok = 1;
+ for ( j = 0 ; j < i ; j++ ) {
+ q = pointers[j];
+ sq = sizes[j];
+ eq = q+sq;
+
+ if ( (p < q && ep > q) || (p >= q && p < eq) ) {
+ ok = 0;
+ err = 1;
+ break;
+ }
+ }
+ printf("Allocated %6d bytes at %p, ok = %d\n", sp, p, ok);
+
+ if ( p )
+ memset(p, 0xee, sp); /* Poison this memory */
+ }
+
+ for ( i = 0 ; i < NCYCLES ; i++ ) {
+ free(pointers[i]);
+ printf("Freed %6d bytes at %p\n", sizes[i], pointers[i]);
+ }
+ }
+
+ return err;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/malloctest2.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/malloctest2.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,60 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define NCYCLES 32768
+#define NSLOTS 4096
+
+struct slot {
+ char *ptr;
+ size_t size;
+};
+
+struct slot s[NSLOTS];
+
+int main(void)
+{
+ size_t sp, sq;
+ char *p, *ep, *q, *eq;
+ int r, i, j;
+ int ok;
+ int err = 0;
+
+ for ( r = 0 ; r < NCYCLES ; r++ ) {
+ i = lrand48() % NSLOTS;
+
+ if ( s[i].ptr ) {
+ free(s[i].ptr);
+ printf("Freed %8zu bytes at %p\n", s[i].size, s[i].ptr);
+ s[i].ptr = NULL;
+ s[i].size = 0;
+ } else {
+ sp = lrand48(); /* 32-bit random number */
+ sp >>= 12+(lrand48() % 20);
+
+ s[i].size = sp;
+ s[i].ptr = p = malloc(sp);
+ ep = p+sp;
+ ok = 1;
+ for ( j = 0 ; j < NSLOTS ; j++ ) {
+ q = s[j].ptr;
+ if ( i != j && q ) {
+ sq = s[j].size;
+ eq = q+sq;
+
+ if ( (p < q && ep > q) || (p >= q && p < eq) ) {
+ ok = 0;
+ err = 1;
+ break;
+ }
+ }
+ }
+ printf("Allocated %8zu bytes at %p, ok = %d\n", sp, p, ok);
+
+ if ( p )
+ memset(p, 0xee, sp); /* Poison this memory */
+ }
+ }
+ return err;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/memstrtest.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/memstrtest.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+int main(void)
+{
+ unsigned char t1[256], t2[256];
+ int i;
+ int r;
+
+ for(i = 0; i < (int)sizeof(t1); i++)
+ t1[i] = t2[i] = (unsigned char)i;
+
+ r = memcmp(t1, t2, sizeof(t1));
+ printf("memcmp r = %d\n", r);
+ r = memcmp(t1, t2, sizeof(t1)/2);
+ printf("memcmp r = %d\n", r);
+ t1[255] = 0;
+ r = memcmp(t1, t2, sizeof(t1));
+ printf("memcmp r = %d\n", r);
+
+ for (i = 0; i < (int)sizeof(t1); i++)
+ t1[i] = 0xaa;
+ memset(t2, 0xaa, sizeof(t2));
+ r = memcmp(t1, t2, sizeof(t1));
+ printf("memcmp r = %d\n", r);
+ return 0;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/microhello.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/microhello.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,9 @@
+#include <stdio.h>
+#include <unistd.h>
+
+int main(void)
+{
+ static const char hello[] = "Hello, World!\n";
+ _fwrite(hello, sizeof hello-1, stdout);
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/minihello.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/minihello.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(void)
+{
+ fputs("Hello, World!\n", stdout);
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/mmaptest.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/mmaptest.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,28 @@
+/*
+ * mmaptest.c
+ *
+ * Test some simple cases of mmap()
+ */
+
+#include <sys/mman.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdint.h>
+#include <sys/syscall.h>
+
+int main(int argc, char *argv[])
+{
+ void *foo;
+
+ (void)argc; (void)argv;
+
+ /* Important case, this is how we get memory for malloc() */
+ errno = 0;
+ foo = mmap(0, 65536, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+
+ printf("mmap() returned %p, errno = %d\n", foo, errno);
+
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/nfs_no_rpc.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/nfs_no_rpc.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,538 @@
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/utsname.h>
+#include <sys/mount.h>
+#include <netinet/in.h>
+#include <unistd.h>
+#include <signal.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+/* Default path we try to mount. "%s" gets replaced by our IP address */
+#define NFS_ROOT "/tftpboot/%s"
+#define NFS_DEF_FILE_IO_BUFFER_SIZE 4096
+#define NFS_MAXPATHLEN 1024
+#define NFS_MNT_PROGRAM 100005
+#define NFS_MNT_PORT 627
+#define NFS_PROGRAM 100003
+#define NFS_PORT 2049
+#define NFS2_VERSION 2
+#define NFS3_VERSION 3
+#define NFS_MNT_PROGRAM 100005
+#define NFS_MNT_VERSION 1
+#define NFS_MNT3_VERSION 3
+#define MNTPROC_MNT 1
+#define MOUNTPROC3_MNT 1
+#define RPC_PMAP_PROGRAM 100000
+#define RPC_PMAP_VERSION 2
+#define RPC_PMAP_PORT 111
+
+#define NFS2_FHSIZE 32
+#define NFS3_FHSIZE 64
+
+#define RPC_VERSION 2
+
+enum rpc_msg_type {
+ RPC_CALL = 0,
+ RPC_REPLY = 1
+};
+
+enum rpc_auth_flavor {
+ RPC_AUTH_NULL = 0,
+ RPC_AUTH_UNIX = 1,
+ RPC_AUTH_SHORT = 2,
+ RPC_AUTH_DES = 3,
+ RPC_AUTH_KRB = 4,
+};
+
+enum rpc_reply_stat {
+ RPC_MSG_ACCEPTED = 0,
+ RPC_MSG_DENIED = 1
+};
+
+#define NFS_MAXFHSIZE 64
+struct nfs_fh {
+ unsigned short size;
+ unsigned char data[NFS_MAXFHSIZE];
+};
+
+struct nfs2_fh {
+ char data[NFS2_FHSIZE];
+};
+
+#define NFS_MOUNT_VERSION 4
+
+struct nfs_mount_data {
+ int version;
+ int fd;
+ struct nfs2_fh old_root;
+ int flags;
+ int rsize;
+ int wsize;
+ int timeo;
+ int retrans;
+ int acregmin;
+ int acregmax;
+ int acdirmin;
+ int acdirmax;
+ struct sockaddr_in addr;
+ char hostname[256];
+ int namlen;
+ unsigned int bsize;
+ struct nfs_fh root;
+};
+
+#define NFS_MOUNT_SOFT 0x0001 /* 1 */
+#define NFS_MOUNT_INTR 0x0002 /* 1 */
+#define NFS_MOUNT_SECURE 0x0004 /* 1 */
+#define NFS_MOUNT_POSIX 0x0008 /* 1 */
+#define NFS_MOUNT_NOCTO 0x0010 /* 1 */
+#define NFS_MOUNT_NOAC 0x0020 /* 1 */
+#define NFS_MOUNT_TCP 0x0040 /* 2 */
+#define NFS_MOUNT_VER3 0x0080 /* 3 */
+#define NFS_MOUNT_KERBEROS 0x0100 /* 3 */
+#define NFS_MOUNT_NONLM 0x0200 /* 3 */
+#define NFS_MOUNT_BROKEN_SUID 0x0400 /* 4 */
+#define NFS_MOUNT_FLAGMASK 0xFFFF
+
+static char nfs_root_name[256];
+static u_int32_t root_server_addr;
+static char root_server_path[256];
+
+/* Address of NFS server */
+static u_int32_t servaddr;
+
+/* Name of directory to mount */
+static char nfs_path[NFS_MAXPATHLEN];
+
+/* NFS-related data */
+static struct nfs_mount_data nfs_data = {
+ .version = NFS_MOUNT_VERSION,
+ .flags = NFS_MOUNT_NONLM, /* No lockd in nfs root yet */
+ .rsize = NFS_DEF_FILE_IO_BUFFER_SIZE,
+ .wsize = NFS_DEF_FILE_IO_BUFFER_SIZE,
+ .bsize = 0,
+ .timeo = 7,
+ .retrans = 3,
+ .acregmin = 3,
+ .acregmax = 60,
+ .acdirmin = 30,
+ .acdirmax = 60,
+};
+static int nfs_port = -1;
+static int mount_port;
+
+/***************************************************************************
+
+ Parsing of options
+
+ ***************************************************************************/
+
+/*
+ * The following integer options are recognized
+ */
+static struct nfs_int_opts {
+ const char *name;
+ int *val;
+} root_int_opts[] = {
+ { "port", &nfs_port },
+ { "rsize", &nfs_data.rsize },
+ { "wsize", &nfs_data.wsize },
+ { "timeo", &nfs_data.timeo },
+ { "retrans", &nfs_data.retrans },
+ { "acregmin", &nfs_data.acregmin },
+ { "acregmax", &nfs_data.acregmax },
+ { "acdirmin", &nfs_data.acdirmin },
+ { "acdirmax", &nfs_data.acdirmax },
+ { NULL, NULL }
+};
+
+/*
+ * And now the flag options
+ */
+static struct nfs_bool_opts {
+ const char *name;
+ int and_mask;
+ int or_mask;
+} root_bool_opts[] = {
+ { "soft", ~NFS_MOUNT_SOFT, NFS_MOUNT_SOFT },
+ { "hard", ~NFS_MOUNT_SOFT, 0 },
+ { "intr", ~NFS_MOUNT_INTR, NFS_MOUNT_INTR },
+ { "nointr", ~NFS_MOUNT_INTR, 0 },
+ { "posix", ~NFS_MOUNT_POSIX, NFS_MOUNT_POSIX },
+ { "noposix", ~NFS_MOUNT_POSIX, 0 },
+ { "cto", ~NFS_MOUNT_NOCTO, 0 },
+ { "nocto", ~NFS_MOUNT_NOCTO, NFS_MOUNT_NOCTO },
+ { "ac", ~NFS_MOUNT_NOAC, 0 },
+ { "noac", ~NFS_MOUNT_NOAC, NFS_MOUNT_NOAC },
+ { "lock", ~NFS_MOUNT_NONLM, 0 },
+ { "nolock", ~NFS_MOUNT_NONLM, NFS_MOUNT_NONLM },
+#ifdef CONFIG_NFS_V3
+ { "v2", ~NFS_MOUNT_VER3, 0 },
+ { "v3", ~NFS_MOUNT_VER3, NFS_MOUNT_VER3 },
+#endif
+ { "udp", ~NFS_MOUNT_TCP, 0 },
+ { "tcp", ~NFS_MOUNT_TCP, NFS_MOUNT_TCP },
+ { "broken_suid",~NFS_MOUNT_BROKEN_SUID, NFS_MOUNT_BROKEN_SUID },
+ { NULL, 0, 0 }
+};
+/*
+ * Parse option string.
+ */
+static void root_nfs_parse(char *name, char *buf)
+{
+ char *options, *val, *cp;
+
+ if ((options = strchr(name, ','))) {
+ *options++ = 0;
+ cp = strtok(options, ",");
+ while (cp) {
+ if ((val = strchr(cp, '='))) {
+ struct nfs_int_opts *opts = root_int_opts;
+ *val++ = '\0';
+ while (opts->name && strcmp(opts->name, cp))
+ opts++;
+ if (opts->name)
+ *(opts->val) = (int) strtoul(val, NULL, 10);
+ } else {
+ struct nfs_bool_opts *opts = root_bool_opts;
+ while (opts->name && strcmp(opts->name, cp))
+ opts++;
+ if (opts->name) {
+ nfs_data.flags &= opts->and_mask;
+ nfs_data.flags |= opts->or_mask;
+ }
+ }
+ cp = strtok(NULL, ",");
+ }
+ }
+ if (name[0] && strcmp(name, "default")) {
+ strncpy(buf, name, NFS_MAXPATHLEN-1);
+ buf[NFS_MAXPATHLEN-1] = 0;
+ }
+}
+
+/*
+ * Prepare the NFS data structure and parse all options.
+ */
+static int root_nfs_name(char *name)
+{
+ char buf[NFS_MAXPATHLEN];
+ struct utsname uname_buf;
+
+ /* Set some default values */
+ strcpy(buf, NFS_ROOT);
+
+ /* Process options received from the remote server */
+ root_nfs_parse(root_server_path, buf);
+
+ /* Override them by options set on kernel command-line */
+ root_nfs_parse(name, buf);
+
+ uname(&uname_buf);
+ if (strlen(buf) + strlen(uname_buf.nodename) > NFS_MAXPATHLEN) {
+ printf("nfsroot: Pathname for remote directory too long.\n");
+ return -1;
+ }
+ sprintf(nfs_path, buf, uname_buf.nodename);
+
+ return 1;
+}
+
+/***************************************************************************
+
+ Routines to actually mount the root directory
+
+ ***************************************************************************/
+
+/*
+ * Construct sockaddr_in from address and port number.
+ */
+static inline void
+set_sockaddr(struct sockaddr_in *sin, u_int32_t addr, u_int16_t port)
+{
+ memset(sin, 0, sizeof(*sin));
+ sin->sin_family = AF_INET;
+ sin->sin_addr.s_addr = addr;
+ sin->sin_port = port;
+}
+
+/*
+ * Extremely crude RPC-over-UDP call. We get an already encoded request
+ * to pass, we do that and put the reply into buffer. That (and callers
+ * below - getport, getfh2 and getfh3) should be replaced with proper
+ * librpc use. Now, if we only had one that wasn't bloated as a dead
+ * gnu that had lied for a while under the sun...
+ */
+
+static u_int32_t XID;
+static int flag;
+static void timeout(int n)
+{
+ (void)n;
+ flag = 1;
+}
+static int do_call(struct sockaddr_in *sin, u_int32_t msg[], u_int32_t rmsg[],
+ u_int32_t len, u_int32_t rlen)
+{
+ struct sockaddr_in from;
+ int slen = sizeof(struct sockaddr_in);
+ struct timeval tv = {1, 0};
+ int n;
+ int fd;
+
+ sysv_signal(SIGALRM, timeout);
+ fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (fd < 0)
+ goto Esocket;
+ setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (void*)&tv, sizeof(tv));
+ len *= 4;
+ if (sendto(fd, msg, len, 0, (struct sockaddr *)sin, slen)!=(int)len)
+ goto Esend;
+ setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (void*)&tv, sizeof(tv));
+ alarm(0);
+ flag = 0;
+ alarm(5);
+ rlen *= 4;
+ do {
+ slen = sizeof(from);
+ n = recvfrom(fd, rmsg, rlen, 0, (struct sockaddr*)&from, &slen);
+ if (flag || n < 0)
+ goto Erecv;
+ } while (memcmp(&from, sin, sizeof(from)) || rmsg[0] != msg[0]);
+
+ if (n < 6*4 || n % 4 || ntohl(rmsg[1]) != 1 || rmsg[2] ||
+ rmsg[3] || rmsg[4] || rmsg[5])
+ goto Einval;
+ alarm(0);
+ close(fd);
+ return n / 4 - 6;
+
+Esend: printf("rpc: write failed\n");
+ goto out;
+Erecv: printf("rpc: read failed\n");
+ goto out;
+Einval: printf("rpc: invalid response\n");
+ goto out;
+Esocket:printf("rpc: can't create socket\n");
+ return -1;
+out:
+ alarm(0);
+ close(fd);
+ return -1;
+}
+
+enum {
+ PMAP_GETPORT = 3
+};
+
+static void do_header(u_int32_t msg[], u_int32_t prog, u_int32_t vers, u_int32_t proc)
+{
+ msg[0] = XID++;
+ msg[1] = htonl(RPC_CALL);
+ msg[2] = htonl(RPC_VERSION);
+ msg[3] = htonl(prog);
+ msg[4] = htonl(vers);
+ msg[5] = htonl(proc);
+ msg[6] = htonl(RPC_AUTH_NULL);
+ msg[7] = htonl(0);
+ msg[8] = htonl(RPC_AUTH_NULL);
+ msg[9] = htonl(0);
+}
+
+static int getport(u_int32_t prog, u_int32_t vers, u_int32_t prot)
+{
+ struct sockaddr_in sin;
+ unsigned msg[14];
+ unsigned rmsg[7];
+ int n;
+ set_sockaddr(&sin, servaddr, htons(RPC_PMAP_PORT));
+ do_header(msg, RPC_PMAP_PROGRAM, RPC_PMAP_VERSION, PMAP_GETPORT);
+ msg[10] = htonl(prog);
+ msg[11] = htonl(vers);
+ msg[12] = htonl(prot);
+ msg[13] = htonl(0);
+ n = do_call(&sin, msg, rmsg, 14, 7);
+ if (n <= 0)
+ return -1;
+ else
+ return ntohl(rmsg[6]);
+}
+
+static int getfh2(void)
+{
+ struct sockaddr_in sin;
+ unsigned msg[10+1+256/4];
+ unsigned rmsg[6 + 1 + NFS2_FHSIZE/4];
+ int n;
+ int len = strlen(nfs_path);
+ set_sockaddr(&sin, servaddr, mount_port);
+
+ if (len > 255) {
+ printf("nfsroot: pathname is too long");
+ return -1;
+ }
+ memset(msg, 0, sizeof(msg));
+ do_header(msg, NFS_MNT_PROGRAM, NFS_MNT_VERSION, MNTPROC_MNT);
+ msg[10] = htonl(len);
+ strcpy((char*)&msg[11], nfs_path);
+ n = do_call(&sin, msg, rmsg, 11 + (len + 3)/4, 7 + NFS2_FHSIZE/4);
+ if (n < 0)
+ return -1;
+ if (n != NFS2_FHSIZE/4 + 1)
+ goto Esize;
+ if (rmsg[6]) {
+ printf("nfsroot: mountd returned an error (%d)",htonl(rmsg[6]));
+ return -1;
+ }
+ nfs_data.root.size = NFS2_FHSIZE;
+ memcpy(nfs_data.root.data, &rmsg[7], NFS2_FHSIZE);
+ return 0;
+Esize:
+ printf("nfsroot: bad fhandle size");
+ return -1;
+}
+
+static int getfh3(void)
+{
+ struct sockaddr_in sin;
+ unsigned msg[10+1+256/4];
+ unsigned rmsg[6 + 1 + 1 + NFS3_FHSIZE/4];
+ int n;
+ int len = strlen(nfs_path);
+ int size;
+ set_sockaddr(&sin, servaddr, mount_port);
+
+ if (len > 255) {
+ printf("nfsroot: pathname is too long");
+ return -1;
+ }
+ memset(msg, 0, sizeof(msg));
+ do_header(msg, NFS_MNT_PROGRAM, NFS_MNT3_VERSION, MOUNTPROC3_MNT);
+ msg[10] = htonl(len);
+ strcpy((char*)&msg[11], nfs_path);
+ n = do_call(&sin, msg, rmsg, 11 + (len + 3)/4, 8 + NFS3_FHSIZE/4);
+ if (n < 0)
+ return -1;
+ if (n <= 2)
+ goto Esize;
+ if (rmsg[6]) {
+ printf("nfsroot: mountd returned an error (%d)",htonl(rmsg[6]));
+ return -1;
+ }
+ size = ntohl(rmsg[7]);
+ if (size > NFS3_FHSIZE || n != 2 + size/4)
+ goto Esize;
+ nfs_data.root.size = size;
+ memcpy(nfs_data.root.data, &rmsg[8], size);
+ return 0;
+Esize:
+ printf("nfsroot: bad fhandle size");
+ return -1;
+}
+
+/*
+ * Use portmapper to find mountd and nfsd port numbers if not overriden
+ * by the user. Use defaults if portmapper is not available.
+ * XXX: Is there any nfs server with no portmapper?
+ */
+static int root_nfs_ports(void)
+{
+ int port;
+ int nfsd_ver, mountd_ver;
+ int proto;
+
+ if (nfs_data.flags & NFS_MOUNT_VER3) {
+ nfsd_ver = NFS3_VERSION;
+ mountd_ver = NFS_MNT3_VERSION;
+ } else {
+ nfsd_ver = NFS2_VERSION;
+ mountd_ver = NFS_MNT_VERSION;
+ }
+
+ proto = (nfs_data.flags & NFS_MOUNT_TCP) ? IPPROTO_TCP : IPPROTO_UDP;
+
+ if (nfs_port < 0) {
+ if ((port = getport(NFS_PROGRAM, nfsd_ver, proto)) < 0) {
+ printf("nfsroot: Unable to get nfsd port "
+ "number from server, using default\n");
+ port = NFS_PORT;
+ }
+ nfs_port = htons(port);
+ printf("nfsroot: Portmapper on server returned %d "
+ "as nfsd port\n", port);
+ }
+
+ if ((port = getport(NFS_MNT_PROGRAM, mountd_ver, proto)) < 0) {
+ printf("nfsroot: Unable to get mountd port "
+ "number from server, using default\n");
+ port = NFS_MNT_PORT;
+ }
+ mount_port = htons(port);
+ printf("nfsroot: mountd port is %d\n", port);
+
+ return 0;
+}
+
+int main(void)
+{
+ unsigned char *p;
+ struct timeval tv;
+ char *s;
+
+ /* FIX: use getopt() instead of this */
+
+ s = getenv("root_server_addr");
+ if (s)
+ root_server_addr = strtoul(s, NULL, 10);
+ s = getenv("root_server_path");
+ if (s)
+ strncpy(root_server_path, s, 255);
+ s = getenv("nfs_root_name");
+ if (s)
+ strncpy(nfs_root_name, s, 255);
+
+ /*
+ * Decode the root directory path name and NFS options from
+ * the kernel command line. This has to go here in order to
+ * be able to use the client IP address for the remote root
+ * directory (necessary for pure RARP booting).
+ */
+ if (root_nfs_name(nfs_root_name) < 0)
+ return 0;
+ if ((servaddr = root_server_addr) == INADDR_NONE) {
+ printf("nfsroot: No NFS server available, giving up.\n");
+ return 0;
+ }
+
+ p = (char *) &servaddr;
+ sprintf(nfs_data.hostname, "%d.%d.%d.%d", p[0], p[1], p[2], p[3]);
+
+#ifdef NFSROOT_DEBUG
+ printf("nfsroot: Mounting %s on server %s as root\n",
+ nfs_path, nfs_data.hostname);
+ printf("nfsroot: rsize = %d, wsize = %d, timeo = %d, retrans = %d\n",
+ nfs_data.rsize, nfs_data.wsize, nfs_data.timeo, nfs_data.retrans);
+ printf("nfsroot: acreg (min,max) = (%d,%d), acdir (min,max) = (%d,%d)\n",
+ nfs_data.acregmin, nfs_data.acregmax,
+ nfs_data.acdirmin, nfs_data.acdirmax);
+ printf("nfsroot: nfsd port = %d, mountd port = %d, flags = %08x\n",
+ nfs_port, mount_port, nfs_data.flags);
+#endif
+
+ gettimeofday(&tv, NULL);
+ XID = (tv.tv_sec << 15) ^ tv.tv_usec;
+
+ if (root_nfs_ports() < 0)
+ return 0;
+ if (nfs_data.flags & NFS_MOUNT_VER3) {
+ if (getfh3())
+ return 0;
+ } else {
+ if (getfh2())
+ return 0;
+ }
+ set_sockaddr((struct sockaddr_in *) &nfs_data.addr, servaddr, nfs_port);
+ return mount("/dev/root", "/mnt", "nfs", 0, &nfs_data) == 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/opentest.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/opentest.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+int main(void)
+{
+ char buffer[1024];
+ FILE *f;
+
+ f = fopen("/etc/passwd", "r");
+ fgets(buffer, 1024, f);
+ fclose(f);
+
+ printf("Line 1 = %s", buffer);
+
+ return 0;
+}
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/setenvtest.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/setenvtest.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,38 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int main(int argc, char *argv[])
+{
+ (void)argc; (void)argv;
+
+ /* Set SETENV */
+ setenv("SETENV", "setenv", 1);
+
+ /* Set PUTENV */
+ putenv("PUTENV=putenv");
+
+ /* Print the results... */
+ printf("SETENV = %s\n", getenv("SETENV"));
+ printf("PUTENV = %s\n", getenv("PUTENV"));
+
+ /* Override tests */
+ setenv("SETENV", "setenv_good", 1);
+ putenv("PUTENV=putenv_good");
+ printf("SETENV = %s\n", getenv("SETENV"));
+ printf("PUTENV = %s\n", getenv("PUTENV"));
+
+ /* Non-override test */
+ setenv("SETENV", "setenv_bad", 0);
+ setenv("NEWENV", "newenv_good", 0);
+ printf("SETENV = %s\n", getenv("SETENV"));
+ printf("NEWENV = %s\n", getenv("NEWENV"));
+
+ /* Undef test */
+ unsetenv("SETENV");
+ unsetenv("NEWENV");
+ printf("SETENV = %s\n", getenv("SETENV"));
+ printf("NEWENV = %s\n", getenv("NEWENV"));
+
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/setjmptest.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/setjmptest.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,36 @@
+/*
+ * setjmptest.c
+ */
+
+#include <stdio.h>
+#include <setjmp.h>
+
+static jmp_buf buf;
+
+void do_stuff(int v)
+{
+ printf("setjmp returned %d\n", v);
+ longjmp(buf, v+1);
+}
+
+void recurse(int ctr, int v)
+{
+ if ( ctr-- ) {
+ recurse(ctr, v);
+ } else {
+ do_stuff(v);
+ }
+ _fwrite(".", 1, stdout);
+}
+
+int main(void)
+{
+ int v;
+
+ v = setjmp(buf);
+
+ if ( v < 256 )
+ recurse(v,v);
+
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/stat.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/stat.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,65 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/sysmacros.h>
+#include <sys/types.h>
+
+static void do_stat(const char *path)
+{
+ struct stat st;
+
+ if ( stat(path, &st) ) {
+ perror(path);
+ exit(1);
+ }
+
+ printf("Path = %s\n"
+ " st_dev = %#jx (%u,%u)\n"
+ " st_ino = %ju\n"
+ " st_mode = %#jo\n"
+ " st_nlink = %ju\n"
+ " st_uid = %ju\n"
+ " st_gid = %ju\n"
+ " st_rdev = %#jx (%u,%u)\n"
+ " st_size = %ju\n"
+ " st_blksize = %ju\n"
+ " st_blocks = %ju\n",
+ path,
+ (uintmax_t)st.st_dev, major(st.st_dev), minor(st.st_dev),
+ (uintmax_t)st.st_ino,
+ (uintmax_t)st.st_mode,
+ (uintmax_t)st.st_nlink,
+ (uintmax_t)st.st_uid,
+ (uintmax_t)st.st_gid,
+ (uintmax_t)st.st_rdev, major(st.st_rdev), minor(st.st_rdev),
+ (uintmax_t)st.st_size,
+ (uintmax_t)st.st_blksize,
+ (uintmax_t)st.st_blocks);
+
+#ifdef _STATBUF_ST_NSEC
+ printf(" st_atim = %jd.%09u\n"
+ " st.mtim = %jd.%09u\n"
+ " st.ctim = %jd.%09u\n",
+ (uintmax_t)st.st_atim.tv_sec, (unsigned int)st.st_atim.tv_nsec,
+ (uintmax_t)st.st_mtim.tv_sec, (unsigned int)st.st_mtim.tv_nsec,
+ (uintmax_t)st.st_ctim.tv_sec, (unsigned int)st.st_ctim.tv_nsec);
+#else
+ printf(" st_atime = %jd\n"
+ " st.mtime = %jd\n"
+ " st.ctime = %jd\n",
+ (uintmax_t)st.st_atime,
+ (uintmax_t)st.st_mtime,
+ (uintmax_t)st.st_ctime);
+#endif
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+
+ for ( i = 1 ; i < argc ; i++ )
+ do_stat(argv[i]);
+
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/statfs.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/statfs.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,43 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/vfs.h>
+
+static void do_statfs(const char *path)
+{
+ struct statfs sfs;
+
+ if ( statfs(path, &sfs) ) {
+ perror(path);
+ exit(1);
+ }
+
+ printf("Path = %s\n"
+ " f_type = %#jx\n"
+ " f_bsize = %jd\n"
+ " f_blocks = %jd\n"
+ " f_bfree = %jd\n"
+ " f_bavail = %jd\n"
+ " f_files = %jd\n"
+ " f_ffree = %jd\n"
+ " f_namelen = %jd\n",
+ path,
+ (uintmax_t)sfs.f_type,
+ (intmax_t)sfs.f_bsize,
+ (intmax_t)sfs.f_blocks,
+ (intmax_t)sfs.f_bfree,
+ (intmax_t)sfs.f_bavail,
+ (intmax_t)sfs.f_files,
+ (intmax_t)sfs.f_ffree,
+ (intmax_t)sfs.f_namelen);
+}
+
+int main(int argc, char *argv[])
+{
+ int i;
+
+ for ( i = 1 ; i < argc ; i++ )
+ do_statfs(argv[i]);
+
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/strtoimax.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/strtoimax.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+/*
+ * strtoimaxtest.c
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+
+int main(int argc, char *argv[])
+{
+ int i;
+ char *ep;
+ intmax_t iv;
+
+ for ( i = 1 ; i < argc ; i++ ) {
+ iv = strtoimax(argv[i], &ep, 0);
+ printf("strtoimax(\"%s\") = %jd\n", argv[i], iv);
+ if ( *ep )
+ printf(" ep = \"%s\"\n", ep);
+ }
+
+ return 0;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/strtotime.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/strtotime.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <time.h>
+
+int main(int argc, char *argv[])
+{
+ struct timeval tv;
+ struct timespec ts;
+ int i;
+ const char *rv, *rs;
+
+ for ( i = 1 ; i < argc ; i++ ) {
+ rs = strtotimespec(argv[i], &ts);
+ rv = strtotimeval(argv[i], &tv);
+ printf("String: \"%s\"\n"
+ "Timespec: %ld.%09ld\n"
+ "Residual: \"%s\"\n"
+ "Timeval: %ld.%06ld\n"
+ "Residual: \"%s\"\n",
+ argv[i],
+ (long)ts.tv_sec, (long)ts.tv_nsec, rs,
+ (long)tv.tv_sec, (long)tv.tv_usec, rv);
+ }
+
+ return 0;
+}
+
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/testrand48.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/testrand48.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+int main(void)
+{
+ unsigned short seed1[] = { 0x1234, 0x5678, 0x9abc };
+ unsigned short *oldseed;
+
+ oldseed = seed48(seed1);
+ printf("Initial seed: %#06x %#06x %#06x\n",
+ oldseed[0], oldseed[1], oldseed[2]);
+
+ printf("lrand48() = %ld\n", lrand48());
+
+ seed48(seed1);
+ printf("mrand48() = %ld\n", mrand48());
+
+ return 1;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/tests/testvsnp.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/tests/testvsnp.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,115 @@
+#include <assert.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdio.h>
+
+int main(void)
+{
+ int r, i;
+ char buffer[512];
+
+ r = snprintf(buffer, 512, "Hello, %d", 37);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %'d", 37373737);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %'x", 0xdeadbeef);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %'#X", 0xdeadbeef);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %'#llo", 0123456701234567ULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ /* Make sure overflow works correctly */
+ memset(buffer, '\xff', 512);
+ r = snprintf(buffer, 16, "Hello, %'#llo", 0123456701234567ULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+ for ( i = 16 ; i < 512 ; i++ )
+ assert ( buffer[i] == '\xff' );
+
+ r = snprintf(buffer, 512, "Hello, %'#40.20llo", 0123456701234567ULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %'#-40.20llo", 0123456701234567ULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %'#*.*llo", 40, 20, 0123456701234567ULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %'#*.*llo", -40, 20, 0123456701234567ULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %'#*.*llo", -40, -20, 0123456701234567ULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %'#*.*llx", -40, -20, 0123456701234567ULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %p", &buffer);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %P", &buffer);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %20p", &buffer);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %-20p", &buffer);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 512, "Hello, %-20p", NULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 20, "Hello, %'-20p", NULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 15, "Hello, %'-20p", NULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 3, "Hello, %'-20p", NULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ /* This shouldn't change buffer in any way! */
+ r = snprintf(buffer, 0, "Hello, %'-20p", NULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ for ( i = -30 ; i <= 30 ; i++ ) {
+ r = snprintf(buffer, 40, "Hello, %'*p", i, NULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+ }
+
+ r = snprintf(buffer, 40, "Hello, %'-20s", "String");
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 40, "Hello, %'20s", "String");
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 40, "Hello, %'020s", "String");
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 40, "Hello, %'-20s", NULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 40, "Hello, %'20s", NULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 40, "Hello, %'020s", NULL);
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 40, "Hello, %'-20c", '*');
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 40, "Hello, %'20c", '*');
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ r = snprintf(buffer, 40, "Hello, %'020c", '*');
+ printf("buffer = \"%s\" (%d), r = %d\n", buffer, strlen(buffer), r);
+
+ return 0;
+}
+
Added: multipath-tools/upstream/current/klibc-0.190/klibc/time.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/time.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,23 @@
+/*
+ * time.c
+ */
+
+#include <time.h>
+#include <sys/time.h>
+#include <sys/syscall.h>
+
+#ifndef __NR_time
+
+time_t time(time_t *t)
+{
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+
+ if ( t )
+ *t = (time_t)tv.tv_sec;
+
+ return (time_t)tv.tv_sec;
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/umount.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/umount.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * umount.c
+ *
+ * Single-argument form of umount
+ */
+
+#include <sys/mount.h>
+
+int umount(const char *dir)
+{
+ return umount2(dir, 0);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/unsetenv.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/unsetenv.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,40 @@
+/*
+ * unsetenv.c
+ */
+
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+int unsetenv(const char *name)
+{
+ size_t len;
+ char **p, *q;
+ const char *z;
+
+ if ( !name || !name[0] ) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ len = 0;
+ for ( z = name ; *z ; z++ ) {
+ len++;
+ if ( *z == '=' ) {
+ errno = EINVAL;
+ return -1;
+ }
+ }
+
+ for ( p = environ ; (q = *p) ; p++ ) {
+ if ( !strncmp(name,q,len) && q[len] == '=' )
+ break;
+ }
+
+ for ( ; (q = *p) ; p++ ) {
+ p[0] = p[1];
+ }
+
+ return 0;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/usleep.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/usleep.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * usleep.c
+ */
+
+#include <errno.h>
+#include <time.h>
+
+void usleep(unsigned long usec)
+{
+ struct timespec ts;
+
+ ts.tv_sec = usec/1000000UL;
+ ts.tv_nsec = (usec%1000000UL) * 1000;
+ while ( nanosleep(&ts,&ts) == -1 && errno == EINTR );
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/utime.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/utime.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+/*
+ * utime.c
+ */
+
+#include <utime.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/syscall.h>
+
+#ifndef __NR_utime
+
+int utime(const char *filename, const struct utimbuf *buf)
+{
+ struct timeval tvp[2];
+
+ tvp[0].tv_sec = buf->actime;
+ tvp[0].tv_usec = 0;
+ tvp[1].tv_sec = buf->modtime;
+ tvp[1].tv_usec = 0;
+
+ return utimes(filename, tvp);
+}
+
+#endif
Added: multipath-tools/upstream/current/klibc-0.190/klibc/vasprintf.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/vasprintf.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,25 @@
+/*
+ * vasprintf.c
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+int vasprintf(char **bufp, const char *format, va_list ap)
+{
+ va_list ap1;
+ int bytes;
+ char *p;
+
+ va_copy(ap1, ap);
+
+ bytes = vsnprintf(NULL, 0, format, ap1) + 1;
+ va_end(ap1);
+
+ *bufp = p = malloc(bytes);
+ if ( !p )
+ return -1;
+
+ return vsnprintf(p, bytes, format, ap);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/vfprintf.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/vfprintf.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,26 @@
+/*
+ * vfprintf.c
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+#include <unistd.h>
+
+#define BUFFER_SIZE 32768
+
+int vfprintf(FILE *file, const char *format, va_list ap)
+{
+ int rv;
+ char buffer[BUFFER_SIZE];
+
+ rv = vsnprintf(buffer, BUFFER_SIZE, format, ap);
+
+ if ( rv < 0 )
+ return rv;
+
+ if ( rv > BUFFER_SIZE-1 )
+ rv = BUFFER_SIZE-1;
+
+ return _fwrite(buffer, rv, file);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/vprintf.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/vprintf.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+/*
+ * vprintf.c
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+
+int vprintf(const char *format, va_list ap)
+{
+ return vfprintf(stdout, format, ap);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/vsnprintf.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/vsnprintf.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,433 @@
+/*
+ * vsnprintf.c
+ *
+ * vsnprintf(), from which the rest of the printf()
+ * family is built
+ */
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <inttypes.h>
+#include <string.h>
+#include <limits.h>
+#include <stdio.h>
+
+enum flags {
+ FL_ZERO = 0x01, /* Zero modifier */
+ FL_MINUS = 0x02, /* Minus modifier */
+ FL_PLUS = 0x04, /* Plus modifier */
+ FL_TICK = 0x08, /* ' modifier */
+ FL_SPACE = 0x10, /* Space modifier */
+ FL_HASH = 0x20, /* # modifier */
+ FL_SIGNED = 0x40, /* Number is signed */
+ FL_UPPER = 0x80 /* Upper case digits */
+};
+
+/* These may have to be adjusted on certain implementations */
+enum ranks {
+ rank_char = -2,
+ rank_short = -1,
+ rank_int = 0,
+ rank_long = 1,
+ rank_longlong = 2
+};
+
+#define MIN_RANK rank_char
+#define MAX_RANK rank_longlong
+
+#define INTMAX_RANK rank_longlong
+#define SIZE_T_RANK rank_long
+#define PTRDIFF_T_RANK rank_long
+
+#define EMIT(x) ({ if (o<n){*q++ = (x);} o++; })
+
+static size_t
+format_int(char *q, size_t n, uintmax_t val, enum flags flags,
+ int base, int width, int prec)
+{
+ char *qq;
+ size_t o = 0, oo;
+ static const char lcdigits[] = "0123456789abcdef";
+ static const char ucdigits[] = "0123456789ABCDEF";
+ const char *digits;
+ uintmax_t tmpval;
+ int minus = 0;
+ int ndigits = 0, nchars;
+ int tickskip, b4tick;
+
+ /* Select type of digits */
+ digits = (flags & FL_UPPER) ? ucdigits : lcdigits;
+
+ /* If signed, separate out the minus */
+ if ( flags & FL_SIGNED && (intmax_t)val < 0 ) {
+ minus = 1;
+ val = (uintmax_t)(-(intmax_t)val);
+ }
+
+ /* Count the number of digits needed. This returns zero for 0. */
+ tmpval = val;
+ while ( tmpval ) {
+ tmpval /= base;
+ ndigits++;
+ }
+
+ /* Adjust ndigits for size of output */
+
+ if ( flags & FL_HASH && base == 8 ) {
+ if ( prec < ndigits+1 )
+ prec = ndigits+1;
+ }
+
+ if ( ndigits < prec ) {
+ ndigits = prec; /* Mandatory number padding */
+ } else if ( val == 0 ) {
+ ndigits = 1; /* Zero still requires space */
+ }
+
+ /* For ', figure out what the skip should be */
+ if ( flags & FL_TICK ) {
+ tickskip = (base == 16) ? 4 : 3;
+ } else {
+ tickskip = ndigits; /* No tick marks */
+ }
+
+ /* Tick marks aren't digits, but generated by the number converter */
+ ndigits += (ndigits-1)/tickskip;
+
+ /* Now compute the number of nondigits */
+ nchars = ndigits;
+
+ if ( minus || (flags & (FL_PLUS|FL_SPACE)) )
+ nchars++; /* Need space for sign */
+ if ( (flags & FL_HASH) && base == 16 ) {
+ nchars += 2; /* Add 0x for hex */
+ }
+
+ /* Emit early space padding */
+ if ( !(flags & (FL_MINUS|FL_ZERO)) && width > nchars ) {
+ while ( width > nchars ) {
+ EMIT(' ');
+ width--;
+ }
+ }
+
+ /* Emit nondigits */
+ if ( minus )
+ EMIT('-');
+ else if ( flags & FL_PLUS )
+ EMIT('+');
+ else if ( flags & FL_SPACE )
+ EMIT(' ');
+
+ if ( (flags & FL_HASH) && base == 16 ) {
+ EMIT('0');
+ EMIT((flags & FL_UPPER) ? 'X' : 'x');
+ }
+
+ /* Emit zero padding */
+ if ( (flags & (FL_MINUS|FL_ZERO)) == FL_ZERO && width > ndigits ) {
+ while ( width > nchars ) {
+ EMIT('0');
+ width--;
+ }
+ }
+
+ /* Generate the number. This is done from right to left. */
+ q += ndigits; /* Advance the pointer to end of number */
+ o += ndigits;
+ qq = q; oo = o; /* Temporary values */
+
+ b4tick = tickskip;
+ while ( ndigits > 0 ) {
+ if ( !b4tick-- ) {
+ qq--; oo--; ndigits--;
+ if ( oo < n ) *qq = '_';
+ b4tick = tickskip-1;
+ }
+ qq--; oo--; ndigits--;
+ if ( oo < n ) *qq = digits[val%base];
+ val /= base;
+ }
+
+ /* Emit late space padding */
+ while ( (flags & FL_MINUS) && width > nchars ) {
+ EMIT(' ');
+ width--;
+ }
+
+ return o;
+}
+
+
+int vsnprintf(char *buffer, size_t n, const char *format, va_list ap)
+{
+ const char *p = format;
+ char ch;
+ char *q = buffer;
+ size_t o = 0; /* Number of characters output */
+ uintmax_t val = 0;
+ int rank = rank_int; /* Default rank */
+ int width = 0;
+ int prec = -1;
+ int base;
+ size_t sz;
+ enum flags flags = 0;
+ enum {
+ st_normal, /* Ground state */
+ st_flags, /* Special flags */
+ st_width, /* Field width */
+ st_prec, /* Field precision */
+ st_modifiers /* Length or conversion modifiers */
+ } state = st_normal;
+ const char *sarg; /* %s string argument */
+ char carg; /* %c char argument */
+ int slen; /* String length */
+
+ while ( (ch = *p++) ) {
+ switch ( state ) {
+ case st_normal:
+ if ( ch == '%' ) {
+ state = st_flags;
+ flags = 0; rank = rank_int; width = 0; prec = -1;
+ } else {
+ EMIT(ch);
+ }
+ break;
+
+ case st_flags:
+ switch ( ch ) {
+ case '-':
+ flags |= FL_MINUS;
+ break;
+ case '+':
+ flags |= FL_PLUS;
+ break;
+ case '\'':
+ flags |= FL_TICK;
+ break;
+ case ' ':
+ flags |= FL_SPACE;
+ break;
+ case '#':
+ flags |= FL_HASH;
+ break;
+ case '0':
+ flags |= FL_ZERO;
+ break;
+ default:
+ state = st_width;
+ p--; /* Process this character again */
+ break;
+ }
+ break;
+
+ case st_width:
+ if ( ch >= '0' && ch <= '9' ) {
+ width = width*10+(ch-'0');
+ } else if ( ch == '*' ) {
+ width = va_arg(ap, int);
+ if ( width < 0 ) {
+ width = -width;
+ flags |= FL_MINUS;
+ }
+ } else if ( ch == '.' ) {
+ prec = 0; /* Precision given */
+ state = st_prec;
+ } else {
+ state = st_modifiers;
+ p--; /* Process this character again */
+ }
+ break;
+
+ case st_prec:
+ if ( ch >= '0' && ch <= '9' ) {
+ prec = prec*10+(ch-'0');
+ } else if ( ch == '*' ) {
+ prec = va_arg(ap, int);
+ if ( prec < 0 )
+ prec = -1;
+ } else {
+ state = st_modifiers;
+ p--; /* Process this character again */
+ }
+ break;
+
+ case st_modifiers:
+ switch ( ch ) {
+ /* Length modifiers - nonterminal sequences */
+ case 'h':
+ rank--; /* Shorter rank */
+ break;
+ case 'l':
+ rank++; /* Longer rank */
+ break;
+ case 'j':
+ rank = INTMAX_RANK;
+ break;
+ case 'z':
+ rank = SIZE_T_RANK;
+ break;
+ case 't':
+ rank = PTRDIFF_T_RANK;
+ break;
+ case 'L':
+ case 'q':
+ rank += 2;
+ break;
+ default:
+ /* Output modifiers - terminal sequences */
+ state = st_normal; /* Next state will be normal */
+ if ( rank < MIN_RANK ) /* Canonicalize rank */
+ rank = MIN_RANK;
+ else if ( rank > MAX_RANK )
+ rank = MAX_RANK;
+
+ switch ( ch ) {
+ case 'P': /* Upper case pointer */
+ flags |= FL_UPPER;
+ /* fall through */
+ case 'p': /* Pointer */
+ base = 16;
+ prec = (CHAR_BIT*sizeof(void *)+3)/4;
+ flags |= FL_HASH;
+ val = (uintmax_t)(uintptr_t)va_arg(ap, void *);
+ goto is_integer;
+
+ case 'd': /* Signed decimal output */
+ case 'i':
+ base = 10;
+ flags |= FL_SIGNED;
+ switch (rank) {
+ case rank_char:
+ /* Yes, all these casts are needed... */
+ val = (uintmax_t)(intmax_t)(signed char)va_arg(ap, signed int);
+ break;
+ case rank_short:
+ val = (uintmax_t)(intmax_t)(signed short)va_arg(ap, signed int);
+ break;
+ case rank_int:
+ val = (uintmax_t)(intmax_t)va_arg(ap, signed int);
+ break;
+ case rank_long:
+ val = (uintmax_t)(intmax_t)va_arg(ap, signed long);
+ break;
+ case rank_longlong:
+ val = (uintmax_t)(intmax_t)va_arg(ap, signed long long);
+ break;
+ }
+ goto is_integer;
+ case 'o': /* Octal */
+ base = 8;
+ goto is_unsigned;
+ case 'u': /* Unsigned decimal */
+ base = 10;
+ goto is_unsigned;
+ case 'X': /* Upper case hexadecimal */
+ flags |= FL_UPPER;
+ /* fall through */
+ case 'x': /* Hexadecimal */
+ base = 16;
+ goto is_unsigned;
+
+ is_unsigned:
+ switch (rank) {
+ case rank_char:
+ val = (uintmax_t)(unsigned char)va_arg(ap, unsigned int);
+ break;
+ case rank_short:
+ val = (uintmax_t)(unsigned short)va_arg(ap, unsigned int);
+ break;
+ case rank_int:
+ val = (uintmax_t)va_arg(ap, unsigned int);
+ break;
+ case rank_long:
+ val = (uintmax_t)va_arg(ap, unsigned long);
+ break;
+ case rank_longlong:
+ val = (uintmax_t)va_arg(ap, unsigned long long);
+ break;
+ }
+ /* fall through */
+
+ is_integer:
+ sz = format_int(q, (o<n) ? n-o : 0, val, flags, base, width, prec);
+ q += sz; o += sz;
+ break;
+
+ case 'c': /* Character */
+ carg = (char)va_arg(ap, int);
+ sarg = &carg;
+ slen = 1;
+ goto is_string;
+ case 's': /* String */
+ sarg = va_arg(ap, const char *);
+ sarg = sarg ? sarg : "(null)";
+ slen = strlen(sarg);
+ goto is_string;
+
+ is_string:
+ {
+ char sch;
+ int i;
+
+ if ( prec != -1 && slen > prec )
+ slen = prec;
+
+ if ( width > slen && !(flags & FL_MINUS) ) {
+ char pad = (flags & FL_ZERO) ? '0' : ' ';
+ while ( width > slen ) {
+ EMIT(pad);
+ width--;
+ }
+ }
+ for ( i = slen ; i ; i-- ) {
+ sch = *sarg++;
+ EMIT(sch);
+ }
+ if ( width > slen && (flags & FL_MINUS) ) {
+ while ( width > slen ) {
+ EMIT(' ');
+ width--;
+ }
+ }
+ }
+ break;
+
+ case 'n': /* Output the number of characters written */
+ {
+ switch (rank) {
+ case rank_char:
+ *va_arg(ap, signed char *) = o;
+ break;
+ case rank_short:
+ *va_arg(ap, signed short *) = o;
+ break;
+ case rank_int:
+ *va_arg(ap, signed int *) = o;
+ break;
+ case rank_long:
+ *va_arg(ap, signed long *) = o;
+ break;
+ case rank_longlong:
+ *va_arg(ap, signed long long *) = o;
+ break;
+ }
+ }
+ break;
+
+ default: /* Anything else, including % */
+ EMIT(ch);
+ break;
+ }
+ }
+ }
+ }
+
+ /* Null-terminate the string */
+ if ( o<n )
+ *q = '\0'; /* No overflow */
+ else if ( n>0 )
+ buffer[n-1] = '\0'; /* Overflow - terminate at end of buffer */
+
+ return o;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/vsprintf.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/vsprintf.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+/*
+ * vsprintf.c
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+
+int vsprintf(char *buffer, const char *format, va_list ap)
+{
+ return vsnprintf(buffer, ~(size_t)0, format, ap);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/vsscanf.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/vsscanf.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,365 @@
+/*
+ * vsscanf.c
+ *
+ * vsscanf(), from which the rest of the scanf()
+ * family is built
+ */
+
+#include <ctype.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <inttypes.h>
+#include <string.h>
+#include <limits.h>
+#include <stdio.h>
+
+#ifndef LONG_BIT
+#define LONG_BIT (CHAR_BIT*sizeof(long))
+#endif
+
+enum flags {
+ FL_SPLAT = 0x01, /* Drop the value, do not assign */
+ FL_INV = 0x02, /* Character-set with inverse */
+ FL_WIDTH = 0x04, /* Field width specified */
+ FL_MINUS = 0x08, /* Negative number */
+};
+
+enum ranks {
+ rank_char = -2,
+ rank_short = -1,
+ rank_int = 0,
+ rank_long = 1,
+ rank_longlong = 2,
+ rank_ptr = INT_MAX /* Special value used for pointers */
+};
+
+#define MIN_RANK rank_char
+#define MAX_RANK rank_longlong
+
+#define INTMAX_RANK rank_longlong
+#define SIZE_T_RANK rank_long
+#define PTRDIFF_T_RANK rank_long
+
+enum bail {
+ bail_none = 0, /* No error condition */
+ bail_eof, /* Hit EOF */
+ bail_err /* Conversion mismatch */
+};
+
+static inline const char *
+skipspace(const char *p)
+{
+ while ( isspace((unsigned char)*p) ) p++;
+ return p;
+}
+
+#undef set_bit
+static inline void
+set_bit(unsigned long *bitmap, unsigned int bit)
+{
+ bitmap[bit/LONG_BIT] |= 1UL << (bit%LONG_BIT);
+}
+
+#undef test_bit
+static inline int
+test_bit(unsigned long *bitmap, unsigned int bit)
+{
+ return (int)(bitmap[bit/LONG_BIT] >> (bit%LONG_BIT)) & 1;
+}
+
+int vsscanf(const char *buffer, const char *format, va_list ap)
+{
+ const char *p = format;
+ char ch;
+ const char *q = buffer;
+ const char *qq;
+ uintmax_t val = 0;
+ int rank = rank_int; /* Default rank */
+ unsigned int width = UINT_MAX;
+ int base;
+ enum flags flags = 0;
+ enum {
+ st_normal, /* Ground state */
+ st_flags, /* Special flags */
+ st_width, /* Field width */
+ st_modifiers, /* Length or conversion modifiers */
+ st_match_init, /* Initial state of %[ sequence */
+ st_match, /* Main state of %[ sequence */
+ st_match_range, /* After - in a %[ sequence */
+ } state = st_normal;
+ char *sarg = NULL; /* %s %c or %[ string argument */
+ enum bail bail = bail_none;
+ int sign;
+ int converted = 0; /* Successful conversions */
+ unsigned long matchmap[((1 << CHAR_BIT)+(LONG_BIT-1))/LONG_BIT];
+ int matchinv = 0; /* Is match map inverted? */
+ unsigned char range_start = 0;
+
+ while ( (ch = *p++) && !bail ) {
+ switch ( state ) {
+ case st_normal:
+ if ( ch == '%' ) {
+ state = st_flags;
+ flags = 0; rank = rank_int; width = UINT_MAX;
+ } else if ( isspace((unsigned char)ch) ) {
+ q = skipspace(q);
+ } else {
+ if ( *q == ch )
+ q++;
+ else
+ bail = bail_err; /* Match failure */
+ }
+ break;
+
+ case st_flags:
+ switch ( ch ) {
+ case '*':
+ flags |= FL_SPLAT;
+ break;
+ case '0' ... '9':
+ width = (ch-'0');
+ state = st_width;
+ flags |= FL_WIDTH;
+ break;
+ default:
+ state = st_modifiers;
+ p--; /* Process this character again */
+ break;
+ }
+ break;
+
+ case st_width:
+ if ( ch >= '0' && ch <= '9' ) {
+ width = width*10+(ch-'0');
+ } else {
+ state = st_modifiers;
+ p--; /* Process this character again */
+ }
+ break;
+
+ case st_modifiers:
+ switch ( ch ) {
+ /* Length modifiers - nonterminal sequences */
+ case 'h':
+ rank--; /* Shorter rank */
+ break;
+ case 'l':
+ rank++; /* Longer rank */
+ break;
+ case 'j':
+ rank = INTMAX_RANK;
+ break;
+ case 'z':
+ rank = SIZE_T_RANK;
+ break;
+ case 't':
+ rank = PTRDIFF_T_RANK;
+ break;
+ case 'L':
+ case 'q':
+ rank = rank_longlong; /* long double/long long */
+ break;
+
+ default:
+ /* Output modifiers - terminal sequences */
+ state = st_normal; /* Next state will be normal */
+ if ( rank < MIN_RANK ) /* Canonicalize rank */
+ rank = MIN_RANK;
+ else if ( rank > MAX_RANK )
+ rank = MAX_RANK;
+
+ switch ( ch ) {
+ case 'P': /* Upper case pointer */
+ case 'p': /* Pointer */
+#if 0 /* Enable this to allow null pointers by name */
+ q = skipspace(q);
+ if ( !isdigit((unsigned char)*q) ) {
+ static const char * const nullnames[] =
+ { "null", "nul", "nil", "(null)", "(nul)", "(nil)", 0 };
+ const char * const *np;
+
+ /* Check to see if it's a null pointer by name */
+ for ( np = nullnames ; *np ; np++ ) {
+ if ( !strncasecmp(q, *np, strlen(*np)) ) {
+ val = (uintmax_t)((void *)NULL);
+ goto set_integer;
+ }
+ }
+ /* Failure */
+ bail = bail_err;
+ break;
+ }
+ /* else */
+#endif
+ rank = rank_ptr;
+ base = 0; sign = 0;
+ goto scan_int;
+
+ case 'i': /* Base-independent integer */
+ base = 0; sign = 1;
+ goto scan_int;
+
+ case 'd': /* Decimal integer */
+ base = 10; sign = 1;
+ goto scan_int;
+
+ case 'o': /* Octal integer */
+ base = 8; sign = 0;
+ goto scan_int;
+
+ case 'u': /* Unsigned decimal integer */
+ base = 10; sign = 0;
+ goto scan_int;
+
+ case 'x': /* Hexadecimal integer */
+ case 'X':
+ base = 16; sign = 0;
+ goto scan_int;
+
+ case 'n': /* Number of characters consumed */
+ val = (q-buffer);
+ goto set_integer;
+
+ scan_int:
+ q = skipspace(q);
+ if ( !*q ) {
+ bail = bail_eof;
+ break;
+ }
+ val = strntoumax(q, (char **)&qq, base, width);
+ if ( qq == q ) {
+ bail = bail_err;
+ break;
+ }
+ q = qq;
+ converted++;
+ /* fall through */
+
+ set_integer:
+ if ( !(flags & FL_SPLAT) ) {
+ switch(rank) {
+ case rank_char:
+ *va_arg(ap, unsigned char *) = (unsigned char)val;
+ break;
+ case rank_short:
+ *va_arg(ap, unsigned short *) = (unsigned short)val;
+ break;
+ case rank_int:
+ *va_arg(ap, unsigned int *) = (unsigned int)val;
+ break;
+ case rank_long:
+ *va_arg(ap, unsigned long *) = (unsigned long)val;
+ break;
+ case rank_longlong:
+ *va_arg(ap, unsigned long long *) = (unsigned long long)val;
+ break;
+ case rank_ptr:
+ *va_arg(ap, void **) = (void *)(uintptr_t)val;
+ break;
+ }
+ }
+ break;
+
+ case 'c': /* Character */
+ width = (flags & FL_WIDTH) ? width : 1; /* Default width == 1 */
+ sarg = va_arg(ap, char *);
+ while ( width-- ) {
+ if ( !*q ) {
+ bail = bail_eof;
+ break;
+ }
+ *sarg++ = *q++;
+ }
+ if ( !bail )
+ converted++;
+ break;
+
+ case 's': /* String */
+ {
+ char *sp;
+ sp = sarg = va_arg(ap, char *);
+ while ( width-- && *q && !isspace((unsigned char)*q) ) {
+ *sp++ = *q++;
+ }
+ if ( sarg != sp ) {
+ *sp = '\0'; /* Terminate output */
+ converted++;
+ } else {
+ bail = bail_eof;
+ }
+ }
+ break;
+
+ case '[': /* Character range */
+ sarg = va_arg(ap, char *);
+ state = st_match_init;
+ matchinv = 0;
+ memset(matchmap, 0, sizeof matchmap);
+ break;
+
+ case '%': /* %% sequence */
+ if ( *q == '%' )
+ q++;
+ else
+ bail = bail_err;
+ break;
+
+ default: /* Anything else */
+ bail = bail_err; /* Unknown sequence */
+ break;
+ }
+ }
+ break;
+
+ case st_match_init: /* Initial state for %[ match */
+ if ( ch == '^' && !(flags & FL_INV) ) {
+ matchinv = 1;
+ } else {
+ set_bit(matchmap, (unsigned char)ch);
+ state = st_match;
+ }
+ break;
+
+ case st_match: /* Main state for %[ match */
+ if ( ch == ']' ) {
+ goto match_run;
+ } else if ( ch == '-' ) {
+ range_start = (unsigned char)ch;
+ state = st_match_range;
+ } else {
+ set_bit(matchmap, (unsigned char)ch);
+ }
+ break;
+
+ case st_match_range: /* %[ match after - */
+ if ( ch == ']' ) {
+ set_bit(matchmap, (unsigned char)'-'); /* - was last character */
+ goto match_run;
+ } else {
+ int i;
+ for ( i = range_start ; i < (unsigned char)ch ; i++ )
+ set_bit(matchmap, i);
+ state = st_match;
+ }
+ break;
+
+ match_run: /* Match expression finished */
+ qq = q;
+ while ( width && *q && test_bit(matchmap, (unsigned char)*q)^matchinv ) {
+ *sarg++ = *q++;
+ }
+ if ( q != qq ) {
+ *sarg = '\0';
+ converted++;
+ } else {
+ bail = *q ? bail_err : bail_eof;
+ }
+ break;
+ }
+ }
+
+ if ( bail == bail_eof && !converted )
+ converted = -1; /* Return EOF (-1) */
+
+ return converted;
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/wait.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/wait.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * wait.c
+ */
+
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+
+pid_t wait(int *status)
+{
+ return wait4((pid_t)-1, status, 0, NULL);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/wait3.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/wait3.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * wait3.c
+ */
+
+#include <sys/types.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+
+pid_t wait3(int *status, int options, struct rusage *rusage)
+{
+ return wait4((pid_t)-1, status, options, rusage);
+}
Added: multipath-tools/upstream/current/klibc-0.190/klibc/waitpid.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/klibc-0.190/klibc/waitpid.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+/*
+ * waitpid.c
+ */
+
+#include <sys/types.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+
+pid_t waitpid(pid_t pid, int *status, int options)
+{
+ return wait4(pid, status, options, NULL);
+}
Added: multipath-tools/upstream/current/kpartx/ChangeLog
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/ChangeLog Fri Mar 4 08:05:19 2005
@@ -0,0 +1,9 @@
+002:
+* convert to kpartx name everywhere
+* remove all HDGEO ioctl code
+* now work with files by mapping loops on the fly
+* merged and massage lopart.[ch] from lomount.[ch]
+ (due credit to original author here : hpa ?)
+* added a fn find_loop_by_file in lopart.[ch]
+001:
+* Initial release
Added: multipath-tools/upstream/current/kpartx/Makefile
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/Makefile Fri Mar 4 08:05:19 2005
@@ -0,0 +1,61 @@
+# Makefile
+#
+# Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui at free.fr>
+#
+BUILD=glibc
+
+include ../Makefile.inc
+
+ifeq ($(strip $(BUILD)),klibc)
+ CFLAGS = ${REQFLAGS} ${OPTFLAGS} -I$(libdmdir) -I. -I$(multipathdir)
+ OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o gpt.o crc32.o \
+ lopart.o xstrncpy.o \
+ $(MULTIPATHLIB)-$(BUILD).a $(DMLIB)-$(BUILD).a
+else
+ CFLAGS = -pipe -g -Wall -Wunused -Wstrict-prototypes -I. \
+ -I$(multipathdir)
+ LDFLAGS = -ldevmapper
+ OBJS = bsd.o dos.o kpartx.o solaris.o unixware.o \
+ gpt.o crc32.o lopart.o xstrncpy.o $(MULTIPATHLIB)-$(BUILD).a
+endif
+
+EXEC = kpartx
+
+all: $(BUILD)
+
+prepare:
+ rm -f core *.o *.gz
+
+glibc: prepare $(OBJS)
+ $(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
+ $(STRIP) $(EXEC)
+ $(GZIP) $(EXEC).8 > $(EXEC).8.gz
+
+klibc: prepare $(KLIBC) $(OBJS)
+ $(LD) -o $(EXEC) $(CRT0) $(OBJS) $(KLIBC) $(LIBGCC)
+ $(STRIP) $(EXEC)
+ $(GZIP) $(EXEC).8 > $(EXEC).8.gz
+
+$(DMLIB)-$(BUILD).a:
+ make -C $(libdmdir) BUILD=$(BUILD)
+
+$(MULTIPATHLIB)-$(BUILD).a:
+ make -C $(multipathdir) BUILD=$(BUILD)
+
+$(KLIBC):
+ rm -f $(klibcdir)/linux
+ ln -s $(KERNEL_BUILD) $(klibcdir)/linux
+ make -C $(klibcdir)
+
+install:
+ install -d $(DESTDIR)$(bindir)
+ install -m 755 $(EXEC) $(DESTDIR)$(bindir)
+ install -d $(DESTDIR)$(mandir)
+ install -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
+
+uninstall:
+ rm -f $(DESTDIR)$(bindir)/$(EXEC)
+ rm -f $(DESTDIR)$(mandir)/$(EXEC).8.gz
+
+clean:
+ rm -f core *.o $(EXEC) *.gz
Added: multipath-tools/upstream/current/kpartx/README
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/README Fri Mar 4 08:05:19 2005
@@ -0,0 +1,9 @@
+This version of partx is intented to be build
+static against klibc.
+
+It creates partitions as device maps.
+
+With due respect to the original authors,
+
+have fun,
+cvaroqui
Added: multipath-tools/upstream/current/kpartx/bsd.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/bsd.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,83 @@
+#include "kpartx.h"
+#include <stdio.h>
+
+#define BSD_DISKMAGIC (0x82564557UL) /* The disk magic number */
+#define XBSD_MAXPARTITIONS 16
+#define BSD_FS_UNUSED 0
+
+struct bsd_disklabel {
+ unsigned int d_magic; /* the magic number */
+ short int d_type; /* drive type */
+ short int d_subtype; /* controller/d_type specific */
+ char d_typename[16]; /* type name, e.g. "eagle" */
+ char d_packname[16]; /* pack identifier */
+ unsigned int d_secsize; /* # of bytes per sector */
+ unsigned int d_nsectors; /* # of data sectors per track */
+ unsigned int d_ntracks; /* # of tracks per cylinder */
+ unsigned int d_ncylinders; /* # of data cylinders per unit */
+ unsigned int d_secpercyl; /* # of data sectors per cylinder */
+ unsigned int d_secperunit; /* # of data sectors per unit */
+ unsigned short d_sparespertrack;/* # of spare sectors per track */
+ unsigned short d_sparespercyl; /* # of spare sectors per cylinder */
+ unsigned int d_acylinders; /* # of alt. cylinders per unit */
+ unsigned short d_rpm; /* rotational speed */
+ unsigned short d_interleave; /* hardware sector interleave */
+ unsigned short d_trackskew; /* sector 0 skew, per track */
+ unsigned short d_cylskew; /* sector 0 skew, per cylinder */
+ unsigned int d_headswitch; /* head switch time, usec */
+ unsigned int d_trkseek; /* track-to-track seek, usec */
+ unsigned int d_flags; /* generic flags */
+ unsigned int d_drivedata[5]; /* drive-type specific information */
+ unsigned int d_spare[5]; /* reserved for future use */
+ unsigned int d_magic2; /* the magic number (again) */
+ unsigned short d_checksum; /* xor of data incl. partitions */
+
+ /* filesystem and partition information: */
+ unsigned short d_npartitions; /* number of partitions in following */
+ unsigned int d_bbsize; /* size of boot area at sn0, bytes */
+ unsigned int d_sbsize; /* max size of fs superblock, bytes */
+ struct bsd_partition { /* the partition table */
+ unsigned int p_size; /* number of sectors in partition */
+ unsigned int p_offset; /* starting sector */
+ unsigned int p_fsize; /* filesystem basic fragment size */
+ unsigned char p_fstype; /* filesystem type, see below */
+ unsigned char p_frag; /* filesystem fragments per block */
+ unsigned short p_cpg; /* filesystem cylinders per group */
+ } d_partitions[XBSD_MAXPARTITIONS];/* actually may be more */
+};
+
+int
+read_bsd_pt(int fd, struct slice all, struct slice *sp, int ns) {
+ struct bsd_disklabel *l;
+ struct bsd_partition *p;
+ unsigned int offset = all.start;
+ int max_partitions;
+ char *bp;
+ int n = 0;
+
+ bp = getblock(fd, offset+1); /* 1 sector suffices */
+ if (bp == NULL)
+ return -1;
+
+ l = (struct bsd_disklabel *) bp;
+ if (l->d_magic != BSD_DISKMAGIC)
+ return -1;
+
+ max_partitions = 16;
+ if (l->d_npartitions < max_partitions)
+ max_partitions = l->d_npartitions;
+ for (p = l->d_partitions; p - l->d_partitions < max_partitions; p++) {
+ if (p->p_fstype == BSD_FS_UNUSED)
+ /* nothing */;
+ else if (n < ns) {
+ sp[n].start = p->p_offset;
+ sp[n].size = p->p_size;
+ n++;
+ } else {
+ fprintf(stderr,
+ "bsd_partition: too many slices\n");
+ break;
+ }
+ }
+ return n;
+}
Added: multipath-tools/upstream/current/kpartx/byteorder.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/byteorder.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+#ifndef BYTEORDER_H_INCLUDED
+#define BYTEORDER_H_INCLUDED
+
+#if defined (__s390__) || defined (__s390x__)
+#define le32_to_cpu(x) ( \
+ (*(((unsigned char *) &(x)))) + \
+ (*(((unsigned char *) &(x))+1) << 8) + \
+ (*(((unsigned char *) &(x))+2) << 16) + \
+ (*(((unsigned char *) &(x))+3) << 24) \
+ )
+#else
+#define le32_to_cpu(x) (x)
+#endif
+
+#endif /* BYTEORDER_H_INCLUDED */
Added: multipath-tools/upstream/current/kpartx/crc32.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/crc32.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,393 @@
+/*
+ * crc32.c
+ * This code is in the public domain; copyright abandoned.
+ * Liability for non-performance of this code is limited to the amount
+ * you paid for it. Since it is distributed for free, your refund will
+ * be very very small. If it breaks, you get to keep both pieces.
+ */
+
+#include "crc32.h"
+
+#if __GNUC__ >= 3 /* 2.x has "attribute", but only 3.0 has "pure */
+#define attribute(x) __attribute__(x)
+#else
+#define attribute(x)
+#endif
+
+/*
+ * There are multiple 16-bit CRC polynomials in common use, but this is
+ * *the* standard CRC-32 polynomial, first popularized by Ethernet.
+ * x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x^1+x^0
+ */
+#define CRCPOLY_LE 0xedb88320
+#define CRCPOLY_BE 0x04c11db7
+
+/* How many bits at a time to use. Requires a table of 4<<CRC_xx_BITS bytes. */
+/* For less performance-sensitive, use 4 */
+#define CRC_LE_BITS 8
+#define CRC_BE_BITS 8
+
+/*
+ * Little-endian CRC computation. Used with serial bit streams sent
+ * lsbit-first. Be sure to use cpu_to_le32() to append the computed CRC.
+ */
+#if CRC_LE_BITS > 8 || CRC_LE_BITS < 1 || CRC_LE_BITS & CRC_LE_BITS-1
+# error CRC_LE_BITS must be a power of 2 between 1 and 8
+#endif
+
+#if CRC_LE_BITS == 1
+/*
+ * In fact, the table-based code will work in this case, but it can be
+ * simplified by inlining the table in ?: form.
+ */
+#define crc32init_le()
+#define crc32cleanup_le()
+/**
+ * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
+ * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
+ * other uses, or the previous crc32 value if computing incrementally.
+ * @p - pointer to buffer over which CRC is run
+ * @len - length of buffer @p
+ *
+ */
+uint32_t attribute((pure)) crc32_le(uint32_t crc, unsigned char const *p, size_t len)
+{
+ int i;
+ while (len--) {
+ crc ^= *p++;
+ for (i = 0; i < 8; i++)
+ crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
+ }
+ return crc;
+}
+#else /* Table-based approach */
+
+static uint32_t *crc32table_le;
+/**
+ * crc32init_le() - allocate and initialize LE table data
+ *
+ * crc is the crc of the byte i; other entries are filled in based on the
+ * fact that crctable[i^j] = crctable[i] ^ crctable[j].
+ *
+ */
+static int
+crc32init_le(void)
+{
+ unsigned i, j;
+ uint32_t crc = 1;
+
+ crc32table_le =
+ malloc((1 << CRC_LE_BITS) * sizeof(uint32_t));
+ if (!crc32table_le)
+ return 1;
+ crc32table_le[0] = 0;
+
+ for (i = 1 << (CRC_LE_BITS - 1); i; i >>= 1) {
+ crc = (crc >> 1) ^ ((crc & 1) ? CRCPOLY_LE : 0);
+ for (j = 0; j < 1 << CRC_LE_BITS; j += 2 * i)
+ crc32table_le[i + j] = crc ^ crc32table_le[j];
+ }
+ return 0;
+}
+
+/**
+ * crc32cleanup_le(): free LE table data
+ */
+static void
+crc32cleanup_le(void)
+{
+ if (crc32table_le) free(crc32table_le);
+ crc32table_le = NULL;
+}
+
+/**
+ * crc32_le() - Calculate bitwise little-endian Ethernet AUTODIN II CRC32
+ * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
+ * other uses, or the previous crc32 value if computing incrementally.
+ * @p - pointer to buffer over which CRC is run
+ * @len - length of buffer @p
+ *
+ */
+uint32_t attribute((pure)) crc32_le(uint32_t crc, unsigned char const *p, size_t len)
+{
+ while (len--) {
+# if CRC_LE_BITS == 8
+ crc = (crc >> 8) ^ crc32table_le[(crc ^ *p++) & 255];
+# elif CRC_LE_BITS == 4
+ crc ^= *p++;
+ crc = (crc >> 4) ^ crc32table_le[crc & 15];
+ crc = (crc >> 4) ^ crc32table_le[crc & 15];
+# elif CRC_LE_BITS == 2
+ crc ^= *p++;
+ crc = (crc >> 2) ^ crc32table_le[crc & 3];
+ crc = (crc >> 2) ^ crc32table_le[crc & 3];
+ crc = (crc >> 2) ^ crc32table_le[crc & 3];
+ crc = (crc >> 2) ^ crc32table_le[crc & 3];
+# endif
+ }
+ return crc;
+}
+#endif
+
+/*
+ * Big-endian CRC computation. Used with serial bit streams sent
+ * msbit-first. Be sure to use cpu_to_be32() to append the computed CRC.
+ */
+#if CRC_BE_BITS > 8 || CRC_BE_BITS < 1 || CRC_BE_BITS & CRC_BE_BITS-1
+# error CRC_BE_BITS must be a power of 2 between 1 and 8
+#endif
+
+#if CRC_BE_BITS == 1
+/*
+ * In fact, the table-based code will work in this case, but it can be
+ * simplified by inlining the table in ?: form.
+ */
+#define crc32init_be()
+#define crc32cleanup_be()
+
+/**
+ * crc32_be() - Calculate bitwise big-endian Ethernet AUTODIN II CRC32
+ * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
+ * other uses, or the previous crc32 value if computing incrementally.
+ * @p - pointer to buffer over which CRC is run
+ * @len - length of buffer @p
+ *
+ */
+uint32_t attribute((pure)) crc32_be(uint32_t crc, unsigned char const *p, size_t len)
+{
+ int i;
+ while (len--) {
+ crc ^= *p++ << 24;
+ for (i = 0; i < 8; i++)
+ crc =
+ (crc << 1) ^ ((crc & 0x80000000) ? CRCPOLY_BE :
+ 0);
+ }
+ return crc;
+}
+
+#else /* Table-based approach */
+static uint32_t *crc32table_be;
+
+/**
+ * crc32init_be() - allocate and initialize BE table data
+ */
+static int
+crc32init_be(void)
+{
+ unsigned i, j;
+ uint32_t crc = 0x80000000;
+
+ crc32table_be =
+ malloc((1 << CRC_BE_BITS) * sizeof(uint32_t));
+ if (!crc32table_be)
+ return 1;
+ crc32table_be[0] = 0;
+
+ for (i = 1; i < 1 << CRC_BE_BITS; i <<= 1) {
+ crc = (crc << 1) ^ ((crc & 0x80000000) ? CRCPOLY_BE : 0);
+ for (j = 0; j < i; j++)
+ crc32table_be[i + j] = crc ^ crc32table_be[j];
+ }
+ return 0;
+}
+
+/**
+ * crc32cleanup_be(): free BE table data
+ */
+static void
+crc32cleanup_be(void)
+{
+ if (crc32table_be) free(crc32table_be);
+ crc32table_be = NULL;
+}
+
+
+/**
+ * crc32_be() - Calculate bitwise big-endian Ethernet AUTODIN II CRC32
+ * @crc - seed value for computation. ~0 for Ethernet, sometimes 0 for
+ * other uses, or the previous crc32 value if computing incrementally.
+ * @p - pointer to buffer over which CRC is run
+ * @len - length of buffer @p
+ *
+ */
+uint32_t attribute((pure)) crc32_be(uint32_t crc, unsigned char const *p, size_t len)
+{
+ while (len--) {
+# if CRC_BE_BITS == 8
+ crc = (crc << 8) ^ crc32table_be[(crc >> 24) ^ *p++];
+# elif CRC_BE_BITS == 4
+ crc ^= *p++ << 24;
+ crc = (crc << 4) ^ crc32table_be[crc >> 28];
+ crc = (crc << 4) ^ crc32table_be[crc >> 28];
+# elif CRC_BE_BITS == 2
+ crc ^= *p++ << 24;
+ crc = (crc << 2) ^ crc32table_be[crc >> 30];
+ crc = (crc << 2) ^ crc32table_be[crc >> 30];
+ crc = (crc << 2) ^ crc32table_be[crc >> 30];
+ crc = (crc << 2) ^ crc32table_be[crc >> 30];
+# endif
+ }
+ return crc;
+}
+#endif
+
+/*
+ * A brief CRC tutorial.
+ *
+ * A CRC is a long-division remainder. You add the CRC to the message,
+ * and the whole thing (message+CRC) is a multiple of the given
+ * CRC polynomial. To check the CRC, you can either check that the
+ * CRC matches the recomputed value, *or* you can check that the
+ * remainder computed on the message+CRC is 0. This latter approach
+ * is used by a lot of hardware implementations, and is why so many
+ * protocols put the end-of-frame flag after the CRC.
+ *
+ * It's actually the same long division you learned in school, except that
+ * - We're working in binary, so the digits are only 0 and 1, and
+ * - When dividing polynomials, there are no carries. Rather than add and
+ * subtract, we just xor. Thus, we tend to get a bit sloppy about
+ * the difference between adding and subtracting.
+ *
+ * A 32-bit CRC polynomial is actually 33 bits long. But since it's
+ * 33 bits long, bit 32 is always going to be set, so usually the CRC
+ * is written in hex with the most significant bit omitted. (If you're
+ * familiar with the IEEE 754 floating-point format, it's the same idea.)
+ *
+ * Note that a CRC is computed over a string of *bits*, so you have
+ * to decide on the endianness of the bits within each byte. To get
+ * the best error-detecting properties, this should correspond to the
+ * order they're actually sent. For example, standard RS-232 serial is
+ * little-endian; the most significant bit (sometimes used for parity)
+ * is sent last. And when appending a CRC word to a message, you should
+ * do it in the right order, matching the endianness.
+ *
+ * Just like with ordinary division, the remainder is always smaller than
+ * the divisor (the CRC polynomial) you're dividing by. Each step of the
+ * division, you take one more digit (bit) of the dividend and append it
+ * to the current remainder. Then you figure out the appropriate multiple
+ * of the divisor to subtract to being the remainder back into range.
+ * In binary, it's easy - it has to be either 0 or 1, and to make the
+ * XOR cancel, it's just a copy of bit 32 of the remainder.
+ *
+ * When computing a CRC, we don't care about the quotient, so we can
+ * throw the quotient bit away, but subtract the appropriate multiple of
+ * the polynomial from the remainder and we're back to where we started,
+ * ready to process the next bit.
+ *
+ * A big-endian CRC written this way would be coded like:
+ * for (i = 0; i < input_bits; i++) {
+ * multiple = remainder & 0x80000000 ? CRCPOLY : 0;
+ * remainder = (remainder << 1 | next_input_bit()) ^ multiple;
+ * }
+ * Notice how, to get at bit 32 of the shifted remainder, we look
+ * at bit 31 of the remainder *before* shifting it.
+ *
+ * But also notice how the next_input_bit() bits we're shifting into
+ * the remainder don't actually affect any decision-making until
+ * 32 bits later. Thus, the first 32 cycles of this are pretty boring.
+ * Also, to add the CRC to a message, we need a 32-bit-long hole for it at
+ * the end, so we have to add 32 extra cycles shifting in zeros at the
+ * end of every message,
+ *
+ * So the standard trick is to rearrage merging in the next_input_bit()
+ * until the moment it's needed. Then the first 32 cycles can be precomputed,
+ * and merging in the final 32 zero bits to make room for the CRC can be
+ * skipped entirely.
+ * This changes the code to:
+ * for (i = 0; i < input_bits; i++) {
+ * remainder ^= next_input_bit() << 31;
+ * multiple = (remainder & 0x80000000) ? CRCPOLY : 0;
+ * remainder = (remainder << 1) ^ multiple;
+ * }
+ * With this optimization, the little-endian code is simpler:
+ * for (i = 0; i < input_bits; i++) {
+ * remainder ^= next_input_bit();
+ * multiple = (remainder & 1) ? CRCPOLY : 0;
+ * remainder = (remainder >> 1) ^ multiple;
+ * }
+ *
+ * Note that the other details of endianness have been hidden in CRCPOLY
+ * (which must be bit-reversed) and next_input_bit().
+ *
+ * However, as long as next_input_bit is returning the bits in a sensible
+ * order, we can actually do the merging 8 or more bits at a time rather
+ * than one bit at a time:
+ * for (i = 0; i < input_bytes; i++) {
+ * remainder ^= next_input_byte() << 24;
+ * for (j = 0; j < 8; j++) {
+ * multiple = (remainder & 0x80000000) ? CRCPOLY : 0;
+ * remainder = (remainder << 1) ^ multiple;
+ * }
+ * }
+ * Or in little-endian:
+ * for (i = 0; i < input_bytes; i++) {
+ * remainder ^= next_input_byte();
+ * for (j = 0; j < 8; j++) {
+ * multiple = (remainder & 1) ? CRCPOLY : 0;
+ * remainder = (remainder << 1) ^ multiple;
+ * }
+ * }
+ * If the input is a multiple of 32 bits, you can even XOR in a 32-bit
+ * word at a time and increase the inner loop count to 32.
+ *
+ * You can also mix and match the two loop styles, for example doing the
+ * bulk of a message byte-at-a-time and adding bit-at-a-time processing
+ * for any fractional bytes at the end.
+ *
+ * The only remaining optimization is to the byte-at-a-time table method.
+ * Here, rather than just shifting one bit of the remainder to decide
+ * in the correct multiple to subtract, we can shift a byte at a time.
+ * This produces a 40-bit (rather than a 33-bit) intermediate remainder,
+ * but again the multiple of the polynomial to subtract depends only on
+ * the high bits, the high 8 bits in this case.
+ *
+ * The multile we need in that case is the low 32 bits of a 40-bit
+ * value whose high 8 bits are given, and which is a multiple of the
+ * generator polynomial. This is simply the CRC-32 of the given
+ * one-byte message.
+ *
+ * Two more details: normally, appending zero bits to a message which
+ * is already a multiple of a polynomial produces a larger multiple of that
+ * polynomial. To enable a CRC to detect this condition, it's common to
+ * invert the CRC before appending it. This makes the remainder of the
+ * message+crc come out not as zero, but some fixed non-zero value.
+ *
+ * The same problem applies to zero bits prepended to the message, and
+ * a similar solution is used. Instead of starting with a remainder of
+ * 0, an initial remainder of all ones is used. As long as you start
+ * the same way on decoding, it doesn't make a difference.
+ */
+
+
+/**
+ * init_crc32(): generates CRC32 tables
+ *
+ * On successful initialization, use count is increased.
+ * This guarantees that the library functions will stay resident
+ * in memory, and prevents someone from 'rmmod crc32' while
+ * a driver that needs it is still loaded.
+ * This also greatly simplifies drivers, as there's no need
+ * to call an initialization/cleanup function from each driver.
+ * Since crc32.o is a library module, there's no requirement
+ * that the user can unload it.
+ */
+int
+init_crc32(void)
+{
+ int rc1, rc2, rc;
+ rc1 = crc32init_le();
+ rc2 = crc32init_be();
+ rc = rc1 || rc2;
+ return rc;
+}
+
+/**
+ * cleanup_crc32(): frees crc32 data when no longer needed
+ */
+void
+cleanup_crc32(void)
+{
+ crc32cleanup_le();
+ crc32cleanup_be();
+}
Added: multipath-tools/upstream/current/kpartx/crc32.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/crc32.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,19 @@
+/*
+ * crc32.h
+ */
+#ifndef _CRC32_H
+#define _CRC32_H
+
+#include <inttypes.h>
+#include <stdlib.h>
+
+extern int init_crc32(void);
+extern void cleanup_crc32(void);
+extern uint32_t crc32_le(uint32_t crc, unsigned char const *p, size_t len);
+extern uint32_t crc32_be(uint32_t crc, unsigned char const *p, size_t len);
+
+#define crc32(seed, data, length) crc32_le(seed, (unsigned char const *)data, length)
+#define ether_crc_le(length, data) crc32_le(~0, data, length)
+#define ether_crc(length, data) crc32_be(~0, data, length)
+
+#endif /* _CRC32_H */
Added: multipath-tools/upstream/current/kpartx/dos.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/dos.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,112 @@
+#include "kpartx.h"
+#include "byteorder.h"
+#include <stdio.h>
+#include "dos.h"
+
+static int
+is_extended(int type) {
+ return (type == 5 || type == 0xf || type == 0x85);
+}
+
+static int
+read_extended_partition(int fd, struct partition *ep,
+ struct slice *sp, int ns)
+{
+ struct partition *p;
+ unsigned long start, here;
+ unsigned char *bp;
+ int loopct = 0;
+ int moretodo = 1;
+ int i, n=0;
+
+ here = start = le32_to_cpu(ep->start_sect);
+
+ while (moretodo) {
+ moretodo = 0;
+ if (++loopct > 100)
+ return n;
+
+ bp = getblock(fd, here);
+ if (bp == NULL)
+ return n;
+
+ if (bp[510] != 0x55 || bp[511] != 0xaa)
+ return n;
+
+ p = (struct partition *) (bp + 0x1be);
+
+ for (i=0; i<2; i++, p++) {
+ if (p->nr_sects == 0 || is_extended(p->sys_type))
+ continue;
+ if (n < ns) {
+ sp[n].start = here + le32_to_cpu(p->start_sect);
+ sp[n].size = le32_to_cpu(p->nr_sects);
+ n++;
+ } else {
+ fprintf(stderr,
+ "dos_extd_partition: too many slices\n");
+ return n;
+ }
+ loopct = 0;
+ }
+
+ p -= 2;
+ for (i=0; i<2; i++, p++) {
+ if(p->nr_sects != 0 && is_extended(p->sys_type)) {
+ here = start + le32_to_cpu(p->start_sect);
+ moretodo = 1;
+ break;
+ }
+ }
+ }
+ return n;
+}
+
+static int
+is_gpt(int type) {
+ return (type == 0xEE);
+}
+
+int
+read_dos_pt(int fd, struct slice all, struct slice *sp, int ns) {
+ struct partition *p;
+ unsigned long offset = all.start;
+ int i, n=0;
+ unsigned char *bp;
+
+ bp = getblock(fd, offset);
+ if (bp == NULL)
+ return -1;
+
+ if (bp[510] != 0x55 || bp[511] != 0xaa)
+ return -1;
+
+ p = (struct partition *) (bp + 0x1be);
+ for (i=0; i<4; i++) {
+ if (is_gpt(p->sys_type)) {
+ return 0;
+ }
+ p++;
+ }
+ p = (struct partition *) (bp + 0x1be);
+ for (i=0; i<4; i++) {
+ /* always add, even if zero length */
+ if (n < ns) {
+ sp[n].start = le32_to_cpu(p->start_sect);
+ sp[n].size = le32_to_cpu(p->nr_sects);
+ n++;
+ } else {
+ fprintf(stderr,
+ "dos_partition: too many slices\n");
+ break;
+ }
+ p++;
+ }
+ p = (struct partition *) (bp + 0x1be);
+ for (i=0; i<4; i++) {
+ if (is_extended(p->sys_type))
+ n += read_extended_partition(fd, p, sp+n, ns-n);
+ p++;
+ }
+ return n;
+}
Added: multipath-tools/upstream/current/kpartx/dos.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/dos.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,13 @@
+#ifndef DOS_H_INCLUDED
+#define DOS_H_INCLUDED
+
+struct partition {
+ unsigned char boot_ind; /* 0x80 - active */
+ unsigned char bh, bs, bc;
+ unsigned char sys_type;
+ unsigned char eh, es, ec;
+ unsigned int start_sect;
+ unsigned int nr_sects;
+} __attribute__((packed));
+
+#endif /* DOS_H_INCLUDED */
Added: multipath-tools/upstream/current/kpartx/efi.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/efi.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,58 @@
+/*
+ efi.[ch] - Manipulates EFI variables as exported in /proc/efi/vars
+
+ Copyright (C) 2001 Dell Computer Corporation <Matt_Domsch at dell.com>
+
+ 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef EFI_H
+#define EFI_H
+
+/*
+ * Extensible Firmware Interface
+ * Based on 'Extensible Firmware Interface Specification'
+ * version 1.02, 12 December, 2000
+ */
+#include <stdint.h>
+#include <string.h>
+
+typedef struct {
+ uint8_t b[16];
+} efi_guid_t;
+
+#define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \
+((efi_guid_t) \
+{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
+ (b) & 0xff, ((b) >> 8) & 0xff, \
+ (c) & 0xff, ((c) >> 8) & 0xff, \
+ (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
+
+
+/******************************************************
+ * GUIDs
+ ******************************************************/
+#define NULL_GUID \
+EFI_GUID( 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
+
+static inline int
+efi_guidcmp(efi_guid_t left, efi_guid_t right)
+{
+ return memcmp(&left, &right, sizeof (efi_guid_t));
+}
+
+typedef uint16_t efi_char16_t; /* UNICODE character */
+
+#endif /* EFI_H */
Added: multipath-tools/upstream/current/kpartx/gpt.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/gpt.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,625 @@
+/*
+ gpt.[ch]
+
+ Copyright (C) 2000-2001 Dell Computer Corporation <Matt_Domsch at dell.com>
+
+ EFI GUID Partition Table handling
+ Per Intel EFI Specification v1.02
+ http://developer.intel.com/technology/efi/efi.htm
+
+ 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#define _FILE_OFFSET_BITS 64
+
+#include "gpt.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <asm/byteorder.h>
+#include "crc32.h"
+
+#define BLKGETLASTSECT _IO(0x12,108) /* get last sector of block device */
+#define BLKGETSIZE _IO(0x12,96) /* return device size */
+#define BLKSSZGET _IO(0x12,104) /* get block device sector size */
+#define BLKGETSIZE64 _IOR(0x12,114,sizeof(uint64_t)) /* return device size in bytes (u64 *arg) */
+
+struct blkdev_ioctl_param {
+ unsigned int block;
+ size_t content_length;
+ char * block_contents;
+};
+
+/**
+ * efi_crc32() - EFI version of crc32 function
+ * @buf: buffer to calculate crc32 of
+ * @len - length of buf
+ *
+ * Description: Returns EFI-style CRC32 value for @buf
+ *
+ * This function uses the little endian Ethernet polynomial
+ * but seeds the function with ~0, and xor's with ~0 at the end.
+ * Note, the EFI Specification, v1.02, has a reference to
+ * Dr. Dobbs Journal, May 1994 (actually it's in May 1992).
+ */
+static inline uint32_t
+efi_crc32(const void *buf, unsigned long len)
+{
+ return (crc32(~0L, buf, len) ^ ~0L);
+}
+
+/**
+ * is_pmbr_valid(): test Protective MBR for validity
+ * @mbr: pointer to a legacy mbr structure
+ *
+ * Description: Returns 1 if PMBR is valid, 0 otherwise.
+ * Validity depends on two things:
+ * 1) MSDOS signature is in the last two bytes of the MBR
+ * 2) One partition of type 0xEE is found
+ */
+static int
+is_pmbr_valid(legacy_mbr *mbr)
+{
+ int i, found = 0, signature = 0;
+ if (!mbr)
+ return 0;
+ signature = (__le16_to_cpu(mbr->signature) == MSDOS_MBR_SIGNATURE);
+ for (i = 0; signature && i < 4; i++) {
+ if (mbr->partition[i].sys_type ==
+ EFI_PMBR_OSTYPE_EFI_GPT) {
+ found = 1;
+ break;
+ }
+ }
+ return (signature && found);
+}
+
+
+/************************************************************
+ * get_sector_size
+ * Requires:
+ * - filedes is an open file descriptor, suitable for reading
+ * Modifies: nothing
+ * Returns:
+ * sector size, or 512.
+ ************************************************************/
+static int
+get_sector_size(int filedes)
+{
+ int rc, sector_size = 512;
+
+ rc = ioctl(filedes, BLKSSZGET, §or_size);
+ if (rc)
+ sector_size = 512;
+ return sector_size;
+}
+
+/************************************************************
+ * _get_num_sectors
+ * Requires:
+ * - filedes is an open file descriptor, suitable for reading
+ * Modifies: nothing
+ * Returns:
+ * Last LBA value on success
+ * 0 on error
+ *
+ * Try getting BLKGETSIZE64 and BLKSSZGET first,
+ * then BLKGETSIZE if necessary.
+ * Kernels 2.4.15-2.4.18 and 2.5.0-2.5.3 have a broken BLKGETSIZE64
+ * which returns the number of 512-byte sectors, not the size of
+ * the disk in bytes. Fixed in kernels 2.4.18-pre8 and 2.5.4-pre3.
+ ************************************************************/
+static uint64_t
+_get_num_sectors(int filedes)
+{
+ unsigned long sectors=0;
+ int rc;
+#if 0
+ uint64_t bytes=0;
+
+ rc = ioctl(filedes, BLKGETSIZE64, &bytes);
+ if (!rc)
+ return bytes / get_sector_size(filedes);
+#endif
+ rc = ioctl(filedes, BLKGETSIZE, §ors);
+ if (rc)
+ return 0;
+
+ return sectors;
+}
+
+/************************************************************
+ * last_lba(): return number of last logical block of device
+ *
+ * @fd
+ *
+ * Description: returns Last LBA value on success, 0 on error.
+ * Notes: The value st_blocks gives the size of the file
+ * in 512-byte blocks, which is OK if
+ * EFI_BLOCK_SIZE_SHIFT == 9.
+ ************************************************************/
+
+static uint64_t
+last_lba(int filedes)
+{
+ int rc;
+ uint64_t sectors = 0;
+ struct stat s;
+ memset(&s, 0, sizeof (s));
+ rc = fstat(filedes, &s);
+ if (rc == -1) {
+ fprintf(stderr, "last_lba() could not stat: %s\n",
+ strerror(errno));
+ return 0;
+ }
+
+ if (S_ISBLK(s.st_mode)) {
+ sectors = _get_num_sectors(filedes);
+ } else {
+ fprintf(stderr,
+ "last_lba(): I don't know how to handle files with mode %x\n",
+ s.st_mode);
+ sectors = 1;
+ }
+
+ return sectors - 1;
+}
+
+
+static ssize_t
+read_lastoddsector(int fd, uint64_t lba, void *buffer, size_t count)
+{
+ int rc;
+ struct blkdev_ioctl_param ioctl_param;
+
+ if (!buffer) return 0;
+
+ ioctl_param.block = 0; /* read the last sector */
+ ioctl_param.content_length = count;
+ ioctl_param.block_contents = buffer;
+
+ rc = ioctl(fd, BLKGETLASTSECT, &ioctl_param);
+ if (rc == -1) perror("read failed");
+
+ return !rc;
+}
+
+static ssize_t
+read_lba(int fd, uint64_t lba, void *buffer, size_t bytes)
+{
+ int sector_size = get_sector_size(fd);
+ off_t offset = lba * sector_size;
+ ssize_t bytesread;
+
+ lseek(fd, offset, SEEK_SET);
+ bytesread = read(fd, buffer, bytes);
+
+ /* Kludge. This is necessary to read/write the last
+ block of an odd-sized disk, until Linux 2.5.x kernel fixes.
+ This is only used by gpt.c, and only to read
+ one sector, so we don't have to be fancy.
+ */
+ if (!bytesread && !(last_lba(fd) & 1) && lba == last_lba(fd)) {
+ bytesread = read_lastoddsector(fd, lba, buffer, bytes);
+ }
+ return bytesread;
+}
+
+/**
+ * alloc_read_gpt_entries(): reads partition entries from disk
+ * @fd is an open file descriptor to the whole disk
+ * @gpt is a buffer into which the GPT will be put
+ * Description: Returns ptes on success, NULL on error.
+ * Allocates space for PTEs based on information found in @gpt.
+ * Notes: remember to free pte when you're done!
+ */
+static gpt_entry *
+alloc_read_gpt_entries(int fd, gpt_header * gpt)
+{
+ gpt_entry *pte;
+ size_t count = __le32_to_cpu(gpt->num_partition_entries) *
+ __le32_to_cpu(gpt->sizeof_partition_entry);
+
+ if (!count) return NULL;
+
+ pte = (gpt_entry *)malloc(count);
+ if (!pte)
+ return NULL;
+ memset(pte, 0, count);
+
+ if (!read_lba(fd, __le64_to_cpu(gpt->partition_entry_lba), pte,
+ count)) {
+ free(pte);
+ return NULL;
+ }
+ return pte;
+}
+
+/**
+ * alloc_read_gpt_header(): Allocates GPT header, reads into it from disk
+ * @fd is an open file descriptor to the whole disk
+ * @lba is the Logical Block Address of the partition table
+ *
+ * Description: returns GPT header on success, NULL on error. Allocates
+ * and fills a GPT header starting at @ from @bdev.
+ * Note: remember to free gpt when finished with it.
+ */
+static gpt_header *
+alloc_read_gpt_header(int fd, uint64_t lba)
+{
+ gpt_header *gpt;
+ gpt = (gpt_header *)
+ malloc(sizeof (gpt_header));
+ if (!gpt)
+ return NULL;
+ memset(gpt, 0, sizeof (*gpt));
+ if (!read_lba(fd, lba, gpt, sizeof (gpt_header))) {
+ free(gpt);
+ return NULL;
+ }
+
+ return gpt;
+}
+
+/**
+ * is_gpt_valid() - tests one GPT header and PTEs for validity
+ * @fd is an open file descriptor to the whole disk
+ * @lba is the logical block address of the GPT header to test
+ * @gpt is a GPT header ptr, filled on return.
+ * @ptes is a PTEs ptr, filled on return.
+ *
+ * Description: returns 1 if valid, 0 on error.
+ * If valid, returns pointers to newly allocated GPT header and PTEs.
+ */
+static int
+is_gpt_valid(int fd, uint64_t lba,
+ gpt_header ** gpt, gpt_entry ** ptes)
+{
+ int rc = 0; /* default to not valid */
+ uint32_t crc, origcrc;
+
+ if (!gpt || !ptes)
+ return 0;
+ if (!(*gpt = alloc_read_gpt_header(fd, lba)))
+ return 0;
+
+ /* Check the GUID Partition Table signature */
+ if (__le64_to_cpu((*gpt)->signature) != GPT_HEADER_SIGNATURE) {
+ /*
+ printf("GUID Partition Table Header signature is wrong: %" PRIx64" != %" PRIx64 "\n",
+ __le64_to_cpu((*gpt)->signature), GUID_PT_HEADER_SIGNATURE);
+ */
+ free(*gpt);
+ *gpt = NULL;
+ return rc;
+ }
+
+ /* Check the GUID Partition Table Header CRC */
+ origcrc = __le32_to_cpu((*gpt)->header_crc32);
+ (*gpt)->header_crc32 = 0;
+ crc = efi_crc32(*gpt, __le32_to_cpu((*gpt)->header_size));
+ if (crc != origcrc) {
+ // printf( "GPTH CRC check failed, %x != %x.\n", origcrc, crc);
+ (*gpt)->header_crc32 = __cpu_to_le32(origcrc);
+ free(*gpt);
+ *gpt = NULL;
+ return 0;
+ }
+ (*gpt)->header_crc32 = __cpu_to_le32(origcrc);
+
+ /* Check that the my_lba entry points to the LBA
+ * that contains the GPT we read */
+ if (__le64_to_cpu((*gpt)->my_lba) != lba) {
+ /*
+ printf( "my_lba % PRIx64 "x != lba %"PRIx64 "x.\n",
+ __le64_to_cpu((*gpt)->my_lba), lba);
+ */
+ free(*gpt);
+ *gpt = NULL;
+ return 0;
+ }
+
+ if (!(*ptes = alloc_read_gpt_entries(fd, *gpt))) {
+ free(*gpt);
+ *gpt = NULL;
+ return 0;
+ }
+
+ /* Check the GUID Partition Entry Array CRC */
+ crc = efi_crc32(*ptes,
+ __le32_to_cpu((*gpt)->num_partition_entries) *
+ __le32_to_cpu((*gpt)->sizeof_partition_entry));
+ if (crc != __le32_to_cpu((*gpt)->partition_entry_array_crc32)) {
+ // printf("GUID Partitition Entry Array CRC check failed.\n");
+ free(*gpt);
+ *gpt = NULL;
+ free(*ptes);
+ *ptes = NULL;
+ return 0;
+ }
+
+ /* We're done, all's well */
+ return 1;
+}
+/**
+ * compare_gpts() - Search disk for valid GPT headers and PTEs
+ * @pgpt is the primary GPT header
+ * @agpt is the alternate GPT header
+ * @lastlba is the last LBA number
+ * Description: Returns nothing. Sanity checks pgpt and agpt fields
+ * and prints warnings on discrepancies.
+ *
+ */
+static void
+compare_gpts(gpt_header *pgpt, gpt_header *agpt, uint64_t lastlba)
+{
+ int error_found = 0;
+ if (!pgpt || !agpt)
+ return;
+ if (__le64_to_cpu(pgpt->my_lba) != __le64_to_cpu(agpt->alternate_lba)) {
+ error_found++;
+ fprintf(stderr,
+ "GPT:Primary header LBA != Alt. header alternate_lba\n");
+#ifdef DEBUG
+ fprintf(stderr, "GPT:%" PRIx64 " != %" PRIx64 "\n",
+ __le64_to_cpu(pgpt->my_lba),
+ __le64_to_cpu(agpt->alternate_lba));
+#endif
+ }
+ if (__le64_to_cpu(pgpt->alternate_lba) != __le64_to_cpu(agpt->my_lba)) {
+ error_found++;
+ fprintf(stderr,
+ "GPT:Primary header alternate_lba != Alt. header my_lba\n");
+#ifdef DEBUG
+ fprintf(stderr, "GPT:%" PRIx64 " != %" PRIx64 "\n",
+ __le64_to_cpu(pgpt->alternate_lba),
+ __le64_to_cpu(agpt->my_lba));
+#endif
+ }
+ if (__le64_to_cpu(pgpt->first_usable_lba) !=
+ __le64_to_cpu(agpt->first_usable_lba)) {
+ error_found++;
+ fprintf(stderr, "GPT:first_usable_lbas don't match.\n");
+#ifdef DEBUG
+ fprintf(stderr, "GPT:%" PRIx64 " != %" PRIx64 "\n",
+ __le64_to_cpu(pgpt->first_usable_lba),
+ __le64_to_cpu(agpt->first_usable_lba));
+#endif
+ }
+ if (__le64_to_cpu(pgpt->last_usable_lba) !=
+ __le64_to_cpu(agpt->last_usable_lba)) {
+ error_found++;
+ fprintf(stderr, "GPT:last_usable_lbas don't match.\n");
+#ifdef DEBUG
+ fprintf(stderr, "GPT:%" PRIx64 " != %" PRIx64 "\n",
+ __le64_to_cpu(pgpt->last_usable_lba),
+ __le64_to_cpu(agpt->last_usable_lba));
+#endif
+ }
+ if (efi_guidcmp(pgpt->disk_guid, agpt->disk_guid)) {
+ error_found++;
+ fprintf(stderr, "GPT:disk_guids don't match.\n");
+ }
+ if (__le32_to_cpu(pgpt->num_partition_entries) !=
+ __le32_to_cpu(agpt->num_partition_entries)) {
+ error_found++;
+ fprintf(stderr, "GPT:num_partition_entries don't match: "
+ "0x%x != 0x%x\n",
+ __le32_to_cpu(pgpt->num_partition_entries),
+ __le32_to_cpu(agpt->num_partition_entries));
+ }
+ if (__le32_to_cpu(pgpt->sizeof_partition_entry) !=
+ __le32_to_cpu(agpt->sizeof_partition_entry)) {
+ error_found++;
+ fprintf(stderr,
+ "GPT:sizeof_partition_entry values don't match: "
+ "0x%x != 0x%x\n",
+ __le32_to_cpu(pgpt->sizeof_partition_entry),
+ __le32_to_cpu(agpt->sizeof_partition_entry));
+ }
+ if (__le32_to_cpu(pgpt->partition_entry_array_crc32) !=
+ __le32_to_cpu(agpt->partition_entry_array_crc32)) {
+ error_found++;
+ fprintf(stderr,
+ "GPT:partition_entry_array_crc32 values don't match: "
+ "0x%x != 0x%x\n",
+ __le32_to_cpu(pgpt->partition_entry_array_crc32),
+ __le32_to_cpu(agpt->partition_entry_array_crc32));
+ }
+ if (__le64_to_cpu(pgpt->alternate_lba) != lastlba) {
+ error_found++;
+ fprintf(stderr,
+ "GPT:Primary header thinks Alt. header is not at the end of the disk.\n");
+#ifdef DEBUG
+ fprintf(stderr, "GPT:%" PRIx64 " != %" PRIx64 "\n",
+ __le64_to_cpu(pgpt->alternate_lba), lastlba);
+#endif
+ }
+
+ if (__le64_to_cpu(agpt->my_lba) != lastlba) {
+ error_found++;
+ fprintf(stderr,
+ "GPT:Alternate GPT header not at the end of the disk.\n");
+#ifdef DEBUG
+ fprintf(stderr, "GPT:%" PRIx64 " != %" PRIx64 "\n",
+ __le64_to_cpu(agpt->my_lba), lastlba);
+#endif
+ }
+
+ if (error_found)
+ fprintf(stderr,
+ "GPT: Use GNU Parted to correct GPT errors.\n");
+ return;
+}
+
+/**
+ * find_valid_gpt() - Search disk for valid GPT headers and PTEs
+ * @fd is an open file descriptor to the whole disk
+ * @gpt is a GPT header ptr, filled on return.
+ * @ptes is a PTEs ptr, filled on return.
+ * Description: Returns 1 if valid, 0 on error.
+ * If valid, returns pointers to newly allocated GPT header and PTEs.
+ * Validity depends on finding either the Primary GPT header and PTEs valid,
+ * or the Alternate GPT header and PTEs valid, and the PMBR valid.
+ */
+static int
+find_valid_gpt(int fd, gpt_header ** gpt, gpt_entry ** ptes)
+{
+ extern int force_gpt;
+ int good_pgpt = 0, good_agpt = 0, good_pmbr = 0;
+ gpt_header *pgpt = NULL, *agpt = NULL;
+ gpt_entry *pptes = NULL, *aptes = NULL;
+ legacy_mbr *legacymbr = NULL;
+ uint64_t lastlba;
+ if (!gpt || !ptes)
+ return 0;
+
+ lastlba = last_lba(fd);
+ good_pgpt = is_gpt_valid(fd, GPT_PRIMARY_PARTITION_TABLE_LBA,
+ &pgpt, &pptes);
+ if (good_pgpt) {
+ good_agpt = is_gpt_valid(fd,
+ __le64_to_cpu(pgpt->alternate_lba),
+ &agpt, &aptes);
+ if (!good_agpt) {
+ good_agpt = is_gpt_valid(fd, lastlba,
+ &agpt, &aptes);
+ }
+ }
+ else {
+ good_agpt = is_gpt_valid(fd, lastlba,
+ &agpt, &aptes);
+ }
+
+ /* The obviously unsuccessful case */
+ if (!good_pgpt && !good_agpt) {
+ goto fail;
+ }
+
+ /* This will be added to the EFI Spec. per Intel after v1.02. */
+ legacymbr = malloc(sizeof (*legacymbr));
+ if (legacymbr) {
+ memset(legacymbr, 0, sizeof (*legacymbr));
+ read_lba(fd, 0, (uint8_t *) legacymbr,
+ sizeof (*legacymbr));
+ good_pmbr = is_pmbr_valid(legacymbr);
+ free(legacymbr);
+ legacymbr=NULL;
+ }
+
+ /* Failure due to bad PMBR */
+ if ((good_pgpt || good_agpt) && !good_pmbr && !force_gpt) {
+ fprintf(stderr,
+ " Warning: Disk has a valid GPT signature "
+ "but invalid PMBR.\n"
+ " Assuming this disk is *not* a GPT disk anymore.\n"
+ " Use gpt kernel option to override. "
+ "Use GNU Parted to correct disk.\n");
+ goto fail;
+ }
+
+ /* Would fail due to bad PMBR, but force GPT anyhow */
+ if ((good_pgpt || good_agpt) && !good_pmbr && force_gpt) {
+ fprintf(stderr,
+ " Warning: Disk has a valid GPT signature but "
+ "invalid PMBR.\n"
+ " Use GNU Parted to correct disk.\n"
+ " gpt option taken, disk treated as GPT.\n");
+ }
+
+ compare_gpts(pgpt, agpt, lastlba);
+
+ /* The good cases */
+ if (good_pgpt && (good_pmbr || force_gpt)) {
+ *gpt = pgpt;
+ *ptes = pptes;
+ if (agpt) { free(agpt); agpt = NULL; }
+ if (aptes) { free(aptes); aptes = NULL; }
+ if (!good_agpt) {
+ fprintf(stderr,
+ "Alternate GPT is invalid, "
+ "using primary GPT.\n");
+ }
+ return 1;
+ }
+ else if (good_agpt && (good_pmbr || force_gpt)) {
+ *gpt = agpt;
+ *ptes = aptes;
+ if (pgpt) { free(pgpt); pgpt = NULL; }
+ if (pptes) { free(pptes); pptes = NULL; }
+ fprintf(stderr,
+ "Primary GPT is invalid, using alternate GPT.\n");
+ return 1;
+ }
+
+ fail:
+ if (pgpt) { free(pgpt); pgpt=NULL; }
+ if (agpt) { free(agpt); agpt=NULL; }
+ if (pptes) { free(pptes); pptes=NULL; }
+ if (aptes) { free(aptes); aptes=NULL; }
+ *gpt = NULL;
+ *ptes = NULL;
+ return 0;
+}
+
+/**
+ * read_gpt_pt()
+ * @fd
+ * @all - slice with start/size of whole disk
+ *
+ * 0 if this isn't our partition table
+ * number of partitions if successful
+ *
+ */
+int
+read_gpt_pt (int fd, struct slice all, struct slice *sp, int ns)
+{
+ gpt_header *gpt = NULL;
+ gpt_entry *ptes = NULL;
+ uint32_t i;
+ int n = 0;
+ int last_used_index=-1;
+
+ if (!find_valid_gpt (fd, &gpt, &ptes) || !gpt || !ptes) {
+ if (gpt)
+ free (gpt);
+ if (ptes)
+ free (ptes);
+ return 0;
+ }
+
+ for (i = 0; i < __le32_to_cpu(gpt->num_partition_entries) && i < ns; i++) {
+ if (!efi_guidcmp (NULL_GUID, ptes[i].partition_type_guid)) {
+ sp[n].start = 0;
+ sp[n].size = 0;
+ n++;
+ } else {
+ sp[n].start = __le64_to_cpu(ptes[i].starting_lba);
+ sp[n].size = __le64_to_cpu(ptes[i].ending_lba) -
+ __le64_to_cpu(ptes[i].starting_lba) + 1;
+ last_used_index=n;
+ n++;
+ }
+ }
+ free (ptes);
+ free (gpt);
+ return last_used_index+1;
+}
Added: multipath-tools/upstream/current/kpartx/gpt.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/gpt.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,131 @@
+/*
+ gpt.[ch]
+
+ Copyright (C) 2000-2001 Dell Computer Corporation <Matt_Domsch at dell.com>
+
+ EFI GUID Partition Table handling
+ Per Intel EFI Specification v1.02
+ http://developer.intel.com/technology/efi/efi.htm
+
+ 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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+#ifndef _GPT_H
+#define _GPT_H
+
+
+#include <inttypes.h>
+#include "kpartx.h"
+#include "dos.h"
+#include "efi.h"
+
+#define EFI_PMBR_OSTYPE_EFI 0xEF
+#define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
+#define MSDOS_MBR_SIGNATURE 0xaa55
+#define GPT_BLOCK_SIZE 512
+
+#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
+#define GPT_HEADER_REVISION_V1_02 0x00010200
+#define GPT_HEADER_REVISION_V1_00 0x00010000
+#define GPT_HEADER_REVISION_V0_99 0x00009900
+#define GPT_PRIMARY_PARTITION_TABLE_LBA 1
+
+typedef struct _gpt_header {
+ uint64_t signature;
+ uint32_t revision;
+ uint32_t header_size;
+ uint32_t header_crc32;
+ uint32_t reserved1;
+ uint64_t my_lba;
+ uint64_t alternate_lba;
+ uint64_t first_usable_lba;
+ uint64_t last_usable_lba;
+ efi_guid_t disk_guid;
+ uint64_t partition_entry_lba;
+ uint32_t num_partition_entries;
+ uint32_t sizeof_partition_entry;
+ uint32_t partition_entry_array_crc32;
+ uint8_t reserved2[GPT_BLOCK_SIZE - 92];
+} __attribute__ ((packed)) gpt_header;
+
+typedef struct _gpt_entry_attributes {
+ uint64_t required_to_function:1;
+ uint64_t reserved:47;
+ uint64_t type_guid_specific:16;
+} __attribute__ ((packed)) gpt_entry_attributes;
+
+typedef struct _gpt_entry {
+ efi_guid_t partition_type_guid;
+ efi_guid_t unique_partition_guid;
+ uint64_t starting_lba;
+ uint64_t ending_lba;
+ gpt_entry_attributes attributes;
+ efi_char16_t partition_name[72 / sizeof(efi_char16_t)];
+} __attribute__ ((packed)) gpt_entry;
+
+
+/*
+ These values are only defaults. The actual on-disk structures
+ may define different sizes, so use those unless creating a new GPT disk!
+*/
+
+#define GPT_DEFAULT_RESERVED_PARTITION_ENTRY_ARRAY_SIZE 16384
+/*
+ Number of actual partition entries should be calculated
+ as:
+*/
+#define GPT_DEFAULT_RESERVED_PARTITION_ENTRIES \
+ (GPT_DEFAULT_RESERVED_PARTITION_ENTRY_ARRAY_SIZE / \
+ sizeof(gpt_entry))
+
+
+/* Protected Master Boot Record & Legacy MBR share same structure */
+/* Needs to be packed because the u16s force misalignment. */
+
+typedef struct _legacy_mbr {
+ uint8_t bootcode[440];
+ uint32_t unique_mbr_signature;
+ uint16_t unknown;
+ struct partition partition[4];
+ uint16_t signature;
+} __attribute__ ((packed)) legacy_mbr;
+
+
+#define EFI_GPT_PRIMARY_PARTITION_TABLE_LBA 1
+
+/* Functions */
+int read_gpt_pt (int fd, struct slice all, struct slice *sp, int ns);
+
+
+#endif
+
+/*
+ * Overrides for Emacs so that we follow Linus's tabbing style.
+ * Emacs will notice this stuff at the end of the file and automatically
+ * adjust the settings for this buffer only. This must remain at the end
+ * of the file.
+ * ---------------------------------------------------------------------------
+ * Local variables:
+ * c-indent-level: 4
+ * c-brace-imaginary-offset: 0
+ * c-brace-offset: -4
+ * c-argdecl-indent: 4
+ * c-label-offset: -4
+ * c-continued-statement-offset: 4
+ * c-continued-brace-offset: 0
+ * indent-tabs-mode: nil
+ * tab-width: 8
+ * End:
+ */
Added: multipath-tools/upstream/current/kpartx/kpartx.8
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/kpartx.8 Fri Mar 4 08:05:19 2005
@@ -0,0 +1,39 @@
+.TH KPARTX 8 "February 2004" "" "Linux Administrator's Manual"
+.SH NAME
+kpartx \- Create device maps from partition tables
+.SH SYNOPSIS
+.B kpartx
+.RB [\| \-a\ \c
+.BR |\ -d\ |\ -l \|]
+.RB [\| \-v \|]
+.RB wholedisk
+.SH DESCRIPTION
+This tool, derived from util-linux' partx, reads partition
+tables on specified device and create device maps over partitions
+segments detected. It is called from hotplug upon device maps
+creation and deletion.
+.SH OPTIONS
+.TP
+.B \-a
+Add partition mappings
+.TP
+.B \-d
+Delete partition mappings
+.TP
+.B \-l
+List partition mappings that would be added -a
+.TP
+.B \-p
+set device name-partition number delimiter
+.TP
+.B \-v
+Operate verbosely
+.SH "SEE ALSO"
+.BR multipath (8)
+.BR multipathd (8)
+.BR hotplug (8)
+.SH "AUTHORS"
+This man page was assembled By Patrick Caulfield
+for the Debian project. From documentation provided
+by the multipath author Christophe Varoqui, <christophe.varoqui at free.fr> and others.
+
Added: multipath-tools/upstream/current/kpartx/kpartx.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/kpartx.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,449 @@
+/*
+ * Given a block device and a partition table type,
+ * try to parse the partition table, and list the
+ * contents. Optionally add or remove partitions.
+ *
+ * Read wholedisk and add all partitions:
+ * kpartx [-a|-d|-l] [-v] wholedisk
+ *
+ * aeb, 2000-03-21
+ * cva, 2002-10-26
+ */
+
+#include "kpartx.h"
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <ctype.h>
+#include <libdevmapper.h>
+#include <devmapper.h>
+
+#include "crc32.h"
+
+/* loop devices */
+#include "lopart.h"
+
+#define SIZE(a) (sizeof(a)/sizeof((a)[0]))
+
+#define MAXTYPES 64
+#define MAXSLICES 256
+#define DM_TARGET "linear"
+#define LO_NAME_SIZE 64
+#define PARTNAME_SIZE 128
+#define DELIM_SIZE 8
+
+struct slice slices[MAXSLICES];
+
+enum action { LIST, ADD, DELETE };
+
+struct pt {
+ char *type;
+ ptreader *fn;
+} pts[MAXTYPES];
+
+int ptct = 0;
+
+static void
+addpts(char *t, ptreader f)
+{
+ if (ptct >= MAXTYPES) {
+ fprintf(stderr, "addpts: too many types\n");
+ exit(1);
+ }
+ pts[ptct].type = t;
+ pts[ptct].fn = f;
+ ptct++;
+}
+
+static void
+initpts(void)
+{
+ addpts("gpt", read_gpt_pt);
+ addpts("dos", read_dos_pt);
+ addpts("bsd", read_bsd_pt);
+ addpts("solaris", read_solaris_pt);
+ addpts("unixware", read_unixware_pt);
+}
+
+static char short_opts[] = "ladgvnp:t:";
+
+/* Used in gpt.c */
+int force_gpt=0;
+
+static int
+usage(void) {
+ printf("usage : kpartx [-a|-d|-l] [-v] wholedisk\n");
+ printf("\t-a add partition devmappings\n");
+ printf("\t-d del partition devmappings\n");
+ printf("\t-l list partitions devmappings that would be added by -a\n");
+ printf("\t-p set device name-partition number delimiter\n");
+ printf("\t-v verbose\n");
+ return 1;
+}
+
+static void
+set_delimiter (char * device, char * delimiter)
+{
+ char * p = device;
+
+ while (*(p++) != 0x0)
+ continue;
+
+ if (isdigit(*(p - 2)))
+ *delimiter = 'p';
+}
+
+static void
+strip_slash (char * device)
+{
+ char * p = device;
+
+ while (*(p++) != 0x0) {
+
+ if (*p == '/')
+ *p = '!';
+ }
+}
+
+static int
+find_devname_offset (char * device)
+{
+ char *p, *q = NULL;
+
+ p = device;
+
+ while (*p++)
+ if (*p == '/')
+ q = p;
+
+ return (int)(q - device) + 1;
+}
+
+int
+main(int argc, char **argv){
+ int fd, i, j, k, n, op, off, arg;
+ struct slice all;
+ struct pt *ptp;
+ enum action what = LIST;
+ char *p, *type, *diskdevice, *device;
+ int lower, upper;
+ int verbose = 0;
+ char partname[PARTNAME_SIZE], params[PARTNAME_SIZE + 16];
+ char * loopdev = NULL;
+ char * delim = NULL;
+ int loopro = 0;
+ struct stat buf;
+
+ initpts();
+ init_crc32();
+
+ lower = upper = 0;
+ type = device = diskdevice = NULL;
+ memset(&all, 0, sizeof(all));
+ memset(&partname, 0, sizeof(partname));
+
+ if (argc < 2) {
+ usage();
+ exit(1);
+ }
+
+ while ((arg = getopt(argc, argv, short_opts)) != EOF) switch(arg) {
+ case 'g':
+ force_gpt=1;
+ break;
+ case 't':
+ type = optarg;
+ break;
+ case 'v':
+ verbose = 1;
+ break;
+ case 'n':
+ p = optarg;
+ lower = atoi(p);
+ if ((p[1] == '-') && p[2])
+ upper = atoi(p+2);
+ else
+ upper = lower;
+ break;
+ case 'p':
+ delim = optarg;
+ break;
+ case 'l':
+ what = LIST;
+ break;
+ case 'a':
+ what = ADD;
+ break;
+ case 'd':
+ what = DELETE;
+ break;
+ default:
+ usage();
+ exit(1);
+ }
+
+ if (dm_prereq(DM_TARGET, 0, 0, 0) && (what == ADD || what == DELETE)) {
+ fprintf(stderr, "device mapper prerequisites not met\n");
+ exit(1);
+ }
+
+ if (optind == argc-2) {
+ device = argv[optind];
+ diskdevice = argv[optind+1];
+ } else if (optind == argc-1) {
+ diskdevice = device = argv[optind];
+ } else {
+ usage();
+ exit(1);
+ }
+
+ if (stat (device, &buf)) {
+ printf("failed to stat() device\n");
+ exit (1);
+ }
+
+ if (S_ISREG (buf.st_mode)) {
+ loopdev = malloc(LO_NAME_SIZE * sizeof(char));
+
+ if (!loopdev)
+ exit(1);
+
+ /* already looped file ? */
+ loopdev = find_loop_by_file(device);
+
+ if (!loopdev && what == DELETE)
+ exit (0);
+
+ if (!loopdev) {
+ loopdev = find_unused_loop_device();
+
+ if (set_loop(loopdev, device, 0, &loopro)) {
+ fprintf(stderr, "can't set up loop\n");
+ exit (1);
+ }
+ }
+ device = loopdev;
+ }
+
+ if (delim == NULL) {
+ delim = malloc(DELIM_SIZE);
+ memset(delim, 0, DELIM_SIZE);
+ set_delimiter(device, delim);
+ }
+
+ off = find_devname_offset(device);
+ fd = open(device, O_RDONLY);
+
+ if (fd == -1) {
+ perror(device);
+ exit(1);
+ }
+ if (!lower)
+ lower = 1;
+
+ /* add/remove partitions to the kernel devmapper tables */
+ for (i = 0; i < ptct; i++) {
+ ptp = &pts[i];
+
+ if (type && strcmp(type, ptp->type) > 0)
+ continue;
+
+ /* here we get partitions */
+ n = ptp->fn(fd, all, slices, SIZE(slices));
+
+#ifdef DEBUG
+ if (n >= 0)
+ printf("%s: %d slices\n", ptp->type, n);
+#endif
+
+ if (n > 0)
+ close(fd);
+ else
+ continue;
+
+ /*
+ * test for overlap, as in the case of an extended partition
+ * zero their size to avoid mapping
+ */
+ for (j=0; j<n; j++) {
+ for (k=j+1; k<n; k++) {
+ if (slices[k].start > slices[j].start &&
+ slices[k].start < slices[j].start +
+ slices[j].size)
+ slices[j].size = 0;
+ }
+ }
+
+ switch(what) {
+ case LIST:
+ for (j = 0; j < n; j++) {
+ if (slices[j].size == 0)
+ continue;
+
+ printf("%s%s%d : 0 %lu %s %lu\n",
+ device + off, delim, j+1,
+ (unsigned long) slices[j].size, device,
+ (unsigned long) slices[j].start);
+ }
+ break;
+
+ case DELETE:
+ for (j = 0; j < n; j++) {
+ if (safe_sprintf(partname, "%s%s%d",
+ device + off , delim, j+1)) {
+ fprintf(stderr, "partname too small\n");
+ exit(1);
+ }
+ strip_slash(partname);
+
+ if (!slices[j].size || !dm_map_present(partname))
+ continue;
+
+ if (!dm_simplecmd(DM_DEVICE_REMOVE, partname))
+ continue;
+
+ if (verbose)
+ printf("del devmap : %s\n", partname);
+ }
+
+ if (S_ISREG (buf.st_mode)) {
+ if (del_loop(device)) {
+ if (verbose)
+ printf("can't del loop : %s\n",
+ device);
+ exit(1);
+ }
+ printf("loop deleted : %s\n", device);
+ }
+ break;
+
+ case ADD:
+ for (j=0; j<n; j++) {
+ if (slices[j].size == 0)
+ continue;
+
+ if (safe_sprintf(partname, "%s%s%d",
+ device + off , delim, j+1)) {
+ fprintf(stderr, "partname too small\n");
+ exit(1);
+ }
+ strip_slash(partname);
+
+ if (safe_sprintf(params, "%s %lu", device,
+ (unsigned long)slices[j].start)) {
+ fprintf(stderr, "params too small\n");
+ exit(1);
+ }
+
+ op = (dm_map_present(partname) ?
+ DM_DEVICE_RELOAD : DM_DEVICE_CREATE);
+
+ dm_addmap(op, partname, DM_TARGET, params,
+ slices[j].size);
+
+ if (op == DM_DEVICE_RELOAD)
+ dm_simplecmd(DM_DEVICE_RESUME,
+ partname);
+
+ if (verbose)
+ printf("add map %s : 0 %lu %s %s\n",
+ partname, slices[j].size,
+ DM_TARGET, params);
+ }
+ break;
+
+ default:
+ break;
+
+ }
+ if (n > 0)
+ break;
+ }
+ return 0;
+}
+
+void *
+xmalloc (size_t size) {
+ void *t;
+
+ if (size == 0)
+ return NULL;
+
+ t = malloc (size);
+
+ if (t == NULL) {
+ fprintf(stderr, "Out of memory\n");
+ exit(1);
+ }
+
+ return t;
+}
+
+/*
+ * sseek: seek to specified sector
+ */
+#if !defined (__alpha__) && !defined (__ia64__) && !defined (__x86_64__) \
+ && !defined (__s390x__)
+#include <linux/unistd.h> /* _syscall */
+static
+_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo,
+ long long *, res, uint, wh);
+#endif
+
+static int
+sseek(int fd, unsigned int secnr) {
+ long long in, out;
+ in = ((long long) secnr << 9);
+ out = 1;
+
+#if !defined (__alpha__) && !defined (__ia64__) && !defined (__x86_64__) \
+ && !defined (__s390x__)
+ if (_llseek (fd, in>>32, in & 0xffffffff, &out, SEEK_SET) != 0
+ || out != in)
+#else
+ if ((out = lseek(fd, in, SEEK_SET)) != in)
+#endif
+ {
+ fprintf(stderr, "llseek error\n");
+ return -1;
+ }
+ return 0;
+}
+
+static
+struct block {
+ unsigned int secnr;
+ char *block;
+ struct block *next;
+} *blockhead;
+
+char *
+getblock (int fd, unsigned int secnr) {
+ struct block *bp;
+
+ for (bp = blockhead; bp; bp = bp->next)
+
+ if (bp->secnr == secnr)
+ return bp->block;
+
+ if (sseek(fd, secnr))
+ return NULL;
+
+ bp = xmalloc(sizeof(struct block));
+ bp->secnr = secnr;
+ bp->next = blockhead;
+ blockhead = bp;
+ bp->block = (char *) xmalloc(1024);
+
+ if (read(fd, bp->block, 1024) != 1024) {
+ fprintf(stderr, "read error, sector %d\n", secnr);
+ bp->block = NULL;
+ }
+
+ return bp->block;
+}
Added: multipath-tools/upstream/current/kpartx/kpartx.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/kpartx.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,42 @@
+#ifndef _KPARTX_H
+#define _KPARTX_H
+
+/*
+ * For each partition type there is a routine that takes
+ * a block device and a range, and returns the list of
+ * slices found there in the supplied array SP that can
+ * hold NS entries. The return value is the number of
+ * entries stored, or -1 if the appropriate type is not
+ * present.
+ */
+
+#define likely(x) __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+
+#define safe_sprintf(var, format, args...) \
+ snprintf(var, sizeof(var), format, ##args) >= sizeof(var)
+
+/*
+ * units: 512 byte sectors
+ */
+struct slice {
+ unsigned long start;
+ unsigned long size;
+};
+
+typedef int (ptreader)(int fd, struct slice all, struct slice *sp, int ns);
+
+extern ptreader read_dos_pt;
+extern ptreader read_bsd_pt;
+extern ptreader read_solaris_pt;
+extern ptreader read_unixware_pt;
+extern ptreader read_gpt_pt;
+
+char *getblock(int fd, unsigned int secnr);
+
+static inline int
+four2int(unsigned char *p) {
+ return p[0] + (p[1]<<8) + (p[2]<<16) + (p[3]<<24);
+}
+
+#endif /* _KPARTX_H */
Added: multipath-tools/upstream/current/kpartx/loop.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/loop.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,157 @@
+#ifndef _LINUX_LOOP_H
+#define _LINUX_LOOP_H
+
+/*
+ * include/linux/loop.h
+ *
+ * Written by Theodore Ts'o, 3/29/93.
+ *
+ * Copyright 1993 by Theodore Ts'o. Redistribution of this file is
+ * permitted under the GNU General Public License.
+ */
+
+#define LO_NAME_SIZE 64
+#define LO_KEY_SIZE 32
+
+#ifdef __KERNEL__
+#include <linux/bio.h>
+#include <linux/blkdev.h>
+#include <linux/spinlock.h>
+
+/* Possible states of device */
+enum {
+ Lo_unbound,
+ Lo_bound,
+ Lo_rundown,
+};
+
+struct loop_func_table;
+
+struct loop_device {
+ int lo_number;
+ int lo_refcnt;
+ loff_t lo_offset;
+ loff_t lo_sizelimit;
+ int lo_flags;
+ int (*transfer)(struct loop_device *, int cmd,
+ struct page *raw_page, unsigned raw_off,
+ struct page *loop_page, unsigned loop_off,
+ int size, sector_t real_block);
+ char lo_file_name[LO_NAME_SIZE];
+ char lo_crypt_name[LO_NAME_SIZE];
+ char lo_encrypt_key[LO_KEY_SIZE];
+ int lo_encrypt_key_size;
+ struct loop_func_table *lo_encryption;
+ __u32 lo_init[2];
+ uid_t lo_key_owner; /* Who set the key */
+ int (*ioctl)(struct loop_device *, int cmd,
+ unsigned long arg);
+
+ struct file * lo_backing_file;
+ struct block_device *lo_device;
+ unsigned lo_blocksize;
+ void *key_data;
+
+ int old_gfp_mask;
+
+ spinlock_t lo_lock;
+ struct bio *lo_bio;
+ struct bio *lo_biotail;
+ int lo_state;
+ struct semaphore lo_sem;
+ struct semaphore lo_ctl_mutex;
+ struct semaphore lo_bh_mutex;
+ atomic_t lo_pending;
+
+ request_queue_t *lo_queue;
+};
+
+#endif /* __KERNEL__ */
+
+/*
+ * Loop flags
+ */
+#define LO_FLAGS_READ_ONLY 1
+
+#include <asm/posix_types.h> /* for __kernel_old_dev_t */
+#include <asm/types.h> /* for __u64 */
+
+/* Backwards compatibility version */
+struct loop_info {
+ int lo_number; /* ioctl r/o */
+ __kernel_old_dev_t lo_device; /* ioctl r/o */
+ unsigned long lo_inode; /* ioctl r/o */
+ __kernel_old_dev_t lo_rdevice; /* ioctl r/o */
+ int lo_offset;
+ int lo_encrypt_type;
+ int lo_encrypt_key_size; /* ioctl w/o */
+ int lo_flags; /* ioctl r/o */
+ char lo_name[LO_NAME_SIZE];
+ unsigned char lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+ unsigned long lo_init[2];
+ char reserved[4];
+};
+
+struct loop_info64 {
+ __u64 lo_device; /* ioctl r/o */
+ __u64 lo_inode; /* ioctl r/o */
+ __u64 lo_rdevice; /* ioctl r/o */
+ __u64 lo_offset;
+ __u64 lo_sizelimit;/* bytes, 0 == max available */
+ __u32 lo_number; /* ioctl r/o */
+ __u32 lo_encrypt_type;
+ __u32 lo_encrypt_key_size; /* ioctl w/o */
+ __u32 lo_flags; /* ioctl r/o */
+ __u8 lo_file_name[LO_NAME_SIZE];
+ __u8 lo_crypt_name[LO_NAME_SIZE];
+ __u8 lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
+ __u64 lo_init[2];
+};
+
+/*
+ * Loop filter types
+ */
+
+#define LO_CRYPT_NONE 0
+#define LO_CRYPT_XOR 1
+#define LO_CRYPT_DES 2
+#define LO_CRYPT_FISH2 3 /* Twofish encryption */
+#define LO_CRYPT_BLOW 4
+#define LO_CRYPT_CAST128 5
+#define LO_CRYPT_IDEA 6
+#define LO_CRYPT_DUMMY 9
+#define LO_CRYPT_SKIPJACK 10
+#define LO_CRYPT_CRYPTOAPI 18
+#define MAX_LO_CRYPT 20
+
+#ifdef __KERNEL__
+/* Support for loadable transfer modules */
+struct loop_func_table {
+ int number; /* filter type */
+ int (*transfer)(struct loop_device *lo, int cmd,
+ struct page *raw_page, unsigned raw_off,
+ struct page *loop_page, unsigned loop_off,
+ int size, sector_t real_block);
+ int (*init)(struct loop_device *, const struct loop_info64 *);
+ /* release is called from loop_unregister_transfer or clr_fd */
+ int (*release)(struct loop_device *);
+ int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
+ struct module *owner;
+};
+
+int loop_register_transfer(struct loop_func_table *funcs);
+int loop_unregister_transfer(int number);
+
+#endif
+/*
+ * IOCTL commands --- we will commandeer 0x4C ('L')
+ */
+
+#define LOOP_SET_FD 0x4C00
+#define LOOP_CLR_FD 0x4C01
+#define LOOP_SET_STATUS 0x4C02
+#define LOOP_GET_STATUS 0x4C03
+#define LOOP_SET_STATUS64 0x4C04
+#define LOOP_GET_STATUS64 0x4C05
+
+#endif
Added: multipath-tools/upstream/current/kpartx/lopart.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/lopart.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,294 @@
+/* Taken from Ted's losetup.c - Mitch <m.dsouza at mrc-apu.cam.ac.uk> */
+/* Added vfs mount options - aeb - 960223 */
+/* Removed lomount - aeb - 960224 */
+
+/* 1999-02-22 Arkadiusz Mi¶kiewicz <misiek at pld.ORG.PL>
+ * - added Native Language Support
+ * Sun Mar 21 1999 - Arnaldo Carvalho de Melo <acme at conectiva.com.br>
+ * - fixed strerr(errno) in gettext calls
+ */
+
+#define PROC_DEVICES "/proc/devices"
+
+/*
+ * losetup.c - setup and control loop devices
+ */
+
+#include "kpartx.h"
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <sysmacros.h>
+
+#include "loop.h"
+#include "lopart.h"
+#include "xstrncpy.h"
+
+#if !defined (__alpha__) && !defined (__ia64__) && !defined (__x86_64__) \
+ && !defined (__s390x__)
+#define int2ptr(x) ((void *) ((int) x))
+#else
+#define int2ptr(x) ((void *) ((long) x))
+#endif
+
+static char *
+xstrdup (const char *s)
+{
+ char *t;
+
+ if (s == NULL)
+ return NULL;
+
+ t = strdup (s);
+
+ if (t == NULL) {
+ fprintf(stderr, "not enough memory");
+ exit(1);
+ }
+
+ return t;
+}
+
+extern int
+is_loop_device (const char *device)
+{
+ struct stat statbuf;
+ int loopmajor;
+#if 1
+ loopmajor = 7;
+#else
+ FILE *procdev;
+ char line[100], *cp;
+
+ loopmajor = 0;
+
+ if ((procdev = fopen(PROC_DEVICES, "r")) != NULL) {
+
+ while (fgets (line, sizeof(line), procdev)) {
+
+ if ((cp = strstr (line, " loop\n")) != NULL) {
+ *cp='\0';
+ loopmajor=atoi(line);
+ break;
+ }
+ }
+
+ fclose(procdev);
+ }
+#endif
+ return (loopmajor && stat(device, &statbuf) == 0 &&
+ S_ISBLK(statbuf.st_mode) &&
+ major(statbuf.st_rdev) == loopmajor);
+}
+
+#define SIZE(a) (sizeof(a)/sizeof(a[0]))
+
+extern char *
+find_loop_by_file (const char * filename)
+{
+ char dev[20];
+ char *loop_formats[] = { "/dev/loop%d", "/dev/loop/%d" };
+ int i, j, fd;
+ struct stat statbuf;
+ struct loop_info loopinfo;
+
+ for (j = 0; j < SIZE(loop_formats); j++) {
+
+ for (i = 0; i < 256; i++) {
+ sprintf (dev, loop_formats[j], i);
+
+ if (stat (dev, &statbuf) != 0 ||
+ !S_ISBLK(statbuf.st_mode))
+ continue;
+
+ fd = open (dev, O_RDONLY);
+
+ if (fd < 0)
+ break;
+
+ if (ioctl (fd, LOOP_GET_STATUS, &loopinfo) != 0) {
+ close (fd);
+ continue;
+ }
+
+ if (0 == strcmp(filename, loopinfo.lo_name)) {
+ close (fd);
+ return xstrdup(dev); /*found */
+ }
+
+ close (fd);
+ continue;
+ }
+ }
+ return NULL;
+}
+
+extern char *
+find_unused_loop_device (void)
+{
+ /* 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]. */
+
+ 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;
+
+ for (j = 0; j < SIZE(loop_formats); j++) {
+
+ for(i = 0; i < 256; i++) {
+ sprintf(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 xstrdup(dev);/* probably free */
+ }
+
+ close (fd);
+ }
+
+ /* continue trying as long as devices exist */
+ continue;
+ }
+ 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)
+ fprintf(stderr, "mount: could not find any device /dev/loop#");
+
+ else if (!someloop) {
+
+ if (loop_known == 1)
+ fprintf(stderr,
+ "mount: Could not find any loop device.\n"
+ " Maybe /dev/loop# has a wrong major number?");
+
+ else if (loop_known == -1)
+ fprintf(stderr,
+ "mount: Could not find any loop device, and, according to %s,\n"
+ " this kernel does not know about the loop device.\n"
+ " (If so, then recompile or `insmod loop.o'.)",
+ PROC_DEVICES);
+
+ else
+ fprintf(stderr,
+ "mount: Could not find any loop device. Maybe this kernel does not know\n"
+ " about the loop device (then recompile or `insmod loop.o'), or\n"
+ " maybe /dev/loop# has the wrong major number?");
+
+ } else
+ fprintf(stderr, "mount: could not find any free loop device");
+
+ return 0;
+}
+
+extern int
+set_loop (const char *device, const char *file, int offset, int *loopro)
+{
+ struct loop_info loopinfo;
+ int fd, ffd, mode;
+
+ mode = (*loopro ? O_RDONLY : O_RDWR);
+
+ if ((ffd = open (file, mode)) < 0) {
+
+ if (!*loopro && errno == EROFS)
+ ffd = open (file, mode = O_RDONLY);
+
+ if (ffd < 0) {
+ perror (file);
+ return 1;
+ }
+ }
+
+ if ((fd = open (device, mode)) < 0) {
+ perror (device);
+ return 1;
+ }
+
+ *loopro = (mode == O_RDONLY);
+ memset (&loopinfo, 0, sizeof (loopinfo));
+
+ xstrncpy (loopinfo.lo_name, file, LO_NAME_SIZE);
+ loopinfo.lo_offset = offset;
+ loopinfo.lo_encrypt_type = LO_CRYPT_NONE;
+ loopinfo.lo_encrypt_key_size = 0;
+
+ if (ioctl (fd, LOOP_SET_FD, int2ptr(ffd)) < 0) {
+ perror ("ioctl: LOOP_SET_FD");
+ close (fd);
+ close (ffd);
+ return 1;
+ }
+
+ if (ioctl (fd, LOOP_SET_STATUS, &loopinfo) < 0) {
+ (void) ioctl (fd, LOOP_CLR_FD, 0);
+ perror ("ioctl: LOOP_SET_STATUS");
+ close (fd);
+ close (ffd);
+ return 1;
+ }
+
+ close (fd);
+ close (ffd);
+ return 0;
+}
+
+extern int
+del_loop (const char *device)
+{
+ int fd;
+
+ if ((fd = open (device, O_RDONLY)) < 0) {
+ int errsv = errno;
+ fprintf(stderr, "loop: can't delete device %s: %s\n",
+ device, strerror (errsv));
+ return 1;
+ }
+
+ if (ioctl (fd, LOOP_CLR_FD, 0) < 0) {
+ perror ("ioctl: LOOP_CLR_FD");
+ close (fd);
+ return 1;
+ }
+
+ close (fd);
+ return 0;
+}
Added: multipath-tools/upstream/current/kpartx/lopart.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/lopart.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,6 @@
+extern int verbose;
+extern int set_loop (const char *, const char *, int, int *);
+extern int del_loop (const char *);
+extern int is_loop_device (const char *);
+extern char * find_unused_loop_device (void);
+extern char * find_loop_by_file (const char *);
Added: multipath-tools/upstream/current/kpartx/solaris.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/solaris.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,71 @@
+#include "kpartx.h"
+#include <stdio.h>
+#include <sys/types.h>
+#include <time.h> /* time_t */
+
+#define SOLARIS_X86_NUMSLICE 8
+#define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL)
+
+//typedef int daddr_t; /* or long - check */
+
+struct solaris_x86_slice {
+ unsigned short s_tag; /* ID tag of partition */
+ unsigned short s_flag; /* permision flags */
+ daddr_t s_start; /* start sector no of partition */
+ long s_size; /* # of blocks in partition */
+};
+
+struct solaris_x86_vtoc {
+ unsigned long v_bootinfo[3]; /* info for mboot */
+ unsigned long v_sanity; /* to verify vtoc sanity */
+ unsigned long v_version; /* layout version */
+ char v_volume[8]; /* volume name */
+ unsigned short v_sectorsz; /* sector size in bytes */
+ unsigned short v_nparts; /* number of partitions */
+ unsigned long v_reserved[10]; /* free space */
+ struct solaris_x86_slice
+ v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */
+ time_t timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp */
+ char v_asciilabel[128]; /* for compatibility */
+};
+
+int
+read_solaris_pt(int fd, struct slice all, struct slice *sp, int ns) {
+ struct solaris_x86_vtoc *v;
+ struct solaris_x86_slice *s;
+ unsigned int offset = all.start;
+ int i, n;
+ char *bp;
+
+ bp = getblock(fd, offset+1); /* 1 sector suffices */
+ if (bp == NULL)
+ return -1;
+
+ v = (struct solaris_x86_vtoc *) bp;
+ if(v->v_sanity != SOLARIS_X86_VTOC_SANE)
+ return -1;
+
+ if(v->v_version != 1) {
+ fprintf(stderr, "Cannot handle solaris version %ld vtoc\n",
+ v->v_version);
+ return 0;
+ }
+
+ for(i=0, n=0; i<SOLARIS_X86_NUMSLICE; i++) {
+ s = &v->v_slice[i];
+
+ if (s->s_size == 0)
+ continue;
+ if (n < ns) {
+ sp[n].start = offset + s->s_start;
+ sp[n].size = s->s_size;
+ n++;
+ } else {
+ fprintf(stderr,
+ "solaris_x86_partition: too many slices\n");
+ break;
+ }
+ }
+ return n;
+}
+
Added: multipath-tools/upstream/current/kpartx/sysmacros.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/sysmacros.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,9 @@
+/* versions to be used with > 16-bit dev_t - leave unused for now */
+
+#ifndef major
+#define major(dev) ((dev) >> 8)
+#endif
+
+#ifndef minor
+#define minor(dev) ((dev) & 0xff)
+#endif
Added: multipath-tools/upstream/current/kpartx/unixware.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/unixware.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,83 @@
+#include "kpartx.h"
+#include <stdio.h>
+
+#define UNIXWARE_FS_UNUSED 0
+#define UNIXWARE_NUMSLICE 16
+#define UNIXWARE_DISKMAGIC (0xCA5E600D)
+#define UNIXWARE_DISKMAGIC2 (0x600DDEEE)
+
+struct unixware_slice {
+ unsigned short s_label; /* label */
+ unsigned short s_flags; /* permission flags */
+ unsigned int start_sect; /* starting sector */
+ unsigned int nr_sects; /* number of sectors in slice */
+};
+
+struct unixware_disklabel {
+ unsigned int d_type; /* drive type */
+ unsigned char d_magic[4]; /* the magic number */
+ unsigned int d_version; /* version number */
+ char d_serial[12]; /* serial number of the device */
+ unsigned int d_ncylinders; /* # of data cylinders per device */
+ unsigned int d_ntracks; /* # of tracks per cylinder */
+ unsigned int d_nsectors; /* # of data sectors per track */
+ unsigned int d_secsize; /* # of bytes per sector */
+ unsigned int d_part_start; /* # of first sector of this partition */
+ unsigned int d_unknown1[12]; /* ? */
+ unsigned int d_alt_tbl; /* byte offset of alternate table */
+ unsigned int d_alt_len; /* byte length of alternate table */
+ unsigned int d_phys_cyl; /* # of physical cylinders per device */
+ unsigned int d_phys_trk; /* # of physical tracks per cylinder */
+ unsigned int d_phys_sec; /* # of physical sectors per track */
+ unsigned int d_phys_bytes; /* # of physical bytes per sector */
+ unsigned int d_unknown2; /* ? */
+ unsigned int d_unknown3; /* ? */
+ unsigned int d_pad[8]; /* pad */
+
+ struct unixware_vtoc {
+ unsigned char v_magic[4]; /* the magic number */
+ unsigned int v_version; /* version number */
+ char v_name[8]; /* volume name */
+ unsigned short v_nslices; /* # of slices */
+ unsigned short v_unknown1; /* ? */
+ unsigned int v_reserved[10]; /* reserved */
+ struct unixware_slice
+ v_slice[UNIXWARE_NUMSLICE]; /* slice headers */
+ } vtoc;
+
+}; /* 408 */
+
+int
+read_unixware_pt(int fd, struct slice all, struct slice *sp, int ns) {
+ struct unixware_disklabel *l;
+ struct unixware_slice *p;
+ unsigned int offset = all.start;
+ char *bp;
+ int n = 0;
+
+ bp = getblock(fd, offset+29); /* 1 sector suffices */
+ if (bp == NULL)
+ return -1;
+
+ l = (struct unixware_disklabel *) bp;
+ if (four2int(l->d_magic) != UNIXWARE_DISKMAGIC ||
+ four2int(l->vtoc.v_magic) != UNIXWARE_DISKMAGIC2)
+ return -1;
+
+ p = &l->vtoc.v_slice[1]; /* slice 0 is the whole disk. */
+ while (p - &l->vtoc.v_slice[0] < UNIXWARE_NUMSLICE) {
+ if (p->s_label == UNIXWARE_FS_UNUSED)
+ /* nothing */;
+ else if (n < ns) {
+ sp[n].start = p->start_sect;
+ sp[n].size = p->nr_sects;
+ n++;
+ } else {
+ fprintf(stderr,
+ "unixware_partition: too many slices\n");
+ break;
+ }
+ p++;
+ }
+ return n;
+}
Added: multipath-tools/upstream/current/kpartx/xstrncpy.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/xstrncpy.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+/* NUL-terminated version of strncpy() */
+#include <string.h>
+#include "xstrncpy.h"
+
+/* caller guarantees n > 0 */
+void
+xstrncpy(char *dest, const char *src, size_t n) {
+ strncpy(dest, src, n-1);
+ dest[n-1] = 0;
+}
Added: multipath-tools/upstream/current/kpartx/xstrncpy.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/kpartx/xstrncpy.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1 @@
+extern void xstrncpy(char *dest, const char *src, size_t n);
Added: multipath-tools/upstream/current/libcheckers/Makefile
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libcheckers/Makefile Fri Mar 4 08:05:19 2005
@@ -0,0 +1,38 @@
+# Makefile
+#
+# Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui at free.fr>
+#
+BUILD = glibc
+
+include ../Makefile.inc
+
+OBJS = readsector0.o tur.o selector.o checkers.o emc_clariion.o
+
+ifeq ($(strip $(BUILD)),klibc)
+ CFLAGS = ${REQFLAGS} ${OPTFLAGS}
+else
+ CFLAGS =
+endif
+
+all: $(BUILD)
+
+prepare:
+ rm -f core *.o *.gz
+
+klibc: prepare $(KLIBC) $(OBJS)
+ ar rs libcheckers-klibc.a *.o
+
+glibc: prepare $(OBJS)
+ ar rs libcheckers-glibc.a *.o
+
+$(KLIBC):
+ rm -f $(klibcdir)/linux
+ ln -s $(KERNEL_BUILD) $(klibcdir)/linux
+ make -C $(klibcdir)
+
+install:
+
+uninstall:
+
+clean:
+ rm -f core *.a *.o *.gz
Added: multipath-tools/upstream/current/libcheckers/checkers.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libcheckers/checkers.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,44 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "checkers.h"
+
+extern int
+devnode (int action, char *devt)
+{
+ dev_t dev;
+ int major, minor;
+ int ret = 0;
+ char devnode[DEVNODE_SIZE];
+
+ if (snprintf(devnode, sizeof(devnode), "/tmp/.checkpath.%s",
+ devt) >= sizeof(devnode)) {
+ fprintf(stderr, "checkpath: devnode too small\n");
+ return -1;
+ }
+
+ switch (action)
+ {
+ case CREATE_NODE:
+ sscanf(devt, "%i:%i", &major, &minor);
+ dev = makedev(major, minor);
+ unlink(devnode);
+ ret = mknod(devnode, S_IFBLK | S_IRUSR | S_IWUSR, dev);
+ break;
+
+ case UNLINK_NODE:
+ unlink(devnode);
+ break;
+
+ case OPEN_NODE:
+ ret = open(devnode, O_RDONLY);
+ break;
+
+ default:
+ break;
+ }
+ return(ret);
+}
Added: multipath-tools/upstream/current/libcheckers/checkers.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libcheckers/checkers.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,34 @@
+#ifndef _CHECKERS_H
+#define _CHECKERS_H
+
+#define CHECKER_NAME_SIZE 16
+#define DEVNODE_SIZE 256
+#define MAX_CHECKER_MSG_SIZE 256
+
+enum devnode_actions {
+ CREATE_NODE,
+ UNLINK_NODE,
+ OPEN_NODE
+};
+
+enum checkers {
+ CHECKER_RESERVED,
+ TUR,
+ READSECTOR0,
+ EMC_CLARIION
+};
+
+#define MSG(a) if (msg != NULL) \
+ snprintf(msg, MAX_CHECKER_MSG_SIZE, "%s\n", a);
+
+int devnode (int, char *);
+
+int get_checker_id (char *);
+void *get_checker_addr (int);
+int get_checker_name (char *, int);
+
+int emc_clariion (char *, char *, void **);
+int readsector0 (char *, char *, void **);
+int tur (char *, char *, void **);
+
+#endif /* _CHECKERS_H */
Added: multipath-tools/upstream/current/libcheckers/emc_clariion.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libcheckers/emc_clariion.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,157 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#include "sg_include.h"
+#include "path_state.h"
+#include "checkers.h"
+
+#define INQUIRY_CMD 0x12
+#define INQUIRY_CMDLEN 6
+#define HEAVY_CHECK_COUNT 10
+
+struct emc_clariion_checker_context {
+ int fd;
+ int run_count;
+ char wwn[16];
+ unsigned wwn_set;
+};
+
+int emc_clariion(char *devt, char *msg, void **context)
+{
+ unsigned char sense_buffer[256];
+ unsigned char sb[128];
+ unsigned char inqCmdBlk[INQUIRY_CMDLEN] = {INQUIRY_CMD, 1, 0xC0, 0,
+ sizeof(sb), 0};
+ struct sg_io_hdr io_hdr;
+ struct emc_clariion_checker_context * ctxt = NULL;
+ int ret;
+
+ /*
+ * caller passed in a context : use its address
+ */
+ if (context)
+ ctxt = (struct emc_clariion_checker_context *) (*context);
+
+ /*
+ * passed in context is uninitialized or volatile context :
+ * initialize it
+ */
+ if (!ctxt) {
+ ctxt = malloc(sizeof(struct emc_clariion_checker_context));
+ memset(ctxt, 0, sizeof(struct emc_clariion_checker_context));
+
+ if (!ctxt) {
+ MSG("cannot allocate context");
+ return -1;
+ }
+ if (context)
+ *context = ctxt;
+ }
+ ctxt->run_count++;
+
+ if ((ctxt->run_count % HEAVY_CHECK_COUNT) == 0) {
+ ctxt->run_count = 0;
+ /* do stuff */
+ }
+
+ if (!ctxt->fd) {
+ if (devnode(CREATE_NODE, devt)) {
+ ret = -1;
+ goto out;
+ }
+ ctxt->fd = devnode(OPEN_NODE, devt);
+ devnode(UNLINK_NODE, devt);
+ }
+ memset(&io_hdr, 0, sizeof (struct sg_io_hdr));
+ io_hdr.interface_id = 'S';
+ io_hdr.cmd_len = sizeof (inqCmdBlk);
+ io_hdr.mx_sb_len = sizeof (sb);
+ io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
+ io_hdr.dxfer_len = sizeof (sense_buffer);
+ io_hdr.dxferp = sense_buffer;
+ io_hdr.cmdp = inqCmdBlk;
+ io_hdr.sbp = sb;
+ io_hdr.timeout = 60000;
+ io_hdr.pack_id = 0;
+ if (ioctl(ctxt->fd, SG_IO, &io_hdr) < 0) {
+ MSG("emc_clariion_checker: sending query command failed");
+ ret = PATH_DOWN;
+ goto out;
+ }
+ if (io_hdr.info & SG_INFO_OK_MASK) {
+ MSG("emc_clariion_checker: query command indicates error");
+ ret = PATH_DOWN;
+ goto out;
+ }
+ if (/* Verify the code page - right page & revision */
+ sense_buffer[1] != 0xc0 || sense_buffer[9] != 0x00) {
+ MSG("emc_clariion_checker: Path unit report page in unknown format");
+ ret = PATH_DOWN;
+ goto out;
+ }
+
+ if ( /* Effective initiator type */
+ sense_buffer[27] != 0x03
+ /* Failover mode should be set to 1 */
+ || (sense_buffer[28] & 0x07) != 0x04
+ /* Arraycommpath should be set to 1 */
+ || (sense_buffer[30] & 0x04) != 0x04) {
+ MSG("emc_clariion_checker: Path not correctly configured for failover");
+ ret = PATH_DOWN;
+ goto out;
+ }
+
+ if ( /* LUN operations should indicate normal operations */
+ sense_buffer[48] != 0x00) {
+ MSG("emc_clariion_checker: Path not available for normal operations");
+ ret = PATH_SHAKY;
+ goto out;
+ }
+
+#if 0
+ /* This is not actually an error as the failover to this group
+ * _would_ bind the path */
+ if ( /* LUN should at least be bound somewhere */
+ sense_buffer[4] != 0x00) {
+ ret = PATH_UP;
+ goto out;
+ }
+#endif
+
+ /*
+ * store the LUN WWN there and compare that it indeed did not
+ * change in between, to protect against the path suddenly
+ * pointing somewhere else.
+ */
+ if (context && ctxt->wwn_set) {
+ if (memcmp(ctxt->wwn, &sense_buffer[10], 16) != 0) {
+ MSG("emc_clariion_checker: Logical Unit WWN has changed!");
+ ret = PATH_DOWN;
+ goto out;
+ }
+ } else {
+ memcpy(ctxt->wwn, &sense_buffer[10], 16);
+ ctxt->wwn_set = 1;
+ }
+
+
+ MSG("emc_clariion_checker: Path healthy");
+ ret = PATH_UP;
+out:
+ /*
+ * caller told us he doesn't want to keep the context :
+ * free it
+ */
+ if (!context) {
+ close(ctxt->fd);
+ free(ctxt);
+ }
+ return(ret);
+}
Added: multipath-tools/upstream/current/libcheckers/path_state.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libcheckers/path_state.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,3 @@
+#define PATH_DOWN 0
+#define PATH_UP 1
+#define PATH_SHAKY 2
Added: multipath-tools/upstream/current/libcheckers/readsector0.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libcheckers/readsector0.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,144 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#include "sg_include.h"
+#include "path_state.h"
+#include "checkers.h"
+
+#define SENSE_BUFF_LEN 32
+#define DEF_TIMEOUT 60000
+
+#define MSG_READSECTOR0_UP "readsector0 checker reports path is up"
+#define MSG_READSECTOR0_DOWN "readsector0 checker reports path is down"
+
+struct readsector0_checker_context {
+ int fd;
+};
+
+static int
+sg_read (int sg_fd, unsigned char * buff)
+{
+ /* defaults */
+ int blocks = 1;
+ long long start_block = 0;
+ int bs = 512;
+ int cdbsz = 10;
+ int * diop = NULL;
+
+ unsigned char rdCmd[cdbsz];
+ unsigned char senseBuff[SENSE_BUFF_LEN];
+ struct sg_io_hdr io_hdr;
+ int res;
+ int rd_opcode[] = {0x8, 0x28, 0xa8, 0x88};
+ int sz_ind;
+
+ memset(rdCmd, 0, cdbsz);
+ sz_ind = 1;
+ rdCmd[0] = rd_opcode[sz_ind];
+ rdCmd[2] = (unsigned char)((start_block >> 24) & 0xff);
+ rdCmd[3] = (unsigned char)((start_block >> 16) & 0xff);
+ rdCmd[4] = (unsigned char)((start_block >> 8) & 0xff);
+ rdCmd[5] = (unsigned char)(start_block & 0xff);
+ rdCmd[7] = (unsigned char)((blocks >> 8) & 0xff);
+ rdCmd[8] = (unsigned char)(blocks & 0xff);
+
+ memset(&io_hdr, 0, sizeof(struct sg_io_hdr));
+ io_hdr.interface_id = 'S';
+ io_hdr.cmd_len = cdbsz;
+ io_hdr.cmdp = rdCmd;
+ io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
+ io_hdr.dxfer_len = bs * blocks;
+ io_hdr.dxferp = buff;
+ io_hdr.mx_sb_len = SENSE_BUFF_LEN;
+ io_hdr.sbp = senseBuff;
+ io_hdr.timeout = DEF_TIMEOUT;
+ io_hdr.pack_id = (int)start_block;
+ if (diop && *diop)
+ io_hdr.flags |= SG_FLAG_DIRECT_IO;
+
+ while (((res = ioctl(sg_fd, SG_IO, &io_hdr)) < 0) && (EINTR == errno));
+
+ if (res < 0) {
+ if (ENOMEM == errno) {
+ return PATH_UP;
+ }
+ return PATH_DOWN;
+ }
+
+ if ((0 == io_hdr.status) &&
+ (0 == io_hdr.host_status) &&
+ (0 == io_hdr.driver_status)) {
+ return PATH_UP;
+ } else {
+ return PATH_DOWN;
+ }
+}
+
+extern int
+readsector0 (char *devt, char *msg, void **context)
+{
+ char buf[512];
+ struct readsector0_checker_context * ctxt = NULL;
+ int ret;
+
+ /*
+ * caller passed in a context : use its address
+ */
+ if (context)
+ ctxt = (struct readsector0_checker_context *) (*context);
+
+ /*
+ * passed in context is uninitialized or volatile context :
+ * initialize it
+ */
+ if (!ctxt) {
+ ctxt = malloc(sizeof(struct readsector0_checker_context));
+ memset(ctxt, 0, sizeof(struct readsector0_checker_context));
+
+ if (!ctxt) {
+ MSG("cannot allocate context");
+ return -1;
+ }
+ if (context)
+ *context = ctxt;
+ }
+ if (!ctxt->fd) {
+ if (devnode(CREATE_NODE, devt)) {
+ MSG("cannot create node");
+ ret = -1;
+ goto out;
+ }
+ ctxt->fd = devnode(OPEN_NODE, devt);
+ devnode(UNLINK_NODE, devt);
+ }
+ ret = sg_read(ctxt->fd, &buf[0]);
+
+ switch (ret)
+ {
+ case PATH_DOWN:
+ MSG(MSG_READSECTOR0_DOWN);
+ break;
+ case PATH_UP:
+ MSG(MSG_READSECTOR0_UP);
+ break;
+ default:
+ break;
+ }
+out:
+ /*
+ * caller told us he doesn't want to keep the context :
+ * free it
+ */
+ if (!context) {
+ close(ctxt->fd);
+ free(ctxt);
+ }
+ return ret;
+}
Added: multipath-tools/upstream/current/libcheckers/selector.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libcheckers/selector.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,64 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "checkers.h"
+
+extern int
+get_checker_id (char * str)
+{
+ if (0 == strncmp(str, "tur", 3))
+ return TUR;
+ if (0 == strncmp(str, "readsector0", 11))
+ return READSECTOR0;
+ if (0 == strncmp(str, "emc_clariion", 12))
+ return EMC_CLARIION;
+ return -1;
+}
+
+extern void *
+get_checker_addr (int id)
+{
+ int (*checker) (char *, char *, void **);
+
+ switch (id) {
+ case TUR:
+ checker = &tur;
+ break;
+ case READSECTOR0:
+ checker = &readsector0;
+ break;
+ case EMC_CLARIION:
+ checker = &emc_clariion;
+ break;
+ default:
+ checker = NULL;
+ break;
+ }
+ return checker;
+}
+
+extern int
+get_checker_name (char * str, int id)
+{
+ char * s;
+
+ switch (id) {
+ case TUR:
+ s = "tur";
+ break;
+ case READSECTOR0:
+ s = "readsector0";
+ break;
+ case EMC_CLARIION:
+ s = "emc_clariion";
+ break;
+ default:
+ s = "undefined";
+ break;
+ }
+ if (snprintf(str, CHECKER_NAME_SIZE, "%s", s) >= CHECKER_NAME_SIZE) {
+ fprintf(stderr, "checker_name too small\n");
+ return 1;
+ }
+ return 0;
+}
Added: multipath-tools/upstream/current/libcheckers/sg_include.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libcheckers/sg_include.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,43 @@
+#ifdef SG_KERNEL_INCLUDES
+ #define __user
+ typedef unsigned char u8;
+ #include "/usr/src/linux/include/scsi/sg.h"
+ #include "/usr/src/linux/include/scsi/scsi.h"
+#else
+ #ifdef SG_TRICK_GNU_INCLUDES
+ #include <linux/../scsi/sg.h>
+ #include <linux/../scsi/scsi.h>
+ #else
+ #include <scsi/sg.h>
+ #endif
+#endif
+
+/*
+ Getting the correct include files for the sg interface can be an ordeal.
+ In a perfect world, one would just write:
+ #include <scsi/sg.h>
+ #include <scsi/scsi.h>
+ This would include the files found in the /usr/include/scsi directory.
+ Those files are maintained with the GNU library which may or may not
+ agree with the kernel and version of sg driver that is running. Any
+ many cases this will not matter. However in some it might, for example
+ glibc 2.1's include files match the sg driver found in the lk 2.2
+ series. Hence if glibc 2.1 is used with lk 2.4 then the additional
+ sg v3 interface will not be visible.
+ If this is a problem then defining SG_KERNEL_INCLUDES will access the
+ kernel supplied header files (assuming they are in the normal place).
+ The GNU library maintainers and various kernel people don't like
+ this approach (but it does work).
+ The technique selected by defining SG_TRICK_GNU_INCLUDES worked (and
+ was used) prior to glibc 2.2 . Prior to that version /usr/include/linux
+ was a symbolic link to /usr/src/linux/include/linux .
+
+ There are other approaches if this include "mixup" causes pain. These
+ would involve include files being copied or symbolic links being
+ introduced.
+
+ Sorry about the inconvenience. Typically neither SG_KERNEL_INCLUDES
+ nor SG_TRICK_GNU_INCLUDES is defined.
+
+ dpg 20010415, 20030522
+*/
Added: multipath-tools/upstream/current/libcheckers/tur.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libcheckers/tur.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,105 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+
+#include "sg_include.h"
+#include "path_state.h"
+#include "checkers.h"
+
+#define TUR_CMD_LEN 6
+#define HEAVY_CHECK_COUNT 10
+
+#define MSG_TUR_UP "tur checker reports path is up"
+#define MSG_TUR_DOWN "tur checker reports path is down"
+
+struct tur_checker_context {
+ int fd;
+ int run_count;
+};
+
+
+extern int
+tur (char *devt, char *msg, void **context)
+{
+ unsigned char turCmdBlk[TUR_CMD_LEN] = { 0x00, 0, 0, 0, 0, 0 };
+ struct sg_io_hdr io_hdr;
+ unsigned char sense_buffer[32];
+ struct tur_checker_context * ctxt = NULL;
+ int ret;
+
+ /*
+ * caller passed in a context : use its address
+ */
+ if (context)
+ ctxt = (struct tur_checker_context *) (*context);
+
+ /*
+ * passed in context is uninitialized or volatile context :
+ * initialize it
+ */
+ if (!ctxt) {
+ ctxt = malloc(sizeof(struct tur_checker_context));
+ memset(ctxt, 0, sizeof(struct tur_checker_context));
+
+ if (!ctxt) {
+ MSG("cannot allocate context");
+ return -1;
+ }
+ if (context)
+ *context = ctxt;
+ }
+ ctxt->run_count++;
+
+ if ((ctxt->run_count % HEAVY_CHECK_COUNT) == 0) {
+ ctxt->run_count = 0;
+ /* do stuff */
+ }
+ if (!ctxt->fd) {
+ if (devnode(CREATE_NODE, devt)) {
+ MSG("cannot create node");
+ ret = -1;
+ goto out;
+ }
+ ctxt->fd = devnode(OPEN_NODE, devt);
+ devnode(UNLINK_NODE, devt);
+ }
+
+ memset(&io_hdr, 0, sizeof (struct sg_io_hdr));
+ io_hdr.interface_id = 'S';
+ io_hdr.cmd_len = sizeof (turCmdBlk);
+ io_hdr.mx_sb_len = sizeof (sense_buffer);
+ io_hdr.dxfer_direction = SG_DXFER_NONE;
+ io_hdr.cmdp = turCmdBlk;
+ io_hdr.sbp = sense_buffer;
+ io_hdr.timeout = 20000;
+ io_hdr.pack_id = 0;
+ if (ioctl(ctxt->fd, SG_IO, &io_hdr) < 0) {
+ MSG(MSG_TUR_DOWN);
+ ret = PATH_DOWN;
+ goto out;
+ }
+ if (io_hdr.info & SG_INFO_OK_MASK) {
+ MSG(MSG_TUR_DOWN);
+ ret = PATH_DOWN;
+ goto out;
+ }
+ MSG(MSG_TUR_UP);
+ ret = PATH_UP;
+
+out:
+ /*
+ * caller told us he doesn't want to keep the context :
+ * free it
+ */
+ if (!context) {
+ close(ctxt->fd);
+ free(ctxt);
+ }
+ return(ret);
+}
Added: multipath-tools/upstream/current/libdevmapper/.exported_symbols
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libdevmapper/.exported_symbols Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+dm_log_init
+dm_log_init_verbose
+dm_task_create
+dm_task_destroy
+dm_task_set_name
+dm_task_set_uuid
+dm_get_library_version
+dm_task_get_driver_version
+dm_task_get_info
+dm_task_get_deps
+dm_task_get_name
+dm_task_get_names
+dm_task_get_versions
+dm_task_get_uuid
+dm_task_set_ro
+dm_task_set_newname
+dm_task_set_event_nr
+dm_task_set_major
+dm_task_set_minor
+dm_task_set_sector
+dm_task_set_message
+dm_task_add_target
+dm_get_next_target
+dm_task_run
+dm_set_dev_dir
+dm_dir
+dm_format_dev
+dm_lib_release
+dm_lib_exit
Added: multipath-tools/upstream/current/libdevmapper/Makefile
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libdevmapper/Makefile Fri Mar 4 08:05:19 2005
@@ -0,0 +1,28 @@
+# Makefile
+#
+# Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui at free.fr>
+
+BUILD = klibc
+
+include ../Makefile.inc
+
+CFLAGS += -I. -Iioctl -Iinclude ${REQFLAGS} ${OPTFLAGS}
+
+OBJS = ioctl/libdm-iface.o libdm-common.o
+
+all: $(BUILD)
+
+klibc: $(KLIBC) $(OBJS)
+ ar rs libdevmapper-klibc.a *.o ioctl/*.o
+
+$(KLIBC):
+ rm -f $(klibcdir)/linux
+ ln -s $(KERNEL_BUILD) $(klibcdir)/linux
+ make -C $(klibcdir)
+
+install:
+
+uninstall:
+
+clean:
+ rm -f core *.o ioctl/*.o ioctl/*.so *.a
Added: multipath-tools/upstream/current/libdevmapper/include/.symlinks
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libdevmapper/include/.symlinks Fri Mar 4 08:05:19 2005
@@ -0,0 +1,2 @@
+../lib/libdevmapper.h
+../po/pogen.h
Added: multipath-tools/upstream/current/libdevmapper/include/kdev_t.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libdevmapper/include/kdev_t.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of the device-mapper userspace tools.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _LVM_KDEV_H
+#define _LVM_KDEV_H
+
+#define MAJOR(dev) ((dev & 0xfff00) >> 8)
+#define MINOR(dev) ((dev & 0xff) | ((dev >> 12) & 0xfff00))
+#define MKDEV(ma,mi) ((mi & 0xff) | (ma << 8) | ((mi & ~0xff) << 12))
+
+#endif
Added: multipath-tools/upstream/current/libdevmapper/include/linux/.symlinks
==============================================================================
Added: multipath-tools/upstream/current/libdevmapper/include/list.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libdevmapper/include/list.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of the device-mapper userspace tools.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _LVM_LIST_H
+#define _LVM_LIST_H
+
+#include <assert.h>
+
+struct list {
+ struct list *n, *p;
+};
+
+#define LIST_INIT(name) struct list name = { &(name), &(name) }
+
+static inline void list_init(struct list *head)
+{
+ head->n = head->p = head;
+}
+
+static inline void list_add(struct list *head, struct list *elem)
+{
+ assert(head->n);
+
+ elem->n = head;
+ elem->p = head->p;
+
+ head->p->n = elem;
+ head->p = elem;
+}
+
+static inline void list_add_h(struct list *head, struct list *elem)
+{
+ assert(head->n);
+
+ elem->n = head->n;
+ elem->p = head;
+
+ head->n->p = elem;
+ head->n = elem;
+}
+
+static inline void list_del(struct list *elem)
+{
+ elem->n->p = elem->p;
+ elem->p->n = elem->n;
+}
+
+static inline int list_empty(struct list *head)
+{
+ return head->n == head;
+}
+
+static inline int list_end(struct list *head, struct list *elem)
+{
+ return elem->n == head;
+}
+
+static inline struct list *list_next(struct list *head, struct list *elem)
+{
+ return (list_end(head, elem) ? NULL : elem->n);
+}
+
+#define list_iterate(v, head) \
+ for (v = (head)->n; v != head; v = v->n)
+
+#define list_uniterate(v, head, start) \
+ for (v = (start)->p; v != head; v = v->p)
+
+#define list_iterate_safe(v, t, head) \
+ for (v = (head)->n, t = v->n; v != head; v = t, t = v->n)
+
+static inline unsigned int list_size(const struct list *head)
+{
+ unsigned int s = 0;
+ const struct list *v;
+
+ list_iterate(v, head)
+ s++;
+
+ return s;
+}
+
+#define list_item(v, t) \
+ ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->list))
+
+#define list_struct_base(v, t, h) \
+ ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->h))
+
+/* Given a known element in a known structure, locate another */
+#define struct_field(v, t, e, f) \
+ (((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->e))->f)
+
+/* Given a known element in a known structure, locate the list head */
+#define list_head(v, t, e) struct_field(v, t, e, list)
+
+#endif
Added: multipath-tools/upstream/current/libdevmapper/include/log.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libdevmapper/include/log.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of the device-mapper userspace tools.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef LIB_DMLOG_H
+#define LIB_DMLOG_H
+
+#include "libdevmapper.h"
+
+#define _LOG_DEBUG 7
+#define _LOG_INFO 6
+#define _LOG_NOTICE 5
+#define _LOG_WARN 4
+#define _LOG_ERR 3
+#define _LOG_FATAL 2
+
+extern dm_log_fn _log;
+
+#define plog(l, x...) _log(l, __FILE__, __LINE__, ## x)
+
+#define log_error(x...) plog(_LOG_ERR, x)
+#define log_print(x...) plog(_LOG_WARN, x)
+#define log_verbose(x...) plog(_LOG_NOTICE, x)
+#define log_very_verbose(x...) plog(_LOG_INFO, x)
+#define log_debug(x...) plog(_LOG_DEBUG, x)
+
+#endif
Added: multipath-tools/upstream/current/libdevmapper/ioctl/libdm-compat.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libdevmapper/ioctl/libdm-compat.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of the device-mapper userspace tools.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef _LINUX_LIBDM_COMPAT_H
+#define _LINUX_LIBDM_COMPAT_H
+
+#include "kdev_t.h"
+#include <inttypes.h>
+#include <linux/dm-ioctl.h>
+#include <sys/ioctl.h>
+
+struct dm_task;
+struct dm_info;
+
+/*
+ * Old versions of structures for backwards compatibility.
+ */
+
+struct dm_ioctl_v1 {
+ uint32_t version[3]; /* in/out */
+ uint32_t data_size; /* total size of data passed in
+ * including this struct */
+
+ uint32_t data_start; /* offset to start of data
+ * relative to start of this struct */
+
+ int32_t target_count; /* in/out */
+ int32_t open_count; /* out */
+ uint32_t flags; /* in/out */
+
+ __kernel_dev_t dev; /* in/out */
+
+ char name[DM_NAME_LEN]; /* device name */
+ char uuid[DM_UUID_LEN]; /* unique identifier for
+ * the block device */
+};
+
+struct dm_target_spec_v1 {
+ int32_t status; /* used when reading from kernel only */
+ uint64_t sector_start;
+ uint32_t length;
+ uint32_t next;
+
+ char target_type[DM_MAX_TYPE_NAME];
+
+};
+
+struct dm_target_deps_v1 {
+ uint32_t count;
+
+ __kernel_dev_t dev[0]; /* out */
+};
+
+enum {
+ /* Top level cmds */
+ DM_VERSION_CMD_V1 = 0,
+ DM_REMOVE_ALL_CMD_V1,
+
+ /* device level cmds */
+ DM_DEV_CREATE_CMD_V1,
+ DM_DEV_REMOVE_CMD_V1,
+ DM_DEV_RELOAD_CMD_V1,
+ DM_DEV_RENAME_CMD_V1,
+ DM_DEV_SUSPEND_CMD_V1,
+ DM_DEV_DEPS_CMD_V1,
+ DM_DEV_STATUS_CMD_V1,
+
+ /* target level cmds */
+ DM_TARGET_STATUS_CMD_V1,
+ DM_TARGET_WAIT_CMD_V1,
+};
+
+#define DM_VERSION_V1 _IOWR(DM_IOCTL, DM_VERSION_CMD_V1, struct dm_ioctl)
+#define DM_REMOVE_ALL_V1 _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD_V1, struct dm_ioctl)
+
+#define DM_DEV_CREATE_V1 _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD_V1, struct dm_ioctl)
+#define DM_DEV_REMOVE_V1 _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD_V1, struct dm_ioctl)
+#define DM_DEV_RELOAD_V1 _IOWR(DM_IOCTL, DM_DEV_RELOAD_CMD_V1, struct dm_ioctl)
+#define DM_DEV_SUSPEND_V1 _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD_V1, struct dm_ioctl)
+#define DM_DEV_RENAME_V1 _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD_V1, struct dm_ioctl)
+#define DM_DEV_DEPS_V1 _IOWR(DM_IOCTL, DM_DEV_DEPS_CMD_V1, struct dm_ioctl)
+#define DM_DEV_STATUS_V1 _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD_V1, struct dm_ioctl)
+
+#define DM_TARGET_STATUS_V1 _IOWR(DM_IOCTL, DM_TARGET_STATUS_CMD_V1, struct dm_ioctl)
+#define DM_TARGET_WAIT_V1 _IOWR(DM_IOCTL, DM_TARGET_WAIT_CMD_V1, struct dm_ioctl)
+
+/* *INDENT-OFF* */
+static struct cmd_data _cmd_data_v1[] = {
+ { "create", DM_DEV_CREATE_V1, {1, 0, 0} },
+ { "reload", DM_DEV_RELOAD_V1, {1, 0, 0} },
+ { "remove", DM_DEV_REMOVE_V1, {1, 0, 0} },
+ { "remove_all", DM_REMOVE_ALL_V1, {1, 0, 0} },
+ { "suspend", DM_DEV_SUSPEND_V1, {1, 0, 0} },
+ { "resume", DM_DEV_SUSPEND_V1, {1, 0, 0} },
+ { "info", DM_DEV_STATUS_V1, {1, 0, 0} },
+ { "deps", DM_DEV_DEPS_V1, {1, 0, 0} },
+ { "rename", DM_DEV_RENAME_V1, {1, 0, 0} },
+ { "version", DM_VERSION_V1, {1, 0, 0} },
+ { "status", DM_TARGET_STATUS_V1, {1, 0, 0} },
+ { "table", DM_TARGET_STATUS_V1, {1, 0, 0} },
+ { "waitevent", DM_TARGET_WAIT_V1, {1, 0, 0} },
+ { "names", 0, {4, 0, 0} },
+ { "clear", 0, {4, 0, 0} },
+ { "mknodes", 0, {4, 0, 0} },
+ { "versions", 0, {4, 1, 0} },
+ { "message", 0, {4, 2, 0} },
+};
+/* *INDENT-ON* */
+
+#endif
Added: multipath-tools/upstream/current/libdevmapper/ioctl/libdm-iface.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libdevmapper/ioctl/libdm-iface.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,1245 @@
+/*
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of the device-mapper userspace tools.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "libdm-targets.h"
+#include "libdm-common.h"
+#include "log.h"
+#include "kernel/ioctl/dm-ioctl.h"
+
+#ifdef DM_COMPAT
+# include "libdm-compat.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <limits.h>
+
+#ifdef linux
+# include "kdev_t.h"
+# include <linux/limits.h>
+# include <linux/dm-ioctl.h>
+#else
+# define MAJOR(x) major((x))
+# define MINOR(x) minor((x))
+# define MKDEV(x,y) makedev((x),(y))
+#endif
+
+/*
+ * Ensure build compatibility.
+ * The hard-coded versions here are the highest present
+ * in the _cmd_data arrays.
+ */
+
+#if !((DM_VERSION_MAJOR == 1 && DM_VERSION_MINOR >= 0) || \
+ (DM_VERSION_MAJOR == 4 && DM_VERSION_MINOR >= 0))
+#error The version of dm-ioctl.h included is incompatible.
+#endif
+
+/* dm major version no for running kernel */
+static int _dm_version = DM_VERSION_MAJOR;
+static int _log_suppress = 0;
+
+static int _control_fd = -1;
+static int _version_checked = 0;
+static int _version_ok = 1;
+
+/*
+ * Support both old and new major numbers to ease the transition.
+ * Clumsy, but only temporary.
+ */
+#if DM_VERSION_MAJOR == 4 && defined(DM_COMPAT)
+const int _dm_compat = 1;
+#else
+const int _dm_compat = 0;
+#endif
+
+
+/* *INDENT-OFF* */
+static struct cmd_data _cmd_data_v4[] = {
+ {"create", DM_DEV_CREATE, {4, 0, 0}},
+ {"reload", DM_TABLE_LOAD, {4, 0, 0}},
+ {"remove", DM_DEV_REMOVE, {4, 0, 0}},
+ {"remove_all", DM_REMOVE_ALL, {4, 0, 0}},
+ {"suspend", DM_DEV_SUSPEND, {4, 0, 0}},
+ {"resume", DM_DEV_SUSPEND, {4, 0, 0}},
+ {"info", DM_DEV_STATUS, {4, 0, 0}},
+ {"deps", DM_TABLE_DEPS, {4, 0, 0}},
+ {"rename", DM_DEV_RENAME, {4, 0, 0}},
+ {"version", DM_VERSION, {4, 0, 0}},
+ {"status", DM_TABLE_STATUS, {4, 0, 0}},
+ {"table", DM_TABLE_STATUS, {4, 0, 0}},
+ {"waitevent", DM_DEV_WAIT, {4, 0, 0}},
+ {"names", DM_LIST_DEVICES, {4, 0, 0}},
+ {"clear", DM_TABLE_CLEAR, {4, 0, 0}},
+ {"mknodes", DM_DEV_STATUS, {4, 0, 0}},
+#ifdef DM_LIST_VERSIONS
+ {"versions", DM_LIST_VERSIONS, {4, 1, 0}},
+#endif
+#ifdef DM_TARGET_MSG
+ {"message", DM_TARGET_MSG, {4, 2, 0}},
+#endif
+};
+/* *INDENT-ON* */
+
+#define ALIGNMENT_V1 sizeof(int)
+#define ALIGNMENT 8
+
+/* FIXME Rejig library to record & use errno instead */
+#ifndef DM_EXISTS_FLAG
+# define DM_EXISTS_FLAG 0x00000004
+#endif
+
+static void *_align(void *ptr, unsigned int a)
+{
+ register unsigned long agn = --a;
+
+ return (void *) (((unsigned long) ptr + agn) & ~agn);
+}
+
+static int _open_control(void)
+{
+ char control[PATH_MAX];
+
+ if (_control_fd != -1)
+ return 1;
+
+ snprintf(control, sizeof(control), "%s/control", dm_dir());
+
+ if ((_control_fd = open(control, O_RDWR)) < 0) {
+ log_error("%s: open failed: %s", control, strerror(errno));
+ log_error("Is device-mapper driver missing from kernel?");
+ return 0;
+ }
+
+ return 1;
+}
+
+void dm_task_destroy(struct dm_task *dmt)
+{
+ struct target *t, *n;
+
+ for (t = dmt->head; t; t = n) {
+ n = t->next;
+ free(t->params);
+ free(t->type);
+ free(t);
+ }
+
+ if (dmt->dev_name)
+ free(dmt->dev_name);
+
+ if (dmt->newname)
+ free(dmt->newname);
+
+ if (dmt->message)
+ free(dmt->message);
+
+ if (dmt->dmi.v4)
+ free(dmt->dmi.v4);
+
+ if (dmt->uuid)
+ free(dmt->uuid);
+
+ free(dmt);
+}
+
+/*
+ * Protocol Version 1 compatibility functions.
+ */
+
+#ifdef DM_COMPAT
+
+static int _dm_task_get_driver_version_v1(struct dm_task *dmt, char *version,
+ size_t size)
+{
+ unsigned int *v;
+
+ if (!dmt->dmi.v1) {
+ version[0] = '\0';
+ return 0;
+ }
+
+ v = dmt->dmi.v1->version;
+ snprintf(version, size, "%u.%u.%u", v[0], v[1], v[2]);
+ return 1;
+}
+
+/* Unmarshall the target info returned from a status call */
+static int _unmarshal_status_v1(struct dm_task *dmt, struct dm_ioctl_v1 *dmi)
+{
+ char *outbuf = (char *) dmi + dmi->data_start;
+ char *outptr = outbuf;
+ int32_t i;
+ struct dm_target_spec_v1 *spec;
+
+ for (i = 0; i < dmi->target_count; i++) {
+ spec = (struct dm_target_spec_v1 *) outptr;
+
+ if (!dm_task_add_target(dmt, spec->sector_start,
+ (uint64_t) spec->length,
+ spec->target_type,
+ outptr + sizeof(*spec))) {
+ return 0;
+ }
+
+ outptr = outbuf + spec->next;
+ }
+
+ return 1;
+}
+
+static int _dm_format_dev_v1(char *buf, int bufsize, uint32_t dev_major,
+ uint32_t dev_minor)
+{
+ int r;
+
+ if (bufsize < 8)
+ return 0;
+
+ r = snprintf(buf, bufsize, "%03x:%03x", dev_major, dev_minor);
+ if (r < 0 || r > bufsize - 1)
+ return 0;
+
+ return 1;
+}
+
+static int _dm_task_get_info_v1(struct dm_task *dmt, struct dm_info *info)
+{
+ if (!dmt->dmi.v1)
+ return 0;
+
+ memset(info, 0, sizeof(*info));
+
+ info->exists = dmt->dmi.v1->flags & DM_EXISTS_FLAG ? 1 : 0;
+ if (!info->exists)
+ return 1;
+
+ info->suspended = dmt->dmi.v1->flags & DM_SUSPEND_FLAG ? 1 : 0;
+ info->read_only = dmt->dmi.v1->flags & DM_READONLY_FLAG ? 1 : 0;
+ info->target_count = dmt->dmi.v1->target_count;
+ info->open_count = dmt->dmi.v1->open_count;
+ info->event_nr = 0;
+ info->major = MAJOR(dmt->dmi.v1->dev);
+ info->minor = MINOR(dmt->dmi.v1->dev);
+ info->live_table = 1;
+ info->inactive_table = 0;
+
+ return 1;
+}
+
+static const char *_dm_task_get_name_v1(struct dm_task *dmt)
+{
+ return (dmt->dmi.v1->name);
+}
+
+static const char *_dm_task_get_uuid_v1(struct dm_task *dmt)
+{
+ return (dmt->dmi.v1->uuid);
+}
+
+static struct dm_deps *_dm_task_get_deps_v1(struct dm_task *dmt)
+{
+ log_error("deps version 1 no longer supported by libdevmapper");
+ return NULL;
+}
+
+static struct dm_names *_dm_task_get_names_v1(struct dm_task *dmt)
+{
+ return (struct dm_names *) (((void *) dmt->dmi.v1) +
+ dmt->dmi.v1->data_start);
+}
+
+static void *_add_target_v1(struct target *t, void *out, void *end)
+{
+ void *out_sp = out;
+ struct dm_target_spec_v1 sp;
+ size_t sp_size = sizeof(struct dm_target_spec_v1);
+ int len;
+ const char no_space[] = "Ran out of memory building ioctl parameter";
+
+ out += sp_size;
+ if (out >= end) {
+ log_error(no_space);
+ return NULL;
+ }
+
+ sp.status = 0;
+ sp.sector_start = t->start;
+ sp.length = t->length;
+ strncpy(sp.target_type, t->type, sizeof(sp.target_type));
+
+ len = strlen(t->params);
+
+ if ((out + len + 1) >= end) {
+ log_error(no_space);
+
+ log_error("t->params= '%s'", t->params);
+ return NULL;
+ }
+ strcpy((char *) out, t->params);
+ out += len + 1;
+
+ /* align next block */
+ out = _align(out, ALIGNMENT_V1);
+
+ sp.next = out - out_sp;
+
+ memcpy(out_sp, &sp, sp_size);
+
+ return out;
+}
+
+static struct dm_ioctl_v1 *_flatten_v1(struct dm_task *dmt)
+{
+ const size_t min_size = 16 * 1024;
+ const int (*version)[3];
+
+ struct dm_ioctl_v1 *dmi;
+ struct target *t;
+ size_t len = sizeof(struct dm_ioctl_v1);
+ void *b, *e;
+ int count = 0;
+
+ for (t = dmt->head; t; t = t->next) {
+ len += sizeof(struct dm_target_spec_v1);
+ len += strlen(t->params) + 1 + ALIGNMENT_V1;
+ count++;
+ }
+
+ if (count && dmt->newname) {
+ log_error("targets and newname are incompatible");
+ return NULL;
+ }
+
+ if (dmt->newname)
+ len += strlen(dmt->newname) + 1;
+
+ /*
+ * Give len a minimum size so that we have space to store
+ * dependencies or status information.
+ */
+ if (len < min_size)
+ len = min_size;
+
+ if (!(dmi = malloc(len)))
+ return NULL;
+
+ memset(dmi, 0, len);
+
+ version = &_cmd_data_v1[dmt->type].version;
+
+ dmi->version[0] = (*version)[0];
+ dmi->version[1] = (*version)[1];
+ dmi->version[2] = (*version)[2];
+
+ dmi->data_size = len;
+ dmi->data_start = sizeof(struct dm_ioctl_v1);
+
+ if (dmt->dev_name)
+ strncpy(dmi->name, dmt->dev_name, sizeof(dmi->name));
+
+ if (dmt->type == DM_DEVICE_SUSPEND)
+ dmi->flags |= DM_SUSPEND_FLAG;
+ if (dmt->read_only)
+ dmi->flags |= DM_READONLY_FLAG;
+
+ if (dmt->minor >= 0) {
+ if (dmt->major <= 0) {
+ log_error("Missing major number for persistent device");
+ return NULL;
+ }
+ dmi->flags |= DM_PERSISTENT_DEV_FLAG;
+ dmi->dev = MKDEV(dmt->major, dmt->minor);
+ }
+
+ if (dmt->uuid)
+ strncpy(dmi->uuid, dmt->uuid, sizeof(dmi->uuid));
+
+ dmi->target_count = count;
+
+ b = (void *) (dmi + 1);
+ e = (void *) ((char *) dmi + len);
+
+ for (t = dmt->head; t; t = t->next)
+ if (!(b = _add_target_v1(t, b, e)))
+ goto bad;
+
+ if (dmt->newname)
+ strcpy(b, dmt->newname);
+
+ return dmi;
+
+ bad:
+ free(dmi);
+ return NULL;
+}
+
+static int _dm_names_v1(struct dm_ioctl_v1 *dmi)
+{
+ const char *dev_dir = dm_dir();
+ int r = 1, len;
+ const char *name;
+ struct dirent *dirent;
+ DIR *d;
+ struct dm_names *names, *old_names = NULL;
+ void *end = (void *) dmi + dmi->data_size;
+ struct stat buf;
+ char path[PATH_MAX];
+
+ log_print("Warning: Device list may be incomplete with interface "
+ "version 1.");
+ log_print("Please upgrade your kernel device-mapper driver.");
+
+ if (!(d = opendir(dev_dir))) {
+ log_error("%s: opendir failed: %s", dev_dir, strerror(errno));
+ return 0;
+ }
+
+ names = (struct dm_names *) ((void *) dmi + dmi->data_start);
+
+ names->dev = 0; /* Flags no data */
+
+ while ((dirent = readdir(d))) {
+ name = dirent->d_name;
+
+ if (name[0] == '.' || !strcmp(name, "control"))
+ continue;
+
+ if (old_names)
+ old_names->next = (uint32_t) ((void *) names -
+ (void *) old_names);
+ snprintf(path, sizeof(path), "%s/%s", dev_dir, name);
+ if (stat(path, &buf)) {
+ log_error("%s: stat failed: %s", path, strerror(errno));
+ continue;
+ }
+ if (!S_ISBLK(buf.st_mode))
+ continue;
+ names->dev = (uint64_t) buf.st_rdev;
+ names->next = 0;
+ len = strlen(name);
+ if (((void *) (names + 1) + len + 1) >= end) {
+ log_error("Insufficient buffer space for device list");
+ r = 0;
+ break;
+ }
+
+ strcpy(names->name, name);
+
+ old_names = names;
+ names = _align((void *) ++names + len + 1, ALIGNMENT);
+ }
+
+ if (closedir(d))
+ log_error("%s: closedir failed: %s", dev_dir, strerror(errno));
+
+ return r;
+}
+
+static int _dm_task_run_v1(struct dm_task *dmt)
+{
+ struct dm_ioctl_v1 *dmi;
+ unsigned int command;
+
+ dmi = _flatten_v1(dmt);
+ if (!dmi) {
+ log_error("Couldn't create ioctl argument");
+ return 0;
+ }
+
+ if (!_open_control())
+ return 0;
+
+ if ((unsigned) dmt->type >=
+ (sizeof(_cmd_data_v1) / sizeof(*_cmd_data_v1))) {
+ log_error("Internal error: unknown device-mapper task %d",
+ dmt->type);
+ goto bad;
+ }
+
+ command = _cmd_data_v1[dmt->type].cmd;
+
+ if (dmt->type == DM_DEVICE_TABLE)
+ dmi->flags |= DM_STATUS_TABLE_FLAG;
+
+ log_debug("dm %s %s %s %s", _cmd_data_v1[dmt->type].name, dmi->name,
+ dmi->uuid, dmt->newname ? dmt->newname : "");
+ if (dmt->type == DM_DEVICE_LIST) {
+ if (!_dm_names_v1(dmi))
+ goto bad;
+ } else if (ioctl(_control_fd, command, dmi) < 0) {
+ if (_log_suppress)
+ log_verbose("device-mapper ioctl cmd %d failed: %s",
+ _IOC_NR(command), strerror(errno));
+ else
+ log_error("device-mapper ioctl cmd %d failed: %s",
+ _IOC_NR(command), strerror(errno));
+ goto bad;
+ }
+
+ switch (dmt->type) {
+ case DM_DEVICE_CREATE:
+ add_dev_node(dmt->dev_name, MAJOR(dmi->dev), MINOR(dmi->dev));
+ break;
+
+ case DM_DEVICE_REMOVE:
+ rm_dev_node(dmt->dev_name);
+ break;
+
+ case DM_DEVICE_RENAME:
+ rename_dev_node(dmt->dev_name, dmt->newname);
+ break;
+
+ case DM_DEVICE_MKNODES:
+ if (dmi->flags & DM_EXISTS_FLAG)
+ add_dev_node(dmt->dev_name, MAJOR(dmi->dev),
+ MINOR(dmi->dev));
+ else
+ rm_dev_node(dmt->dev_name);
+ break;
+
+ case DM_DEVICE_STATUS:
+ case DM_DEVICE_TABLE:
+ if (!_unmarshal_status_v1(dmt, dmi))
+ goto bad;
+ break;
+
+ case DM_DEVICE_SUSPEND:
+ case DM_DEVICE_RESUME:
+ dmt->type = DM_DEVICE_INFO;
+ if (!dm_task_run(dmt))
+ goto bad;
+ free(dmi); /* We'll use what info returned */
+ return 1;
+ }
+
+ dmt->dmi.v1 = dmi;
+ return 1;
+
+ bad:
+ free(dmi);
+ return 0;
+}
+
+#endif
+
+/*
+ * Protocol Version 4 functions.
+ */
+
+int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size)
+{
+ unsigned int *v;
+
+#ifdef DM_COMPAT
+ if (_dm_version == 1)
+ return _dm_task_get_driver_version_v1(dmt, version, size);
+#endif
+
+ if (!dmt->dmi.v4) {
+ version[0] = '\0';
+ return 0;
+ }
+
+ v = dmt->dmi.v4->version;
+ snprintf(version, size, "%u.%u.%u", v[0], v[1], v[2]);
+ return 1;
+}
+
+static int _check_version(char *version, size_t size, int log_suppress)
+{
+ struct dm_task *task;
+ int r;
+
+ if (!(task = dm_task_create(DM_DEVICE_VERSION))) {
+ log_error("Failed to get device-mapper version");
+ version[0] = '\0';
+ return 0;
+ }
+
+ if (log_suppress)
+ _log_suppress = 1;
+
+ r = dm_task_run(task);
+ dm_task_get_driver_version(task, version, size);
+ dm_task_destroy(task);
+ _log_suppress = 0;
+
+ return r;
+}
+
+/*
+ * Find out device-mapper's major version number the first time
+ * this is called and whether or not we support it.
+ */
+int dm_check_version(void)
+{
+ char libversion[64], dmversion[64];
+ const char *compat = "";
+
+ if (_version_checked)
+ return _version_ok;
+
+ _version_checked = 1;
+
+ if (_check_version(dmversion, sizeof(dmversion), _dm_compat))
+ return 1;
+
+ if (!_dm_compat)
+ goto bad;
+
+ log_verbose("device-mapper ioctl protocol version %d failed. "
+ "Trying protocol version 1.", _dm_version);
+ _dm_version = 1;
+ if (_check_version(dmversion, sizeof(dmversion), 0)) {
+ log_verbose("Using device-mapper ioctl protocol version 1");
+ return 1;
+ }
+
+ compat = "(compat)";
+
+ dm_get_library_version(libversion, sizeof(libversion));
+
+ log_error("Incompatible libdevmapper %s%s and kernel driver %s",
+ libversion, compat, dmversion);
+
+ bad:
+ _version_ok = 0;
+ return 0;
+}
+
+void *dm_get_next_target(struct dm_task *dmt, void *next,
+ uint64_t *start, uint64_t *length,
+ char **target_type, char **params)
+{
+ struct target *t = (struct target *) next;
+
+ if (!t)
+ t = dmt->head;
+
+ if (!t)
+ return NULL;
+
+ *start = t->start;
+ *length = t->length;
+ *target_type = t->type;
+ *params = t->params;
+
+ return t->next;
+}
+
+/* Unmarshall the target info returned from a status call */
+static int _unmarshal_status(struct dm_task *dmt, struct dm_ioctl *dmi)
+{
+ char *outbuf = (char *) dmi + dmi->data_start;
+ char *outptr = outbuf;
+ uint32_t i;
+ struct dm_target_spec *spec;
+
+ for (i = 0; i < dmi->target_count; i++) {
+ spec = (struct dm_target_spec *) outptr;
+ if (!dm_task_add_target(dmt, spec->sector_start,
+ spec->length,
+ spec->target_type,
+ outptr + sizeof(*spec))) {
+ return 0;
+ }
+
+ outptr = outbuf + spec->next;
+ }
+
+ return 1;
+}
+
+int dm_format_dev(char *buf, int bufsize, uint32_t dev_major,
+ uint32_t dev_minor)
+{
+ int r;
+
+#ifdef DM_COMPAT
+ if (_dm_version == 1)
+ return _dm_format_dev_v1(buf, bufsize, dev_major, dev_minor);
+#endif
+
+ if (bufsize < 8)
+ return 0;
+
+ r = snprintf(buf, bufsize, "%03u:%03u", dev_major, dev_minor);
+ if (r < 0 || r > bufsize - 1)
+ return 0;
+
+ return 1;
+}
+
+int dm_task_get_info(struct dm_task *dmt, struct dm_info *info)
+{
+#ifdef DM_COMPAT
+ if (_dm_version == 1)
+ return _dm_task_get_info_v1(dmt, info);
+#endif
+
+ if (!dmt->dmi.v4)
+ return 0;
+
+ memset(info, 0, sizeof(*info));
+
+ info->exists = dmt->dmi.v4->flags & DM_EXISTS_FLAG ? 1 : 0;
+ if (!info->exists)
+ return 1;
+
+ info->suspended = dmt->dmi.v4->flags & DM_SUSPEND_FLAG ? 1 : 0;
+ info->read_only = dmt->dmi.v4->flags & DM_READONLY_FLAG ? 1 : 0;
+ info->live_table = dmt->dmi.v4->flags & DM_ACTIVE_PRESENT_FLAG ? 1 : 0;
+ info->inactive_table = dmt->dmi.v4->flags & DM_INACTIVE_PRESENT_FLAG ?
+ 1 : 0;
+ info->target_count = dmt->dmi.v4->target_count;
+ info->open_count = dmt->dmi.v4->open_count;
+ info->event_nr = dmt->dmi.v4->event_nr;
+ info->major = MAJOR(dmt->dmi.v4->dev);
+ info->minor = MINOR(dmt->dmi.v4->dev);
+
+ return 1;
+}
+
+const char *dm_task_get_name(struct dm_task *dmt)
+{
+#ifdef DM_COMPAT
+ if (_dm_version == 1)
+ return _dm_task_get_name_v1(dmt);
+#endif
+
+ return (dmt->dmi.v4->name);
+}
+
+const char *dm_task_get_uuid(struct dm_task *dmt)
+{
+#ifdef DM_COMPAT
+ if (_dm_version == 1)
+ return _dm_task_get_uuid_v1(dmt);
+#endif
+
+ return (dmt->dmi.v4->uuid);
+}
+
+struct dm_deps *dm_task_get_deps(struct dm_task *dmt)
+{
+#ifdef DM_COMPAT
+ if (_dm_version == 1)
+ return _dm_task_get_deps_v1(dmt);
+#endif
+
+ return (struct dm_deps *) (((void *) dmt->dmi.v4) +
+ dmt->dmi.v4->data_start);
+}
+
+struct dm_names *dm_task_get_names(struct dm_task *dmt)
+{
+#ifdef DM_COMPAT
+ if (_dm_version == 1)
+ return _dm_task_get_names_v1(dmt);
+#endif
+
+ return (struct dm_names *) (((void *) dmt->dmi.v4) +
+ dmt->dmi.v4->data_start);
+}
+
+struct dm_versions *dm_task_get_versions(struct dm_task *dmt)
+{
+ return (struct dm_versions *) (((void *) dmt->dmi.v4) +
+ dmt->dmi.v4->data_start);
+}
+
+int dm_task_set_ro(struct dm_task *dmt)
+{
+ dmt->read_only = 1;
+ return 1;
+}
+
+int dm_task_set_newname(struct dm_task *dmt, const char *newname)
+{
+ if (!(dmt->newname = strdup(newname))) {
+ log_error("dm_task_set_newname: strdup(%s) failed", newname);
+ return 0;
+ }
+
+ return 1;
+}
+
+int dm_task_set_message(struct dm_task *dmt, const char *message)
+{
+ if (!(dmt->message = strdup(message))) {
+ log_error("dm_task_set_message: strdup(%s) failed", message);
+ return 0;
+ }
+
+ return 1;
+}
+
+int dm_task_set_sector(struct dm_task *dmt, uint64_t sector)
+{
+ dmt->sector = sector;
+
+ return 1;
+}
+
+int dm_task_set_event_nr(struct dm_task *dmt, uint32_t event_nr)
+{
+ dmt->event_nr = event_nr;
+
+ return 1;
+}
+
+struct target *create_target(uint64_t start, uint64_t len, const char *type,
+ const char *params)
+{
+ struct target *t = malloc(sizeof(*t));
+
+ if (!t) {
+ log_error("create_target: malloc(%d) failed", sizeof(*t));
+ return NULL;
+ }
+
+ memset(t, 0, sizeof(*t));
+
+ if (!(t->params = strdup(params))) {
+ log_error("create_target: strdup(params) failed");
+ goto bad;
+ }
+
+ if (!(t->type = strdup(type))) {
+ log_error("create_target: strdup(type) failed");
+ goto bad;
+ }
+
+ t->start = start;
+ t->length = len;
+ return t;
+
+ bad:
+ free(t->params);
+ free(t->type);
+ free(t);
+ return NULL;
+}
+
+static void *_add_target(struct target *t, void *out, void *end)
+{
+ void *out_sp = out;
+ struct dm_target_spec sp;
+ size_t sp_size = sizeof(struct dm_target_spec);
+ int len;
+ const char no_space[] = "Ran out of memory building ioctl parameter";
+
+ out += sp_size;
+ if (out >= end) {
+ log_error(no_space);
+ return NULL;
+ }
+
+ sp.status = 0;
+ sp.sector_start = t->start;
+ sp.length = t->length;
+ strncpy(sp.target_type, t->type, sizeof(sp.target_type));
+
+ len = strlen(t->params);
+
+ if ((out + len + 1) >= end) {
+ log_error(no_space);
+
+ log_error("t->params= '%s'", t->params);
+ return NULL;
+ }
+ strcpy((char *) out, t->params);
+ out += len + 1;
+
+ /* align next block */
+ out = _align(out, ALIGNMENT);
+
+ sp.next = out - out_sp;
+ memcpy(out_sp, &sp, sp_size);
+
+ return out;
+}
+
+static struct dm_ioctl *_flatten(struct dm_task *dmt)
+{
+ const size_t min_size = 16 * 1024;
+ const int (*version)[3];
+
+ struct dm_ioctl *dmi;
+ struct target *t;
+ struct dm_target_msg *tmsg;
+ size_t len = sizeof(struct dm_ioctl);
+ void *b, *e;
+ int count = 0;
+
+ for (t = dmt->head; t; t = t->next) {
+ len += sizeof(struct dm_target_spec);
+ len += strlen(t->params) + 1 + ALIGNMENT;
+ count++;
+ }
+
+ if (count && (dmt->sector || dmt->message)) {
+ log_error("targets and message are incompatible");
+ return NULL;
+ }
+
+ if (count && dmt->newname) {
+ log_error("targets and newname are incompatible");
+ return NULL;
+ }
+
+ if (dmt->newname && (dmt->sector || dmt->message)) {
+ log_error("message and newname are incompatible");
+ return NULL;
+ }
+
+ if (dmt->sector && !dmt->message) {
+ log_error("message is required with sector");
+ return NULL;
+ }
+
+ if (dmt->newname)
+ len += strlen(dmt->newname) + 1;
+
+ if (dmt->message)
+ len += sizeof(struct dm_target_msg) + strlen(dmt->message) + 1;
+
+ /*
+ * Give len a minimum size so that we have space to store
+ * dependencies or status information.
+ */
+ if (len < min_size)
+ len = min_size;
+
+ if (!(dmi = malloc(len)))
+ return NULL;
+
+ memset(dmi, 0, len);
+
+ version = &_cmd_data_v4[dmt->type].version;
+
+ dmi->version[0] = (*version)[0];
+ dmi->version[1] = (*version)[1];
+ dmi->version[2] = (*version)[2];
+
+ dmi->data_size = len;
+ dmi->data_start = sizeof(struct dm_ioctl);
+
+ if (dmt->dev_name)
+ strncpy(dmi->name, dmt->dev_name, sizeof(dmi->name));
+
+ if (dmt->type == DM_DEVICE_SUSPEND)
+ dmi->flags |= DM_SUSPEND_FLAG;
+ if (dmt->read_only)
+ dmi->flags |= DM_READONLY_FLAG;
+
+ if (dmt->minor >= 0) {
+ if (dmt->major <= 0) {
+ log_error("Missing major number for persistent device");
+ return NULL;
+ }
+ dmi->flags |= DM_PERSISTENT_DEV_FLAG;
+ dmi->dev = MKDEV(dmt->major, dmt->minor);
+ }
+
+ if (dmt->uuid)
+ strncpy(dmi->uuid, dmt->uuid, sizeof(dmi->uuid));
+
+ dmi->target_count = count;
+ dmi->event_nr = dmt->event_nr;
+
+ b = (void *) (dmi + 1);
+ e = (void *) ((char *) dmi + len);
+
+ for (t = dmt->head; t; t = t->next)
+ if (!(b = _add_target(t, b, e)))
+ goto bad;
+
+ if (dmt->newname)
+ strcpy(b, dmt->newname);
+
+ if (dmt->message) {
+ tmsg = (struct dm_target_msg *) b;
+ tmsg->sector = dmt->sector;
+ strcpy(tmsg->message, dmt->message);
+ }
+
+ return dmi;
+
+ bad:
+ free(dmi);
+ return NULL;
+}
+
+static int _process_mapper_dir(struct dm_task *dmt)
+{
+ struct dirent *dirent;
+ DIR *d;
+ const char *dir;
+ int r = 1;
+
+ dir = dm_dir();
+ if (!(d = opendir(dir))) {
+ fprintf(stderr, "opendir %s: %s", dir, strerror(errno));
+ return 0;
+ }
+
+ while ((dirent = readdir(d))) {
+ if (!strcmp(dirent->d_name, ".") ||
+ !strcmp(dirent->d_name, "..") ||
+ !strcmp(dirent->d_name, "control"))
+ continue;
+ dm_task_set_name(dmt, dirent->d_name);
+ dm_task_run(dmt);
+ }
+
+ if (closedir(d)) {
+ fprintf(stderr, "closedir %s: %s", dir, strerror(errno));
+ }
+
+ return r;
+}
+
+static int _process_all_v4(struct dm_task *dmt)
+{
+ struct dm_task *task;
+ struct dm_names *names;
+ unsigned next = 0;
+ int r = 1;
+
+ if (!(task = dm_task_create(DM_DEVICE_LIST)))
+ return 0;
+
+ if (!dm_task_run(task)) {
+ r = 0;
+ goto out;
+ }
+
+ if (!(names = dm_task_get_names(task))) {
+ r = 0;
+ goto out;
+ }
+
+ if (!names->dev)
+ goto out;
+
+ do {
+ names = (void *) names + next;
+ if (!dm_task_set_name(dmt, names->name)) {
+ r = 0;
+ goto out;
+ }
+ if (!dm_task_run(dmt))
+ r = 0;
+ next = names->next;
+ } while (next);
+
+ out:
+ dm_task_destroy(task);
+ return r;
+}
+
+static int _mknodes_v4(struct dm_task *dmt)
+{
+ (void) _process_mapper_dir(dmt);
+
+ return _process_all_v4(dmt);
+}
+
+static int _create_and_load_v4(struct dm_task *dmt)
+{
+ struct dm_task *task;
+ int r;
+
+ /* Use new task struct to create the device */
+ if (!(task = dm_task_create(DM_DEVICE_CREATE))) {
+ log_error("Failed to create device-mapper task struct");
+ return 0;
+ }
+
+ /* Copy across relevant fields */
+ if (dmt->dev_name && !dm_task_set_name(task, dmt->dev_name)) {
+ dm_task_destroy(task);
+ return 0;
+ }
+
+ if (dmt->uuid && !dm_task_set_uuid(task, dmt->uuid)) {
+ dm_task_destroy(task);
+ return 0;
+ }
+
+ task->major = dmt->major;
+ task->minor = dmt->minor;
+
+ r = dm_task_run(task);
+ dm_task_destroy(task);
+ if (!r)
+ return r;
+
+ /* Next load the table */
+ if (!(task = dm_task_create(DM_DEVICE_RELOAD))) {
+ log_error("Failed to create device-mapper task struct");
+ return 0;
+ }
+
+ /* Copy across relevant fields */
+ if (dmt->dev_name && !dm_task_set_name(task, dmt->dev_name)) {
+ dm_task_destroy(task);
+ return 0;
+ }
+
+ task->read_only = dmt->read_only;
+ task->head = dmt->head;
+ task->tail = dmt->tail;
+
+ r = dm_task_run(task);
+
+ task->head = NULL;
+ task->tail = NULL;
+ dm_task_destroy(task);
+ if (!r)
+ return r;
+
+ /* Use the original structure last so the info will be correct */
+ dmt->type = DM_DEVICE_RESUME;
+ free(dmt->uuid);
+ dmt->uuid = NULL;
+
+ r = dm_task_run(dmt);
+
+ return r;
+}
+
+int dm_task_run(struct dm_task *dmt)
+{
+ struct dm_ioctl *dmi = NULL;
+ unsigned int command;
+
+#ifdef DM_COMPAT
+ if (_dm_version == 1)
+ return _dm_task_run_v1(dmt);
+#endif
+
+ if ((unsigned) dmt->type >=
+ (sizeof(_cmd_data_v4) / sizeof(*_cmd_data_v4))) {
+ log_error("Internal error: unknown device-mapper task %d",
+ dmt->type);
+ goto bad;
+ }
+
+ command = _cmd_data_v4[dmt->type].cmd;
+
+ /* Old-style creation had a table supplied */
+ if (dmt->type == DM_DEVICE_CREATE && dmt->head)
+ return _create_and_load_v4(dmt);
+
+ if (dmt->type == DM_DEVICE_MKNODES && !dmt->dev_name)
+ return _mknodes_v4(dmt);
+
+ if (!_open_control())
+ return 0;
+
+ dmi = _flatten(dmt);
+ if (!dmi) {
+ log_error("Couldn't create ioctl argument");
+ return 0;
+ }
+
+ if (dmt->type == DM_DEVICE_TABLE)
+ dmi->flags |= DM_STATUS_TABLE_FLAG;
+
+ dmi->flags |= DM_EXISTS_FLAG; /* FIXME */
+ log_debug("dm %s %s %s %s%.0llu %s", _cmd_data_v4[dmt->type].name,
+ dmi->name, dmi->uuid, dmt->newname ? dmt->newname : "",
+ dmt->sector, dmt->message ? dmt->message : "");
+ if (ioctl(_control_fd, command, dmi) < 0) {
+ if (errno == ENXIO && ((dmt->type == DM_DEVICE_INFO) ||
+ (dmt->type == DM_DEVICE_MKNODES))) {
+ dmi->flags &= ~DM_EXISTS_FLAG; /* FIXME */
+ goto ignore_error;
+ }
+ if (_log_suppress)
+ log_verbose("device-mapper ioctl cmd %d failed: %s",
+ _IOC_NR(command), strerror(errno));
+ else
+ log_error("device-mapper ioctl cmd %d failed: %s",
+ _IOC_NR(command), strerror(errno));
+ goto bad;
+ }
+
+ ignore_error:
+ switch (dmt->type) {
+ case DM_DEVICE_CREATE:
+ add_dev_node(dmt->dev_name, MAJOR(dmi->dev), MINOR(dmi->dev));
+ break;
+
+ case DM_DEVICE_REMOVE:
+ rm_dev_node(dmt->dev_name);
+ break;
+
+ case DM_DEVICE_RENAME:
+ rename_dev_node(dmt->dev_name, dmt->newname);
+ break;
+
+ case DM_DEVICE_MKNODES:
+ if (dmi->flags & DM_EXISTS_FLAG)
+ add_dev_node(dmt->dev_name, MAJOR(dmi->dev),
+ MINOR(dmi->dev));
+ else
+ rm_dev_node(dmt->dev_name);
+ break;
+
+ case DM_DEVICE_STATUS:
+ case DM_DEVICE_TABLE:
+ case DM_DEVICE_WAITEVENT:
+ if (!_unmarshal_status(dmt, dmi))
+ goto bad;
+ break;
+ }
+
+ dmt->dmi.v4 = dmi;
+ return 1;
+
+ bad:
+ free(dmi);
+ return 0;
+}
+
+void dm_lib_release(void)
+{
+ if (_control_fd != -1) {
+ close(_control_fd);
+ _control_fd = -1;
+ }
+ update_devs();
+}
+
+void dm_lib_exit(void)
+{
+ if (_control_fd != -1) {
+ close(_control_fd);
+ _control_fd = -1;
+ }
+ _version_ok = 1;
+ _version_checked = 0;
+}
Added: multipath-tools/upstream/current/libdevmapper/ioctl/libdm-targets.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libdevmapper/ioctl/libdm-targets.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of the device-mapper userspace tools.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef LIB_DMTARGETS_H
+#define LIB_DMTARGETS_H
+
+#include <inttypes.h>
+
+struct dm_ioctl;
+struct dm_ioctl_v1;
+
+struct target {
+ uint64_t start;
+ uint64_t length;
+ char *type;
+ char *params;
+
+ struct target *next;
+};
+
+struct dm_task {
+ int type;
+ char *dev_name;
+
+ struct target *head, *tail;
+
+ int read_only;
+ uint32_t event_nr;
+ int major;
+ int minor;
+ union {
+ struct dm_ioctl *v4;
+ struct dm_ioctl_v1 *v1;
+ } dmi;
+ char *newname;
+ char *message;
+ uint64_t sector;
+
+ char *uuid;
+};
+
+struct cmd_data {
+ const char *name;
+ const int cmd;
+ const int version[3];
+};
+
+int dm_check_version(void);
+
+#endif
Added: multipath-tools/upstream/current/libdevmapper/kernel/ioctl/dm-ioctl.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libdevmapper/kernel/ioctl/dm-ioctl.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,300 @@
+/*
+ * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited.
+ *
+ * This file is released under the LGPL.
+ */
+
+#ifndef _LINUX_DM_IOCTL_V4_H
+#define _LINUX_DM_IOCTL_V4_H
+
+#include <linux/types.h>
+
+#define DM_DIR "mapper" /* Slashes not supported */
+#define DM_MAX_TYPE_NAME 16
+#define DM_NAME_LEN 128
+#define DM_UUID_LEN 129
+
+/*
+ * A traditional ioctl interface for the device mapper.
+ *
+ * Each device can have two tables associated with it, an
+ * 'active' table which is the one currently used by io passing
+ * through the device, and an 'inactive' one which is a table
+ * that is being prepared as a replacement for the 'active' one.
+ *
+ * DM_VERSION:
+ * Just get the version information for the ioctl interface.
+ *
+ * DM_REMOVE_ALL:
+ * Remove all dm devices, destroy all tables. Only really used
+ * for debug.
+ *
+ * DM_LIST_DEVICES:
+ * Get a list of all the dm device names.
+ *
+ * DM_DEV_CREATE:
+ * Create a new device, neither the 'active' or 'inactive' table
+ * slots will be filled. The device will be in suspended state
+ * after creation, however any io to the device will get errored
+ * since it will be out-of-bounds.
+ *
+ * DM_DEV_REMOVE:
+ * Remove a device, destroy any tables.
+ *
+ * DM_DEV_RENAME:
+ * Rename a device.
+ *
+ * DM_SUSPEND:
+ * This performs both suspend and resume, depending which flag is
+ * passed in.
+ * Suspend: This command will not return until all pending io to
+ * the device has completed. Further io will be deferred until
+ * the device is resumed.
+ * Resume: It is no longer an error to issue this command on an
+ * unsuspended device. If a table is present in the 'inactive'
+ * slot, it will be moved to the active slot, then the old table
+ * from the active slot will be _destroyed_. Finally the device
+ * is resumed.
+ *
+ * DM_DEV_STATUS:
+ * Retrieves the status for the table in the 'active' slot.
+ *
+ * DM_DEV_WAIT:
+ * Wait for a significant event to occur to the device. This
+ * could either be caused by an event triggered by one of the
+ * targets of the table in the 'active' slot, or a table change.
+ *
+ * DM_TABLE_LOAD:
+ * Load a table into the 'inactive' slot for the device. The
+ * device does _not_ need to be suspended prior to this command.
+ *
+ * DM_TABLE_CLEAR:
+ * Destroy any table in the 'inactive' slot (ie. abort).
+ *
+ * DM_TABLE_DEPS:
+ * Return a set of device dependencies for the 'active' table.
+ *
+ * DM_TABLE_STATUS:
+ * Return the targets status for the 'active' table.
+ *
+ * DM_TARGET_MSG:
+ * Pass a message string to the target at a specific offset of a device.
+ */
+
+/*
+ * All ioctl arguments consist of a single chunk of memory, with
+ * this structure at the start. If a uuid is specified any
+ * lookup (eg. for a DM_INFO) will be done on that, *not* the
+ * name.
+ */
+struct dm_ioctl {
+ /*
+ * The version number is made up of three parts:
+ * major - no backward or forward compatibility,
+ * minor - only backwards compatible,
+ * patch - both backwards and forwards compatible.
+ *
+ * All clients of the ioctl interface should fill in the
+ * version number of the interface that they were
+ * compiled with.
+ *
+ * All recognised ioctl commands (ie. those that don't
+ * return -ENOTTY) fill out this field, even if the
+ * command failed.
+ */
+ uint32_t version[3]; /* in/out */
+ uint32_t data_size; /* total size of data passed in
+ * including this struct */
+
+ uint32_t data_start; /* offset to start of data
+ * relative to start of this struct */
+
+ uint32_t target_count; /* in/out */
+ int32_t open_count; /* out */
+ uint32_t flags; /* in/out */
+ uint32_t event_nr; /* in/out */
+ uint32_t padding;
+
+ uint64_t dev; /* in/out */
+
+ char name[DM_NAME_LEN]; /* device name */
+ char uuid[DM_UUID_LEN]; /* unique identifier for
+ * the block device */
+};
+
+/*
+ * Used to specify tables. These structures appear after the
+ * dm_ioctl.
+ */
+struct dm_target_spec {
+ uint64_t sector_start;
+ uint64_t length;
+ int32_t status; /* used when reading from kernel only */
+
+ /*
+ * Location of the next dm_target_spec.
+ * - When specifying targets on a DM_TABLE_LOAD command, this value is
+ * the number of bytes from the start of the "current" dm_target_spec
+ * to the start of the "next" dm_target_spec.
+ * - When retrieving targets on a DM_TABLE_STATUS command, this value
+ * is the number of bytes from the start of the first dm_target_spec
+ * (that follows the dm_ioctl struct) to the start of the "next"
+ * dm_target_spec.
+ */
+ uint32_t next;
+
+ char target_type[DM_MAX_TYPE_NAME];
+
+ /*
+ * Parameter string starts immediately after this object.
+ * Be careful to add padding after string to ensure correct
+ * alignment of subsequent dm_target_spec.
+ */
+};
+
+/*
+ * Used to retrieve the target dependencies.
+ */
+struct dm_target_deps {
+ uint32_t count; /* Array size */
+ uint32_t padding; /* unused */
+ uint64_t dev[0]; /* out */
+};
+
+/*
+ * Used to get a list of all dm devices.
+ */
+struct dm_name_list {
+ uint64_t dev;
+ uint32_t next; /* offset to the next record from
+ the _start_ of this */
+ char name[0];
+};
+
+/*
+ * Used to retrieve the target versions
+ */
+struct dm_target_versions {
+ uint32_t next;
+ uint32_t version[3];
+
+ char name[0];
+};
+
+/*
+ * Used to pass message to a target
+ */
+struct dm_target_msg {
+ uint64_t sector; /* Device sector */
+
+ char message[0];
+};
+
+/*
+ * If you change this make sure you make the corresponding change
+ * to dm-ioctl.c:lookup_ioctl()
+ */
+enum {
+ /* Top level cmds */
+ DM_VERSION_CMD = 0,
+ DM_REMOVE_ALL_CMD,
+ DM_LIST_DEVICES_CMD,
+
+ /* device level cmds */
+ DM_DEV_CREATE_CMD,
+ DM_DEV_REMOVE_CMD,
+ DM_DEV_RENAME_CMD,
+ DM_DEV_SUSPEND_CMD,
+ DM_DEV_STATUS_CMD,
+ DM_DEV_WAIT_CMD,
+
+ /* Table level cmds */
+ DM_TABLE_LOAD_CMD,
+ DM_TABLE_CLEAR_CMD,
+ DM_TABLE_DEPS_CMD,
+ DM_TABLE_STATUS_CMD,
+
+ /* Added later */
+ DM_LIST_VERSIONS_CMD,
+ DM_TARGET_MSG_CMD,
+};
+
+/*
+ * The dm_ioctl struct passed into the ioctl is just the header
+ * on a larger chunk of memory. On x86-64 and other
+ * architectures the dm-ioctl struct will be padded to an 8 byte
+ * boundary so the size will be different, which would change the
+ * ioctl code - yes I really messed up. This hack forces these
+ * architectures to have the correct ioctl code.
+ */
+#ifdef CONFIG_COMPAT
+typedef char ioctl_struct[308];
+#define DM_VERSION_32 _IOWR(DM_IOCTL, DM_VERSION_CMD, ioctl_struct)
+#define DM_REMOVE_ALL_32 _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, ioctl_struct)
+#define DM_LIST_DEVICES_32 _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, ioctl_struct)
+
+#define DM_DEV_CREATE_32 _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, ioctl_struct)
+#define DM_DEV_REMOVE_32 _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, ioctl_struct)
+#define DM_DEV_RENAME_32 _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, ioctl_struct)
+#define DM_DEV_SUSPEND_32 _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, ioctl_struct)
+#define DM_DEV_STATUS_32 _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, ioctl_struct)
+#define DM_DEV_WAIT_32 _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, ioctl_struct)
+
+#define DM_TABLE_LOAD_32 _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, ioctl_struct)
+#define DM_TABLE_CLEAR_32 _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, ioctl_struct)
+#define DM_TABLE_DEPS_32 _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, ioctl_struct)
+#define DM_TABLE_STATUS_32 _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, ioctl_struct)
+#define DM_LIST_VERSIONS_32 _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, ioctl_struct)
+#define DM_TARGET_MSG_32 _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, ioctl_struct)
+#endif
+
+#define DM_IOCTL 0xfd
+
+#define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
+#define DM_REMOVE_ALL _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
+#define DM_LIST_DEVICES _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
+
+#define DM_DEV_CREATE _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
+#define DM_DEV_REMOVE _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
+#define DM_DEV_RENAME _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl)
+#define DM_DEV_SUSPEND _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl)
+#define DM_DEV_STATUS _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl)
+#define DM_DEV_WAIT _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl)
+
+#define DM_TABLE_LOAD _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl)
+#define DM_TABLE_CLEAR _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
+#define DM_TABLE_DEPS _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
+#define DM_TABLE_STATUS _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
+#define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
+#define DM_TARGET_MSG _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
+
+#define DM_VERSION_MAJOR 4
+#define DM_VERSION_MINOR 2
+#define DM_VERSION_PATCHLEVEL 0
+#define DM_VERSION_EXTRA "-ioctl (2004-06-08)"
+
+/* Status bits */
+#define DM_READONLY_FLAG (1 << 0) /* In/Out */
+#define DM_SUSPEND_FLAG (1 << 1) /* In/Out */
+#define DM_PERSISTENT_DEV_FLAG (1 << 3) /* In */
+
+/*
+ * Flag passed into ioctl STATUS command to get table information
+ * rather than current status.
+ */
+#define DM_STATUS_TABLE_FLAG (1 << 4) /* In */
+
+/*
+ * Flags that indicate whether a table is present in either of
+ * the two table slots that a device has.
+ */
+#define DM_ACTIVE_PRESENT_FLAG (1 << 5) /* Out */
+#define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */
+
+/*
+ * Indicates that the buffer passed in wasn't big enough for the
+ * results.
+ */
+#define DM_BUFFER_FULL_FLAG (1 << 8) /* Out */
+
+#endif /* _LINUX_DM_IOCTL_H */
Added: multipath-tools/upstream/current/libdevmapper/libdevmapper-klibc.a
==============================================================================
Binary file. No diff available.
Added: multipath-tools/upstream/current/libdevmapper/libdevmapper.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libdevmapper/libdevmapper.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of the device-mapper userspace tools.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef LIB_DEVICE_MAPPER_H
+#define LIB_DEVICE_MAPPER_H
+
+#include <inttypes.h>
+#include <sys/types.h>
+
+#ifdef linux
+# include <linux/types.h>
+#endif
+
+/*
+ * Since it is quite laborious to build the ioctl
+ * arguments for the device-mapper people are
+ * encouraged to use this library.
+ *
+ * You will need to build a struct dm_task for
+ * each ioctl command you want to execute.
+ */
+
+typedef void (*dm_log_fn) (int level, const char *file, int line,
+ const char *f, ...);
+
+/*
+ * The library user may wish to register their own
+ * logging function, by default errors go to stderr.
+ * Use dm_log_init(NULL) to restore the default log fn.
+ */
+void dm_log_init(dm_log_fn fn);
+void dm_log_init_verbose(int level);
+
+enum {
+ DM_DEVICE_CREATE,
+ DM_DEVICE_RELOAD,
+ DM_DEVICE_REMOVE,
+ DM_DEVICE_REMOVE_ALL,
+
+ DM_DEVICE_SUSPEND,
+ DM_DEVICE_RESUME,
+
+ DM_DEVICE_INFO,
+ DM_DEVICE_DEPS,
+ DM_DEVICE_RENAME,
+
+ DM_DEVICE_VERSION,
+
+ DM_DEVICE_STATUS,
+ DM_DEVICE_TABLE,
+ DM_DEVICE_WAITEVENT,
+
+ DM_DEVICE_LIST,
+
+ DM_DEVICE_CLEAR,
+
+ DM_DEVICE_MKNODES,
+
+ DM_DEVICE_LIST_VERSIONS,
+
+ DM_DEVICE_TARGET_MSG
+};
+
+struct dm_task;
+
+struct dm_task *dm_task_create(int type);
+void dm_task_destroy(struct dm_task *dmt);
+
+int dm_task_set_name(struct dm_task *dmt, const char *name);
+int dm_task_set_uuid(struct dm_task *dmt, const char *uuid);
+
+/*
+ * Retrieve attributes after an info.
+ */
+struct dm_info {
+ int exists;
+ int suspended;
+ int live_table;
+ int inactive_table;
+ int32_t open_count;
+ uint32_t event_nr;
+ uint32_t major;
+ uint32_t minor; /* minor device number */
+ int read_only; /* 0:read-write; 1:read-only */
+
+ int32_t target_count;
+};
+
+struct dm_deps {
+ uint32_t count;
+ uint32_t filler;
+ uint64_t device[0];
+};
+
+struct dm_names {
+ uint64_t dev;
+ uint32_t next; /* Offset to next struct from start of this struct */
+ char name[0];
+};
+
+struct dm_versions {
+ uint32_t next; /* Offset to next struct from start of this struct */
+ uint32_t version[3];
+
+ char name[0];
+};
+
+int dm_get_library_version(char *version, size_t size);
+int dm_task_get_driver_version(struct dm_task *dmt, char *version, size_t size);
+int dm_task_get_info(struct dm_task *dmt, struct dm_info *dmi);
+const char *dm_task_get_name(struct dm_task *dmt);
+const char *dm_task_get_uuid(struct dm_task *dmt);
+
+struct dm_deps *dm_task_get_deps(struct dm_task *dmt);
+struct dm_names *dm_task_get_names(struct dm_task *dmt);
+struct dm_versions *dm_task_get_versions(struct dm_task *dmt);
+
+int dm_task_set_ro(struct dm_task *dmt);
+int dm_task_set_newname(struct dm_task *dmt, const char *newname);
+int dm_task_set_minor(struct dm_task *dmt, int minor);
+int dm_task_set_major(struct dm_task *dmt, int major);
+int dm_task_set_event_nr(struct dm_task *dmt, uint32_t event_nr);
+int dm_task_set_message(struct dm_task *dmt, const char *message);
+int dm_task_set_sector(struct dm_task *dmt, uint64_t sector);
+
+/*
+ * Use these to prepare for a create or reload.
+ */
+int dm_task_add_target(struct dm_task *dmt,
+ uint64_t start,
+ uint64_t size, const char *ttype, const char *params);
+
+/*
+ * Format major/minor numbers correctly for input to driver
+ */
+int dm_format_dev(char *buf, int bufsize, uint32_t dev_major, uint32_t dev_minor);
+
+/* Use this to retrive target information returned from a STATUS call */
+void *dm_get_next_target(struct dm_task *dmt,
+ void *next, uint64_t *start, uint64_t *length,
+ char **target_type, char **params);
+
+/*
+ * Call this to actually run the ioctl.
+ */
+int dm_task_run(struct dm_task *dmt);
+
+/*
+ * Configure the device-mapper directory
+ */
+int dm_set_dev_dir(const char *dir);
+const char *dm_dir(void);
+
+/* Release library resources */
+void dm_lib_release(void);
+void dm_lib_exit(void);
+
+#endif /* LIB_DEVICE_MAPPER_H */
Added: multipath-tools/upstream/current/libdevmapper/libdm-common.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libdevmapper/libdm-common.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,428 @@
+/*
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of the device-mapper userspace tools.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "libdm-targets.h"
+#include "libdm-common.h"
+#include "list.h"
+#include "log.h"
+#include "kdev_t.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+#include <linux/dm-ioctl.h>
+
+#ifdef HAVE_SELINUX
+# include <selinux/selinux.h>
+#endif
+
+#define DEV_DIR "/dev/"
+
+static char _dm_dir[PATH_MAX] = DEV_DIR DM_DIR;
+
+static int _verbose = 0;
+
+/*
+ * Library users can provide their own logging
+ * function.
+ */
+static void _default_log(int level, const char *file, int line,
+ const char *f, ...)
+{
+ va_list ap;
+
+ if (level > _LOG_WARN && !_verbose)
+ return;
+
+ va_start(ap, f);
+
+ if (level < _LOG_WARN)
+ vfprintf(stderr, f, ap);
+ else
+ vprintf(f, ap);
+
+ va_end(ap);
+
+ if (level < _LOG_WARN)
+ fprintf(stderr, "\n");
+ else
+ fprintf(stdout, "\n");
+}
+
+dm_log_fn _log = _default_log;
+
+void dm_log_init(dm_log_fn fn)
+{
+ if (fn)
+ _log = fn;
+ else
+ _log = _default_log;
+}
+
+void dm_log_init_verbose(int level)
+{
+ _verbose = level;
+}
+
+static void _build_dev_path(char *buffer, size_t len, const char *dev_name)
+{
+ /* If there's a /, assume caller knows what they're doing */
+ if (strchr(dev_name, '/'))
+ snprintf(buffer, len, "%s", dev_name);
+ else
+ snprintf(buffer, len, "%s/%s", _dm_dir, dev_name);
+}
+
+int dm_get_library_version(char *version, size_t size)
+{
+ strncpy(version, DM_LIB_VERSION, size);
+ return 1;
+}
+
+struct dm_task *dm_task_create(int type)
+{
+ struct dm_task *dmt = malloc(sizeof(*dmt));
+
+ if (!dm_check_version())
+ return NULL;
+
+ if (!dmt) {
+ log_error("dm_task_create: malloc(%d) failed", sizeof(*dmt));
+ return NULL;
+ }
+
+ memset(dmt, 0, sizeof(*dmt));
+
+ dmt->type = type;
+ dmt->minor = -1;
+ dmt->major = -1;
+
+ return dmt;
+}
+
+int dm_task_set_name(struct dm_task *dmt, const char *name)
+{
+ char *pos;
+ char path[PATH_MAX];
+ struct stat st1, st2;
+
+ if (dmt->dev_name) {
+ free(dmt->dev_name);
+ dmt->dev_name = NULL;
+ }
+
+ /* If path was supplied, remove it if it points to the same device
+ * as its last component.
+ */
+ if ((pos = strrchr(name, '/'))) {
+ snprintf(path, sizeof(path), "%s/%s", _dm_dir, pos + 1);
+
+ if (stat(name, &st1) || stat(path, &st2) ||
+ !(st1.st_dev == st2.st_dev)) {
+ log_error("dm_task_set_name: Device %s not found",
+ name);
+ return 0;
+ }
+
+ name = pos + 1;
+ }
+
+ if (!(dmt->dev_name = strdup(name))) {
+ log_error("dm_task_set_name: strdup(%s) failed", name);
+ return 0;
+ }
+
+ return 1;
+}
+
+int dm_task_set_uuid(struct dm_task *dmt, const char *uuid)
+{
+ if (dmt->uuid) {
+ free(dmt->uuid);
+ dmt->uuid = NULL;
+ }
+
+ if (!(dmt->uuid = strdup(uuid))) {
+ log_error("dm_task_set_uuid: strdup(%s) failed", uuid);
+ return 0;
+ }
+
+ return 1;
+}
+
+int dm_task_set_major(struct dm_task *dmt, int major)
+{
+ dmt->major = major;
+ log_debug("Setting major: %d", dmt->major);
+
+ return 1;
+}
+
+int dm_task_set_minor(struct dm_task *dmt, int minor)
+{
+ dmt->minor = minor;
+ log_debug("Setting minor: %d", dmt->minor);
+
+ return 1;
+}
+
+int dm_task_add_target(struct dm_task *dmt, uint64_t start, uint64_t size,
+ const char *ttype, const char *params)
+{
+ struct target *t = create_target(start, size, ttype, params);
+
+ if (!t)
+ return 0;
+
+ if (!dmt->head)
+ dmt->head = dmt->tail = t;
+ else {
+ dmt->tail->next = t;
+ dmt->tail = t;
+ }
+
+ return 1;
+}
+
+#ifdef HAVE_SELINUX
+static int _set_selinux_context(const char *path)
+{
+ security_context_t scontext;
+
+ log_debug("Setting SELinux context for %s", path);
+ if (is_selinux_enabled() <= 0)
+ return 1;
+
+ if (matchpathcon(path, 0, &scontext) < 0) {
+ log_error("%s: matchpathcon failed: %s", path, strerror(errno));
+ return 0;
+ }
+
+ if ((lsetfilecon(path, scontext) < 0) && (errno != ENOTSUP)) {
+ log_error("%s: lsetfilecon failed: %s", path, strerror(errno));
+ free(scontext);
+ return 0;
+ }
+
+ free(scontext);
+ return 1;
+}
+#endif
+
+static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor)
+{
+ char path[PATH_MAX];
+ struct stat info;
+ dev_t dev = MKDEV(major, minor);
+
+ _build_dev_path(path, sizeof(path), dev_name);
+
+ if (stat(path, &info) >= 0) {
+ if (!S_ISBLK(info.st_mode)) {
+ log_error("A non-block device file at '%s' "
+ "is already present", path);
+ return 0;
+ }
+
+ if (info.st_rdev == dev)
+ return 1;
+
+ if (unlink(path) < 0) {
+ log_error("Unable to unlink device node for '%s'",
+ dev_name);
+ return 0;
+ }
+ }
+
+ if (mknod(path, S_IFBLK | S_IRUSR | S_IWUSR | S_IRGRP, dev) < 0) {
+ log_error("Unable to make device node for '%s'", dev_name);
+ return 0;
+ }
+#ifdef HAVE_SELINUX
+ if (!_set_selinux_context(path))
+ return 0;
+#endif
+
+ return 1;
+}
+
+static int _rename_dev_node(const char *old_name, const char *new_name)
+{
+ char oldpath[PATH_MAX];
+ char newpath[PATH_MAX];
+ struct stat info;
+
+ _build_dev_path(oldpath, sizeof(oldpath), old_name);
+ _build_dev_path(newpath, sizeof(newpath), new_name);
+
+ if (stat(newpath, &info) == 0) {
+ if (!S_ISBLK(info.st_mode)) {
+ log_error("A non-block device file at '%s' "
+ "is already present", newpath);
+ return 0;
+ }
+
+ if (unlink(newpath) < 0) {
+ if (errno == EPERM) {
+ /* devfs, entry has already been renamed */
+ return 1;
+ }
+ log_error("Unable to unlink device node for '%s'",
+ new_name);
+ return 0;
+ }
+ }
+
+ if (rename(oldpath, newpath) < 0) {
+ log_error("Unable to rename device node from '%s' to '%s'",
+ old_name, new_name);
+ return 0;
+ }
+
+ return 1;
+}
+
+static int _rm_dev_node(const char *dev_name)
+{
+ char path[PATH_MAX];
+ struct stat info;
+
+ _build_dev_path(path, sizeof(path), dev_name);
+
+ if (stat(path, &info) < 0)
+ return 1;
+
+ if (unlink(path) < 0) {
+ log_error("Unable to unlink device node for '%s'", dev_name);
+ return 0;
+ }
+
+ return 1;
+}
+
+typedef enum {
+ NODE_ADD,
+ NODE_DEL,
+ NODE_RENAME
+} node_op_t;
+
+static int _do_node_op(node_op_t type, const char *dev_name, uint32_t major,
+ uint32_t minor, const char *old_name)
+{
+ switch (type) {
+ case NODE_ADD:
+ return _add_dev_node(dev_name, major, minor);
+ case NODE_DEL:
+ return _rm_dev_node(dev_name);
+ case NODE_RENAME:
+ return _rename_dev_node(old_name, dev_name);
+ }
+
+ return 1;
+}
+
+static LIST_INIT(_node_ops);
+
+struct node_op_parms {
+ struct list list;
+ node_op_t type;
+ char *dev_name;
+ uint32_t major;
+ uint32_t minor;
+ char *old_name;
+ char names[0];
+};
+
+static void _store_str(char **pos, char **ptr, const char *str)
+{
+ strcpy(*pos, str);
+ *ptr = *pos;
+ *pos += strlen(*ptr) + 1;
+}
+
+static int _stack_node_op(node_op_t type, const char *dev_name, uint32_t major,
+ uint32_t minor, const char *old_name)
+{
+ struct node_op_parms *nop;
+ size_t len = strlen(dev_name) + strlen(old_name) + 2;
+ char *pos;
+
+ if (!(nop = malloc(sizeof(*nop) + len))) {
+ log_error("Insufficient memory to stack mknod operation");
+ return 0;
+ }
+
+ pos = nop->names;
+ nop->type = type;
+ nop->major = major;
+ nop->minor = minor;
+
+ _store_str(&pos, &nop->dev_name, dev_name);
+ _store_str(&pos, &nop->old_name, old_name);
+
+ list_add(&_node_ops, &nop->list);
+
+ return 1;
+}
+
+static void _pop_node_ops(void)
+{
+ struct list *noph, *nopht;
+ struct node_op_parms *nop;
+
+ list_iterate_safe(noph, nopht, &_node_ops) {
+ nop = list_item(noph, struct node_op_parms);
+ _do_node_op(nop->type, nop->dev_name, nop->major, nop->minor,
+ nop->old_name);
+ list_del(&nop->list);
+ free(nop);
+ }
+}
+
+int add_dev_node(const char *dev_name, uint32_t major, uint32_t minor)
+{
+ return _stack_node_op(NODE_ADD, dev_name, major, minor, "");
+}
+
+int rename_dev_node(const char *old_name, const char *new_name)
+{
+ return _stack_node_op(NODE_RENAME, new_name, 0, 0, old_name);
+}
+
+int rm_dev_node(const char *dev_name)
+{
+ return _stack_node_op(NODE_DEL, dev_name, 0, 0, "");
+}
+
+void update_devs(void)
+{
+ _pop_node_ops();
+}
+
+int dm_set_dev_dir(const char *dir)
+{
+ snprintf(_dm_dir, sizeof(_dm_dir), "%s%s", dir, DM_DIR);
+ return 1;
+}
+
+const char *dm_dir(void)
+{
+ return _dm_dir;
+}
Added: multipath-tools/upstream/current/libdevmapper/libdm-common.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libdevmapper/libdm-common.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
+ * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of the device-mapper userspace tools.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef LIB_DMCOMMON_H
+#define LIB_DMCOMMON_H
+
+#include "libdevmapper.h"
+
+struct target *create_target(uint64_t start,
+ uint64_t len,
+ const char *type, const char *params);
+
+int add_dev_node(const char *dev_name, uint32_t minor, uint32_t major);
+int rm_dev_node(const char *dev_name);
+int rename_dev_node(const char *old_name, const char *new_name);
+void update_devs(void);
+
+#define DM_LIB_VERSION "1.00.19-ioctl (2004-07-03)"
+
+#endif
Added: multipath-tools/upstream/current/libmultipath/Makefile
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/Makefile Fri Mar 4 08:05:19 2005
@@ -0,0 +1,39 @@
+# Makefile
+#
+# Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui at free.fr>
+#
+BUILD = glibc
+
+include ../Makefile.inc
+
+OBJS = memory.o parser.o vector.o devmapper.o callout.o \
+ sysfs_devinfo.o hwtable.o blacklist.o util.o
+
+ifeq ($(strip $(BUILD)),klibc)
+ CFLAGS = ${REQFLAGS} ${OPTFLAGS} -I$(libdmdir)
+else
+ CFLAGS = -pipe -g -Wall -Wunused -Wstrict-prototypes
+endif
+
+all: $(BUILD)
+
+prepare:
+ rm -f core *.o *.gz
+
+klibc: prepare $(KLIBC) $(OBJS)
+ ar rs libmultipath-klibc.a *.o
+
+glibc: prepare $(OBJS)
+ ar rs libmultipath-glibc.a *.o
+
+$(KLIBC):
+ rm -f $(klibcdir)/linux
+ ln -s $(KERNEL_BUILD) $(klibcdir)/linux
+ make -C $(klibcdir)
+
+install:
+
+uninstall:
+
+clean:
+ rm -f core *.a *.o *.gz
Added: multipath-tools/upstream/current/libmultipath/blacklist.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/blacklist.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,46 @@
+#include <string.h>
+#include <stdio.h>
+
+#include "memory.h"
+#include "vector.h"
+#include "util.h"
+#include "blacklist.h"
+
+void
+setup_default_blist (vector blist)
+{
+ char * str;
+
+ VECTOR_ADDSTR(blist, "c0d");
+ VECTOR_ADDSTR(blist, "c1d");
+ VECTOR_ADDSTR(blist, "c2d");
+ VECTOR_ADDSTR(blist, "fd");
+ VECTOR_ADDSTR(blist, "hd");
+ VECTOR_ADDSTR(blist, "md");
+ VECTOR_ADDSTR(blist, "dm");
+ VECTOR_ADDSTR(blist, "sr");
+ VECTOR_ADDSTR(blist, "scd");
+ VECTOR_ADDSTR(blist, "st");
+ VECTOR_ADDSTR(blist, "ram");
+ VECTOR_ADDSTR(blist, "raw");
+ VECTOR_ADDSTR(blist, "loop");
+ VECTOR_ADDSTR(blist, "nbd");
+ VECTOR_ADDSTR(blist, "ub");
+}
+
+int
+blacklist (vector blist, char * dev)
+{
+ int i;
+ char *p;
+ char buff[BLIST_ENTRY_SIZE];
+
+ basename(dev, buff);
+
+ vector_foreach_slot (blist, p, i) {
+ if (memcmp(buff, p, strlen(p)) == 0)
+ return 1;
+ }
+ return 0;
+}
+
Added: multipath-tools/upstream/current/libmultipath/blacklist.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/blacklist.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+#ifndef _BLACKLIST_H
+#define _BLACKLIST_H
+
+#define BLIST_ENTRY_SIZE 255
+
+#define VECTOR_ADDSTR(a, b) \
+ str = zalloc(6 * sizeof(char)); \
+ snprintf(str, 6, b); \
+ vector_alloc_slot(a); \
+ vector_set_slot(a, str);
+
+void setup_default_blist (vector blist);
+int blacklist (vector blist, char * dev);
+
+#endif /* _BLACKLIST_H */
Added: multipath-tools/upstream/current/libmultipath/callout.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/callout.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,102 @@
+#include <stdio.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <errno.h>
+
+#define PROGRAM_SIZE 100
+#define FIELD_PROGRAM
+
+#define strfieldcpy(to, from) \
+do { \
+ to[sizeof(to)-1] = '\0'; \
+ strncpy(to, from, sizeof(to)-1); \
+} while (0)
+
+int execute_program(char *path, char *value, int len)
+{
+ int retval;
+ int count;
+ int status;
+ int fds[2];
+ pid_t pid;
+ char *pos;
+ char arg[PROGRAM_SIZE];
+ char *argv[sizeof(arg) / 2];
+ int i;
+
+ i = 0;
+ if (strchr(path, ' ')) {
+ strfieldcpy(arg, path);
+ pos = arg;
+ while (pos != NULL) {
+ if (pos[0] == '\'') {
+ /* don't separate if in apostrophes */
+ pos++;
+ argv[i] = strsep(&pos, "\'");
+ while (pos[0] == ' ')
+ pos++;
+ } else {
+ argv[i] = strsep(&pos, " ");
+ }
+ i++;
+ }
+ }
+ argv[i] = NULL;
+
+ retval = pipe(fds);
+
+ if (retval != 0)
+ return -1;
+
+
+ pid = fork();
+
+ switch(pid) {
+ case 0:
+ /* child */
+ close(STDOUT_FILENO);
+
+ /* dup write side of pipe to STDOUT */
+ dup(fds[1]);
+
+ retval = execv(argv[0], argv);
+
+ exit(-1);
+ case -1:
+ return -1;
+ default:
+ /* parent reads from fds[0] */
+ close(fds[1]);
+ retval = 0;
+ i = 0;
+ while (1) {
+ count = read(fds[0], value + i, len - i-1);
+ if (count <= 0)
+ break;
+
+ i += count;
+ if (i >= len-1) {
+ retval = -1;
+ break;
+ }
+ }
+
+ if (count < 0)
+ retval = -1;
+
+ if (i > 0 && value[i-1] == '\n')
+ i--;
+ value[i] = '\0';
+
+ close(fds[0]);
+ wait(&status);
+
+ if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0))
+ retval = -1;
+ }
+ return retval;
+}
Added: multipath-tools/upstream/current/libmultipath/callout.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/callout.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1 @@
+int execute_program(char *, char *, int);
Added: multipath-tools/upstream/current/libmultipath/defaults.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/defaults.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+#define DEFAULT_GETUID "/sbin/scsi_id -g -u -s /block/%n"
+#define DEFAULT_UDEVDIR "/udev"
+#define DEFAULT_SELECTOR "round-robin 0"
+#define DEFAULT_FEATURES "0"
+#define DEFAULT_HWHANDLER "0"
+
+#define DEFAULT_TARGET "multipath"
+#define DEFAULT_PIDFILE "/var/run/multipathd.pid"
+#define DEFAULT_RUNFILE "/var/run/multipath.run"
+#define DEFAULT_CONFIGFILE "/etc/multipath.conf"
+
Added: multipath-tools/upstream/current/libmultipath/devmapper.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/devmapper.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,268 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <libdevmapper.h>
+
+extern int
+dm_prereq (char * str, int x, int y, int z)
+{
+ int r = 1;
+ struct dm_task *dmt;
+ struct dm_versions *target;
+ struct dm_versions *last_target;
+
+ if (!(dmt = dm_task_create(DM_DEVICE_LIST_VERSIONS)))
+ return 1;
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ target = dm_task_get_versions(dmt);
+
+ /* Fetch targets and print 'em */
+ do {
+ last_target = target;
+
+ if (!strncmp(str, target->name, strlen(str)) &&
+ /* dummy prereq on multipath version */
+ target->version[0] >= x &&
+ target->version[1] >= y &&
+ target->version[2] >= z
+ )
+ r = 0;
+
+ target = (void *) target + target->next;
+ } while (last_target != target);
+
+ out:
+ dm_task_destroy(dmt);
+ return r;
+}
+
+extern int
+dm_simplecmd (int task, const char *name) {
+ int r = 0;
+ struct dm_task *dmt;
+
+ if (!(dmt = dm_task_create (task)))
+ return 0;
+
+ if (!dm_task_set_name (dmt, name))
+ goto out;
+
+ r = dm_task_run (dmt);
+
+ out:
+ dm_task_destroy (dmt);
+ return r;
+}
+
+extern int
+dm_addmap (int task, const char *name, const char *target,
+ const char *params, unsigned long size) {
+ int r = 0;
+ struct dm_task *dmt;
+
+ if (!(dmt = dm_task_create (task)))
+ return 0;
+
+ if (!dm_task_set_name (dmt, name))
+ goto addout;
+
+ if (!dm_task_add_target (dmt, 0, size, target, params))
+ goto addout;
+
+ r = dm_task_run (dmt);
+
+ addout:
+ dm_task_destroy (dmt);
+ return r;
+}
+
+extern int
+dm_map_present (char * str)
+{
+ int r = 0;
+ struct dm_task *dmt;
+ struct dm_names *names;
+ unsigned next = 0;
+
+ if (!(dmt = dm_task_create (DM_DEVICE_LIST)))
+ return 0;
+
+ if (!dm_task_run (dmt))
+ goto out;
+
+ if (!(names = dm_task_get_names (dmt)))
+ goto out;
+
+ if (!names->dev)
+ goto out;
+
+ do {
+ if (0 == strcmp (names->name, str))
+ r = 1;
+
+ next = names->next;
+ names = (void *) names + next;
+ } while (next);
+
+ out:
+ dm_task_destroy (dmt);
+ return r;
+}
+
+extern int
+dm_get_map(char * name, unsigned long * size, char ** outparams)
+{
+ int r = 0;
+ struct dm_task *dmt;
+ void *next = NULL;
+ uint64_t start, length;
+ char *target_type = NULL;
+ char *params;
+ int cmd;
+
+ cmd = DM_DEVICE_TABLE;
+
+ if (!(dmt = dm_task_create(cmd)))
+ return 0;
+
+ if (!dm_task_set_name(dmt, name))
+ goto out;
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ /* Fetch 1st target */
+ next = dm_get_next_target(dmt, next, &start, &length,
+ &target_type, ¶ms);
+
+ if (size)
+ *size = length;
+
+ *outparams = malloc(strlen(params) + 1);
+
+ if (!*outparams)
+ goto out;
+
+ if (sprintf(*outparams, params))
+ goto out;
+
+ r = 1;
+
+ out:
+ dm_task_destroy(dmt);
+ return r;
+}
+
+extern int
+dm_get_status(char * name, char ** outstatus)
+{
+ int r = 0;
+ struct dm_task *dmt;
+ void *next = NULL;
+ uint64_t start, length;
+ char *target_type = NULL;
+ char *status;
+ int cmd;
+
+ cmd = DM_DEVICE_STATUS;
+
+ if (!(dmt = dm_task_create(cmd)))
+ return 0;
+
+ if (!dm_task_set_name(dmt, name))
+ goto out;
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ /* Fetch 1st target */
+ next = dm_get_next_target(dmt, next, &start, &length,
+ &target_type, &status);
+
+ *outstatus = malloc(strlen(status) + 1);
+
+ if (!*outstatus)
+ goto out;
+
+ if (sprintf(*outstatus, status))
+ goto out;
+
+ r = 1;
+
+ out:
+ dm_task_destroy(dmt);
+ return r;
+}
+
+extern int
+dm_type(char * name, char * type)
+{
+ int r = 0;
+ struct dm_task *dmt;
+ void *next = NULL;
+ uint64_t start, length;
+ char *target_type = NULL;
+ char *params;
+ int cmd;
+
+ cmd = DM_DEVICE_TABLE;
+
+ if (!(dmt = dm_task_create(cmd)))
+ return 0;
+
+ if (!dm_task_set_name(dmt, name))
+ goto out;
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ /* Fetch 1st target */
+ next = dm_get_next_target(dmt, next, &start, &length,
+ &target_type, ¶ms);
+
+ if (0 == strcmp(target_type, type)) {
+ r = 1;
+ goto out;
+ }
+
+ out:
+ dm_task_destroy(dmt);
+ return r;
+}
+
+extern int
+dm_flush_maps (char * type)
+{
+ int r = 0;
+ struct dm_task *dmt;
+ struct dm_names *names;
+ unsigned next = 0;
+
+ if (!(dmt = dm_task_create (DM_DEVICE_LIST)))
+ return 0;
+
+ if (!dm_task_run (dmt))
+ goto out;
+
+ if (!(names = dm_task_get_names (dmt)))
+ goto out;
+
+ if (!names->dev)
+ goto out;
+
+ do {
+ if (dm_type(names->name, type) &&
+ !dm_simplecmd(DM_DEVICE_REMOVE, names->name))
+ r++;
+
+ next = names->next;
+ names = (void *) names + next;
+ } while (next);
+
+ out:
+ dm_task_destroy (dmt);
+ return r;
+}
Added: multipath-tools/upstream/current/libmultipath/devmapper.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/devmapper.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,8 @@
+int dm_prereq (char *, int, int, int);
+int dm_simplecmd (int, const char *);
+int dm_addmap (int, const char *, const char *, const char *, unsigned long);
+int dm_map_present (char *);
+int dm_get_map(char *, unsigned long *, char **);
+int dm_get_status(char *, char **);
+int dm_type(char *, char *);
+int dm_flush_maps (char *);
Added: multipath-tools/upstream/current/libmultipath/hwtable.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/hwtable.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,59 @@
+#include <stdio.h>
+
+#include "memory.h"
+#include "vector.h"
+#include "structs.h"
+#include "defaults.h"
+#include "hwtable.h"
+
+#include "../libcheckers/checkers.h"
+#include "../multipath/pgpolicies.h"
+
+extern struct hwentry *
+find_hw (vector hwtable, char * vendor, char * product)
+{
+ int i;
+ struct hwentry * hwe;
+
+ vector_foreach_slot (hwtable, hwe, i)
+ if (hwe->vendor && hwe->product &&
+ strcmp(hwe->vendor, vendor) == 0 &&
+ (hwe->product[0] == '*' ||
+ strcmp(hwe->product, product) == 0))
+ return hwe;
+ return NULL;
+}
+
+void
+setup_default_hwtable (vector hw)
+{
+ struct hwentry * hwe;
+ ADDHWE(hw, "COMPAQ", "HSV110 (C)COMPAQ", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "COMPAQ", "MSA1000", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "COMPAQ", "MSA1000 VOLUME", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "DEC", "HSG80", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "HP", "HSV110", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "HP", "A6189A", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "HP", "OPEN-", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "DDN", "SAN DataDirector", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "EMC", "SYMMETRIX", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "FSC", "CentricStor", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "HITACHI", "DF400", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "HITACHI", "DF500", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "HITACHI", "DF600", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "IBM", "ProFibre 4000R", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "SGI", "TP9100", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "SGI", "TP9300", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "SGI", "TP9400", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "SGI", "TP9500", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "3PARdata", "VV", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "STK", "OPENstorage D280", GROUP_BY_SERIAL, DEFAULT_GETUID);
+ ADDHWE(hw, "SUN", "StorEdge 3510", MULTIBUS, DEFAULT_GETUID);
+ ADDHWE(hw, "SUN", "T4", MULTIBUS, DEFAULT_GETUID);
+
+ ADDHWE_EXT(hw, "DGC", "*", GROUP_BY_PRIO, DEFAULT_GETUID,
+ DEFAULT_GETUID " -p 0xc0", "1 emc", "0", "emc_clariion");
+ ADDHWE_EXT(hw, "IBM", "3542", GROUP_BY_SERIAL, DEFAULT_GETUID,
+ NULL, "0", "0", "tur");
+}
+
Added: multipath-tools/upstream/current/libmultipath/hwtable.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/hwtable.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,47 @@
+#ifndef _HWTABLE_H
+#define _HWTABLE_H
+
+#define ADDHWE(a, b, c, d, e) \
+ hwe = zalloc (sizeof(struct hwentry)); \
+ hwe->vendor = zalloc (SCSI_VENDOR_SIZE * sizeof(char)); \
+ snprintf (hwe->vendor, SCSI_VENDOR_SIZE, "%-8s", b); \
+ hwe->product = zalloc (SCSI_PRODUCT_SIZE * sizeof(char)); \
+ snprintf (hwe->product, SCSI_PRODUCT_SIZE, "%-17s", c); \
+ hwe->pgpolicy = d; \
+ hwe->getuid = e; \
+ vector_alloc_slot(a); \
+ vector_set_slot(a, hwe);
+
+#define ADDHWE_EXT(a, b, c, d, e, f, g, i, j) \
+ hwe = zalloc (sizeof(struct hwentry)); \
+ hwe->vendor = zalloc (SCSI_VENDOR_SIZE * sizeof(char)); \
+ snprintf (hwe->vendor, SCSI_VENDOR_SIZE, "%-8s", b); \
+ hwe->product = zalloc (SCSI_PRODUCT_SIZE * sizeof(char)); \
+ snprintf (hwe->product, SCSI_PRODUCT_SIZE, "%-17s", c); \
+ hwe->pgpolicy = d; \
+ hwe->getuid = e; \
+ hwe->getprio = f; \
+ hwe->hwhandler = g; \
+ hwe->features = i; \
+ hwe->checker_index = get_checker_id(j); \
+ vector_alloc_slot(a); \
+ vector_set_slot(a, hwe);
+
+struct hwentry {
+ int selector_args;
+ int pgpolicy;
+ int checker_index;
+
+ char * vendor;
+ char * product;
+ char * selector;
+ char * getuid;
+ char * getprio;
+ char * features;
+ char * hwhandler;
+};
+
+void setup_default_hwtable (vector hw);
+struct hwentry * find_hw (vector hwtable, char * vendor, char * product);
+
+#endif /* _HWTABLE_H */
Added: multipath-tools/upstream/current/libmultipath/memory.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/memory.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+#include "memory.h"
+
+void *
+zalloc(unsigned long size)
+{
+ void *mem;
+
+ if ((mem = malloc(size)))
+ memset(mem, 0, size);
+
+ return mem;
+}
Added: multipath-tools/upstream/current/libmultipath/memory.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/memory.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,12 @@
+#ifndef _MEMORY_H
+#define _MEMORY_H
+
+#include <stdlib.h>
+#include <string.h>
+
+#define MALLOC(a) zalloc(a)
+#define FREE(a) free(a)
+
+extern void * zalloc (unsigned long size);
+
+#endif /* _MEMORY_H */
Added: multipath-tools/upstream/current/libmultipath/parser.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/parser.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,349 @@
+/*
+ * Part: Configuration file parser/reader. Place into the dynamic
+ * data structure representation the conf file
+ *
+ * Version: $Id: parser.c,v 1.0.3 2003/05/11 02:28:03 acassen Exp $
+ *
+ * Author: Alexandre Cassen, <acassen at linux-vs.org>
+ *
+ * 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.
+ *
+ * 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 of the License, or (at your option) any later version.
+ */
+
+#include <syslog.h>
+
+#include "parser.h"
+#include "memory.h"
+
+/* local vars */
+static int sublevel = 0;
+
+void
+keyword_alloc(vector keywords, char *string, void (*handler) (vector))
+{
+ struct keyword *keyword;
+
+ vector_alloc_slot(keywords);
+
+ keyword = (struct keyword *) zalloc(sizeof (struct keyword));
+ keyword->string = string;
+ keyword->handler = handler;
+
+ vector_set_slot(keywords, keyword);
+}
+
+void
+install_keyword_root(char *string, void (*handler) (vector))
+{
+ keyword_alloc(keywords, string, handler);
+}
+
+void
+install_sublevel(void)
+{
+ sublevel++;
+}
+
+void
+install_sublevel_end(void)
+{
+ sublevel--;
+}
+
+void
+install_keyword(char *string, void (*handler) (vector))
+{
+ int i = 0;
+ struct keyword *keyword;
+
+ /* fetch last keyword */
+ keyword = VECTOR_SLOT(keywords, VECTOR_SIZE(keywords) - 1);
+
+ /* position to last sub level */
+ for (i = 0; i < sublevel; i++)
+ keyword =
+ VECTOR_SLOT(keyword->sub, VECTOR_SIZE(keyword->sub) - 1);
+
+ /* First sub level allocation */
+ if (!keyword->sub)
+ keyword->sub = vector_alloc();
+
+ /* add new sub keyword */
+ keyword_alloc(keyword->sub, string, handler);
+}
+
+void
+free_keywords(vector keywords)
+{
+ struct keyword *keyword;
+ int i;
+
+ for (i = 0; i < VECTOR_SIZE(keywords); i++) {
+ keyword = VECTOR_SLOT(keywords, i);
+ if (keyword->sub)
+ free_keywords(keyword->sub);
+ free(keyword);
+ }
+ vector_free(keywords);
+}
+
+vector
+alloc_strvec(char *string)
+{
+ char *cp, *start, *token;
+ int strlen;
+ int in_string;
+ vector strvec;
+
+ if (!string)
+ return NULL;
+
+ cp = string;
+
+ /* Skip white spaces */
+ while (isspace((int) *cp) && *cp != '\0')
+ cp++;
+
+ /* Return if there is only white spaces */
+ if (*cp == '\0')
+ return NULL;
+
+ /* Return if string begin with a comment */
+ if (*cp == '!' || *cp == '#')
+ return NULL;
+
+ /* Create a vector and alloc each command piece */
+ strvec = vector_alloc();
+
+ in_string = 0;
+ while (1) {
+ start = cp;
+ if (*cp == '"') {
+ cp++;
+ token = zalloc(2);
+ *(token) = '"';
+ *(token + 1) = '\0';
+ if (in_string)
+ in_string = 0;
+ else
+ in_string = 1;
+
+ } else {
+ while ((in_string || !isspace((int) *cp)) && *cp
+ != '\0' && *cp != '"')
+ cp++;
+ strlen = cp - start;
+ token = zalloc(strlen + 1);
+ memcpy(token, start, strlen);
+ *(token + strlen) = '\0';
+ }
+
+ /* Alloc & set the slot */
+ vector_alloc_slot(strvec);
+ vector_set_slot(strvec, token);
+
+ while (isspace((int) *cp) && *cp != '\0')
+ cp++;
+ if (*cp == '\0' || *cp == '!' || *cp == '#')
+ return strvec;
+ }
+}
+
+int
+read_line(char *buf, int size)
+{
+ int ch;
+ int count = 0;
+
+ while ((ch = fgetc(stream)) != EOF && (int) ch != '\n'
+ && (int) ch != '\r') {
+ if (count < size)
+ buf[count] = (int) ch;
+ else
+ break;
+ count++;
+ }
+ return (ch == EOF) ? 0 : 1;
+}
+
+vector
+read_value_block(void)
+{
+ char *buf;
+ int i;
+ char *str = NULL;
+ char *dup;
+ vector vec = NULL;
+ vector elements = vector_alloc();
+
+ buf = (char *) zalloc(MAXBUF);
+ while (read_line(buf, MAXBUF)) {
+ vec = alloc_strvec(buf);
+ if (vec) {
+ str = VECTOR_SLOT(vec, 0);
+ if (!strcmp(str, EOB)) {
+ free_strvec(vec);
+ break;
+ }
+
+ if (VECTOR_SIZE(vec))
+ for (i = 0; i < VECTOR_SIZE(vec); i++) {
+ str = VECTOR_SLOT(vec, i);
+ dup = (char *) zalloc(strlen(str) + 1);
+ memcpy(dup, str, strlen(str));
+ vector_alloc_slot(elements);
+ vector_set_slot(elements, dup);
+ }
+ free_strvec(vec);
+ }
+ memset(buf, 0, MAXBUF);
+ }
+
+ free(buf);
+ return elements;
+}
+
+void
+alloc_value_block(vector strvec, void (*alloc_func) (vector))
+{
+ char *buf;
+ char *str = NULL;
+ vector vec = NULL;
+
+ buf = (char *) zalloc(MAXBUF);
+ while (read_line(buf, MAXBUF)) {
+ vec = alloc_strvec(buf);
+ if (vec) {
+ str = VECTOR_SLOT(vec, 0);
+ if (!strcmp(str, EOB)) {
+ free_strvec(vec);
+ break;
+ }
+
+ if (VECTOR_SIZE(vec))
+ (*alloc_func) (vec);
+
+ free_strvec(vec);
+ }
+ memset(buf, 0, MAXBUF);
+ }
+ free(buf);
+}
+
+void *
+set_value(vector strvec)
+{
+ char *str = VECTOR_SLOT(strvec, 1);
+ int size = strlen(str);
+ int i = 0;
+ int len = 0;
+ char *alloc = NULL;
+ char *tmp;
+
+ if (*str == '"') {
+ for (i = 2; i < VECTOR_SIZE(strvec); i++) {
+ str = VECTOR_SLOT(strvec, i);
+ len += strlen(str);
+ if (!alloc)
+ alloc =
+ (char *) zalloc(sizeof (char *) *
+ (len + 1));
+ else {
+ alloc =
+ realloc(alloc, sizeof (char *) * (len + 1));
+ tmp = VECTOR_SLOT(strvec, i-1);
+ if (*str != '"' && *tmp != '"')
+ strncat(alloc, " ", 1);
+ }
+
+ if (i != VECTOR_SIZE(strvec)-1)
+ strncat(alloc, str, strlen(str));
+ }
+ } else {
+ alloc = zalloc(sizeof (char *) * (size + 1));
+ memcpy(alloc, str, size);
+ }
+ return alloc;
+}
+
+/* non-recursive configuration stream handler */
+static int kw_level = 0;
+void
+process_stream(vector keywords)
+{
+ int i;
+ struct keyword *keyword;
+ char *str;
+ char *buf;
+ vector strvec;
+
+ buf = zalloc(MAXBUF);
+ while (read_line(buf, MAXBUF)) {
+ strvec = alloc_strvec(buf);
+ memset(buf,0, MAXBUF);
+
+ if (!strvec) {
+ continue;
+ }
+
+ str = VECTOR_SLOT(strvec, 0);
+
+ if (!strcmp(str, EOB) && kw_level > 0) {
+ free_strvec(strvec);
+ break;
+ }
+
+ for (i = 0; i < VECTOR_SIZE(keywords); i++) {
+ keyword = VECTOR_SLOT(keywords, i);
+
+ if (!strcmp(keyword->string, str)) {
+ if (keyword->handler)
+ (*keyword->handler) (strvec);
+
+ if (keyword->sub) {
+ kw_level++;
+ process_stream(keyword->sub);
+ kw_level--;
+ }
+ break;
+ }
+ }
+
+ free_strvec(strvec);
+ }
+
+ free(buf);
+ return;
+
+}
+
+/* Data initialization */
+void
+init_data(char *conf_file, vector (*init_keywords) (void))
+{
+ stream = fopen(conf_file, "r");
+ if (!stream) {
+ syslog(LOG_WARNING, "Configuration file open problem");
+ return;
+ }
+
+ /* Init Keywords structure */
+ (*init_keywords) ();
+
+/* Dump configuration *
+ vector_dump(keywords);
+ dump_keywords(keywords, 0);
+*/
+
+ /* Stream handling */
+ process_stream(keywords);
+ fclose(stream);
+ free_keywords(keywords);
+}
Added: multipath-tools/upstream/current/libmultipath/parser.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/parser.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,73 @@
+/*
+ * Soft: Keepalived is a failover program for the LVS project
+ * <www.linuxvirtualserver.org>. It monitor & manipulate
+ * a loadbalanced server pool using multi-layer checks.
+ *
+ * Part: cfreader.c include file.
+ *
+ * Version: $Id: parser.h,v 1.0.3 2003/05/11 02:28:03 acassen Exp $
+ *
+ * Author: Alexandre Cassen, <acassen at linux-vs.org>
+ *
+ * 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.
+ *
+ * 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 of the License, or (at your option) any later version.
+ */
+
+#ifndef _PARSER_H
+#define _PARSER_H
+
+/* system includes */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <syslog.h>
+#include <ctype.h>
+
+/* local includes */
+#include "vector.h"
+
+/* Global definitions */
+#define EOB "}"
+#define MAXBUF 1024
+
+/* ketword definition */
+struct keyword {
+ char *string;
+ void (*handler) (vector);
+ vector sub;
+};
+
+/* Reloading helpers */
+#define SET_RELOAD (reload = 1)
+#define UNSET_RELOAD (reload = 0)
+#define RELOAD_DELAY 5
+
+/* global var exported */
+vector keywords;
+FILE *stream;
+
+/* Prototypes */
+extern void keyword_alloc(vector keywords, char *string, void (*handler) (vector));
+extern void install_keyword_root(char *string, void (*handler) (vector));
+extern void install_sublevel(void);
+extern void install_sublevel_end(void);
+extern void install_keyword(char *string, void (*handler) (vector));
+extern void dump_keywords(vector keydump, int level);
+extern void free_keywords(vector keywords);
+extern vector alloc_strvec(char *string);
+extern int read_line(char *buf, int size);
+extern vector read_value_block(void);
+extern void alloc_value_block(vector strvec, void (*alloc_func) (vector));
+extern void *set_value(vector strvec);
+extern void process_stream(vector keywords);
+extern void init_data(char *conf_file, vector (*init_keywords) (void));
+
+#endif
Added: multipath-tools/upstream/current/libmultipath/safe_printf.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/safe_printf.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,9 @@
+#ifndef _SAFE_PRINTF_H
+#define _SAFE_PRINTF_H
+
+#define safe_sprintf(var, format, args...) \
+ snprintf(var, sizeof(var), format, ##args) >= sizeof(var)
+#define safe_snprintf(var, size, format, args...) \
+ snprintf(var, size, format, ##args) >= size
+
+#endif /* _SAFE_PRINTF_H */
Added: multipath-tools/upstream/current/libmultipath/structs.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/structs.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,105 @@
+#ifndef _STRUCTS_H
+#define _STRUCTS_H
+
+#define WWID_SIZE 64
+#define SERIAL_SIZE 17
+#define NODE_NAME_SIZE 19
+#define PATH_STR_SIZE 16
+#define PARAMS_SIZE 256
+#define FILE_NAME_SIZE 256
+#define CALLOUT_MAX_SIZE 128
+#define BLK_DEV_SIZE 33
+
+#define SCSI_VENDOR_SIZE 9
+#define SCSI_PRODUCT_SIZE 17
+#define SCSI_REV_SIZE 5
+
+enum pathstates {
+ PSTATE_RESERVED,
+ PSTATE_FAILED,
+ PSTATE_ACTIVE
+};
+
+enum pgstates {
+ PGSTATE_RESERVED,
+ PGSTATE_ENABLED,
+ PGSTATE_DISABLED,
+ PGSTATE_ACTIVE
+};
+
+struct scsi_idlun {
+ int dev_id;
+ int host_unique_id;
+ int host_no;
+};
+
+struct sg_id {
+ int host_no;
+ int channel;
+ int scsi_id;
+ int lun;
+ short h_cmd_per_lun;
+ short d_queue_depth;
+ int unused1;
+ int unused2;
+};
+
+struct scsi_dev {
+ char dev[FILE_NAME_SIZE];
+ struct scsi_idlun scsi_id;
+ int host_no;
+};
+
+struct path {
+ char dev[FILE_NAME_SIZE];
+ char dev_t[BLK_DEV_SIZE];
+ struct scsi_idlun scsi_id;
+ struct sg_id sg_id;
+ char wwid[WWID_SIZE];
+ char vendor_id[SCSI_VENDOR_SIZE];
+ char product_id[SCSI_PRODUCT_SIZE];
+ char rev[SCSI_REV_SIZE];
+ char serial[SERIAL_SIZE];
+ char tgt_node_name[NODE_NAME_SIZE];
+ unsigned long size;
+ int state;
+ int dmstate;
+ int failcount;
+ unsigned int priority;
+ int claimed;
+ char * getuid;
+ char * getprio;
+ int (*checkfn) (char *, char *, void **);
+ void * checker_context;
+ struct multipath * mpp;
+};
+
+struct multipath {
+ char wwid[WWID_SIZE];
+ char * alias;
+ int pgpolicy;
+ int nextpg;
+ int queuedio;
+ int action;
+ unsigned long size;
+ vector paths;
+ vector pg;
+ char params[PARAMS_SIZE];
+ char status[PARAMS_SIZE];
+ char * selector;
+ char * features;
+ char * hwhandler;
+
+ /* configlet pointers */
+ struct mpentry * mpe;
+ struct hwentry * hwe;
+};
+
+struct pathgroup {
+ long id;
+ int status;
+ int priority;
+ vector paths;
+};
+
+#endif
Added: multipath-tools/upstream/current/libmultipath/sysfs_devinfo.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/sysfs_devinfo.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <sysfs/libsysfs.h>
+
+#include "safe_printf.h"
+#include "sysfs_devinfo.h"
+
+#define declare_sysfs_get_str(fname, fmt) \
+extern int \
+sysfs_get_##fname (char * sysfs_path, char * dev, char * buff, int len) \
+{ \
+ char attr_path[SYSFS_PATH_SIZE]; \
+ char attr_buff[SYSFS_PATH_SIZE]; \
+ int attr_len; \
+\
+ if(safe_sprintf(attr_path, fmt, sysfs_path, dev)) \
+ return 1; \
+ if (0 > sysfs_read_attribute_value(attr_path, attr_buff, sizeof(attr_buff))) \
+ return 1; \
+\
+ attr_len = strlen(attr_buff); \
+ if (attr_len < 2 || attr_len - 1 > len) \
+ return 1; \
+\
+ strncpy(buff, attr_buff, attr_len - 1); \
+ buff[attr_len - 1] = '\0'; \
+ return 0; \
+}
+
+declare_sysfs_get_str(vendor, "%s/block/%s/device/vendor");
+declare_sysfs_get_str(model, "%s/block/%s/device/model");
+declare_sysfs_get_str(rev, "%s/block/%s/device/rev");
+declare_sysfs_get_str(dev, "%s/block/%s/dev");
+
+#define declare_sysfs_get_val(fname, fmt) \
+extern unsigned long \
+sysfs_get_##fname (char * sysfs_path, char * dev) \
+{ \
+ char attr_path[SYSFS_PATH_SIZE]; \
+ char attr_buff[SYSFS_PATH_SIZE]; \
+\
+ if(safe_sprintf(attr_path, fmt, sysfs_path, dev)) \
+ return 0; \
+ if (0 > sysfs_read_attribute_value(attr_path, attr_buff, sizeof(attr_buff))) \
+ return 0; \
+\
+ return strtoul(attr_buff, NULL, 0); \
+}
+
+declare_sysfs_get_val(size, "%s/block/%s/size");
+
Added: multipath-tools/upstream/current/libmultipath/sysfs_devinfo.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/sysfs_devinfo.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,8 @@
+#define SYSFS_PATH_SIZE 255
+
+int sysfs_get_vendor (char * sysfs_path, char * dev, char * buff, int len);
+int sysfs_get_model (char * sysfs_path, char * dev, char * buff, int len);
+int sysfs_get_rev (char * sysfs_path, char * dev, char * buff, int len);
+int sysfs_get_dev (char * sysfs_path, char * dev, char * buff, int len);
+
+unsigned long sysfs_get_size (char * sysfs_path, char * dev);
Added: multipath-tools/upstream/current/libmultipath/util.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/util.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,16 @@
+#include <string.h>
+
+void
+basename (char * str1, char * str2)
+{
+ char *p = str1 + (strlen(str1) - 1);
+
+ while (*--p != '/' && p != str1)
+ continue;
+
+ if (p != str1)
+ p++;
+
+ strcpy(str2, p);
+}
+
Added: multipath-tools/upstream/current/libmultipath/util.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/util.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,2 @@
+void basename (char * src, char * dst);
+
Added: multipath-tools/upstream/current/libmultipath/vector.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/vector.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,112 @@
+/*
+ * Soft: Keepalived is a failover program for the LVS project
+ * <www.linuxvirtualserver.org>. It monitor & manipulate
+ * a loadbalanced server pool using multi-layer checks.
+ *
+ * Part: Vector structure manipulation.
+ *
+ * Version: $Id: vector.c,v 1.0.3 2003/05/11 02:28:03 acassen Exp $
+ *
+ * Author: Alexandre Cassen, <acassen at linux-vs.org>
+ *
+ * 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.
+ *
+ * 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 of the License, or (at your option) any later version.
+ */
+
+#include "memory.h"
+#include <stdlib.h>
+#include "vector.h"
+
+/*
+ * Initialize vector struct.
+ * allocated 'size' slot elements then return vector.
+ */
+vector
+vector_alloc(void)
+{
+ vector v = (vector) zalloc(sizeof (struct _vector));
+ return v;
+}
+
+/* allocated one slot */
+void
+vector_alloc_slot(vector v)
+{
+ v->allocated += VECTOR_DEFAULT_SIZE;
+ if (v->slot)
+ v->slot = realloc(v->slot, sizeof (void *) * v->allocated);
+ else
+ v->slot = (void *) zalloc(sizeof (void *) * v->allocated);
+}
+
+void
+vector_insert_slot(vector v, int slot, void *value)
+{
+ int i;
+
+ vector_alloc_slot(v);
+
+ for (i = (v->allocated /VECTOR_DEFAULT_SIZE) - 2; i >= slot; i--)
+ v->slot[i + 1] = v->slot[i];
+
+ v->slot[slot] = value;
+}
+
+void
+vector_del_slot(vector v, int slot)
+{
+ int i;
+
+ if (!v->allocated)
+ return;
+
+ for (i = slot + 1; i < (v->allocated / VECTOR_DEFAULT_SIZE); i++)
+ v->slot[i-1] = v->slot[i];
+
+ v->allocated -= VECTOR_DEFAULT_SIZE;
+
+ if (!v->allocated)
+ v->slot = NULL;
+ else
+ v = realloc(v->slot, sizeof (void *) * v->allocated);
+}
+
+/* Free memory vector allocation */
+void
+vector_free(vector v)
+{
+ free(v->slot);
+ free(v);
+}
+
+void
+free_strvec(vector strvec)
+{
+ int i;
+ char *str;
+
+ if (!strvec)
+ return;
+
+ for (i = 0; i < VECTOR_SIZE(strvec); i++)
+ if ((str = VECTOR_SLOT(strvec, i)) != NULL)
+ free(str);
+
+ vector_free(strvec);
+}
+
+/* Set a vector slot value */
+void
+vector_set_slot(vector v, void *value)
+{
+ unsigned int i = v->allocated - 1;
+
+ v->slot[i] = value;
+}
Added: multipath-tools/upstream/current/libmultipath/vector.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libmultipath/vector.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,52 @@
+/*
+ * Soft: Keepalived is a failover program for the LVS project
+ * <www.linuxvirtualserver.org>. It monitor & manipulate
+ * a loadbalanced server pool using multi-layer checks.
+ *
+ * Part: vector.c include file.
+ *
+ * Version: $Id: vector.h,v 1.0.3 2003/05/11 02:28:03 acassen Exp $
+ *
+ * Author: Alexandre Cassen, <acassen at linux-vs.org>
+ *
+ * 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.
+ *
+ * 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 of the License, or (at your option) any later version.
+ */
+
+#ifndef _VECTOR_H
+#define _VECTOR_H
+
+/* vector definition */
+struct _vector {
+ unsigned int allocated;
+ void **slot;
+};
+typedef struct _vector *vector;
+
+#define VECTOR_DEFAULT_SIZE 1
+#define VECTOR_SLOT(V,E) ((V)->slot[(E)])
+#define VECTOR_SIZE(V) ((V)->allocated)
+#define VECTOR_LAST_SLOT(V) ((V)->slot[((V)->allocated - 1)])
+
+#define vector_foreach_slot(v,p,i) \
+ for (i = 0; i < (v)->allocated && ((p) = (v)->slot[i]); i++)
+
+/* Prototypes */
+extern vector vector_alloc(void);
+extern void vector_alloc_slot(vector v);
+extern void vector_free(vector v);
+extern void free_strvec(vector strvec);
+extern void vector_set_slot(vector v, void *value);
+extern void vector_del_slot(vector v, int slot);
+extern void vector_insert_slot(vector v, int slot, void *value);
+extern void vector_dump(vector v);
+extern void dump_strvec(vector strvec);
+
+#endif
Added: multipath-tools/upstream/current/libsysfs/LGPL
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libsysfs/LGPL Fri Mar 4 08:05:19 2005
@@ -0,0 +1,441 @@
+
+ GNU Lesser Public License
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ [This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your freedom to
+ share and change it. By contrast, the GNU General Public Licenses are
+ intended to guarantee your freedom to share and change free software--to
+ make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some specially
+ designated software packages--typically libraries--of the Free Software
+ Foundation and other authors who decide to use it. You can use it too, but
+ we suggest you first think carefully about whether this license or the
+ ordinary General Public License is the better strategy to use in any
+ particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use, not
+ price. Our General Public Licenses are designed to make sure that you have
+ the freedom to distribute copies of free software (and charge for this
+ service if you wish); that you receive source code or can get it if you
+ want it; that you can change the software and use pieces of it in new free
+ programs; and that you are informed that you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+ distributors to deny you these rights or to ask you to surrender these
+ rights. These restrictions translate to certain responsibilities for you
+ if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis or
+ for a fee, you must give the recipients all the rights that we gave you.
+ You must make sure that they, too, receive or can get the source code. If
+ you link other code with the library, you must provide complete object
+ files to the recipients, so that they can relink them with the library
+ after making changes to the library and recompiling it. And you must show
+ them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+ library, and (2) we offer you this license, which gives you legal
+ permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that there is
+ no warranty for the free library. Also, if the library is modified by
+ someone else and passed on, the recipients should know that what they have
+ is not the original version, so that the original author's reputation will
+ not be affected by problems that might be introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of any
+ free program. We wish to make sure that a company cannot effectively
+ restrict the users of a free program by obtaining a restrictive license
+ from a patent holder. Therefore, we insist that any patent license
+ obtained for a version of the library must be consistent with the full
+ freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the ordinary
+ GNU General Public License. This license, the GNU Lesser General Public
+ License, applies to certain designated libraries, and is quite different
+ from the ordinary General Public License. We use this license for certain
+ libraries in order to permit linking those libraries into non-free
+ programs.
+
+ When a program is linked with a library, whether statically or using a
+ shared library, the combination of the two is legally speaking a combined
+ work, a derivative of the original library. The ordinary General Public
+ License therefore permits such linking only if the entire combination fits
+ its criteria of freedom. The Lesser General Public License permits more
+ lax criteria for linking other code with the library.
+
+ We call this license the "Lesser" General Public License because it does
+ Less to protect the user's freedom than the ordinary General Public
+ License. It also provides other free software developers Less of an
+ advantage over competing non-free programs. These disadvantages are the
+ reason we use the ordinary General Public License for many libraries.
+ However, the Lesser license provides advantages in certain special
+ circumstances.
+
+ For example, on rare occasions, there may be a special need to encourage
+ the widest possible use of a certain library, so that it becomes a
+ de-facto standard. To achieve this, non-free programs must be allowed to
+ use the library. A more frequent case is that a free library does the same
+ job as widely used non-free libraries. In this case, there is little to
+ gain by limiting the free library to free software only, so we use the
+ Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+ programs enables a greater number of people to use a large body of free
+ software. For example, permission to use the GNU C Library in non-free
+ programs enables many more people to use the whole GNU operating system,
+ as well as its variant, the GNU/Linux operating system.
+
+ Although the Lesser General Public License is Less protective of the
+ users' freedom, it does ensure that the user of a program that is linked
+ with the Library has the freedom and the wherewithal to run that program
+ using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+ modification follow. Pay close attention to the difference between a "work
+ based on the library" and a "work that uses the library". The former
+ contains code derived from the library, whereas the latter must be
+ combined with the library in order to run.
+
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other program
+ which contains a notice placed by the copyright holder or other authorized
+ party saying it may be distributed under the terms of this Lesser General
+ Public License (also called "this License"). Each licensee is addressed as
+ "you".
+
+ A "library" means a collection of software functions and/or data prepared
+ so as to be conveniently linked with application programs (which use some
+ of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work which
+ has been distributed under these terms. A "work based on the Library"
+ means either the Library or any derivative work under copyright law: that
+ is to say, a work containing the Library or a portion of it, either
+ verbatim or with modifications and/or translated straightforwardly into
+ another language. (Hereinafter, translation is included without limitation
+ in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for making
+ modifications to it. For a library, complete source code means all the
+ source code for all modules it contains, plus any associated interface
+ definition files, plus the scripts used to control compilation and
+ installation of the library.
+
+ Activities other than copying, distribution and modification are not
+ covered by this License; they are outside its scope. The act of running a
+ program using the Library is not restricted, and output from such a
+ program is covered only if its contents constitute a work based on the
+ Library (independent of the use of the Library in a tool for writing it).
+ Whether that is true depends on what the Library does and what the program
+ that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's complete
+ source code as you receive it, in any medium, provided that you
+ conspicuously and appropriately publish on each copy an appropriate
+ copyright notice and disclaimer of warranty; keep intact all the notices
+ that refer to this License and to the absence of any warranty; and
+ distribute a copy of this License along with the Library.
+
+ You may charge a fee for the physical act of transferring a copy, and you
+ may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Library or any portion of it,
+ thus forming a work based on the Library, and copy and distribute such
+ modifications or work under the terms of Section 1 above, provided that
+ you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices stating
+ that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no charge to
+ all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a table
+ of data to be supplied by an application program that uses the facility,
+ other than as an argument passed when the facility is invoked, then you
+ must make a good faith effort to ensure that, in the event an
+ application does not supply such function or table, the facility still
+ operates, and performs whatever part of its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has a
+ purpose that is entirely well-defined independent of the application.
+ Therefore, Subsection 2d requires that any application-supplied function
+ or table used by this function must be optional: if the application does
+ not supply it, the square root function must still compute square
+ roots.)
+
+ These requirements apply to the modified work as a whole. If
+ identifiable sections of that work are not derived from the Library, and
+ can be reasonably considered independent and separate works in
+ themselves, then this License, and its terms, do not apply to those
+ sections when you distribute them as separate works. But when you
+ distribute the same sections as part of a whole which is a work based on
+ the Library, the distribution of the whole must be on the terms of this
+ License, whose permissions for other licensees extend to the entire
+ whole, and thus to each and every part regardless of who wrote it.
+
+ Thus, it is not the intent of this section to claim rights or contest
+ your rights to work written entirely by you; rather, the intent is to
+ exercise the right to control the distribution of derivative or
+ collective works based on the Library.
+
+ In addition, mere aggregation of another work not based on the Library
+ with the Library (or with a work based on the Library) on a volume of a
+ storage or distribution medium does not bring the other work under the
+ scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+ License instead of this License to a given copy of the Library. To do
+ this, you must alter all the notices that refer to this License, so that
+ they refer to the ordinary GNU General Public License, version 2, instead
+ of to this License. (If a newer version than version 2 of the ordinary GNU
+ General Public License has appeared, then you can specify that version
+ instead if you wish.) Do not make any other change in these notices.
+
+ Once this change is made in a given copy, it is irreversible for that
+ copy, so the ordinary GNU General Public License applies to all subsequent
+ copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of the
+ Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or derivative of
+ it, under Section 2) in object code or executable form under the terms of
+ Sections 1 and 2 above provided that you accompany it with the complete
+ corresponding machine-readable source code, which must be distributed
+ under the terms of Sections 1 and 2 above on a medium customarily used for
+ software interchange.
+
+ If distribution of object code is made by offering access to copy from a
+ designated place, then offering equivalent access to copy the source code
+ from the same place satisfies the requirement to distribute the source
+ code, even though third parties are not compelled to copy the source along
+ with the object code.
+
+ 5. A program that contains no derivative of any portion of the Library,
+ but is designed to work with the Library by being compiled or linked with
+ it, is called a "work that uses the Library". Such a work, in isolation,
+ is not a derivative work of the Library, and therefore falls outside the
+ scope of this License.
+
+ However, linking a "work that uses the Library" with the Library creates
+ an executable that is a derivative of the Library (because it contains
+ portions of the Library), rather than a "work that uses the library". The
+ executable is therefore covered by this License. Section 6 states terms
+ for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file that
+ is part of the Library, the object code for the work may be a derivative
+ work of the Library even though the source code is not. Whether this is
+ true is especially significant if the work can be linked without the
+ Library, or if the work is itself a library. The threshold for this to be
+ true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data structure
+ layouts and accessors, and small macros and small inline functions (ten
+ lines or less in length), then the use of the object file is unrestricted,
+ regardless of whether it is legally a derivative work. (Executables
+ containing this object code plus portions of the Library will still fall
+ under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may distribute
+ the object code for the work under the terms of Section 6. Any executables
+ containing that work also fall under Section 6, whether or not they are
+ linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or link a
+ "work that uses the Library" with the Library to produce a work containing
+ portions of the Library, and distribute that work under terms of your
+ choice, provided that the terms permit modification of the work for the
+ customer's own use and reverse engineering for debugging such
+ modifications.
+
+ You must give prominent notice with each copy of the work that the Library
+ is used in it and that the Library and its use are covered by this
+ License. You must supply a copy of this License. If the work during
+ execution displays copyright notices, you must include the copyright
+ notice for the Library among them, as well as a reference directing the
+ user to the copy of this License. Also, you must do one of these things:
+
+ a) Accompany the work with the complete corresponding machine-readable
+ source code for the Library including whatever changes were used in the
+ work (which must be distributed under Sections 1 and 2 above); and, if
+ the work is an executable linked with the Library, with the complete
+ machine-readable "work that uses the Library", as object code and/or
+ source code, so that the user can modify the Library and then relink to
+ produce a modified executable containing the modified Library. (It is
+ understood that the user who changes the contents of definitions files
+ in the Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the Library.
+ A suitable mechanism is one that (1) uses at run time a copy of the
+ library already present on the user's computer system, rather than
+ copying library functions into the executable, and (2) will operate
+ properly with a modified version of the library, if the user installs
+ one, as long as the modified version is interface-compatible with the
+ version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at least three
+ years, to give the same user the materials specified in Subsection 6a,
+ above, for a charge no more than the cost of performing this
+ distribution.
+
+ d) If distribution of the work is made by offering access to copy from a
+ designated place, offer equivalent access to copy the above specified
+ materials from the same place.
+
+ e) Verify that the user has already received a copy of these materials
+ or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the Library"
+ must include any data and utility programs needed for reproducing the
+ executable from it. However, as a special exception, the materials to be
+ distributed need not include anything that is normally distributed (in
+ either source or binary form) with the major components (compiler, kernel,
+ and so on) of the operating system on which the executable runs, unless
+ that component itself accompanies the executable.
+
+ It may happen that this requirement contradicts the license restrictions
+ of other proprietary libraries that do not normally accompany the
+ operating system. Such a contradiction means you cannot use both them and
+ the Library together in an executable that you distribute.
+
+ 7. You may place library facilities that are a work based on the Library
+ side-by-side in a single library together with other library facilities
+ not covered by this License, and distribute such a combined library,
+ provided that the separate distribution of the work based on the Library
+ and of the other library facilities is otherwise permitted, and provided
+ that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work based on
+ the Library, uncombined with any other library facilities. This must be
+ distributed under the terms of the Sections above.
+
+ b) Give prominent notice with the combined library of the fact that part
+ of it is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute the
+ Library except as expressly provided under this License. Any attempt
+ otherwise to copy, modify, sublicense, link with, or distribute the
+ Library is void, and will automatically terminate your rights under this
+ License. However, parties who have received copies, or rights, from you
+ under this License will not have their licenses terminated so long as such
+ parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not signed
+ it. However, nothing else grants you permission to modify or distribute
+ the Library or its derivative works. These actions are prohibited by law
+ if you do not accept this License. Therefore, by modifying or distributing
+ the Library (or any work based on the Library), you indicate your
+ acceptance of this License to do so, and all its terms and conditions for
+ copying, distributing or modifying the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+ Library), the recipient automatically receives a license from the original
+ licensor to copy, distribute, link with or modify the Library subject to
+ these terms and conditions. You may not impose any further restrictions on
+ the recipients' exercise of the rights granted herein. You are not
+ responsible for enforcing compliance by third parties with this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+ infringement or for any other reason (not limited to patent issues),
+ conditions are imposed on you (whether by court order, agreement or
+ otherwise) that contradict the conditions of this License, they do not
+ excuse you from the conditions of this License. If you cannot distribute
+ so as to satisfy simultaneously your obligations under this License and
+ any other pertinent obligations, then as a consequence you may not
+ distribute the Library at all. For example, if a patent license would not
+ permit royalty-free redistribution of the Library by all those who receive
+ copies directly or indirectly through you, then the only way you could
+ satisfy both it and this License would be to refrain entirely from
+ distribution of the Library.
+
+ If any portion of this section is held invalid or unenforceable under any
+ particular circumstance, the balance of the section is intended to apply,
+ and the section as a whole is intended to apply in other circumstances.
+
+ It is not the purpose of this section to induce you to infringe any
+ patents or other property right claims or to contest validity of any such
+ claims; this section has the sole purpose of protecting the integrity of
+ the free software distribution system which is implemented by public
+ license practices. Many people have made generous contributions to the
+ wide range of software distributed through that system in reliance on
+ consistent application of that system; it is up to the author/donor to
+ decide if he or she is willing to distribute software through any other
+ system and a licensee cannot impose that choice.
+
+ This section is intended to make thoroughly clear what is believed to be a
+ consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in certain
+ countries either by patents or by copyrighted interfaces, the original
+ copyright holder who places the Library under this License may add an
+ explicit geographical distribution limitation excluding those countries,
+ so that distribution is permitted only in or among countries not thus
+ excluded. In such case, this License incorporates the limitation as if
+ written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new versions
+ of the Lesser General Public License from time to time. Such new versions
+ will be similar in spirit to the present version, but may differ in detail
+ to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the Library
+ specifies a version number of this License which applies to it and "any
+ later version", you have the option of following the terms and conditions
+ either of that version or of any later version published by the Free
+ Software Foundation. If the Library does not specify a license version
+ number, you may choose any version ever published by the Free Software
+ Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+ programs whose distribution conditions are incompatible with these, write
+ to the author to ask for permission. For software which is copyrighted by
+ the Free Software Foundation, write to the Free Software Foundation; we
+ sometimes make exceptions for this. Our decision will be guided by the two
+ goals of preserving the free status of all derivatives of our free
+ software and of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+ FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+ PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+ TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE
+ LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+ REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+ REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
+ ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT
+ LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES
+ SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE
+ WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+
Added: multipath-tools/upstream/current/libsysfs/Makefile
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libsysfs/Makefile Fri Mar 4 08:05:19 2005
@@ -0,0 +1,37 @@
+# Makefile
+#
+# Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui at free.fr>
+
+BUILD = klibc
+
+include ../Makefile.inc
+
+ifeq ($(strip $(BUILD)),klibc)
+ CFLAGS = ${REQFLAGS} ${OPTFLAGS}
+else
+ CFLAGS =
+endif
+
+OBJS = dlist.o sysfs_dir.o sysfs_utils.o
+
+all: $(BUILD)
+
+prepare:
+ rm -f core *.o *.gz
+
+glibc:
+
+klibc: prepare $(KLIBC) $(OBJS)
+ ar rs libsysfs-klibc.a *.o
+
+$(KLIBC):
+ rm -f $(klibcdir)/linux
+ ln -s $(KERNEL_BUILD) $(klibcdir)/linux
+ make -C $(klibcdir)
+
+install:
+
+uninstall:
+
+clean:
+ rm -f core *.a *.o *.gz
Added: multipath-tools/upstream/current/libsysfs/dlist.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libsysfs/dlist.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,354 @@
+/*
+ * dlist.c
+ *
+ * Copyright (C) 2003 Eric J Bohm
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 021110307 USA
+ *
+ */
+
+
+/* Double linked list implementation.
+
+ * You allocate the data and give dlist the pointer.
+ * If your data is complex set the dlist->del_func to a an appropriate
+ * delete function. Otherwise dlist will just use free.
+
+*/
+#include <stdlib.h>
+#include "sysfs/dlist.h"
+
+/*
+ * Return pointer to node at marker.
+ * else null if no nodes.
+ */
+
+inline void *dlist_mark(Dlist *list)
+{
+ if(list->marker!=NULL)
+ return(list->marker->data);
+ else
+ return(NULL);
+}
+
+/*
+ * Set marker to start.
+ */
+
+inline void dlist_start(Dlist *list)
+{
+ list->marker=list->head;
+}
+
+/*
+ * Set marker to end.
+ */
+
+inline void dlist_end(Dlist *list)
+{
+ list->marker=list->head;
+}
+
+/* internal use function
+ * quickie inline to consolidate the marker movement logic
+ * in one place
+ *
+ * when direction true it moves marker after
+ * when direction false it moves marker before.
+ * return pointer to data at new marker
+ * if nowhere to move the marker in desired direction return null
+ */
+inline void *_dlist_mark_move(Dlist *list,int direction)
+{
+ if(direction)
+ {
+ if( list->marker && list->marker->next!=NULL)
+ list->marker=list->marker->next;
+ else
+ return(NULL);
+ }
+ else
+ {
+ if( list->marker && list->marker->prev!=NULL)
+ list->marker=list->marker->prev;
+ else
+ return(NULL);
+ }
+ if(list->marker!=list->head)
+ return(list->marker->data);
+ else
+ return(NULL);
+}
+
+/*
+ * Create new linked list to store nodes of datasize.
+ * return null if list cannot be created.
+ */
+Dlist *dlist_new(size_t datasize)
+{
+ Dlist *list=NULL;
+ if((list=malloc(sizeof(Dlist))))
+ {
+ list->marker=NULL;
+ list->count=0L;
+ list->data_size=datasize;
+ list->del_func=free;
+ list->head=&(list->headnode);
+ list->head->prev=NULL;
+ list->head->next=NULL;
+ list->head->data=NULL;
+ }
+ return(list);
+}
+
+/*
+ * Create new linked list to store nodes of datasize set list
+ * data node delete function to the passed in del_func
+ * return null if list cannot be created.
+ */
+Dlist *dlist_new_with_delete(size_t datasize,void (*del_func)(void*))
+{
+ Dlist *list=NULL;
+ list=dlist_new(datasize);
+ if(list!=NULL)
+ list->del_func=del_func;
+ return(list);
+}
+
+
+/*
+ * remove marker node from list
+ * call data_delete function on data if registered.
+ * otherwise call free.
+ * when direction true it moves marker after
+ * when direction false it moves marker before.
+ * free marker node
+ * return nothing.
+ */
+void dlist_delete(Dlist *list,int direction)
+{
+ if((list->marker != list->head)&&(list->marker!=NULL))
+ {
+ DL_node *corpse;
+ corpse=list->marker;
+ _dlist_mark_move(list,direction);
+ if(list->head->next==corpse)
+ list->head->next=corpse->next;
+ if(list->head->prev==corpse)
+ list->head->prev=corpse->prev;
+ if(corpse->prev!=NULL) //should be impossible
+ corpse->prev->next=corpse->next;
+ if(corpse->next!=NULL) //should be impossible
+ corpse->next->prev=corpse->prev;
+ list->del_func(corpse->data);
+ list->count--;
+ free(corpse);
+ }
+}
+
+/*
+ * Insert node containing data at marker.
+ * If direction true it inserts after.
+ * If direction false it inserts before.
+ * move marker to inserted node
+ * return pointer to inserted node
+ */
+void *dlist_insert(Dlist *list,void *data,int direction)
+{
+ DL_node *new_node=NULL;
+ if(list==NULL || data==NULL)
+ return(NULL);
+ if(list->marker==NULL) //in case the marker ends up unset
+ list->marker=list->head;
+ if((new_node=malloc(sizeof(DL_node))))
+ {
+ new_node->data=data;
+ new_node->prev=NULL;
+ new_node->next=NULL;
+ list->count++;
+ if(list->head->next==NULL) //no l
+ {
+ list->head->next=list->head->prev=new_node;
+ new_node->prev=list->head;
+ new_node->next=list->head;
+ }
+ else if(direction)
+ {
+ new_node->next=list->marker->next;
+ new_node->prev=list->marker;
+ list->marker->next->prev=new_node;
+ list->marker->next=new_node;
+ }
+ else
+ {
+ new_node->prev=list->marker->prev;
+ new_node->next=list->marker;
+ list->marker->prev->next=new_node;
+ list->marker->prev=new_node;
+ }
+ list->marker=new_node;
+ }
+ else
+ {
+ return(NULL);
+ }
+ return(list->marker->data);
+}
+
+/*
+ * Remove DL_node from list without deallocating data.
+ * if marker == killme .
+ * when direction true it moves marker after
+ * when direction false it moves marker before.
+ * to previous if there is no next.
+ */
+void *_dlist_remove(Dlist *list,DL_node *killme,int direction)
+{
+ if(killme!=NULL)
+ {
+ void *killer_data=killme->data;
+ // take care of head and marker pointers.
+ if(list->marker==killme)
+ _dlist_mark_move(list,direction);
+ if(killme ==list->head->next)
+ list->head->next=killme->next;
+ if(killme==list->head->prev)
+ list->head->prev=killme->prev;
+ // remove from list
+ if(killme->prev !=NULL)
+ killme->prev->next=killme->next;
+ if(killme->next !=NULL)
+ killme->next->prev=killme->prev;
+ list->count--;
+ free(killme);
+ return(killer_data);
+ }
+ else
+ return (NULL);
+}
+
+
+/*
+ * Insert node containing data after end.
+ */
+void dlist_push(Dlist *list,void *data)
+{
+ list->marker=list->head->prev;
+ dlist_insert(list,data,1);
+}
+
+/*
+ * Insert node containing data at start.
+ */
+
+void dlist_unshift(Dlist *list,void *data)
+
+{
+ list->marker=list->head->next;
+ dlist_insert(list,data,0);
+}
+
+void dlist_unshift_sorted(Dlist *list, void *data,
+ int (*sorter)(void *new, void *old))
+{
+ if (list->count == 0)
+ dlist_unshift(list, data);
+ else {
+ list->marker=list->head->next;
+ dlist_insert_sorted(list, data, sorter);
+ }
+}
+
+/*
+ * Remove end node from list.
+ * Return pointer to data in removed node.
+ * Null if no nodes.
+ */
+
+void *dlist_pop(Dlist *list)
+{
+ return(_dlist_remove(list,list->head->prev,0));
+}
+
+/*
+ * Remove start node from list.
+ * Return pointer to data in removed node.
+ * Null if no nodes.
+ */
+
+void *dlist_shift(Dlist *list)
+{
+ return(_dlist_remove(list,list->head->next,1));
+}
+
+
+/*
+ * destroy the list freeing all memory
+ */
+
+
+void dlist_destroy(Dlist *list)
+{
+ if(list !=NULL)
+ {
+ dlist_start(list);
+ dlist_next(list);
+ while (dlist_mark(list)) {
+ dlist_delete(list,1);
+ }
+ free(list);
+ }
+}
+
+/**
+ * Return void pointer to list_data element matching comp function criteria
+ * else null
+ * Does not move the marker.
+ */
+
+void *dlist_find_custom(struct dlist *list, void *target, int (*comp)(void *, void *))
+{
+ /* test the comp function on each node */
+ struct dl_node *nodepointer;
+ dlist_for_each_nomark(list,nodepointer)
+ if(comp(target,nodepointer->data))
+ return(nodepointer->data);
+ return(NULL);
+}
+
+/**
+ * Apply the node_operation function to each data node in the list
+ */
+void dlist_transform(struct dlist *list, void (*node_operation)(void *))
+{
+ struct dl_node *nodepointer;
+ dlist_for_each_nomark(list,nodepointer)
+ node_operation(nodepointer->data);
+}
+
+/**
+ * insert new into list in sorted order
+ * sorter function in form int sorter(new,ith)
+ * must return 1 for when new should go before ith
+ * else 0
+ * return pointer to inserted node
+ * NOTE: assumes list is already sorted
+ */
+void *dlist_insert_sorted(struct dlist *list, void *new, int (*sorter)(void *, void *))
+{
+ for(dlist_start(list),dlist_next(list); \
+ list->marker!=list->head && !sorter(new,list->marker->data);dlist_next(list));
+ return(dlist_insert_before(list,new));
+}
Added: multipath-tools/upstream/current/libsysfs/libsysfs-klibc.a
==============================================================================
Binary file. No diff available.
Added: multipath-tools/upstream/current/libsysfs/sysfs.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libsysfs/sysfs.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,44 @@
+/*
+ * sysfs.h
+ *
+ * Internal Header Definitions for libsysfs
+ *
+ * Copyright (C) IBM Corp. 2003
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef _SYSFS_H_
+#define _SYSFS_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "sysfs/dlist.h"
+
+/* Debugging */
+#ifdef DEBUG
+#include "../logging.h"
+#define dprintf(format, arg...) dbg(format, ##arg)
+#else
+#define dprintf(format, arg...) do { } while (0)
+#endif
+
+#endif /* _SYSFS_H_ */
Added: multipath-tools/upstream/current/libsysfs/sysfs/dlist.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libsysfs/sysfs/dlist.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,195 @@
+/*
+ * dlist.h
+ *
+ * Copyright (C) 2003 Eric J Bohm
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef _DLIST_H_
+#define _DLIST_H_
+
+/* Double linked list header.
+
+* navigate your list with DLIST_PREV and DLIST_NEXT. These are macros
+* so function call overhead is minimized.
+
+* Supports perl style push, pop, shift, unshift list semantics.
+
+* You allocate the data and give dlist the pointer. If your data is
+* complex set the dlist->del_func to a an appropriate delete using
+* dlist_new_with_delete. Your delete function must match
+(void * )(del(void *)
+*Otherwise dlist will just use free.
+
+* NOTE: The small amount of pain involved in doing that allows us to
+* avoid copy in copy out semantics.
+
+* Dlist uses an internal mark pointer to keep track of where you are
+* in the list.
+
+* insert and delete take a directional parameter. Where direction
+* corresponds to the direction in which you want the list to go.
+* true direction corresponded to progressing forward in the last
+* false to regressing in the list.
+* so a dlist_insert(yourlist,item,1) will insert it after the mark
+* so a dlist_insert(yourlist,item,0) will insert it before the mark
+* any insert will move the mark to the new node regardless of the direction.
+
+* Just use the dlist_(insert|delete)_(before|after) macros if you do not want
+* to think about it.
+
+*/
+typedef struct dl_node {
+ struct dl_node *prev;
+ struct dl_node *next;
+ void *data;
+} DL_node;
+
+typedef struct dlist {
+ DL_node *marker;
+ unsigned long count;
+ size_t data_size;
+ void (*del_func)(void *);
+ DL_node headnode;
+ DL_node *head;
+} Dlist;
+
+Dlist *dlist_new(size_t datasize);
+Dlist *dlist_new_with_delete(size_t datasize,void (*del_func)(void*));
+void *_dlist_mark_move(Dlist *list,int direction);
+void *dlist_mark(Dlist *);
+void dlist_start(Dlist *);
+void dlist_end(Dlist *);
+
+void *dlist_insert(Dlist *,void *,int) ;
+
+void *dlist_insert_sorted(struct dlist *list, void *new_elem, int (*sorter)(void *, void *));
+
+void dlist_delete(Dlist *,int);
+
+void dlist_push(Dlist *,void *);
+
+void dlist_unshift(Dlist *,void *);
+void dlist_unshift_sorted(Dlist *,void *,int (*sorter)(void *, void *));
+
+void *dlist_pop(Dlist *);
+
+void *dlist_shift(Dlist *);
+
+void dlist_destroy(Dlist *);
+
+void *dlist_find_custom(struct dlist *list, void *target, int (*comp)(void *, void *));
+void dlist_transform(struct dlist *list, void (*node_operation)(void *));
+
+
+/*
+ * _dlist_remove is for internal use only
+ * _dlist_mark_move is for internal use only
+ */
+void *_dlist_remove(struct dlist *,struct dl_node *,int );
+
+#define dlist_prev(A) _dlist_mark_move((A),0)
+#define dlist_next(A) _dlist_mark_move((A),1)
+
+#define dlist_insert_before(A,B) dlist_insert((A),(B),0)
+#define dlist_insert_after(A,B) dlist_insert((A),(B),1)
+
+#define dlist_delete_before(A) dlist_delete((A),0)
+#define dlist_delete_after(A) dlist_delete((A),1)
+
+/**
+ * provide for loop header which iterates the mark from start to end
+ * list: the dlist pointer, use dlist_mark(list) to get iterator
+ */
+#define dlist_for_each(list) \
+ for(dlist_start(list),dlist_next(list); \
+ (list)->marker!=(list)->head;dlist_next(list))
+
+/**
+ * provide for loop header which iterates the mark from end to start
+ * list: the dlist pointer, use dlist_mark(list) to get iterator
+ */
+#define dlist_for_each_rev(list) \
+ for(dlist_end(list),dlist_prev(list); \
+ (list)->marker!=(list)->head;dlist_prev(list))
+
+/**
+ * provide for loop header which iterates through the list without moving mark
+ * list: the dlist_pointer
+ * iterator: dl_node pointer to iterate
+ */
+#define dlist_for_each_nomark(list,iterator) \
+ for((iterator)=(list)->head->next; (iterator)!=(list)->head; \
+ (iterator)=(iterator)->next)
+
+/**
+ * provide for loop header which iterates through the list without moving mark
+ * in reverse
+ * list: the dlist_pointer
+ * iterator: dl_node pointer to iterate
+ */
+#define dlist_for_each_nomark_rev(list,iterator) \
+ for((iterator)=(list)->head->prev; (iterator)!=(list)->head; \
+ (iterator)=(iterator)->prev)
+/**
+ * provide for loop header which iterates through the list providing a
+ * data iterator
+ * list: the dlist pointer
+ * data_iterator: the pointer of type datatype to iterate
+ * datatype: actual type of the contents in the dl_node->data
+ */
+
+#define dlist_for_each_data(list,data_iterator,datatype) \
+ for(dlist_start(list), (data_iterator)=(datatype *) dlist_next(list); \
+ (list)->marker!=(list)->head;(data_iterator)=(datatype *) dlist_next(list))
+
+/**
+ * provide for loop header which iterates through the list providing a
+ * data iterator in reverse
+ * list: the dlist pointer
+ * data_iterator: the pointer of type datatype to iterate
+ * datatype: actual type of the contents in the dl_node->data
+ */
+#define dlist_for_each_data_rev(list,data_iterator,datatype) \
+ for(dlist_end(list), (data_iterator)=(datatype *) dlist_prev(list); \
+ (list)->marker!=(list)->head;(data_iterator)=(datatype *) dlist_prev(list))
+
+/**
+ * provide for loop header which iterates through the list providing a
+ * data iterator without moving the mark
+ * list: the dlist pointer
+ * iterator: the dl_node pointer to iterate
+ * data_iterator: the pointer of type datatype to iterate
+ * datatype: actual type of the contents in the dl_node->data
+ */
+
+#define dlist_for_each_data_nomark(list,iterator,data_iterator,datatype) \
+ for((iterator)=(list)->head->next, (data_iterator)=(datatype *) (iterator)->data; \
+ (iterator)!=(list)->head;(iterator)=(iterator)->next,(data_iterator)=(datatype *) (iterator))
+
+/**
+ * provide for loop header which iterates through the list providing a
+ * data iterator in reverse without moving the mark
+ * list: the dlist pointer
+ * iterator: the dl_node pointer to iterate
+ * data_iterator: the pointer of type datatype to iterate
+ * datatype: actual type of the contents in the dl_node->data
+ */
+#define dlist_for_each_data_nomark_rev(list,iterator, data_iterator,datatype) \
+ for((iterator)=(list)->head->prev, (data_iterator)=(datatype *) (iterator)->data; \
+ (iterator)!=(list)->head;(iterator)=(iterator)->prev,(data_iterator)=(datatype *) (iterator))
+
+#endif /* _DLIST_H_ */
Added: multipath-tools/upstream/current/libsysfs/sysfs/libsysfs.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libsysfs/sysfs/libsysfs.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,162 @@
+/*
+ * libsysfs.h
+ *
+ * Header Definitions for libsysfs
+ *
+ * Copyright (C) IBM Corp. 2003
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#ifndef _LIBSYSFS_H_
+#define _LIBSYSFS_H_
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Defines to prevent buffer overruns
+ */
+#define safestrcpy(to, from) strncpy(to, from, sizeof(to)-1)
+#define safestrcat(to, from) strncat(to, from, sizeof(to) - strlen(to)-1)
+
+#define safestrcpymax(to, from, max) \
+do { \
+ to[max-1] = '\0'; \
+ strncpy(to, from, max-1); \
+} while (0)
+
+#define safestrcatmax(to, from, max) \
+do { \
+ to[max-1] = '\0'; \
+ strncat(to, from, max - strlen(to)-1); \
+} while (0)
+
+/*
+ * Generic #defines go here..
+ */
+#define SYSFS_FSTYPE_NAME "sysfs"
+#define SYSFS_PROC_MNTS "/proc/mounts"
+#define SYSFS_BUS_NAME "bus"
+#define SYSFS_CLASS_NAME "class"
+#define SYSFS_BLOCK_NAME "block"
+#define SYSFS_DEVICES_NAME "devices"
+#define SYSFS_DRIVERS_NAME "drivers"
+#define SYSFS_NAME_ATTRIBUTE "name"
+#define SYSFS_UNKNOWN "unknown"
+#define SYSFS_PATH_ENV "SYSFS_PATH"
+
+#define SYSFS_PATH_MAX 255
+#define SYSFS_NAME_LEN 50
+#define SYSFS_BUS_ID_SIZE 20
+
+#define SYSFS_METHOD_SHOW 0x01 /* attr can be read by user */
+#define SYSFS_METHOD_STORE 0x02 /* attr can be changed by user */
+
+/*
+ * NOTE: We have the statically allocated "name" as the first element of all
+ * the structures. This feature is used in the "sorter" function for dlists
+ */
+
+struct sysfs_attribute {
+ char name[SYSFS_NAME_LEN];
+ char path[SYSFS_PATH_MAX];
+ char *value;
+ unsigned short len; /* value length */
+ unsigned short method; /* show and store */
+};
+
+struct sysfs_link {
+ char name[SYSFS_NAME_LEN];
+ char path[SYSFS_PATH_MAX];
+ char target[SYSFS_PATH_MAX];
+};
+
+struct sysfs_directory {
+ char name[SYSFS_NAME_LEN];
+ char path[SYSFS_PATH_MAX];
+
+ /* Private: for internal use only */
+ struct dlist *subdirs;
+ struct dlist *links;
+ struct dlist *attributes;
+};
+
+/*
+ * Function Prototypes
+ */
+extern int sysfs_get_mnt_path(char *mnt_path, size_t len);
+extern int sysfs_remove_trailing_slash(char *path);
+extern int sysfs_get_name_from_path(const char *path, char *name, size_t len);
+extern int sysfs_path_is_dir(const char *path);
+extern int sysfs_path_is_link(const char *path);
+extern int sysfs_path_is_file(const char *path);
+extern int sysfs_get_link(const char *path, char *target, size_t len);
+extern struct dlist *sysfs_open_subsystem_list(char *name);
+extern struct dlist *sysfs_open_bus_devices_list(char *name);
+extern void sysfs_close_list(struct dlist *list);
+
+/* sysfs directory and file access */
+extern void sysfs_close_attribute(struct sysfs_attribute *sysattr);
+extern struct sysfs_attribute *sysfs_open_attribute(const char *path);
+extern int sysfs_read_attribute(struct sysfs_attribute *sysattr);
+extern int sysfs_read_attribute_value(const char *attrpath,
+ char *value, size_t vsize);
+extern int sysfs_write_attribute(struct sysfs_attribute *sysattr,
+ const char *new_value, size_t len);
+extern char *sysfs_get_value_from_attributes(struct dlist *attr,
+ const char *name);
+extern int sysfs_refresh_dir_attributes(struct sysfs_directory *sysdir);
+extern int sysfs_refresh_dir_links(struct sysfs_directory *sysdir);
+extern int sysfs_refresh_dir_subdirs(struct sysfs_directory *sysdir);
+extern void sysfs_close_directory(struct sysfs_directory *sysdir);
+extern struct sysfs_directory *sysfs_open_directory(const char *path);
+extern int sysfs_read_dir_attributes(struct sysfs_directory *sysdir);
+extern int sysfs_read_dir_links(struct sysfs_directory *sysdir);
+extern int sysfs_read_dir_subdirs(struct sysfs_directory *sysdir);
+extern int sysfs_read_directory(struct sysfs_directory *sysdir);
+extern int sysfs_read_all_subdirs(struct sysfs_directory *sysdir);
+extern struct sysfs_directory *sysfs_get_subdirectory
+ (struct sysfs_directory *dir, char *subname);
+extern void sysfs_close_link(struct sysfs_link *ln);
+extern struct sysfs_link *sysfs_open_link(const char *lnpath);
+extern struct sysfs_link *sysfs_get_directory_link
+ (struct sysfs_directory *dir, char *linkname);
+extern struct sysfs_link *sysfs_get_subdirectory_link
+ (struct sysfs_directory *dir, char *linkname);
+extern struct sysfs_attribute *sysfs_get_directory_attribute
+ (struct sysfs_directory *dir, char *attrname);
+extern struct dlist *sysfs_get_dir_attributes(struct sysfs_directory *dir);
+extern struct dlist *sysfs_get_dir_links(struct sysfs_directory *dir);
+extern struct dlist *sysfs_get_dir_subdirs(struct sysfs_directory *dir);
+
+/**
+ * sort_list: sorter function to keep list elements sorted in alphabetical
+ * order. Just does a strncmp as you can see :)
+ *
+ * Returns 1 if less than 0 otherwise
+ *
+ * NOTE: We take care to have a statically allocated "name" as the first
+ * lement of all libsysfs structures. Hence, this function will work
+ * AS IS for _ALL_ the lists that have to be sorted.
+ */
+static inline int sort_list(void *new_elem, void *old_elem)
+{
+ return ((strncmp(((struct sysfs_attribute *)new_elem)->name,
+ ((struct sysfs_attribute *)old_elem)->name,
+ strlen(((struct sysfs_attribute *)new_elem)->name))) < 0 ? 1 : 0);
+}
+
+#endif /* _LIBSYSFS_H_ */
Added: multipath-tools/upstream/current/libsysfs/sysfs_dir.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libsysfs/sysfs_dir.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,1069 @@
+/*
+ * sysfs_dir.c
+ *
+ * Directory utility functions for libsysfs
+ *
+ * Copyright (C) IBM Corp. 2003
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#include "sysfs/libsysfs.h"
+#include "sysfs.h"
+
+/**
+ * sysfs_del_attribute: routine for dlist integration
+ */
+static void sysfs_del_attribute(void *attr)
+{
+ sysfs_close_attribute((struct sysfs_attribute *)attr);
+}
+
+/**
+ * sysfs_del_link: routine for dlist integration
+ */
+static void sysfs_del_link(void *ln)
+{
+ sysfs_close_link((struct sysfs_link *)ln);
+}
+
+/**
+ * sysfs_del_dir: routine for dlist integration
+ */
+static void sysfs_del_directory(void *dir)
+{
+ sysfs_close_directory((struct sysfs_directory *)dir);
+}
+
+/**
+ * dir_attribute_name_equal: compares dir attributes by name
+ * @a: attribute name for comparison
+ * @b: sysfs_attribute to be compared.
+ * returns 1 if a==b->name or 0 if not equal
+ */
+static int dir_attribute_name_equal(void *a, void *b)
+{
+ if (a == NULL || b == NULL)
+ return 0;
+
+ if (strcmp(((char *)a), ((struct sysfs_attribute *)b)->name) == 0)
+ return 1;
+
+ return 0;
+}
+
+/**
+ * dir_link_name_equal: compares dir links by name
+ * @a: link name for comparison
+ * @b: sysfs_link to be compared.
+ * returns 1 if a==b->name or 0 if not equal
+ */
+static int dir_link_name_equal(void *a, void *b)
+{
+ if (a == NULL || b == NULL)
+ return 0;
+
+ if (strcmp(((char *)a), ((struct sysfs_link *)b)->name) == 0)
+ return 1;
+
+ return 0;
+}
+
+/**
+ * dir_subdir_name_equal: compares subdirs by name
+ * @a: name of subdirectory to compare
+ * @b: sysfs_directory subdirectory to be compared
+ * returns 1 if a==b->name or 0 if not equal
+ */
+static int dir_subdir_name_equal(void *a, void *b)
+{
+ if (a == NULL || b == NULL)
+ return 0;
+
+ if (strcmp(((char *)a), ((struct sysfs_directory *)b)->name) == 0)
+ return 1;
+
+ return 0;
+}
+
+/**
+ * sysfs_close_attribute: closes and cleans up attribute
+ * @sysattr: attribute to close.
+ */
+void sysfs_close_attribute(struct sysfs_attribute *sysattr)
+{
+ if (sysattr != NULL) {
+ if (sysattr->value != NULL)
+ free(sysattr->value);
+ free(sysattr);
+ }
+}
+
+/**
+ * alloc_attribute: allocates and initializes attribute structure
+ * returns struct sysfs_attribute with success and NULL with error.
+ */
+static struct sysfs_attribute *alloc_attribute(void)
+{
+ return (struct sysfs_attribute *)
+ calloc(1, sizeof(struct sysfs_attribute));
+}
+
+/**
+ * sysfs_open_attribute: creates sysfs_attribute structure
+ * @path: path to attribute.
+ * returns sysfs_attribute struct with success and NULL with error.
+ */
+struct sysfs_attribute *sysfs_open_attribute(const char *path)
+{
+ struct sysfs_attribute *sysattr = NULL;
+ struct stat fileinfo;
+
+ if (path == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+ sysattr = alloc_attribute();
+ if (sysattr == NULL) {
+ dprintf("Error allocating attribute at %s\n", path);
+ return NULL;
+ }
+ if (sysfs_get_name_from_path(path, sysattr->name,
+ SYSFS_NAME_LEN) != 0) {
+ dprintf("Error retrieving attrib name from path: %s\n", path);
+ sysfs_close_attribute(sysattr);
+ return NULL;
+ }
+ safestrcpy(sysattr->path, path);
+ if ((stat(sysattr->path, &fileinfo)) != 0) {
+ dprintf("Stat failed: No such attribute?\n");
+ sysattr->method = 0;
+ free(sysattr);
+ sysattr = NULL;
+ } else {
+ if (fileinfo.st_mode & S_IRUSR)
+ sysattr->method |= SYSFS_METHOD_SHOW;
+ if (fileinfo.st_mode & S_IWUSR)
+ sysattr->method |= SYSFS_METHOD_STORE;
+ }
+
+ return sysattr;
+}
+
+/**
+ * sysfs_write_attribute: write value to the attribute
+ * @sysattr: attribute to write
+ * @new_value: value to write
+ * @len: length of "new_value"
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_write_attribute(struct sysfs_attribute *sysattr,
+ const char *new_value, size_t len)
+{
+ int fd;
+ int length;
+
+ if (sysattr == NULL || new_value == NULL || len == 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (!(sysattr->method & SYSFS_METHOD_STORE)) {
+ dprintf ("Store method not supported for attribute %s\n",
+ sysattr->path);
+ errno = EACCES;
+ return -1;
+ }
+ if (sysattr->method & SYSFS_METHOD_SHOW) {
+ /*
+ * read attribute again to see if we can get an updated value
+ */
+ if ((sysfs_read_attribute(sysattr)) != 0) {
+ dprintf("Error reading attribute\n");
+ return -1;
+ }
+ if ((strncmp(sysattr->value, new_value, sysattr->len)) == 0) {
+ dprintf("Attr %s already has the requested value %s\n",
+ sysattr->name, new_value);
+ return 0;
+ }
+ }
+ /*
+ * open O_WRONLY since some attributes have no "read" but only
+ * "write" permission
+ */
+ if ((fd = open(sysattr->path, O_WRONLY)) < 0) {
+ dprintf("Error reading attribute %s\n", sysattr->path);
+ return -1;
+ }
+
+ length = write(fd, new_value, len);
+ if (length < 0) {
+ dprintf("Error writing to the attribute %s - invalid value?\n",
+ sysattr->name);
+ close(fd);
+ return -1;
+ } else if ((unsigned int)length != len) {
+ dprintf("Could not write %d bytes to attribute %s\n",
+ len, sysattr->name);
+ /*
+ * since we could not write user supplied number of bytes,
+ * restore the old value if one available
+ */
+ if (sysattr->method & SYSFS_METHOD_SHOW) {
+ length = write(fd, sysattr->value, sysattr->len);
+ close(fd);
+ return -1;
+ }
+ }
+
+ /*
+ * Validate length that has been copied. Alloc appropriate area
+ * in sysfs_attribute. Verify first if the attribute supports reading
+ * (show method). If it does not, do not bother
+ */
+ if (sysattr->method & SYSFS_METHOD_SHOW) {
+ if (length != sysattr->len) {
+ sysattr->value = (char *)realloc
+ (sysattr->value, length);
+ sysattr->len = length;
+ safestrcpymax(sysattr->value, new_value, length);
+ } else {
+ /*"length" of the new value is same as old one */
+ safestrcpymax(sysattr->value, new_value, length);
+ }
+ }
+
+ close(fd);
+ return 0;
+}
+
+/**
+ * sysfs_read_attribute: reads value from attribute
+ * @sysattr: attribute to read
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_read_attribute(struct sysfs_attribute *sysattr)
+{
+ char *fbuf = NULL;
+ char *vbuf = NULL;
+ ssize_t length = 0;
+ long pgsize = 0;
+ int fd;
+
+ if (sysattr == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ if (!(sysattr->method & SYSFS_METHOD_SHOW)) {
+ dprintf("Show method not supported for attribute %s\n",
+ sysattr->path);
+ errno = EACCES;
+ return -1;
+ }
+ pgsize = getpagesize();
+ fbuf = (char *)calloc(1, pgsize+1);
+ if (fbuf == NULL) {
+ dprintf("calloc failed\n");
+ return -1;
+ }
+ if ((fd = open(sysattr->path, O_RDONLY)) < 0) {
+ dprintf("Error reading attribute %s\n", sysattr->path);
+ free(fbuf);
+ return -1;
+ }
+ length = read(fd, fbuf, pgsize);
+ if (length < 0) {
+ dprintf("Error reading from attribute %s\n", sysattr->path);
+ close(fd);
+ free(fbuf);
+ return -1;
+ }
+ if (sysattr->len > 0) {
+ if ((sysattr->len == length) &&
+ (!(strncmp(sysattr->value, fbuf, length)))) {
+ close(fd);
+ free(fbuf);
+ return 0;
+ }
+ free(sysattr->value);
+ }
+ sysattr->len = length;
+ close(fd);
+ vbuf = (char *)realloc(fbuf, length+1);
+ if (vbuf == NULL) {
+ dprintf("realloc failed\n");
+ free(fbuf);
+ return -1;
+ }
+ sysattr->value = vbuf;
+
+ return 0;
+}
+
+/**
+ * sysfs_read_attribute_value: given path to attribute, return its value.
+ * values can be up to a pagesize, if buffer is smaller the value will
+ * be truncated.
+ * @attrpath: sysfs path to attribute
+ * @value: buffer to put value
+ * @vsize: size of value buffer
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_read_attribute_value(const char *attrpath,
+ char *value, size_t vsize)
+{
+ struct sysfs_attribute *attr = NULL;
+ size_t length = 0;
+
+ if (attrpath == NULL || value == NULL || vsize == 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ attr = sysfs_open_attribute(attrpath);
+ if (attr == NULL) {
+ dprintf("Invalid attribute path %s\n", attrpath);
+ errno = EINVAL;
+ return -1;
+ }
+ if((sysfs_read_attribute(attr)) != 0 || attr->value == NULL) {
+ dprintf("Error reading from attribute %s\n", attrpath);
+ sysfs_close_attribute(attr);
+ return -1;
+ }
+ length = strlen(attr->value);
+ if (length > vsize)
+ dprintf("Value length %d is larger than supplied buffer %d\n",
+ length, vsize);
+ safestrcpymax(value, attr->value, vsize);
+ sysfs_close_attribute(attr);
+
+ return 0;
+}
+
+/**
+ * sysfs_get_value_from_attrbutes: given a linked list of attributes and an
+ * attribute name, return its value
+ * @attr: attribute to search
+ * @name: name to look for
+ * returns char * value - could be NULL
+ */
+char *sysfs_get_value_from_attributes(struct dlist *attr, const char *name)
+{
+ struct sysfs_attribute *cur = NULL;
+
+ if (attr == NULL || name == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+ dlist_for_each_data(attr, cur, struct sysfs_attribute) {
+ if (strcmp(cur->name, name) == 0)
+ return cur->value;
+ }
+ return NULL;
+}
+
+/**
+ * sysfs_close_link: closes and cleans up link.
+ * @ln: link to close.
+ */
+void sysfs_close_link(struct sysfs_link *ln)
+{
+ if (ln != NULL)
+ free(ln);
+}
+
+/**
+ * sysfs_close_directory: closes directory, cleans up attributes and links
+ * @sysdir: sysfs_directory to close
+ */
+void sysfs_close_directory(struct sysfs_directory *sysdir)
+{
+ if (sysdir != NULL) {
+ if (sysdir->subdirs != NULL)
+ dlist_destroy(sysdir->subdirs);
+ if (sysdir->links != NULL)
+ dlist_destroy(sysdir->links);
+ if (sysdir->attributes != NULL)
+ dlist_destroy(sysdir->attributes);
+ free(sysdir);
+ sysdir = NULL;
+ }
+}
+
+/**
+ * alloc_directory: allocates and initializes directory structure
+ * returns struct sysfs_directory with success or NULL with error.
+ */
+static struct sysfs_directory *alloc_directory(void)
+{
+ return (struct sysfs_directory *)
+ calloc(1, sizeof(struct sysfs_directory));
+}
+
+/**
+ * alloc_link: allocates and initializes link structure
+ * returns struct sysfs_link with success or NULL with error.
+ */
+static struct sysfs_link *alloc_link(void)
+{
+ return (struct sysfs_link *)calloc(1, sizeof(struct sysfs_link));
+}
+
+/**
+ * sysfs_read_all_subdirs: calls sysfs_read_directory for all subdirs
+ * @sysdir: directory whose subdirs need reading.
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_read_all_subdirs(struct sysfs_directory *sysdir)
+{
+ struct sysfs_directory *cursub = NULL;
+ int retval = 0;
+
+ if (sysdir == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ if (sysdir->subdirs == NULL)
+ if ((sysfs_read_dir_subdirs(sysdir)) != 0)
+ return 0;
+ if (sysdir->subdirs != NULL) {
+ dlist_for_each_data(sysdir->subdirs, cursub,
+ struct sysfs_directory) {
+ if ((sysfs_read_dir_subdirs(cursub)) != 0) {
+ dprintf ("Error reading subdirectory %s\n",
+ cursub->name);
+ retval = -1;
+ }
+ }
+ }
+ if (!retval)
+ errno = 0;
+ return retval;
+}
+
+/**
+ * sysfs_open_directory: opens a sysfs directory, creates dir struct, and
+ * returns.
+ * @path: path of directory to open.
+ * returns: struct sysfs_directory * with success and NULL on error.
+ */
+struct sysfs_directory *sysfs_open_directory(const char *path)
+{
+ struct sysfs_directory *sdir = NULL;
+
+ if (path == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (sysfs_path_is_dir(path) != 0) {
+ dprintf("Invalid path to directory %s\n", path);
+ errno = EINVAL;
+ return NULL;
+ }
+
+ sdir = alloc_directory();
+ if (sdir == NULL) {
+ dprintf("Error allocating directory %s\n", path);
+ return NULL;
+ }
+ if (sysfs_get_name_from_path(path, sdir->name, SYSFS_NAME_LEN) != 0) {
+ dprintf("Error getting directory name from path: %s\n", path);
+ sysfs_close_directory(sdir);
+ return NULL;
+ }
+ safestrcpy(sdir->path, path);
+
+ return sdir;
+}
+
+/**
+ * sysfs_open_link: opens a sysfs link, creates struct, and returns
+ * @path: path of link to open.
+ * returns: struct sysfs_link * with success and NULL on error.
+ */
+struct sysfs_link *sysfs_open_link(const char *linkpath)
+{
+ struct sysfs_link *ln = NULL;
+
+ if (linkpath == NULL || strlen(linkpath) > SYSFS_PATH_MAX) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ ln = alloc_link();
+ if (ln == NULL) {
+ dprintf("Error allocating link %s\n", linkpath);
+ return NULL;
+ }
+ safestrcpy(ln->path, linkpath);
+ if ((sysfs_get_name_from_path(linkpath, ln->name, SYSFS_NAME_LEN)) != 0
+ || (sysfs_get_link(linkpath, ln->target, SYSFS_PATH_MAX)) != 0) {
+ errno = EINVAL;
+ dprintf("Invalid link path %s\n", linkpath);
+ return NULL;
+ }
+
+ return ln;
+}
+
+/**
+ * add_attribute: open and add attribute at path to given directory
+ * @sysdir: directory to add attribute to
+ * @path: path to attribute
+ * returns 0 with success and -1 with error.
+ */
+static int add_attribute(struct sysfs_directory *sysdir, const char *path)
+{
+ struct sysfs_attribute *attr = NULL;
+
+ attr = sysfs_open_attribute(path);
+ if (attr == NULL) {
+ dprintf("Error opening attribute %s\n", path);
+ return -1;
+ }
+ if (attr->method & SYSFS_METHOD_SHOW) {
+ if ((sysfs_read_attribute(attr)) != 0) {
+ dprintf("Error reading attribute %s\n", path);
+ sysfs_close_attribute(attr);
+ return 0;
+ }
+ }
+
+ if (sysdir->attributes == NULL) {
+ sysdir->attributes = dlist_new_with_delete
+ (sizeof(struct sysfs_attribute), sysfs_del_attribute);
+ }
+ dlist_unshift_sorted(sysdir->attributes, attr, sort_list);
+
+ return 0;
+}
+
+/**
+ * add_subdirectory: open and add subdirectory at path to given directory
+ * @sysdir: directory to add subdir to
+ * @path: path to subdirectory
+ * returns 0 with success and -1 with error.
+ */
+static int add_subdirectory(struct sysfs_directory *sysdir, const char *path)
+{
+ struct sysfs_directory *subdir = NULL;
+
+ subdir = sysfs_open_directory(path);
+ if (subdir == NULL) {
+ dprintf("Error opening directory %s\n", path);
+ return -1;
+ }
+ if (sysdir->subdirs == NULL)
+ sysdir->subdirs = dlist_new_with_delete
+ (sizeof(struct sysfs_directory), sysfs_del_directory);
+ dlist_unshift_sorted(sysdir->subdirs, subdir, sort_list);
+ return 0;
+}
+
+/**
+ * add_link: open and add link at path to given directory
+ * @sysdir: directory to add link to
+ * @path: path to link
+ * returns 0 with success and -1 with error.
+ */
+static int add_link(struct sysfs_directory *sysdir, const char *path)
+{
+ struct sysfs_link *ln = NULL;
+
+ ln = sysfs_open_link(path);
+ if (ln == NULL) {
+ dprintf("Error opening link %s\n", path);
+ return -1;
+ }
+ if (sysdir->links == NULL)
+ sysdir->links = dlist_new_with_delete
+ (sizeof(struct sysfs_link), sysfs_del_link);
+ dlist_unshift_sorted(sysdir->links, ln, sort_list);
+ return 0;
+}
+
+/**
+ * sysfs_read_dir_attributes: grabs attributes for the given directory
+ * @sysdir: sysfs directory to open
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_read_dir_attributes(struct sysfs_directory *sysdir)
+{
+ DIR *dir = NULL;
+ struct dirent *dirent = NULL;
+ char file_path[SYSFS_PATH_MAX];
+ int retval = 0;
+
+ if (sysdir == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ dir = opendir(sysdir->path);
+ if (dir == NULL) {
+ dprintf("Error opening directory %s\n", sysdir->path);
+ return -1;
+ }
+ while(((dirent = readdir(dir)) != NULL) && retval == 0) {
+ if (0 == strcmp(dirent->d_name, "."))
+ continue;
+ if (0 == strcmp(dirent->d_name, ".."))
+ continue;
+ memset(file_path, 0, SYSFS_PATH_MAX);
+ safestrcpy(file_path, sysdir->path);
+ safestrcat(file_path, "/");
+ safestrcat(file_path, dirent->d_name);
+ if ((sysfs_path_is_file(file_path)) == 0)
+ retval = add_attribute(sysdir, file_path);
+ }
+ closedir(dir);
+ if (!retval)
+ errno = 0;
+ return(retval);
+}
+
+/**
+ * sysfs_read_dir_links: grabs links in a specific directory
+ * @sysdir: sysfs directory to read links
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_read_dir_links(struct sysfs_directory *sysdir)
+{
+ DIR *dir = NULL;
+ struct dirent *dirent = NULL;
+ char file_path[SYSFS_PATH_MAX];
+ int retval = 0;
+
+ if (sysdir == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ dir = opendir(sysdir->path);
+ if (dir == NULL) {
+ dprintf("Error opening directory %s\n", sysdir->path);
+ return -1;
+ }
+ while(((dirent = readdir(dir)) != NULL) && retval == 0) {
+ if (0 == strcmp(dirent->d_name, "."))
+ continue;
+ if (0 == strcmp(dirent->d_name, ".."))
+ continue;
+ memset(file_path, 0, SYSFS_PATH_MAX);
+ safestrcpy(file_path, sysdir->path);
+ safestrcat(file_path, "/");
+ safestrcat(file_path, dirent->d_name);
+ if ((sysfs_path_is_link(file_path)) == 0) {
+ retval = add_link(sysdir, file_path);
+ if (retval != 0)
+ break;
+ }
+ }
+ closedir(dir);
+ if (!retval)
+ errno = 0;
+ return(retval);
+}
+
+/**
+ * sysfs_read_dir_subdirs: grabs subdirs in a specific directory
+ * @sysdir: sysfs directory to read links
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_read_dir_subdirs(struct sysfs_directory *sysdir)
+{
+ DIR *dir = NULL;
+ struct dirent *dirent = NULL;
+ char file_path[SYSFS_PATH_MAX];
+ int retval = 0;
+
+ if (sysdir == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ dir = opendir(sysdir->path);
+ if (dir == NULL) {
+ dprintf("Error opening directory %s\n", sysdir->path);
+ return -1;
+ }
+ while(((dirent = readdir(dir)) != NULL) && retval == 0) {
+ if (0 == strcmp(dirent->d_name, "."))
+ continue;
+ if (0 == strcmp(dirent->d_name, ".."))
+ continue;
+ memset(file_path, 0, SYSFS_PATH_MAX);
+ safestrcpy(file_path, sysdir->path);
+ safestrcat(file_path, "/");
+ safestrcat(file_path, dirent->d_name);
+ if ((sysfs_path_is_dir(file_path)) == 0)
+ retval = add_subdirectory(sysdir, file_path);
+ }
+ closedir(dir);
+ if (!retval)
+ errno = 0;
+ return(retval);
+}
+
+/**
+ * sysfs_read_directory: grabs attributes, links, and subdirectories
+ * @sysdir: sysfs directory to open
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_read_directory(struct sysfs_directory *sysdir)
+{
+ DIR *dir = NULL;
+ struct dirent *dirent = NULL;
+ struct stat astats;
+ char file_path[SYSFS_PATH_MAX];
+ int retval = 0;
+
+ if (sysdir == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ dir = opendir(sysdir->path);
+ if (dir == NULL) {
+ dprintf("Error opening directory %s\n", sysdir->path);
+ return -1;
+ }
+ while(((dirent = readdir(dir)) != NULL) && retval == 0) {
+ if (0 == strcmp(dirent->d_name, "."))
+ continue;
+ if (0 == strcmp(dirent->d_name, ".."))
+ continue;
+ memset(file_path, 0, SYSFS_PATH_MAX);
+ safestrcpy(file_path, sysdir->path);
+ safestrcat(file_path, "/");
+ safestrcat(file_path, dirent->d_name);
+ if ((lstat(file_path, &astats)) != 0) {
+ dprintf("stat failed\n");
+ continue;
+ }
+ if (S_ISDIR(astats.st_mode))
+ retval = add_subdirectory(sysdir, file_path);
+
+ else if (S_ISLNK(astats.st_mode))
+ retval = add_link(sysdir, file_path);
+
+ else if (S_ISREG(astats.st_mode))
+ retval = add_attribute(sysdir, file_path);
+ }
+ closedir(dir);
+ if (!retval)
+ errno = 0;
+ return(retval);
+}
+
+/**
+ * sysfs_refresh_dir_attributes: Refresh attributes list
+ * @sysdir: directory whose list of attributes to refresh
+ * Returns 0 on success, 1 on failure
+ */
+int sysfs_refresh_dir_attributes(struct sysfs_directory *sysdir)
+{
+ if (sysdir == NULL) {
+ errno = EINVAL;
+ return 1;
+ }
+ if ((sysfs_path_is_dir(sysdir->path)) != 0) {
+ dprintf("Invalid path to directory %s\n", sysdir->path);
+ errno = EINVAL;
+ return 1;
+ }
+ if (sysdir->attributes != NULL) {
+ dlist_destroy(sysdir->attributes);
+ sysdir->attributes = NULL;
+ }
+ if ((sysfs_read_dir_attributes(sysdir)) != 0) {
+ dprintf("Error refreshing attributes for directory %s\n",
+ sysdir->path);
+ return 1;
+ }
+ errno = 0;
+ return 0;
+}
+
+/**
+ * sysfs_refresh_dir_links: Refresh links list
+ * @sysdir: directory whose list of links to refresh
+ * Returns 0 on success, 1 on failure
+ */
+int sysfs_refresh_dir_links(struct sysfs_directory *sysdir)
+{
+ if (sysdir == NULL) {
+ errno = EINVAL;
+ return 1;
+ }
+ if ((sysfs_path_is_dir(sysdir->path)) != 0) {
+ dprintf("Invalid path to directory %s\n", sysdir->path);
+ errno = EINVAL;
+ return 1;
+ }
+ if (sysdir->links != NULL) {
+ dlist_destroy(sysdir->links);
+ sysdir->links = NULL;
+ }
+ if ((sysfs_read_dir_links(sysdir)) != 0) {
+ dprintf("Error refreshing links for directory %s\n",
+ sysdir->path);
+ return 1;
+ }
+ errno = 0;
+ return 0;
+}
+
+/**
+ * sysfs_refresh_dir_subdirs: Refresh subdirs list
+ * @sysdir: directory whose list of subdirs to refresh
+ * Returns 0 on success, 1 on failure
+ */
+int sysfs_refresh_dir_subdirs(struct sysfs_directory *sysdir)
+{
+ if (sysdir == NULL) {
+ errno = EINVAL;
+ return 1;
+ }
+ if ((sysfs_path_is_dir(sysdir->path)) != 0) {
+ dprintf("Invalid path to directory %s\n", sysdir->path);
+ errno = EINVAL;
+ return 1;
+ }
+ if (sysdir->subdirs != NULL) {
+ dlist_destroy(sysdir->subdirs);
+ sysdir->subdirs = NULL;
+ }
+ if ((sysfs_read_dir_subdirs(sysdir)) != 0) {
+ dprintf("Error refreshing subdirs for directory %s\n",
+ sysdir->path);
+ return 1;
+ }
+ errno = 0;
+ return 0;
+}
+
+/**
+ * sysfs_get_directory_attribute: retrieves attribute attrname from current
+ * directory only
+ * @dir: directory to retrieve attribute from
+ * @attrname: name of attribute to look for
+ *
+ * NOTE: Since we know the attribute to look for, this routine looks for the
+ * attribute if it was created _after_ the attrlist was read initially.
+ *
+ * returns sysfs_attribute if found and NULL if not found
+ */
+struct sysfs_attribute *sysfs_get_directory_attribute
+ (struct sysfs_directory *dir, char *attrname)
+{
+ struct sysfs_attribute *attr = NULL;
+ char new_path[SYSFS_PATH_MAX];
+
+ if (dir == NULL || attrname == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (dir->attributes == NULL)
+ if ((sysfs_read_dir_attributes(dir) != 0)
+ || (dir->attributes == NULL))
+ return NULL;
+
+ attr = (struct sysfs_attribute *)dlist_find_custom
+ (dir->attributes, attrname, dir_attribute_name_equal);
+ if (attr != NULL) {
+ if ((sysfs_read_attribute(attr)) != 0) {
+ dprintf("Error reading attribute %s\n", attr->name);
+ return NULL;
+ }
+ } else {
+ memset(new_path, 0, SYSFS_PATH_MAX);
+ safestrcpy(new_path, dir->path);
+ safestrcat(new_path, "/");
+ safestrcat(new_path, attrname);
+ if ((sysfs_path_is_file(new_path)) == 0) {
+ if ((add_attribute(dir, new_path)) == 0) {
+ attr = (struct sysfs_attribute *)
+ dlist_find_custom(dir->attributes,
+ attrname, dir_attribute_name_equal);
+ }
+ }
+ }
+
+ return attr;
+}
+
+/**
+ * sysfs_get_directory_link: retrieves link from one directory list
+ * @dir: directory to retrieve link from
+ * @linkname: name of link to look for
+ * returns reference to sysfs_link if found and NULL if not found
+ */
+struct sysfs_link *sysfs_get_directory_link
+ (struct sysfs_directory *dir, char *linkname)
+{
+ if (dir == NULL || linkname == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+ if (dir->links == NULL) {
+ if ((sysfs_read_dir_links(dir) != 0) || (dir->links == NULL))
+ return NULL;
+ } else {
+ if ((sysfs_refresh_dir_links(dir)) != 0)
+ return NULL;
+ }
+
+ return (struct sysfs_link *)dlist_find_custom(dir->links,
+ linkname, dir_link_name_equal);
+}
+
+/**
+ * sysfs_get_subdirectory: retrieves subdirectory by name.
+ * @dir: directory to search for subdirectory.
+ * @subname: subdirectory name to get.
+ * returns reference to subdirectory or NULL if not found
+ */
+struct sysfs_directory *sysfs_get_subdirectory(struct sysfs_directory *dir,
+ char *subname)
+{
+ struct sysfs_directory *sub = NULL, *cursub = NULL;
+
+ if (dir == NULL || subname == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (dir->subdirs == NULL)
+ if (sysfs_read_dir_subdirs(dir) != 0)
+ return NULL;
+
+ sub = (struct sysfs_directory *)dlist_find_custom(dir->subdirs,
+ subname, dir_subdir_name_equal);
+ if (sub != NULL)
+ return sub;
+
+ if (dir->subdirs != NULL) {
+ dlist_for_each_data(dir->subdirs, cursub,
+ struct sysfs_directory) {
+ if (cursub->subdirs == NULL) {
+ if (sysfs_read_dir_subdirs(cursub) != 0)
+ continue;
+ if (cursub->subdirs == NULL)
+ continue;
+ }
+ sub = sysfs_get_subdirectory(cursub, subname);
+ if (sub != NULL)
+ return sub;
+ }
+ }
+ return NULL;
+}
+
+/**
+ * sysfs_get_subdirectory_link: looks through all subdirs for specific link.
+ * @dir: directory and subdirectories to search for link.
+ * @linkname: link name to get.
+ * returns reference to link or NULL if not found
+ */
+struct sysfs_link *sysfs_get_subdirectory_link(struct sysfs_directory *dir,
+ char *linkname)
+{
+ struct sysfs_directory *cursub = NULL;
+ struct sysfs_link *ln = NULL;
+
+ if (dir == NULL || linkname == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ ln = sysfs_get_directory_link(dir, linkname);
+ if (ln != NULL)
+ return ln;
+
+ if (dir->subdirs == NULL)
+ if (sysfs_read_dir_subdirs(dir) != 0)
+ return NULL;
+
+ if (dir->subdirs != NULL) {
+ dlist_for_each_data(dir->subdirs, cursub,
+ struct sysfs_directory) {
+ ln = sysfs_get_subdirectory_link(cursub, linkname);
+ if (ln != NULL)
+ return ln;
+ }
+ }
+ return NULL;
+}
+
+/**
+ * sysfs_get_dir_attributes: returns dlist of directory attributes
+ * @dir: directory to retrieve attributes from
+ * returns dlist of attributes or NULL
+ */
+struct dlist *sysfs_get_dir_attributes(struct sysfs_directory *dir)
+{
+ if (dir == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (dir->attributes == NULL) {
+ if (sysfs_read_dir_attributes(dir) != 0)
+ return NULL;
+ }
+
+ return (dir->attributes);
+}
+
+/**
+ * sysfs_get_dir_links: returns dlist of directory links
+ * @dir: directory to return links for
+ * returns dlist of links or NULL
+ */
+struct dlist *sysfs_get_dir_links(struct sysfs_directory *dir)
+{
+ if (dir == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (dir->links == NULL) {
+ if (sysfs_read_dir_links(dir) != 0)
+ return NULL;
+ }
+
+ return (dir->links);
+}
+
+/**
+ * sysfs_get_dir_subdirs: returns dlist of directory subdirectories
+ * @dir: directory to return subdirs for
+ * returns dlist of subdirs or NULL
+ */
+struct dlist *sysfs_get_dir_subdirs(struct sysfs_directory *dir)
+{
+ if (dir == NULL) {
+ errno = EINVAL;
+ return NULL;
+ }
+
+ if (dir->subdirs == NULL) {
+ if (sysfs_read_dir_subdirs(dir) != 0)
+ return NULL;
+ }
+
+ return (dir->subdirs);
+}
Added: multipath-tools/upstream/current/libsysfs/sysfs_utils.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/libsysfs/sysfs_utils.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,487 @@
+/*
+ * sysfs_utils.c
+ *
+ * System utility functions for libsysfs
+ *
+ * Copyright (C) IBM Corp. 2003
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+#include "sysfs/libsysfs.h"
+#include "sysfs.h"
+#ifndef __KLIBC__
+#include <mntent.h>
+#endif
+
+static int sort_char(void *new_elem, void *old_elem)
+{
+ return ((strncmp((char *)new_elem, (char *)old_elem,
+ strlen((char *)new_elem))) < 0 ? 1 : 0);
+}
+
+/**
+ * sysfs_remove_trailing_slash: Removes any trailing '/' in the given path
+ * @path: Path to look for the trailing '/'
+ * Returns 0 on success 1 on error
+ */
+int sysfs_remove_trailing_slash(char *path)
+{
+ char *c = NULL;
+
+ if (path == NULL) {
+ errno = EINVAL;
+ return 1;
+ }
+ c = strrchr(path, '/');
+ if (c == NULL) {
+ dprintf("Invalid path %s\n", path);
+ errno = EINVAL;
+ return 1;
+ }
+ if (*(c+1) == '\0')
+ *c = '\0';
+ return 0;
+}
+
+/**
+ * sysfs_get_fs_mnt_path: Gets the mount point for specified filesystem.
+ * @fs_type: filesystem type to retrieve mount point
+ * @mnt_path: place to put the retrieved mount path
+ * @len: size of mnt_path
+ * returns 0 with success and -1 with error.
+ */
+static int sysfs_get_fs_mnt_path(const char *fs_type,
+ char *mnt_path, size_t len)
+{
+#ifdef __KLIBC__
+ safestrcpymax(mnt_path, "/sys", len);
+ return 0;
+#else
+ FILE *mnt;
+ struct mntent *mntent;
+ int ret = 0;
+ size_t dirlen = 0;
+
+ /* check arg */
+ if (fs_type == NULL || mnt_path == NULL || len == 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ if ((mnt = setmntent(SYSFS_PROC_MNTS, "r")) == NULL) {
+ dprintf("Error getting mount information\n");
+ return -1;
+ }
+ while (ret == 0 && dirlen == 0 && (mntent = getmntent(mnt)) != NULL) {
+ if (strcmp(mntent->mnt_type, fs_type) == 0) {
+ dirlen = strlen(mntent->mnt_dir);
+ if (dirlen <= (len - 1)) {
+ safestrcpymax(mnt_path, mntent->mnt_dir, len);
+ } else {
+ dprintf("Error - mount path too long\n");
+ ret = -1;
+ }
+ }
+ }
+ endmntent(mnt);
+ if (dirlen == 0 && ret == 0) {
+ dprintf("Filesystem %s not found!\n", fs_type);
+ errno = EINVAL;
+ ret = -1;
+ }
+ if ((sysfs_remove_trailing_slash(mnt_path)) != 0)
+ ret = -1;
+
+ return ret;
+#endif
+}
+
+/*
+ * sysfs_get_mnt_path: Gets the sysfs mount point.
+ * @mnt_path: place to put "sysfs" mount point
+ * @len: size of mnt_path
+ * returns 0 with success and -1 with error.
+ */
+int sysfs_get_mnt_path(char *mnt_path, size_t len)
+{
+ char *sysfs_path = NULL;
+ int ret = 0;
+
+ if (mnt_path == NULL || len == 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ sysfs_path = getenv(SYSFS_PATH_ENV);
+ if (sysfs_path != NULL) {
+ safestrcpymax(mnt_path, sysfs_path, len);
+ if ((sysfs_remove_trailing_slash(mnt_path)) != 0)
+ return 1;
+ } else
+ ret = sysfs_get_fs_mnt_path(SYSFS_FSTYPE_NAME, mnt_path, len);
+
+ return ret;
+}
+
+/**
+ * sysfs_get_name_from_path: returns last name from a "/" delimited path
+ * @path: path to get name from
+ * @name: where to put name
+ * @len: size of name
+ */
+int sysfs_get_name_from_path(const char *path, char *name, size_t len)
+{
+ char tmp[SYSFS_PATH_MAX];
+ char *n = NULL;
+
+ if (path == NULL || name == NULL || len == 0) {
+ errno = EINVAL;
+ return -1;
+ }
+ memset(tmp, 0, SYSFS_PATH_MAX);
+ safestrcpy(tmp, path);
+ n = strrchr(tmp, '/');
+ if (n == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ if (*(n+1) == '\0') {
+ *n = '\0';
+ n = strrchr(tmp, '/');
+ if (n == NULL) {
+ errno = EINVAL;
+ return -1;
+ }
+ }
+ n++;
+ safestrcpymax(name, n, len);
+ return 0;
+}
+
+/**
+ * sysfs_get_link: returns link source
+ * @path: symbolic link's path
+ * @target: where to put name
+ * @len: size of name
+ */
+int sysfs_get_link(const char *path, char *target, size_t len)
+{
+ char devdir[SYSFS_PATH_MAX];
+ char linkpath[SYSFS_PATH_MAX];
+ char temp_path[SYSFS_PATH_MAX];
+ char *d = NULL, *s = NULL;
+ int slashes = 0, count = 0;
+
+ if (path == NULL || target == NULL || len == 0) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ memset(devdir, 0, SYSFS_PATH_MAX);
+ memset(linkpath, 0, SYSFS_PATH_MAX);
+ memset(temp_path, 0, SYSFS_PATH_MAX);
+ safestrcpy(devdir, path);
+
+ if ((readlink(path, linkpath, SYSFS_PATH_MAX)) < 0) {
+ return -1;
+ }
+ d = linkpath;
+ /*
+ * Three cases here:
+ * 1. relative path => format ../..
+ * 2. absolute path => format /abcd/efgh
+ * 3. relative path _from_ this dir => format abcd/efgh
+ */
+ switch (*d) {
+ case '.':
+ /*
+ * handle the case where link is of type ./abcd/xxx
+ */
+ safestrcpy(temp_path, devdir);
+ if (*(d+1) == '/')
+ d += 2;
+ else if (*(d+1) == '.')
+ goto parse_path;
+ s = strrchr(temp_path, '/');
+ if (s != NULL) {
+ *(s+1) = '\0';
+ safestrcat(temp_path, d);
+ } else {
+ safestrcpy(temp_path, d);
+ }
+ safestrcpymax(target, temp_path, len);
+ break;
+ /*
+ * relative path
+ * getting rid of leading "../.."
+ */
+parse_path:
+ while (*d == '/' || *d == '.') {
+ if (*d == '/')
+ slashes++;
+ d++;
+ }
+ d--;
+ s = &devdir[strlen(devdir)-1];
+ while (s != NULL && count != (slashes+1)) {
+ s--;
+ if (*s == '/')
+ count++;
+ }
+ safestrcpymax(s, d, (SYSFS_PATH_MAX-strlen(devdir)));
+ safestrcpymax(target, devdir, len);
+ break;
+ case '/':
+ /* absolute path - copy as is */
+ safestrcpymax(target, linkpath, len);
+ break;
+ default:
+ /* relative path from this directory */
+ safestrcpy(temp_path, devdir);
+ s = strrchr(temp_path, '/');
+ if (s != NULL) {
+ *(s+1) = '\0';
+ safestrcat(temp_path, linkpath);
+ } else {
+ safestrcpy(temp_path, linkpath);
+ }
+ safestrcpymax(target, temp_path, len);
+ }
+ return 0;
+}
+
+/**
+ * sysfs_del_name: free function for sysfs_open_subsystem_list
+ * @name: memory area to be freed
+ */
+static void sysfs_del_name(void *name)
+{
+ free(name);
+}
+
+
+/**
+ * sysfs_close_list: generic list free routine
+ * @list: dlist to free
+ * Returns nothing
+ */
+void sysfs_close_list(struct dlist *list)
+{
+ if (list != NULL)
+ dlist_destroy(list);
+}
+
+/**
+ * sysfs_open_subsystem_list: gets a list of all supported "name" subsystem
+ * details from the system
+ * @name: name of the subsystem, eg., "bus", "class", "devices"
+ * Returns a dlist of supported names or NULL if subsystem not supported
+ */
+struct dlist *sysfs_open_subsystem_list(char *name)
+{
+ char sysfs_path[SYSFS_PATH_MAX], *subsys_name = NULL;
+ char *c = NULL;
+ struct sysfs_directory *dir = NULL, *cur = NULL;
+ struct dlist *list = NULL;
+
+ if (name == NULL)
+ return NULL;
+
+ if (sysfs_get_mnt_path(sysfs_path, SYSFS_PATH_MAX) != 0) {
+ dprintf("Error getting sysfs mount point\n");
+ return NULL;
+ }
+
+ safestrcat(sysfs_path, "/");
+ safestrcat(sysfs_path, name);
+ dir = sysfs_open_directory(sysfs_path);
+ if (dir == NULL) {
+ dprintf("Error opening sysfs_directory at %s\n", sysfs_path);
+ return NULL;
+ }
+
+ if ((sysfs_read_dir_subdirs(dir)) != 0) {
+ dprintf("Error reading sysfs_directory at %s\n", sysfs_path);
+ sysfs_close_directory(dir);
+ return NULL;
+ }
+
+ if (dir->subdirs != NULL) {
+ list = dlist_new_with_delete(SYSFS_NAME_LEN,
+ sysfs_del_name);
+ if (list == NULL) {
+ dprintf("Error creating list\n");
+ sysfs_close_directory(dir);
+ return NULL;
+ }
+
+ dlist_for_each_data(dir->subdirs, cur,
+ struct sysfs_directory) {
+ subsys_name = (char *)calloc(1, SYSFS_NAME_LEN);
+ safestrcpymax(subsys_name, cur->name, SYSFS_NAME_LEN);
+ dlist_unshift_sorted(list, subsys_name, sort_char);
+ }
+ }
+ sysfs_close_directory(dir);
+ /*
+ * We are now considering "block" as a "class". Hence, if the subsys
+ * name requested here is "class", verify if "block" is supported on
+ * this system and return the same.
+ */
+ if (strcmp(name, SYSFS_CLASS_NAME) == 0) {
+ c = strstr(sysfs_path, SYSFS_CLASS_NAME);
+ if (c == NULL)
+ goto out;
+ *c = '\0';
+ safestrcpymax(c, SYSFS_BLOCK_NAME,
+ sizeof(sysfs_path) - strlen(sysfs_path));
+ if ((sysfs_path_is_dir(sysfs_path)) == 0) {
+ subsys_name = (char *)calloc(1, SYSFS_NAME_LEN);
+ safestrcpymax(subsys_name, SYSFS_BLOCK_NAME,
+ SYSFS_NAME_LEN);
+ dlist_unshift_sorted(list, subsys_name, sort_char);
+ }
+ }
+out:
+ return list;
+}
+
+
+/**
+ * sysfs_open_bus_devices_list: gets a list of all devices on "name" bus
+ * @name: name of the subsystem, eg., "pci", "scsi", "usb"
+ * Returns a dlist of supported names or NULL if subsystem not supported
+ */
+struct dlist *sysfs_open_bus_devices_list(char *name)
+{
+ char sysfs_path[SYSFS_PATH_MAX], *device_name = NULL;
+ struct sysfs_directory *dir = NULL;
+ struct sysfs_link *cur = NULL;
+ struct dlist *list = NULL;
+
+ if (name == NULL)
+ return NULL;
+
+ if (sysfs_get_mnt_path(sysfs_path, SYSFS_PATH_MAX) != 0) {
+ dprintf("Error getting sysfs mount point\n");
+ return NULL;
+ }
+
+ safestrcat(sysfs_path, "/");
+ safestrcat(sysfs_path, SYSFS_BUS_NAME);
+ safestrcat(sysfs_path, "/");
+ safestrcat(sysfs_path, name);
+ safestrcat(sysfs_path, "/");
+ safestrcat(sysfs_path, SYSFS_DEVICES_NAME);
+ dir = sysfs_open_directory(sysfs_path);
+ if (dir == NULL) {
+ dprintf("Error opening sysfs_directory at %s\n", sysfs_path);
+ return NULL;
+ }
+
+ if ((sysfs_read_dir_links(dir)) != 0) {
+ dprintf("Error reading sysfs_directory at %s\n", sysfs_path);
+ sysfs_close_directory(dir);
+ return NULL;
+ }
+
+ if (dir->links != NULL) {
+ list = dlist_new_with_delete(SYSFS_NAME_LEN,
+ sysfs_del_name);
+ if (list == NULL) {
+ dprintf("Error creating list\n");
+ sysfs_close_directory(dir);
+ return NULL;
+ }
+
+ dlist_for_each_data(dir->links, cur,
+ struct sysfs_link) {
+ device_name = (char *)calloc(1, SYSFS_NAME_LEN);
+ safestrcpymax(device_name, cur->name, SYSFS_NAME_LEN);
+ dlist_unshift_sorted(list, device_name, sort_char);
+ }
+ }
+ sysfs_close_directory(dir);
+ return list;
+}
+
+/**
+ * sysfs_path_is_dir: Check if the path supplied points to a directory
+ * @path: path to validate
+ * Returns 0 if path points to dir, 1 otherwise
+ */
+int sysfs_path_is_dir(const char *path)
+{
+ struct stat astats;
+
+ if (path == NULL) {
+ errno = EINVAL;
+ return 1;
+ }
+ if ((lstat(path, &astats)) != 0) {
+ dprintf("stat() failed\n");
+ return 1;
+ }
+ if (S_ISDIR(astats.st_mode))
+ return 0;
+
+ return 1;
+}
+
+/**
+ * sysfs_path_is_link: Check if the path supplied points to a link
+ * @path: path to validate
+ * Returns 0 if path points to link, 1 otherwise
+ */
+int sysfs_path_is_link(const char *path)
+{
+ struct stat astats;
+
+ if (path == NULL) {
+ errno = EINVAL;
+ return 1;
+ }
+ if ((lstat(path, &astats)) != 0) {
+ dprintf("stat() failed\n");
+ return 1;
+ }
+ if (S_ISLNK(astats.st_mode))
+ return 0;
+
+ return 1;
+}
+
+/**
+ * sysfs_path_is_file: Check if the path supplied points to a file
+ * @path: path to validate
+ * Returns 0 if path points to file, 1 otherwise
+ */
+int sysfs_path_is_file(const char *path)
+{
+ struct stat astats;
+
+ if (path == NULL) {
+ errno = EINVAL;
+ return 1;
+ }
+ if ((lstat(path, &astats)) != 0) {
+ dprintf("stat() failed\n");
+ return 1;
+ }
+ if (S_ISREG(astats.st_mode))
+ return 0;
+
+ return 1;
+}
Added: multipath-tools/upstream/current/multipath-tools.spec.in
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath-tools.spec.in Fri Mar 4 08:05:19 2005
@@ -0,0 +1,56 @@
+%define _rpmdir rpms
+%define _builddir .
+
+Summary: Tools to manage multipathed devices with the device-mapper.
+Name: multipath-tools
+Version: __VERSION__
+Release: 1
+License: GPL
+Group: Utilities/System
+URL: http://christophe.varoqui.free.fr
+Source: /dev/null
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
+Packager: Christophe Varoqui <christophe.varoqui at free.fr>
+Prefix: /
+Vendor: Starving Linux Artists (tm Brian O'Sullivan)
+ExclusiveOS: linux
+
+%description
+%{name} provides the tools to manage multipathed devices by
+instructing the device-mapper multipath module what to do. The tools
+are :
+* multipath : scan the system for multipathed devices, assembles them
+ and update the device-mapper's maps
+* multipathd : wait for maps events, then execs multipath
+* devmap-name : provides a meaningful device name to udev for devmaps
+* kpartx : maps linear devmaps upon device partitions, which makes
+ multipath maps partionable
+
+%prep
+mkdir -p %{buildroot} %{_rpmdir}
+
+%build
+make
+
+%install
+rm -rf %{buildroot}
+make DESTDIR=%{buildroot} install
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root,-)
+%{prefix}/sbin/devmap_name
+%{prefix}/sbin/multipath
+%{prefix}/sbin/kpartx
+%{prefix}/usr/share/man/man8/devmap_name.8.gz
+%{prefix}/usr/share/man/man8/multipath.8.gz
+%{prefix}/usr/bin/multipathd
+%{prefix}/etc/hotplug.d/scsi/multipath.hotplug
+%{prefix}/etc/init.d/multipathd
+
+
+%changelog
+* Sat May 14 2004 Christophe Varoqui
+- Initial build.
Added: multipath-tools/upstream/current/multipath.conf.annotated
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath.conf.annotated Fri Mar 4 08:05:19 2005
@@ -0,0 +1,344 @@
+#
+# name : defaults
+# desc : multipath-tools default settings
+#
+defaults {
+ #
+ # name : multipath_tool
+ # scope : multipathd
+ # desc : the tool in charge of configuring the multipath device maps
+ # default : "/sbin/multipath -v 0 -S"
+ #
+ multipath_tool "/sbin/multipath -v 0 -S"
+
+ #
+ # name : udev_dir
+ # desc : directory where udev creates its device nodes
+ # default : /udev
+ #
+ udev_dir /dev
+
+ #
+ # name : polling_interval
+ # scope : multipathd
+ # desc : interval between two path checks in seconds
+ # default : 5
+ #
+ polling_interval 10
+
+ #
+ # name : default_selector
+ # scope : multipath
+ # desc : the default path selector algorithm to use
+ # these algorithms are offered by the kernel multipath target
+ # values : "round-robin 0"
+ # default : "round-robin 0"
+ #
+ default_selector "round-robin 0"
+
+ #
+ # name : default_path_grouping_policy
+ # scope : multipath
+ # desc : the default path grouping policy to apply to unspecified
+ # multipaths
+ # default : multibus
+ #
+ default_path_grouping_policy multibus
+
+ #
+ # name : default_getuid_callout
+ # scope : multipath
+ # desc : the default program and args to callout to obtain a unique
+ # path identifier. Absolute path required
+ # default : /sbin/scsi_id -g -u -s
+ #
+ default_getuid_callout "/sbin/scsi_id -g -u -s /block/%n"
+
+ #
+ # name : default_prio_callout
+ # scope : multipath
+ # desc : the default program and args to callout to obtain a path
+ # priority value. The ALUA bits in SPC-3 provide an
+ # exploitable prio value for example
+ # default : /bin/false
+ #
+ default_prio_callout "/bin/false"
+}
+
+#
+# name : devnode_blacklist
+# scope : multipath & multipathd
+# desc : list of device names to discard as not multipath candidates
+# default : cciss, fd, hd, md, dm, sr, scd, st, ram, raw, loop
+#
+devnode_blacklist {
+ devnode c0d
+ devnode c1d
+ devnode c2d
+ devnode ub
+ devnode nbd
+ devnode fd
+ devnode hd
+ devnode md
+ devnode dm
+ devnode sr
+ devnode scd
+ devnode st
+ devnode ram
+ devnode raw
+ devnode loop
+}
+
+#
+# name : multipaths
+# scope : multipath & multipathd
+# desc : list of multipaths finest-grained settings
+#
+multipaths {
+ #
+ # name : multipath
+ # scope : multipath & multipathd
+ # desc : container for settings that apply to one specific multipath
+ #
+ multipath {
+ #
+ # name : wwid
+ # scope : multipath & multipathd
+ # desc : index of the container
+ #
+ wwid 3600508b4000156d700012000000b0000
+
+ #
+ # name : alias
+ # scope : multipath
+ # desc : symbolic name for the multipath
+ #
+ alias yellow
+
+ #
+ # name : path_grouping_policy
+ # scope : multipath
+ # desc : path grouping policy to apply to this multipath
+ # values : failover, multibus, group_by_serial
+ # default : failover
+ #
+ path_grouping_policy multibus
+
+ #
+ # name : path_checker
+ # scope : multipathd
+ # desc : path checking alorithm to use to check path state
+ # values : readsector0, tur
+ # default : readsector0
+ #
+ # path_checker readsector0
+
+ #
+ # name : path_selector
+ # desc : the path selector algorithm to use for this mpath
+ # these algo are offered by the kernel mpath target
+ # values : "round-robin 0"
+ # default : "round-robin 0"
+ #
+ path_selector "round-robin 0"
+ }
+ multipath {
+ wwid 1DEC_____321816758474
+ alias red
+ }
+}
+
+#
+# name : devices
+# scope : multipath & multipathd
+# desc : list of per storage controler settings
+# overrides default settings (device_maps block)
+# overriden by per multipath settings (multipaths block)
+#
+devices {
+ #
+ # name : device
+ # scope : multipath & multipathd
+ # desc : settings for this specific storage controler
+ #
+ device {
+ #
+ # name : vendor, product
+ # scope : multipath & multipathd
+ # desc : index for the block
+ #
+ vendor "COMPAQ "
+ product "HSV110 (C)COMPAQ"
+
+ #
+ # name : path_grouping_policy
+ # scope : multipath
+ # desc : path grouping policy to apply to multipath hosted
+ # by this storage controler
+ # values : failover = 1 path per priority group
+ # multibus = all valid paths in 1 priority
+ # group
+ # group_by_serial = 1 priority group per detected
+ # serial number
+ # default : failover
+ #
+ path_grouping_policy multibus
+
+ #
+ # name : getuid_callout
+ # scope : multipath
+ # desc : the program and args to callout to obtain a unique
+ # path identifier. Absolute path required
+ # default : /sbin/scsi_id -g -u -s
+ #
+ getuid_callout "/sbin/scsi_id -g -u -s /block/%n"
+
+ #
+ # name : prio_callout
+ # scope : multipath
+ # desc : the program and args to callout to obtain a path
+ # weight. Weights are summed for each path group to
+ # determine the next PG to use case of failure.
+ # default : no callout, all paths equals
+ #
+ prio_callout "/sbin/pp_balance_units %d"
+
+ #
+ # name : path_checker
+ # scope : multipathd
+ # desc : path checking alorithm to use to check path state
+ # values : readsector0, tur
+ # default : readsector0
+ #
+ path_checker readsector0
+
+ #
+ # name : path_selector
+ # desc : the path selector algorithm to use for this mpath
+ # these algo are offered by the kernel mpath target
+ # values : "round-robin 0"
+ # default : "round-robin 0"
+ #
+ path_selector "round-robin 0"
+ }
+ device {
+ vendor "COMPAQ "
+ product "MSA1000 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "COMPAQ "
+ product "MSA1000 VOLUME "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "DEC "
+ product "HSG80 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "HP "
+ product "HSV100 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "3PARdata"
+ product "VV "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "DDN "
+ product "SAN DataDirector"
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "FSC "
+ product "CentricStor "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "HITACHI "
+ product "DF400 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "HITACHI "
+ product "DF500 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "HITACHI "
+ product "DF600 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "IBM "
+ product "ProFibre 4000R "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "IBM "
+ product "3542 "
+ path_grouping_policy group_by_serial
+ path_checker tur
+ }
+ device {
+ vendor "SGI "
+ product "TP9100 "
+ vendor "COMPAQ "
+ product "MSA1000 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "SGI "
+ product "TP9300 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "SGI "
+ product "TP9400 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "SGI "
+ product "TP9500 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ # all paths active but with a switchover latency
+ # LSI controlers
+ vendor "STK "
+ product "OPENstorage D280"
+ path_grouping_policy group_by_serial
+ path_checker tur
+ }
+ device {
+ # assymmetric array
+ vendor "SUN "
+ product "StorEdge 3510 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ # symmetric array
+ vendor "SUN "
+ product "T4 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+}
Added: multipath-tools/upstream/current/multipath.conf.synthetic
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath.conf.synthetic Fri Mar 4 08:05:19 2005
@@ -0,0 +1,172 @@
+defaults {
+ multipath_tool "/sbin/multipath -v 0 -S"
+ udev_dir /dev
+ polling_interval 10
+ default_selector "round-robin 0"
+ default_path_grouping_policy multibus
+ default_getuid_callout "/sbin/scsi_id -g -u -s /block/%n"
+ default_prio_callout "/bin/false"
+ default_features "0"
+}
+devnode_blacklist {
+ devnode c0d
+ devnode c1d
+ devnode c2d
+ devnode ub
+ devnode nbd
+ devnode fd
+ devnode hd
+ devnode md
+ devnode dm
+ devnode sr
+ devnode scd
+ devnode st
+ devnode ram
+ devnode raw
+ devnode loop
+}
+multipaths {
+ multipath {
+ wwid 3600508b4000156d700012000000b0000
+ alias yellow
+ path_grouping_policy multibus
+ path_checker readsector0
+ path_selector "round-robin 0"
+ }
+ multipath {
+ wwid 1DEC_____321816758474
+ alias red
+ }
+}
+devices {
+ device {
+ vendor "COMPAQ "
+ product "HSV110 (C)COMPAQ"
+ path_grouping_policy multibus
+ getuid_callout "/sbin/scsi_id -g -u -s /block/%n"
+ path_checker readsector0
+ path_selector "round-robin 0"
+ features "1 queue_if_no_path"
+ hardware_handler "0"
+ }
+ device {
+ vendor "COMPAQ "
+ product "MSA1000 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "COMPAQ "
+ product "MSA1000 VOLUME "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "DEC "
+ product "HSG80 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "HP "
+ product "HSV100 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "3PARdata"
+ product "VV "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "IBM "
+ product "3542 "
+ path_grouping_policy group_by_serial
+ path_checker tur
+ }
+ device {
+ vendor "DDN "
+ product "SAN DataDirector"
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "FSC "
+ product "CentricStor "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "HITACHI "
+ product "DF400 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "HITACHI "
+ product "DF500 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "HITACHI "
+ product "DF600 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "IBM "
+ product "ProFibre 4000R "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "SGI "
+ product "TP9100 "
+ vendor "COMPAQ "
+ product "MSA1000 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "SGI "
+ product "TP9300 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "SGI "
+ product "TP9400 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ vendor "SGI "
+ product "TP9500 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ # all paths active but with a switchover latency
+ # LSI controlers
+ vendor "STK "
+ product "OPENstorage D280"
+ path_grouping_policy group_by_serial
+ path_checker tur
+ }
+ device {
+ # assymmetric array
+ vendor "SUN "
+ product "StorEdge 3510 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+ device {
+ # symmetric array
+ vendor "SUN "
+ product "T4 "
+ path_grouping_policy multibus
+ path_checker tur
+ }
+}
Added: multipath-tools/upstream/current/multipath/.main.c.swo
==============================================================================
Binary file. No diff available.
Added: multipath-tools/upstream/current/multipath/.main.c.swp
==============================================================================
Binary file. No diff available.
Added: multipath-tools/upstream/current/multipath/01_udev
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/01_udev Fri Mar 4 08:05:19 2005
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+cp /sbin/udev $INITRDDIR/sbin/hotplug
+cp /sbin/udevstart $INITRDDIR/sbin/
+cp /bin/mountpoint $INITRDDIR/bin/
+cp /bin/readlink $INITRDDIR/bin/
+
+PROGS="/sbin/udev /sbin/udevstart /bin/mountpoint /bin/readlink"
+LIBS=`ldd $PROGS | grep -v linux-gate.so | sort -u | \
+awk '{print $3}'`
+for i in $LIBS
+do
+ mkdir -p `dirname $INITRDDIR/$i`
+ cp $i $INITRDDIR/$i
+done
+
+#
+# config files
+#
+if [ -d /etc/dev.d ]
+then
+ cp -a /etc/dev.d $INITRDDIR/etc/
+fi
+
+if [ -d /etc/udev ]
+then
+ cp -a /etc/udev $INITRDDIR/etc/
+fi
+
+#
+# run udev from initrd
+#
+cat <<EOF >| $INITRDDIR/scripts/10_udev.sh
+
+cd /
+mount -nt proc proc proc
+mount -nt sysfs sysfs sys
+mount -nt tmpfs tmpfs dev || mount -nt ramfs ramfs dev
+mount -nt tmpfs tmpfs tmp || mount -nt ramfs ramfs tmp
+
+#modprobe dm-mod
+#modprobe dm-multipath
+/sbin/udevstart
+
+umount -n tmp
+umount -n sys
+umount -n proc
+
+sleep 2
+EOF
Added: multipath-tools/upstream/current/multipath/02_multipath
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/02_multipath Fri Mar 4 08:05:19 2005
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# store the multipath tool in the initrd
+# hotplug & udev will take care of calling it when appropriate
+# this tool is statically linked against klibc : no additional libs
+#
+cp /sbin/multipath $INITRDDIR/sbin
+cp /sbin/devmap_name $INITRDDIR/sbin
+cp /sbin/kpartx $INITRDDIR/sbin
+
+#
+# feed the dependencies too
+# scsi_id is dynamicaly linked, so store the libs too
+#
+cp /sbin/scsi_id $INITRDDIR/sbin
+cp /bin/mountpoint $INITRDDIR/bin
+
+PROGS="/sbin/scsi_id /bin/mountpoint"
+LIBS=`ldd $PROGS | grep -v linux-gate.so | sort -u | \
+awk '{print $3}'`
+for i in $LIBS
+do
+ mkdir -p `dirname $INITRDDIR/$i`
+ cp $i $INITRDDIR/$i
+done
+
+#
+# config file ?
+#
+if [ -f /etc/multipath.conf ]
+then
+ cp /etc/multipath.conf $INITRDDIR/etc/
+fi
+
Added: multipath-tools/upstream/current/multipath/Makefile
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/Makefile Fri Mar 4 08:05:19 2005
@@ -0,0 +1,75 @@
+# Makefile
+#
+# Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui at free.fr>
+BUILD = glibc
+
+include ../Makefile.inc
+
+OBJS = pgpolicies.o propsel.o devinfo.o main.o dict.o dmparser.o \
+ $(MULTIPATHLIB)-$(BUILD).a $(CHECKERSLIB)-$(BUILD).a
+
+ifeq ($(strip $(BUILD)),klibc)
+ CFLAGS = ${REQFLAGS} ${OPTFLAGS} -DDEBUG=${DEBUG} \
+ -DVERSION=$(VERSION) -I$(multipathdir) \
+ -I$(libdmdir) -I$(sysfsdir) -I$(checkersdir)
+ OBJS += $(SYSFSLIB)-$(BUILD).a $(DMLIB)-$(BUILD).a
+else
+ CFLAGS = -pipe -g -Wall -Wunused -Wstrict-prototypes \
+ -DDEBUG=$(DEBUG) -I$(multipathdir) -I$(checkersdir) \
+ -DVERSION=$(VERSION)
+ LDFLAGS = -ldevmapper -lsysfs
+endif
+
+EXEC = multipath
+DEBUG = 0
+
+all: $(BUILD)
+
+prepare:
+ rm -f core *.o *.gz
+
+glibc: prepare $(OBJS)
+ $(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
+ $(STRIP) $(EXEC)
+ $(GZIP) $(EXEC).8 > $(EXEC).8.gz
+
+klibc: prepare $(KLIBC) $(OBJS)
+ $(LD) -o $(EXEC) $(CRT0) $(OBJS) $(KLIBC) $(LIBGCC)
+ $(STRIP) $(EXEC)
+ $(GZIP) $(EXEC).8 > $(EXEC).8.gz
+
+$(CHECKERSLIB)-$(BUILD).a:
+ make -C $(checkersdir) BUILD=$(BUILD) $(BUILD)
+
+$(MULTIPATHLIB)-$(BUILD).a:
+ make -C $(multipathdir) BUILD=$(BUILD) $(BUILD)
+
+$(SYSFSLIB)-$(BUILD).a:
+ make -C $(sysfsdir) BUILD=$(BUILD) $(BUILD)
+
+$(DMLIB)-$(BUILD).a:
+ make -C $(libdmdir) BUILD=$(BUILD) $(BUILD)
+
+$(KLIBC):
+ rm -f $(klibcdir)/linux
+ ln -s $(KERNEL_BUILD) $(klibcdir)/linux
+ make -C $(klibcdir)
+
+install:
+ install -d $(DESTDIR)$(bindir)
+ install -m 755 $(EXEC) $(DESTDIR)$(bindir)/
+ install -d $(DESTDIR)/etc/dev.d/block/
+ install -m 755 multipath.dev $(DESTDIR)/etc/dev.d/block/
+ install -d $(DESTDIR)/etc/udev/rules.d
+ install -m 755 multipath.rules $(DESTDIR)/etc/udev/rules.d/
+ install -d $(DESTDIR)$(mandir)
+ install -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
+
+uninstall:
+ rm $(DESTDIR)/etc/dev.d/block/multipath.dev
+ rm $(DESTDIR)/etc/udev/rules.d/multipath.rules
+ rm $(DESTDIR)$(bindir)/$(EXEC)
+ rm $(DESTDIR)$(mandir)/$(EXEC).8.gz
+
+clean:
+ rm -f core *.o $(EXEC) *.gz
Added: multipath-tools/upstream/current/multipath/config.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/config.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,44 @@
+#ifndef _CONFIG_H
+#define _CONFIG_H
+
+#ifndef _VECTOR_H
+#include "vector.h"
+#endif
+
+struct mpentry {
+ int selector_args;
+ int pgpolicy;
+
+ char * wwid;
+ char * selector;
+ char * getuid;
+ char * alias;
+};
+
+struct config {
+ int verbosity;
+ int dry_run;
+ int list;
+ int signal;
+ int pgpolicy_flag;
+ int with_sysfs;
+ int default_selector_args;
+ int default_pgpolicy;
+
+ char * dev;
+ char * udev_dir;
+ char * default_selector;
+ char * default_getuid;
+ char * default_getprio;
+ char * default_features;
+ char * default_hwhandler;
+
+ vector mptable;
+ vector hwtable;
+ vector aliases;
+ vector blist;
+};
+
+struct config * conf;
+
+#endif
Added: multipath-tools/upstream/current/multipath/debug.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/debug.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,5 @@
+#if DEBUG
+#define dbg(format, arg...) fprintf(stderr, format "\n", ##arg)
+#else
+#define dbg(format, arg...) do {} while(0)
+#endif
Added: multipath-tools/upstream/current/multipath/dev_t.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/dev_t.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+#define MINORBITS 20
+#define MINORMASK ((1U << MINORBITS) - 1)
+
+#define MAJOR(dev) ((unsigned int) ((dev) >> MINORBITS))
+#define MINOR(dev) ((unsigned int) ((dev) & MINORMASK))
+#define MKDEV(ma,mi) (((ma) << MINORBITS) | (mi))
+
+#define print_dev_t(buffer, dev) \
+ sprintf((buffer), "%u:%u\n", MAJOR(dev), MINOR(dev))
+
+#define format_dev_t(buffer, dev) \
+ ({ \
+ sprintf(buffer, "%u:%u", MAJOR(dev), MINOR(dev)); \
+ buffer; \
+ })
Added: multipath-tools/upstream/current/multipath/devinfo.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/devinfo.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,455 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <errno.h>
+#include <safe_printf.h>
+
+#include <sysfs/dlist.h>
+#include <sysfs/libsysfs.h>
+#include <memory.h>
+#include <callout.h>
+#include <util.h>
+#include <vector.h>
+#include <structs.h>
+
+#include "sysfs_devinfo.h"
+#include "devinfo.h"
+#include "sg_include.h"
+#include "debug.h"
+#include "config.h"
+#include "propsel.h"
+
+#define readattr(a,b) \
+ sysfs_read_attribute_value(a, b, sizeof(b))
+
+static int
+opennode (char * devt, int mode)
+{
+ char devpath[FILE_NAME_SIZE];
+ unsigned int major;
+ unsigned int minor;
+ int fd;
+
+ sscanf(devt, "%u:%u", &major, &minor);
+
+ /* first, try with udev reverse mappings */
+ if (safe_sprintf(devpath, "%s/reverse/%u:%u",
+ conf->udev_dir, major, minor)) {
+ fprintf(stderr, "devpath too small\n");
+ return -1;
+ }
+ fd = open(devpath, mode);
+
+ if (fd >= 0)
+ return fd;
+
+ /* fallback to temp devnode creation */
+ memset(devpath, 0, FILE_NAME_SIZE);
+
+ if (safe_sprintf(devpath, "/tmp/.multipath.%u.%u.devnode",
+ major, minor)) {
+ fprintf(stderr, "devpath too small\n");
+ return -1;
+ }
+ unlink (devpath);
+ mknod(devpath, S_IFBLK|S_IRUSR|S_IWUSR, makedev(major, minor));
+ fd = open(devpath, mode);
+
+ if (fd < 0)
+ unlink(devpath);
+
+ return fd;
+
+}
+
+static void
+closenode (char * devt, int fd)
+{
+ char devpath[FILE_NAME_SIZE];
+ unsigned int major;
+ unsigned int minor;
+
+ if (fd >= 0) /* as it should always be */
+ close(fd);
+
+ sscanf(devt, "%u:%u", &major, &minor);
+ if (safe_sprintf(devpath, "/tmp/.multipath.%u.%u.devnode",
+ major, minor)) {
+ fprintf(stderr, "devpath too small\n");
+ return;
+ }
+ unlink(devpath);
+}
+
+int
+get_claimed(char *devt)
+{
+ int fd;
+
+ /*
+ * FIXME : O_EXCL always fails ?
+ */
+ fd = opennode(devt, O_RDONLY);
+
+ if (fd < 0)
+ return 1;
+
+ closenode(devt, fd);
+
+ return 0;
+}
+
+extern int
+devt2devname (char *devname, char *devt)
+{
+ struct sysfs_directory * sdir;
+ struct sysfs_directory * devp;
+ char sysfs_path[FILE_NAME_SIZE];
+ char block_path[FILE_NAME_SIZE];
+ char attr_path[FILE_NAME_SIZE];
+ char attr_value[16];
+ int len;
+
+ if (sysfs_get_mnt_path(sysfs_path, FILE_NAME_SIZE)) {
+ fprintf(stderr, "feature available with sysfs only\n");
+ exit(1);
+ }
+
+ if(safe_sprintf(block_path, "%s/block", sysfs_path)) {
+ fprintf(stderr, "block_path too small\n");
+ exit(1);
+ }
+ sdir = sysfs_open_directory(block_path);
+ sysfs_read_directory(sdir);
+
+ dlist_for_each_data (sdir->subdirs, devp, struct sysfs_directory) {
+ if(safe_sprintf(attr_path, "%s/%s/dev",
+ block_path, devp->name)) {
+ fprintf(stderr, "attr_path too small\n");
+ exit(1);
+ }
+ sysfs_read_attribute_value(attr_path, attr_value,
+ sizeof(attr_value));
+
+ len = strlen(attr_value);
+
+ /* discard newline */
+ if (len > 1) len--;
+
+ if (strlen(devt) == len &&
+ strncmp(attr_value, devt, len) == 0) {
+ if(safe_sprintf(attr_path, "%s/%s",
+ block_path, devp->name)) {
+ fprintf(stderr, "attr_path too small\n");
+ exit(1);
+ }
+ sysfs_get_name_from_path(attr_path, devname,
+ FILE_NAME_SIZE);
+ return 0;
+ }
+ }
+ sysfs_close_directory(sdir);
+ return 1;
+}
+
+static int
+do_inq(int sg_fd, int cmddt, int evpd, unsigned int pg_op,
+ void *resp, int mx_resp_len, int noisy)
+{
+ unsigned char inqCmdBlk[INQUIRY_CMDLEN] =
+ { INQUIRY_CMD, 0, 0, 0, 0, 0 };
+ unsigned char sense_b[SENSE_BUFF_LEN];
+ struct sg_io_hdr io_hdr;
+
+ if (cmddt)
+ inqCmdBlk[1] |= 2;
+ if (evpd)
+ inqCmdBlk[1] |= 1;
+ inqCmdBlk[2] = (unsigned char) pg_op;
+ inqCmdBlk[3] = (unsigned char)((mx_resp_len >> 8) & 0xff);
+ inqCmdBlk[4] = (unsigned char) (mx_resp_len & 0xff);
+ memset(&io_hdr, 0, sizeof (struct sg_io_hdr));
+ io_hdr.interface_id = 'S';
+ io_hdr.cmd_len = sizeof (inqCmdBlk);
+ io_hdr.mx_sb_len = sizeof (sense_b);
+ io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
+ io_hdr.dxfer_len = mx_resp_len;
+ io_hdr.dxferp = resp;
+ io_hdr.cmdp = inqCmdBlk;
+ io_hdr.sbp = sense_b;
+ io_hdr.timeout = DEF_TIMEOUT;
+
+ if (ioctl(sg_fd, SG_IO, &io_hdr) < 0)
+ return -1;
+
+ /* treat SG_ERR here to get rid of sg_err.[ch] */
+ io_hdr.status &= 0x7e;
+ if ((0 == io_hdr.status) && (0 == io_hdr.host_status) &&
+ (0 == io_hdr.driver_status))
+ return 0;
+ if ((SCSI_CHECK_CONDITION == io_hdr.status) ||
+ (SCSI_COMMAND_TERMINATED == io_hdr.status) ||
+ (SG_ERR_DRIVER_SENSE == (0xf & io_hdr.driver_status))) {
+ if (io_hdr.sbp && (io_hdr.sb_len_wr > 2)) {
+ int sense_key;
+ unsigned char * sense_buffer = io_hdr.sbp;
+ if (sense_buffer[0] & 0x2)
+ sense_key = sense_buffer[1] & 0xf;
+ else
+ sense_key = sense_buffer[2] & 0xf;
+ if(RECOVERED_ERROR == sense_key)
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int
+get_serial (char * str, char * devt)
+{
+ int fd;
+ int len;
+ char buff[MX_ALLOC_LEN + 1];
+
+ fd = opennode(devt, O_RDONLY);
+
+ if (fd < 0)
+ return 0;
+
+ if (0 == do_inq(fd, 0, 1, 0x80, buff, MX_ALLOC_LEN, 0)) {
+ len = buff[3];
+ if (len > 0) {
+ memcpy(str, buff + 4, len);
+ buff[len] = '\0';
+ }
+ close(fd);
+ return 1;
+ }
+
+ closenode(devt, fd);
+ return 0;
+}
+
+extern int
+sysfs_devinfo(struct path * curpath)
+{
+ char attr_path[FILE_NAME_SIZE];
+ char attr_buff[FILE_NAME_SIZE];
+ char sysfs_path[FILE_NAME_SIZE];
+
+ if (sysfs_get_mnt_path(sysfs_path, FILE_NAME_SIZE)) {
+ fprintf(stderr, "need sysfs mounted : out\n");
+ return 1;
+ }
+
+ if (sysfs_get_vendor(sysfs_path, curpath->dev,
+ curpath->vendor_id, SCSI_VENDOR_SIZE))
+ return 1;
+ dbg("vendor = %s", curpath->vendor_id);
+
+ if (sysfs_get_model(sysfs_path, curpath->dev,
+ curpath->product_id, SCSI_PRODUCT_SIZE))
+ return 1;
+ dbg("product = %s", curpath->product_id);
+
+ if (sysfs_get_rev(sysfs_path, curpath->dev,
+ curpath->rev, SCSI_REV_SIZE))
+ return 1;
+ dbg("rev = %s", curpath->rev);
+
+ if (sysfs_get_dev(sysfs_path, curpath->dev,
+ curpath->dev_t, BLK_DEV_SIZE))
+ return 1;
+ dbg("dev_t = %s", curpath->dev_t);
+
+ curpath->size = sysfs_get_size(sysfs_path, curpath->dev);
+
+ if (curpath->size == 0)
+ return 1;
+ dbg("size = %lu", curpath->size);
+
+ /*
+ * host / bus / target / lun
+ */
+ if(safe_sprintf(attr_path, "%s/block/%s/device",
+ sysfs_path, curpath->dev)) {
+ fprintf(stderr, "attr_path too small\n");
+ return 1;
+ }
+ if (0 > sysfs_get_link(attr_path, attr_buff, sizeof(attr_buff)))
+ return 1;
+ basename(attr_buff, attr_path);
+ sscanf(attr_path, "%i:%i:%i:%i",
+ &curpath->sg_id.host_no,
+ &curpath->sg_id.channel,
+ &curpath->sg_id.scsi_id,
+ &curpath->sg_id.lun);
+ dbg("h:b:t:l = %i:%i:%i:%i",
+ curpath->sg_id.host_no,
+ curpath->sg_id.channel,
+ curpath->sg_id.scsi_id,
+ curpath->sg_id.lun);
+
+ /*
+ * target node name
+ */
+ if(safe_sprintf(attr_path,
+ "%s/class/fc_transport/target%i:%i:%i/node_name",
+ sysfs_path,
+ curpath->sg_id.host_no,
+ curpath->sg_id.channel,
+ curpath->sg_id.scsi_id)) {
+ fprintf(stderr, "attr_path too small\n");
+ return 1;
+ }
+ if (0 <= readattr(attr_path, attr_buff) && strlen(attr_buff) > 0)
+ strncpy(curpath->tgt_node_name, attr_buff,
+ strlen(attr_buff) - 1);
+ dbg("tgt_node_name = %s", curpath->tgt_node_name);
+
+ return 0;
+}
+
+static char *
+apply_format (char * string, int maxsize, struct path * pp)
+{
+ char * pos;
+ char * dst;
+ char * p;
+ int len;
+ int free;
+
+ if (!string)
+ return NULL;
+
+ dst = zalloc(maxsize);
+
+ if (!dst)
+ return NULL;
+
+ p = dst;
+ pos = strchr(string, '%');
+ free = maxsize;
+
+ if (!pos)
+ return string;
+
+ len = (int) (pos - string) + 1;
+ free -= len;
+
+ if (free < 2)
+ return NULL;
+
+ snprintf(p, len, "%s", string);
+ p += len - 1;
+ pos++;
+
+ switch (*pos) {
+ case 'n':
+ len = strlen(pp->dev) + 1;
+ free -= len;
+
+ if (free < 2)
+ return NULL;
+
+ snprintf(p, len, "%s", pp->dev);
+ p += len - 1;
+ break;
+ case 'd':
+ len = strlen(pp->dev_t) + 1;
+ free -= len;
+
+ if (free < 2)
+ return NULL;
+
+ snprintf(p, len, "%s", pp->dev_t);
+ p += len - 1;
+ break;
+ default:
+ break;
+ }
+ pos++;
+
+ if (!*pos)
+ return dst;
+
+ len = strlen(pos) + 1;
+ free -= len;
+
+ if (free < 2)
+ return NULL;
+
+ snprintf(p, len, "%s", pos);
+ dbg("reformated callout = %s", dst);
+ return dst;
+}
+
+extern int
+devinfo (struct path *pp)
+{
+ char * buff;
+ char prio[16];
+
+ dbg("===== path %s =====", pp->dev);
+
+ /*
+ * fetch info available in sysfs
+ */
+ if (sysfs_devinfo(pp))
+ return 1;
+
+ /*
+ * then those not available through sysfs
+ */
+ get_serial(pp->serial, pp->dev_t);
+ dbg("serial = %s", pp->serial);
+ pp->claimed = get_claimed(pp->dev_t);
+ dbg("claimed = %i", pp->claimed);
+
+ /*
+ * get path state, no message collection, no context
+ */
+ select_checkfn(pp);
+ pp->state = pp->checkfn(pp->dev_t, NULL, NULL);
+ dbg("state = %i", pp->state);
+
+ /*
+ * get path prio
+ */
+ select_getprio(pp);
+ buff = apply_format(pp->getprio, CALLOUT_MAX_SIZE, pp);
+
+ if (!buff)
+ pp->priority = 1;
+ else if (execute_program(buff, prio, 16)) {
+ dbg("error calling out %s", buff);
+ pp->priority = 1;
+ } else
+ pp->priority = atoi(prio);
+
+ dbg("prio = %u", pp->priority);
+
+ /*
+ * get path uid
+ */
+ select_getuid(pp);
+ buff = apply_format(pp->getuid, CALLOUT_MAX_SIZE, pp);
+
+ if (buff && execute_program(buff, pp->wwid, WWID_SIZE) == 0) {
+ dbg("uid = %s (callout)", pp->wwid);
+ return 0;
+ }
+
+ /*
+ * no wwid : blank for safety
+ */
+ dbg("uid = 0x0 (unable to fetch)");
+ memset(pp->wwid, 0, WWID_SIZE);
+ return 1;
+}
+
Added: multipath-tools/upstream/current/multipath/devinfo.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/devinfo.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,29 @@
+#define INQUIRY_CMDLEN 6
+#define INQUIRY_CMD 0x12
+#define SENSE_BUFF_LEN 32
+#define DEF_TIMEOUT 60000
+#define RECOVERED_ERROR 0x01
+#define MX_ALLOC_LEN 255
+#define BLKGETSIZE _IO(0x12,96)
+#define TUR_CMD_LEN 6
+
+/*
+ * exerpt from sg_err.h
+ */
+#define SCSI_CHECK_CONDITION 0x2
+#define SCSI_COMMAND_TERMINATED 0x22
+#define SG_ERR_DRIVER_SENSE 0x08
+
+#include "main.h"
+
+/*
+ * prototypes
+ */
+void basename (char *, char *);
+int get_serial (char *, char *);
+int sysfs_devinfo (struct path *);
+//unsigned long get_disk_size (char *);
+int do_tur (char *);
+int get_claimed(char *);
+int devt2devname (char *, char *);
+int devinfo (struct path *);
Added: multipath-tools/upstream/current/multipath/dict.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/dict.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,266 @@
+#include <checkers.h>
+#include <vector.h>
+#include <hwtable.h>
+#include <structs.h>
+
+#include "parser.h"
+#include "config.h"
+#include "pgpolicies.h"
+#include "debug.h"
+#include "memory.h"
+
+/*
+ * default block handlers
+ */
+static void
+udev_dir_handler(vector strvec)
+{
+ conf->udev_dir = set_value(strvec);
+}
+
+static void
+def_selector_handler(vector strvec)
+{
+ conf->default_selector = set_value(strvec);
+}
+
+static void
+def_pgpolicy_handler(vector strvec)
+{
+ char * buff;
+
+ buff = set_value(strvec);
+ conf->default_pgpolicy = get_pgpolicy_id(buff);
+ free(buff);
+}
+
+static void
+def_getuid_callout_handler(vector strvec)
+{
+ conf->default_getuid = set_value(strvec);
+}
+
+static void
+def_prio_callout_handler(vector strvec)
+{
+ conf->default_getprio = set_value(strvec);
+}
+
+static void
+def_features_handler(vector strvec)
+{
+ conf->default_features = set_value(strvec);
+}
+
+/*
+ * blacklist block handlers
+ */
+static void
+blacklist_handler(vector strvec)
+{
+ conf->blist = vector_alloc();
+}
+
+static void
+devnode_handler(vector strvec)
+{
+ char * buff;
+
+ buff = set_value(strvec);
+ vector_alloc_slot(conf->blist);
+ vector_set_slot(conf->blist, buff);
+}
+
+/*
+ * devices block handlers
+ */
+static void
+devices_handler(vector strvec)
+{
+ conf->hwtable = vector_alloc();
+}
+
+static void
+device_handler(vector strvec)
+{
+ struct hwentry * hwe;
+
+ vector_alloc_slot(conf->hwtable);
+ hwe = zalloc(sizeof(struct hwentry));
+ vector_set_slot(conf->hwtable, hwe);
+}
+
+static void
+vendor_handler(vector strvec)
+{
+ struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
+
+ hwe->vendor = set_value(strvec);
+}
+
+static void
+product_handler(vector strvec)
+{
+ struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
+
+ hwe->product = set_value(strvec);
+}
+
+static void
+hw_pgpolicy_handler(vector strvec)
+{
+ char * buff;
+ struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
+
+ buff = set_value(strvec);
+ hwe->pgpolicy = get_pgpolicy_id(buff);
+ free(buff);
+}
+
+static void
+hw_getuid_callout_handler(vector strvec)
+{
+ struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
+
+ hwe->getuid = set_value(strvec);
+}
+
+static void
+hw_selector_handler(vector strvec)
+{
+ struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
+
+ hwe->selector = set_value(strvec);
+}
+
+static void
+hw_path_checker_handler(vector strvec)
+{
+ char * buff;
+ struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
+
+ buff = set_value(strvec);
+ hwe->checker_index = get_checker_id(buff);
+
+ free(buff);
+}
+
+static void
+hw_features_handler(vector strvec)
+{
+ struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
+
+ hwe->features = set_value(strvec);
+}
+
+static void
+hw_handler_handler(vector strvec)
+{
+ struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
+
+ hwe->hwhandler = set_value(strvec);
+}
+
+static void
+prio_callout_handler(vector strvec)
+{
+ struct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);
+
+ hwe->getprio = set_value(strvec);
+}
+
+/*
+ * multipaths block handlers
+ */
+static void
+multipaths_handler(vector strvec)
+{
+ conf->mptable = vector_alloc();
+}
+
+static void
+multipath_handler(vector strvec)
+{
+ struct mpentry * mpe;
+
+ vector_alloc_slot(conf->mptable);
+ mpe = zalloc(sizeof(struct mpentry));
+ vector_set_slot(conf->mptable, mpe);
+}
+
+static void
+wwid_handler(vector strvec)
+{
+ struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
+
+ mpe->wwid = set_value(strvec);
+}
+
+static void
+alias_handler(vector strvec)
+{
+ struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
+
+ mpe->alias = set_value(strvec);
+}
+
+static void
+mp_pgpolicy_handler(vector strvec)
+{
+ char * buff;
+ struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
+
+ buff = set_value(strvec);
+ mpe->pgpolicy = get_pgpolicy_id(buff);
+ free(buff);
+}
+
+static void
+mp_selector_handler(vector strvec)
+{
+ struct mpentry * mpe = VECTOR_LAST_SLOT(conf->mptable);
+
+ mpe->selector = set_value(strvec);
+}
+
+vector
+init_keywords(void)
+{
+ keywords = vector_alloc();
+
+ install_keyword_root("defaults", NULL);
+ install_keyword("udev_dir", &udev_dir_handler);
+ install_keyword("default_selector", &def_selector_handler);
+ install_keyword("default_path_grouping_policy", &def_pgpolicy_handler);
+ install_keyword("default_getuid_callout", &def_getuid_callout_handler);
+ install_keyword("default_prio_callout", &def_prio_callout_handler);
+ install_keyword("default_features", &def_features_handler);
+
+ install_keyword_root("devnode_blacklist", &blacklist_handler);
+ install_keyword("devnode", &devnode_handler);
+
+ install_keyword_root("devices", &devices_handler);
+ install_keyword("device", &device_handler);
+ install_sublevel();
+ install_keyword("vendor", &vendor_handler);
+ install_keyword("product", &product_handler);
+ install_keyword("path_grouping_policy", &hw_pgpolicy_handler);
+ install_keyword("getuid_callout", &hw_getuid_callout_handler);
+ install_keyword("path_selector", &hw_selector_handler);
+ install_keyword("path_checker", &hw_path_checker_handler);
+ install_keyword("features", &hw_features_handler);
+ install_keyword("hardware_handler", &hw_handler_handler);
+ install_keyword("prio_callout", &prio_callout_handler);
+ install_sublevel_end();
+
+ install_keyword_root("multipaths", &multipaths_handler);
+ install_keyword("multipath", &multipath_handler);
+ install_sublevel();
+ install_keyword("wwid", &wwid_handler);
+ install_keyword("alias", &alias_handler);
+ install_keyword("path_grouping_policy", &mp_pgpolicy_handler);
+ install_keyword("path_selector", &mp_selector_handler);
+ install_sublevel_end();
+
+ return keywords;
+}
Added: multipath-tools/upstream/current/multipath/dict.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/dict.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,10 @@
+#ifndef _DICT_H
+#define _DICT_H
+
+#ifndef _VECTOR_H
+#include "vector.h"
+#endif
+
+vector init_keywords(void);
+
+#endif
Added: multipath-tools/upstream/current/multipath/dmparser.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/dmparser.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,356 @@
+/*
+ * Christophe Varoqui (2004)
+ * This code is GPLv2, see license file
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <vector.h>
+#include <memory.h>
+#include <structs.h>
+
+#include "devinfo.h"
+
+#define WORD_SIZE 64
+
+#if DEBUG
+#define dbg(format, arg...) fprintf(stderr, format "\n", ##arg)
+#else
+#define dbg(format, arg...) do {} while(0)
+#endif
+
+static struct path *
+find_path (vector pathvec, char * dev_t)
+{
+ int i, len;
+ struct path * pp;
+
+ vector_foreach_slot (pathvec, pp, i)
+ if (((len = strlen(dev_t)) == strlen(pp->dev_t)) &&
+ !strncmp(pp->dev_t, dev_t, len))
+ return pp;
+
+ dbg("path %s not found in pathvec\n", dev_t);
+ return NULL;
+}
+
+static int
+get_word (char * sentence, char ** word)
+{
+ char * p;
+ int len;
+ int skip = 0;
+
+ while (*sentence == ' ') {
+ sentence++;
+ skip++;
+ }
+ if (*sentence == '\0')
+ return 0;
+
+ p = sentence;
+
+ while (*p != ' ' && *p != '\0')
+ p++;
+
+ len = (int) (p - sentence);
+
+ if (!word)
+ return skip + len;
+
+ *word = zalloc(len + 1);
+
+ if (!*word) {
+ fprintf(stderr, "get_word : oom\n");
+ return 0;
+ }
+ strncpy(*word, sentence, len);
+// dbg("*word = %s, len = %i", *word, len);
+
+ if (*p == '\0')
+ return 0;
+
+ return skip + len;
+}
+
+static int
+merge_words (char ** dst, char * word, int space)
+{
+ char * p;
+ int len;
+
+ len = strlen(*dst) + strlen(word) + space;
+ *dst = realloc(*dst, len + 1);
+
+ if (!*dst)
+ return 1;
+
+ p = *dst;
+
+ while (*p != '\0')
+ p++;
+
+ while (space) {
+ *p = ' ';
+ p++;
+ space--;
+ }
+ strncpy(p, word, strlen(word) + 1);
+
+ return 0;
+}
+
+extern void
+disassemble_map (vector pathvec, char * params, struct multipath * mpp)
+{
+ char * word;
+ char * p;
+ int i, j, k;
+ int num_features;
+ int num_hwhandler;
+ int num_pg;
+ int num_pg_args;
+ int num_paths;
+ int num_paths_args;
+ struct path * pp;
+ struct pathgroup * pgp;
+
+ p = params;
+
+ /*
+ * features
+ */
+ p += get_word(p, &mpp->features);
+ num_features = atoi(mpp->features);
+
+ for (i = 0; i < num_features; i++) {
+ p += get_word(p, &word);
+ merge_words(&mpp->features, word, 1);
+ free(word);
+ }
+
+ /*
+ * hwhandler
+ */
+ p += get_word(p, &mpp->hwhandler);
+ num_hwhandler = atoi(mpp->hwhandler);
+
+ for (i = 0; i < num_hwhandler; i++) {
+ p += get_word(p, &word);
+ merge_words(&mpp->hwhandler, word, 1);
+ free(word);
+ }
+
+ /*
+ * nb of path groups
+ */
+ p += get_word(p, &word);
+ num_pg = atoi(word);
+ free(word);
+
+ if (num_pg > 0 && !mpp->pg)
+ mpp->pg = vector_alloc();
+
+ /*
+ * first pg to try
+ */
+ p += get_word(p, &word);
+ mpp->nextpg = atoi(word);
+ free(word);
+
+ for (i = 0; i < num_pg; i++) {
+ /*
+ * selector
+ */
+
+ if (!mpp->selector) {
+ p += get_word(p, &mpp->selector);
+ /*
+ * selector args
+ */
+ p += get_word(p, &word);
+ num_pg_args = atoi(word);
+ merge_words(&mpp->selector, word, 1);
+ free(word);
+ } else {
+ p += get_word(p, NULL);
+ p += get_word(p, NULL);
+ }
+
+ for (j = 0; j < num_pg_args; j++)
+ p += get_word(p, NULL);
+
+ /*
+ * paths
+ */
+ pgp = zalloc(sizeof(struct pathgroup));
+ pgp->paths = vector_alloc();
+ vector_alloc_slot(mpp->pg);
+ vector_set_slot(mpp->pg, pgp);
+
+ p += get_word(p, &word);
+ num_paths = atoi(word);
+ free(word);
+
+ p += get_word(p, &word);
+ num_paths_args = atoi(word);
+ free(word);
+
+ for (j = 0; j < num_paths; j++) {
+ p += get_word(p, &word);
+ pp = find_path(pathvec, word);
+ if (!pp) {
+ pp = zalloc(sizeof(struct path));
+ strncpy(pp->dev_t, word, BLK_DEV_SIZE);
+ devt2devname(pp->dev, pp->dev_t);
+ devinfo(pp);
+ }
+ free(word);
+
+ if (pp) {
+ vector_alloc_slot(pgp->paths);
+ vector_set_slot(pgp->paths, pp);
+ pgp->id ^= (long)pp;
+ }
+ if (pp && !strlen(mpp->wwid))
+ strncpy(mpp->wwid, pp->wwid, WWID_SIZE);
+
+ for (k = 0; k < num_paths_args; k++)
+ p += get_word(p, NULL);
+ }
+ }
+}
+
+extern void
+disassemble_status (char * params, struct multipath * mpp)
+{
+ char * word;
+ char * p;
+ int i, j;
+ int num_feature_args;
+ int num_hwhandler_args;
+ int num_pg;
+ int num_pg_args;
+ int num_paths;
+ struct path * pp;
+ struct pathgroup * pgp;
+
+ p = params;
+
+ /*
+ * features
+ */
+ p += get_word(p, &word);
+ num_feature_args = atoi(word);
+ free(word);
+
+ for (i = 0; i < num_feature_args; i++) {
+ if (i == 1) {
+ p += get_word(p, &word);
+ mpp->queuedio = atoi(word);
+ free(word);
+ continue;
+ }
+ /* unknown */
+ p += get_word(p, NULL);
+ }
+ /*
+ * hwhandler
+ */
+ p += get_word(p, &word);
+ num_hwhandler_args = atoi(word);
+ free(word);
+
+ for (i = 0; i < num_hwhandler_args; i++)
+ p += get_word(p, NULL);
+
+ /*
+ * nb of path groups
+ */
+ p += get_word(p, &word);
+ num_pg = atoi(word);
+ free(word);
+
+ /*
+ * next pg to try
+ */
+ p += get_word(p, NULL);
+
+ if (VECTOR_SIZE(mpp->pg) < num_pg)
+ return;
+
+ for (i = 0; i < num_pg; i++) {
+ pgp = VECTOR_SLOT(mpp->pg, i);
+ /*
+ * PG status
+ */
+ p += get_word(p, &word);
+ switch (*word) {
+ case 'D':
+ pgp->status = PGSTATE_DISABLED;
+ break;
+ case 'A':
+ pgp->status = PGSTATE_ACTIVE;
+ break;
+ case 'E':
+ pgp->status = PGSTATE_ENABLED;
+ break;
+ default:
+ pgp->status = PGSTATE_RESERVED;
+ break;
+ }
+ free(word);
+
+ /*
+ * undef ?
+ */
+ p += get_word(p, NULL);
+
+ p += get_word(p, &word);
+ num_paths = atoi(word);
+ free(word);
+
+ p += get_word(p, &word);
+ num_pg_args = atoi(word);
+ free(word);
+
+ if (VECTOR_SIZE(pgp->paths) < num_paths)
+ return;
+
+ for (j = 0; j < num_paths; j++) {
+ pp = VECTOR_SLOT(pgp->paths, j);
+ /*
+ * path
+ */
+ p += get_word(p, NULL);
+
+ /*
+ * path status
+ */
+ p += get_word(p, &word);
+ switch (*word) {
+ case 'F':
+ pp->dmstate = PSTATE_FAILED;
+ break;
+ case 'A':
+ pp->dmstate = PSTATE_ACTIVE;
+ break;
+ default:
+ break;
+ }
+ free(word);
+ /*
+ * fail count
+ */
+ p += get_word(p, &word);
+ pp->failcount = atoi(word);
+ free(word);
+ }
+ /*
+ * selector args
+ */
+ for (j = 0; j < num_pg_args; j++)
+ p += get_word(p, NULL);
+ }
+}
Added: multipath-tools/upstream/current/multipath/dmparser.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/dmparser.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,2 @@
+void disassemble_map (vector, char *, struct multipath *);
+void disassemble_status (char *, struct multipath *);
Added: multipath-tools/upstream/current/multipath/main.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/main.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,1200 @@
+/*
+ * Soft: multipath device mapper target autoconfig
+ *
+ * Version: $Id: main.h,v 0.0.1 2003/09/18 15:13:38 cvaroqui Exp $
+ *
+ * Author: Copyright (C) 2003 Christophe Varoqui
+ *
+ * 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.
+ *
+ * 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 of the License, or (at your option) any later version.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/ioctl.h>
+
+#include <parser.h>
+#include <vector.h>
+#include <memory.h>
+#include <sysfs/dlist.h>
+#include <sysfs/libsysfs.h>
+#include <libdevmapper.h>
+#include <devmapper.h>
+#include <checkers.h>
+#include <path_state.h>
+#include <safe_printf.h>
+#include <blacklist.h>
+#include <hwtable.h>
+#include <util.h>
+#include <defaults.h>
+#include <structs.h>
+
+#include "main.h"
+#include "devinfo.h"
+#include "config.h"
+#include "pgpolicies.h"
+#include "dict.h"
+#include "debug.h"
+#include "dmparser.h"
+#include "propsel.h"
+
+/* helpers */
+#define argis(x) if (0 == strcmp(x, argv[i]))
+
+static int
+filepresent (char * run) {
+ struct stat buf;
+
+ if(!stat(run, &buf))
+ return 1;
+ return 0;
+}
+
+static int
+get_pathvec_sysfs (vector pathvec)
+{
+ struct sysfs_directory * sdir;
+ struct sysfs_directory * devp;
+ struct sysfs_link * linkp;
+ char refwwid[WWID_SIZE];
+ char empty_buff[WWID_SIZE];
+ char buff[FILE_NAME_SIZE];
+ char path[FILE_NAME_SIZE];
+ char sysfs_path[FILE_NAME_SIZE];
+ struct path * curpath;
+
+ memset (empty_buff, 0, WWID_SIZE);
+ memset (refwwid, 0, WWID_SIZE);
+
+ if (sysfs_get_mnt_path(sysfs_path, FILE_NAME_SIZE)) {
+ fprintf(stderr, "multipath tools need sysfs\n");
+ exit(1);
+ }
+
+ /*
+ * if called from /etc/dev.d or pathcheckers, only consider the paths
+ * that relate to the device pointed by conf->dev
+ */
+ if (conf->dev && filepresent(conf->dev)) {
+ dbg("limited scope = %s", conf->dev);
+ curpath = zalloc(sizeof (struct path));
+ basename(conf->dev, curpath->dev);
+
+ if (devinfo(curpath))
+ return 1;
+
+ memcpy(refwwid, curpath->wwid, WWID_SIZE);
+ free(curpath);
+ }
+
+ /*
+ * if devt specified on the cmd line,
+ * only consider affiliated paths
+ */
+ if (conf->dev && !devt2devname(buff, conf->dev)) {
+ dbg("limited scope = %s", conf->dev);
+ curpath = zalloc(sizeof (struct path));
+ if(safe_sprintf(curpath->dev, "%s", buff)) {
+ fprintf(stderr, "curpath->dev too small\n");
+ exit(1);
+ }
+ if (devinfo(curpath))
+ return 1;
+
+ memcpy(refwwid, curpath->wwid, WWID_SIZE);
+ free(curpath);
+ }
+
+ if(safe_sprintf(path, "%s/block", sysfs_path)) {
+ fprintf(stderr, "path too small\n");
+ exit(1);
+ }
+ sdir = sysfs_open_directory(path);
+ sysfs_read_directory(sdir);
+
+ dlist_for_each_data(sdir->subdirs, devp, struct sysfs_directory) {
+ if (blacklist(conf->blist, devp->name))
+ continue;
+
+ sysfs_read_directory(devp);
+
+ if (devp->links == NULL)
+ continue;
+
+ dlist_for_each_data(devp->links, linkp, struct sysfs_link) {
+ if (!strncmp(linkp->name, "device", 6))
+ break;
+ }
+ if (linkp == NULL) {
+ continue;
+ }
+ basename(devp->path, buff);
+ curpath = zalloc(sizeof(struct path));
+
+ if(safe_sprintf(curpath->dev, "%s", buff)) {
+ fprintf(stderr, "curpath->dev too small\n");
+ exit(1);
+ }
+ if (devinfo(curpath)) {
+ free (curpath);
+ fprintf(stderr, "pb getting path info, free\n");
+ continue;
+ }
+ if (memcmp(empty_buff, refwwid, WWID_SIZE) != 0 &&
+ memcmp(curpath->wwid, refwwid, WWID_SIZE) != 0) {
+ dbg("skip path %s : out of scope", curpath->dev);
+ free(curpath);
+ continue;
+ }
+ vector_alloc_slot(pathvec);
+ vector_set_slot(pathvec, curpath);
+ }
+ sysfs_close_directory(sdir);
+ return 0;
+}
+
+/*
+ * print_path styles
+ */
+#define PRINT_PATH_ALL 0
+#define PRINT_PATH_SHORT 1
+
+static void
+print_path (struct path * pp, int style)
+{
+ if (style != PRINT_PATH_SHORT && pp->wwid)
+ printf ("%s ", pp->wwid);
+ else
+ printf (" \\_ ");
+
+ printf("%i:%i:%i:%i ",
+ pp->sg_id.host_no,
+ pp->sg_id.channel,
+ pp->sg_id.scsi_id,
+ pp->sg_id.lun);
+
+ if (pp->dev)
+ printf("%-4s ", pp->dev);
+
+ if (pp->dev_t)
+ printf("%-7s ", pp->dev_t);
+
+ switch (pp->state) {
+ case PATH_UP:
+ printf("[ready ]");
+ break;
+ case PATH_DOWN:
+ printf("[faulty]");
+ break;
+ case PATH_SHAKY:
+ printf("[shaky ]");
+ break;
+ default:
+ printf("[undef ]");
+ break;
+ }
+ switch (pp->dmstate) {
+ case PSTATE_ACTIVE:
+ printf("[active]");
+ break;
+ case PSTATE_FAILED:
+ printf("[failed]");
+ break;
+ default:
+ break;
+ }
+ if (pp->claimed)
+ printf("[claimed]");
+
+ if (style != PRINT_PATH_SHORT && pp->product_id)
+ printf("[%.16s]", pp->product_id);
+
+ fprintf(stdout, "\n");
+}
+
+#if DEBUG
+static void
+print_map (struct multipath * mpp)
+{
+ if (mpp->size && mpp->params)
+ printf("0 %lu %s %s\n",
+ mpp->size, DEFAULT_TARGET, mpp->params);
+ return;
+}
+
+static void
+print_all_paths (vector pathvec)
+{
+ int i;
+ char empty_buff[WWID_SIZE];
+ struct path * pp;
+
+ /* initialize a cmp 0-filled buffer */
+ memset(empty_buff, 0, WWID_SIZE);
+
+ vector_foreach_slot (pathvec, pp, i) {
+ /* leave out paths with incomplete devinfo */
+ if (memcmp(empty_buff, pp->wwid, WWID_SIZE) == 0)
+ continue;
+
+ print_path(pp, PRINT_PATH_ALL);
+ }
+}
+
+static void
+print_all_maps (vector mp)
+{
+ int i;
+ struct multipath * mpp;
+
+ vector_foreach_slot (mp, mpp, i)
+ print_map(mpp);
+}
+#endif
+
+static void
+print_mp (struct multipath * mpp)
+{
+ int j, i;
+ struct path * pp = NULL;
+ struct pathgroup * pgp = NULL;
+
+ if (mpp->action == ACT_NOTHING || conf->verbosity == 0)
+ return;
+
+ if (conf->verbosity > 1) {
+ switch (mpp->action) {
+ case ACT_RELOAD:
+ printf("%s: ", ACT_RELOAD_STR);
+ break;
+
+ case ACT_CREATE:
+ printf("%s: ", ACT_CREATE_STR);
+ break;
+
+ case ACT_SWITCHPG:
+ printf("%s: ", ACT_SWITCHPG_STR);
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ if (mpp->alias)
+ printf("%s", mpp->alias);
+
+ if (conf->verbosity == 1) {
+ printf("\n");
+ return;
+ }
+ if (strncmp(mpp->alias, mpp->wwid, WWID_SIZE))
+ printf(" (%s)", mpp->wwid);
+
+ printf("\n");
+
+ if (mpp->size < 2000)
+ printf("[size=%lu kB]", mpp->size / 2);
+ else if (mpp->size < (2000 * 1024))
+ printf("[size=%lu MB]", mpp->size / 2 / 1024);
+ else if (mpp->size < (2000 * 1024 * 1024))
+ printf("[size=%lu GB]", mpp->size / 2 / 1024 / 1024);
+ else
+ printf("[size=%lu TB]", mpp->size / 2 / 1024 / 1024 / 1024);
+
+ if (mpp->features)
+ printf("[features=\"%s\"]", mpp->features);
+
+ if (mpp->hwhandler)
+ printf("[hwhandler=\"%s\"]", mpp->hwhandler);
+
+ fprintf(stdout, "\n");
+
+ if (!mpp->pg)
+ return;
+
+ vector_foreach_slot (mpp->pg, pgp, j) {
+ printf("\\_ ");
+
+ if (mpp->selector)
+ printf("%s ", mpp->selector);
+
+ switch (pgp->status) {
+ case PGSTATE_ENABLED:
+ printf("[enabled]");
+ break;
+ case PGSTATE_DISABLED:
+ printf("[disabled]");
+ break;
+ case PGSTATE_ACTIVE:
+ printf("[active]");
+ break;
+ default:
+ break;
+ }
+ if (mpp->nextpg && mpp->nextpg == j + 1)
+ printf("[first]");
+
+ printf("\n");
+
+ vector_foreach_slot (pgp->paths, pp, i)
+ print_path(pp, PRINT_PATH_SHORT);
+ }
+ printf("\n");
+}
+
+static void
+print_all_mp (vector mp)
+{
+ int k;
+ struct multipath * mpp;
+
+ if (conf->verbosity == 0)
+ return;
+
+ vector_foreach_slot (mp, mpp, k)
+ print_mp(mpp);
+}
+
+static void
+coalesce_paths (vector mp, vector pathvec)
+{
+ int k, i;
+ char empty_buff[WWID_SIZE];
+ struct multipath * mpp;
+ struct path * pp1;
+ struct path * pp2;
+
+ memset(empty_buff, 0, WWID_SIZE);
+
+ vector_foreach_slot (pathvec, pp1, k) {
+ /* skip this path for some reason */
+
+ /* 1. if path has no unique id */
+ if (memcmp(empty_buff, pp1->wwid, WWID_SIZE) == 0)
+ continue;
+
+ /* 2. if path already coalesced */
+ if (pp1->mpp)
+ continue;
+
+ /*
+ * at this point, we know we really got a new mp
+ */
+ mpp = zalloc(sizeof(struct multipath));
+ pp1->mpp = mpp;
+ strcpy(mpp->wwid, pp1->wwid);
+ mpp->size = pp1->size;
+
+ mpp->mpe = find_mp(pp1->wwid);
+ mpp->hwe = find_hw(conf->hwtable,
+ pp1->vendor_id, pp1->product_id);
+
+ mpp->paths = vector_alloc();
+ vector_alloc_slot (mpp->paths);
+ vector_set_slot (mpp->paths, pp1);
+
+ for (i = k + 1; i < VECTOR_SIZE(pathvec); i++) {
+ pp2 = VECTOR_SLOT(pathvec, i);
+
+ if (strcmp(pp1->wwid, pp2->wwid))
+ continue;
+
+ pp2->mpp = mpp;
+
+ if (pp2->size != mpp->size) {
+ /*
+ * ouch, avoid feeding that to the DM
+ */
+ dbg("path size mismatch : discard %s",
+ mpp->wwid);
+ mpp->action = ACT_NOTHING;
+ }
+ vector_alloc_slot(mpp->paths);
+ vector_set_slot(mpp->paths, VECTOR_SLOT(pathvec, i));
+ }
+ if (mpp) {
+ vector_alloc_slot(mp);
+ vector_set_slot(mp, mpp);
+ }
+ }
+}
+
+static int
+dm_switchgroup(char * mapname, int index)
+{
+ int r = 0;
+ struct dm_task *dmt;
+ char str[24];
+
+ if (!(dmt = dm_task_create(DM_DEVICE_TARGET_MSG)))
+ return 0;
+
+ if (!dm_task_set_name(dmt, mapname))
+ goto out;
+
+ if (!dm_task_set_sector(dmt, 0))
+ goto out;
+
+ snprintf(str, 24, "switch_group %i\n", index);
+ dbg("message %s 0 %s", mapname, str);
+
+ if (!dm_task_set_message(dmt, str))
+ goto out;
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ r = 1;
+
+ out:
+ dm_task_destroy(dmt);
+
+ return r;
+}
+static int
+dm_reinstate(char * mapname, char * path)
+{
+ int r = 0;
+ int sz;
+ struct dm_task *dmt;
+ char *str;
+
+ if (!(dmt = dm_task_create(DM_DEVICE_TARGET_MSG)))
+ return 0;
+
+ if (!dm_task_set_name(dmt, mapname))
+ goto out;
+
+ if (!dm_task_set_sector(dmt, 0))
+ goto out;
+
+ sz = strlen(path) + 16;
+ str = zalloc(sz);
+
+ snprintf(str, sz, "reinstate_path %s\n", path);
+
+ if (!dm_task_set_message(dmt, str))
+ goto out;
+
+ free(str);
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ r = 1;
+
+ out:
+ dm_task_destroy(dmt);
+
+ return r;
+}
+
+/*
+ * Transforms the path group vector into a proper device map string
+ */
+void
+assemble_map (struct multipath * mp)
+{
+ int i, j;
+ int shift, freechar;
+ char * p;
+ struct pathgroup * pgp;
+ struct path * pp;
+
+ p = mp->params;
+ freechar = sizeof(mp->params);
+
+ shift = snprintf(p, freechar, "%s %s %i %i",
+ mp->features, mp->hwhandler,
+ VECTOR_SIZE(mp->pg), mp->nextpg);
+
+ if (shift >= freechar) {
+ fprintf(stderr, "mp->params too small\n");
+ exit(1);
+ }
+ p += shift;
+ freechar -= shift;
+
+ vector_foreach_slot (mp->pg, pgp, i) {
+ pgp = VECTOR_SLOT(mp->pg, i);
+ shift = snprintf(p, freechar, " %s %i 1", mp->selector,
+ VECTOR_SIZE(pgp->paths));
+ if (shift >= freechar) {
+ fprintf(stderr, "mp->params too small\n");
+ exit(1);
+ }
+ p += shift;
+ freechar -= shift;
+
+ vector_foreach_slot (pgp->paths, pp, j) {
+ shift = snprintf(p, freechar, " %s 1000" ,pp->dev_t);
+ if (shift >= freechar) {
+ fprintf(stderr, "mp->params too small\n");
+ exit(1);
+ }
+ p += shift;
+ freechar -= shift;
+ }
+ }
+ if (freechar < 1) {
+ fprintf(stderr, "mp->params too small\n");
+ exit(1);
+ }
+ snprintf(p, 1, "\n");
+}
+
+static int
+setup_map (struct multipath * mpp)
+{
+ struct path * pp;
+ struct pathgroup * pgp;
+ int i, j;
+ int highest = 0;
+
+ /*
+ * don't bother if devmap size is unknown
+ */
+ if (mpp->size <= 0)
+ return 1;
+
+ /*
+ * don't bother if a constituant path is claimed
+ * FIXME : claimed detection broken, always unclaimed for now
+ */
+ vector_foreach_slot (mpp->paths, pp, i)
+ if (pp->claimed)
+ return 1;
+
+ /*
+ * properties selectors
+ */
+ select_pgpolicy(mpp);
+ select_selector(mpp);
+ select_features(mpp);
+ select_hwhandler(mpp);
+ select_alias(mpp);
+
+ /*
+ * apply selected grouping policy to valid paths
+ */
+ switch (mpp->pgpolicy) {
+ case MULTIBUS:
+ one_group(mpp);
+ break;
+ case FAILOVER:
+ one_path_per_group(mpp);
+ break;
+ case GROUP_BY_SERIAL:
+ group_by_serial(mpp);
+ break;
+ case GROUP_BY_PRIO:
+ group_by_prio(mpp);
+ break;
+ case GROUP_BY_NODE_NAME:
+ group_by_node_name(mpp);
+ break;
+ default:
+ break;
+ }
+ if (mpp->pg == NULL) {
+ dbg("pgpolicy failed to produce a ->pg vector");
+ return 1;
+ }
+
+ /*
+ * ponders each path group and determine highest prio pg
+ */
+ mpp->nextpg = 1;
+ vector_foreach_slot (mpp->pg, pgp, i) {
+ vector_foreach_slot (pgp->paths, pp, j) {
+ pgp->id ^= (long)pp;
+ if (pp->state != PATH_DOWN)
+ pgp->priority += pp->priority;
+ }
+ if (pgp->priority > highest) {
+ highest = pgp->priority;
+ mpp->nextpg = i + 1;
+ }
+ }
+
+ /*
+ * transform the mp->pg vector of vectors of paths
+ * into a mp->params strings to feed the device-mapper
+ */
+ assemble_map(mpp);
+ return 0;
+}
+
+/*
+ * detect if a path is in the map we are about to create but not in the
+ * current one (triggers a valid reload)
+ * if a path is in the current map but not in the one we are about to create,
+ * don't reload : it may come back latter so save the reload burden
+ */
+static int
+pgcmp2 (struct multipath * mpp, struct multipath * cmpp)
+{
+ int i, j, k, l;
+ struct pathgroup * pgp;
+ struct pathgroup * cpgp;
+ struct path * pp;
+ struct path * cpp;
+ int found = 0;
+
+ vector_foreach_slot (mpp->pg, pgp, i) {
+ vector_foreach_slot (pgp->paths, pp, j) {
+ vector_foreach_slot (cmpp->pg, cpgp, k) {
+ vector_foreach_slot (cpgp->paths, cpp, l) {
+ if (pp == cpp) {
+ found = 1;
+ break;
+ }
+ }
+ if (found)
+ break;
+ }
+ if (found) {
+ found = 0;
+ break;
+ } else
+ return 1;
+ }
+ }
+ return 0;
+}
+
+#if 0
+static int
+pgcmp (struct multipath * mpp, struct multipath * cmpp)
+{
+ int i, j;
+ struct pathgroup * pgp;
+ struct pathgroup * cpgp;
+ int r = 0;
+
+ vector_foreach_slot (mpp->pg, pgp, i) {
+ vector_foreach_slot (cmpp->pg, cpgp, j) {
+ if (pgp->id == cpgp->id) {
+ r = 0;
+ break;
+ }
+ r++;
+ }
+ if (r)
+ return r;
+ }
+ return r;
+}
+#endif
+
+static void
+select_action (struct multipath * mpp, vector curmp)
+{
+ int i;
+ struct multipath * cmpp;
+
+ vector_foreach_slot (curmp, cmpp, i) {
+ if (strncmp(cmpp->alias, mpp->alias, strlen(mpp->alias)))
+ continue;
+
+ if (cmpp->size != mpp->size) {
+ dbg("size different than current");
+ mpp->action = ACT_RELOAD;
+ return;
+ }
+ if (strncmp(cmpp->features, mpp->features,
+ strlen(mpp->features))) {
+ dbg("features different than current");
+ mpp->action = ACT_RELOAD;
+ return;
+ }
+ if (strncmp(cmpp->hwhandler, mpp->hwhandler,
+ strlen(mpp->hwhandler))) {
+ dbg("hwhandler different than current");
+ mpp->action = ACT_RELOAD;
+ return;
+ }
+ if (strncmp(cmpp->selector, mpp->selector,
+ strlen(mpp->selector))) {
+ dbg("selector different than current");
+ mpp->action = ACT_RELOAD;
+ return;
+ }
+ if (VECTOR_SIZE(cmpp->pg) != VECTOR_SIZE(mpp->pg)) {
+ dbg("different number of PG");
+ mpp->action = ACT_RELOAD;
+ return;
+ }
+ if (pgcmp2(mpp, cmpp)) {
+ dbg("different path group topology");
+ mpp->action = ACT_RELOAD;
+ return;
+ }
+ if (cmpp->nextpg != mpp->nextpg) {
+ dbg("nextpg different than current");
+ mpp->action = ACT_SWITCHPG;
+ return;
+ }
+ mpp->action = ACT_NOTHING;
+ return;
+ }
+ mpp->action = ACT_CREATE;
+ return;
+}
+
+static int
+reinstate_paths (struct multipath * mpp)
+{
+ int i, j;
+ struct pathgroup * pgp;
+ struct path * pp;
+
+ vector_foreach_slot (mpp->pg, pgp, i) {
+ vector_foreach_slot (pgp->paths, pp, j) {
+ if (pp->state != PATH_UP &&
+ (pgp->status == PGSTATE_DISABLED ||
+ pgp->status == PGSTATE_ACTIVE))
+ continue;
+
+ if (pp->dmstate == PSTATE_FAILED) {
+ dm_reinstate(mpp->alias, pp->dev_t);
+ }
+ }
+ }
+ return 0;
+}
+
+static int
+domap (struct multipath * mpp)
+{
+ int op;
+ int r = 0;
+
+ print_mp(mpp);
+
+ /*
+ * last chance to quit before touching the devmaps
+ */
+ if (conf->dry_run || mpp->action == ACT_NOTHING)
+ return 0;
+
+ if (mpp->action == ACT_SWITCHPG) {
+ dm_switchgroup(mpp->alias, mpp->nextpg);
+ /*
+ * we may have avoided reinstating paths because there where in
+ * active or disabled PG. Now that the topology has changed, retry.
+ */
+ reinstate_paths(mpp);
+ return 0;
+ }
+ if (mpp->action == ACT_CREATE)
+ op = DM_DEVICE_CREATE;
+
+ if (mpp->action == ACT_RELOAD)
+ op = DM_DEVICE_RELOAD;
+
+
+ /*
+ * device mapper creation or updating
+ * here we know we'll have garbage on stderr from
+ * libdevmapper. so shut it down temporarily.
+ */
+ dm_log_init_verbose(0);
+
+ r = dm_addmap(op, mpp->alias, DEFAULT_TARGET, mpp->params, mpp->size);
+
+ if (r == 0)
+ dm_simplecmd(DM_DEVICE_REMOVE, mpp->alias);
+ else if (op == DM_DEVICE_RELOAD)
+ dm_simplecmd(DM_DEVICE_RESUME, mpp->alias);
+
+ /*
+ * PG order is random, so we need to set the primary one
+ * upon create or reload
+ */
+ dm_switchgroup(mpp->alias, mpp->nextpg);
+
+ dm_log_init_verbose(1);
+
+ return r;
+}
+
+static int
+dm_get_maps (vector mp, char * type)
+{
+ struct multipath * mpp;
+ int r = 0;
+ struct dm_task *dmt;
+ struct dm_names *names;
+ unsigned next = 0;
+ unsigned long length;
+ char *params;
+ char *status;
+
+ if (!(dmt = dm_task_create (DM_DEVICE_LIST)))
+ return 0;
+
+ if (!dm_task_run (dmt))
+ goto out;
+
+ if (!(names = dm_task_get_names (dmt)))
+ goto out;
+
+ if (!names->dev)
+ goto out;
+
+ do {
+ if (dm_type(names->name, DEFAULT_TARGET)) {
+ dm_get_map(names->name, &length, ¶ms);
+ dm_get_status(names->name, &status);
+ mpp = zalloc(sizeof(struct multipath));
+
+ if (!mpp) {
+ r = 1;
+ goto out;
+ }
+ mpp->size = length;
+ mpp->alias = zalloc(strlen(names->name) + 1);
+ strncat(mpp->alias, names->name, strlen(names->name));
+ strncat(mpp->params, params, PARAMS_SIZE);
+ strncat(mpp->status, status, PARAMS_SIZE);
+
+ vector_alloc_slot(mp);
+ vector_set_slot(mp, mpp);
+ mpp = NULL;
+ }
+ next = names->next;
+ names = (void *) names + next;
+ } while (next);
+
+ out:
+ dm_task_destroy (dmt);
+ return r;
+}
+
+static void
+signal_daemon (void)
+{
+ FILE *file;
+ pid_t pid;
+ char *buf;
+
+ buf = malloc (8);
+
+ file = fopen (DEFAULT_PIDFILE, "r");
+
+ if (!file) {
+ if (conf->verbosity > 0)
+ fprintf (stderr, "cannot signal daemon, "
+ "pidfile not found\n");
+ return;
+ }
+
+ buf = fgets (buf, 8, file);
+ fclose (file);
+
+ pid = (pid_t) atol (buf);
+ free (buf);
+
+ kill (pid, SIGHUP);
+}
+
+static void
+usage (char * progname)
+{
+ fprintf (stderr, VERSION_STRING);
+ fprintf (stderr, "Usage: %s\t[-v level] [-d] [-S]\n",
+ progname);
+ fprintf (stderr,
+ "\t\t\t[-p failover|multibus|group_by_serial|group_by_prio]\n" \
+ "\t\t\t[device]\n" \
+ "\n" \
+ "\t-v level\tverbosty level\n" \
+ "\t 0\t\t\tno output\n" \
+ "\t 1\t\t\tprint created devmap names only\n" \
+ "\t 2\t\t\tprint all paths and multipaths\n" \
+ "\t-d\t\tdry run, do not create or update devmaps\n" \
+ "\t-S\t\tinhibit signal sending to multipathd\n"
+ "\t-F\t\tflush all multipath device maps\n" \
+ "\t-p policy\tforce all maps to specified policy :\n" \
+ "\t failover\t\t1 path per priority group\n" \
+ "\t multibus\t\tall paths in 1 priority group\n" \
+ "\t group_by_serial\t1 priority group per serial\n" \
+ "\t group_by_prio\t1 priority group per priority lvl\n" \
+ "\t group_by_node_name\t1 priority group per target node\n" \
+ "\n" \
+ "\tdevice\t\tlimit scope to the device's multipath\n" \
+ "\t\t\t(udev-style $DEVNAME reference, eg /dev/sdb\n" \
+ "\t\t\tor major:minor or a device map name)\n" \
+ );
+
+ exit(1);
+}
+
+int try_lock (char * file)
+{
+ int fd;
+ struct flock fl;
+
+ /*
+ * create the file to lock if it does not exist
+ */
+ fd = open(file, O_CREAT|O_RDWR);
+
+ if (fd < 0) {
+ fprintf(stderr, "can't create runfile\n");
+ exit(1);
+ }
+ fl.l_type = F_WRLCK;
+ fl.l_whence = 0;
+ fl.l_start = 0;
+ fl.l_len = 0;
+
+ /*
+ * set a max wait time
+ */
+ alarm(2);
+
+ if (fcntl(fd, F_SETLKW, &fl) == -1) {
+ fprintf(stderr, "can't take a write lease on %s\n", file);
+ return 1;
+ }
+ alarm(0);
+
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ vector mp, curmp;
+ vector pathvec;
+ struct multipath * mpp;
+ int k;
+ int arg;
+ extern char *optarg;
+ extern int optind;
+
+ if (dm_prereq(DEFAULT_TARGET, 1, 0, 3)) {
+ fprintf(stderr, "device mapper prerequisites not met.\n");
+ exit(1);
+ }
+
+ /*
+ * Don't run in parallel
+ * ie, acquire a F_WRLCK-type lock on DEFAULT_RUNFILE
+ */
+ if (try_lock(DEFAULT_RUNFILE)) {
+ fprintf(stderr, "waited for to long. exiting\n");
+ exit(1);
+ }
+
+ /*
+ * alloc config struct
+ */
+ conf = zalloc(sizeof(struct config));
+
+ /*
+ * internal defaults
+ */
+ conf->list = 0;
+ conf->dry_run = 0; /* 1 == Do not Create/Update devmaps */
+ conf->verbosity = 1;
+ conf->pgpolicy_flag = 0; /* do not override defaults */
+ conf->signal = 1; /* 1 == Send a signal to multipathd */
+ conf->dev = NULL;
+ conf->default_selector = NULL;
+ conf->default_selector_args = 0;
+ conf->default_pgpolicy = 0;
+ conf->mptable = NULL;
+ conf->hwtable = NULL;
+ conf->blist = NULL;
+ conf->default_features = NULL;
+ conf->default_hwhandler = NULL;
+
+ while ((arg = getopt(argc, argv, ":qdlFSi:v:p:")) != EOF ) {
+ switch(arg) {
+ case 1: printf("optarg : %s\n",optarg);
+ break;
+ case 'v':
+ if (sizeof(optarg) > sizeof(char *) ||
+ !isdigit(optarg[0]))
+ usage (argv[0]);
+
+ conf->verbosity = atoi(optarg);
+ break;
+ case 'd':
+ conf->dry_run = 1;
+ conf->signal = 0;
+ break;
+ case 'F':
+ dm_flush_maps(DEFAULT_TARGET);
+ goto out;
+ break;
+ case 'l':
+ conf->list = 1;
+ conf->dry_run = 1;
+ conf->signal = 0;
+ break;
+ case 'S':
+ conf->signal = 0;
+ break;
+ case 'p':
+ conf->pgpolicy_flag = get_pgpolicy_id(optarg);
+ if (conf->pgpolicy_flag == -1) {
+ printf("'%s' is not a valid policy\n", optarg);
+ usage(argv[0]);
+ }
+ break;
+ case ':':
+ fprintf(stderr, "Missing option arguement\n");
+ usage(argv[0]);
+ case '?':
+ fprintf(stderr, "Unknown switch: %s\n", optarg);
+ usage(argv[0]);
+ default:
+ usage(argv[0]);
+ }
+ }
+ if (optind<argc) {
+ conf->dev = zalloc(FILE_NAME_SIZE);
+ strncpy(conf->dev, argv[optind], FILE_NAME_SIZE);
+ }
+
+ /*
+ * allocate core vectors to store paths and multipaths
+ */
+ mp = vector_alloc();
+ curmp = vector_alloc();
+ pathvec = vector_alloc();
+
+ if (!mp || !curmp || !pathvec) {
+ fprintf(stderr, "can not allocate memory\n");
+ exit(1);
+ }
+
+ /*
+ * read the config file
+ */
+ if (filepresent(DEFAULT_CONFIGFILE))
+ init_data (DEFAULT_CONFIGFILE, init_keywords);
+
+ /*
+ * fill the voids left in the config file
+ */
+ if (conf->hwtable == NULL) {
+ conf->hwtable = vector_alloc();
+ setup_default_hwtable(conf->hwtable);
+ }
+ if (conf->blist == NULL) {
+ conf->blist = vector_alloc();
+ setup_default_blist(conf->blist);
+ }
+ if (conf->mptable == NULL)
+ conf->mptable = vector_alloc();
+
+ if (conf->default_selector == NULL)
+ conf->default_selector = DEFAULT_SELECTOR;
+
+ if (conf->udev_dir == NULL)
+ conf->udev_dir = DEFAULT_UDEVDIR;
+
+ if (conf->default_getuid == NULL)
+ conf->default_getuid = DEFAULT_GETUID;
+
+ if (conf->default_features == NULL)
+ conf->default_features = DEFAULT_FEATURES;
+
+ if (conf->default_hwhandler == NULL)
+ conf->default_hwhandler = DEFAULT_HWHANDLER;
+
+ /*
+ * if we have a blacklisted device parameterexit early
+ */
+ if (conf->dev && blacklist(conf->blist, conf->dev))
+ exit(0);
+
+ /*
+ * get a path list and group them as multipaths
+ */
+ if (get_pathvec_sysfs(pathvec) || VECTOR_SIZE(pathvec) == 0)
+ exit(1);
+
+ dm_get_maps(curmp, DEFAULT_TARGET);
+
+ if (VECTOR_SIZE(pathvec) == 0 && conf->verbosity > 0) {
+ fprintf(stdout, "no path found\n");
+ exit(0);
+ }
+
+ vector_foreach_slot (curmp, mpp, k) {
+ dbg("params = %s", mpp->params);
+ dbg("status = %s", mpp->status);
+ disassemble_map(pathvec, mpp->params, mpp);
+ disassemble_status(mpp->status, mpp);
+
+ if (!conf->dry_run)
+ reinstate_paths(mpp);
+ }
+ if (conf->list) {
+ print_all_mp(curmp);
+ goto out;
+ }
+
+ coalesce_paths(mp, pathvec);
+
+ /*
+ * conf->dev can be a mapname
+ * if so, only reconfigure this map
+ */
+ vector_foreach_slot (mp, mpp, k) {
+ if (conf->dev && (
+ (mpp->alias &&
+ 0 == strncmp(mpp->alias, conf->dev, FILE_NAME_SIZE)) ||
+ 0 == strncmp(mpp->wwid, conf->dev, FILE_NAME_SIZE))) {
+ setup_map(mpp);
+
+ if (mpp->action == 0)
+ select_action(mpp, curmp);
+ domap(mpp);
+ goto out;
+ }
+ }
+
+ vector_foreach_slot (mp, mpp, k) {
+ setup_map(mpp);
+
+ if (mpp->action == 0)
+ select_action(mpp, curmp);
+ domap(mpp);
+ }
+
+#if DEBUG
+ fprintf(stdout, "#\n# all paths :\n#\n");
+ print_all_paths(pathvec);
+ fprintf(stdout, "#\n# device maps :\n#\n");
+ print_all_maps(mp);
+#endif
+out:
+ /*
+ * signal multipathd that new devmaps may have come up
+ */
+ if (conf->signal)
+ signal_daemon();
+
+ exit(0);
+}
Added: multipath-tools/upstream/current/multipath/main.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/main.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,55 @@
+/*
+ * Soft: Description here...
+ *
+ * Version: $Id: main.h,v 0.0.1 2003/09/18 15:13:38 cvaroqui Exp $
+ *
+ * Author: Copyright (C) 2003 Christophe Varoqui
+ *
+ * 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.
+ *
+ * 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 of the License, or (at your option) any later version.
+ */
+
+#ifndef _MAIN_H
+#define _MAIN_H
+
+/*
+ * configurator actions
+ */
+#define ACT_NOTHING_STR "unchanged"
+#define ACT_RELOAD_STR "reload"
+#define ACT_SWITCHPG_STR "switchpg"
+#define ACT_CREATE_STR "create"
+
+enum actions {
+ ACT_RESERVED,
+ ACT_NOTHING,
+ ACT_RELOAD,
+ ACT_SWITCHPG,
+ ACT_CREATE
+};
+
+/*
+ * Build version
+ */
+#define PROG "multipath"
+
+#define VERSION_CODE 0x000402
+#define DATE_CODE 0x170105
+
+#define MULTIPATH_VERSION(version) \
+ (version >> 16) & 0xFF, \
+ (version >> 8) & 0xFF, \
+ version & 0xFF
+
+#define VERSION_STRING PROG" v%d.%d.%d (%.2d/%.2d, 20%.2d)\n", \
+ MULTIPATH_VERSION(VERSION_CODE), \
+ MULTIPATH_VERSION(DATE_CODE)
+
+#endif
Added: multipath-tools/upstream/current/multipath/multipath.8
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/multipath.8 Fri Mar 4 08:05:19 2005
@@ -0,0 +1,90 @@
+.TH MULTIPATH 8 "February 2004" "" "Linux Administrator's Manual"
+.SH NAME
+multipath \- Device mapper target autoconfig
+.SH SYNOPSIS
+.B multipath
+.RB [\| \-v\ \c
+.IR verbosity \|]
+.RB [\| \-d \|]
+.RB [\| \-l \|]
+.RB [\| \-i\ \c
+.IR int \|]
+.RB [\| \-p\ \c
+.BR failover | multibus | group_by_serial | group_by_prio | group_by_node_name \|]
+.RB [\| -S \|]
+.RB [\| device \|]
+.SH DESCRIPTION
+.B multipath
+is used to detect multiple paths to devices for fail-over or performance reasons and coalesces them
+.SH OPTIONS
+.TP
+.B \-v " level"
+verbosity, print all paths and multipaths
+.RS 1.2i
+.TP 1.2i
+.B 0
+no output
+.TP
+.B 1
+print the created or updated multipath names only, for use to feed other tools like kpartx
+.TP
+.B 2 +
+print all info : detected paths, coalesced paths (ie multipaths) and device maps
+.RE
+.TP
+.B \-d
+dry run, do not create or update devmaps
+.TP
+.B \-l
+list the current multipath configuration
+.TP
+.TP
+.BI \-i " interval"
+multipath target param: polling interval
+.TP
+.BI \-D " major:minor"
+update only the devmap the path pointed by
+.I major:minor
+is in
+.TP
+.B \-F
+flush all the multipath device maps
+.TP
+.BI \-p " policy"
+force maps to specified policy:
+.RS 1.2i
+.TP 1.2i
+.B failover
+1 path per priority group
+.TP
+.B multibus
+all paths in 1 priority group
+.TP
+.B group_by_serial
+1 priority group per serial
+.TP
+.B group_by_prio
+1 priority group per priority value. Priorities are determined by callout programs specified as a global, per-controler or per-multipath option in the configuration file
+.TP
+.B group_by_node_name
+1 priority group per target node name. Target node names are fetched in /sys/class/fc_transport/target*/node_name.
+.RE
+.TP
+.B \-S
+do not send signal to multipathd. -d activate this silently.
+.TP
+.BI device
+update only the devmap the path pointed by
+.I device
+is in.
+.I device
+is in the /dev/sdb (as shown by udev in the $DEVNAME variable) or major:minor format.
+.I device
+may alternatively be a multipath mapname
+.SH "SEE ALSO"
+.BR udev (8),
+.BR dmsetup (8)
+.BR hotplug (8)
+.SH AUTHORS
+.B multipath
+was developed by Christophe Varoqui, <christophe.varoqui at free.fr> and others.
Added: multipath-tools/upstream/current/multipath/multipath.dev
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/multipath.dev Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+#!/bin/sh -e
+
+map=$(/sbin/multipath -S -v 1 $DEVNAME)
+
+if [ -z $map ]
+then
+ exit
+fi
+
+echo "path $DEVNAME : multipath $map"
+
+if [ -b /dev/$map ]
+then
+ kpartx -v -a /dev/$map
+fi
Added: multipath-tools/upstream/current/multipath/multipath.rules
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/multipath.rules Fri Mar 4 08:05:19 2005
@@ -0,0 +1,3 @@
+# multipath wants the devmaps presented as meaninglful device names
+# so name them after their devmap name
+KERNEL="dm-[0-9]*", PROGRAM="/sbin/devmap_name %M %m", NAME="%k", SYMLINK="%c"
Added: multipath-tools/upstream/current/multipath/pgpolicies.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/pgpolicies.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,306 @@
+/*
+ * Here we define the path grouping policies
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <path_state.h>
+#include <safe_printf.h>
+#include <memory.h>
+#include <vector.h>
+#include <structs.h>
+#include "pgpolicies.h"
+
+extern int
+get_pgpolicy_id (char * str)
+{
+ if (0 == strncmp(str, "failover", 8))
+ return FAILOVER;
+ if (0 == strncmp(str, "multibus", 8))
+ return MULTIBUS;
+ if (0 == strncmp(str, "group_by_serial", 15))
+ return GROUP_BY_SERIAL;
+ if (0 == strncmp(str, "group_by_prio", 13))
+ return GROUP_BY_PRIO;
+ if (0 == strncmp(str, "group_by_node_name", 18))
+ return GROUP_BY_NODE_NAME;
+
+ return -1;
+}
+
+extern void
+get_pgpolicy_name (char * buff, int id)
+{
+ char * s;
+
+ switch (id) {
+ case FAILOVER:
+ s = "failover";
+ break;
+ case MULTIBUS:
+ s = "multibus";
+ break;
+ case GROUP_BY_SERIAL:
+ s = "group_by_serial";
+ break;
+ case GROUP_BY_PRIO:
+ s = "group_by_prio";
+ break;
+ case GROUP_BY_NODE_NAME:
+ s = "group_by_node_name";
+ break;
+ default:
+ s = "undefined";
+ break;
+ }
+ if(safe_snprintf(buff, POLICY_NAME_SIZE, "%s", s)) {
+ fprintf(stderr, "get_pgpolicy_name: buff too small\n");
+ exit(1);
+ }
+}
+
+extern void
+group_by_status (struct multipath * mp, int state)
+{
+ int i;
+ struct path * pp;
+ struct pathgroup * pgp;
+ vector failedpaths;
+ vector pathsleft;
+
+ if (mp->pg == NULL)
+ mp->pg = vector_alloc();
+
+ failedpaths = vector_alloc();
+ pathsleft = vector_alloc();
+
+ for (i = 0; i < VECTOR_SIZE(mp->paths); i++) {
+ pp = VECTOR_SLOT(mp->paths, i);
+
+ if (pp->state == state) {
+ vector_alloc_slot(failedpaths);
+ vector_set_slot(failedpaths, pp);
+ } else {
+ vector_alloc_slot(pathsleft);
+ vector_set_slot(pathsleft, pp);
+ }
+ }
+ if (VECTOR_SIZE(failedpaths) > 0) {
+ pgp = zalloc(sizeof(struct pathgroup));
+ pgp->paths = failedpaths;
+ vector_alloc_slot(mp->pg);
+ vector_set_slot(mp->pg, pgp);
+ vector_free(mp->paths);
+ mp->paths = pathsleft;
+ } else {
+ vector_free(pathsleft);
+ vector_free(failedpaths);
+ }
+ return;
+}
+
+/*
+ * One path group per unique tgt_node_name present in the path vector
+ */
+extern void
+group_by_node_name (struct multipath * mp) {
+ int i, j;
+ int * bitmap;
+ struct path * pp;
+ struct pathgroup * pgp;
+ struct path * pp2;
+
+ if (mp->pg == NULL)
+ mp->pg = vector_alloc();
+
+ /* init the bitmap */
+ bitmap = zalloc(VECTOR_SIZE(mp->paths) * sizeof (int));
+
+ for (i = 0; i < VECTOR_SIZE(mp->paths); i++) {
+
+ if (bitmap[i])
+ continue;
+
+ pp = VECTOR_SLOT(mp->paths, i);
+
+ /* here, we really got a new pg */
+ pgp = zalloc(sizeof(struct pathgroup));
+ pgp->paths = vector_alloc();
+ vector_alloc_slot(mp->pg);
+ vector_set_slot(mp->pg, pgp);
+
+ /* feed the first path */
+ vector_alloc_slot(pgp->paths);
+ vector_set_slot(pgp->paths, pp);
+
+ bitmap[i] = 1;
+
+ for (j = i + 1; j < VECTOR_SIZE(mp->paths); j++) {
+
+ if (bitmap[j])
+ continue;
+
+ pp2 = VECTOR_SLOT(mp->paths, j);
+
+ if (!strncmp(pp->tgt_node_name, pp2->tgt_node_name,
+ NODE_NAME_SIZE)) {
+ vector_alloc_slot(pgp->paths);
+ vector_set_slot(pgp->paths, pp2);
+ bitmap[j] = 1;
+ }
+ }
+ }
+ free(bitmap);
+ vector_free(mp->paths);
+ mp->paths = NULL;
+}
+
+/*
+ * One path group per unique serial number present in the path vector
+ */
+extern void
+group_by_serial (struct multipath * mp) {
+ int i, j;
+ int * bitmap;
+ struct path * pp;
+ struct pathgroup * pgp;
+ struct path * pp2;
+
+ if (mp->pg == NULL)
+ mp->pg = vector_alloc();
+
+ /* init the bitmap */
+ bitmap = zalloc(VECTOR_SIZE(mp->paths) * sizeof (int));
+
+ for (i = 0; i < VECTOR_SIZE(mp->paths); i++) {
+
+ if (bitmap[i])
+ continue;
+
+ pp = VECTOR_SLOT(mp->paths, i);
+
+ /* here, we really got a new pg */
+ pgp = zalloc(sizeof(struct pathgroup));
+ pgp->paths = vector_alloc();
+ vector_alloc_slot(mp->pg);
+ vector_set_slot(mp->pg, pgp);
+
+ /* feed the first path */
+ vector_alloc_slot(pgp->paths);
+ vector_set_slot(pgp->paths, pp);
+
+ bitmap[i] = 1;
+
+ for (j = i + 1; j < VECTOR_SIZE(mp->paths); j++) {
+
+ if (bitmap[j])
+ continue;
+
+ pp2 = VECTOR_SLOT(mp->paths, j);
+
+ if (0 == strcmp(pp->serial, pp2->serial)) {
+ vector_alloc_slot(pgp->paths);
+ vector_set_slot(pgp->paths, pp2);
+ bitmap[j] = 1;
+ }
+ }
+ }
+ free(bitmap);
+ vector_free(mp->paths);
+ mp->paths = NULL;
+}
+
+extern void
+one_path_per_group (struct multipath * mp)
+{
+ int i;
+ struct path * pp;
+ struct pathgroup * pgp;
+
+ if (mp->pg == NULL)
+ mp->pg = vector_alloc();
+
+ for (i = 0; i < VECTOR_SIZE(mp->paths); i++) {
+ pp = VECTOR_SLOT(mp->paths, i);
+ pgp = zalloc(sizeof(struct pathgroup));
+ pgp->paths = vector_alloc();
+ vector_alloc_slot(pgp->paths);
+ vector_set_slot(pgp->paths, pp);
+ vector_alloc_slot(mp->pg);
+ vector_set_slot(mp->pg, pgp);
+ }
+ vector_free(mp->paths);
+ mp->paths = NULL;
+}
+
+extern void
+one_group (struct multipath * mp) /* aka multibus */
+{
+ int i;
+ struct path * pp;
+ struct pathgroup * pgp;
+
+ pgp = zalloc(sizeof(struct pathgroup));
+ pgp->paths = vector_alloc();
+
+ if (mp->pg == NULL)
+ mp->pg = vector_alloc();
+
+ for (i = 0; i < VECTOR_SIZE(mp->paths); i++) {
+ pp = VECTOR_SLOT(mp->paths, i);
+ vector_alloc_slot(pgp->paths);
+ vector_set_slot(pgp->paths, pp);
+ }
+ if (VECTOR_SIZE(pgp->paths) > 0) {
+ vector_alloc_slot(mp->pg);
+ vector_set_slot(mp->pg, pgp);
+ } else {
+ vector_free(pgp->paths);
+ free(pgp);
+ }
+ vector_free(mp->paths);
+ mp->paths = NULL;
+ return;
+}
+
+extern void
+group_by_prio (struct multipath * mp)
+{
+ int i;
+ unsigned int prio;
+ struct path * pp;
+ struct pathgroup * pgp;
+
+ if (mp->pg == NULL)
+ mp->pg = vector_alloc();
+
+ while (VECTOR_SIZE(mp->paths) > 0) {
+ /*
+ * init a new pgpaths, put in the first path in mp->paths
+ */
+ pp = VECTOR_SLOT(mp->paths, 0);
+ prio = pp->priority;
+ pgp = zalloc(sizeof(struct pathgroup));
+ pgp->paths = vector_alloc();
+ vector_alloc_slot(pgp->paths);
+ vector_set_slot(pgp->paths, pp);
+ vector_alloc_slot(mp->pg);
+ vector_set_slot(mp->pg, pgp);
+ vector_del_slot(mp->paths, 0);
+
+ /*
+ * add the other paths with the same prio
+ */
+ for (i = 0; i < VECTOR_SIZE(mp->paths); i++) {
+ pp = VECTOR_SLOT(mp->paths, i);
+ if (pp->priority == prio) {
+ vector_alloc_slot(pgp->paths);
+ vector_set_slot(pgp->paths, pp);
+ vector_del_slot(mp->paths, i);
+ }
+ }
+ }
+ vector_free(mp->paths);
+ mp->paths = NULL;
+}
Added: multipath-tools/upstream/current/multipath/pgpolicies.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/pgpolicies.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,34 @@
+#ifndef _PGPOLICIES_H
+#define _PGPOLICIES_H
+
+#if 0
+#ifndef _MAIN_H
+#include "main.h"
+#endif
+#endif
+
+#define POLICY_NAME_SIZE 32
+
+/* Storage controlers capabilities */
+enum iopolicies {
+ IOPOLICY_RESERVED,
+ FAILOVER,
+ MULTIBUS,
+ GROUP_BY_SERIAL,
+ GROUP_BY_PRIO,
+ GROUP_BY_NODE_NAME
+};
+
+int get_pgpolicy_id(char *);
+void get_pgpolicy_name (char *, int);
+
+/*
+ * policies
+ */
+void one_path_per_group(struct multipath *);
+void one_group(struct multipath *);
+void group_by_serial(struct multipath *);
+void group_by_prio(struct multipath *);
+void group_by_node_name(struct multipath *);
+
+#endif
Added: multipath-tools/upstream/current/multipath/propsel.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/propsel.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,179 @@
+#include <stdio.h>
+#include <string.h>
+#include <vector.h>
+#include <checkers.h>
+#include <hwtable.h>
+
+#include "structs.h"
+#include "pgpolicies.h"
+#include "config.h"
+#include "debug.h"
+
+/*
+ * helpers
+ */
+extern struct mpentry *
+find_mp (char * wwid)
+{
+ int i;
+ struct mpentry * mpe;
+
+ vector_foreach_slot (conf->mptable, mpe, i)
+ if (mpe->wwid && strcmp(mpe->wwid, wwid) == 0)
+ return mpe;
+
+ return NULL;
+}
+
+/*
+ * selectors :
+ * traverse the configuration layers from most specific to most generic
+ * stop at first explicit setting found
+ */
+extern int
+select_pgpolicy (struct multipath * mp)
+{
+ struct path * pp;
+ char pgpolicy_name[POLICY_NAME_SIZE];
+
+ pp = VECTOR_SLOT(mp->paths, 0);
+
+ if (conf->pgpolicy_flag > 0) {
+ mp->pgpolicy = conf->pgpolicy_flag;
+ get_pgpolicy_name(pgpolicy_name, mp->pgpolicy);
+ dbg("pgpolicy = %s (cmd line flag)", pgpolicy_name);
+ return 0;
+ }
+ if (mp->mpe && mp->mpe->pgpolicy > 0) {
+ mp->pgpolicy = mp->mpe->pgpolicy;
+ get_pgpolicy_name(pgpolicy_name, mp->pgpolicy);
+ dbg("pgpolicy = %s (LUN setting)", pgpolicy_name);
+ return 0;
+ }
+ if (mp->hwe && mp->hwe->pgpolicy > 0) {
+ mp->pgpolicy = mp->hwe->pgpolicy;
+ get_pgpolicy_name(pgpolicy_name, mp->pgpolicy);
+ dbg("pgpolicy = %s (controler setting)", pgpolicy_name);
+ return 0;
+ }
+ if (conf->default_pgpolicy > 0) {
+ mp->pgpolicy = conf->default_pgpolicy;
+ get_pgpolicy_name(pgpolicy_name, mp->pgpolicy);
+ dbg("pgpolicy = %s (config file default)", pgpolicy_name);
+ return 0;
+ }
+ mp->pgpolicy = FAILOVER;
+ get_pgpolicy_name(pgpolicy_name, FAILOVER);
+ dbg("pgpolicy = %s (internal default)", pgpolicy_name);
+ return 0;
+}
+
+extern int
+select_selector (struct multipath * mp)
+{
+ if (mp->mpe && mp->mpe->selector) {
+ mp->selector = mp->mpe->selector;
+ dbg("selector = %s (LUN setting)", mp->selector);
+ return 0;
+ }
+ if (mp->hwe && mp->hwe->selector) {
+ mp->selector = mp->hwe->selector;
+ dbg("selector = %s (controler setting)", mp->selector);
+ return 0;
+ }
+ mp->selector = conf->default_selector;
+ dbg("selector = %s (internal default)", mp->selector);
+ return 0;
+}
+
+extern int
+select_alias (struct multipath * mp)
+{
+ if (mp->mpe && mp->mpe->alias)
+ mp->alias = mp->mpe->alias;
+ else
+ mp->alias = mp->wwid;
+
+ return 0;
+}
+
+extern int
+select_features (struct multipath * mp)
+{
+ if (mp->hwe && mp->hwe->features) {
+ mp->features = mp->hwe->features;
+ dbg("features = %s (controler setting)", mp->features);
+ return 0;
+ }
+ mp->features = conf->default_features;
+ dbg("features = %s (internal default)", mp->features);
+ return 0;
+}
+
+extern int
+select_hwhandler (struct multipath * mp)
+{
+ if (mp->hwe && mp->hwe->hwhandler) {
+ mp->hwhandler = mp->hwe->hwhandler;
+ dbg("hwhandler = %s (controler setting)", mp->hwhandler);
+ return 0;
+ }
+ mp->hwhandler = conf->default_hwhandler;
+ dbg("hwhandler = %s (internal default)", mp->hwhandler);
+ return 0;
+}
+
+extern int
+select_checkfn(struct path *pp)
+{
+ char checker_name[CHECKER_NAME_SIZE];
+ struct hwentry * hwe = NULL;
+
+ hwe = find_hw(conf->hwtable, pp->vendor_id, pp->product_id);
+
+ if (hwe && hwe->checker_index > 0) {
+ get_checker_name(checker_name, hwe->checker_index);
+ dbg("path checker = %s (controler setting)", checker_name);
+ pp->checkfn = get_checker_addr(hwe->checker_index);
+ return 0;
+ }
+ pp->checkfn = &readsector0;
+ get_checker_name(checker_name, READSECTOR0);
+ dbg("path checker = %s (internal default)", checker_name);
+ return 0;
+}
+
+extern int
+select_getuid (struct path * pp)
+{
+ struct hwentry * hwe = NULL;
+
+ hwe = find_hw(conf->hwtable, pp->vendor_id, pp->product_id);
+
+ if (hwe && hwe->getuid) {
+ pp->getuid = hwe->getuid;
+ dbg("getuid = %s (controler setting)", pp->getuid);
+ return 0;
+ }
+ pp->getuid = conf->default_getuid;
+ dbg("getuid = %s (internal default)", pp->getuid);
+ return 0;
+}
+
+extern int
+select_getprio (struct path * pp)
+{
+ struct hwentry * hwe = NULL;
+
+ hwe = find_hw(conf->hwtable, pp->vendor_id, pp->product_id);
+
+ if (hwe && hwe->getprio) {
+ pp->getprio = hwe->getprio;
+ dbg("getprio = %s (controler setting)", pp->getprio);
+ return 0;
+ }
+ pp->getprio = conf->default_getprio;
+ dbg("getprio = %s (internal default)", pp->getprio);
+ return 0;
+}
+
Added: multipath-tools/upstream/current/multipath/propsel.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/propsel.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,11 @@
+struct mpentry * find_mp (char * wwid);
+
+int select_pgpolicy (struct multipath * mp);
+int select_selector (struct multipath * mp);
+int select_alias (struct multipath * mp);
+int select_features (struct multipath * mp);
+int select_hwhandler (struct multipath * mp);
+int select_checkfn(struct path *pp);
+int select_getuid (struct path * pp);
+int select_getprio (struct path * pp);
+
Added: multipath-tools/upstream/current/multipath/sg_include.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipath/sg_include.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,2 @@
+#define __user
+#include <scsi/sg.h>
Added: multipath-tools/upstream/current/multipathd/Makefile
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipathd/Makefile Fri Mar 4 08:05:19 2005
@@ -0,0 +1,68 @@
+BUILD = glibc
+EXEC = multipathd
+
+#
+# debug verbosity, same as syslog.h
+# nothing to below 5, full debug at 7
+#
+LOGLEVEL = 7
+
+include ../Makefile.inc
+
+#
+# directories where to put stuff
+#
+bindir = /usr/bin
+mandir = /usr/share/man/man8
+rcdir = /etc/init.d
+
+#
+# basic flags setting
+#
+CFLAGS = -pipe -g -Wall -Wunused -Wstrict-prototypes -DLOGLEVEL=$(LOGLEVEL) \
+ -I$(multipathdir) -I$(checkersdir)
+LDFLAGS = -lpthread -ldevmapper -lsysfs
+
+#
+# object files
+#
+OBJS = main.o copy.o devinfo.o dict.o \
+ $(CHECKERSLIB)-glibc.a \
+ $(MULTIPATHLIB)-glibc.a \
+
+#
+# directives
+#
+all : $(BUILD)
+
+glibc: $(EXEC)
+
+klibc: glibc
+
+$(EXEC): $(OBJS)
+ $(CC) $(OBJS) -o $(EXEC) $(LDFLAGS)
+ strip $(EXEC)
+ $(GZIP) $(EXEC).8 > $(EXEC).8.gz
+
+$(CHECKERSLIB)-glibc.a:
+ $(MAKE) -C $(checkersdir) BUILD=glibc glibc
+
+$(MULTIPATHLIB)-glibc.a:
+ $(MAKE) -C $(multipathdir) BUILD=glibc glibc
+
+install:
+ install -d $(DESTDIR)$(bindir)
+ install -m 755 $(EXEC) $(DESTDIR)$(bindir)
+ install -d $(DESTDIR)$(rcdir)
+ install -m 755 multipathd.init $(DESTDIR)$(rcdir)/$(EXEC)
+ install -d $(DESTDIR)$(mandir)
+ install -m 644 $(EXEC).8.gz $(DESTDIR)$(mandir)
+
+uninstall:
+ rm -f $(DESTDIR)$(bindir)/$(EXEC)
+ rm -f $(DESTDIR)$(rcdir)/$(EXEC)
+ rm -f $(DESTDIR)$(mandir)/$(EXEC).8.gz
+
+clean:
+ rm -f core *.o $(EXEC) *.gz
+
Added: multipath-tools/upstream/current/multipathd/clone_platform.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipathd/clone_platform.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,15 @@
+/*
+ * This file is copied from the LTP project. Thanks.
+ * It is covered by the GPLv2, see the LICENSE file
+ */
+#define CHILD_STACK_SIZE 16384
+
+#if defined (__s390__) || (__s390x__)
+#define clone __clone
+extern int __clone(int(void*),void*,int,void*);
+#elif defined(__ia64__)
+#define clone2 __clone2
+extern int __clone2(int (*fn) (void *arg), void *child_stack_base,
+ size_t child_stack_size, int flags, void *arg,
+ pid_t *parent_tid, void *tls, pid_t *child_tid);
+#endif
Added: multipath-tools/upstream/current/multipathd/copy.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipathd/copy.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,98 @@
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+#include <syslog.h>
+#include <errno.h>
+#include <util.h>
+
+#define FILESIZE 128
+
+int
+copy (char * src, char * dst)
+{
+ int fdin;
+ int fdout;
+ char * mmsrc;
+ char * mmdst;
+ struct stat statbuf;
+
+ fdin = open (src, O_RDONLY);
+
+ if (fdin < 0) {
+ syslog(3, "[copy.c] cannot open %s", src);
+ return -1;
+ }
+ /*
+ * Stat the input file to obtain its size
+ */
+ if (fstat (fdin, &statbuf) < 0) {
+ syslog(3, "[copy.c] cannot stat %s", src);
+ goto out1;
+ }
+ /*
+ * Open the output file for writing,
+ * with the same permissions as the source file
+ */
+ fdout = open (dst, O_RDWR | O_CREAT | O_TRUNC, statbuf.st_mode);
+
+ if (fdout < 0) {
+ syslog(3, "[copy.c] cannot open %s", dst);
+ goto out1;
+ }
+
+ if (lseek (fdout, statbuf.st_size - 1, SEEK_SET) == -1) {
+ syslog(3, "[copy.c] cannot lseek %s", dst);
+ goto out2;
+ }
+
+ if (write (fdout, "", 1) != 1) {
+ syslog(3, "[copy.c] cannot write dummy char");
+ goto out2;
+ }
+ /*
+ * Blast the bytes from one file to the other
+ */
+ if ((mmsrc = mmap(0, statbuf.st_size, PROT_READ, MAP_SHARED, fdin, 0))
+ == (caddr_t) -1) {
+ syslog(3, "[copy.c] cannot mmap %s", src);
+ goto out2;
+ }
+
+ if ((mmdst = mmap(0, statbuf.st_size, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fdout, 0)) == (caddr_t) -1) {
+ syslog(3, "[copy.c] cannot mmap %s", dst);
+ goto out3;
+ }
+ memcpy(mmdst, mmsrc, statbuf.st_size);
+
+/* done */
+ munmap(mmdst, statbuf.st_size);
+out3:
+ munmap(mmsrc, statbuf.st_size);
+out2:
+ close (fdout);
+out1:
+ close (fdin);
+
+ return 0;
+}
+
+int
+copytodir (char * src, char * dstdir)
+{
+ char dst[FILESIZE];
+ char filename[FILESIZE];
+
+ basename(src, filename);
+ if (FILESIZE <= snprintf(dst, FILESIZE, "%s/%s", dstdir, filename)) {
+ syslog(3, "[copy.c] filename buffer overflow : %s ", filename);
+ return -1;
+ }
+
+ return copy(src, dst);
+}
Added: multipath-tools/upstream/current/multipathd/copy.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipathd/copy.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,6 @@
+#ifndef _COPY_H
+#define _COPY_H
+
+int copytodir (char *, char *);
+
+#endif /* _COPY_H */
Added: multipath-tools/upstream/current/multipathd/devinfo.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipathd/devinfo.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,24 @@
+#include <sysfs/libsysfs.h>
+
+#include "devinfo.h"
+#include "sysfs_devinfo.h"
+
+int
+get_lun_strings(char * vendor_id, char * product_id, char * rev, char * dev)
+{
+ char sysfs_path[SYSFS_PATH_SIZE];
+
+ if (sysfs_get_mnt_path (sysfs_path, SYSFS_PATH_SIZE))
+ return 1;
+
+ if (sysfs_get_vendor(sysfs_path, dev, vendor_id, 8))
+ return 1;
+
+ if (sysfs_get_model(sysfs_path, dev, product_id, 16))
+ return 1;
+
+ if (sysfs_get_rev(sysfs_path, dev, rev, 4))
+ return 1;
+
+ return 0;
+}
Added: multipath-tools/upstream/current/multipathd/devinfo.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipathd/devinfo.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,6 @@
+#ifndef _DEVINFO_H
+#define _DEVINFO_H
+
+int get_lun_strings (char *, char *, char *, char *);
+
+#endif /* _DEVINFO_H */
Added: multipath-tools/upstream/current/multipathd/dict.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipathd/dict.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,169 @@
+#include <syslog.h>
+#include <checkers.h>
+#include <vector.h>
+#include <hwtable.h>
+
+#include "main.h"
+#include "parser.h"
+#include "memory.h"
+
+/*
+ * helper function to draw a list of callout binaries found in the config file
+ */
+extern void
+push_callout(char * callout)
+{
+ int i;
+ char * bin;
+ char * p;
+
+ /*
+ * purge command line arguments
+ */
+ p = callout;
+
+ while (*p != ' ' && *p != '\0')
+ p++;
+
+ if (binvec == NULL)
+ binvec = vector_alloc();
+
+ /*
+ * if this callout is already stored in binvec, don't store it twice
+ */
+ vector_foreach_slot (binvec, bin, i)
+ if (memcmp(bin, callout, p - callout) == 0)
+ return;
+
+ /*
+ * else, store it
+ */
+ bin = MALLOC((p - callout) + 1);
+ strncpy(bin, callout, p - callout);
+ syslog(LOG_DEBUG, "add %s to binvec", bin);
+
+ vector_alloc_slot(binvec);
+ vector_set_slot(binvec, bin);
+}
+
+/*
+ * devices block handlers
+ */
+static void
+multipath_tool_handler(vector strvec)
+{
+ multipath = set_value(strvec);
+ push_callout(multipath);
+}
+
+static void
+polling_interval_handler(vector strvec)
+{
+ char * buff;
+
+ buff = VECTOR_SLOT(strvec, 1);
+ checkint = atoi(buff);
+}
+
+static void
+blacklist_handler(vector strvec)
+{
+ blist = vector_alloc();
+}
+
+static void
+devnode_handler(vector strvec)
+{
+ char * buff;
+
+ buff = set_value(strvec);
+ vector_alloc_slot(blist);
+ vector_set_slot(blist, buff);
+}
+
+/*
+ * devices block handlers
+ */
+static void
+devices_handler(vector strvec)
+{
+ hwtable = vector_alloc();
+}
+
+static void
+device_handler(vector strvec)
+{
+ struct hwentry * hwe;
+
+ vector_alloc_slot(hwtable);
+ hwe = MALLOC(sizeof(struct hwentry));
+ vector_set_slot(hwtable, hwe);
+}
+
+static void
+vendor_handler(vector strvec)
+{
+ struct hwentry * hwe;
+
+ hwe = VECTOR_SLOT(hwtable, VECTOR_SIZE(hwtable) - 1);
+ hwe->vendor = set_value(strvec);
+}
+
+static void
+product_handler(vector strvec)
+{
+ struct hwentry * hwe;
+
+ hwe = VECTOR_SLOT(hwtable, VECTOR_SIZE(hwtable) - 1);
+ hwe->product = set_value(strvec);
+}
+
+static void
+path_checker_handler(vector strvec)
+{
+ char * buff;
+ struct hwentry * hwe = VECTOR_SLOT(hwtable, VECTOR_SIZE(hwtable) - 1);
+
+ buff = set_value(strvec);
+ hwe->checker_index = get_checker_id(buff);
+
+ FREE(buff);
+}
+
+static void
+default_tool_handler(vector strvec)
+{
+ char * callout;
+
+ callout = set_value(strvec);
+ push_callout(callout);
+}
+
+/*
+ * keyword tree declaration
+ */
+vector
+init_keywords(void)
+{
+ keywords = vector_alloc();
+
+ install_keyword_root("defaults", NULL);
+ install_keyword("default_getuid_callout", &default_tool_handler);
+ install_keyword("default_prio_callout", &default_tool_handler);
+ install_keyword("polling_interval", &polling_interval_handler);
+ install_keyword("multipath_tool", &multipath_tool_handler);
+
+ install_keyword_root("devnode_blacklist", &blacklist_handler);
+ install_keyword("devnode", &devnode_handler);
+
+ install_keyword_root("devices", &devices_handler);
+ install_keyword("device", &device_handler);
+ install_sublevel();
+ install_keyword("vendor", &vendor_handler);
+ install_keyword("product", &product_handler);
+ install_keyword("path_checker", &path_checker_handler);
+ install_keyword("getuid_callout", &default_tool_handler);
+ install_sublevel_end();
+
+ return keywords;
+}
Added: multipath-tools/upstream/current/multipathd/dict.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipathd/dict.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,9 @@
+#ifndef _DICT_H
+#define _DICT_H
+
+#include "vector.h"
+
+vector init_keywords(void);
+void push_callout(char * callout);
+
+#endif /* _DICT_H */
Added: multipath-tools/upstream/current/multipathd/main.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipathd/main.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,915 @@
+#include <string.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <linux/unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <libdevmapper.h>
+#include <signal.h>
+#include <wait.h>
+#include <sched.h>
+#include <errno.h>
+#include <syslog.h>
+#include <sys/mount.h>
+#include <sys/mman.h>
+
+/*
+ * libsysfs
+ */
+#include <sysfs/libsysfs.h>
+#include <sysfs/dlist.h>
+
+/*
+ * libcheckers
+ */
+#include <checkers.h>
+#include <path_state.h>
+
+/*
+ * libmultipath
+ */
+#include <sysfs_devinfo.h>
+#include <parser.h>
+#include <vector.h>
+#include <memory.h>
+#include <callout.h>
+#include <safe_printf.h>
+#include <blacklist.h>
+#include <hwtable.h>
+#include <defaults.h>
+#include <structs.h>
+
+#include "main.h"
+#include "dict.h"
+#include "devinfo.h"
+#include "copy.h"
+#include "clone_platform.h"
+
+#define FILE_NAME_SIZE 256
+#define CMDSIZE 160
+
+#define CALLOUT_DIR "/var/cache/multipathd"
+
+#ifndef LOGLEVEL
+#define LOGLEVEL 5
+#endif
+
+#define LOG_MSG(a,b) \
+ if (strlen(a)) { \
+ syslog(LOG_WARNING, "%s: %s", b, a); \
+ memset(a, 0, MAX_CHECKER_MSG_SIZE); \
+ }
+
+/*
+ * global vars
+ */
+int from_sighup;
+pthread_mutex_t *event_lock;
+pthread_cond_t *event;
+
+/*
+ * structs
+ */
+struct paths {
+ pthread_mutex_t *lock;
+ vector pathvec;
+};
+
+struct event_thread {
+ pthread_t *thread;
+ pthread_mutex_t *waiter_lock;
+ int event_nr;
+ char mapname[WWID_SIZE];
+};
+
+/*
+ * helpers functions
+ */
+static void
+strvec_free (vector vec)
+{
+ int i;
+ char * str;
+
+ vector_foreach_slot (vec, str, i)
+ if (str)
+ FREE(str);
+
+ vector_free(vec);
+}
+
+static int
+select_checkfn(struct path *pp, char *devname)
+{
+ char vendor[SCSI_VENDOR_SIZE];
+ char product[SCSI_PRODUCT_SIZE];
+ char rev[SCSI_REV_SIZE];
+ char checker_name[CHECKER_NAME_SIZE];
+ int r;
+ struct hwentry * hwe;
+
+ /*
+ * default checkfn
+ */
+ pp->checkfn = &readsector0;
+
+ r = get_lun_strings(vendor, product, rev, devname);
+
+ if (r) {
+ syslog(LOG_ERR, "can not get scsi strings");
+ return r;
+ }
+ hwe = find_hw(hwtable, vendor, product);
+
+ if (hwe && hwe->checker_index > 0) {
+ get_checker_name(checker_name, hwe->checker_index);
+ syslog(LOG_INFO, "set %s path checker for %s",
+ checker_name, devname);
+ pp->checkfn = get_checker_addr(hwe->checker_index);
+ return 0;
+ }
+ syslog(LOG_INFO, "set readsector0 path checker for %s (default)",
+ devname);
+ return 0;
+}
+
+static int
+exit_daemon (int status)
+{
+ if (status != 0)
+ fprintf(stderr, "bad exit status. see daemon.log\n");
+
+ syslog(LOG_INFO, "umount ramfs");
+ umount(CALLOUT_DIR);
+
+ syslog(LOG_INFO, "unlink pidfile");
+ unlink(DEFAULT_PIDFILE);
+
+ syslog(LOG_NOTICE, "--------shut down-------");
+ exit(status);
+}
+
+static void *
+get_devmaps (void)
+{
+ char *devmap;
+ struct dm_task *dmt, *dmt1;
+ struct dm_names *names = NULL;
+ unsigned next = 0;
+ void *nexttgt;
+ uint64_t start, length;
+ char *target_type = NULL;
+ char *params;
+ vector devmaps;
+
+ devmaps = vector_alloc();
+
+ if (!(dmt = dm_task_create(DM_DEVICE_LIST)))
+ return NULL;
+
+ if (!dm_task_run(dmt)) {
+ devmaps = NULL;
+ goto out;
+ }
+
+ if (!(names = dm_task_get_names(dmt))) {
+ devmaps = NULL;
+ goto out;
+ }
+
+ if (!names->dev) {
+ syslog(LOG_WARNING, "no devmap found");
+ goto out;
+ }
+
+ do {
+ /*
+ * keep only multipath maps
+ */
+ names = (void *) names + next;
+ nexttgt = NULL;
+ syslog(LOG_DEBUG, "devmap %s :", names->name);
+
+ if (!(dmt1 = dm_task_create(DM_DEVICE_STATUS)))
+ goto out;
+
+ if (!dm_task_set_name(dmt1, names->name))
+ goto out1;
+
+ if (!dm_task_run(dmt1))
+ goto out1;
+
+ do {
+ nexttgt = dm_get_next_target(dmt1, nexttgt,
+ &start,
+ &length,
+ &target_type,
+ ¶ms);
+ syslog(LOG_DEBUG, "\\_ %lu %lu %s",
+ (unsigned long) start,
+ (unsigned long) length,
+ target_type);
+
+ if (!target_type) {
+ syslog(LOG_INFO, " unknown target type");
+ goto out1;
+ }
+
+ if (!strncmp(target_type, "multipath", 9)) {
+ devmap = MALLOC(WWID_SIZE);
+ strcpy(devmap, names->name);
+ vector_alloc_slot(devmaps);
+ vector_set_slot(devmaps, devmap);
+ } else
+ syslog(LOG_DEBUG,
+ " skip non multipath target");
+ } while (nexttgt);
+
+out1:
+ dm_task_destroy(dmt1);
+ next = names->next;
+
+ } while (next);
+
+out:
+ dm_task_destroy(dmt);
+ return devmaps;
+}
+
+static int
+updatepaths (struct paths *allpaths, char *sysfs_path)
+{
+ int i;
+ struct path *pp;
+ struct sysfs_directory * sdir;
+ struct sysfs_directory * devp;
+ char path[FILE_NAME_SIZE];
+ char attr_path[FILE_NAME_SIZE];
+ char attr_buff[17];
+
+ if (safe_sprintf(path, "%s/block", sysfs_path)) {
+ fprintf(stderr, "updatepaths: path too small\n");
+ return 1;
+ }
+ sdir = sysfs_open_directory(path);
+
+ if (!sdir) {
+ syslog(LOG_ERR, "cannot open %s/block", sysfs_path);
+ return 1;
+ }
+ if (sysfs_read_dir_subdirs(sdir) < 0) {
+ syslog(LOG_ERR, "cannot open %s/block subdirs", sysfs_path);
+ sysfs_close_directory(sdir);
+ return 1;
+ }
+ pthread_mutex_lock(allpaths->lock);
+
+ dlist_for_each_data(sdir->subdirs, devp, struct sysfs_directory) {
+ if (blacklist(blist, devp->name)) {
+ syslog(LOG_DEBUG, "%s blacklisted", devp->name);
+ continue;
+ }
+ memset(attr_buff, 0, sizeof (attr_buff));
+ memset(attr_path, 0, sizeof (attr_path));
+
+ if (safe_sprintf(attr_path, "%s/block/%s/dev",
+ sysfs_path, devp->name)) {
+ fprintf(stderr, "updatepaths: attr_path too small\n");
+ continue;
+ }
+ if (0 > sysfs_read_attribute_value(attr_path, attr_buff, 17)) {
+ syslog(LOG_ERR, "no such attribute : %s",
+ attr_path);
+ continue;
+ }
+ /*
+ * detect if path already exists in path vector
+ * if so, keep the old one for for checker context and
+ * state persistance
+ */
+ vector_foreach_slot (allpaths->pathvec, pp, i)
+ if (!strncmp(pp->dev_t, attr_buff,
+ strlen(pp->dev_t) + 1))
+ break;
+
+ if (i < VECTOR_SIZE(allpaths->pathvec)) {
+ syslog(LOG_INFO, "path checker already active : %s",
+ pp->dev_t);
+ continue;
+ }
+
+ /*
+ * ok, really allocate a path
+ */
+ pp = MALLOC(sizeof(struct path));
+
+ if (safe_snprintf(pp->dev_t, BLK_DEV_SIZE, "%s",
+ attr_buff)) {
+ fprintf(stderr, "dev_t too small\n");
+ FREE(pp);
+ continue;
+ }
+ if (select_checkfn(pp, devp->name)) {
+ FREE(pp);
+ continue;
+ }
+ pp->state = pp->checkfn(pp->dev_t, NULL, &pp->checker_context);
+ vector_alloc_slot(allpaths->pathvec);
+ vector_set_slot(allpaths->pathvec, pp);
+ syslog(LOG_NOTICE, "path checker startup : %s", pp->dev_t);
+ }
+ pthread_mutex_unlock(allpaths->lock);
+ sysfs_close_directory(sdir);
+ return 0;
+}
+
+static int
+geteventnr (char *name)
+{
+ struct dm_task *dmt;
+ struct dm_info info;
+
+ if (!(dmt = dm_task_create(DM_DEVICE_INFO)))
+ return 0;
+
+ if (!dm_task_set_name(dmt, name))
+ goto out;
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ if (!dm_task_get_info(dmt, &info)) {
+ info.event_nr = 0;
+ goto out;
+ }
+
+ if (!info.exists) {
+ syslog(LOG_ERR, "Device %s does not exist", name);
+ info.event_nr = 0;
+ goto out;
+ }
+
+out:
+ dm_task_destroy(dmt);
+
+ return info.event_nr;
+}
+
+static void *
+waitevent (void * et)
+{
+ struct event_thread *waiter;
+ char buff[1];
+ char cmd[CMDSIZE];
+ struct dm_task *dmt;
+
+ mlockall(MCL_CURRENT | MCL_FUTURE);
+ waiter = (struct event_thread *)et;
+
+ if (safe_snprintf(cmd, CMDSIZE, "%s %s", multipath, waiter->mapname)) {
+ syslog(LOG_ERR, "command too long, abord reconfigure");
+ return NULL;
+ }
+ pthread_mutex_lock (waiter->waiter_lock);
+
+ waiter->event_nr = geteventnr (waiter->mapname);
+ syslog(LOG_DEBUG, "waiter->event_nr = %i", waiter->event_nr);
+
+ if (!(dmt = dm_task_create(DM_DEVICE_WAITEVENT)))
+ return 0;
+
+ if (!dm_task_set_name(dmt, waiter->mapname))
+ goto out;
+
+ if (waiter->event_nr && !dm_task_set_event_nr(dmt, waiter->event_nr))
+ goto out;
+
+ dm_task_run(dmt);
+
+out:
+ dm_task_destroy(dmt);
+
+ syslog(LOG_DEBUG, "%s", cmd);
+ syslog(LOG_NOTICE, "devmap event on %s", waiter->mapname);
+ execute_program(cmd, buff, 1);
+
+ /*
+ * tell waiterloop we have an event
+ */
+ pthread_mutex_lock (event_lock);
+ pthread_cond_signal(event);
+ pthread_mutex_unlock (event_lock);
+
+ /*
+ * release waiter_lock so that waiterloop knows we are gone
+ */
+ pthread_mutex_unlock (waiter->waiter_lock);
+ pthread_exit(waiter->thread);
+
+ return (NULL);
+}
+
+static void *
+waiterloop (void *ap)
+{
+ struct paths * allpaths;
+ vector devmaps = NULL;
+ char * devmap;
+ vector waiters;
+ struct event_thread *wp;
+ pthread_attr_t attr;
+ int r;
+ char buff[1];
+ int i, j;
+ char sysfs_path[FILE_NAME_SIZE];
+
+ syslog(LOG_NOTICE, "start DM events thread");
+ mlockall(MCL_CURRENT | MCL_FUTURE);
+
+ if (sysfs_get_mnt_path(sysfs_path, FILE_NAME_SIZE)) {
+ syslog(LOG_ERR, "can not find sysfs mount point");
+ return NULL;
+ }
+
+ /*
+ * inits
+ */
+ allpaths = (struct paths *)ap;
+ waiters = vector_alloc();
+ pthread_attr_init(&attr);
+ pthread_attr_setstacksize(&attr, 32 * 1024);
+
+ syslog(LOG_NOTICE, "initial reconfigure multipath maps");
+ execute_program(multipath, buff, 1);
+
+ while (1) {
+ /*
+ * update devmap list
+ */
+ syslog(LOG_INFO, "refresh devmaps list");
+ if (devmaps != NULL)
+ strvec_free(devmaps);
+
+ while ((devmaps = get_devmaps()) == NULL) {
+ /*
+ * we're not allowed to fail here
+ */
+ syslog(LOG_ERR, "can't get devmaps ... retry");
+ sleep(5);
+ }
+
+ /*
+ * update paths list
+ */
+ syslog(LOG_INFO, "refresh failpaths list");
+
+ while(updatepaths(allpaths, sysfs_path)) {
+ syslog(LOG_ERR, "can't update path list ... retry");
+ sleep(5);
+ }
+
+ /*
+ * start waiters on all devmaps
+ */
+ syslog(LOG_INFO, "start up event loops");
+
+ vector_foreach_slot (devmaps, devmap, i) {
+ /*
+ * find out if devmap already has
+ * a running waiter thread
+ */
+ vector_foreach_slot (waiters, wp, j)
+ if (!strcmp (wp->mapname, devmap))
+ break;
+
+ /*
+ * no event_thread struct : init it
+ */
+ if (j == VECTOR_SIZE(waiters)) {
+ wp = MALLOC (sizeof (struct event_thread));
+ strncpy (wp->mapname, devmap, WWID_SIZE);
+ wp->thread = MALLOC (sizeof (pthread_t));
+ wp->waiter_lock = (pthread_mutex_t *)
+ MALLOC (sizeof (pthread_mutex_t));
+ pthread_mutex_init (wp->waiter_lock, NULL);
+ vector_alloc_slot (waiters);
+ vector_set_slot (waiters, wp);
+ }
+
+ /*
+ * event_thread struct found
+ */
+ if (j < VECTOR_SIZE(waiters)) {
+ r = pthread_mutex_trylock (wp->waiter_lock);
+
+ /*
+ * thread already running : next devmap
+ */
+ if (r)
+ continue;
+
+ pthread_mutex_unlock (wp->waiter_lock);
+ }
+
+ syslog(LOG_NOTICE, "event checker startup : %s",
+ wp->mapname);
+ pthread_create (wp->thread, &attr, waitevent, wp);
+ pthread_detach (*wp->thread);
+ }
+ /*
+ * wait event condition
+ */
+ pthread_mutex_lock (event_lock);
+ pthread_cond_wait(event, event_lock);
+ pthread_mutex_unlock (event_lock);
+ }
+
+ return (NULL);
+}
+
+static void *
+checkerloop (void *ap)
+{
+ struct paths *allpaths;
+ struct path *pp;
+ int i;
+ int newstate;
+ char buff[1];
+ char cmd[CMDSIZE];
+ char checker_msg[MAX_CHECKER_MSG_SIZE];
+
+ memset(checker_msg, 0, MAX_CHECKER_MSG_SIZE);
+
+ mlockall(MCL_CURRENT | MCL_FUTURE);
+ allpaths = (struct paths *)ap;
+
+ syslog(LOG_NOTICE, "path checkers start up");
+
+ while (1) {
+ pthread_mutex_lock(allpaths->lock);
+ syslog(LOG_DEBUG, "checking paths");
+
+ vector_foreach_slot (allpaths->pathvec, pp, i) {
+ if (!pp->checkfn) {
+ syslog(LOG_ERR, "checkfn is void");
+ continue;
+ }
+ newstate = pp->checkfn(pp->dev_t, checker_msg,
+ &pp->checker_context);
+
+ if (newstate != pp->state) {
+ pp->state = newstate;
+ LOG_MSG(checker_msg, pp->dev_t);
+
+ /*
+ * don't trigger map reconfiguration for
+ * path going down. It will be handled
+ * in due time by DM event waiters
+ */
+ if (newstate == PATH_DOWN ||
+ newstate == PATH_SHAKY)
+ continue;
+
+ /*
+ * reconfigure map now
+ */
+ if (safe_snprintf(cmd, CMDSIZE, "%s %s",
+ multipath, pp->dev_t)) {
+ syslog(LOG_ERR, "command too long,"
+ " abord reconfigure");
+ } else {
+ syslog(LOG_DEBUG, "%s", cmd);
+ syslog(LOG_INFO,
+ "reconfigure %s multipath",
+ pp->dev_t);
+ execute_program(cmd, buff, 1);
+ }
+
+ /*
+ * tell waiterloop we have an event
+ */
+ pthread_mutex_lock (event_lock);
+ pthread_cond_signal(event);
+ pthread_mutex_unlock (event_lock);
+ }
+ pp->state = newstate;
+ }
+ pthread_mutex_unlock(allpaths->lock);
+ sleep(checkint);
+ }
+ return (NULL);
+}
+
+static struct paths *
+initpaths (void)
+{
+ struct paths *allpaths;
+
+ allpaths = MALLOC (sizeof (struct paths));
+ allpaths->lock =
+ (pthread_mutex_t *) MALLOC (sizeof (pthread_mutex_t));
+ allpaths->pathvec = vector_alloc();
+ pthread_mutex_init (allpaths->lock, NULL);
+
+ event = (pthread_cond_t *) MALLOC (sizeof (pthread_cond_t));
+ pthread_cond_init (event, NULL);
+ event_lock = (pthread_mutex_t *) MALLOC (sizeof (pthread_mutex_t));
+ pthread_mutex_init (event_lock, NULL);
+
+ return (allpaths);
+}
+
+/*
+ * this logic is all about keeping callouts working in case of
+ * system disk outage (think system over SAN)
+ * this needs the clone syscall, so don't bother if not present
+ * (Debian Woody)
+ */
+#ifdef CLONE_NEWNS
+static int
+prepare_namespace(void)
+{
+ mode_t mode;
+ struct stat *buf;
+ char ramfs_args[64];
+ int i;
+ int fd;
+ char * bin;
+ size_t size = 10;
+ struct stat statbuf;
+
+ buf = MALLOC(sizeof(struct stat));
+
+ /*
+ * create a temp mount point for ramfs
+ */
+ if (stat (CALLOUT_DIR, buf) < 0) {
+ if (mkdir(CALLOUT_DIR, mode) < 0) {
+ syslog(LOG_ERR, "cannot create " CALLOUT_DIR);
+ return -1;
+ }
+ syslog(LOG_DEBUG, "created " CALLOUT_DIR);
+ }
+
+ /*
+ * compute the optimal ramdisk size
+ */
+ vector_foreach_slot (binvec, bin,i) {
+ if ((fd = open(bin, O_RDONLY)) < 0) {
+ syslog(LOG_ERR, "cannot open %s", bin);
+ return -1;
+ }
+ if (fstat(fd, &statbuf) < 0) {
+ syslog(LOG_ERR, "cannot stat %s", bin);
+ return -1;
+ }
+ size += statbuf.st_size;
+ close(fd);
+ }
+ syslog(LOG_INFO, "ramfs maxsize is %u", (unsigned int) size);
+
+ /*
+ * mount the ramfs
+ */
+ if (safe_sprintf(ramfs_args, "maxsize=%u", (unsigned int) size)) {
+ fprintf(stderr, "ramfs_args too small\n");
+ return -1;
+ }
+ if (mount(NULL, CALLOUT_DIR, "ramfs", MS_SYNCHRONOUS, ramfs_args) < 0) {
+ syslog(LOG_ERR, "cannot mount ramfs on " CALLOUT_DIR);
+ return -1;
+ }
+ syslog(LOG_DEBUG, "mount ramfs on " CALLOUT_DIR);
+
+ /*
+ * populate the ramfs with callout binaries
+ */
+ vector_foreach_slot (binvec, bin,i) {
+ if (copytodir(bin, CALLOUT_DIR) < 0) {
+ syslog(LOG_ERR, "cannot copy %s in ramfs", bin);
+ exit_daemon(1);
+ }
+ syslog(LOG_DEBUG, "cp %s in ramfs", bin);
+ }
+ strvec_free(binvec);
+
+ /*
+ * bind the ramfs to :
+ * /sbin : default home of multipath ...
+ * /bin : default home of scsi_id ...
+ * /tmp : home of tools temp files
+ */
+ if (mount(CALLOUT_DIR, "/sbin", NULL, MS_BIND, NULL) < 0) {
+ syslog(LOG_ERR, "cannot bind ramfs on /sbin");
+ return -1;
+ }
+ syslog(LOG_DEBUG, "bind ramfs on /sbin");
+ if (mount(CALLOUT_DIR, "/bin", NULL, MS_BIND, NULL) < 0) {
+ syslog(LOG_ERR, "cannot bind ramfs on /bin");
+ return -1;
+ }
+ syslog(LOG_DEBUG, "bind ramfs on /bin");
+ if (mount(CALLOUT_DIR, "/tmp", NULL, MS_BIND, NULL) < 0) {
+ syslog(LOG_ERR, "cannot bind ramfs on /tmp");
+ return -1;
+ }
+ syslog(LOG_DEBUG, "bind ramfs on /tmp");
+
+ return 0;
+}
+#endif
+
+static void
+pidfile (pid_t pid)
+{
+ FILE *file;
+ struct stat *buf;
+
+ buf = MALLOC(sizeof(struct stat));
+
+ if (!stat(DEFAULT_PIDFILE, buf)) {
+ syslog(LOG_ERR, "already running : out");
+ FREE(buf);
+ exit(1);
+ }
+
+ umask(022);
+ pid = setsid();
+
+ if (pid < -1) {
+ syslog(LOG_ERR, "setsid() error");
+ exit(1);
+ }
+
+ file = fopen(DEFAULT_PIDFILE, "w");
+ fprintf(file, "%d\n", pid);
+ fclose(file);
+ FREE(buf);
+}
+
+static void *
+signal_set(int signo, void (*func) (int))
+{
+ int r;
+ struct sigaction sig;
+ struct sigaction osig;
+
+ sig.sa_handler = func;
+ sigemptyset(&sig.sa_mask);
+ sig.sa_flags = 0;
+
+ r = sigaction(signo, &sig, &osig);
+
+ if (r < 0)
+ return (SIG_ERR);
+ else
+ return (osig.sa_handler);
+}
+
+static void
+sighup (int sig)
+{
+ syslog(LOG_NOTICE, "SIGHUP received from multipath or operator");
+
+ /*
+ * signal updatepaths() that we come from SIGHUP
+ */
+ from_sighup = 1;
+
+ /*
+ * ask for allpaths refresh
+ */
+ pthread_mutex_lock (event_lock);
+ pthread_cond_signal(event);
+ pthread_mutex_unlock (event_lock);
+}
+
+static void
+sigend (int sig)
+{
+ exit_daemon(0);
+}
+
+static void
+signal_init(void)
+{
+ signal_set(SIGHUP, sighup);
+ signal_set(SIGINT, sigend);
+ signal_set(SIGTERM, sigend);
+ signal_set(SIGKILL, sigend);
+}
+
+static void
+setscheduler (void)
+{
+ int res;
+ static struct sched_param sched_param = {
+ sched_priority: 99
+ };
+
+ res = sched_setscheduler (0, SCHED_RR, &sched_param);
+
+ if (res == -1)
+ syslog(LOG_WARNING, "Could not set SCHED_RR at priority 99");
+ return;
+}
+
+static int
+child (void * param)
+{
+ pthread_t wait_thr, check_thr;
+ pthread_attr_t attr;
+ struct paths *allpaths;
+
+ openlog("multipathd", 0, LOG_DAEMON);
+ setlogmask(LOG_UPTO(LOGLEVEL));
+ syslog(LOG_NOTICE, "--------start up--------");
+
+ pidfile(getpid());
+ signal_init();
+ setscheduler();
+ allpaths = initpaths();
+ checkint = CHECKINT;
+
+ syslog(LOG_INFO, "read " DEFAULT_CONFIGFILE);
+ init_data(DEFAULT_CONFIGFILE, init_keywords);
+
+ /*
+ * fill the voids left in the config file
+ */
+ if (binvec == NULL) {
+ binvec = vector_alloc();
+ push_callout("/sbin/scsi_id");
+ }
+
+ if (multipath == NULL) {
+ multipath = MULTIPATH;
+ push_callout(multipath);
+ }
+
+ if (hwtable == NULL) {
+ hwtable = vector_alloc();
+ setup_default_hwtable(hwtable);
+ }
+
+ if (blist == NULL) {
+ blist = vector_alloc();
+ setup_default_blist(blist);
+ }
+
+#ifdef CLONE_NEWNS
+ if (prepare_namespace() < 0) {
+ syslog(LOG_ERR, "cannot prepare namespace");
+ exit_daemon(1);
+ }
+#endif
+
+ mlockall(MCL_CURRENT | MCL_FUTURE);
+ /*
+ * start threads
+ */
+ pthread_attr_init(&attr);
+ pthread_attr_setstacksize(&attr, 64 * 1024);
+
+ pthread_create(&wait_thr, &attr, waiterloop, allpaths);
+ pthread_create(&check_thr, &attr, checkerloop, allpaths);
+ pthread_join(wait_thr, NULL);
+ pthread_join(check_thr, NULL);
+
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ int err;
+ void * child_stack = (void *)malloc(CHILD_STACK_SIZE);
+
+#ifdef CLONE_NEWNS /* recent systems have clone() */
+
+# if defined(__hppa__) || defined(__powerpc64__)
+ err = clone(child, child_stack, CLONE_NEWNS, NULL);
+# elif defined(__ia64__)
+ err = clone2(child, child_stack,
+ CHILD_STACK_SIZE, CLONE_NEWNS, NULL,
+ NULL, NULL, NULL);
+# else
+ err = clone(child, child_stack + CHILD_STACK_SIZE, CLONE_NEWNS, NULL);
+# endif
+ if (err < 0)
+ exit (1);
+
+ exit(0);
+#else /* older system fallback to fork() */
+ err = fork();
+
+ if (err < 0)
+ exit (1);
+
+ return (child(child_stack));
+#endif
+
+}
Added: multipath-tools/upstream/current/multipathd/main.h
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipathd/main.h Fri Mar 4 08:05:19 2005
@@ -0,0 +1,14 @@
+#ifndef HWTABLE_H
+#define HWTABLE_H
+
+#define CHECKINT 5
+#define MULTIPATH "/sbin/multipath -v 0 -S"
+
+/* External vars */
+vector hwtable;
+vector blist;
+vector binvec;
+int checkint;
+char * multipath;
+
+#endif
Added: multipath-tools/upstream/current/multipathd/multipathd.8
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipathd/multipathd.8 Fri Mar 4 08:05:19 2005
@@ -0,0 +1,22 @@
+.TH MULTIPATHD 8 "October 2004" "Linux Administrator's Manual"
+.SH NAME
+multipathd \- multipath daemon
+.SH SYNOPSYS
+.B multipathd
+
+This daemon is in charge of checking for failed paths. When this happens,
+it will reconfigure the multipath map the path belongs to, so that this map
+regain its maximum performance and redundancy.
+
+This daemon executes the external multipath config tool when events occur.
+In turn, the multipath tool signals the multipathd daemon it is done with
+devmap reconfiguration, so that it can refresh its failed path list.
+
+.SH "SEE ALSO"
+.BR multipath (8)
+.BR kpartx (8)
+.BR hotplug (8)
+.SH "AUTHORS"
+This man page was assembled by Patrick Caulfield
+for the Debian project. From documentation provided
+by the multipath author Christophe Varoqui, <christophe.varoqui at free.fr> and others.
Added: multipath-tools/upstream/current/multipathd/multipathd.init
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/multipathd/multipathd.init Fri Mar 4 08:05:19 2005
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin
+DAEMON=/usr/bin/multipathd
+PIDFILE=/var/run/multipathd.pid
+
+test -x $DAEMON || exit 0
+
+case "$1" in
+ start)
+ echo -n "Starting multipath daemon: multipathd"
+ $DAEMON
+ echo "."
+ ;;
+ stop)
+ echo -n "Stopping multipath daemon: multipathd"
+ echo "."
+ if [ -f $PIDFILE ]
+ then
+ kill `cat $PIDFILE`
+ else
+ echo "multipathd not running: Nothing to stop..."
+ fi
+ ;;
+ force-reload|restart)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo "Usage: /etc/init.d/multipathd {start|stop|restart|force-reload}"
+ exit 1
+ ;;
+esac
+
+exit 0
Added: multipath-tools/upstream/current/path_priority/Makefile
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/path_priority/Makefile Fri Mar 4 08:05:19 2005
@@ -0,0 +1,55 @@
+# Makefile
+#
+# Copyright (C) 2003 Christophe Varoqui, <christophe.varoqui at free.fr>
+BUILD = glibc
+DEBUG = 0
+
+include ../Makefile.inc
+
+ifeq ($(strip $(BUILD)),klibc)
+ CFLAGS = ${REQFLAGS} ${OPTFLAGS} -I$(libdmdir) \
+ -I$(multipathdir) -DDEBUG=$(DEBUG)
+ OBJS = pp_balance_units.o $(DMLIB)-$(BUILD).a \
+ $(MULTIPATHLIB)-$(BUILD).a
+else
+ CFLAGS = -pipe -g -Wall -Wunused -Wstrict-prototypes \
+ -I$(multipathdir) -DDEBUG=$(DEBUG)
+ LDFLAGS = -ldevmapper
+ OBJS = pp_balance_units.o $(MULTIPATHLIB)-$(BUILD).a
+endif
+
+EXEC = pp_balance_units
+
+all: $(BUILD)
+
+prepare:
+ rm -f core *.o *.gz
+
+glibc: prepare $(OBJS)
+ $(CC) -o $(EXEC) $(OBJS) $(LDFLAGS)
+# $(STRIP) $(EXEC)
+
+klibc: prepare $(KLIBC) $(OBJS)
+ $(LD) -o $(EXEC) $(CRT0) $(OBJS) $(KLIBC) $(LIBGCC)
+ $(STRIP) $(EXEC)
+
+$(DMLIB)-$(BUILD).a:
+ make -C $(libdmdir) BUILD=$(BUILD) $(BUILD)
+
+$(MULTIPATHLIB)-$(BUILD).a:
+ make -C $(multipathdir) BUILD=$(BUILD) $(BUILD)
+
+$(KLIBC):
+ rm -f $(klibcdir)/linux
+ ln -s $(KERNEL_BUILD) $(klibcdir)/linux
+ make -C $(klibcdir)
+
+install:
+ install -d $(DESTDIR)$(bindir)
+ install -m 755 $(EXEC) $(DESTDIR)$(bindir)/
+
+uninstall:
+ rm $(DESTDIR)$(bindir)/$(EXEC)
+
+clean:
+ rm -f core *.o $(EXEC) *.gz
Added: multipath-tools/upstream/current/path_priority/pp_balance_units.c
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/path_priority/pp_balance_units.c Fri Mar 4 08:05:19 2005
@@ -0,0 +1,470 @@
+/*
+ * Christophe Varoqui (2004)
+ * This code is GPLv2, see license file
+ *
+ * This path prioritizer aims to balance logical units over all
+ * controlers available. The logic is :
+ *
+ * - list all paths in all primary path groups
+ * - for each path, get the controler's serial
+ * - compute the number of active paths attached to each controler
+ * - compute the max number of paths attached to the same controler
+ * - if sums are already balanced or if the path passed as parameter is
+ * attached to controler with less active paths, then return
+ * (max_path_attached_to_one_controler - number_of_paths_on_this_controler)
+ * - else, or if anything goes wrong, return 1 as a default prio
+ *
+ */
+#define __user
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <libdevmapper.h>
+#include <vector.h>
+#include <memory.h>
+
+#include <string.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <scsi/sg.h>
+
+#define SERIAL_SIZE 255
+#define WORD_SIZE 255
+#define PARAMS_SIZE 255
+#define FILE_NAME_SIZE 255
+#define INQUIRY_CMDLEN 6
+#define INQUIRY_CMD 0x12
+#define SENSE_BUFF_LEN 32
+#define DEF_TIMEOUT 60000
+#define RECOVERED_ERROR 0x01
+#define MX_ALLOC_LEN 255
+#define SCSI_CHECK_CONDITION 0x2
+#define SCSI_COMMAND_TERMINATED 0x22
+#define SG_ERR_DRIVER_SENSE 0x08
+
+#if DEBUG
+#define debug(format, arg...) fprintf(stderr, format "\n", ##arg)
+#else
+#define debug(format, arg...) do {} while(0)
+#endif
+
+#define safe_sprintf(var, format, args...) \
+ snprintf(var, sizeof(var), format, ##args) >= sizeof(var)
+#define safe_snprintf(var, size, format, args...) \
+ snprintf(var, size, format, ##args) >= size
+
+struct path {
+ char dev_t[WORD_SIZE];
+ char serial[SERIAL_SIZE];
+};
+
+struct controler {
+ char serial[SERIAL_SIZE];
+ int path_count;
+};
+
+static int
+exit_tool (int ret)
+{
+ printf("1\n");
+ exit(ret);
+}
+
+static int
+opennode (char * devt, int mode)
+{
+ char devpath[FILE_NAME_SIZE];
+ unsigned int major;
+ unsigned int minor;
+ int fd;
+
+ sscanf(devt, "%u:%u", &major, &minor);
+ memset(devpath, 0, FILE_NAME_SIZE);
+
+ if (safe_sprintf(devpath, "/tmp/.pp_balance.%u.%u.devnode",
+ major, minor)) {
+ fprintf(stderr, "devpath too small\n");
+ return -1;
+ }
+ unlink (devpath);
+ mknod(devpath, S_IFBLK|S_IRUSR|S_IWUSR, makedev(major, minor));
+ fd = open(devpath, mode);
+
+ if (fd < 0)
+ unlink(devpath);
+
+ return fd;
+
+}
+
+static void
+closenode (char * devt, int fd)
+{
+ char devpath[FILE_NAME_SIZE];
+ unsigned int major;
+ unsigned int minor;
+
+ if (fd >= 0)
+ close(fd);
+
+ sscanf(devt, "%u:%u", &major, &minor);
+ if (safe_sprintf(devpath, "/tmp/.pp_balance.%u.%u.devnode",
+ major, minor)) {
+ fprintf(stderr, "devpath too small\n");
+ return;
+ }
+ unlink(devpath);
+}
+
+static int
+do_inq(int sg_fd, int cmddt, int evpd, unsigned int pg_op,
+ void *resp, int mx_resp_len, int noisy)
+{
+ unsigned char inqCmdBlk[INQUIRY_CMDLEN] =
+ { INQUIRY_CMD, 0, 0, 0, 0, 0 };
+ unsigned char sense_b[SENSE_BUFF_LEN];
+ struct sg_io_hdr io_hdr;
+
+ if (cmddt)
+ inqCmdBlk[1] |= 2;
+ if (evpd)
+ inqCmdBlk[1] |= 1;
+ inqCmdBlk[2] = (unsigned char) pg_op;
+ inqCmdBlk[3] = (unsigned char)((mx_resp_len >> 8) & 0xff);
+ inqCmdBlk[4] = (unsigned char) (mx_resp_len & 0xff);
+ memset(&io_hdr, 0, sizeof (struct sg_io_hdr));
+ io_hdr.interface_id = 'S';
+ io_hdr.cmd_len = sizeof (inqCmdBlk);
+ io_hdr.mx_sb_len = sizeof (sense_b);
+ io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
+ io_hdr.dxfer_len = mx_resp_len;
+ io_hdr.dxferp = resp;
+ io_hdr.cmdp = inqCmdBlk;
+ io_hdr.sbp = sense_b;
+ io_hdr.timeout = DEF_TIMEOUT;
+
+ if (ioctl(sg_fd, SG_IO, &io_hdr) < 0)
+ return -1;
+
+ /* treat SG_ERR here to get rid of sg_err.[ch] */
+ io_hdr.status &= 0x7e;
+ if ((0 == io_hdr.status) && (0 == io_hdr.host_status) &&
+ (0 == io_hdr.driver_status))
+ return 0;
+ if ((SCSI_CHECK_CONDITION == io_hdr.status) ||
+ (SCSI_COMMAND_TERMINATED == io_hdr.status) ||
+ (SG_ERR_DRIVER_SENSE == (0xf & io_hdr.driver_status))) {
+ if (io_hdr.sbp && (io_hdr.sb_len_wr > 2)) {
+ int sense_key;
+ unsigned char * sense_buffer = io_hdr.sbp;
+ if (sense_buffer[0] & 0x2)
+ sense_key = sense_buffer[1] & 0xf;
+ else
+ sense_key = sense_buffer[2] & 0xf;
+ if(RECOVERED_ERROR == sense_key)
+ return 0;
+ }
+ }
+ return -1;
+}
+
+static int
+get_serial (char * str, char * devt)
+{
+ int fd;
+ int len;
+ char buff[MX_ALLOC_LEN + 1];
+
+ fd = opennode(devt, O_RDONLY);
+
+ if (fd < 0)
+ return 0;
+
+ if (0 == do_inq(fd, 0, 1, 0x80, buff, MX_ALLOC_LEN, 0)) {
+ len = buff[3];
+ if (len > 0) {
+ memcpy(str, buff + 4, len);
+ buff[len] = '\0';
+ }
+ close(fd);
+ return 1;
+ }
+
+ closenode(devt, fd);
+ return 0;
+}
+
+static void *
+get_params (void)
+{
+ struct dm_task *dmt, *dmt1;
+ struct dm_names *names = NULL;
+ unsigned next = 0;
+ void *nexttgt;
+ uint64_t start, length;
+ char *target_type = NULL;
+ char *params;
+ char *pp;
+ vector paramsvec = NULL;
+
+ if (!(dmt = dm_task_create(DM_DEVICE_LIST)))
+ return NULL;
+
+ if (!dm_task_run(dmt))
+ goto out;
+
+ if (!(names = dm_task_get_names(dmt)))
+ goto out;
+
+ if (!names->dev) {
+ debug("no devmap found");
+ goto out;
+ }
+ do {
+ /*
+ * keep only multipath maps
+ */
+ names = (void *) names + next;
+ nexttgt = NULL;
+ debug("devmap %s :", names->name);
+
+ if (!(dmt1 = dm_task_create(DM_DEVICE_TABLE)))
+ goto out;
+
+ if (!dm_task_set_name(dmt1, names->name))
+ goto out1;
+
+ if (!dm_task_run(dmt1))
+ goto out1;
+
+ do {
+ nexttgt = dm_get_next_target(dmt1, nexttgt,
+ &start,
+ &length,
+ &target_type,
+ ¶ms);
+ debug("\\_ %lu %lu %s", (unsigned long) start,
+ (unsigned long) length,
+ target_type);
+
+ if (!target_type) {
+ debug("unknown target type");
+ goto out1;
+ }
+
+ if (!strncmp(target_type, "multipath", 9)) {
+ if (!paramsvec)
+ paramsvec = vector_alloc();
+
+ pp = malloc(PARAMS_SIZE);
+ strncpy(pp, params, PARAMS_SIZE);
+ vector_alloc_slot(paramsvec);
+ vector_set_slot(paramsvec, pp);
+ } else
+ debug("skip non multipath target");
+ } while (nexttgt);
+out1:
+ dm_task_destroy(dmt1);
+ next = names->next;
+ } while (next);
+out:
+ dm_task_destroy(dmt);
+ return paramsvec;
+}
+
+static int
+get_word (char *sentence, char *word)
+{
+ char *p;
+ int skip = 0;
+
+ while (*sentence == ' ') {
+ sentence++;
+ skip++;
+ }
+ p = sentence;
+
+ while (*p != ' ' && *p != '\0')
+ p++;
+
+ skip += (p - sentence);
+
+ if (p - sentence > WORD_SIZE) {
+ fprintf(stderr, "word too small\n");
+ exit_tool(1);
+ }
+ strncpy(word, sentence, WORD_SIZE);
+ word += p - sentence;
+ *word = '\0';
+
+ if (*p == '\0')
+ return 0;
+
+ return skip;
+}
+
+static int
+is_path (char * word)
+{
+ char *p;
+
+ if (!word)
+ return 0;
+
+ p = word;
+
+ while (*p != '\0') {
+ if (*p == ':')
+ return 1;
+ p++;
+ }
+ return 0;
+}
+
+static int
+get_paths (vector pathvec)
+{
+ vector paramsvec = NULL;
+ char * str;
+ struct path * pp;
+ int i;
+ enum where {BEFOREPG, INPG, AFTERPG};
+ int pos = BEFOREPG;
+
+ if (!pathvec)
+ return 1;
+
+ if (!(paramsvec = get_params()))
+ exit_tool(0);
+
+ vector_foreach_slot (paramsvec, str, i) {
+ debug("params %s", str);
+ while (pos != AFTERPG) {
+ pp = zalloc(sizeof(struct path));
+ str += get_word(str, pp->dev_t);
+
+ if (!is_path(pp->dev_t)) {
+ free(pp);
+
+ if (pos == INPG)
+ pos = AFTERPG;
+
+ continue;
+ }
+ if (pos == BEFOREPG)
+ pos = INPG;
+
+ get_serial(pp->serial, pp->dev_t);
+ vector_alloc_slot(pathvec);
+ vector_set_slot(pathvec, pp);
+ debug("store %s [%s]",
+ pp->dev_t, pp->serial);
+ }
+ pos = BEFOREPG;
+ }
+ return 0;
+}
+
+static void *
+find_controler (vector controlers, char * serial)
+{
+ int i;
+ struct controler * cp;
+
+ if (!controlers)
+ return NULL;
+
+ vector_foreach_slot (controlers, cp, i)
+ if (!strncmp(cp->serial, serial, SERIAL_SIZE))
+ return cp;
+ return NULL;
+}
+
+static void
+get_controlers (vector controlers, vector pathvec)
+{
+ int i;
+ struct path * pp;
+ struct controler * cp;
+
+ if (!controlers)
+ return;
+
+ vector_foreach_slot (pathvec, pp, i) {
+ if (!pp || !strlen(pp->serial))
+ continue;
+
+ cp = find_controler(controlers, pp->serial);
+
+ if (!cp) {
+ cp = zalloc(sizeof(struct controler));
+ vector_alloc_slot(controlers);
+ vector_set_slot(controlers, cp);
+ strncpy(cp->serial, pp->serial, SERIAL_SIZE);
+ }
+ cp->path_count++;
+ }
+}
+
+static int
+get_max_path_count (vector controlers)
+{
+ int i;
+ int max = 0;
+ struct controler * cp;
+
+ if (!controlers)
+ return 0;
+
+ vector_foreach_slot (controlers, cp, i) {
+ debug("controler %s : %i paths", cp->serial, cp->path_count);
+ if(cp->path_count > max)
+ max = cp->path_count;
+ }
+ debug("max_path_count = %i", max);
+ return max;
+}
+
+int
+main (int argc, char **argv)
+{
+ vector pathvec = NULL;
+ vector controlers = NULL;
+ struct path * ref_path = NULL;
+ struct controler * cp = NULL;
+ int max_path_count = 0;
+
+ ref_path = zalloc(sizeof(struct path));
+
+ if (!ref_path)
+ exit_tool(1);
+
+ if (argc != 2)
+ exit_tool(1);
+
+ if (optind<argc)
+ strncpy(ref_path->dev_t, argv[optind], WORD_SIZE);
+
+ get_serial(ref_path->serial, ref_path->dev_t);
+
+ if (!ref_path->serial || !strlen(ref_path->serial))
+ exit_tool(0);
+
+ pathvec = vector_alloc();
+ controlers = vector_alloc();
+
+ get_paths(pathvec);
+ get_controlers(controlers, pathvec);
+ max_path_count = get_max_path_count(controlers);
+ cp = find_controler(controlers, ref_path->serial);
+
+ if (!cp)
+ exit_tool(1);
+
+ printf("%i\n", max_path_count - cp->path_count + 1);
+
+ return(0);
+}
Added: multipath-tools/upstream/current/path_priority/pp_random
==============================================================================
--- (empty file)
+++ multipath-tools/upstream/current/path_priority/pp_random Fri Mar 4 08:05:19 2005
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo $RANDOM
More information about the pkg-lvm-commits
mailing list